Handle object lights with radius 0

This commit is contained in:
Jarrod Doyle 2024-09-23 18:08:21 +01:00
parent 63133da6a4
commit e004292e53
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 19 additions and 10 deletions

View File

@ -1,4 +1,4 @@
using System.Numerics; using System.Numerics;
using KeepersCompound.LGS.Database; using KeepersCompound.LGS.Database;
using KeepersCompound.LGS.Database.Chunks; using KeepersCompound.LGS.Database.Chunks;
using TinyEmbree; using TinyEmbree;
@ -108,19 +108,28 @@ class Program
else if (brush.media == BrList.Brush.Media.Object) else if (brush.media == BrList.Brush.Media.Object)
{ {
var id = (int)brush.brushInfo; var id = (int)brush.brushInfo;
var light = hierarchy.GetProperty<PropLight>(id, "P$Light"); var propLight = hierarchy.GetProperty<PropLight>(id, "P$Light");
var lightColor = hierarchy.GetProperty<PropLightColor>(id, "P$LightColo"); var propLightColor = hierarchy.GetProperty<PropLightColor>(id, "P$LightColo");
if (light != null) if (propLight != null)
{ {
lightColor ??= new PropLightColor { Hue = 0, Saturation = 0 }; propLightColor ??= new PropLightColor { Hue = 0, Saturation = 0 };
lights.Add(new Light
var light = new Light
{ {
position = brush.position, position = brush.position,
color = HsbToRgb(lightColor.Hue, lightColor.Saturation, light.Brightness), color = HsbToRgb(propLightColor.Hue, propLightColor.Saturation, propLight.Brightness),
radius = light.Radius, radius = propLight.Radius,
r2 = light.Radius * light.Radius, r2 = propLight.Radius * propLight.Radius,
}); };
if (propLight.Radius == 0)
{
light.radius = float.MaxValue;
light.r2 = float.MaxValue;
}
lights.Add(light);
} }
} }
} }