feat(headless): hydrate isolated collision worlds

This commit is contained in:
Erik 2026-07-27 09:25:58 +02:00
parent 9569dadb57
commit b6547ff38c
20 changed files with 1960 additions and 101 deletions

View file

@ -56,9 +56,25 @@ public sealed class TerrainSurface
public TerrainSurface(byte[] heights, float[] heightTable,
uint landblockX = 0, uint landblockY = 0,
byte[]? terrainTypes = null)
: this(
heights,
(heightTable
?? throw new ArgumentNullException(nameof(heightTable)))
.AsSpan(),
landblockX,
landblockY,
terrainTypes)
{
}
public TerrainSurface(
byte[] heights,
ReadOnlySpan<float> heightTable,
uint landblockX = 0,
uint landblockY = 0,
byte[]? terrainTypes = null)
{
ArgumentNullException.ThrowIfNull(heights);
ArgumentNullException.ThrowIfNull(heightTable);
if (heights.Length < 81)
throw new ArgumentException("heights must have 81 entries", nameof(heights));
if (heightTable.Length < 256)
@ -191,8 +207,25 @@ public sealed class TerrainSurface
uint landblockX, uint landblockY,
float localX, float localY)
{
ArgumentNullException.ThrowIfNull(heights);
ArgumentNullException.ThrowIfNull(heightTable);
return SampleZFromHeightmap(
heights,
heightTable.AsSpan(),
landblockX,
landblockY,
localX,
localY);
}
public static float SampleZFromHeightmap(
byte[] heights,
ReadOnlySpan<float> heightTable,
uint landblockX,
uint landblockY,
float localX,
float localY)
{
ArgumentNullException.ThrowIfNull(heights);
if (heights.Length < 81)
throw new ArgumentException("heights must have 81 entries", nameof(heights));
if (heightTable.Length < 256)