mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-22 11:41:08 +00:00
- the rest of light.cpp
This commit is contained in:
parent
2aba992d63
commit
6d7337e41b
1 changed files with 47 additions and 52 deletions
|
@ -37,51 +37,50 @@ BEGIN_SW_NS
|
||||||
void SectorLightShade(DSWActor* actor, short intensity)
|
void SectorLightShade(DSWActor* actor, short intensity)
|
||||||
{
|
{
|
||||||
auto u = actor->hasU()? actor->u() : nullptr;
|
auto u = actor->hasU()? actor->u() : nullptr;
|
||||||
auto sp = &actor->s();
|
|
||||||
int8_t* wall_shade;
|
int8_t* wall_shade;
|
||||||
short base_shade;
|
short base_shade;
|
||||||
|
|
||||||
if (TEST_BOOL8(sp))
|
if (TEST_BOOL8(actor))
|
||||||
intensity = -intensity;
|
intensity = -intensity;
|
||||||
|
|
||||||
if (!TEST_BOOL2(sp))
|
if (!TEST_BOOL2(actor))
|
||||||
{
|
{
|
||||||
if (!TEST_BOOL6(sp))
|
if (!TEST_BOOL6(actor))
|
||||||
sp->sector()->floorpal = sp->pal;
|
actor->spr.sector()->floorpal = actor->spr.pal;
|
||||||
sp->sector()->floorshade = LIGHT_FloorShade(actor) + intensity; // floor change
|
actor->spr.sector()->floorshade = LIGHT_FloorShade(actor) + intensity; // floor change
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TEST_BOOL3(sp))
|
if (!TEST_BOOL3(actor))
|
||||||
{
|
{
|
||||||
if (!TEST_BOOL6(sp))
|
if (!TEST_BOOL6(actor))
|
||||||
sp->sector()->ceilingpal = sp->pal;
|
actor->spr.sector()->ceilingpal = actor->spr.pal;
|
||||||
sp->sector()->ceilingshade = LIGHT_CeilingShade(actor) + intensity; // ceiling change
|
actor->spr.sector()->ceilingshade = LIGHT_CeilingShade(actor) + intensity; // ceiling change
|
||||||
}
|
}
|
||||||
|
|
||||||
// change wall
|
// change wall
|
||||||
if (!TEST_BOOL4(sp))
|
if (!TEST_BOOL4(actor))
|
||||||
{
|
{
|
||||||
ASSERT(u && u->WallShade.Data());
|
ASSERT(u && u->WallShade.Data());
|
||||||
wall_shade = u->WallShade.Data();
|
wall_shade = u->WallShade.Data();
|
||||||
int wallcount = 0;
|
int wallcount = 0;
|
||||||
|
|
||||||
for(auto &wal : wallsofsector(sp->sector()))
|
for(auto &wal : wallsofsector(actor->spr.sector()))
|
||||||
{
|
{
|
||||||
base_shade = wall_shade[wallcount];
|
base_shade = wall_shade[wallcount];
|
||||||
wal.shade = base_shade + intensity;
|
wal.shade = base_shade + intensity;
|
||||||
if (!TEST_BOOL6(sp))
|
if (!TEST_BOOL6(actor))
|
||||||
wal.pal = sp->pal;
|
wal.pal = actor->spr.pal;
|
||||||
wallcount++;
|
wallcount++;
|
||||||
|
|
||||||
if (TEST(sp->extra, SPRX_BOOL5))
|
if (TEST(actor->spr.extra, SPRX_BOOL5))
|
||||||
{
|
{
|
||||||
if (wal.twoSided())
|
if (wal.twoSided())
|
||||||
{
|
{
|
||||||
auto nextWall = wal.nextWall();
|
auto nextWall = wal.nextWall();
|
||||||
base_shade = wall_shade[wallcount];
|
base_shade = wall_shade[wallcount];
|
||||||
nextWall->shade = base_shade + intensity;
|
nextWall->shade = base_shade + intensity;
|
||||||
if (!TEST_BOOL6(sp))
|
if (!TEST_BOOL6(actor))
|
||||||
nextWall->pal = sp->pal;
|
nextWall->pal = actor->spr.pal;
|
||||||
wallcount++;
|
wallcount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -92,7 +91,6 @@ void SectorLightShade(DSWActor* actor, short intensity)
|
||||||
|
|
||||||
void DiffuseLighting(DSWActor* actor)
|
void DiffuseLighting(DSWActor* actor)
|
||||||
{
|
{
|
||||||
auto sp = &actor->s();
|
|
||||||
int i;
|
int i;
|
||||||
short count;
|
short count;
|
||||||
short shade;
|
short shade;
|
||||||
|
@ -107,13 +105,13 @@ void DiffuseLighting(DSWActor* actor)
|
||||||
if (LIGHT_Match(itActor) != LIGHT_Match(actor))
|
if (LIGHT_Match(itActor) != LIGHT_Match(actor))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
shade = sp->shade + ((LIGHT_DiffuseNum(itActor) + 1) * LIGHT_DiffuseMult(itActor));
|
shade = actor->spr.shade + ((LIGHT_DiffuseNum(itActor) + 1) * LIGHT_DiffuseMult(itActor));
|
||||||
|
|
||||||
if (shade > LIGHT_MaxDark(actor))
|
if (shade > LIGHT_MaxDark(actor))
|
||||||
shade = LIGHT_MaxDark(actor);
|
shade = LIGHT_MaxDark(actor);
|
||||||
|
|
||||||
if (!TEST_BOOL6(itActor))
|
if (!TEST_BOOL6(itActor))
|
||||||
itActor->spr.pal = sp->pal;
|
itActor->spr.pal = actor->spr.pal;
|
||||||
|
|
||||||
SectorLightShade(itActor, shade);
|
SectorLightShade(itActor, shade);
|
||||||
|
|
||||||
|
@ -257,16 +255,13 @@ void InitLighting(void)
|
||||||
|
|
||||||
void DoLighting(void)
|
void DoLighting(void)
|
||||||
{
|
{
|
||||||
SPRITEp sp;
|
|
||||||
|
|
||||||
SWStatIterator it(STAT_LIGHTING);
|
SWStatIterator it(STAT_LIGHTING);
|
||||||
while (auto itActor = it.Next())
|
while (auto itActor = it.Next())
|
||||||
{
|
{
|
||||||
auto u = itActor->u();
|
auto u = itActor->u();
|
||||||
sp = &itActor->s();
|
|
||||||
|
|
||||||
// on/off test
|
// on/off test
|
||||||
if (TEST_BOOL1(sp) == OFF)
|
if (TEST_BOOL1(itActor) == OFF)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
switch (LIGHT_Type(itActor))
|
switch (LIGHT_Type(itActor))
|
||||||
|
@ -283,19 +278,19 @@ void DoLighting(void)
|
||||||
|
|
||||||
if ((RANDOM_P2(128 << 8) >> 8) > 64)
|
if ((RANDOM_P2(128 << 8) >> 8) > 64)
|
||||||
{
|
{
|
||||||
sp->shade = -LIGHT_MaxBright(itActor) + RandomRange(LIGHT_MaxBright(itActor) + LIGHT_MaxDark(itActor));
|
itActor->spr.shade = -LIGHT_MaxBright(itActor) + RandomRange(LIGHT_MaxBright(itActor) + LIGHT_MaxDark(itActor));
|
||||||
SectorLightShade(itActor, sp->shade);
|
SectorLightShade(itActor, itActor->spr.shade);
|
||||||
DiffuseLighting(itActor);
|
DiffuseLighting(itActor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// turn off lighting - even colored lighting
|
// turn off lighting - even colored lighting
|
||||||
auto spal = sp->pal;
|
auto spal = itActor->spr.pal;
|
||||||
sp->pal = 0;
|
itActor->spr.pal = 0;
|
||||||
sp->shade = LIGHT_MaxDark(itActor);
|
itActor->spr.shade = LIGHT_MaxDark(itActor);
|
||||||
SectorLightShade(itActor, sp->shade);
|
SectorLightShade(itActor, itActor->spr.shade);
|
||||||
DiffuseLighting(itActor);
|
DiffuseLighting(itActor);
|
||||||
sp->pal = spal;
|
itActor->spr.pal = spal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,18 +306,18 @@ void DoLighting(void)
|
||||||
|
|
||||||
if (LIGHT_Dir(itActor) == 1)
|
if (LIGHT_Dir(itActor) == 1)
|
||||||
{
|
{
|
||||||
sp->shade += LIGHT_ShadeInc(itActor);
|
itActor->spr.shade += LIGHT_ShadeInc(itActor);
|
||||||
if (sp->shade >= LIGHT_MaxDark(itActor))
|
if (itActor->spr.shade >= LIGHT_MaxDark(itActor))
|
||||||
LIGHT_DirChange(itActor);
|
LIGHT_DirChange(itActor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sp->shade -= LIGHT_ShadeInc(itActor);
|
itActor->spr.shade -= LIGHT_ShadeInc(itActor);
|
||||||
if (sp->shade <= -LIGHT_MaxBright(itActor))
|
if (itActor->spr.shade <= -LIGHT_MaxBright(itActor))
|
||||||
LIGHT_DirChange(itActor);
|
LIGHT_DirChange(itActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
SectorLightShade(itActor, sp->shade);
|
SectorLightShade(itActor, itActor->spr.shade);
|
||||||
DiffuseLighting(itActor);
|
DiffuseLighting(itActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,10 +333,10 @@ void DoLighting(void)
|
||||||
|
|
||||||
if (LIGHT_Dir(itActor) == 1)
|
if (LIGHT_Dir(itActor) == 1)
|
||||||
{
|
{
|
||||||
sp->shade += LIGHT_ShadeInc(itActor);
|
itActor->spr.shade += LIGHT_ShadeInc(itActor);
|
||||||
if (sp->shade >= LIGHT_MaxDark(itActor))
|
if (itActor->spr.shade >= LIGHT_MaxDark(itActor))
|
||||||
{
|
{
|
||||||
sp->pal = 0; // off
|
itActor->spr.pal = 0; // off
|
||||||
LIGHT_DirChange(itActor);
|
LIGHT_DirChange(itActor);
|
||||||
// stop it until switch is hit
|
// stop it until switch is hit
|
||||||
RESET_BOOL1(itActor);
|
RESET_BOOL1(itActor);
|
||||||
|
@ -349,9 +344,9 @@ void DoLighting(void)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sp->shade -= LIGHT_ShadeInc(itActor);
|
itActor->spr.shade -= LIGHT_ShadeInc(itActor);
|
||||||
sp->pal = u->spal; // on
|
itActor->spr.pal = u->spal; // on
|
||||||
if (sp->shade <= -LIGHT_MaxBright(itActor))
|
if (itActor->spr.shade <= -LIGHT_MaxBright(itActor))
|
||||||
{
|
{
|
||||||
LIGHT_DirChange(itActor);
|
LIGHT_DirChange(itActor);
|
||||||
// stop it until switch is hit
|
// stop it until switch is hit
|
||||||
|
@ -359,7 +354,7 @@ void DoLighting(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SectorLightShade(itActor, sp->shade);
|
SectorLightShade(itActor, itActor->spr.shade);
|
||||||
DiffuseLighting(itActor);
|
DiffuseLighting(itActor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,26 +370,26 @@ void DoLighting(void)
|
||||||
|
|
||||||
if ((RANDOM_P2(128 << 8) >> 8) > 64)
|
if ((RANDOM_P2(128 << 8) >> 8) > 64)
|
||||||
{
|
{
|
||||||
sp->shade = -LIGHT_MaxBright(itActor) + RandomRange(LIGHT_MaxBright(itActor) + LIGHT_MaxDark(itActor));
|
itActor->spr.shade = -LIGHT_MaxBright(itActor) + RandomRange(LIGHT_MaxBright(itActor) + LIGHT_MaxDark(itActor));
|
||||||
SectorLightShade(itActor, sp->shade);
|
SectorLightShade(itActor, itActor->spr.shade);
|
||||||
DiffuseLighting(itActor);
|
DiffuseLighting(itActor);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// turn off lighting - even colored lighting
|
// turn off lighting - even colored lighting
|
||||||
auto spal = sp->pal;
|
auto spal = itActor->spr.pal;
|
||||||
sp->pal = 0;
|
itActor->spr.pal = 0;
|
||||||
sp->shade = LIGHT_MaxDark(itActor);
|
itActor->spr.shade = LIGHT_MaxDark(itActor);
|
||||||
SectorLightShade(itActor, sp->shade);
|
SectorLightShade(itActor, itActor->spr.shade);
|
||||||
DiffuseLighting(itActor);
|
DiffuseLighting(itActor);
|
||||||
sp->pal = spal;
|
itActor->spr.pal = spal;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((RANDOM_P2(128 << 8) >> 8) < 8)
|
if ((RANDOM_P2(128 << 8) >> 8) < 8)
|
||||||
{
|
{
|
||||||
// set to full brightness
|
// set to full brightness
|
||||||
sp->shade = -LIGHT_MaxBright(itActor);
|
itActor->spr.shade = -LIGHT_MaxBright(itActor);
|
||||||
SectorLightShade(itActor, sp->shade);
|
SectorLightShade(itActor, itActor->spr.shade);
|
||||||
DiffuseLighting(itActor);
|
DiffuseLighting(itActor);
|
||||||
// turn it off until a swith happens
|
// turn it off until a swith happens
|
||||||
RESET_BOOL1(itActor);
|
RESET_BOOL1(itActor);
|
||||||
|
|
Loading…
Reference in a new issue