Complete Render Residual A's faithful port: PhysicsCameraCollisionProbe.SweepEye now mirrors SmartBox::update_viewer (acclient_2013_pseudo_c.txt:92761) end-to-end: - Start cell (pc:92824-92844): indoor (>=0x100) seats the sweep at the head-PIVOT via PhysicsEngine.AdjustPosition (the cellar-lip case — feet in the low connector, head up at floor level); outdoor keeps the player cell. - Sweep pivot -> sought-eye from the seated start cell (unchanged 0x5c viewer flags). - Success (pc:92870): set_viewer(curr_pos), viewer_cell = curr_cell. - Fallback 1 (pc:92878): AdjustPosition(sought_eye). - Fallback 2 / no-cell (pc:92775, 92886): snap to player, viewer_cell = null. This also makes cellId==0 faithful (was returning the desired eye; retail snaps to player_pos) and adds the playerPos arg to ICameraCollisionProbe.SweepEye. Supporting: ResolveResult.Ok surfaces FindTransitionalPosition's return (retail find_valid_position != 0, pc:273898) so SweepEye knows when to fall back. TDD: 11 new tests (FindVisibleChildCell 4, AdjustPosition 3, ResolveResult.Ok 2, SweepEye orchestration 2). The seating test's RED proved the sweep does NOT auto- advance feet->room, so the pivot-seated start cell is genuinely decisive. Core 1326 pass / 4 documented-fail / 1 skip; App 179 pass / 0 fail. No regression. Per the live-capture finding, the visible payoff is the cellar-corner (point 3); the cottage-room bluish void stays for residual C. Spec: docs/superpowers/specs/2026-06-05-residual-a-camera-collision-design.md. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
46 lines
1.7 KiB
C#
46 lines
1.7 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" — 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
|
|
}
|
|
}
|