fix(physics): validate retail cell containment roots

This commit is contained in:
Erik 2026-07-31 14:48:26 +02:00
parent 7716c2ee89
commit 3e0f3b6206
23 changed files with 429 additions and 197 deletions

View file

@ -71,10 +71,11 @@ public class CameraCollisionUpdateViewerTests
var cache = new PhysicsDataCache();
var engine = new PhysicsEngine { DataCache = cache };
// Feet cell: interior Z ≤ 94, in its stab list the room cell above. No portals
// (so the collision sweep cannot transit to the room — the start cell is decisive).
// Feet cell: interior Z ≤ 94, in its stab list the room cell above.
// The inert sentinel portal keeps the synthetic cell eligible for
// retail CEnvCell::point_in_cell without creating a usable transit.
cache.RegisterCellStructForTest(FeetCellId, MakeCell(InteriorZAtMost(94f), new uint[] { RoomCellId }));
// Room cell: interior Z ≥ 94, no walls, no portals.
// Room cell: interior Z ≥ 94, no walls and no usable portals.
cache.RegisterCellStructForTest(RoomCellId, MakeCell(InteriorZAtLeast(94f), Array.Empty<uint>()));
var heights = new byte[81];
@ -110,7 +111,7 @@ public class CameraCollisionUpdateViewerTests
InverseWorldTransform = Matrix4x4.Identity,
Resolved = new Dictionary<ushort, ResolvedPolygon>(),
CellBSP = new CellBSPTree { Root = cellBspRoot },
Portals = Array.Empty<PortalInfo>(),
Portals = [new PortalInfo(0xFFFF, 0, 0)],
PortalPolygons = new Dictionary<ushort, ResolvedPolygon>(),
VisibleCellIds = new HashSet<uint>(visibleCellIds),
};