feat(render): Phase A8.F — PhysicsCameraCollisionProbe (swept-sphere eye via ResolveWithTransition)
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
69c7f8db86
commit
376e2c3578
3 changed files with 124 additions and 0 deletions
|
|
@ -0,0 +1,43 @@
|
|||
using System.Numerics;
|
||||
using AcDream.App.Rendering;
|
||||
using AcDream.Core.Physics;
|
||||
using Xunit;
|
||||
|
||||
namespace AcDream.App.Tests.Rendering;
|
||||
|
||||
public class PhysicsCameraCollisionProbeTests
|
||||
{
|
||||
// The probe must convert the desired eye path (where the SPHERE CENTER
|
||||
// should travel) into the foot-capsule path InitPath expects (which offsets
|
||||
// sphere0 up by radius), then invert it on the result. Verify the round trip.
|
||||
[Fact]
|
||||
public void SpherePathOffset_RoundTrips()
|
||||
{
|
||||
var p = new Vector3(10f, 20f, 30f);
|
||||
const float r = 0.3f;
|
||||
|
||||
var path = PhysicsCameraCollisionProbe.ToSpherePath(p, r);
|
||||
Assert.Equal(p.Z - r, path.Z, 5);
|
||||
Assert.Equal(p.X, path.X, 5);
|
||||
Assert.Equal(p.Y, path.Y, 5);
|
||||
|
||||
var back = PhysicsCameraCollisionProbe.FromSpherePath(path, r);
|
||||
Assert.Equal(p.X, back.X, 5);
|
||||
Assert.Equal(p.Y, back.Y, 5);
|
||||
Assert.Equal(p.Z, back.Z, 5);
|
||||
}
|
||||
|
||||
// cellId == 0 means "no starting cell" — the probe must short-circuit and
|
||||
// return the desired eye without touching the engine.
|
||||
[Fact]
|
||||
public void SweepEye_NoStartingCell_ReturnsDesiredEyeUnchanged()
|
||||
{
|
||||
var probe = new PhysicsCameraCollisionProbe(new PhysicsEngine());
|
||||
var pivot = new Vector3(0f, 0f, 1.5f);
|
||||
var eye = new Vector3(-2f, 0f, 2.2f);
|
||||
|
||||
var result = probe.SweepEye(pivot, eye, cellId: 0, selfEntityId: 0);
|
||||
|
||||
Assert.Equal(eye, result);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue