acdream/tests/AcDream.App.Tests/Rendering/Wb/BuildingTests.cs
Erik f125fdb220 feat(render): Phase A8 RR3 — Building + BuildingRegistry + BuildingLoader
New per-landblock data model for WB-style per-building cell scoping:

  Building            — BuildingId, EnvCellIds, ExitPortalPolygons,
                        occlusion-query state (Step 5 lifecycle)
  BuildingRegistry    — two-way indexed (by cellId + by buildingId);
                        single source of truth per landblock
  BuildingLoader      — static factory from LandBlockInfo.Buildings;
                        walks interior portals to expand cell sets;
                        collects exit portal polygons in world space

10 new unit tests cover data invariants + registry indexing + loader
mapping per the algorithm resolved in RR2 findings.

LoadedCell.BuildingId stamping wired in RR4. Render-time consumption
arrives in RR7 (Steps 1-4) + RR9 (Step 5) + RR11 (RenderOutsideIn).

Design: docs/superpowers/specs/2026-05-26-phase-a8-wb-full-port-design.md
Spike: docs/research/2026-05-26-a8-buildings-data-shape.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-27 11:08:43 +02:00

44 lines
1.2 KiB
C#

using System.Collections.Generic;
using System.Numerics;
using AcDream.App.Rendering.Wb;
using Xunit;
namespace AcDream.App.Tests.Rendering.Wb;
public class BuildingTests
{
[Fact]
public void Building_RequiredFields_PopulateCorrectly()
{
var b = new Building
{
BuildingId = 42,
EnvCellIds = new HashSet<uint> { 0xA9B40150u, 0xA9B40151u },
ExitPortalPolygons = new List<Vector3[]>
{
new[] { new Vector3(0, 0, 0), new Vector3(1, 0, 0), new Vector3(1, 1, 0) },
},
};
Assert.Equal(42u, b.BuildingId);
Assert.Equal(2, b.EnvCellIds.Count);
Assert.Contains(0xA9B40150u, b.EnvCellIds);
Assert.Single(b.ExitPortalPolygons);
Assert.Equal(3, b.ExitPortalPolygons[0].Length);
}
[Fact]
public void Building_OcclusionQueryState_DefaultsZero()
{
var b = new Building
{
BuildingId = 0,
EnvCellIds = new HashSet<uint>(),
ExitPortalPolygons = new List<Vector3[]>(),
};
Assert.Equal(0u, b.QueryId);
Assert.False(b.QueryStarted);
Assert.False(b.WasVisible);
}
}