fix(physics): restore retail cell availability semantics

This commit is contained in:
Erik 2026-07-31 14:22:45 +02:00
parent d3c0d9ec0e
commit 7716c2ee89
14 changed files with 393 additions and 62 deletions

View file

@ -160,4 +160,50 @@ public sealed class PhysicsDataCacheProductionTests
structure.ContainmentBsp,
runtimeCell.FlatContainmentBsp);
}
[Fact]
public void ProductionCellPublication_PreservesLoadedCellWithEmptyRoots()
{
const uint cellId = 0xA9B4_0174u;
PhysicsDataCache cache = PhysicsDataCache.CreateProduction();
var emptyPhysics = new FlatPhysicsBsp(
-1,
ImmutableArray<FlatPhysicsBspNode>.Empty,
ImmutableArray<int>.Empty,
FlatPolygonTable.Empty);
var emptyContainment = new FlatCellContainmentBsp(
-1,
ImmutableArray<FlatCellBspNode>.Empty);
var structure = new FlatCellStructureCollisionAsset(
emptyPhysics,
emptyContainment,
FlatPolygonTable.Empty);
var topology = new FlatEnvCellTopology(
ImmutableArray<FlatEnvCellPortal>.Empty,
ImmutableArray<uint>.Empty,
seenOutside: false);
cache.CacheCellStruct(
cellId,
new EnvCell(),
Matrix4x4.Identity,
structure,
topology);
CellPhysics loaded = Assert.IsType<CellPhysics>(
cache.GetCellStruct(cellId));
Assert.False(CollisionTraversal.HasPhysics(cache, loaded));
Assert.True(CollisionTraversal.HasCellContainment(cache, loaded));
Assert.True(CollisionTraversal.PointInsideCell(
cache,
loaded,
new Vector3(10_000f, -10_000f, 500f)));
var graphCell = Assert.IsType<AcDream.Core.World.Cells.EnvCell>(
cache.CellGraph.GetVisible(cellId));
Assert.True(graphCell.PointInCell(
new Vector3(10_000f, -10_000f, 500f)));
Assert.Equal(1, cache.CellStructCount);
Assert.Equal(1, cache.FlatCellStructCount);
Assert.Equal(0, cache.GraphCellStructCount);
}
}