From 010757eb6ffce4643a9e2964b4ac4777137576ce Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Mon, 23 Dec 2024 17:57:36 +0000 Subject: [PATCH] Add light helper functions --- KeepersCompound.Lightmapper/Light.cs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/KeepersCompound.Lightmapper/Light.cs b/KeepersCompound.Lightmapper/Light.cs index cb7523a..f74dbe8 100644 --- a/KeepersCompound.Lightmapper/Light.cs +++ b/KeepersCompound.Lightmapper/Light.cs @@ -35,6 +35,30 @@ public class Light }; } + public void FixRadius() + { + if (Radius == 0) + { + Radius = float.MaxValue; + R2 = float.MaxValue; + } + } + + public void ApplyTransforms( + Vector3 vhotLightPos, + Vector3 vhotLightDir, + Matrix4x4 translate, + Matrix4x4 rotate, + Matrix4x4 scale) + { + var transform = scale * rotate * translate; + vhotLightPos = Vector3.Transform(vhotLightPos, transform); + vhotLightDir = Vector3.Transform(vhotLightDir, transform); + + Position = Vector3.Transform(Position, rotate) + vhotLightPos; + SpotlightDir = Vector3.Normalize(vhotLightDir - vhotLightPos); + } + public float StrengthAtPoint(Vector3 point, Plane plane) { // Calculate light strength at a given point. As far as I can tell