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" — retail update_viewer snaps the viewer // to the player position (set_viewer(player_pos), viewer_cell = null; pc:92775), // so the probe must short-circuit to playerPos without touching the engine. [Fact] public void SweepEye_NoStartingCell_SnapsToPlayer() { var probe = new PhysicsCameraCollisionProbe(new PhysicsEngine()); var pivot = new Vector3(0f, 0f, 1.5f); var eye = new Vector3(-2f, 0f, 2.2f); var player = new Vector3(0f, 0f, 0f); var result = probe.SweepEye(pivot, eye, cellId: 0, selfEntityId: 0, playerPos: player); Assert.Equal(player, result.Eye); Assert.Equal(0u, result.ViewerCellId); // cellId==0 → snap to player, null viewer cell } }