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>
45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
namespace AcDream.Core.Physics;
|
|
|
|
/// <summary>
|
|
/// Indoor walking Phase 2 (2026-05-19). Portal connection between two
|
|
/// EnvCells. Each <see cref="CellPhysics"/> carries a list of these,
|
|
/// mirroring retail's <c>CCellStruct.portals</c> array.
|
|
///
|
|
/// <para>
|
|
/// <see cref="OtherCellId"/> is a low-16 cell index (combined with the
|
|
/// owning landblock prefix at lookup time) or <c>0xFFFF</c> to mean
|
|
/// "exit to outdoor world" (the player crosses this portal to leave
|
|
/// the building).
|
|
/// </para>
|
|
///
|
|
/// <para>
|
|
/// <see cref="PolygonId"/> indexes the OWNING cell's
|
|
/// <see cref="CellPhysics.PortalPolygons"/> dict (the visible-polygon
|
|
/// table, NOT <see cref="CellPhysics.Resolved"/> which holds physics
|
|
/// polys).
|
|
/// </para>
|
|
///
|
|
/// <para>
|
|
/// <see cref="PortalSide"/> decodes bit 2 of <see cref="Flags"/>:
|
|
/// <c>(Flags & 2) == 0</c> → portal's polygon normal points INTO
|
|
/// the owning cell (so dist > 0 in cell-local space means "outside
|
|
/// the cell, beyond the portal"). Used in <c>find_transit_cells</c>'s
|
|
/// load-hint path for unloaded neighbours.
|
|
/// </para>
|
|
/// </summary>
|
|
public readonly struct PortalInfo
|
|
{
|
|
public PortalInfo(ushort otherCellId, ushort polygonId, ushort flags)
|
|
{
|
|
OtherCellId = otherCellId;
|
|
PolygonId = polygonId;
|
|
Flags = flags;
|
|
}
|
|
|
|
public ushort OtherCellId { get; }
|
|
public ushort PolygonId { get; }
|
|
public ushort Flags { get; }
|
|
|
|
/// <summary>Bit 2 of <see cref="Flags"/>. See struct docstring.</summary>
|
|
public bool PortalSide => (Flags & 2) == 0;
|
|
}
|