mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
Under conditions of CLASSIC_Z_DIFF_64 (r4960), make some drawvox() vars 64-bit.
- In drawvox(), make view-relative x and y high-precision on desktops. To a large extent (but not completely), this fixes "stray" fake floor shadow sprites for voxels. - In the mouse picking code for voxels, fix a possible integer overflow. A new engine.c-private function mulscale_triple30() is added. DONT_BUILD. git-svn-id: https://svn.eduke32.com/eduke32@5017 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
326ba366e9
commit
a1a79b001e
1 changed files with 23 additions and 8 deletions
|
@ -64,6 +64,7 @@ L_State g_engState;
|
||||||
|
|
||||||
#if !defined EDUKE32_TOUCH_DEVICES && !defined GEKKO && !defined __OPENDINGUX__
|
#if !defined EDUKE32_TOUCH_DEVICES && !defined GEKKO && !defined __OPENDINGUX__
|
||||||
// Handle absolute z difference of floor/ceiling to camera >= 1<<24.
|
// Handle absolute z difference of floor/ceiling to camera >= 1<<24.
|
||||||
|
// Also: higher precision view-relative x and y for drawvox().
|
||||||
# define CLASSIC_Z_DIFF_64
|
# define CLASSIC_Z_DIFF_64
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3357,6 +3358,12 @@ static inline void wallmosts_finish(int16_t *mostbuf, int32_t z1, int32_t z2,
|
||||||
#ifdef CLASSIC_Z_DIFF_64
|
#ifdef CLASSIC_Z_DIFF_64
|
||||||
typedef int64_t zint_t;
|
typedef int64_t zint_t;
|
||||||
|
|
||||||
|
// For drawvox()
|
||||||
|
static inline zint_t mulscale16z(int32_t a, int32_t d)
|
||||||
|
{
|
||||||
|
return ((zint_t)a * d)>>16;
|
||||||
|
}
|
||||||
|
|
||||||
static inline zint_t mulscale20z(int32_t a, int32_t d)
|
static inline zint_t mulscale20z(int32_t a, int32_t d)
|
||||||
{
|
{
|
||||||
return ((zint_t)a * d)>>20;
|
return ((zint_t)a * d)>>20;
|
||||||
|
@ -3368,6 +3375,7 @@ static inline zint_t dmulscale24z(int32_t a, int32_t d, int32_t S, int32_t D)
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
typedef int32_t zint_t;
|
typedef int32_t zint_t;
|
||||||
|
# define mulscale16z mulscale16
|
||||||
# define mulscale20z mulscale20
|
# define mulscale20z mulscale20
|
||||||
# define dmulscale24z dmulscale24
|
# define dmulscale24z dmulscale24
|
||||||
#endif
|
#endif
|
||||||
|
@ -5392,6 +5400,8 @@ static void drawalls(int32_t bunch)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// High-precision integer type for view-relative x and y in drawvox().
|
||||||
|
typedef zint_t voxint_t;
|
||||||
|
|
||||||
//
|
//
|
||||||
// drawvox
|
// drawvox
|
||||||
|
@ -5466,8 +5476,8 @@ static void drawvox(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasp
|
||||||
cosang = mulscale16(cosang, dayscalerecip);
|
cosang = mulscale16(cosang, dayscalerecip);
|
||||||
sinang = mulscale16(sinang, dayscalerecip);
|
sinang = mulscale16(sinang, dayscalerecip);
|
||||||
|
|
||||||
const int32_t gxstart = y*cosang - x*sinang;
|
const voxint_t gxstart = (voxint_t)y*cosang - (voxint_t)x*sinang;
|
||||||
const int32_t gystart = x*cosang + 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);
|
||||||
const int32_t gyinc = dmulscale10(sprcosang,cosang, sprsinang,sinang);
|
const int32_t gyinc = dmulscale10(sprcosang,cosang, sprsinang,sinang);
|
||||||
|
|
||||||
|
@ -5577,16 +5587,16 @@ static void drawvox(int32_t dasprx, int32_t daspry, int32_t dasprz, int32_t dasp
|
||||||
const int32_t nxoff = mulscale16(x2-x1,viewingrangerecip);
|
const int32_t nxoff = mulscale16(x2-x1,viewingrangerecip);
|
||||||
x1 = mulscale16(x1, viewingrangerecip);
|
x1 = mulscale16(x1, viewingrangerecip);
|
||||||
|
|
||||||
const int32_t ggxstart = gxstart + ggyinc[ys];
|
const voxint_t ggxstart = gxstart + ggyinc[ys];
|
||||||
const int32_t ggystart = gystart - ggxinc[ys];
|
const voxint_t ggystart = gystart - ggxinc[ys];
|
||||||
|
|
||||||
for (x=xs; x!=xe; x+=xi)
|
for (x=xs; x!=xe; x+=xi)
|
||||||
{
|
{
|
||||||
const intptr_t slabxoffs = (intptr_t)&davoxptr[B_LITTLE32(longptr[x])];
|
const intptr_t slabxoffs = (intptr_t)&davoxptr[B_LITTLE32(longptr[x])];
|
||||||
int16_t *const shortptr = (int16_t *)&davoxptr[((x*(daysiz+1))<<1) + xyvoxoffs];
|
int16_t *const shortptr = (int16_t *)&davoxptr[((x*(daysiz+1))<<1) + xyvoxoffs];
|
||||||
|
|
||||||
int32_t nx = mulscale16(ggxstart+ggxinc[x], viewingrangerecip) + x1;
|
voxint_t nx = mulscale16z(ggxstart+ggxinc[x], viewingrangerecip) + x1;
|
||||||
int32_t ny = ggystart + ggyinc[x];
|
voxint_t ny = ggystart + ggyinc[x];
|
||||||
|
|
||||||
for (y=ys; y!=ye; y+=yi,nx+=dagyinc,ny-=dagxinc)
|
for (y=ys; y!=ye; y+=yi,nx+=dagyinc,ny-=dagxinc)
|
||||||
{
|
{
|
||||||
|
@ -5778,6 +5788,11 @@ static uint8_t falpha_to_blend(float alpha, int32_t *cstatptr, int32_t transbit1
|
||||||
return blendidx;
|
return blendidx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline int32_t mulscale_triple30(int32_t a, int32_t b, int32_t c)
|
||||||
|
{
|
||||||
|
return ((int64_t)a * b * c)>>30;
|
||||||
|
}
|
||||||
|
|
||||||
static void drawsprite_classic(int32_t snum)
|
static void drawsprite_classic(int32_t snum)
|
||||||
{
|
{
|
||||||
int32_t x1, y1, x2, y2, i, j, k, x;
|
int32_t x1, y1, x2, y2, i, j, k, x;
|
||||||
|
@ -6788,8 +6803,8 @@ draw_as_face_sprite:
|
||||||
const int32_t xspan = ((B_LITTLE32(longptr[0])+B_LITTLE32(longptr[1]))>>1);
|
const int32_t xspan = ((B_LITTLE32(longptr[0])+B_LITTLE32(longptr[1]))>>1);
|
||||||
const int32_t yspan = B_LITTLE32(longptr[2]);
|
const int32_t yspan = B_LITTLE32(longptr[2]);
|
||||||
|
|
||||||
const int32_t xsiz = mulscale30(siz,xv*xspan);
|
const int32_t xsiz = mulscale_triple30(siz, xv, xspan);
|
||||||
const int32_t ysiz = mulscale30(siz,nyrepeat*yspan);
|
const int32_t ysiz = mulscale_triple30(siz, nyrepeat, yspan);
|
||||||
|
|
||||||
//Watch out for divscale overflow
|
//Watch out for divscale overflow
|
||||||
if (((xspan>>11) < xsiz) && (yspan < (ysiz>>1)))
|
if (((xspan>>11) < xsiz) && (yspan < (ysiz>>1)))
|
||||||
|
|
Loading…
Reference in a new issue