- properly track whether some action in the current frame may have triggered a dynamic light activation.

This commit is contained in:
Christoph Oelckers 2021-09-21 20:31:10 +02:00
parent da806b354d
commit 6c12a8de12
6 changed files with 30 additions and 4 deletions

View file

@ -260,6 +260,7 @@ enum ELevelFlags : unsigned int
LEVEL3_NOSHADOWMAP = 0x00010000, // disables shadowmaps for a given level. LEVEL3_NOSHADOWMAP = 0x00010000, // disables shadowmaps for a given level.
LEVEL3_AVOIDMELEE = 0x00020000, // global flag needed for proper MBF support. LEVEL3_AVOIDMELEE = 0x00020000, // global flag needed for proper MBF support.
LEVEL3_NOJUMPDOWN = 0x00040000, // only for MBF21. Inverse of MBF's dog_jumping flag. LEVEL3_NOJUMPDOWN = 0x00040000, // only for MBF21. Inverse of MBF's dog_jumping flag.
LEVEL3_LIGHTCREATED = 0x00080000, // a light had been created in the last frame
}; };

View file

@ -598,6 +598,9 @@ void P_SetupLevel(FLevelLocals *Level, int position, bool newGame)
auto it = Level->GetThinkerIterator<AActor>(); auto it = Level->GetThinkerIterator<AActor>();
AActor* ac; AActor* ac;
Level->flags3 |= LEVEL3_LIGHTCREATED;
// Initial setup of the dynamic lights. // Initial setup of the dynamic lights.
while ((ac = it.Next())) while ((ac = it.Next()))
{ {

View file

@ -850,6 +850,7 @@ int AttachLightDef(AActor *self, int _lightid, int _lightname)
auto userlight = self->UserLights[FindUserLight(self, lightid, true)]; auto userlight = self->UserLights[FindUserLight(self, lightid, true)];
userlight->CopyFrom(*LightDefaults[lightdef]); userlight->CopyFrom(*LightDefaults[lightdef]);
self->flags8 |= MF8_RECREATELIGHTS; self->flags8 |= MF8_RECREATELIGHTS;
self->Level->flags3 |= LEVEL3_LIGHTCREATED;
return 1; return 1;
} }
return 0; return 0;
@ -894,6 +895,7 @@ int AttachLightDirect(AActor *self, int _lightid, int type, int color, int radiu
userlight->UnsetSpotPitch(); userlight->UnsetSpotPitch();
} }
self->flags8 |= MF8_RECREATELIGHTS; self->flags8 |= MF8_RECREATELIGHTS;
self->Level->flags3 |= LEVEL3_LIGHTCREATED;
return 1; return 1;
} }
@ -931,6 +933,7 @@ int RemoveLight(AActor *self, int _lightid)
delete self->UserLights[userlight]; delete self->UserLights[userlight];
self->UserLights.Delete(userlight); self->UserLights.Delete(userlight);
self->flags8 |= MF8_RECREATELIGHTS; self->flags8 |= MF8_RECREATELIGHTS;
self->Level->flags3 |= LEVEL3_LIGHTCREATED;
return 1; return 1;
} }
return 0; return 0;

View file

@ -144,8 +144,9 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level)
} }
} while (count != 0); } while (count != 0);
if (Level->HasDynamicLights) if (Level->lights || (Level->flags3 & LEVEL3_LIGHTCREATED))
{ {
Level->flags3 &= ~LEVEL3_LIGHTCREATED;
recreateLights(); recreateLights();
for (auto light = Level->lights; light;) for (auto light = Level->lights; light;)
{ {
@ -174,8 +175,9 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level)
} }
} while (count != 0); } while (count != 0);
if (Level->lights && Level->HasDynamicLights) if (Level->lights || (Level->flags3 & LEVEL3_LIGHTCREATED))
{ {
Level->flags3 &= ~LEVEL3_LIGHTCREATED;
recreateLights(); recreateLights();
// Also profile the internal dynamic lights, even though they are not implemented as thinkers. // Also profile the internal dynamic lights, even though they are not implemented as thinkers.
auto &prof = Profiles[NAME_InternalDynamicLight]; auto &prof = Profiles[NAME_InternalDynamicLight];

View file

@ -584,7 +584,11 @@ bool AActor::SetState (FState *newstate, bool nofunction)
newstate = newstate->GetNextState(); newstate = newstate->GetNextState();
} while (tics == 0); } while (tics == 0);
if (GetInfo()->LightAssociations.Size())
{
flags8 |= MF8_RECREATELIGHTS; flags8 |= MF8_RECREATELIGHTS;
Level->flags3 |= LEVEL3_LIGHTCREATED;
}
return true; return true;
} }
@ -4799,7 +4803,11 @@ void AActor::PostBeginPlay ()
{ {
PrevAngles = Angles; PrevAngles = Angles;
flags7 |= MF7_HANDLENODELAY; flags7 |= MF7_HANDLENODELAY;
if (GetInfo()->LightAssociations.Size())
{
flags8 |= MF8_RECREATELIGHTS; flags8 |= MF8_RECREATELIGHTS;
Level->flags3 |= LEVEL3_LIGHTCREATED;
}
} }
void AActor::CallPostBeginPlay() void AActor::CallPostBeginPlay()

View file

@ -1333,6 +1333,15 @@ enum ELevelFlags
LEVEL3_HIDEAUTHORNAME = 0x00000100, LEVEL3_HIDEAUTHORNAME = 0x00000100,
LEVEL3_PROPERMONSTERFALLINGDAMAGE = 0x00000200, // Properly apply falling damage to the monsters LEVEL3_PROPERMONSTERFALLINGDAMAGE = 0x00000200, // Properly apply falling damage to the monsters
LEVEL3_SKYBOXAO = 0x00000400, // Apply SSAO to sector skies LEVEL3_SKYBOXAO = 0x00000400, // Apply SSAO to sector skies
LEVEL3_E1M8SPECIAL = 0x00000800,
LEVEL3_E2M8SPECIAL = 0x00001000,
LEVEL3_E3M8SPECIAL = 0x00002000,
LEVEL3_E4M8SPECIAL = 0x00004000,
LEVEL3_E4M6SPECIAL = 0x00008000,
LEVEL3_NOSHADOWMAP = 0x00010000, // disables shadowmaps for a given level.
LEVEL3_AVOIDMELEE = 0x00020000, // global flag needed for proper MBF support.
LEVEL3_NOJUMPDOWN = 0x00040000, // only for MBF21. Inverse of MBF's dog_jumping flag.
LEVEL3_LIGHTCREATED = 0x00080000, // a light had been created in the last frame
}; };
// [RH] Compatibility flags. // [RH] Compatibility flags.