fix(physics): validate retail cell containment roots

This commit is contained in:
Erik 2026-07-31 14:48:26 +02:00
parent 7716c2ee89
commit 3e0f3b6206
23 changed files with 429 additions and 197 deletions

View file

@ -2,6 +2,7 @@ using System.Collections.Generic;
using System.Numerics;
using AcDream.Core.Physics;
using AcDream.Core.World.Cells;
using DatReaderWriter.Enums;
using DatReaderWriter.Types;
using Xunit;
using DatEnvCell = DatReaderWriter.DBObjs.EnvCell;
@ -11,7 +12,7 @@ namespace AcDream.Core.Tests.Physics;
public class CellGraphPopulationTests
{
[Fact]
public void CacheCellStruct_PublishesLoadedCell_WhenPhysicsAndContainmentRootsAreNull()
public void CacheCellStruct_RejectsRootlessContainment_ThenAllowsValidRetry()
{
var cache = new PhysicsDataCache();
var cellStruct = new CellStruct
@ -29,13 +30,16 @@ public class CellGraphPopulationTests
cache.CacheCellStruct(0xA9B40174u, dat, cellStruct, Matrix4x4.Identity);
Assert.Null(cache.GetCellStruct(0xA9B40174u));
Assert.Null(cache.CellGraph.GetVisible(0xA9B40174u));
cellStruct.CellBSP.Root = new CellBSPNode { Type = BSPNodeType.Leaf };
cache.CacheCellStruct(0xA9B40174u, dat, cellStruct, Matrix4x4.Identity);
CellPhysics loaded = Assert.IsType<CellPhysics>(
cache.GetCellStruct(0xA9B40174u));
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)));
Assert.NotNull(cache.CellGraph.GetVisible(0xA9B40174u));
Assert.IsType<EnvCell>(cache.CellGraph.GetVisible(0xA9B40174u));
}