feat(core): UCG Stage 1 — LandCell synthesized from TerrainSurface
Outdoor terrain cell (retail CLandCell) synthesized on demand from a landblock's TerrainSurface. Factory Synthesize() samples four quad corners to establish Z bounds; PointInCell() tests the 24 m XY quad in world-local space. BuildingCellId stub is null (Stage 2). 2/2 tests RED→GREEN. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
03f08f00c1
commit
b4c4318c8b
2 changed files with 91 additions and 0 deletions
36
tests/AcDream.Core.Tests/World/Cells/LandCellTests.cs
Normal file
36
tests/AcDream.Core.Tests/World/Cells/LandCellTests.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using System.Numerics;
|
||||
using AcDream.Core.Physics;
|
||||
using AcDream.Core.World.Cells;
|
||||
using Xunit;
|
||||
|
||||
namespace AcDream.Core.Tests.World.Cells;
|
||||
|
||||
public class LandCellTests
|
||||
{
|
||||
private static TerrainSurface FlatTerrain()
|
||||
=> new TerrainSurface(new byte[81], new float[256], landblockX: 0, landblockY: 0);
|
||||
|
||||
[Fact]
|
||||
public void Synthesize_SetsCellIndicesAndQuadBounds()
|
||||
{
|
||||
var origin = new Vector3(1000f, 2000f, 0f);
|
||||
var cell = LandCell.Synthesize(0xA9B40014u, FlatTerrain(), origin, cx: 2, cy: 3);
|
||||
Assert.Equal(2, cell.Cx);
|
||||
Assert.Equal(3, cell.Cy);
|
||||
Assert.Equal(2 * 24f, cell.LocalBoundsMin.X);
|
||||
Assert.Equal(3 * 24f, cell.LocalBoundsMin.Y);
|
||||
Assert.Equal(3 * 24f, cell.LocalBoundsMax.X);
|
||||
Assert.Equal(4 * 24f, cell.LocalBoundsMax.Y);
|
||||
Assert.False(cell.IsEnv);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PointInCell_TestsWorldXyAgainstThe24mQuad()
|
||||
{
|
||||
var origin = new Vector3(1000f, 2000f, 0f);
|
||||
var cell = LandCell.Synthesize(0xA9B40014u, FlatTerrain(), origin, cx: 2, cy: 3);
|
||||
Assert.True(cell.PointInCell(new Vector3(1060f, 2080f, 12.3f)));
|
||||
Assert.False(cell.PointInCell(new Vector3(1000f, 2080f, 0f)));
|
||||
Assert.False(cell.PointInCell(new Vector3(1060f, 2100f, 0f)));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue