Adds PortalInfo struct and extends CellPhysics with CellBSP (third BSP for point-in-cell tests, typed CellBSPTree from DatReaderWriter), Portals (from envCell.CellPortals), PortalPolygons (resolved cellStruct.Polygons — portals reference visible polys, not PhysicsPolygons), and VisibleCellIds (populated for future use; envCell.VisibleCells is List<UInt16>, not Dictionary). Deletes CellPhysics.LocalAabbMin/Max and PhysicsDataCache.TryFindContainingCell — Phase D's AABB shortcut is gone. CacheCellStruct's AABB compute removed; the [cell-cache] diagnostic updated with portal/visible counts instead. CacheCellStruct signature gains an EnvCell parameter (one call site in GameWindow.cs:5384 updated). ResolveOutdoorCellId drops the TryFindContainingCell call; portal-graph CellTransit replaces it next. ResolveOutdoorCellIdTests object initializers had the deleted AABB properties stripped temporarily so the build stays green; the file gets replaced wholesale in the next commit (CellTransit integration). Those 2 AABB-containment tests continue to fail (they were pre-broken on this branch); no new failures introduced. Spec: docs/superpowers/specs/2026-05-19-indoor-portal-cell-tracking-design.md Plan: docs/superpowers/plans/2026-05-19-indoor-portal-cell-tracking.md Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
35 lines
946 B
C#
35 lines
946 B
C#
using AcDream.Core.Physics;
|
|
using Xunit;
|
|
|
|
namespace AcDream.Core.Tests.Physics;
|
|
|
|
public class PortalInfoTests
|
|
{
|
|
[Fact]
|
|
public void PortalSide_FlagsBit2Clear_ReturnsTrue()
|
|
{
|
|
var portal = new PortalInfo(otherCellId: 0x0101, polygonId: 5, flags: 0);
|
|
Assert.True(portal.PortalSide);
|
|
}
|
|
|
|
[Fact]
|
|
public void PortalSide_FlagsBit2Set_ReturnsFalse()
|
|
{
|
|
var portal = new PortalInfo(otherCellId: 0x0101, polygonId: 5, flags: 2);
|
|
Assert.False(portal.PortalSide);
|
|
}
|
|
|
|
[Fact]
|
|
public void PortalSide_OtherBitsSet_FollowsOnlyBit2()
|
|
{
|
|
var portal = new PortalInfo(otherCellId: 0x0101, polygonId: 5, flags: 0xFF & ~2);
|
|
Assert.True(portal.PortalSide);
|
|
}
|
|
|
|
[Fact]
|
|
public void OtherCellId_StoredAsLowSixteenBits()
|
|
{
|
|
var portal = new PortalInfo(otherCellId: 0xFFFF, polygonId: 5, flags: 0);
|
|
Assert.Equal((ushort)0xFFFF, portal.OtherCellId);
|
|
}
|
|
}
|