perf(generation): per-tile reach test skips landing and structural posts -- ~12% less worker CPU

The remove-one ablation put landing posts at ~10% and passage structural posts at ~6% of worker
time, though landings exist only near passage ends and the origin. The parked exact-cull round's
per-SAMPLE post bounds had been a net loss. This round decides reach once per TILE (Codex;
reviewed by me).

- VoxelTilePostReach.h: one per-tile reach mask (thread-local byte), set when the tile is set
  up. The origin landing, passage landing SDF/floors, native floors, tunnel air and passage
  structural posts return their input unchanged on tiles no instance can reach. Per sample this
  costs an inline flag read.
- Reach proofs come from each post's geometry (origin rooms, landing SDF and floors, native floor
  band, structural support spheres), not from comments.
- voxel.TilePostReachDebug=1 evaluates the skipped posts anyway and compares the FINAL field;
  voxel.TilePostReachScale=0.5 deliberately shrinks the reach and must fail.

Default build: 694 tiles, landing reachable on 4 (skipped on 690), structural posts skipped on 169.
Soundness: 123,958,673 comparisons, 0 differences; shrunk reach: 13,929 differences, FAIL as
required.

Final DEFAULT build vs the committed-tip DLL (same command line, two interleaved runs each):
  static  worker 34.80 -> 30.52 s (-12%)   LOD0 generation p50/p95 67.0/107.6 -> 55.8/95.8 ms
  moving  worker 75.96 -> 66.66 s (-12%)   LOD0 generation p50/p95 66.3/106.0 -> 56.0/95.8 ms
Field exact: 841/841 keyed tiles vs a fresh committed-tip trace (669,902 triangles, which includes
9260775's gap floors), export b3e5f4c3..9b377, capability 20,830 / 10,909; strate-crossing and
sealed-proof tests pass.
Ledger: all launches passed or failed where designed to; early raw-SDF debug attempts failed
until the comparator was corrected to compare the final field. No crash folders.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01TaFdXhTdYMkW1xrV6ApT6Y
This commit is contained in:
Fr0zkaandClaude Opus 5 committed 2026-09-15 07:42:13 +02:00
1 parent 92607751b1
commit ce4d8783e9
7 files changed
+790 -20

No files matched your search

@@ -4,6 +4,8 @@
#include "VoxelMarchingCubesMesher.h"
#include "MarchingCubesTables.h"
#include "VoxelDensityProfile.h"
#include "VoxelStrateManager.h"
#include "VoxelTilePostReach.h"
#include "ProfilingDebugging/CpuProfilerTrace.h"
#include "HAL/IConsoleManager.h"
#include "Misc/CommandLine.h"
@@ -17,6 +19,45 @@ namespace
TEXT("Use the operator-major density block path for non-shared mesher grids."));
bool GVoxelForgeBlockSwitchParsed = false;
int32 GVoxelForgeTilePostReachDebug = 0;
FAutoConsoleVariableRef CVarVoxelForgeTilePostReachDebug(
TEXT("voxel.TilePostReachDebug"),
GVoxelForgeTilePostReachDebug,
TEXT("Run skipped landing/structural posts in a bypass and compare their exact result; "
"a nonzero difference fails the debug run."));
float GVoxelForgeTilePostReachScale = 1.0f;
FAutoConsoleVariableRef CVarVoxelForgeTilePostReachScale(
TEXT("voxel.TilePostReachScale"),
GVoxelForgeTilePostReachScale,
TEXT("Scale the per-tile post reach for deliberate soundness tests. Default 1.0 is exact; "
"values below 1 intentionally shrink the guard."));
bool GVoxelForgeTilePostReachSwitchesParsed = false;
void VF_ParseTilePostReachSwitches()
{
if (GVoxelForgeTilePostReachSwitchesParsed)
{
return;
}
GVoxelForgeTilePostReachSwitchesParsed = true;
int32 DebugValue = GVoxelForgeTilePostReachDebug;
float ScaleValue = GVoxelForgeTilePostReachScale;
FParse::Value(
FCommandLine::Get(), TEXT("voxel.TilePostReachDebug="), DebugValue);
FParse::Value(
FCommandLine::Get(), TEXT("voxel.TilePostReachScale="), ScaleValue);
GVoxelForgeTilePostReachDebug = DebugValue != 0 ? 1 : 0;
if (!VoxelMath::IsFinite(ScaleValue) || ScaleValue <= 0.0f)
{
ScaleValue = 1.0f;
}
GVoxelForgeTilePostReachScale = FMath::Min(ScaleValue, 1.0f);
VoxelGenLOD::GTilePostReachDebugEnabled.store(
GVoxelForgeTilePostReachDebug != 0, std::memory_order_relaxed);
}
void VF_ParseOperatorBlockSwitch()
{
if (GVoxelForgeBlockSwitchParsed) { return; }
@@ -42,6 +83,7 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
{
TRACE_CPUPROFILER_EVENT_SCOPE(VoxelForge_MesherGenerateMesh);
VF_ParseOperatorBlockSwitch();
VF_ParseTilePostReachSwitches();
FVoxelMeshData MeshData;
if (OutCaptureGrid) { OutCaptureGrid->Reset(); }
if (OutDensitySampleCount) { *OutDensitySampleCount = 0; }
@@ -233,6 +275,49 @@ FVoxelMeshData UVoxelMarchingCubesMesher::GenerateMesh(FIntVector OriginVoxels,
VoxelGenLOD::TileOriginVoxels, OriginVoxels);
TGuardValue<int32> TileCellsGuard(
VoxelGenLOD::TileCellsPerAxis, CellsPerAxis);
// Every density sample in this tile sees the same post-reach decision. The one-point halo
// matches the actual grid fill below (gx/gy/gz = -1..GridDim), so a false bit proves that no
// landing or passage structural writer can reach any sample used by meshing or gradients.
TGuardValue<bool> TilePostReachDebugGuard(
VoxelGenLOD::bTilePostReachDebug,
GVoxelForgeTilePostReachDebug != 0);
TGuardValue<bool> TilePostReachBypassGuard(
VoxelGenLOD::bTilePostReachBypass, false);
uint8 TilePostReachFlags = VoxelGenLOD::AllTilePostReach;
if (Generator->StrateManager != nullptr)
{
const int64 Extent = static_cast<int64>(CellsPerAxis + 1) * Step;
const FBox LatticeWithHalo(
FVector(
static_cast<float>(static_cast<int64>(OriginVoxels.X) - Step),
static_cast<float>(static_cast<int64>(OriginVoxels.Y) - Step),
static_cast<float>(static_cast<int64>(OriginVoxels.Z) - Step)),
FVector(
static_cast<float>(static_cast<int64>(OriginVoxels.X) + Extent),
static_cast<float>(static_cast<int64>(OriginVoxels.Y) + Extent),
static_cast<float>(static_cast<int64>(OriginVoxels.Z) + Extent)));
const float ReachScale = GVoxelForgeTilePostReachScale;
TilePostReachFlags = 0;
if (Generator->StrateManager->AnyOriginLandingNearLattice(
LatticeWithHalo, OriginVoxels, Step, ReachScale))
{
TilePostReachFlags |= VoxelGenLOD::OriginLandingReachable;
}
if (Generator->StrateManager->AnyPassageLandingNearLattice(
LatticeWithHalo, OriginVoxels, Step, ReachScale))
{
TilePostReachFlags |= VoxelGenLOD::PassageLandingReachable;
}
if (Generator->StrateManager->AnyPassageStructuralPostNearLattice(
LatticeWithHalo, OriginVoxels, Step, ReachScale))
{
TilePostReachFlags |= VoxelGenLOD::PassageStructuralReachable;
}
}
TGuardValue<uint8> TilePostReachFlagsGuard(
VoxelGenLOD::TilePostReachFlags, TilePostReachFlags);
VoxelGenLOD::RecordTileReachMask(TilePostReachFlags);
// COUPE DE CONTENU PAR STRATE — restreint le maillage (et l'échantillonnage) aux cellules
// dont l'intervalle Z chevauche la bande [BandZMinVox, BandZMaxVox] (voxels inclusifs).
// Les tuiles à capture ne sont jamais bandées (niveau 0 — garde-fou ci-dessous).
+387 -17
View File
@@ -2511,6 +2511,12 @@ float UVoxelStrateManager::EvaluateModifierSDF(float WorldX, float WorldY, float
return FLT_MAX;
}
// The landing terms are part of the passage modifier, so their reach proof is deliberately
// wider than the direct post's four-voxel blend: SmoothMin can lower a finite term by K/6 at
// each later combine. Outside that padded room domain, omitting the two landing evaluations
// is an identity for VF_ApplyPassageCarving.
const bool bEvaluateLandingSDF = VoxelGenLOD::IsPassageLandingReachable()
|| VoxelGenLOD::IsTilePostReachBypassActive();
const FIntVector ChunkCoord(
FMath::FloorToInt(WorldX / (float)CHUNK_SIZE),
FMath::FloorToInt(WorldY / (float)CHUNK_SIZE),
@@ -2602,10 +2608,13 @@ float UVoxelStrateManager::EvaluateModifierSDF(float WorldX, float WorldY, float
// A landing is a real room with a hard flat-floor half-space, not a sphere around the
// tube endpoint. It is the same fixed SDF geometry selected during GeneratePassages; it
// never performs a source query here and does not synthesize a radial root connector.
const float UpperLandingSDF = VF_EvaluatePassageLandingSDF(Pos, P.UpperLanding);
const float LowerLandingSDF = VF_EvaluatePassageLandingSDF(Pos, P.LowerLanding);
MinSDF = VoxelSDF::SmoothMin(MinSDF, UpperLandingSDF, BlendK);
MinSDF = VoxelSDF::SmoothMin(MinSDF, LowerLandingSDF, BlendK);
if (bEvaluateLandingSDF)
{
const float UpperLandingSDF = VF_EvaluatePassageLandingSDF(Pos, P.UpperLanding);
const float LowerLandingSDF = VF_EvaluatePassageLandingSDF(Pos, P.LowerLanding);
MinSDF = VoxelSDF::SmoothMin(MinSDF, UpperLandingSDF, BlendK);
MinSDF = VoxelSDF::SmoothMin(MinSDF, LowerLandingSDF, BlendK);
}
}
return MinSDF;
@@ -2617,13 +2626,41 @@ void UVoxelStrateManager::ApplyPassageModifier(
{
VoxelDensityProfile::FScopedTimer ProfileTimer(
VoxelDensityProfile::EBucket::PassageModifier);
const bool bBypass = VoxelGenLOD::IsTilePostReachBypassActive();
const bool bCompareLandingModifier = VoxelGenLOD::bTilePostReachDebug
&& !VoxelGenLOD::IsPassageLandingReachable() && !bBypass;
float CanonicalModifierDensity = Density;
if (bCompareLandingModifier)
{
const bool PreviousBypass = VoxelGenLOD::bTilePostReachBypass;
VoxelGenLOD::bTilePostReachBypass = true;
const float CanonicalSDF = EvaluateModifierSDF(WorldX, WorldY, WorldZ);
VF_ApplyPassageCarving(
CanonicalModifierDensity, CanonicalSDF, BaseDensity, SealThickness);
VoxelGenLOD::bTilePostReachBypass = PreviousBypass;
}
if (!VoxelDensityAblation::IsPassageCarvingOff())
{
const float ModSDF = EvaluateModifierSDF(WorldX, WorldY, WorldZ);
VF_ApplyPassageCarving(Density, ModSDF, BaseDensity, SealThickness);
}
if (bCompareLandingModifier)
{
VoxelGenLOD::RecordSkippedPostComparison(
VoxelGenLOD::ETilePostComparisonKind::PassageLandingSDF,
!VoxelGenLOD::SameFloatBits(Density, CanonicalModifierDensity));
}
ApplyPassageLandingAir(Density, WorldX, WorldY, WorldZ, BaseDensity, SealThickness);
const bool bLandingReachable = VoxelGenLOD::IsPassageLandingReachable()
|| VoxelGenLOD::IsTilePostReachBypassActive();
const bool bStructuralReachable = VoxelGenLOD::IsPassageStructuralReachable()
|| VoxelGenLOD::IsTilePostReachBypassActive();
if (!bLandingReachable && !bStructuralReachable)
{
return;
}
const FIntVector ChunkCoord(
FMath::FloorToInt(WorldX / (float)CHUNK_SIZE),
FMath::FloorToInt(WorldY / (float)CHUNK_SIZE),
@@ -2634,10 +2671,12 @@ void UVoxelStrateManager::ApplyPassageModifier(
for (const int32 PassageIndex : Nearby)
{
const FVoxelPassage& Passage = PassageData[PassageIndex];
const bool bLandingFloor = !VoxelDensityAblation::IsLandingPostsOff()
const bool bLandingFloor = bLandingReachable
&& !VoxelDensityAblation::IsLandingPostsOff()
&& (VF_IsPassageLandingFloor(Position, Passage.UpperLanding)
|| VF_IsPassageLandingFloor(Position, Passage.LowerLanding));
const bool bLegacySupportFloor = !VoxelDensityAblation::IsPassageStructuralPostsOff()
const bool bLegacySupportFloor = bStructuralReachable
&& !VoxelDensityAblation::IsPassageStructuralPostsOff()
&& bPassageSupportFloorWritesEnabled
&& !Passage.bNativeFloorEnabled
&& VF_IsWalkableTunnelFloor(Passage, Position, this, PassageIndex);
@@ -2656,7 +2695,10 @@ void UVoxelStrateManager::ApplyPassageModifier(
// the current walkable tunnel. Reassert tunnel air after all floor posts so overlap cannot
// turn a valid route into a solid plug. At the tunnel's own floor the air predicate is false,
// so the support plane remains solid.
ApplyPassageTunnelAir(Density, WorldX, WorldY, WorldZ, BaseDensity, SealThickness);
if (bStructuralReachable)
{
ApplyPassageTunnelAir(Density, WorldX, WorldY, WorldZ, BaseDensity, SealThickness);
}
}
void UVoxelStrateManager::ApplyPassageCarvingOnly(
@@ -2669,8 +2711,27 @@ void UVoxelStrateManager::ApplyPassageCarvingOnly(
}
VoxelDensityProfile::FScopedTimer ProfileTimer(
VoxelDensityProfile::EBucket::PassageModifier);
const bool bBypass = VoxelGenLOD::IsTilePostReachBypassActive();
const bool bCompareLandingModifier = VoxelGenLOD::bTilePostReachDebug
&& !VoxelGenLOD::IsPassageLandingReachable() && !bBypass;
float CanonicalModifierDensity = Density;
if (bCompareLandingModifier)
{
const bool PreviousBypass = VoxelGenLOD::bTilePostReachBypass;
VoxelGenLOD::bTilePostReachBypass = true;
const float CanonicalSDF = EvaluateModifierSDF(WorldX, WorldY, WorldZ);
VF_ApplyPassageCarving(
CanonicalModifierDensity, CanonicalSDF, BaseDensity, SealThickness);
VoxelGenLOD::bTilePostReachBypass = PreviousBypass;
}
const float ModSDF = EvaluateModifierSDF(WorldX, WorldY, WorldZ);
VF_ApplyPassageCarving(Density, ModSDF, BaseDensity, SealThickness);
if (bCompareLandingModifier)
{
VoxelGenLOD::RecordSkippedPostComparison(
VoxelGenLOD::ETilePostComparisonKind::PassageLandingSDF,
!VoxelGenLOD::SameFloatBits(Density, CanonicalModifierDensity));
}
}
void UVoxelStrateManager::ApplyPassageLandingAir(
@@ -2681,6 +2742,16 @@ void UVoxelStrateManager::ApplyPassageLandingAir(
{
return;
}
if (!VoxelGenLOD::IsPassageLandingReachable()
&& !VoxelGenLOD::IsTilePostReachBypassActive())
{
VoxelGenLOD::CompareSkippedPost(Density, [&]()
{
ApplyPassageLandingAir(
Density, WorldX, WorldY, WorldZ, BaseDensity, SealThickness);
}, VoxelGenLOD::ETilePostComparisonKind::PassageLandingAir);
return;
}
VoxelDensityProfile::FScopedTimer ProfileTimer(
VoxelDensityProfile::EBucket::PassageLandingAir);
const FIntVector ChunkCoord(
@@ -2749,6 +2820,16 @@ void UVoxelStrateManager::ApplyPassageTunnelAir(
{
return;
}
if (!VoxelGenLOD::IsPassageStructuralReachable()
&& !VoxelGenLOD::IsTilePostReachBypassActive())
{
VoxelGenLOD::CompareSkippedPost(Density, [&]()
{
ApplyPassageTunnelAir(
Density, WorldX, WorldY, WorldZ, BaseDensity, SealThickness);
}, VoxelGenLOD::ETilePostComparisonKind::PassageTunnelAir);
return;
}
VoxelDensityProfile::FScopedTimer ProfileTimer(
VoxelDensityProfile::EBucket::PassageTunnelAir);
const FVector Position(WorldX, WorldY, WorldZ);
@@ -2784,6 +2865,30 @@ void UVoxelStrateManager::ApplyPassageLandingFloorMC(
{
return;
}
const bool bBypass = VoxelGenLOD::IsTilePostReachBypassActive();
const bool bLandingReachable = VoxelGenLOD::IsPassageLandingReachable() || bBypass;
const bool bStructuralReachable = VoxelGenLOD::IsPassageStructuralReachable() || bBypass;
const bool bCompareLanding = VoxelGenLOD::bTilePostReachDebug
&& !bLandingReachable && !bBypass;
float CanonicalDensity = Density;
if (bCompareLanding)
{
const bool PreviousBypass = VoxelGenLOD::bTilePostReachBypass;
VoxelGenLOD::bTilePostReachBypass = true;
ApplyPassageLandingFloorMC(
CanonicalDensity, WorldX, WorldY, WorldZ, BaseDensity);
VoxelGenLOD::bTilePostReachBypass = PreviousBypass;
}
if (!bLandingReachable && !bStructuralReachable)
{
if (bCompareLanding)
{
VoxelGenLOD::RecordSkippedPostComparison(
VoxelGenLOD::ETilePostComparisonKind::PassageLandingFloor,
!VoxelGenLOD::SameFloatBits(Density, CanonicalDensity));
}
return;
}
VoxelDensityProfile::FScopedTimer ProfileTimer(
VoxelDensityProfile::EBucket::PassageLandingFloor);
const FIntVector ChunkCoord(
@@ -2796,10 +2901,12 @@ void UVoxelStrateManager::ApplyPassageLandingFloorMC(
for (const int32 PassageIndex : Nearby)
{
const FVoxelPassage& Passage = PassageData[PassageIndex];
const bool bLandingFloor = !VoxelDensityAblation::IsLandingPostsOff()
const bool bLandingFloor = bLandingReachable
&& !VoxelDensityAblation::IsLandingPostsOff()
&& (VF_IsPassageLandingFloor(Position, Passage.UpperLanding)
|| VF_IsPassageLandingFloor(Position, Passage.LowerLanding));
const bool bLegacySupportFloor = !VoxelDensityAblation::IsPassageStructuralPostsOff()
const bool bLegacySupportFloor = bStructuralReachable
&& !VoxelDensityAblation::IsPassageStructuralPostsOff()
&& bPassageSupportFloorWritesEnabled
&& !Passage.bNativeFloorEnabled
&& VF_IsWalkableTunnelFloor(Passage, Position, this, PassageIndex);
@@ -2812,6 +2919,12 @@ void UVoxelStrateManager::ApplyPassageLandingFloorMC(
break;
}
}
if (bCompareLanding)
{
VoxelGenLOD::RecordSkippedPostComparison(
VoxelGenLOD::ETilePostComparisonKind::PassageLandingFloor,
!VoxelGenLOD::SameFloatBits(Density, CanonicalDensity));
}
}
static bool VF_IsPassageRoomFloor(
@@ -2844,6 +2957,32 @@ void UVoxelStrateManager::ApplyPassageStructuralPostsMC(
return;
}
const bool bBypass = VoxelGenLOD::IsTilePostReachBypassActive();
const bool bLandingReachable = VoxelGenLOD::IsPassageLandingReachable() || bBypass;
const bool bStructuralReachable = VoxelGenLOD::IsPassageStructuralReachable() || bBypass;
const bool bCompareLanding = VoxelGenLOD::bTilePostReachDebug
&& !bLandingReachable && !bBypass;
float CanonicalDensity = Density;
if (bCompareLanding)
{
const bool PreviousBypass = VoxelGenLOD::bTilePostReachBypass;
VoxelGenLOD::bTilePostReachBypass = true;
ApplyPassageStructuralPostsMC(
CanonicalDensity, WorldX, WorldY, WorldZ,
BaseDensity, SealThickness, bProtectAuthoredTunnelFloor);
VoxelGenLOD::bTilePostReachBypass = PreviousBypass;
}
if (!bLandingReachable && !bStructuralReachable)
{
if (bCompareLanding)
{
VoxelGenLOD::RecordSkippedPostComparison(
VoxelGenLOD::ETilePostComparisonKind::PassageStructuralPosts,
!VoxelGenLOD::SameFloatBits(Density, CanonicalDensity));
}
return;
}
VoxelDensityProfile::FScopedTimer ProfileTimer(
VoxelDensityProfile::EBucket::PassageStructuralPosts);
@@ -2873,36 +3012,37 @@ void UVoxelStrateManager::ApplyPassageStructuralPostsMC(
const FVoxelPassage& Passage = PassageData[PassageIndex];
const bool bTunnelSupportFloor =
!bDisableStructuralPosts
bStructuralReachable && !bDisableStructuralPosts
&& bPassageSupportFloorWritesEnabled
&& !Passage.bNativeFloorEnabled
&& VF_IsWalkableTunnelFloor(Passage, Position, this, PassageIndex);
if (!bSuppressFloor && !bDisableLandingPosts
if (!bSuppressFloor && bLandingReachable && !bDisableLandingPosts
&& (VF_IsPassageLandingFloor(Position, Passage.UpperLanding)
|| VF_IsPassageLandingFloor(Position, Passage.LowerLanding)))
{
bAnyLandingFloor = true;
}
if (!bSuppressFloor && !bDisableStructuralPosts && bTunnelSupportFloor)
if (!bSuppressFloor && bStructuralReachable
&& !bDisableStructuralPosts && bTunnelSupportFloor)
{
bLegacyTunnelSupportFloor = true;
}
if (!bSuppressFloor && !bDisableLandingPosts
if (!bSuppressFloor && bLandingReachable && !bDisableLandingPosts
&& (VF_IsPassageRoomFloor(Position, Passage.UpperLanding)
|| VF_IsPassageRoomFloor(Position, Passage.LowerLanding)))
{
bAnyRoomFloor = true;
}
if (!bDisableStructuralPosts && !bWalkableAir
if (bStructuralReachable && !bDisableStructuralPosts && !bWalkableAir
&& FVector::DistSquared(Position, Passage.BoundCenter) <= Passage.BoundRadiusSq
&& VF_IsWalkableTunnelAir(Passage, Position, this, PassageIndex))
{
bWalkableAir = true;
}
if (!bDisableLandingPosts
if (bLandingReachable && !bDisableLandingPosts
&& FVector::DistSquared(Position, Passage.BoundCenter) <= Passage.BoundRadiusSq)
{
const FVoxelPassageLanding* Landings[] = {
@@ -2950,6 +3090,12 @@ void UVoxelStrateManager::ApplyPassageStructuralPostsMC(
VoxelDensityProfile::AddCounter(
VoxelDensityProfile::ECounter::PassageSupportFloorBackstopFires);
}
if (bCompareLanding)
{
VoxelGenLOD::RecordSkippedPostComparison(
VoxelGenLOD::ETilePostComparisonKind::PassageStructuralPosts,
!VoxelGenLOD::SameFloatBits(Density, CanonicalDensity));
}
}
void UVoxelStrateManager::ApplyPassageNativeFloorMC(
@@ -2960,6 +3106,15 @@ void UVoxelStrateManager::ApplyPassageNativeFloorMC(
{
return;
}
if (!VoxelGenLOD::IsPassageStructuralReachable()
&& !VoxelGenLOD::IsTilePostReachBypassActive())
{
VoxelGenLOD::CompareSkippedPost(Density, [&]()
{
ApplyPassageNativeFloorMC(Density, WorldX, WorldY, WorldZ, BaseDensity);
}, VoxelGenLOD::ETilePostComparisonKind::PassageNativeFloor);
return;
}
const FIntVector ChunkCoord(
FMath::FloorToInt(WorldX / (float)CHUNK_SIZE),
FMath::FloorToInt(WorldY / (float)CHUNK_SIZE),
@@ -3018,6 +3173,16 @@ void UVoxelStrateManager::ApplyPassageLandingRoomFloorMC(
{
return;
}
if (!VoxelGenLOD::IsPassageLandingReachable()
&& !VoxelGenLOD::IsTilePostReachBypassActive())
{
VoxelGenLOD::CompareSkippedPost(Density, [&]()
{
ApplyPassageLandingRoomFloorMC(
Density, WorldX, WorldY, WorldZ, BaseDensity);
}, VoxelGenLOD::ETilePostComparisonKind::PassageLandingRoomFloor);
return;
}
VoxelDensityProfile::FScopedTimer ProfileTimer(
VoxelDensityProfile::EBucket::PassageLandingRoomFloor);
const FIntVector ChunkCoord(
@@ -3912,6 +4077,22 @@ namespace
FMath::Min((float)Box.Max.Z, MaxZ),
(float)Origin.Z, Step);
}
static bool VF_LatticeBoxTouchesSphere(
const FBox& Box, const FVector& Center, float Radius)
{
if (!Box.IsValid || !VoxelMath::IsFinite(Center.X)
|| !VoxelMath::IsFinite(Center.Y) || !VoxelMath::IsFinite(Center.Z)
|| !VoxelMath::IsFinite(Radius) || Radius < 0.0f)
{
return true;
}
const FVector Closest(
FMath::Clamp(Center.X, (float)Box.Min.X, (float)Box.Max.X),
FMath::Clamp(Center.Y, (float)Box.Min.Y, (float)Box.Max.Y),
FMath::Clamp(Center.Z, (float)Box.Min.Z, (float)Box.Max.Z));
return FVector::DistSquared(Closest, Center) <= Radius * Radius;
}
}
bool UVoxelStrateManager::AnyPassageNearLattice(
@@ -4768,6 +4949,189 @@ bool UVoxelStrateManager::AnyPassageLandingFloorNearLattice(
return false;
}
bool UVoxelStrateManager::AnyPassageLandingNearLattice(
const FBox& VoxelBox, const FIntVector& LatticeOrigin, int32 Step,
float ReachScale) const
{
if (Step <= 0 || !VoxelBox.IsValid
|| !VoxelMath::IsFinite(ReachScale) || ReachScale <= 0.0f)
{
return true;
}
// VF_ApplyPassageCarving has a hard no-op band at ModSDF >= 4. A landing term outside the
// rounded-room AABB by 4 + K (K=3) is either saturated out of SmoothMin when the tube is
// inside the carve band, or leaves the folded result >= 4 when the tube is outside it. That
// proves the landing term cannot change the field; the direct landing/floor posts use their
// smaller, operation-specific pads below.
for (const FVoxelPassage& Passage : Passages)
{
if (!VoxelMath::IsFinite(Passage.BoundCenter.X)
|| !VoxelMath::IsFinite(Passage.BoundCenter.Y)
|| !VoxelMath::IsFinite(Passage.BoundCenter.Z)
|| !VoxelMath::IsFinite(Passage.BoundRadius)
|| !VoxelMath::IsFinite(Passage.BoundRadiusSq)
|| Passage.BoundRadius < 0.0f || Passage.BoundRadiusSq < 0.0f)
{
return true;
}
if (Passage.ControlPoints.Num() >= 2)
{
if (Passage.ControlPoints.Num() > 4096)
{
return true;
}
const bool bTaper = Passage.ControlRadii.Num() == Passage.ControlPoints.Num();
if (!bTaper && !VoxelMath::IsFinite(Passage.Radius))
{
return true;
}
for (int32 PointIndex = 0;
PointIndex < Passage.ControlPoints.Num(); ++PointIndex)
{
const FVector& Point = Passage.ControlPoints[PointIndex];
if (!VoxelMath::IsFinite(Point.X) || !VoxelMath::IsFinite(Point.Y)
|| !VoxelMath::IsFinite(Point.Z)
|| (bTaper && !VoxelMath::IsFinite(Passage.ControlRadii[PointIndex])))
{
return true;
}
}
}
else
{
if (!VoxelMath::IsFinite(Passage.UpperPoint.X)
|| !VoxelMath::IsFinite(Passage.UpperPoint.Y)
|| !VoxelMath::IsFinite(Passage.UpperPoint.Z)
|| !VoxelMath::IsFinite(Passage.LowerPoint.X)
|| !VoxelMath::IsFinite(Passage.LowerPoint.Y)
|| !VoxelMath::IsFinite(Passage.LowerPoint.Z)
|| !VoxelMath::IsFinite(Passage.Radius))
{
return true;
}
}
const FVoxelPassageLanding* Landings[] = {
&Passage.UpperLanding, &Passage.LowerLanding };
for (const FVoxelPassageLanding* Landing : Landings)
{
if (!VoxelMath::IsFinite(Landing->StandingPoint.X)
|| !VoxelMath::IsFinite(Landing->StandingPoint.Y)
|| !VoxelMath::IsFinite(Landing->FloorZ)
|| !VoxelMath::IsFinite(Landing->CeilingZ)
|| !VoxelMath::IsFinite(Landing->HalfWidth)
|| !VoxelMath::IsFinite(Landing->FloorThickness))
{
return true;
}
if (Landing->HalfWidth > 0.0f
&& Landing->FloorThickness > 0.0f
&& VF_LatticeBoxTouchesAABB(
VoxelBox, LatticeOrigin, Step,
Landing->StandingPoint.X - FMath::Max(Landing->HalfWidth - 1.0f, 0.0f)
- ReachScale,
Landing->StandingPoint.X + FMath::Max(Landing->HalfWidth - 1.0f, 0.0f)
+ ReachScale,
Landing->StandingPoint.Y - FMath::Max(Landing->HalfWidth - 1.0f, 0.0f)
- ReachScale,
Landing->StandingPoint.Y + FMath::Max(Landing->HalfWidth - 1.0f, 0.0f)
+ ReachScale,
Landing->FloorZ - Landing->FloorThickness - ReachScale,
Landing->FloorZ + ReachScale))
{
return true;
}
if (Landing->HalfWidth <= 0.0f || Landing->CeilingZ <= Landing->FloorZ)
{
// VF_EvaluatePassageLandingSDF returns FLT_MAX for this descriptor. The floor
// test above has already handled the only remaining possible writer.
continue;
}
}
}
constexpr float SmoothMinK = 3.0f;
const float RoomPad = (VoxelPassageGeometry::LandingCarveBlendVoxels + SmoothMinK)
* ReachScale;
if (!VoxelMath::IsFinite(RoomPad) || RoomPad < 0.0f)
{
return true;
}
for (const FVoxelPassage& Passage : Passages)
{
const FVoxelPassageLanding* Landings[] = {
&Passage.UpperLanding, &Passage.LowerLanding };
for (const FVoxelPassageLanding* Landing : Landings)
{
if (Landing->HalfWidth <= 0.0f || Landing->CeilingZ <= Landing->FloorZ)
{
continue;
}
constexpr float RoomRounding = 1.5f;
const float Height = Landing->CeilingZ - Landing->FloorZ;
const float HalfX = FMath::Max(Landing->HalfWidth - RoomRounding, 0.25f);
const float HalfZ = FMath::Max(Height * 0.5f - RoomRounding, 0.25f);
const float CenterZ = (Landing->FloorZ + Landing->CeilingZ) * 0.5f;
if (VF_LatticeBoxTouchesAABB(
VoxelBox, LatticeOrigin, Step,
Landing->StandingPoint.X - HalfX - RoomRounding - RoomPad,
Landing->StandingPoint.X + HalfX + RoomRounding + RoomPad,
Landing->StandingPoint.Y - HalfX - RoomRounding - RoomPad,
Landing->StandingPoint.Y + HalfX + RoomRounding + RoomPad,
FMath::Min(Landing->FloorZ,
CenterZ - HalfZ - RoomRounding) - RoomPad,
FMath::Max(Landing->CeilingZ,
CenterZ + HalfZ + RoomRounding) + RoomPad))
{
return true;
}
}
}
return false;
}
bool UVoxelStrateManager::AnyPassageStructuralPostNearLattice(
const FBox& VoxelBox, const FIntVector& LatticeOrigin, int32 Step,
float ReachScale) const
{
(void)LatticeOrigin;
(void)Step;
if (Step <= 0 || !VoxelBox.IsValid
|| !VoxelMath::IsFinite(ReachScale) || ReachScale <= 0.0f)
{
return true;
}
// The construction-time BoundRadius encloses every tube, landing room, floor band, and its
// four-voxel carve margin. All structural writers below are subsets of that sphere, so a
// sphere/AABB miss proves identity without doing a per-sample chunk-shortlist lookup.
for (const FVoxelPassage& Passage : Passages)
{
if (!VoxelMath::IsFinite(Passage.BoundCenter.X)
|| !VoxelMath::IsFinite(Passage.BoundCenter.Y)
|| !VoxelMath::IsFinite(Passage.BoundCenter.Z)
|| !VoxelMath::IsFinite(Passage.BoundRadius)
|| !VoxelMath::IsFinite(Passage.BoundRadiusSq)
|| Passage.BoundRadius < 0.0f || Passage.BoundRadiusSq < 0.0f)
{
return true;
}
const float Reach = (Passage.BoundRadius + 1.0f) * ReachScale;
if (!VoxelMath::IsFinite(Reach)
|| VF_LatticeBoxTouchesSphere(VoxelBox, Passage.BoundCenter, Reach))
{
return true;
}
}
return false;
}
bool UVoxelStrateManager::AnyLandingFloorAtLattice(
const FBox& VoxelBox, const FIntVector& LatticeOrigin, int32 Step) const
{
@@ -5013,9 +5377,14 @@ bool UVoxelStrateManager::AnyOriginLandingFloorNearBox(
}
bool UVoxelStrateManager::AnyOriginLandingNearLattice(
const FBox& VoxelBox, const FIntVector& LatticeOrigin, int32 Step) const
const FBox& VoxelBox, const FIntVector& LatticeOrigin, int32 Step,
float ReachScale) const
{
if (OriginSpineRadius <= 0.0f) return false;
if (!VoxelMath::IsFinite(ReachScale) || ReachScale <= 0.0f)
{
return true;
}
for (const FStrateSlot& Slot : StrateLayout)
{
if (Slot.Definition == nullptr) continue;
@@ -5023,7 +5392,8 @@ bool UVoxelStrateManager::AnyOriginLandingNearLattice(
const float BottomZ = static_cast<float>(Slot.BottomChunkZ) * CHUNK_SIZE;
const float Seal = VF_BoundarySealThicknessForDefinition(*Slot.Definition);
if (VoxelPassageGeometry::OriginLandingRoomTouchesLattice(
VoxelBox, LatticeOrigin, Step, TopZ, BottomZ, Seal, OriginSpineRadius))
VoxelBox, LatticeOrigin, Step, TopZ, BottomZ, Seal, OriginSpineRadius,
ReachScale))
{
return true;
}
+93
View File
@@ -19,6 +19,7 @@
#include "VoxelStats.h"
#include "VoxelCaveMorphology.h"
#include "VoxelPassageGeometry.h"
#include "VoxelTilePostReach.h"
// IWYU (FPSemantics = Precise ⇒ plus de PCH partagé) : GetPlayerPosition déréférence le pawn, donc
// APawn doit être COMPLET — `Casts.h` n'en donne qu'une déclaration avant. APlayerController était
// complet par transitivité seulement : on l'inclut explicitement, c'est exactement la fragilité
@@ -1132,6 +1133,98 @@ void AVoxelWorld::EndPlay(const EEndPlayReason::Type EndPlayReason)
}
VoxelCaveMorphology::LogPlayerFitMemoStats();
LogStreamingLatencySummary();
const uint64 TilePostReachDifferences =
VoxelGenLOD::GSkippedPostDifferences.load(std::memory_order_relaxed);
UE_LOG(LogTemp, Display,
TEXT("[VoxelForgeTilePostReach] tiles=%llu origin_reachable=%llu origin_skipped=%llu "
"passage_landing_reachable=%llu passage_landing_skipped=%llu "
"passage_structural_reachable=%llu passage_structural_skipped=%llu "
"debug=%d comparisons=%llu differences=%llu"),
static_cast<unsigned long long>(
VoxelGenLOD::GTilePostReachTileCount.load(std::memory_order_relaxed)),
static_cast<unsigned long long>(
VoxelGenLOD::GOriginLandingReachableTiles.load(std::memory_order_relaxed)),
static_cast<unsigned long long>(
VoxelGenLOD::GOriginLandingSkippedTiles.load(std::memory_order_relaxed)),
static_cast<unsigned long long>(
VoxelGenLOD::GPassageLandingReachableTiles.load(std::memory_order_relaxed)),
static_cast<unsigned long long>(
VoxelGenLOD::GPassageLandingSkippedTiles.load(std::memory_order_relaxed)),
static_cast<unsigned long long>(
VoxelGenLOD::GPassageStructuralReachableTiles.load(std::memory_order_relaxed)),
static_cast<unsigned long long>(
VoxelGenLOD::GPassageStructuralSkippedTiles.load(std::memory_order_relaxed)),
VoxelGenLOD::GTilePostReachDebugEnabled.load(std::memory_order_relaxed) ? 1 : 0,
static_cast<unsigned long long>(
VoxelGenLOD::GSkippedPostComparisons.load(std::memory_order_relaxed)),
static_cast<unsigned long long>(TilePostReachDifferences));
UE_LOG(LogTemp, Display,
TEXT("[VoxelForgeTilePostReachKinds] comparisons="
"origin_air=%llu/origin_floor=%llu/passage_sdf=%llu/landing_air=%llu/"
"tunnel_air=%llu/landing_floor=%llu/structural=%llu/native_floor=%llu/room_floor=%llu "
"differences=%llu/%llu/%llu/%llu/%llu/%llu/%llu/%llu/%llu"),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostComparisonsByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::OriginAir)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostComparisonsByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::OriginFloor)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostComparisonsByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageLandingSDF)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostComparisonsByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageLandingAir)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostComparisonsByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageTunnelAir)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostComparisonsByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageLandingFloor)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostComparisonsByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageStructuralPosts)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostComparisonsByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageNativeFloor)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostComparisonsByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageLandingRoomFloor)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostDifferencesByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::OriginAir)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostDifferencesByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::OriginFloor)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostDifferencesByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageLandingSDF)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostDifferencesByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageLandingAir)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostDifferencesByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageTunnelAir)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostDifferencesByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageLandingFloor)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostDifferencesByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageStructuralPosts)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostDifferencesByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageNativeFloor)].load(
std::memory_order_relaxed)),
static_cast<unsigned long long>(VoxelGenLOD::GSkippedPostDifferencesByKind[
static_cast<uint8>(VoxelGenLOD::ETilePostComparisonKind::PassageLandingRoomFloor)].load(
std::memory_order_relaxed)));
if (VoxelGenLOD::GTilePostReachDebugEnabled.load(std::memory_order_relaxed)
&& TilePostReachDifferences != 0)
{
UE_LOG(LogTemp, Error,
TEXT("[VoxelForgeTilePostReach] soundness failure: skipped post changed the field."));
FPlatformMisc::RequestExitWithStatus(
false, 1, TEXT("VoxelForge tile post reach soundness failure"));
}
PendingTiles.Empty();
PendingTileCancellation.Empty();
PendingUnload.Empty();