The camera spring-arm sweep already resolves the collided eye's cell (ResolveResult.CellId = sp.CurCellId = retail viewer_cell = sphere_path.curr_cell, update_viewer pc:92871). Return it from SweepEye so the render can root on the viewer cell (Phase W single-viewpoint V1, Task 1). Pure plumbing — behavior unchanged; callers extract .Eye. 174 App tests green. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
44 lines
1.5 KiB
C#
44 lines
1.5 KiB
C#
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.Eye);
|
|
Assert.Equal(0u, result.ViewerCellId); // cellId==0 → returned unchanged
|
|
}
|
|
}
|