]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Tweak sun shadow rotations (#35758)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Mon, 10 Mar 2025 04:38:33 +0000 (15:38 +1100)
committerGitHub <noreply@github.com>
Mon, 10 Mar 2025 04:38:33 +0000 (15:38 +1100)
Won't use the entity's rotation for the matrix, I just forgot to do this. Means shadows will always point in the same direction and the points will correctly adjust as the entity rotates.

Content.Client/Light/SunShadowOverlay.cs

index 38bb9276764a272e72d4ccf29a3f9565fb4fff8f..a296f95479f8ece5b93480fb910d73a28e54a585 100644 (file)
@@ -114,7 +114,9 @@ public sealed class SunShadowOverlay : Overlay
                     foreach (var ent in _shadows)
                     {
                         var xform = _entManager.GetComponent<TransformComponent>(ent.Owner);
-                        var worldMatrix = _xformSys.GetWorldMatrix(xform);
+                        var (worldPos, worldRot) = _xformSys.GetWorldPositionRotation(xform);
+                        // Need no rotation on matrix as sun shadow direction doesn't care.
+                        var worldMatrix = Matrix3x2.CreateTranslation(worldPos);
                         var renderMatrix = Matrix3x2.Multiply(worldMatrix, invMatrix);
                         var pointCount = ent.Comp.Points.Length;
 
@@ -122,6 +124,10 @@ public sealed class SunShadowOverlay : Overlay
 
                         for (var i = 0; i < pointCount; i++)
                         {
+                            // Update point based on entity rotation.
+                            indices[i] = worldRot.RotateVec(indices[i]);
+
+                            // Add the offset point by the sun shadow direction.
                             indices[pointCount + i] = indices[i] + direction;
                         }