From 9e184eb8619fc8106c6c968653b7518c212fdb9f Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 21 Jun 2026 11:05:54 +0200 Subject: [PATCH] =?UTF-8?q?docs(#145):=20Slice=203=20design=20=E2=80=94=20?= =?UTF-8?q?carried-anchor=20(body.Position=20-=20CellPosition.Origin)=20re?= =?UTF-8?q?places=20TryGetTerrainOrigin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 (1M context) --- .../2026-06-21-145-cell-relative-physics-frame.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/superpowers/plans/2026-06-21-145-cell-relative-physics-frame.md b/docs/superpowers/plans/2026-06-21-145-cell-relative-physics-frame.md index 2f9dec6e..f5d14ee0 100644 --- a/docs/superpowers/plans/2026-06-21-145-cell-relative-physics-frame.md +++ b/docs/superpowers/plans/2026-06-21-145-cell-relative-physics-frame.md @@ -312,6 +312,16 @@ Co-Authored-By: Claude Opus 4.8 (1M context) " **Goal:** The outdoor membership pick stops deriving the landblock from `TryGetTerrainOrigin` (which falls back to `(0,0)` for unstreamed neighbours). It runs `AdjustToOutside` directly on the carried `(cell, local)` pair. This is the fix — the far-town cascade becomes impossible. +**THE MECHANISM (designed + verified 2026-06-21 — the carried-anchor):** the landblock world origin acdream needs is exactly `blockOrigin = body.Position − body.CellPosition.Frame.Origin` (world pos minus the carried cell-local). This is the *true* landblock origin derived from the carried frame — correct even for an UNSTREAMED neighbour, where `TryGetTerrainOrigin` returns `(0,0)`. Verified against the runaway: at the first far-town tick `body.Position≈(14.8,−0.088,12)` (streaming-rel) and `CellPosition.Frame.Origin≈(14.8,191.9,12)` (local in `0xC95A`), so `blockOrigin ≈ (0,−192)` — exactly the value the handoff confirmed correct for `0xC95A`. Feeding this `blockOrigin` into the EXISTING pick (`pickPos = worldSphereCenter − blockOrigin` at `CellTransit.cs:845`) and `AddAllOutsideCells` makes the whole downstream membership cascade-proof with no rewrite of the pick logic. + +**Implementation steps:** +1. **Seed** `_body.SnapToCell(cellId, worldPos, wireLocal)` at the 3 player-placement sites — login spawn (`GameWindow.cs:~2930`, wire local `(p.PositionX,Y,Z)`, cell `p.LandblockId`), teleport arrival (`~:5474/:5537` — seed the RESOLVED cell + its local), inbound player update. Without a seed, `CellPosition.ObjCellId==0` and the fix no-ops (legacy fallback). Behavior-neutral. +2. **Thread** `Vector3? carriedBlockOrigin` into `CellTransit.FindCellSet`/`FindCellList`/`BuildCellSetAndPickContaining` (default `null` → legacy `TryGetTerrainOrigin`). When supplied, it REPLACES the `:736` derivation. Compute it in `PhysicsEngine.ResolveWithTransition` from the passed `body` (`body.CellPosition.ObjCellId` outdoor & seeded → `body.Position − body.CellPosition.Frame.Origin`, else `null`), thread through the sweep (`RunCheckOtherCellsAndAdvance` → `FindCellSet`) in `TransitionTypes.cs`. ⚠ The sweep threading is the delicate part — `RunCheckOtherCellsAndAdvance` is in the ~2,300-line `TransitionTypes`; the resolve `body` must reach the `FindCellSet` call (add a field on the transition/sphere-path state set at resolve entry). Read that path fully before editing. +3. **Make membership authoritative**: the controller commits `_body.CellPosition.ObjCellId` (or the now-correct `resolveResult.CellId`) — they agree once `blockOrigin` is the carried anchor. Delete the legacy-anchor comment at `:732-735`. +4. **Test** `TeleportFarTownRunawayTests` from `desync-capture.jsonl` (south + east edge, unregistered neighbour, assert no march). Hold every existing membership/replay test green. + +Note: the OTHER `TryGetTerrainOrigin` site (`CellTransit.cs:484`, `BuildShadowCellSet`) is registration-side collision (Slice 4 concern), NOT the player pick — leave it for Slice 4. + **Files:** - Modify: `src/AcDream.Core/Physics/CellTransit.cs:732-736` (the discarded-bool fallback), `:242` (`AddAllOutsideCells` block-origin subtraction), `:845-849` (containing pick), `:484` (the other seed) - Modify: `src/AcDream.Core/Physics/PhysicsEngine.cs:603-625` (the resolve loop feeds the pick)