Work around an issue with far plane clipping with voxels without mipmaps in software mode

Patch from Nuke.YKT.

git-svn-id: https://svn.eduke32.com/eduke32@7869 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
terminx 2019-08-01 06:50:37 +00:00 committed by Christoph Oelckers
parent 9335b339b0
commit a949665f26

View file

@ -4725,7 +4725,7 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int
int8_t dashade, char dapal, const int32_t *daumost, const int32_t *dadmost, int8_t dashade, char dapal, const int32_t *daumost, const int32_t *dadmost,
const int8_t cstat, const int32_t clipcf, int32_t floorz, int32_t ceilingz) const int8_t cstat, const int32_t clipcf, int32_t floorz, int32_t ceilingz)
{ {
int32_t i, j, k, x, y; int32_t i, j, k, x, y, mip;
int32_t cosang = cosglobalang; int32_t cosang = cosglobalang;
int32_t sinang = singlobalang; int32_t sinang = singlobalang;
@ -4737,7 +4737,7 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int
setupdrawslab(ylookup[1], FP_OFF(palookup[dapal])+j); setupdrawslab(ylookup[1], FP_OFF(palookup[dapal])+j);
j = 1310720; j = 1310720;
j *= min(daxscale,dayscale); j >>= 6; //New hacks (for sized-down voxels) //j *= min(daxscale,dayscale); j >>= 6; //New hacks (for sized-down voxels)
for (k=0; k<MAXVOXMIPS; k++) for (k=0; k<MAXVOXMIPS; k++)
{ {
if (i < j) { i = k; break; } if (i < j) { i = k; break; }
@ -4746,11 +4746,16 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int
if (k >= MAXVOXMIPS) if (k >= MAXVOXMIPS)
i = MAXVOXMIPS-1; i = MAXVOXMIPS-1;
mip = 0;
if (novoxmips) if (novoxmips)
{
mip = i;
i = 0; i = 0;
}
char *davoxptr = (char *)voxoff[daindex][i]; char *davoxptr = (char *)voxoff[daindex][i];
if (!davoxptr && i > 0) { davoxptr = (char *)voxoff[daindex][0]; i = 0; } if (!davoxptr && i > 0) { davoxptr = (char *)voxoff[daindex][0]; mip = i; i = 0;}
if (!davoxptr) if (!davoxptr)
return; return;
@ -4791,6 +4796,9 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int
cosang <<= 2; cosang <<= 2;
sinang <<= 2; sinang <<= 2;
cosang >>= mip;
sinang >>= mip;
const voxint_t gxstart = (voxint_t)y*cosang - (voxint_t)x*sinang; const voxint_t gxstart = (voxint_t)y*cosang - (voxint_t)x*sinang;
const voxint_t gystart = (voxint_t)x*cosang + (voxint_t)y*sinang; const voxint_t gystart = (voxint_t)x*cosang + (voxint_t)y*sinang;
const int32_t gxinc = dmulscale10(sprsinang,cosang, sprcosang,-sinang); const int32_t gxinc = dmulscale10(sprsinang,cosang, sprcosang,-sinang);
@ -4966,10 +4974,10 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int
rx -= lx; rx -= lx;
const int32_t l1 = mulscale12(distrecip[clamp((ny-yoff)>>14, 1, DISTRECIPSIZ-1)], dayscale); const int32_t l1 = mulscale(distrecip[clamp((ny-yoff)>>14, 1, DISTRECIPSIZ-1)], dayscale, 12+mip);
// FIXME! AMCTC RC2/beta shotgun voxel // FIXME! AMCTC RC2/beta shotgun voxel
// (e.g. training map right after M16 shooting): // (e.g. training map right after M16 shooting):
const int32_t l2 = mulscale12(distrecip[clamp((ny+yoff)>>14, 1, DISTRECIPSIZ-1)], dayscale); const int32_t l2 = mulscale(distrecip[clamp((ny+yoff)>>14, 1, DISTRECIPSIZ-1)], dayscale, 12+mip);
int32_t cz1 = 0, cz2 = INT32_MAX; int32_t cz1 = 0, cz2 = INT32_MAX;
if (clipcf) if (clipcf)