// Phase A8 RR5 — verify WbDrawDispatcher.WalkEntitiesForTestByCellIds, // the pure-data companion to the new Draw(cellIds:) production overload. // // Semantics: indoor entities (ParentCellId.HasValue) are gated by explicit // membership in cellIds. Building shells (IsBuildingShell) pass only when their // BuildingShellAnchorCellId belongs to the same cell set. // Outdoor scenery (no ParentCellId, not a shell) is excluded by EntitySet.IndoorPass. using System.Collections.Generic; using System.Numerics; using AcDream.App.Rendering.Wb; using AcDream.Core.World; using Xunit; namespace AcDream.Core.Tests.Rendering.Wb; public class WbDrawDispatcherCellIdsOverloadTests { private static WorldEntity CellEnt(uint id, uint cellId) => new() { Id = id, SourceGfxObjOrSetupId = 0x01000001u, ParentCellId = cellId, MeshRefs = new List { new(0x01000001u, Matrix4x4.Identity) }, Position = Vector3.Zero, Rotation = Quaternion.Identity, }; private static WorldEntity OutdoorScenery(uint id) => new() { Id = id, SourceGfxObjOrSetupId = 0x01000001u, ParentCellId = null, IsBuildingShell = false, MeshRefs = new List { new(0x01000001u, Matrix4x4.Identity) }, Position = Vector3.Zero, Rotation = Quaternion.Identity, }; private static WorldEntity BuildingShell(uint id, uint? anchorCellId) => new() { Id = id, SourceGfxObjOrSetupId = 0x02000001u, ParentCellId = null, IsBuildingShell = true, BuildingShellAnchorCellId = anchorCellId, MeshRefs = new List { new(0x01000001u, Matrix4x4.Identity) }, Position = Vector3.Zero, Rotation = Quaternion.Identity, }; [Fact] public void WalkEntitiesByCellIds_IncludesOnlyEntitiesInListedCells() { var entities = new List { CellEnt(0x40000001u, 0xA9B40150u), // in listed cells CellEnt(0x40000002u, 0xA9B40151u), // in listed cells CellEnt(0x40000003u, 0xA9B40999u), // OUT — not in list BuildingShell(0xC0000001u, 0xA9B40150u), // in listed building cells BuildingShell(0xC0000003u, 0xA9B40999u), // OUT — another building shell OutdoorScenery(0xC0000002u), // OUT — not a shell, not in cell list }; var cellIds = new HashSet { 0xA9B40150u, 0xA9B40151u }; var result = WbDrawDispatcher.WalkEntitiesForTestByCellIds( entities, cellIds, set: WbDrawDispatcher.EntitySet.IndoorPass); Assert.Equal(3, result.Count); Assert.Contains(0x40000001u, result); Assert.Contains(0x40000002u, result); Assert.Contains(0xC0000001u, result); Assert.DoesNotContain(0x40000003u, result); Assert.DoesNotContain(0xC0000003u, result); Assert.DoesNotContain(0xC0000002u, result); } [Fact] public void WalkEntitiesByCellIds_EmptyCellList_ExcludesBuildingShells() { var entities = new List { CellEnt(0x40000001u, 0xA9B40150u), BuildingShell(0xC0000001u, 0xA9B40150u), }; var result = WbDrawDispatcher.WalkEntitiesForTestByCellIds( entities, new HashSet(), set: WbDrawDispatcher.EntitySet.IndoorPass); Assert.Empty(result); } }