Merge branch 'mi-side-discolor-fix' into 'master'

MI's side discolor fix

See merge request STJr/SRB2!475
This commit is contained in:
Monster Iestyn 2019-03-26 09:43:20 -04:00
commit 7758b28164

View file

@ -862,16 +862,18 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
leftheight -= viewz; leftheight -= viewz;
rightheight -= viewz; rightheight -= viewz;
#define OVERFLOWTEST(height, scale) \ #define CLAMPMAX INT32_MAX
overflow_test = (INT64)centeryfrac - (((INT64)height*scale)>>FRACBITS); \ #define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out.
if (overflow_test < 0) overflow_test = -overflow_test; \ // Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave.
if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) continue; overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS);
if (overflow_test > (INT64)CLAMPMAX) rlight->height = CLAMPMAX;
else if (overflow_test > (INT64)CLAMPMIN) rlight->height = (fixed_t)overflow_test;
else rlight->height = CLAMPMIN;
OVERFLOWTEST(leftheight, ds->scale1) overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS);
OVERFLOWTEST(rightheight, ds->scale2) if (overflow_test > (INT64)CLAMPMAX) rlight->heightstep = CLAMPMAX;
else if (overflow_test > (INT64)CLAMPMIN) rlight->heightstep = (fixed_t)overflow_test;
rlight->height = (centeryfrac) - FixedMul(leftheight, ds->scale1); else rlight->heightstep = CLAMPMIN;
rlight->heightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2);
rlight->heightstep = (rlight->heightstep-rlight->height)/(range); rlight->heightstep = (rlight->heightstep-rlight->height)/(range);
#else #else
if (light->height < *pfloor->bottomheight) if (light->height < *pfloor->bottomheight)
@ -893,12 +895,16 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
leftheight -= viewz; leftheight -= viewz;
rightheight -= viewz; rightheight -= viewz;
OVERFLOWTEST(leftheight, ds->scale1) // Monster Iestyn (25/03/18): do not skip these lights if they fail overflow test, just clamp them instead so they behave.
OVERFLOWTEST(rightheight, ds->scale2) overflow_test = (INT64)centeryfrac - (((INT64)leftheight*ds->scale1)>>FRACBITS);
#undef OVERFLOWTEST if (overflow_test > (INT64)CLAMPMAX) rlight->botheight = CLAMPMAX;
else if (overflow_test > (INT64)CLAMPMIN) rlight->botheight = (fixed_t)overflow_test;
else rlight->botheight = CLAMPMIN;
rlight->botheight = (centeryfrac) - FixedMul(leftheight, ds->scale1); overflow_test = (INT64)centeryfrac - (((INT64)rightheight*ds->scale2)>>FRACBITS);
rlight->botheightstep = (centeryfrac) - FixedMul(rightheight, ds->scale2); if (overflow_test > (INT64)CLAMPMAX) rlight->botheightstep = CLAMPMAX;
else if (overflow_test > (INT64)CLAMPMIN) rlight->botheightstep = (fixed_t)overflow_test;
else rlight->botheightstep = CLAMPMIN;
rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range); rlight->botheightstep = (rlight->botheightstep-rlight->botheight)/(range);
#else #else
lheight = *light->caster->bottomheight;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : *light->caster->bottomheight; lheight = *light->caster->bottomheight;// > *pfloor->topheight ? *pfloor->topheight + FRACUNIT : *light->caster->bottomheight;
@ -1071,9 +1077,6 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor)
} }
#endif #endif
#define CLAMPMAX INT32_MAX
#define CLAMPMIN (-INT32_MAX) // This is not INT32_MIN on purpose! INT32_MIN makes the drawers freak out.
// draw the columns // draw the columns
for (dc_x = x1; dc_x <= x2; dc_x++) for (dc_x = x1; dc_x <= x2; dc_x++)
{ {