fix(physics): #31 update outdoor cell id during transition movement

This commit is contained in:
Erik 2026-04-29 22:00:30 +02:00
parent 3be0c8b7c7
commit 9fea9b13ad
5 changed files with 109 additions and 29 deletions

View file

@ -190,6 +190,54 @@ public class PhysicsEngineTests
Assert.True(result.Position.X > 192f);
}
[Fact]
public void ResolveWithTransition_OutdoorCellBoundary_UpdatesLowCellId()
{
var engine = MakeFlatEngine(terrainZ: 50f);
var result = engine.ResolveWithTransition(
currentPos: new Vector3(23f, 10f, 50f),
targetPos: new Vector3(25f, 10f, 50f),
cellId: 0x0001u,
sphereRadius: 0.5f,
sphereHeight: 1.2f,
stepUpHeight: 0.4f,
stepDownHeight: 0.4f,
isOnGround: true);
Assert.True(result.IsOnGround);
Assert.InRange(result.Position.X, 24.9f, 25.1f);
Assert.Equal(0x0009u, result.CellId);
}
[Fact]
public void ResolveWithTransition_LandblockBoundary_UpdatesFullOutdoorCellId()
{
var engine = new PhysicsEngine();
var terrainA = new TerrainSurface(FlatHeightmap(50), LinearHeightTable());
engine.AddLandblock(0xA9B4FFFFu, terrainA, Array.Empty<CellSurface>(),
Array.Empty<PortalPlane>(), worldOffsetX: 0f, worldOffsetY: 0f);
var terrainB = new TerrainSurface(FlatHeightmap(50), LinearHeightTable());
engine.AddLandblock(0xAAB4FFFFu, terrainB, Array.Empty<CellSurface>(),
Array.Empty<PortalPlane>(), worldOffsetX: 192f, worldOffsetY: 0f);
var result = engine.ResolveWithTransition(
currentPos: new Vector3(191f, 10f, 50f),
targetPos: new Vector3(193f, 10f, 50f),
cellId: 0xA9B40039u,
sphereRadius: 0.5f,
sphereHeight: 1.2f,
stepUpHeight: 0.4f,
stepDownHeight: 0.4f,
isOnGround: true);
Assert.True(result.IsOnGround);
Assert.InRange(result.Position.X, 192.9f, 193.1f);
Assert.Equal(0xAAB40001u, result.CellId);
}
[Fact]
public void Resolve_LeaveIndoorCell_TransitionsToOutdoor()
{