wip(assembler): M1 round 6 -- owner walk fixes: 25 cm geometry scale, one height datum, carve/fill sign, faster relief meshing

Owner saw content floating above native terrain, spiky triangles, reversed carve/fill and late relief.
Causes: shared mesher placed Core tiles on a 12.5 cm grid; content/atmosphere asked strate ranges in
12.5 cm voxels; Core edits add density where the legacy diff subtracts. Horizon LOD8 bridge edge
5.657 -> 2.265 cells. Relief mesh p95 60.8 -> 42.0 ms (LOD0). New BuildHost checks for scale, height,
blueprint carve/fill and per-kind streaming lag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
This commit is contained in:
Fr0zkaandClaude Opus 5.5 committed 2026-10-09 20:39:24 +02:00
1 parent f67b519e75
commit 61633cb492
18 files changed
+1708 -142

No files matched your search

@@ -139,6 +139,8 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
// Cell size in voxels. No upper clamp: coarse clipmap levels use bigger steps (the EXTENT
// grows). Coarse tiles also use FEWER cells (InCellsPerAxis) for cheaper gen.
Step = FMath::Max(1, Step);
const float GeometryVoxelSize = VoxelMath::IsFinite(GeometryVoxelSizeCm)
? FMath::Max(1.0f, GeometryVoxelSizeCm) : VOXEL_SIZE;
// T2.b — octave bias for THIS tile: drop LODOctaveDrop octaves per Step doubling from
// the generator's per-voxel volumetric noise (sub-cell octaves can't shape a coarse
@@ -150,7 +152,7 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
TGuardValue<int32> SampleStepGuard(VoxelGenLOD::SampleStep, Step);
// World-cm origin of the tile's min corner (positions are built relative to this).
const FVector ChunkWorldPos = FVector(OriginVoxels) * VOXEL_SIZE;
const FVector ChunkWorldPos = FVector(OriginVoxels) * GeometryVoxelSize;
//=========================================================================
// VERTEX DEDUPLICATION MAP
@@ -316,11 +318,11 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
uint8 SurfClass = 0;
if (Normal.Z < -0.1f)
{
const float Zv = WorldPos.Z / VOXEL_SIZE;
const float Zv = WorldPos.Z / GeometryVoxelSize;
const float StepF = (float)Step;
const FIntVector MemoKey(
FMath::RoundToInt(WorldPos.X / (VOXEL_SIZE * StepF)),
FMath::RoundToInt(WorldPos.Y / (VOXEL_SIZE * StepF)),
FMath::RoundToInt(WorldPos.X / (GeometryVoxelSize * StepF)),
FMath::RoundToInt(WorldPos.Y / (GeometryVoxelSize * StepF)),
FMath::FloorToInt(Zv / (float)CHUNK_SIZE));
FVector2f* Col = SurfColMemo.Find(MemoKey);
if (!Col)
@@ -330,12 +332,23 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
static_cast<float>(MemoKey.X*Step),static_cast<float>(MemoKey.Y*Step),
MemoKey.Z,TerrainZ,CeilSurf);
if(!bSurf)
bSurf=Generator->GetSurfaceHeightAt(
(float)(MemoKey.X * Step), (float)(MemoKey.Y * Step), MemoKey.Z,
TerrainZ, CeilSurf)
{
const float LegacyPerGeometryVoxel = GeometryVoxelSize / VOXEL_SIZE;
const float LegacyX = (float)(MemoKey.X * Step) * LegacyPerGeometryVoxel;
const float LegacyY = (float)(MemoKey.Y * Step) * LegacyPerGeometryVoxel;
const int32 LegacyChunkZ = FMath::FloorToInt(
(WorldPos.Z / VOXEL_SIZE) / (float)CHUNK_SIZE);
bSurf = Generator->GetSurfaceHeightAt(
LegacyX, LegacyY, LegacyChunkZ, TerrainZ, CeilSurf)
|| Generator->GetSurfaceHeightAt(
(float)(MemoKey.X * Step), (float)(MemoKey.Y * Step), MemoKey.Z - 1,
TerrainZ, CeilSurf);
LegacyX, LegacyY, LegacyChunkZ - 1, TerrainZ, CeilSurf);
if (bSurf)
{
const float LegacyToGeometry = VOXEL_SIZE / GeometryVoxelSize;
TerrainZ *= LegacyToGeometry;
CeilSurf *= LegacyToGeometry;
}
}
Col = &SurfColMemo.Add(MemoKey, bSurf ? FVector2f(TerrainZ, CeilSurf)
: FVector2f(FLT_MAX, -FLT_MAX));
}
@@ -1481,7 +1494,7 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
const int32 GY = cy + CornerOffsets[i].Y;
const int32 GZ = cz + CornerOffsets[i].Z;
Positions[i] = ChunkWorldPos
+ FVector(GX * Step, GY * Step, GZ * Step) * VOXEL_SIZE;
+ FVector(GX * Step, GY * Step, GZ * Step) * GeometryVoxelSize;
Gradients[i] = GradAt(GX, GY, GZ);
}
if (bSampleCell)
@@ -1512,8 +1525,8 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
{
const FVector Midpoint=(Positions[A]+Positions[B])*0.5f;
const float MidDensity=ShapeWorldContext->DensityAtUnclamped(
Midpoint.X/VOXEL_SIZE,Midpoint.Y/VOXEL_SIZE,
Midpoint.Z/VOXEL_SIZE);
Midpoint.X/GeometryVoxelSize,Midpoint.Y/GeometryVoxelSize,
Midpoint.Z/GeometryVoxelSize);
if(FMath::Abs(MidDensity-IsoLevel)<1.0e-6f)
T=0.5f;
else if((MidDensity<IsoLevel)==(D1<IsoLevel))
@@ -1615,10 +1628,10 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
TArray<uint8> GroundSkirtFaceMasks,CapSkirtFaceMasks;
if (bGenerateSkirts && (GroundTris.Num() + CapTris.Num()) > 0)
{
const float ExtentCm = (float)(CellsPerAxis * Step) * VOXEL_SIZE;
const float ExtentCm = (float)(CellsPerAxis * Step) * GeometryVoxelSize;
const float MinX = ChunkWorldPos.X, MinY = ChunkWorldPos.Y, MinZ = ChunkWorldPos.Z;
const float MaxX = MinX + ExtentCm, MaxY = MinY + ExtentCm, MaxZ = MinZ + ExtentCm;
const float SkirtDepth = FMath::Max(1.0f, SkirtCells) * (float)Step * VOXEL_SIZE;
const float SkirtDepth = FMath::Max(1.0f, SkirtCells) * (float)Step * GeometryVoxelSize;
auto BoundaryFaceMask = [&](const FVector& A, const FVector& B) -> uint8
{
@@ -1656,12 +1669,12 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
{
if(!ShapeWorldContext)return 0.0f;
if(OriginalIndex<0||static_cast<size_t>(OriginalIndex)>=SurfaceVertexDensitySamples.size())
return ShapeWorldContext->DensityAt(Position.X/VOXEL_SIZE,
Position.Y/VOXEL_SIZE,Position.Z/VOXEL_SIZE);
return ShapeWorldContext->DensityAt(Position.X/GeometryVoxelSize,
Position.Y/GeometryVoxelSize,Position.Z/GeometryVoxelSize);
float& Density=SurfaceVertexDensitySamples[static_cast<size_t>(OriginalIndex)];
if(std::isnan(Density))
Density=ShapeWorldContext->DensityAt(Position.X/VOXEL_SIZE,
Position.Y/VOXEL_SIZE,Position.Z/VOXEL_SIZE);
Density=ShapeWorldContext->DensityAt(Position.X/GeometryVoxelSize,
Position.Y/GeometryVoxelSize,Position.Z/GeometryVoxelSize);
return Density;
};
@@ -1685,8 +1698,8 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
{
FSkirtVertex Vertex{Position,Normal,Color,0.0f,OriginalIndex};
if(!bOnSurface&&ShapeWorldContext)
Vertex.Density=ShapeWorldContext->DensityAt(Position.X/VOXEL_SIZE,
Position.Y/VOXEL_SIZE,Position.Z/VOXEL_SIZE);
Vertex.Density=ShapeWorldContext->DensityAt(Position.X/GeometryVoxelSize,
Position.Y/GeometryVoxelSize,Position.Z/GeometryVoxelSize);
return Vertex;
};
const auto InterpolateVertex=[&](const FSkirtVertex& A,const FSkirtVertex& B,float T)
@@ -1702,8 +1715,8 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
static_cast<uint8>(FMath::Clamp(FMath::RoundToInt(FMath::Lerp(static_cast<float>(A.Color.B),static_cast<float>(B.Color.B),T)),0,255)),
static_cast<uint8>(FMath::Clamp(FMath::RoundToInt(FMath::Lerp(static_cast<float>(A.Color.A),static_cast<float>(B.Color.A),T)),0,255)));
Out.Density=ShapeWorldContext
?ShapeWorldContext->DensityAt(Out.Position.X/VOXEL_SIZE,
Out.Position.Y/VOXEL_SIZE,Out.Position.Z/VOXEL_SIZE)
?ShapeWorldContext->DensityAt(Out.Position.X/GeometryVoxelSize,
Out.Position.Y/GeometryVoxelSize,Out.Position.Z/GeometryVoxelSize)
:FMath::Lerp(A.Density,B.Density,T);
Out.OriginalIndex=INDEX_NONE;
return Out;
@@ -1763,8 +1776,8 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
const FVector Position=P0.Position*static_cast<float>(WA)
+P1.Position*static_cast<float>(WB)
+P2.Position*static_cast<float>(WC);
return ShapeWorldContext->DensityAt(Position.X/VOXEL_SIZE,
Position.Y/VOXEL_SIZE,Position.Z/VOXEL_SIZE);
return ShapeWorldContext->DensityAt(Position.X/GeometryVoxelSize,
Position.Y/GeometryVoxelSize,Position.Z/GeometryVoxelSize);
};
const auto VertexProbeDensity=[&](const FSkirtVertex& Vertex)
{
@@ -1811,7 +1824,7 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
else if(ShapeWorldContext)
{
const FVector Center=(P0.Position+P1.Position+P2.Position)
/(3.0f*VOXEL_SIZE);
/(3.0f*GeometryVoxelSize);
if(ShapeWorldContext->DensityAt(Center.X,Center.Y,Center.Z)>0.0f)continue;
}
Tris.Add(PolygonIndices[0]);Tris.Add(PolygonIndices[Fan]);Tris.Add(PolygonIndices[Fan+1]);
@@ -94,6 +94,10 @@ public:
void SetGenerator(const UVoxelGenerator* InGenerator) { Generator = InGenerator; }
// Core tile coordinates use 25 cm voxels; legacy generation keeps 12.5 cm.
// Les coordonnees des tuiles Core utilisent des voxels de 25 cm; le legacy reste a 12,5 cm.
void SetGeometryVoxelSizeCm(float InVoxelSizeCm) { GeometryVoxelSizeCm = InVoxelSizeCm; }
// AVoxelWorld installs its bShuttingDown flag here. The commandlet path leaves it null.
// This is intentionally read-only: workers may observe shutdown, but never mutate world state.
void SetShutdownFlag(const std::atomic<bool>* InShutdownFlag) { ShutdownFlag = InShutdownFlag; }
@@ -116,6 +120,7 @@ private:
const std::atomic<bool>* ShutdownFlag = nullptr;
const FVoxelSharedDensityGrid* SharedDensityGrid = nullptr;
const FStandaloneShapeWorld* ShapeWorldContext = nullptr;
float GeometryVoxelSizeCm = VOXEL_SIZE;
public: