T6 (BR-7) C3: per-cell shadow architecture - flood registration, building channel, per-cell query; b3ce505 stopgap DELETED (closes #99)

The A6.P4 port, fused into one installment per the BR-2 half-port lesson
(registration and query are co-dependent: flood-registering shells under
the old radial query would re-open #98 through the vestibule).

REGISTRATION (ShadowObjectRegistry rewritten):
- Register/RegisterMultiPart/UpdatePosition compute the cell set via
  CellTransit.BuildShadowCellSet (the C2 find_cell_list flood) seeded by
  the entity's m_position cell id; the private 24m XY-grid rectangle and
  its single-landblock clamp are deleted. Flood spheres follow retail's
  CylSphere rule (base point + cyl radius, cap 10; BSP bounding-sphere
  fallback - Ghidra 0x0052b9f0). Statics flood with the do_not_load
  prune; dynamics (server spawns, isStatic:false) without.
- Keep-when-empty (SetPositionInternal num_cells gate, pc:283540): a
  failed flood leaves the previous registration in place.
- RefloodLandblock: streaming-race hook re-runs the flood when a
  landblock's cells hydrate (retail init_objects -> recalc_cross_cells,
  Ghidra 0x0052b420/0x00515a30); wired at GameWindow's hydration tail.
- GameWindow sites pass the server position's full cell id as the seed
  (spawn + UpdatePosition); the five static sites pass ParentCellId.

BUILDING CHANNEL (CSortCell.building shape):
- Building SHELLS are not shadow objects in retail (only caller of
  find_building_collisions is CSortCell::find_collisions 0x005340aa;
  one building per origin landcell, init_buildings 0x0052fd80 verified
  verbatim + ACE cross-ref). IsBuildingShell entities skip the registry;
  Transition.FindBuildingCollisions runs the shell part-0 BSP off
  cache.GetBuilding(cellId) with bldg_check set around it
  (find_building_collisions 0x006b5300), CollidedWithEnvironment on
  non-Contact non-OK. BuildingPhysics.ModelId = pre-resolved part-0
  GfxObj (0x02 Setups resolved at the CacheBuilding site).
- Placement/ethereal weakening: BSPQuery Path 1 passes center_solid=0
  when BldgCheck && HitsInteriorCell (BSPTREE::find_collisions 0x0053a82e
  + placement_insert 0x005399d8) so doorway crossings don't hard-fail
  against shell solids. SpherePath gains both retail fields;
  HitsInteriorCell is rebuilt at every cell-array build
  (build_cell_array reset 0x00509ef2 + find_cell_list/check_building_
  transit set sites).

QUERY (retail per-cell order, transitional_insert 0x0050b6f0):
- TransitionalInsert per attempt: env -> building (LandCell only) ->
  objects on the PRIMARY cell, then on OK the check_other_cells pass
  (env -> building -> objects per OTHER overlapped cell) + the
  carried-cell advance - the advance now happens AFTER all per-cell
  object passes (the WF1 ordering divergence), with Adjusted/Slid
  feeding the retry exactly like retail's OK_TS case.
- FindObjCollisionsInCell = CObjCell::find_obj_collisions (0x0052b750):
  iterate ONLY the asked cell's list. DELETED: the radial 9-landblock
  sweep, the +5m query pad, the b3ce505 indoor-primary gate, and the
  isViewer exemption (the camera is bounded by interior cell-BSP env
  collision - retail's own channel; CameraCornerSealReplayTests pins it
  against real dat, and the new building-channel camera test pins the
  outdoor stop).

TESTS: Core 1416/0/2 (was 1398 + 4 pre-existing #99-era fails + 1 skip),
App 225, UI 420, Net 294 - all green.
- 3 of the 4 #99-era reds flipped green as designed: the door apparatus
  (Apparatus_Grounded_50cmOffCenter_FrontApproach_Blocks) and tick-13558
  (indoor walkthrough) now assert the door BLOCKS; tick-22760 pins the
  outdoor blocking invariant.
- The 4th (BSPStepUp D4) + 22760's lateral-slide delta are NOT cell-set
  problems (probes prove the door is found + BSP-only dispatched;
  BR-7 left both byte-identical) - filed as issue #116 (slide-response
  family), D4 skipped with the issue reference.
- FindEnvCollisionsMultiCellTests migrated to the public entry (the A4
  multi-cell halt now lives at the retail call site).
- New registry pins: per-cell query surface, outdoor-footprint-never-
  indoor (#98 architectural), door-outdoor-cell membership, reflood.
- CameraCollisionIndoorTests rewritten against the building channel
  (the isViewer-exemption pins died with the exemption).

Closes #99 (doors block both ways via registration-time cell membership
+ the straddle-spanning player cell array). #97 likely closed (the +5m
radial pad that produced phantom-collision candidates is gone) - verify
at T5. #98 stays closed ARCHITECTURALLY (outdoor footprints structurally
cannot reach interior cells; the cellar harness stays green).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Erik 2026-06-11 14:37:50 +02:00
parent abf36e2743
commit dbfbf8506c
15 changed files with 1109 additions and 856 deletions

View file

@ -3268,7 +3268,16 @@ public sealed class GameWindow : IDisposable
flags: flags,
worldOffsetX: origin.X,
worldOffsetY: origin.Y,
landblockId: spawn.Position.Value.LandblockId);
landblockId: spawn.Position.Value.LandblockId,
// BR-7 / A6.P4 (2026-06-11): the server position's full cell id
// is the registration flood seed (retail m_position.objcell_id
// into CObjCell::find_cell_list). A door whose spheres straddle
// the doorway lands in BOTH the outdoor landcell and the
// vestibule's shadow list at registration — the architectural
// close of #99. Dynamic objects use calc_cross_cells (no
// do_not_load prune), hence isStatic: false.
seedCellId: spawn.Position.Value.LandblockId,
isStatic: false);
// L.2d slice 1 (2026-05-13): [entity-source] greppable from [resolve-bldg].
// Per-shape detail appears in [resolve-bldg] when collisions fire;
@ -4487,8 +4496,11 @@ public sealed class GameWindow : IDisposable
// (acclient_2013_pseudo_c.txt:284276 / 281200 / 282862).
if (update.Guid != _playerServerGuid)
{
// BR-7: the wire position's full cell id seeds the re-flood
// (retail SetPosition → calc_cross_cells from m_position).
_physicsEngine.ShadowObjects.UpdatePosition(
entity.Id, worldPos, rot, origin.X, origin.Y, p.LandblockId);
entity.Id, worldPos, rot, origin.X, origin.Y, p.LandblockId,
seedCellId: p.LandblockId);
}
// Track remote-entity motion for stop detection. Only record the
@ -5993,7 +6005,25 @@ public sealed class GameWindow : IDisposable
building.Frame.Origin.X, building.Frame.Origin.Y);
uint landcellId = lbPrefix | landcellLow;
_physicsDataCache.CacheBuilding(landcellId, bldPortals, buildingTransform);
// BR-7 / A6.P4 (2026-06-11): the shell part-0 GfxObj id
// arms the retail building collision channel
// (CBuildingObj::find_building_collisions, Ghidra
// 0x006b5300 — one BSP test on part_array->parts[0]).
// 0x01 model ids are the GfxObj; 0x02 Setups resolve to
// their first part here, where the dat is at hand.
uint shellPart0 = building.ModelId;
if ((shellPart0 & 0xFF000000u) == 0x02000000u)
{
// _dats is non-null on every streaming-drain path
// (the GfxObj physics cache loop below dereferences
// it unconditionally).
var bldSetup = _dats!.Get<DatReaderWriter.DBObjs.Setup>(building.ModelId);
shellPart0 = bldSetup is not null && bldSetup.Parts.Count > 0
? bldSetup.Parts[0]
: 0u;
}
_physicsDataCache.CacheBuilding(landcellId, bldPortals, buildingTransform,
modelId: shellPart0);
}
}
@ -6143,6 +6173,16 @@ public sealed class GameWindow : IDisposable
uint partIndex = 0;
foreach (var meshRef in entity.MeshRefs)
{
// BR-7 / A6.P4 (2026-06-11): building SHELLS are not shadow
// objects in retail — their collision is the per-LandCell
// building channel (CSortCell::find_collisions, Ghidra
// 0x005340a0, dispatched off the CacheBuilding entry at the
// building's origin landcell). Registering them here is what
// put the cottage GfxObj into the radial sweep's reach from
// the cellar (#98). Interior statics + outdoor stab objects
// (LandBlockInfo.Objects) remain shadow objects.
if (entity.IsBuildingShell) break;
var partCached = _physicsDataCache.GetGfxObj(meshRef.GfxObjId);
if (partCached?.BSP?.Root is null) { partIndex++; continue; }
@ -6182,7 +6222,7 @@ public sealed class GameWindow : IDisposable
origin.X, origin.Y, lb.LandblockId,
AcDream.Core.Physics.ShadowCollisionType.BSP, 0f,
partScale,
cellScope: entity.ParentCellId ?? 0u);
seedCellId: entity.ParentCellId ?? 0u);
// L.2d slice 1 (2026-05-13): [entity-source] greppable from [resolve-bldg].
// partCached?.BSP?.Root non-null was checked above (else `continue`),
// so hasPhys=true on this path.
@ -6252,7 +6292,7 @@ public sealed class GameWindow : IDisposable
entity.Rotation, cylRadius,
origin.X, origin.Y, lb.LandblockId,
AcDream.Core.Physics.ShadowCollisionType.Cylinder, cylHeight,
cellScope: entity.ParentCellId ?? 0u);
seedCellId: entity.ParentCellId ?? 0u);
// L.2d slice 1 (2026-05-13): [entity-source] greppable from [resolve-bldg].
// state/flags literals: landblock-baked scenery; no server PhysicsState.
if (AcDream.Core.Physics.PhysicsDiagnostics.ProbeBuildingEnabled)
@ -6288,7 +6328,7 @@ public sealed class GameWindow : IDisposable
entity.Rotation, sphRadius,
origin.X, origin.Y, lb.LandblockId,
AcDream.Core.Physics.ShadowCollisionType.Cylinder, sphHeight,
cellScope: entity.ParentCellId ?? 0u);
seedCellId: entity.ParentCellId ?? 0u);
// L.2d slice 1 (2026-05-13): [entity-source] greppable from [resolve-bldg].
// state/flags literals: landblock-baked scenery; no server PhysicsState.
if (AcDream.Core.Physics.PhysicsDiagnostics.ProbeBuildingEnabled)
@ -6312,7 +6352,7 @@ public sealed class GameWindow : IDisposable
entity.Position, entity.Rotation, fr,
origin.X, origin.Y, lb.LandblockId,
AcDream.Core.Physics.ShadowCollisionType.Cylinder, fh,
cellScope: entity.ParentCellId ?? 0u);
seedCellId: entity.ParentCellId ?? 0u);
// L.2d slice 1 (2026-05-13): [entity-source] greppable from [resolve-bldg].
// state/flags literals: landblock-baked scenery; no server PhysicsState.
if (AcDream.Core.Physics.PhysicsDiagnostics.ProbeBuildingEnabled)
@ -6512,7 +6552,7 @@ public sealed class GameWindow : IDisposable
baseCenter, entity.Rotation, cylRadius,
origin.X, origin.Y, lb.LandblockId,
AcDream.Core.Physics.ShadowCollisionType.Cylinder, cylHeight,
cellScope: entity.ParentCellId ?? 0u);
seedCellId: entity.ParentCellId ?? 0u);
// L.2d slice 1 (2026-05-13): [entity-source] greppable from [resolve-bldg].
// state/flags literals: landblock-baked scenery; no server PhysicsState.
if (AcDream.Core.Physics.PhysicsDiagnostics.ProbeBuildingEnabled)
@ -6568,6 +6608,15 @@ public sealed class GameWindow : IDisposable
}
// BR-7 / A6.P4 (2026-06-11): this landblock's cells + buildings are
// now hydrated — re-run the registration flood for entities whose
// shadow cell set touches it. Covers the streaming races in both
// directions (server spawn before the landblock hydrated → flood
// couldn't traverse; cells hydrated after the spawn). Retail
// equivalent: CObjCell::init_objects → recalc_cross_cells on cell
// load (Ghidra 0x0052b420 / 0x00515a30).
_physicsEngine.ShadowObjects.RefloodLandblock(lb.LandblockId);
// Register each stab as a plugin snapshot so the plugin host has
// visibility into the streaming world state.
foreach (var entity in lb.Entities)