diff --git a/src/AcDream.App/Rendering/GameWindow.cs b/src/AcDream.App/Rendering/GameWindow.cs index e4f61dc3..733d454a 100644 --- a/src/AcDream.App/Rendering/GameWindow.cs +++ b/src/AcDream.App/Rendering/GameWindow.cs @@ -6943,6 +6943,17 @@ public sealed class GameWindow : IDisposable // formula (gridX * 8 + gridY + 1) within the 192m × 192m landblock. if (lbInfo is not null && lbInfo.Buildings.Count > 0) { + // #146 (2026-06-24): clear this landblock's prior building cache so + // the loop re-bases each building's STREAMING-RELATIVE WorldTransform + // with the CURRENT _liveCenter (origin, recomputed above per apply). + // CacheBuilding's per-cell first-wins then applies fresh within this + // pass — mirrors terrain's per-apply WorldOffset re-base (AddLandblock). + // Without it, CacheBuilding's idempotent guard locks the transform at + // the frame it was first cached with, so a teleport recenter strands + // the shell BSP at a stale world offset and house walls stop colliding + // (login at Arwic → portal to Holtburg → walls clip; bldOrigin ~5.5km off). + _physicsDataCache.RemoveBuildingsForLandblock(lb.LandblockId); + uint lbPrefix = lb.LandblockId & 0xFFFF0000u; foreach (var building in lbInfo.Buildings) { diff --git a/src/AcDream.Core/Physics/PhysicsDataCache.cs b/src/AcDream.Core/Physics/PhysicsDataCache.cs index 7218e016..fbd2ce67 100644 --- a/src/AcDream.Core/Physics/PhysicsDataCache.cs +++ b/src/AcDream.Core/Physics/PhysicsDataCache.cs @@ -455,6 +455,28 @@ public sealed class PhysicsDataCache }; } + /// + /// #146 (2026-06-24): drop every cached building belonging to a landblock so + /// the next pass re-bases their STREAMING-RELATIVE + /// WorldTransform against the CURRENT _liveCenter. Without this, + /// CacheBuilding's per-cell first-wins guard LOCKS the transform at whatever + /// frame it was first cached with; a teleport recenter then leaves the shell + /// BSP at a stale world offset (~the source↔dest landblock distance), so the + /// foot-sphere walks through where the wall visually is and collision is lost + /// (login at Arwic → portal to Holtburg → house walls clip; bldOrigin probed + /// ~5.5 km off). Terrain avoids this because AddLandblock overwrites its + /// WorldOffset every apply; buildings get the equivalent per-apply re-base via + /// the caller clearing-then-repopulating (which keeps first-wins within each + /// fresh pass — retail CSortCell::add_building semantics preserved). + /// + public void RemoveBuildingsForLandblock(uint landblockId) + { + uint prefix = landblockId & 0xFFFF0000u; + foreach (var key in _buildings.Keys) + if ((key & 0xFFFF0000u) == prefix) + _buildings.TryRemove(key, out _); + } + public BuildingPhysics? GetBuilding(uint landcellId) => _buildings.TryGetValue(landcellId, out var b) ? b : null; diff --git a/src/AcDream.Core/Physics/TransitionTypes.cs b/src/AcDream.Core/Physics/TransitionTypes.cs index 1e39e4a4..c052541f 100644 --- a/src/AcDream.Core/Physics/TransitionTypes.cs +++ b/src/AcDream.Core/Physics/TransitionTypes.cs @@ -2874,7 +2874,7 @@ public sealed class Transition if (PhysicsDiagnostics.ProbeBuildingEnabled) { Console.WriteLine(System.FormattableString.Invariant( - $"[bldg-channel] cell=0x{cellId:X8} model=0x{building.ModelId:X8} wpos=({sp.GlobalSphere[0].Origin.X:F3},{sp.GlobalSphere[0].Origin.Y:F3},{sp.GlobalSphere[0].Origin.Z:F3}) hitsInterior={sp.HitsInteriorCell} result={result}")); + $"[bldg-channel] cell=0x{cellId:X8} model=0x{building.ModelId:X8} wpos=({sp.GlobalSphere[0].Origin.X:F3},{sp.GlobalSphere[0].Origin.Y:F3},{sp.GlobalSphere[0].Origin.Z:F3}) bldOrigin=({bldOrigin.X:F3},{bldOrigin.Y:F3},{bldOrigin.Z:F3}) hitsInterior={sp.HitsInteriorCell} result={result}")); } // 0x006b5338: non-OK + non-Contact mover → environment attribution.