force updated lights to ignore actor trace cache

This commit is contained in:
Ricardo Luís Vaz Silva 2024-12-20 01:19:22 -03:00 committed by Magnus Norddahl
commit af5497c6dd
3 changed files with 18 additions and 11 deletions

View file

@ -421,17 +421,22 @@ void FDynamicLight::Tick()
lightStrength = LightCalcStrength(m_currentRadius);
}
bool updated = UpdateLocation();
updated = UpdateLocation();
if(!updated && markTiles && (m_active != wasactive || oldred != GetRed() || oldblue != GetBlue() || oldgreen != GetGreen() || oldradius != m_currentRadius))
if(!updated && (m_active != wasactive || oldred != GetRed() || oldblue != GetBlue() || oldgreen != GetGreen() || oldradius != m_currentRadius))
{
MarkTilesForUpdate(Level, touching_sides, touching_sector);
if(markTiles)
{
MarkTilesForUpdate(Level, touching_sides, touching_sector);
}
wasactive = m_active;
oldred = GetRed();
oldblue = GetBlue();
oldgreen = GetGreen();
updated = true;
}
wasactive = m_active;
oldred = GetRed();
oldblue = GetBlue();
oldgreen = GetGreen();
}

View file

@ -300,6 +300,8 @@ public:
bool swapped;
bool explicitpitch;
bool updated;
int oldred, oldgreen, oldblue;
float lightStrength;

View file

@ -60,13 +60,13 @@ public:
}
}
bool TraceLightVisbility(FLightNode* node, const FVector3& L, float dist)
bool TraceLightVisbility(FLightNode* node, const FVector3& L, float dist, bool ignoreCache)
{
FDynamicLight* light = node->lightsource;
if (!light->TraceActors() || !level.levelMesh || !Actor)
return true;
if (!ActorMoved && CurrentBit < 64)
if (!ignoreCache && !ActorMoved && CurrentBit < 64)
{
bool traceResult = (Actor->StaticLightsTraceCache.Bits >> CurrentBit) & 1;
CurrentBit++;
@ -176,7 +176,7 @@ void HWDrawInfo::GetDynSpriteLight(AActor *self, float x, float y, float z, FLig
if (light->IsSpot() || light->Trace())
L *= -1.0f / dist;
if (staticLight.TraceLightVisbility(node, L, dist))
if (staticLight.TraceLightVisbility(node, L, dist, light->updated))
{
if(level.info->lightattenuationmode == ELightAttenuationMode::INVERSE_SQUARE)
{
@ -299,7 +299,7 @@ void hw_GetDynModelLight(HWDrawContext* drawctx, AActor *self, FDynLightData &mo
if (light->Trace())
L *= 1.0f / dist;
if (staticLight.TraceLightVisbility(node, L, dist))
if (staticLight.TraceLightVisbility(node, L, dist, light->updated))
{
AddLightToList(modellightdata, group, light, true);
}