feat(core): UCG Stage 1 — populate CellGraph from CacheCellStruct + AddLandblock (inert)
PhysicsDataCache gains a `CellGraph` property (UCG Stage 1). The env-cell hook is placed at the very top of CacheCellStruct — before the idempotency guard and the null-PhysicsBSP early-return — so BSP-less cells are included in the graph even though they are dropped from the legacy _cellStruct map. PhysicsEngine.AddLandblock/RemoveLandblock mirror terrain registration into the graph via a null-guarded DataCache?.CellGraph call. Zero behavior change: CellGraph has no readers this stage. A using-alias (UcgEnvCell / UcgCellGraph) resolves the EnvCell name collision between AcDream.Core.World.Cells and DatReaderWriter.DBObjs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
1aede3d6aa
commit
8e703bef22
3 changed files with 55 additions and 0 deletions
36
tests/AcDream.Core.Tests/Physics/CellGraphPopulationTests.cs
Normal file
36
tests/AcDream.Core.Tests/Physics/CellGraphPopulationTests.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using AcDream.Core.Physics;
|
||||
using AcDream.Core.World.Cells;
|
||||
using DatReaderWriter.Types;
|
||||
using Xunit;
|
||||
using DatEnvCell = DatReaderWriter.DBObjs.EnvCell;
|
||||
|
||||
namespace AcDream.Core.Tests.Physics;
|
||||
|
||||
public class CellGraphPopulationTests
|
||||
{
|
||||
[Fact]
|
||||
public void CacheCellStruct_AddsEnvCellToGraph_EvenWhenPhysicsBspIsNull()
|
||||
{
|
||||
var cache = new PhysicsDataCache();
|
||||
var cellStruct = new CellStruct
|
||||
{
|
||||
VertexArray = new VertexArray { Vertices = new Dictionary<ushort, SWVertex>() },
|
||||
Polygons = new Dictionary<ushort, Polygon>(),
|
||||
// PhysicsBSP omitted (defaults to null) — triggers the null-BSP drop from _cellStruct
|
||||
};
|
||||
var dat = new DatEnvCell
|
||||
{
|
||||
Flags = (DatReaderWriter.Enums.EnvCellFlags)0,
|
||||
CellPortals = new List<DatReaderWriter.Types.CellPortal>(),
|
||||
VisibleCells = new List<ushort>(),
|
||||
};
|
||||
|
||||
cache.CacheCellStruct(0xA9B40174u, dat, cellStruct, Matrix4x4.Identity);
|
||||
|
||||
Assert.Null(cache.GetCellStruct(0xA9B40174u)); // dropped from physics cache
|
||||
Assert.NotNull(cache.CellGraph.GetVisible(0xA9B40174u)); // but present in the graph
|
||||
Assert.IsType<EnvCell>(cache.CellGraph.GetVisible(0xA9B40174u));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue