Added ADDLIGHTLEVEL to add the sector light level to an actor's own defined light level, if desired.

This commit is contained in:
Major Cooke 2022-05-31 13:47:10 -05:00 committed by Christoph Oelckers
parent 9ef202db26
commit 3d14cec191
4 changed files with 23 additions and 3 deletions

View File

@ -427,6 +427,7 @@ enum ActorFlag8
MF8_SEEFRIENDLYMONSTERS = 0X08000000, // [inkoalawetrust] Hostile monster can see friendly monsters. MF8_SEEFRIENDLYMONSTERS = 0X08000000, // [inkoalawetrust] Hostile monster can see friendly monsters.
MF8_CROSSLINECHECK = 0x10000000, // [MC]Enables CanCrossLine virtual MF8_CROSSLINECHECK = 0x10000000, // [MC]Enables CanCrossLine virtual
MF8_MASTERNOSEE = 0x20000000, // Don't show object in first person if their master is the current camera. MF8_MASTERNOSEE = 0x20000000, // Don't show object in first person if their master is the current camera.
MF8_ADDLIGHTLEVEL = 0x40000000, // [MC] Actor light level is additive with sector.
}; };
// --- mobj.renderflags --- // --- mobj.renderflags ---

View File

@ -997,7 +997,7 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
// light calculation // light calculation
bool enhancedvision = false; bool enhancedvision = false;
bool UseActorLight = (thing->LightLevel > -1); const bool UseActorLight = (thing->LightLevel > -1);
// allow disabling of the fullbright flag by a brightmap definition // allow disabling of the fullbright flag by a brightmap definition
// (e.g. to do the gun flashes of Doom's zombies correctly. // (e.g. to do the gun flashes of Doom's zombies correctly.
@ -1006,12 +1006,22 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t
if (fullbright) lightlevel = 255; if (fullbright) lightlevel = 255;
else if (UseActorLight) else if (UseActorLight)
lightlevel = thing->LightLevel; {
int newlevel = thing->LightLevel;
if (thing->flags8 & MF8_ADDLIGHTLEVEL)
{
newlevel += hw_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ?
rendersector->GetCeilingLight() : rendersector->GetFloorLight());
newlevel = clamp(newlevel, 0, 255);
}
lightlevel = newlevel;
}
else else
lightlevel = hw_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ? lightlevel = hw_ClampLight(rendersector->GetTexture(sector_t::ceiling) == skyflatnum ?
rendersector->GetCeilingLight() : rendersector->GetFloorLight()); rendersector->GetCeilingLight() : rendersector->GetFloorLight());
foglevel = (uint8_t)clamp<short>((UseActorLight) ? thing->LightLevel : rendersector->lightlevel, 0, 255); foglevel = (uint8_t)clamp<short>((UseActorLight) ? lightlevel : rendersector->lightlevel, 0, 255);
lightlevel = rendersector->CheckSpriteGlow(lightlevel, thingpos); lightlevel = rendersector->CheckSpriteGlow(lightlevel, thingpos);

View File

@ -956,7 +956,15 @@ namespace swrenderer
thingColormap = GetSpriteColorTable(thing->Sector->Colormap, thing->Sector->SpecialColors[sector_t::sprites], nc); thingColormap = GetSpriteColorTable(thing->Sector->Colormap, thing->Sector->SpecialColors[sector_t::sprites], nc);
} }
if (thing->LightLevel > -1) if (thing->LightLevel > -1)
{
thinglightlevel = thing->LightLevel; thinglightlevel = thing->LightLevel;
if (thing->flags8 & MF8_ADDLIGHTLEVEL)
{
thinglightlevel += thing->Sector->GetTexture(sector_t::ceiling) == skyflatnum ? thing->Sector->GetCeilingLight() : thing->Sector->GetFloorLight();
thinglightlevel = clamp(thinglightlevel, 0, 255);
}
}
if ((sprite.renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE) if ((sprite.renderflags & RF_SPRITETYPEMASK) == RF_WALLSPRITE)
{ {
RenderWallSprite::Project(Thread, thing, sprite.pos, sprite.tex, sprite.spriteScale, sprite.renderflags, thinglightlevel, foggy, thingColormap); RenderWallSprite::Project(Thread, thing, sprite.pos, sprite.tex, sprite.spriteScale, sprite.renderflags, thinglightlevel, foggy, thingColormap);

View File

@ -342,6 +342,7 @@ static FFlagDef ActorFlagDefs[]=
DEFINE_FLAG(MF8, SEEFRIENDLYMONSTERS, AActor, flags8), DEFINE_FLAG(MF8, SEEFRIENDLYMONSTERS, AActor, flags8),
DEFINE_FLAG(MF8, CROSSLINECHECK, AActor, flags8), DEFINE_FLAG(MF8, CROSSLINECHECK, AActor, flags8),
DEFINE_FLAG(MF8, MASTERNOSEE, AActor, flags8), DEFINE_FLAG(MF8, MASTERNOSEE, AActor, flags8),
DEFINE_FLAG(MF8, ADDLIGHTLEVEL, AActor, flags8),
// Effect flags // Effect flags
DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects), DEFINE_FLAG(FX, VISIBILITYPULSE, AActor, effects),