Test AnimParamMath.PlanarForward (enemy facing-from-rotation)
+4 EditMode cases (identity/yaw-180/pitched-degenerate/normalized) for the helper the enemy animation drive uses to derive facing from the replicated LocalTransform.Rotation. EditMode suite 204 -> 208, all green. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -73,5 +73,32 @@ namespace ProjectM.Tests
|
||||
Assert.IsFalse(float.IsNaN(r.x) || float.IsNaN(r.y) || float.IsNaN(r.z));
|
||||
Assert.AreEqual(1f, r.z, Eps); // clamps to 1
|
||||
}
|
||||
|
||||
// ---- PlanarForward (enemy facing from replicated LocalTransform.Rotation) ----
|
||||
|
||||
[Test] public void PlanarForward_Identity_IsWorldForward()
|
||||
{
|
||||
var f = AnimParamMath.PlanarForward(quaternion.identity);
|
||||
Assert.AreEqual(0f, f.x, Eps); Assert.AreEqual(1f, f.y, Eps);
|
||||
}
|
||||
|
||||
[Test] public void PlanarForward_Yaw180_IsBackward()
|
||||
{
|
||||
var f = AnimParamMath.PlanarForward(quaternion.RotateY(math.radians(180f)));
|
||||
Assert.AreEqual(0f, f.x, Eps); Assert.AreEqual(-1f, f.y, Eps);
|
||||
}
|
||||
|
||||
[Test] public void PlanarForward_PitchedToVertical_FallsBackToWorldForward()
|
||||
{
|
||||
// forward rotated to point straight down -> planar XZ ~ 0 -> degenerate fallback (0,1).
|
||||
var f = AnimParamMath.PlanarForward(quaternion.RotateX(math.radians(90f)));
|
||||
Assert.AreEqual(0f, f.x, Eps); Assert.AreEqual(1f, f.y, Eps);
|
||||
}
|
||||
|
||||
[Test] public void PlanarForward_IsNormalized()
|
||||
{
|
||||
var f = AnimParamMath.PlanarForward(quaternion.RotateY(math.radians(37f)));
|
||||
Assert.AreEqual(1f, math.length(f), Eps);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user