Add light helper functions

This commit is contained in:
Jarrod Doyle 2024-12-23 17:57:36 +00:00
parent bf47578133
commit 010757eb6f
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 24 additions and 0 deletions

View File

@ -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) public float StrengthAtPoint(Vector3 point, Plane plane)
{ {
// Calculate light strength at a given point. As far as I can tell // Calculate light strength at a given point. As far as I can tell