mirror of
https://github.com/ZDoom/qzdoom-gpl.git
synced 2025-02-20 18:32:06 +00:00
Simplify CalcTiltedLighting in hope that this function is what made GCC break
This commit is contained in:
parent
b4b391c51e
commit
8bd0df1ace
1 changed files with 14 additions and 84 deletions
|
@ -2818,100 +2818,30 @@ namespace swrenderer
|
||||||
|
|
||||||
// Calculates the lighting for one row of a tilted plane. If the definition
|
// Calculates the lighting for one row of a tilted plane. If the definition
|
||||||
// of GETPALOOKUP changes, this needs to change, too.
|
// of GETPALOOKUP changes, this needs to change, too.
|
||||||
void DrawTiltedSpanPalCommand::CalcTiltedLighting(double lval, double lend, int width, DrawerThread *thread)
|
void DrawTiltedSpanPalCommand::CalcTiltedLighting(double lstart, double lend, int width, DrawerThread *thread)
|
||||||
{
|
{
|
||||||
const uint8_t **tiltlighting = thread->tiltlighting;
|
const uint8_t **tiltlighting = thread->tiltlighting;
|
||||||
|
|
||||||
double lstep;
|
uint8_t *lightstart = basecolormapdata + (GETPALOOKUP(lstart, planeshade) << COLORMAPSHIFT);
|
||||||
uint8_t *lightfiller = nullptr;
|
uint8_t *lightend = basecolormapdata + (GETPALOOKUP(lend, planeshade) << COLORMAPSHIFT);
|
||||||
int i = 0;
|
|
||||||
|
|
||||||
if (width == 0 || lval == lend)
|
if (width == 0 || lightstart == lightend)
|
||||||
{ // Constant lighting
|
{
|
||||||
lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT);
|
for (int i = 0; i <= width; i++)
|
||||||
|
{
|
||||||
|
tiltlighting[i] = lightstart;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lstep = (lend - lval) / width;
|
double lstep = (lend - lstart) / width;
|
||||||
if (lval >= MAXLIGHTVIS)
|
double lval = lstart;
|
||||||
{ // lval starts "too bright".
|
for (int i = 0; i <= width; i++)
|
||||||
lightfiller = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT);
|
|
||||||
for (; i <= width && lval >= MAXLIGHTVIS; ++i)
|
|
||||||
{
|
|
||||||
tiltlighting[i] = lightfiller;
|
|
||||||
lval += lstep;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (lend >= MAXLIGHTVIS)
|
|
||||||
{ // lend ends "too bright".
|
|
||||||
lightfiller = basecolormapdata + (GETPALOOKUP(lend, planeshade) << COLORMAPSHIFT);
|
|
||||||
for (; width > i && lend >= MAXLIGHTVIS; --width)
|
|
||||||
{
|
|
||||||
tiltlighting[width] = lightfiller;
|
|
||||||
lend -= lstep;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (width > 0)
|
|
||||||
{
|
{
|
||||||
lval = FIXED2DBL(planeshade) - lval;
|
tiltlighting[i] = basecolormapdata + (GETPALOOKUP(lval, planeshade) << COLORMAPSHIFT);
|
||||||
lend = FIXED2DBL(planeshade) - lend;
|
lval += lstep;
|
||||||
lstep = (lend - lval) / width;
|
|
||||||
if (lstep < 0)
|
|
||||||
{ // Going from dark to light
|
|
||||||
if (lval < 1.)
|
|
||||||
{ // All bright
|
|
||||||
lightfiller = basecolormapdata;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (lval >= NUMCOLORMAPS)
|
|
||||||
{ // Starts beyond the dark end
|
|
||||||
uint8_t *clight = basecolormapdata + ((NUMCOLORMAPS - 1) << COLORMAPSHIFT);
|
|
||||||
while (lval >= NUMCOLORMAPS && i <= width)
|
|
||||||
{
|
|
||||||
tiltlighting[i++] = clight;
|
|
||||||
lval += lstep;
|
|
||||||
}
|
|
||||||
if (i > width)
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while (i <= width && lval >= 0)
|
|
||||||
{
|
|
||||||
tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT);
|
|
||||||
lval += lstep;
|
|
||||||
}
|
|
||||||
lightfiller = basecolormapdata;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{ // Going from light to dark
|
|
||||||
if (lval >= (NUMCOLORMAPS - 1))
|
|
||||||
{ // All dark
|
|
||||||
lightfiller = basecolormapdata + ((NUMCOLORMAPS - 1) << COLORMAPSHIFT);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
while (lval < 0 && i <= width)
|
|
||||||
{
|
|
||||||
tiltlighting[i++] = basecolormapdata;
|
|
||||||
lval += lstep;
|
|
||||||
}
|
|
||||||
if (i > width)
|
|
||||||
return;
|
|
||||||
while (i <= width && lval < (NUMCOLORMAPS - 1))
|
|
||||||
{
|
|
||||||
tiltlighting[i++] = basecolormapdata + (xs_ToInt(lval) << COLORMAPSHIFT);
|
|
||||||
lval += lstep;
|
|
||||||
}
|
|
||||||
lightfiller = basecolormapdata + ((NUMCOLORMAPS - 1) << COLORMAPSHIFT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (; i <= width; i++)
|
|
||||||
{
|
|
||||||
tiltlighting[i] = lightfiller;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in a new issue