Handle dynamic lights correctly

This commit is contained in:
Jarrod Doyle 2025-01-11 17:57:52 +00:00
parent a0790f50bd
commit 5beba9f9f4
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
3 changed files with 7 additions and 5 deletions

View File

@ -690,13 +690,13 @@ public class WorldRep : IChunk
if (dynamicLight)
{
DynamicLightCount++;
Lights.Add(data);
}
else
{
Lights.Insert(LightCount, data);
LightCount++;
}
Lights.Add(data);
}
}

View File

@ -21,6 +21,7 @@ public class Light
public int ObjId;
public int LightTableIndex;
public bool Anim;
public bool Dynamic;
public WorldRep.LightTable.LightData ToLightData(float lightScale)
{

View File

@ -293,7 +293,7 @@ public class LightMapper
}
}
if (propAnimLight != null && !propAnimLight.Dynamic)
if (propAnimLight != null)
{
var lightIndex = lightTable.LightCount;
propAnimLight.LightTableLightIndex = (ushort)lightIndex;
@ -310,6 +310,7 @@ public class LightMapper
ObjId = id,
LightTableIndex = propAnimLight.LightTableLightIndex,
Anim = true,
Dynamic = propAnimLight.Dynamic,
SpotlightInnerAngle = -1f,
};
@ -324,7 +325,7 @@ public class LightMapper
light.ApplyTransforms(vhotLightPos, vhotLightDir, translate, rotate, scale);
_lights.Add(light);
lightTable.AddLight(light.ToLightData(32.0f));
lightTable.AddLight(light.ToLightData(32.0f), propAnimLight.Dynamic);
}
if (propLight != null && propLight.Brightness != 0)
@ -486,7 +487,7 @@ public class LightMapper
for (var j = 0; j < _lights.Count; j++)
{
var light = _lights[j];
if (!MathUtils.Intersects(new MathUtils.Sphere(light.Position, light.Radius), cellAabb))
if (light.Dynamic || !MathUtils.Intersects(new MathUtils.Sphere(light.Position, light.Radius), cellAabb))
{
continue;
}