Editor-only, default off (voxel.ResearchRedefinedDensityField). The redefined field is a seeded, periodic cross-corridor pattern per strate plus the authored passages, landings and a shaft tree, with four value-noise detail bands at every near-surface 25 cm sample and sound 8^3 brick proofs. 259^3 ring, six workers: 308 ms median (467 ms without skips) vs 8.9 s for the live field. Detail, boundary-artefact, determinism (1 vs 6 workers, two runs) and bound-audit checks pass. Why it is not a pass: the slices show a mostly-solid field with a few straight corridors, where the owner's world is mostly open space; rooms, the tunnel network, composer recipes and archetypes are gone. Much of the speed comes from 60% of bricks being proven solid in that simpler world. What it does show: detail at full resolution plus brick skipping costs ~80-130 ns/sample; the cost of the live field is how rooms/tunnels/passages are represented, not the detail or the lattice. The two walkability tests were redirected to the research field in the working tree; that change is NOT committed (saved as scratchpad step2d-test-redirect.patch) so they keep testing the live world. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
147 lines
6.4 KiB
C++
147 lines
6.4 KiB
C++
#if WITH_DEV_AUTOMATION_TESTS
|
|
|
|
#include "Misc/AutomationTest.h"
|
|
|
|
#include "VoxelForgeTestFixture.h"
|
|
#include "VoxelRedefinedDensityField.h"
|
|
#include "VoxelStrateMeasure.h"
|
|
|
|
IMPLEMENT_SIMPLE_AUTOMATION_TEST(
|
|
FVoxelForgeRedefinedDensityFieldTraversalSeedsTest,
|
|
"VoxelForge.Research.RedefinedFieldTraversalSeeds",
|
|
EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter)
|
|
|
|
bool FVoxelForgeRedefinedDensityFieldTraversalSeedsTest::RunTest(const FString& Parameters)
|
|
{
|
|
(void)Parameters;
|
|
struct FRestoreResearchField
|
|
{
|
|
bool bWasEnabled = VoxelForgeRedefinedDensityField::IsEnabled();
|
|
float PreviousScale = VoxelForgeRedefinedDensityField::GetDetailScale();
|
|
~FRestoreResearchField()
|
|
{
|
|
VoxelForgeRedefinedDensityField::SetDetailScale(PreviousScale);
|
|
VoxelForgeRedefinedDensityField::SetEnabled(bWasEnabled);
|
|
}
|
|
} Restore;
|
|
VoxelForgeRedefinedDensityField::SetEnabled(true);
|
|
VoxelForgeRedefinedDensityField::SetDetailScale(1.0f);
|
|
|
|
constexpr int32 Seeds[] = {1337, 12345, 20260930};
|
|
int32 CheckedLandings = 0;
|
|
int32 CheckedRoutes = 0;
|
|
int32 RoutesWithResolvedEndpoints = 0;
|
|
for (const int32 Seed : Seeds)
|
|
{
|
|
VoxelForgeTest::FTestWorld World;
|
|
World.Build(Seed, /*InGapChunks=*/2, /*InStrateHeightInChunks=*/4);
|
|
if (!World.IsValid())
|
|
{
|
|
AddError(FString::Printf(
|
|
TEXT("Seed %d: test world did not build: %s"), Seed, *World.WhyInvalid()));
|
|
return false;
|
|
}
|
|
|
|
const TArray<FStrateSlot>& Layout = World.StrateManager->GetLayout();
|
|
const TArray<FVoxelPassage>& Passages = World.StrateManager->GetPassages();
|
|
for (const FVoxelPassage& Passage : Passages)
|
|
{
|
|
if (Passage.UpperStrateIndex == Passage.LowerStrateIndex)
|
|
{
|
|
continue;
|
|
}
|
|
const FVector UpperAir = Passage.UpperLanding.StandingPoint;
|
|
const FVector LowerAir = Passage.LowerLanding.StandingPoint;
|
|
const float UpperDensity = World.Generator->GetDensityAt(
|
|
UpperAir.X, UpperAir.Y, UpperAir.Z);
|
|
const float UpperFooting = World.Generator->GetDensityAt(
|
|
UpperAir.X, UpperAir.Y, Passage.UpperLanding.FloorZ - 0.75f);
|
|
const float LowerDensity = World.Generator->GetDensityAt(
|
|
LowerAir.X, LowerAir.Y, LowerAir.Z);
|
|
const float LowerFooting = World.Generator->GetDensityAt(
|
|
LowerAir.X, LowerAir.Y, Passage.LowerLanding.FloorZ - 0.75f);
|
|
++CheckedLandings;
|
|
if (!FMath::IsFinite(UpperDensity) || !FMath::IsFinite(UpperFooting)
|
|
|| !FMath::IsFinite(LowerDensity) || !FMath::IsFinite(LowerFooting)
|
|
|| UpperDensity <= 0.0f || LowerDensity <= 0.0f
|
|
|| UpperFooting >= 0.0f || LowerFooting >= 0.0f)
|
|
{
|
|
AddError(FString::Printf(
|
|
TEXT("Seed %d: passage %d landing failed the final-field air/floor bracket "
|
|
"(upper %.4f/%.4f, lower %.4f/%.4f)."),
|
|
Seed, CheckedLandings - 1, UpperDensity, UpperFooting,
|
|
LowerDensity, LowerFooting));
|
|
}
|
|
}
|
|
|
|
for (int32 StrateIndex = 0; StrateIndex < Layout.Num(); ++StrateIndex)
|
|
{
|
|
FVector Arrival = FVector::ZeroVector;
|
|
FVector Departure = FVector::ZeroVector;
|
|
bool bHasArrival = false;
|
|
bool bHasDeparture = false;
|
|
for (const FVoxelPassage& Passage : Passages)
|
|
{
|
|
if (Passage.UpperStrateIndex == Passage.LowerStrateIndex)
|
|
{
|
|
continue;
|
|
}
|
|
if (Passage.LowerStrateIndex == StrateIndex && !bHasArrival)
|
|
{
|
|
Arrival = Passage.LowerLanding.StandingPoint;
|
|
bHasArrival = true;
|
|
}
|
|
if (Passage.UpperStrateIndex == StrateIndex && !bHasDeparture)
|
|
{
|
|
Departure = Passage.UpperLanding.StandingPoint;
|
|
bHasDeparture = true;
|
|
}
|
|
}
|
|
if (!bHasArrival || !bHasDeparture)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
FVoxelStrateMeasureSettings Settings;
|
|
Settings.SampleStep = 4;
|
|
Settings.RadiusInVoxels = 192;
|
|
Settings.CenterXY = FVector2D(
|
|
(Arrival.X + Departure.X) * 0.5f,
|
|
(Arrival.Y + Departure.Y) * 0.5f);
|
|
Settings.MaxCells = 4000000;
|
|
Settings.HeadroomCells = 2;
|
|
const FVoxelConnectivityDiagnostics Route = VF_DiagnoseConnectivity(
|
|
*World.Generator, *World.StrateManager, StrateIndex,
|
|
Arrival, Departure, Settings);
|
|
++CheckedRoutes;
|
|
RoutesWithResolvedEndpoints += Route.bStartSnapped || Route.bGoalSnapped;
|
|
if (!Route.bValid || Route.Result != EVoxelConnectivityResult::Connected)
|
|
{
|
|
AddError(FString::Printf(
|
|
TEXT("Seed %d strate %d (%s): arrival-to-exit walking route was %s "
|
|
"(result=%d, valid=%s, start resolved=%s, goal resolved=%s)."),
|
|
Seed, StrateIndex,
|
|
Layout[StrateIndex].Definition
|
|
? *Layout[StrateIndex].Definition->GetName() : TEXT("no definition"),
|
|
Route.Result == EVoxelConnectivityResult::Connected
|
|
? TEXT("connected") : TEXT("not connected"),
|
|
static_cast<int32>(Route.Result),
|
|
Route.bValid ? TEXT("yes") : TEXT("no"),
|
|
Route.bStartSnapped ? TEXT("yes") : TEXT("no"),
|
|
Route.bGoalSnapped ? TEXT("yes") : TEXT("no")));
|
|
}
|
|
}
|
|
}
|
|
|
|
TestTrue(TEXT("Several seeds exercised passage landings"), CheckedLandings >= 6);
|
|
TestTrue(TEXT("Several seeds exercised arrival-to-exit walking"), CheckedRoutes >= 6);
|
|
AddInfo(FString::Printf(
|
|
TEXT("Redefined field functional sweep: %d authored passage landings bracket open air "
|
|
"over %d seeds; %d arrival-to-exit walking routes checked; %d used a resolved "
|
|
"coarse endpoint after the full-density segment check."),
|
|
CheckedLandings, UE_ARRAY_COUNT(Seeds), CheckedRoutes, RoutesWithResolvedEndpoints));
|
|
return CheckedLandings >= 6 && CheckedRoutes >= 6;
|
|
}
|
|
|
|
#endif // WITH_DEV_AUTOMATION_TESTS
|