research(step2e): 8 parameter profiles, worst 570 ms -- speed gate met, look NOT yet accepted
Editor-only, default off. Seeded chamber graph (jittered XY grid, spanning tree, optional loops, tunnels, shafts, pillars, ledges, spires, floating masses, basins), 8 profiles, four detail bands at every surface-affecting 25 cm sample, sound brick proofs. 259^3 ring, six workers, medians of 3: 404-570 ms (worst TerracedBasin 570.0 ms). Detail, seam, bound-audit (0 violations, undersized control caught), determinism (1 vs 6 workers) and TraversalSeeds all pass; live tests untouched. Not accepted yet: the profiles are 81-97% open air. In the slices a "TightNetwork" is a large void with scattered solid blobs (rooms of 0.5-0.76 x pitch overlap and merge), and the finest detail band shows as salt-and-pepper speckle with 22-109 separate 1 m components per ring: fast partly because air bricks skip, and the look needs the owner's judgement. Also missing vs live: maze, flat/plain, crystal-chamber, surface-world and underwater grammars; water geometry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
This commit is contained in:
1 parent
f8a46ecf8d
commit
0a7492ffab
38 files changed
+1761
-186
No files matched your search
@@ -55,21 +55,21 @@ namespace
|
||||
};
|
||||
|
||||
const FParameterProfile GParameterProfiles[] = {
|
||||
{ TEXT("OpenVaults"), { 176.0f, 0.34f, 0.45f, 340.0f, 12.0f, 40.0f, 36.0f,
|
||||
{ TEXT("OpenVaults"), { 176.0f, 0.62f, 0.76f, 340.0f, 12.0f, 40.0f, 36.0f,
|
||||
0.35f, 0.14f, 22.0f, 0.04f, 0.12f, 0.08f, 0.15f, 0.00f, 0.0f, 0.50f } },
|
||||
{ TEXT("TightNetwork"), { 104.0f, 0.28f, 0.42f, 112.0f, 8.0f, 20.0f, 22.0f,
|
||||
{ TEXT("TightNetwork"), { 104.0f, 0.52f, 0.64f, 256.0f, 8.0f, 20.0f, 22.0f,
|
||||
0.12f, 0.03f, 14.0f, 0.06f, 0.08f, 0.02f, 0.12f, 0.00f, 0.0f, 0.50f } },
|
||||
{ TEXT("ChamberHalls"), { 144.0f, 0.38f, 0.45f, 320.0f, 18.0f, 34.0f, 32.0f,
|
||||
{ TEXT("ChamberHalls"), { 144.0f, 0.55f, 0.72f, 320.0f, 18.0f, 34.0f, 32.0f,
|
||||
0.28f, 0.18f, 22.0f, 0.08f, 0.22f, 0.10f, 0.22f, 0.05f, 20.0f, 0.40f } },
|
||||
{ TEXT("ShaftForest"), { 128.0f, 0.32f, 0.43f, 176.0f, 12.0f, 26.0f, 28.0f,
|
||||
0.12f, 0.55f, 20.0f, 0.05f, 0.18f, 0.04f, 0.20f, 0.00f, 0.0f, 0.50f } },
|
||||
{ TEXT("FloatingArchipelago"), { 136.0f, 0.37f, 0.45f, 192.0f, 10.0f, 28.0f, 28.0f,
|
||||
{ TEXT("ShaftForest"), { 128.0f, 0.50f, 0.62f, 272.0f, 12.0f, 26.0f, 28.0f,
|
||||
0.12f, 0.92f, 28.0f, 0.05f, 0.18f, 0.04f, 0.20f, 0.00f, 0.0f, 0.50f } },
|
||||
{ TEXT("FloatingArchipelago"), { 136.0f, 0.55f, 0.68f, 216.0f, 10.0f, 28.0f, 28.0f,
|
||||
0.15f, 0.10f, 16.0f, 0.05f, 0.10f, 0.72f, 0.28f, 0.00f, 0.0f, 0.50f } },
|
||||
{ TEXT("PillaredCathedral"), { 160.0f, 0.38f, 0.45f, 248.0f, 12.0f, 32.0f, 34.0f,
|
||||
{ TEXT("PillaredCathedral"), { 160.0f, 0.55f, 0.72f, 248.0f, 12.0f, 32.0f, 34.0f,
|
||||
0.25f, 0.08f, 18.0f, 0.72f, 0.30f, 0.08f, 0.45f, 0.00f, 0.0f, 0.50f } },
|
||||
{ TEXT("TerracedBasin"), { 136.0f, 0.34f, 0.45f, 216.0f, 14.0f, 28.0f, 30.0f,
|
||||
{ TEXT("TerracedBasin"), { 136.0f, 0.52f, 0.65f, 264.0f, 14.0f, 28.0f, 30.0f,
|
||||
0.20f, 0.10f, 18.0f, 0.10f, 0.84f, 0.05f, 0.25f, 0.85f, 48.0f, 0.30f } },
|
||||
{ TEXT("HyperComplex"), { 96.0f, 0.30f, 0.45f, 192.0f, 20.0f, 30.0f, 28.0f,
|
||||
{ TEXT("HyperComplex"), { 96.0f, 0.60f, 0.74f, 280.0f, 20.0f, 30.0f, 28.0f,
|
||||
0.40f, 0.55f, 20.0f, 0.45f, 0.68f, 0.50f, 0.75f, 0.42f, 28.0f, 0.40f } },
|
||||
};
|
||||
|
||||
@@ -82,6 +82,11 @@ namespace
|
||||
float PadRadius = 0.0f;
|
||||
float BlendRadius = LandingFloorBlendVoxels;
|
||||
FVector ApproachEnd = FVector::ZeroVector;
|
||||
bool bGeneratedAnchorPrepared = false;
|
||||
FVector GeneratedAnchorStart = FVector::ZeroVector;
|
||||
FVector GeneratedAnchorDelta = FVector::ZeroVector;
|
||||
float GeneratedAnchorLengthSquared = 0.0f;
|
||||
float GeneratedAnchorReach = 0.0f;
|
||||
};
|
||||
|
||||
struct FVerticalShaftNode
|
||||
@@ -147,6 +152,8 @@ namespace
|
||||
TArray<FLandingSite> Landings;
|
||||
};
|
||||
|
||||
void PrepareParameterizedAnchors(FStratePlan& Plan);
|
||||
|
||||
struct FThreadPlanCache
|
||||
{
|
||||
const UVoxelStrateManager* Manager = nullptr;
|
||||
@@ -159,6 +166,7 @@ namespace
|
||||
};
|
||||
|
||||
thread_local FThreadPlanCache GPlanCache;
|
||||
thread_local const FStratePlan* GParameterizedRoomCellCachePlan = nullptr;
|
||||
thread_local FThreadShaftEdgeCache GShaftEdgeCache;
|
||||
|
||||
FORCEINLINE uint32 Mix(uint32 Value)
|
||||
@@ -477,6 +485,7 @@ namespace
|
||||
if (Manager == nullptr)
|
||||
{
|
||||
GPlanCache = FThreadPlanCache();
|
||||
GParameterizedRoomCellCachePlan = nullptr;
|
||||
return;
|
||||
}
|
||||
const uint64 Lifetime = Manager->GetCacheLifetimeId();
|
||||
@@ -492,6 +501,7 @@ namespace
|
||||
}
|
||||
|
||||
GPlanCache = FThreadPlanCache();
|
||||
GParameterizedRoomCellCachePlan = nullptr;
|
||||
GPlanCache.Manager = Manager;
|
||||
GPlanCache.ManagerLifetimeId = Lifetime;
|
||||
GPlanCache.LayoutVersion = Version;
|
||||
@@ -566,10 +576,10 @@ namespace
|
||||
Plan.Generation.RoomPitchVoxels = FMath::Max(
|
||||
Plan.Generation.RoomPitchVoxels, 80.0f);
|
||||
Plan.Generation.MinimumRoomRadiusFraction = FMath::Clamp(
|
||||
Plan.Generation.MinimumRoomRadiusFraction, 0.20f, 0.41f);
|
||||
Plan.Generation.MinimumRoomRadiusFraction, 0.20f, 0.72f);
|
||||
Plan.Generation.MaximumRoomRadiusFraction = FMath::Clamp(
|
||||
Plan.Generation.MaximumRoomRadiusFraction,
|
||||
Plan.Generation.MinimumRoomRadiusFraction, 0.45f);
|
||||
Plan.Generation.MinimumRoomRadiusFraction, 0.80f);
|
||||
Plan.Generation.LoopProbability = FMath::Clamp(
|
||||
Plan.Generation.LoopProbability, 0.0f, 0.8f);
|
||||
Plan.Generation.VerticalShaftProbability = FMath::Clamp(
|
||||
@@ -718,7 +728,8 @@ namespace
|
||||
Plan.FloorZ = FMath::Clamp(
|
||||
static_cast<float>(FloorSum / FloorCount), Bottom + 16.0f, Top - 72.0f);
|
||||
Plan.CeilingZ = Plan.FloorZ + MinimumCaveHeight;
|
||||
Plan.GenerationFloorZ = Plan.FloorZ;
|
||||
// Parameterized chambers keep their profile-defined vertical span. The
|
||||
// passage landing is connected into that graph by its generated anchor.
|
||||
}
|
||||
}
|
||||
for (FLandingSite& Site : Plan.Landings)
|
||||
@@ -765,6 +776,10 @@ namespace
|
||||
}
|
||||
}
|
||||
}
|
||||
for (FStratePlan& Plan : GPlanCache.Strates)
|
||||
{
|
||||
PrepareParameterizedAnchors(Plan);
|
||||
}
|
||||
}
|
||||
|
||||
struct FGeneratedCaveCell
|
||||
@@ -788,6 +803,30 @@ namespace
|
||||
float SpireLength = 0.0f;
|
||||
float SpireRadius = 0.0f;
|
||||
uint8 FeatureFlags = 0;
|
||||
uint8 OpenTunnelEdges = 0;
|
||||
};
|
||||
|
||||
struct FParameterizedColumnContext
|
||||
{
|
||||
FGeneratedCaveCell GeneratedCells[9];
|
||||
const FGeneratedCaveCell* Cells[9] = {};
|
||||
float RoomDistanceSquared[9] = {};
|
||||
float RoomRadii[9] = {};
|
||||
float RoomHorizontals[9] = {};
|
||||
float RoomFloors[9] = {};
|
||||
float PillarHorizontals[9] = {};
|
||||
float FloatingXYDistanceSquared[9][2] = {};
|
||||
float SpireBaseZ[9] = {};
|
||||
float SpireTipZ[9] = {};
|
||||
float SpireBaseTopZ[9] = {};
|
||||
float SpireTipBottomZ[9] = {};
|
||||
float TunnelT[4] = {};
|
||||
float TunnelHorizontal[4] = {};
|
||||
float LandingDistanceSquared[8] = {};
|
||||
float LandingDistance[8] = {};
|
||||
float LandingBridgeT[8] = {};
|
||||
float LandingBridgeHorizontal[8] = {};
|
||||
bool bHasLandingXYCache = false;
|
||||
};
|
||||
|
||||
constexpr uint8 HasPillarFlag = 1u << 0;
|
||||
@@ -795,6 +834,20 @@ namespace
|
||||
constexpr uint8 HasFloatingFlag = 1u << 2;
|
||||
constexpr uint8 HasSpireFlag = 1u << 3;
|
||||
constexpr uint8 HasBasinFlag = 1u << 4;
|
||||
constexpr uint8 HasVerticalShaftFlag = 1u << 5;
|
||||
constexpr uint8 TunnelToNegativeY = 1u << 0;
|
||||
constexpr uint8 TunnelToPositiveY = 1u << 1;
|
||||
constexpr uint8 TunnelToNegativeX = 1u << 2;
|
||||
constexpr uint8 TunnelToPositiveX = 1u << 3;
|
||||
|
||||
thread_local TArray<FGeneratedCaveCell> GParameterizedRoomCellCache;
|
||||
thread_local FIntPoint GParameterizedRoomCellCacheMin = FIntPoint::ZeroValue;
|
||||
thread_local FIntPoint GParameterizedRoomCellCacheSize = FIntPoint::ZeroValue;
|
||||
|
||||
FIntPoint GeneratedParent(const FStratePlan& Plan, int32 CellX, int32 CellY);
|
||||
bool IsGeneratedEdgeOpen(
|
||||
const FStratePlan& Plan, int32 AX, int32 AY, int32 BX, int32 BY);
|
||||
FORCEINLINE FIntPoint GenerationCellAt(const FStratePlan& Plan, float X, float Y);
|
||||
|
||||
FORCEINLINE float ParameterRoll(uint32 Hash, uint32 Salt)
|
||||
{
|
||||
@@ -829,6 +882,27 @@ namespace
|
||||
Cell.RadiusX = Pitch * RadiusFraction;
|
||||
Cell.RadiusY = Cell.RadiusX * FMath::Lerp(
|
||||
0.82f, 0.98f, ParameterRoll(Hash, 0x27C5u));
|
||||
if (VoxelHash::ToFloat01(Hash3(CellX, CellY, 0x53, Plan.GenerationSeed))
|
||||
< P.VerticalShaftProbability)
|
||||
{
|
||||
Cell.FeatureFlags |= HasVerticalShaftFlag;
|
||||
}
|
||||
if (IsGeneratedEdgeOpen(Plan, CellX, CellY, CellX, CellY - 1))
|
||||
{
|
||||
Cell.OpenTunnelEdges |= TunnelToNegativeY;
|
||||
}
|
||||
if (IsGeneratedEdgeOpen(Plan, CellX, CellY, CellX, CellY + 1))
|
||||
{
|
||||
Cell.OpenTunnelEdges |= TunnelToPositiveY;
|
||||
}
|
||||
if (IsGeneratedEdgeOpen(Plan, CellX, CellY, CellX - 1, CellY))
|
||||
{
|
||||
Cell.OpenTunnelEdges |= TunnelToNegativeX;
|
||||
}
|
||||
if (IsGeneratedEdgeOpen(Plan, CellX, CellY, CellX + 1, CellY))
|
||||
{
|
||||
Cell.OpenTunnelEdges |= TunnelToPositiveX;
|
||||
}
|
||||
Cell.FloorZ = Plan.GenerationFloorZ
|
||||
+ (ParameterRoll(Hash, 0xF103u) * 2.0f - 1.0f) * P.FloorReliefVoxels;
|
||||
Cell.CeilingZ = Cell.FloorZ + P.RoomHeightVoxels;
|
||||
@@ -880,6 +954,42 @@ namespace
|
||||
return Cell;
|
||||
}
|
||||
|
||||
void PrepareParameterizedAnchors(FStratePlan& Plan)
|
||||
{
|
||||
const float AnchorReach = Plan.Generation.RoomPitchVoxels * 1.25f
|
||||
+ FMath::Max(32.0f, Plan.Generation.TunnelRadiusVoxels);
|
||||
for (FLandingSite& Site : Plan.Landings)
|
||||
{
|
||||
const FIntPoint LandingCell = GenerationCellAt(
|
||||
Plan, Site.Position.X, Site.Position.Y);
|
||||
FGeneratedCaveCell NearestCell;
|
||||
float BestDistanceSquared = FLT_MAX;
|
||||
for (int32 CellY = -1; CellY <= 1; ++CellY)
|
||||
for (int32 CellX = -1; CellX <= 1; ++CellX)
|
||||
{
|
||||
const FGeneratedCaveCell Candidate = BuildGeneratedCell(
|
||||
Plan, LandingCell.X + CellX, LandingCell.Y + CellY);
|
||||
const float DX = Candidate.CenterX - Site.Position.X;
|
||||
const float DY = Candidate.CenterY - Site.Position.Y;
|
||||
const float DistanceSquared = DX * DX + DY * DY;
|
||||
if (DistanceSquared < BestDistanceSquared)
|
||||
{
|
||||
BestDistanceSquared = DistanceSquared;
|
||||
NearestCell = Candidate;
|
||||
}
|
||||
}
|
||||
Site.GeneratedAnchorStart = FVector(
|
||||
Site.Position.X, Site.Position.Y, Site.FloorZ + 24.0f);
|
||||
const FVector AnchorEnd(
|
||||
NearestCell.CenterX, NearestCell.CenterY,
|
||||
NearestCell.FloorZ + Plan.Generation.TunnelHalfHeightVoxels);
|
||||
Site.GeneratedAnchorDelta = AnchorEnd - Site.GeneratedAnchorStart;
|
||||
Site.GeneratedAnchorLengthSquared = Site.GeneratedAnchorDelta.SizeSquared();
|
||||
Site.GeneratedAnchorReach = AnchorReach;
|
||||
Site.bGeneratedAnchorPrepared = true;
|
||||
}
|
||||
}
|
||||
|
||||
FORCEINLINE float SmoothMinimum(float A, float B, float K)
|
||||
{
|
||||
const float H = FMath::Max(K - FMath::Abs(A - B), 0.0f) / K;
|
||||
@@ -903,72 +1013,81 @@ namespace
|
||||
}
|
||||
|
||||
FORCEINLINE float GeneratedRoomCell(
|
||||
const FStratePlan& Plan, const FGeneratedCaveCell& Cell,
|
||||
float X, float Y, float Z)
|
||||
const FGeneratedCaveCell& Cell,
|
||||
float Z, float Radius, float Horizontal,
|
||||
const FParameterizedColumnContext& Column, int32 CellIndex)
|
||||
{
|
||||
const float DX = X - Cell.CenterX;
|
||||
const float DY = Y - Cell.CenterY;
|
||||
const float Radius = FMath::Sqrt(DX * DX + DY * DY);
|
||||
const float Horizontal = Cell.RadiusX - Radius;
|
||||
float FloorZ = Cell.FloorZ;
|
||||
if ((Cell.FeatureFlags & HasBasinFlag) != 0)
|
||||
{
|
||||
FloorZ += Plan.Generation.BasinDepthVoxels
|
||||
* FMath::Clamp(Radius / FMath::Max(Cell.RadiusX, 1.0f), 0.0f, 1.0f);
|
||||
}
|
||||
const float FloorZ = Column.RoomFloors[CellIndex];
|
||||
const float Vertical = FMath::Min(Z - FloorZ, Cell.CeilingZ - Z);
|
||||
float Room = SmoothMinimum(Horizontal, Vertical, 8.0f);
|
||||
if (Room > 0.0f && (Cell.FeatureFlags & HasPillarFlag) != 0)
|
||||
if ((Cell.FeatureFlags & HasPillarFlag) != 0 && Room > -14.0f)
|
||||
{
|
||||
const float PX = X - Cell.PillarX;
|
||||
const float PY = Y - Cell.PillarY;
|
||||
const float Pillar = FMath::Max3(
|
||||
FMath::Sqrt(PX * PX + PY * PY) - Cell.PillarRadius,
|
||||
Column.PillarHorizontals[CellIndex],
|
||||
Cell.FloorZ - Z, Z - Cell.CeilingZ);
|
||||
Room = FMath::Min(Room, Pillar);
|
||||
if (Pillar < Room)
|
||||
{
|
||||
Room = Pillar;
|
||||
}
|
||||
}
|
||||
if ((Cell.FeatureFlags & HasLedgeFlag) != 0
|
||||
&& Horizontal >= -2.0f && FMath::Abs(Z - Cell.LedgeZ) <= 3.0f)
|
||||
if ((Cell.FeatureFlags & HasLedgeFlag) != 0)
|
||||
{
|
||||
const float Inner = Cell.RadiusX * 0.58f;
|
||||
const float Outer = Cell.RadiusX + 1.0f;
|
||||
const float Ledge = FMath::Max3(
|
||||
Inner - Radius, Radius - Outer, FMath::Abs(Z - Cell.LedgeZ) - 2.5f);
|
||||
Room = FMath::Min(Room, Ledge);
|
||||
if (Ledge < Room)
|
||||
{
|
||||
Room = Ledge;
|
||||
}
|
||||
}
|
||||
if (Room > 0.0f && (Cell.FeatureFlags & HasFloatingFlag) != 0)
|
||||
if ((Cell.FeatureFlags & HasFloatingFlag) != 0)
|
||||
{
|
||||
for (int32 Blob = 0; Blob < 2; ++Blob)
|
||||
{
|
||||
const float BX = X - Cell.FloatingX[Blob];
|
||||
const float BY = Y - Cell.FloatingY[Blob];
|
||||
if (Room <= -Cell.FloatingRadius[Blob])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const float BZ = Z - Cell.FloatingZ[Blob];
|
||||
const float BlobSolid = FMath::Sqrt(BX * BX + BY * BY + BZ * BZ)
|
||||
const float BlobSolid = FMath::Sqrt(
|
||||
Column.FloatingXYDistanceSquared[CellIndex][Blob] + BZ * BZ)
|
||||
- Cell.FloatingRadius[Blob];
|
||||
Room = FMath::Min(Room, BlobSolid);
|
||||
if (BlobSolid < Room)
|
||||
{
|
||||
Room = BlobSolid;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Room > 0.0f && (Cell.FeatureFlags & HasSpireFlag) != 0)
|
||||
if ((Cell.FeatureFlags & HasSpireFlag) != 0 && Room > -14.0f)
|
||||
{
|
||||
const float BaseZ = Cell.FloorZ + 2.0f;
|
||||
const float TipZ = FMath::Min(Cell.CeilingZ - 2.0f, BaseZ + Cell.SpireLength);
|
||||
if (Z >= BaseZ && Z <= TipZ)
|
||||
const float BaseZ = Column.SpireBaseZ[CellIndex];
|
||||
const float TipZ = Column.SpireTipZ[CellIndex];
|
||||
if (Z >= BaseZ || BaseZ - Z < Room)
|
||||
{
|
||||
const float T = (Z - BaseZ) / FMath::Max(TipZ - BaseZ, 1.0f);
|
||||
const float T = FMath::Clamp(
|
||||
(Z - BaseZ) / FMath::Max(TipZ - BaseZ, 1.0f), 0.0f, 1.0f);
|
||||
const float RadiusAtZ = FMath::Lerp(Cell.SpireRadius, 1.25f, T);
|
||||
const float Spire = FMath::Max3(
|
||||
Radius - RadiusAtZ, BaseZ - Z, Z - TipZ);
|
||||
Room = FMath::Min(Room, Spire);
|
||||
if (Spire < Room)
|
||||
{
|
||||
Room = Spire;
|
||||
}
|
||||
}
|
||||
const float BaseTop = Cell.CeilingZ - 2.0f;
|
||||
const float TipBottom = FMath::Max(Cell.FloorZ + 2.0f, BaseTop - Cell.SpireLength);
|
||||
if (Z >= TipBottom && Z <= BaseTop)
|
||||
const float BaseTop = Column.SpireBaseTopZ[CellIndex];
|
||||
const float TipBottom = Column.SpireTipBottomZ[CellIndex];
|
||||
if (Z <= BaseTop || Z - BaseTop < Room)
|
||||
{
|
||||
const float T = (BaseTop - Z) / FMath::Max(BaseTop - TipBottom, 1.0f);
|
||||
const float T = FMath::Clamp(
|
||||
(BaseTop - Z) / FMath::Max(BaseTop - TipBottom, 1.0f), 0.0f, 1.0f);
|
||||
const float RadiusAtZ = FMath::Lerp(Cell.SpireRadius, 1.25f, T);
|
||||
const float Stalactite = FMath::Max3(
|
||||
Radius - RadiusAtZ, Z - BaseTop, TipBottom - Z);
|
||||
Room = FMath::Min(Room, Stalactite);
|
||||
if (Stalactite < Room)
|
||||
{
|
||||
Room = Stalactite;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Room;
|
||||
@@ -1018,18 +1137,8 @@ namespace
|
||||
FORCEINLINE float GeneratedTunnelEdge(
|
||||
const FStratePlan& Plan,
|
||||
const FGeneratedCaveCell& A, const FGeneratedCaveCell& B,
|
||||
float X, float Y, float Z)
|
||||
float Z, float T, float Horizontal)
|
||||
{
|
||||
if (!IsGeneratedEdgeOpen(Plan, A.CellX, A.CellY, B.CellX, B.CellY))
|
||||
{
|
||||
return -FLT_MAX;
|
||||
}
|
||||
const float T = SegmentParameterXY(X, Y,
|
||||
FVector(A.CenterX, A.CenterY, 0.0f), FVector(B.CenterX, B.CenterY, 0.0f));
|
||||
const float Horizontal = Plan.Generation.TunnelRadiusVoxels
|
||||
- FMath::Sqrt(DistanceSquaredToSegmentXY(
|
||||
X, Y, FVector(A.CenterX, A.CenterY, 0.0f),
|
||||
FVector(B.CenterX, B.CenterY, 0.0f)));
|
||||
const float FloorZ = FMath::Lerp(A.FloorZ, B.FloorZ, T);
|
||||
const float Vertical = FMath::Min(
|
||||
Z - FloorZ,
|
||||
@@ -1037,66 +1146,267 @@ namespace
|
||||
return SmoothMinimum(Horizontal, Vertical, 5.0f);
|
||||
}
|
||||
|
||||
float EvaluateParameterizedMacro(
|
||||
const FStratePlan& Plan, float X, float Y, float Z, float* OutDetailScale)
|
||||
const FGeneratedCaveCell* FindParameterizedBrickRoomCell(
|
||||
const FStratePlan& Plan, const FParameterizedBrickContext* Context,
|
||||
int32 CellX, int32 CellY)
|
||||
{
|
||||
if (Context == nullptr || Context->PlanToken != &Plan
|
||||
|| Context->RoomCellCacheToken != GParameterizedRoomCellCache.GetData()
|
||||
|| GParameterizedRoomCellCachePlan != &Plan
|
||||
|| CellX < Context->RoomCellCacheMin.X
|
||||
|| CellY < Context->RoomCellCacheMin.Y
|
||||
|| CellX >= Context->RoomCellCacheMin.X + Context->RoomCellCacheSize.X
|
||||
|| CellY >= Context->RoomCellCacheMin.Y + Context->RoomCellCacheSize.Y)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
const int32 Index = (CellY - Context->RoomCellCacheMin.Y)
|
||||
* Context->RoomCellCacheSize.X + CellX - Context->RoomCellCacheMin.X;
|
||||
return GParameterizedRoomCellCache.IsValidIndex(Index)
|
||||
? &GParameterizedRoomCellCache[Index] : nullptr;
|
||||
}
|
||||
|
||||
void BuildParameterizedColumnContext(
|
||||
const FStratePlan& Plan, float X, float Y,
|
||||
const FParameterizedBrickContext* Context,
|
||||
FParameterizedColumnContext& OutColumn)
|
||||
{
|
||||
const FIntPoint BaseCell = GenerationCellAt(Plan, X, Y);
|
||||
FGeneratedCaveCell Cells[9];
|
||||
const bool bHasRoomCellCache = Context != nullptr
|
||||
&& Context->PlanToken == &Plan
|
||||
&& Context->RoomCellCacheToken == GParameterizedRoomCellCache.GetData()
|
||||
&& GParameterizedRoomCellCachePlan == &Plan;
|
||||
for (int32 CellY = -1; CellY <= 1; ++CellY)
|
||||
for (int32 CellX = -1; CellX <= 1; ++CellX)
|
||||
{
|
||||
const int32 Index = (CellY + 1) * 3 + CellX + 1;
|
||||
Cells[Index] = BuildGeneratedCell(
|
||||
Plan, BaseCell.X + CellX, BaseCell.Y + CellY);
|
||||
const int32 GeneratedX = BaseCell.X + CellX;
|
||||
const int32 GeneratedY = BaseCell.Y + CellY;
|
||||
if (bHasRoomCellCache)
|
||||
{
|
||||
const int32 CacheX = GeneratedX - Context->RoomCellCacheMin.X;
|
||||
const int32 CacheY = GeneratedY - Context->RoomCellCacheMin.Y;
|
||||
if (CacheX >= 0 && CacheY >= 0
|
||||
&& CacheX < Context->RoomCellCacheSize.X
|
||||
&& CacheY < Context->RoomCellCacheSize.Y)
|
||||
{
|
||||
const int32 CacheIndex = CacheY * Context->RoomCellCacheSize.X + CacheX;
|
||||
if (GParameterizedRoomCellCache.IsValidIndex(CacheIndex))
|
||||
{
|
||||
OutColumn.Cells[Index] = &GParameterizedRoomCellCache[CacheIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OutColumn.Cells[Index] = FindParameterizedBrickRoomCell(
|
||||
Plan, Context, GeneratedX, GeneratedY);
|
||||
}
|
||||
if (OutColumn.Cells[Index] == nullptr)
|
||||
{
|
||||
OutColumn.GeneratedCells[Index] = BuildGeneratedCell(
|
||||
Plan, GeneratedX, GeneratedY);
|
||||
OutColumn.Cells[Index] = &OutColumn.GeneratedCells[Index];
|
||||
}
|
||||
const float DX = X - OutColumn.Cells[Index]->CenterX;
|
||||
const float DY = Y - OutColumn.Cells[Index]->CenterY;
|
||||
const float DistanceSquared = DX * DX + DY * DY;
|
||||
OutColumn.RoomDistanceSquared[Index] = DistanceSquared;
|
||||
OutColumn.RoomRadii[Index] = FMath::Sqrt(DistanceSquared);
|
||||
OutColumn.RoomHorizontals[Index] = OutColumn.Cells[Index]->RadiusX
|
||||
- OutColumn.RoomRadii[Index];
|
||||
|
||||
const FGeneratedCaveCell& Cell = *OutColumn.Cells[Index];
|
||||
OutColumn.RoomFloors[Index] = Cell.FloorZ;
|
||||
if ((Cell.FeatureFlags & HasBasinFlag) != 0)
|
||||
{
|
||||
OutColumn.RoomFloors[Index] += Plan.Generation.BasinDepthVoxels
|
||||
* FMath::Clamp(OutColumn.RoomRadii[Index]
|
||||
/ FMath::Max(Cell.RadiusX, 1.0f), 0.0f, 1.0f);
|
||||
}
|
||||
if ((Cell.FeatureFlags & HasPillarFlag) != 0)
|
||||
{
|
||||
const float PX = X - Cell.PillarX;
|
||||
const float PY = Y - Cell.PillarY;
|
||||
OutColumn.PillarHorizontals[Index] = FMath::Sqrt(PX * PX + PY * PY)
|
||||
- Cell.PillarRadius;
|
||||
}
|
||||
if ((Cell.FeatureFlags & HasFloatingFlag) != 0)
|
||||
{
|
||||
for (int32 Blob = 0; Blob < 2; ++Blob)
|
||||
{
|
||||
const float BX = X - Cell.FloatingX[Blob];
|
||||
const float BY = Y - Cell.FloatingY[Blob];
|
||||
OutColumn.FloatingXYDistanceSquared[Index][Blob] = BX * BX + BY * BY;
|
||||
}
|
||||
}
|
||||
if ((Cell.FeatureFlags & HasSpireFlag) != 0)
|
||||
{
|
||||
OutColumn.SpireBaseZ[Index] = Cell.FloorZ + 2.0f;
|
||||
OutColumn.SpireTipZ[Index] = FMath::Min(
|
||||
Cell.CeilingZ - 2.0f,
|
||||
OutColumn.SpireBaseZ[Index] + Cell.SpireLength);
|
||||
OutColumn.SpireBaseTopZ[Index] = Cell.CeilingZ - 2.0f;
|
||||
OutColumn.SpireTipBottomZ[Index] = FMath::Max(
|
||||
Cell.FloorZ + 2.0f,
|
||||
OutColumn.SpireBaseTopZ[Index] - Cell.SpireLength);
|
||||
}
|
||||
}
|
||||
|
||||
const FGeneratedCaveCell& Centre = *OutColumn.Cells[4];
|
||||
const int32 EdgeIndices[] = {1, 7, 3, 5};
|
||||
const uint8 EdgeFlags[] = {
|
||||
TunnelToNegativeY, TunnelToPositiveY,
|
||||
TunnelToNegativeX, TunnelToPositiveX};
|
||||
for (int32 EdgeIndex = 0; EdgeIndex < UE_ARRAY_COUNT(EdgeIndices); ++EdgeIndex)
|
||||
{
|
||||
OutColumn.TunnelHorizontal[EdgeIndex] = -FLT_MAX;
|
||||
if ((Centre.OpenTunnelEdges & EdgeFlags[EdgeIndex]) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const FGeneratedCaveCell& Next = *OutColumn.Cells[EdgeIndices[EdgeIndex]];
|
||||
const float ABX = Next.CenterX - Centre.CenterX;
|
||||
const float ABY = Next.CenterY - Centre.CenterY;
|
||||
const float LengthSquared = ABX * ABX + ABY * ABY;
|
||||
const float T = LengthSquared > 1.0e-8f
|
||||
? FMath::Clamp(((X - Centre.CenterX) * ABX
|
||||
+ (Y - Centre.CenterY) * ABY) / LengthSquared, 0.0f, 1.0f)
|
||||
: 0.0f;
|
||||
const float DX = X - (Centre.CenterX + T * ABX);
|
||||
const float DY = Y - (Centre.CenterY + T * ABY);
|
||||
OutColumn.TunnelT[EdgeIndex] = T;
|
||||
OutColumn.TunnelHorizontal[EdgeIndex] = Plan.Generation.TunnelRadiusVoxels
|
||||
- FMath::Sqrt(DX * DX + DY * DY);
|
||||
}
|
||||
|
||||
OutColumn.bHasLandingXYCache = Plan.Landings.Num() <= UE_ARRAY_COUNT(
|
||||
OutColumn.LandingDistanceSquared);
|
||||
if (OutColumn.bHasLandingXYCache)
|
||||
{
|
||||
const FLandingSite* Hub = Plan.LandingHubIndex != INDEX_NONE
|
||||
? &Plan.Landings[Plan.LandingHubIndex] : nullptr;
|
||||
for (int32 SiteIndex = 0; SiteIndex < Plan.Landings.Num(); ++SiteIndex)
|
||||
{
|
||||
const FLandingSite& Site = Plan.Landings[SiteIndex];
|
||||
const float DX = X - Site.Position.X;
|
||||
const float DY = Y - Site.Position.Y;
|
||||
const float DistanceSquared = DX * DX + DY * DY;
|
||||
OutColumn.LandingDistanceSquared[SiteIndex] = DistanceSquared;
|
||||
OutColumn.LandingDistance[SiteIndex] = FMath::Sqrt(DistanceSquared);
|
||||
OutColumn.LandingBridgeT[SiteIndex] = 0.0f;
|
||||
OutColumn.LandingBridgeHorizontal[SiteIndex] = -FLT_MAX;
|
||||
if (Hub != nullptr && Plan.Landings.Num() > 1
|
||||
&& SiteIndex != Plan.LandingHubIndex)
|
||||
{
|
||||
OutColumn.LandingBridgeT[SiteIndex] = SegmentParameterXY(
|
||||
X, Y, Site.Position, Hub->Position);
|
||||
OutColumn.LandingBridgeHorizontal[SiteIndex] = LandingBridgeRadius
|
||||
- FMath::Sqrt(DistanceSquaredToSegmentXY(
|
||||
X, Y, Site.Position, Hub->Position));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float EvaluateParameterizedMacro(
|
||||
const FStratePlan& Plan, float X, float Y, float Z, float* OutDetailScale,
|
||||
const FParameterizedBrickContext* Context = nullptr,
|
||||
const FParameterizedColumnContext* ColumnContext = nullptr)
|
||||
{
|
||||
FParameterizedColumnContext LocalColumn;
|
||||
if (ColumnContext == nullptr)
|
||||
{
|
||||
BuildParameterizedColumnContext(Plan, X, Y, Context, LocalColumn);
|
||||
ColumnContext = &LocalColumn;
|
||||
}
|
||||
|
||||
float Macro = -FLT_MAX;
|
||||
for (const FGeneratedCaveCell& Cell : Cells)
|
||||
{
|
||||
const float DX = X - Cell.CenterX;
|
||||
const float DY = Y - Cell.CenterY;
|
||||
const float Horizontal = Cell.RadiusX - FMath::Sqrt(DX * DX + DY * DY);
|
||||
if (Macro > -FLT_MAX * 0.5f && Horizontal < Macro - 6.0f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Macro = SmoothMaximum(Macro,
|
||||
GeneratedRoomCell(Plan, Cell, X, Y, Z), 6.0f);
|
||||
}
|
||||
const FGeneratedCaveCell& Centre = Cells[4];
|
||||
const int32 EdgeIndices[] = {1, 7, 3, 5};
|
||||
for (const int32 EdgeIndex : EdgeIndices)
|
||||
{
|
||||
Macro = SmoothMaximum(Macro,
|
||||
GeneratedTunnelEdge(Plan, Centre, Cells[EdgeIndex], X, Y, Z), 5.0f);
|
||||
}
|
||||
|
||||
const float Bottom = static_cast<float>(Plan.MinChunkZ * CHUNK_SIZE) + 8.0f;
|
||||
const float Top = static_cast<float>(Plan.MaxChunkZExclusive * CHUNK_SIZE) - 8.0f;
|
||||
for (const FGeneratedCaveCell& Cell : Cells)
|
||||
static constexpr int32 CellEvaluationOrder[] = {4, 1, 3, 5, 7, 0, 2, 6, 8};
|
||||
for (int32 OrderIndex = 0;
|
||||
OrderIndex < UE_ARRAY_COUNT(CellEvaluationOrder); ++OrderIndex)
|
||||
{
|
||||
const uint32 ShaftHash = Hash3(
|
||||
Cell.CellX, Cell.CellY, 0x53, Plan.GenerationSeed);
|
||||
if (VoxelHash::ToFloat01(ShaftHash) >= Plan.Generation.VerticalShaftProbability)
|
||||
const int32 Index = CellEvaluationOrder[OrderIndex];
|
||||
const FGeneratedCaveCell& Cell = *ColumnContext->Cells[Index];
|
||||
const float DistanceSquared = ColumnContext->RoomDistanceSquared[Index];
|
||||
if (Macro > -FLT_MAX * 0.5f)
|
||||
{
|
||||
const float MaximumDistance = Cell.RadiusX - Macro + 6.0f;
|
||||
if (MaximumDistance < 0.0f
|
||||
|| DistanceSquared > FMath::Square(MaximumDistance + 1.0e-3f))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const float VerticalUpperBound = FMath::Min(
|
||||
Z - ColumnContext->RoomFloors[Index], Cell.CeilingZ - Z);
|
||||
if (VerticalUpperBound <= Macro - 6.0f)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Macro = SmoothMaximum(Macro,
|
||||
GeneratedRoomCell(Cell, Z,
|
||||
ColumnContext->RoomRadii[Index],
|
||||
ColumnContext->RoomHorizontals[Index],
|
||||
*ColumnContext, Index), 6.0f);
|
||||
}
|
||||
const FGeneratedCaveCell& Centre = *ColumnContext->Cells[4];
|
||||
const int32 EdgeIndices[] = {1, 7, 3, 5};
|
||||
const uint8 EdgeFlags[] = {
|
||||
TunnelToNegativeY, TunnelToPositiveY,
|
||||
TunnelToNegativeX, TunnelToPositiveX};
|
||||
for (int32 EdgeIndex = 0; EdgeIndex < UE_ARRAY_COUNT(EdgeIndices); ++EdgeIndex)
|
||||
{
|
||||
if ((Centre.OpenTunnelEdges & EdgeFlags[EdgeIndex]) != 0)
|
||||
{
|
||||
Macro = SmoothMaximum(Macro, GeneratedTunnelEdge(
|
||||
Plan, Centre, *ColumnContext->Cells[EdgeIndices[EdgeIndex]], Z,
|
||||
ColumnContext->TunnelT[EdgeIndex],
|
||||
ColumnContext->TunnelHorizontal[EdgeIndex]), 5.0f);
|
||||
}
|
||||
}
|
||||
|
||||
for (int32 Index = 0; Index < UE_ARRAY_COUNT(ColumnContext->Cells); ++Index)
|
||||
{
|
||||
const FGeneratedCaveCell& Cell = *ColumnContext->Cells[Index];
|
||||
if ((Cell.FeatureFlags & HasVerticalShaftFlag) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const float DistanceSquared = ColumnContext->RoomDistanceSquared[Index];
|
||||
const float MaximumDistance = Plan.Generation.ShaftRadiusVoxels - Macro + 5.0f;
|
||||
if (MaximumDistance < 0.0f
|
||||
|| DistanceSquared > FMath::Square(MaximumDistance + 1.0e-3f))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const float DX = X - Cell.CenterX;
|
||||
const float DY = Y - Cell.CenterY;
|
||||
const float Horizontal = Plan.Generation.ShaftRadiusVoxels
|
||||
- FMath::Sqrt(DX * DX + DY * DY);
|
||||
- ColumnContext->RoomRadii[Index];
|
||||
const float Vertical = FMath::Min(Z - Bottom, Top - Z);
|
||||
Macro = SmoothMaximum(Macro,
|
||||
SmoothMinimum(Horizontal, Vertical, 5.0f), 5.0f);
|
||||
}
|
||||
|
||||
float DetailFade = 1.0f;
|
||||
for (const FLandingSite& Site : Plan.Landings)
|
||||
for (int32 SiteIndex = 0; SiteIndex < Plan.Landings.Num(); ++SiteIndex)
|
||||
{
|
||||
const float DX = X - Site.Position.X;
|
||||
const float DY = Y - Site.Position.Y;
|
||||
const float DistanceSquared = DX * DX + DY * DY;
|
||||
const float Distance = FMath::Sqrt(DistanceSquared);
|
||||
const FLandingSite& Site = Plan.Landings[SiteIndex];
|
||||
float DistanceSquared = 0.0f;
|
||||
float Distance = 0.0f;
|
||||
if (ColumnContext->bHasLandingXYCache)
|
||||
{
|
||||
DistanceSquared = ColumnContext->LandingDistanceSquared[SiteIndex];
|
||||
Distance = ColumnContext->LandingDistance[SiteIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
const float DX = X - Site.Position.X;
|
||||
const float DY = Y - Site.Position.Y;
|
||||
DistanceSquared = DX * DX + DY * DY;
|
||||
Distance = FMath::Sqrt(DistanceSquared);
|
||||
}
|
||||
const float RoomAir = FMath::Min(
|
||||
Site.PadRadius - Distance,
|
||||
FMath::Min(Z - Site.FloorZ, Site.FloorZ + MinimumCaveHeight - Z));
|
||||
@@ -1106,39 +1416,20 @@ namespace
|
||||
DetailFade = 0.0f;
|
||||
}
|
||||
|
||||
const float AnchorReach = Plan.Generation.RoomPitchVoxels * 1.25f
|
||||
+ FMath::Max(32.0f, Plan.Generation.TunnelRadiusVoxels);
|
||||
if (DistanceSquared > FMath::Square(AnchorReach))
|
||||
if (!Site.bGeneratedAnchorPrepared
|
||||
|| DistanceSquared > FMath::Square(Site.GeneratedAnchorReach))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const FIntPoint LandingCell = GenerationCellAt(Plan, Site.Position.X, Site.Position.Y);
|
||||
FGeneratedCaveCell NearestCell;
|
||||
float BestDistanceSq = FLT_MAX;
|
||||
for (int32 CellY = -1; CellY <= 1; ++CellY)
|
||||
for (int32 CellX = -1; CellX <= 1; ++CellX)
|
||||
{
|
||||
const FGeneratedCaveCell Candidate = BuildGeneratedCell(
|
||||
Plan, LandingCell.X + CellX, LandingCell.Y + CellY);
|
||||
const float CandidateDistanceSq = FMath::Square(Candidate.CenterX - Site.Position.X)
|
||||
+ FMath::Square(Candidate.CenterY - Site.Position.Y);
|
||||
if (CandidateDistanceSq < BestDistanceSq)
|
||||
{
|
||||
BestDistanceSq = CandidateDistanceSq;
|
||||
NearestCell = Candidate;
|
||||
}
|
||||
}
|
||||
const FVector AnchorA(Site.Position.X, Site.Position.Y, Site.FloorZ + 24.0f);
|
||||
const FVector AnchorB(NearestCell.CenterX, NearestCell.CenterY,
|
||||
NearestCell.FloorZ + Plan.Generation.TunnelHalfHeightVoxels);
|
||||
const FVector Segment = AnchorB - AnchorA;
|
||||
const float SegmentLengthSq = Segment.SizeSquared();
|
||||
const FVector Point(X, Y, Z);
|
||||
const float T = SegmentLengthSq > 1.0e-8f
|
||||
? FMath::Clamp(FVector::DotProduct(Point - AnchorA, Segment) / SegmentLengthSq,
|
||||
0.0f, 1.0f) : 0.0f;
|
||||
const float T = Site.GeneratedAnchorLengthSquared > 1.0e-8f
|
||||
? FMath::Clamp(FVector::DotProduct(
|
||||
Point - Site.GeneratedAnchorStart, Site.GeneratedAnchorDelta)
|
||||
/ Site.GeneratedAnchorLengthSquared, 0.0f, 1.0f) : 0.0f;
|
||||
const FVector AnchorDelta = Point
|
||||
- (Site.GeneratedAnchorStart + Site.GeneratedAnchorDelta * T);
|
||||
const float Anchor = FMath::Max(32.0f, Plan.Generation.TunnelRadiusVoxels)
|
||||
- (Point - (AnchorA + Segment * T)).Size();
|
||||
- AnchorDelta.Size();
|
||||
Macro = SmoothMaximum(Macro, Anchor, 5.0f);
|
||||
}
|
||||
|
||||
@@ -1152,9 +1443,13 @@ namespace
|
||||
continue;
|
||||
}
|
||||
const FLandingSite& Site = Plan.Landings[SiteIndex];
|
||||
const float Horizontal = LandingBridgeRadius - FMath::Sqrt(
|
||||
DistanceSquaredToSegmentXY(X, Y, Site.Position, Hub.Position));
|
||||
const float T = SegmentParameterXY(X, Y, Site.Position, Hub.Position);
|
||||
const float Horizontal = ColumnContext->bHasLandingXYCache
|
||||
? ColumnContext->LandingBridgeHorizontal[SiteIndex]
|
||||
: LandingBridgeRadius - FMath::Sqrt(
|
||||
DistanceSquaredToSegmentXY(X, Y, Site.Position, Hub.Position));
|
||||
const float T = ColumnContext->bHasLandingXYCache
|
||||
? ColumnContext->LandingBridgeT[SiteIndex]
|
||||
: SegmentParameterXY(X, Y, Site.Position, Hub.Position);
|
||||
const float FloorZ = FMath::Lerp(Site.FloorZ, Hub.FloorZ, T);
|
||||
const float Vertical = FMath::Min(
|
||||
Z - FloorZ, FloorZ + MinimumCaveHeight - Z);
|
||||
@@ -1455,6 +1750,10 @@ void ResetThreadCache()
|
||||
{
|
||||
GPlanCache = FThreadPlanCache();
|
||||
GShaftEdgeCache = FThreadShaftEdgeCache();
|
||||
GParameterizedRoomCellCache.Reset();
|
||||
GParameterizedRoomCellCacheMin = FIntPoint::ZeroValue;
|
||||
GParameterizedRoomCellCacheSize = FIntPoint::ZeroValue;
|
||||
GParameterizedRoomCellCachePlan = nullptr;
|
||||
}
|
||||
|
||||
static float EvaluateInternal(const UVoxelGenerator& Generator,
|
||||
@@ -1462,7 +1761,8 @@ static float EvaluateInternal(const UVoxelGenerator& Generator,
|
||||
float* OutPreEditDensity, float DetailScale,
|
||||
const FBrickEvaluationContext* Context = nullptr,
|
||||
bool bParameterized = false,
|
||||
const FParameterizedBrickContext* ParameterizedContext = nullptr)
|
||||
const FParameterizedBrickContext* ParameterizedContext = nullptr,
|
||||
const FParameterizedColumnContext* ParameterizedColumnContext = nullptr)
|
||||
{
|
||||
if (Context == nullptr && ParameterizedContext == nullptr)
|
||||
{
|
||||
@@ -1509,7 +1809,8 @@ static float EvaluateInternal(const UVoxelGenerator& Generator,
|
||||
{
|
||||
float DetailFade = 1.0f;
|
||||
const float Macro = bParameterized
|
||||
? EvaluateParameterizedMacro(*Plan, WorldX, WorldY, WorldZ, &DetailFade)
|
||||
? EvaluateParameterizedMacro(*Plan, WorldX, WorldY, WorldZ, &DetailFade,
|
||||
ParameterizedContext, ParameterizedColumnContext)
|
||||
: (Context != nullptr && Context->bMacroXYPrecomputed
|
||||
? EvaluateMacroFromBrick(*Plan, *Context, WorldX, WorldY, WorldZ, &DetailFade)
|
||||
: EvaluateMacro(*Plan, WorldX, WorldY, WorldZ, &DetailFade));
|
||||
@@ -1635,6 +1936,51 @@ float EvaluateParameterizedWithDetailValue(const UVoxelGenerator& Generator,
|
||||
OutPreEditDensity, DetailScale, nullptr, true, Context);
|
||||
}
|
||||
|
||||
void EvaluateParameterizedColumnWithDetailValues(
|
||||
const UVoxelGenerator& Generator, float WorldX, float WorldY, float WorldZStart,
|
||||
const float* DetailValues, int32 DetailStride, int32 Count, float* OutValues,
|
||||
const FParameterizedBrickContext* Context, float DetailScale)
|
||||
{
|
||||
if (DetailValues == nullptr || OutValues == nullptr || Count <= 0 || DetailStride <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
const FIntVector Chunk(
|
||||
FMath::FloorToInt(WorldX / CHUNK_SIZE),
|
||||
FMath::FloorToInt(WorldY / CHUNK_SIZE),
|
||||
FMath::FloorToInt(WorldZStart / CHUNK_SIZE));
|
||||
const FStratePlan* Plan = Context != nullptr && Context->bPlanResolved
|
||||
? static_cast<const FStratePlan*>(Context->PlanToken) : nullptr;
|
||||
if (Plan == nullptr)
|
||||
{
|
||||
EnsurePlan(Generator);
|
||||
Plan = FindStrate(Chunk);
|
||||
}
|
||||
const int32 EndChunkZ = FMath::FloorToInt(
|
||||
(WorldZStart + static_cast<float>(Count - 1)) / CHUNK_SIZE);
|
||||
if (Plan == nullptr || Chunk.Z != EndChunkZ)
|
||||
{
|
||||
for (int32 Z = 0; Z < Count; ++Z)
|
||||
{
|
||||
OutValues[Z] = EvaluateInternal(
|
||||
Generator, WorldX, WorldY, WorldZStart + static_cast<float>(Z),
|
||||
DetailValues[Z * DetailStride], true, nullptr, DetailScale,
|
||||
nullptr, true, Context);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
FParameterizedColumnContext ColumnContext;
|
||||
BuildParameterizedColumnContext(*Plan, WorldX, WorldY, Context, ColumnContext);
|
||||
for (int32 Z = 0; Z < Count; ++Z)
|
||||
{
|
||||
OutValues[Z] = EvaluateInternal(
|
||||
Generator, WorldX, WorldY, WorldZStart + static_cast<float>(Z),
|
||||
DetailValues[Z * DetailStride], true, nullptr, DetailScale,
|
||||
nullptr, true, Context, &ColumnContext);
|
||||
}
|
||||
}
|
||||
|
||||
void BuildParameterizedBrickContext(
|
||||
const UVoxelGenerator& Generator, FIntVector OriginVoxels, FIntVector Size,
|
||||
FParameterizedBrickContext& OutContext)
|
||||
@@ -1674,6 +2020,58 @@ void BuildParameterizedBrickContext(
|
||||
static_cast<float>(OriginVoxels.Z + Size.Z));
|
||||
FindPassageCandidates(FBox(Min, Max), OutContext.PassageCandidates);
|
||||
OutContext.bMayContainPassage = !OutContext.PassageCandidates.IsEmpty();
|
||||
|
||||
if (Plan != nullptr && bStableStrate && !OutContext.bIsGapChunk
|
||||
&& Size.X > 0 && Size.Y > 0)
|
||||
{
|
||||
FIntPoint MinimumBaseCell(MAX_int32, MAX_int32);
|
||||
FIntPoint MaximumBaseCell(MIN_int32, MIN_int32);
|
||||
const int32 CornerX[] = {OriginVoxels.X, End.X};
|
||||
const int32 CornerY[] = {OriginVoxels.Y, End.Y};
|
||||
for (const int32 WorldY : CornerY)
|
||||
for (const int32 WorldX : CornerX)
|
||||
{
|
||||
const FIntPoint Cell = GenerationCellAt(
|
||||
*Plan, static_cast<float>(WorldX), static_cast<float>(WorldY));
|
||||
MinimumBaseCell.X = FMath::Min(MinimumBaseCell.X, Cell.X);
|
||||
MinimumBaseCell.Y = FMath::Min(MinimumBaseCell.Y, Cell.Y);
|
||||
MaximumBaseCell.X = FMath::Max(MaximumBaseCell.X, Cell.X);
|
||||
MaximumBaseCell.Y = FMath::Max(MaximumBaseCell.Y, Cell.Y);
|
||||
}
|
||||
|
||||
const FIntPoint NeededMin = MinimumBaseCell - FIntPoint(1, 1);
|
||||
const FIntPoint NeededMax = MaximumBaseCell + FIntPoint(1, 1);
|
||||
const bool bCacheContainsNeededCells = GParameterizedRoomCellCachePlan == Plan
|
||||
&& GParameterizedRoomCellCacheMin.X <= NeededMin.X
|
||||
&& GParameterizedRoomCellCacheMin.Y <= NeededMin.Y
|
||||
&& GParameterizedRoomCellCacheMin.X + GParameterizedRoomCellCacheSize.X - 1
|
||||
>= NeededMax.X
|
||||
&& GParameterizedRoomCellCacheMin.Y + GParameterizedRoomCellCacheSize.Y - 1
|
||||
>= NeededMax.Y;
|
||||
if (!bCacheContainsNeededCells)
|
||||
{
|
||||
// Keep one extra generated-cell layer beyond the 3x3 query halo so adjacent
|
||||
// proof bricks reuse their deterministic room and edge rolls.
|
||||
GParameterizedRoomCellCacheMin = MinimumBaseCell - FIntPoint(2, 2);
|
||||
GParameterizedRoomCellCacheSize = MaximumBaseCell - MinimumBaseCell
|
||||
+ FIntPoint(5, 5);
|
||||
const int32 RoomCellCount = GParameterizedRoomCellCacheSize.X
|
||||
* GParameterizedRoomCellCacheSize.Y;
|
||||
GParameterizedRoomCellCache.SetNumUninitialized(RoomCellCount);
|
||||
int32 RoomCellIndex = 0;
|
||||
for (int32 CellY = 0; CellY < GParameterizedRoomCellCacheSize.Y; ++CellY)
|
||||
for (int32 CellX = 0; CellX < GParameterizedRoomCellCacheSize.X; ++CellX)
|
||||
{
|
||||
GParameterizedRoomCellCache[RoomCellIndex++] = BuildGeneratedCell(
|
||||
*Plan, GParameterizedRoomCellCacheMin.X + CellX,
|
||||
GParameterizedRoomCellCacheMin.Y + CellY);
|
||||
}
|
||||
GParameterizedRoomCellCachePlan = Plan;
|
||||
}
|
||||
OutContext.RoomCellCacheMin = GParameterizedRoomCellCacheMin;
|
||||
OutContext.RoomCellCacheSize = GParameterizedRoomCellCacheSize;
|
||||
OutContext.RoomCellCacheToken = GParameterizedRoomCellCache.GetData();
|
||||
}
|
||||
}
|
||||
|
||||
void BuildDetailBrick(const UVoxelGenerator& Generator, FIntVector OriginVoxels,
|
||||
@@ -1879,22 +2277,47 @@ void BuildDetailBrick(const UVoxelGenerator& Generator, FIntVector OriginVoxels,
|
||||
MinCellX + X, MinCellY + Y, MinCellZ + Z, BandSeed);
|
||||
}
|
||||
|
||||
for (int32 Z = 0; Z < Size.Z; ++Z)
|
||||
for (int32 Y = 0; Y < Size.Y; ++Y)
|
||||
int32 CellX[8];
|
||||
int32 CellY[8];
|
||||
int32 CellZ[8];
|
||||
float FadeX[8];
|
||||
float FadeY[8];
|
||||
float FadeZ[8];
|
||||
for (int32 X = 0; X < Size.X; ++X)
|
||||
{
|
||||
const float SX = static_cast<float>(OriginVoxels.X + X)
|
||||
/ static_cast<float>(CellSize);
|
||||
const int32 Cell = FMath::FloorToInt(SX);
|
||||
CellX[X] = Cell - MinCellX;
|
||||
FadeX[X] = Fade(SX - static_cast<float>(Cell));
|
||||
}
|
||||
for (int32 Y = 0; Y < Size.Y; ++Y)
|
||||
{
|
||||
const float SY = static_cast<float>(OriginVoxels.Y + Y)
|
||||
/ static_cast<float>(CellSize);
|
||||
const int32 Cell = FMath::FloorToInt(SY);
|
||||
CellY[Y] = Cell - MinCellY;
|
||||
FadeY[Y] = Fade(SY - static_cast<float>(Cell));
|
||||
}
|
||||
for (int32 Z = 0; Z < Size.Z; ++Z)
|
||||
{
|
||||
const float SZ = static_cast<float>(OriginVoxels.Z + Z)
|
||||
/ static_cast<float>(CellSize);
|
||||
const int32 IX = FMath::FloorToInt(SX) - MinCellX;
|
||||
const int32 IY = FMath::FloorToInt(SY) - MinCellY;
|
||||
const int32 IZ = FMath::FloorToInt(SZ) - MinCellZ;
|
||||
const float AX = Fade(SX - static_cast<float>(FMath::FloorToInt(SX)));
|
||||
const float AY = Fade(SY - static_cast<float>(FMath::FloorToInt(SY)));
|
||||
const float AZ = Fade(SZ - static_cast<float>(FMath::FloorToInt(SZ)));
|
||||
const int32 Cell = FMath::FloorToInt(SZ);
|
||||
CellZ[Z] = Cell - MinCellZ;
|
||||
FadeZ[Z] = Fade(SZ - static_cast<float>(Cell));
|
||||
}
|
||||
|
||||
for (int32 Z = 0; Z < Size.Z; ++Z)
|
||||
for (int32 Y = 0; Y < Size.Y; ++Y)
|
||||
for (int32 X = 0; X < Size.X; ++X)
|
||||
{
|
||||
const int32 IX = CellX[X];
|
||||
const int32 IY = CellY[Y];
|
||||
const int32 IZ = CellZ[Z];
|
||||
const float AX = FadeX[X];
|
||||
const float AY = FadeY[Y];
|
||||
const float AZ = FadeZ[Z];
|
||||
const int32 Index = (IZ * GridY + IY) * GridX + IX;
|
||||
const float Value = CellSize == 1
|
||||
? Grid[Index]
|
||||
|
||||
@@ -66,6 +66,7 @@ namespace VoxelForgeRedefinedDensityField
|
||||
struct FParameterizedBrickContext
|
||||
{
|
||||
const void* PlanToken = nullptr;
|
||||
const void* RoomCellCacheToken = nullptr;
|
||||
bool bPlanResolved = false;
|
||||
bool bChunkResolved = false;
|
||||
bool bIsGapChunk = false;
|
||||
@@ -74,6 +75,8 @@ namespace VoxelForgeRedefinedDensityField
|
||||
FIntVector BrickOrigin = FIntVector::ZeroValue;
|
||||
FIntVector BrickSize = FIntVector::ZeroValue;
|
||||
FIntVector Chunk = FIntVector::ZeroValue;
|
||||
FIntPoint RoomCellCacheMin = FIntPoint::ZeroValue;
|
||||
FIntPoint RoomCellCacheSize = FIntPoint::ZeroValue;
|
||||
TArray<int32> PassageCandidates;
|
||||
};
|
||||
|
||||
@@ -117,6 +120,12 @@ namespace VoxelForgeRedefinedDensityField
|
||||
float DetailValue, float* OutPreEditDensity = nullptr, float DetailScale = 1.0f,
|
||||
const FParameterizedBrickContext* Context = nullptr);
|
||||
|
||||
/** Evaluate a Z column while reusing its XY-dependent room graph data. */
|
||||
VOXELFORGE_API void EvaluateParameterizedColumnWithDetailValues(
|
||||
const UVoxelGenerator& Generator, float WorldX, float WorldY, float WorldZStart,
|
||||
const float* DetailValues, int32 DetailStride, int32 Count, float* OutValues,
|
||||
const FParameterizedBrickContext* Context = nullptr, float DetailScale = 1.0f);
|
||||
|
||||
VOXELFORGE_API bool TryClassifyParameterizedBrick(
|
||||
const UVoxelGenerator& Generator, FIntVector OriginVoxels, FIntVector Size,
|
||||
bool& bOutAir, float DetailScale = 1.0f,
|
||||
|
||||
@@ -2545,6 +2545,18 @@ struct FStep2dBrickProofAudit
|
||||
uint64 CorrectlySkippedBricksAudited = 0;
|
||||
uint64 CorrectProofSamplesChecked = 0;
|
||||
uint64 CorrectProofViolations = 0;
|
||||
FIntVector FirstViolationBrickOrigin = FIntVector::ZeroValue;
|
||||
FIntVector FirstViolationBrickSize = FIntVector::ZeroValue;
|
||||
FIntVector FirstViolationSample = FIntVector::ZeroValue;
|
||||
float FirstViolationDensity = 0.0f;
|
||||
float FirstViolationCenterMacro = 0.0f;
|
||||
float FirstViolationSampleMacro = 0.0f;
|
||||
float FirstViolationSampleDetail = 0.0f;
|
||||
float FirstViolationMacroDeltaPerVoxel = 0.0f;
|
||||
float FirstViolationPathMaxGradient = 0.0f;
|
||||
float FirstViolationTinyStepMaxGradient = 0.0f;
|
||||
bool bFirstViolationWasInsideBrick = false;
|
||||
bool bFirstViolationClaimedAir = false;
|
||||
uint64 DeliberatelyUndersizedBoundClaimsChecked = 0;
|
||||
uint64 DeliberateBoundDisagreements = 0;
|
||||
};
|
||||
@@ -2608,6 +2620,88 @@ FStep2dBrickProofAudit AuditStep2dBrickProofs(
|
||||
++Result.CorrectProofSamplesChecked;
|
||||
if ((Density > 0.0f) != bProvenAir)
|
||||
{
|
||||
if (Result.CorrectProofViolations == 0)
|
||||
{
|
||||
Result.FirstViolationBrickOrigin = BrickOrigin;
|
||||
Result.FirstViolationBrickSize = Size;
|
||||
Result.FirstViolationSample = BrickOrigin + FIntVector(X, Y, Z);
|
||||
Result.FirstViolationDensity = Density;
|
||||
const FVector ProofMin(
|
||||
static_cast<float>(BrickOrigin.X - 1),
|
||||
static_cast<float>(BrickOrigin.Y - 1),
|
||||
static_cast<float>(BrickOrigin.Z - 1));
|
||||
const FVector ProofMax(
|
||||
static_cast<float>(BrickOrigin.X + Size.X),
|
||||
static_cast<float>(BrickOrigin.Y + Size.Y),
|
||||
static_cast<float>(BrickOrigin.Z + Size.Z));
|
||||
const FVector ProofCentre = (ProofMin + ProofMax) * 0.5f;
|
||||
const FVector SamplePoint(
|
||||
static_cast<float>(BrickOrigin.X + X),
|
||||
static_cast<float>(BrickOrigin.Y + Y),
|
||||
static_cast<float>(BrickOrigin.Z + Z));
|
||||
Result.FirstViolationCenterMacro = bParameterized
|
||||
? VoxelForgeRedefinedDensityField::EvaluateParameterized(
|
||||
Generator, ProofCentre.X, ProofCentre.Y, ProofCentre.Z,
|
||||
nullptr, 0.0f)
|
||||
: VoxelForgeRedefinedDensityField::Evaluate(
|
||||
Generator, ProofCentre.X, ProofCentre.Y, ProofCentre.Z,
|
||||
nullptr, 0.0f);
|
||||
Result.FirstViolationSampleMacro = bParameterized
|
||||
? VoxelForgeRedefinedDensityField::EvaluateParameterized(
|
||||
Generator, SamplePoint.X, SamplePoint.Y, SamplePoint.Z,
|
||||
nullptr, 0.0f)
|
||||
: VoxelForgeRedefinedDensityField::Evaluate(
|
||||
Generator, SamplePoint.X, SamplePoint.Y, SamplePoint.Z,
|
||||
nullptr, 0.0f);
|
||||
Result.FirstViolationSampleDetail = Density
|
||||
- Result.FirstViolationSampleMacro;
|
||||
const float CentreDistance = (SamplePoint - ProofCentre).Size();
|
||||
Result.FirstViolationMacroDeltaPerVoxel = CentreDistance > 1.0e-6f
|
||||
? FMath::Abs(Result.FirstViolationCenterMacro
|
||||
- Result.FirstViolationSampleMacro) / CentreDistance
|
||||
: 0.0f;
|
||||
if (CentreDistance > 1.0e-6f)
|
||||
{
|
||||
constexpr int32 PathSteps = 32;
|
||||
float PreviousMacro = Result.FirstViolationSampleMacro;
|
||||
for (int32 PathStep = 1; PathStep <= PathSteps; ++PathStep)
|
||||
{
|
||||
const float Alpha = static_cast<float>(PathStep) / PathSteps;
|
||||
const FVector Point = FMath::Lerp(
|
||||
SamplePoint, ProofCentre, Alpha);
|
||||
const float PathMacro = bParameterized
|
||||
? VoxelForgeRedefinedDensityField::EvaluateParameterized(
|
||||
Generator, Point.X, Point.Y, Point.Z, nullptr, 0.0f)
|
||||
: VoxelForgeRedefinedDensityField::Evaluate(
|
||||
Generator, Point.X, Point.Y, Point.Z, nullptr, 0.0f);
|
||||
Result.FirstViolationPathMaxGradient = FMath::Max(
|
||||
Result.FirstViolationPathMaxGradient,
|
||||
FMath::Abs(PathMacro - PreviousMacro)
|
||||
* PathSteps / CentreDistance);
|
||||
PreviousMacro = PathMacro;
|
||||
}
|
||||
}
|
||||
constexpr float TinyStep = 0.01f;
|
||||
for (int32 Axis = 0; Axis < 3; ++Axis)
|
||||
for (int32 SignIndex = 0; SignIndex < 2; ++SignIndex)
|
||||
{
|
||||
const int32 Sign = SignIndex == 0 ? -1 : 1;
|
||||
FVector Point = SamplePoint;
|
||||
Point[Axis] += static_cast<float>(Sign) * TinyStep;
|
||||
const float NeighborMacro = bParameterized
|
||||
? VoxelForgeRedefinedDensityField::EvaluateParameterized(
|
||||
Generator, Point.X, Point.Y, Point.Z, nullptr, 0.0f)
|
||||
: VoxelForgeRedefinedDensityField::Evaluate(
|
||||
Generator, Point.X, Point.Y, Point.Z, nullptr, 0.0f);
|
||||
Result.FirstViolationTinyStepMaxGradient = FMath::Max(
|
||||
Result.FirstViolationTinyStepMaxGradient,
|
||||
FMath::Abs(NeighborMacro - Result.FirstViolationSampleMacro)
|
||||
/ TinyStep);
|
||||
}
|
||||
Result.bFirstViolationWasInsideBrick = X >= 0 && X < Size.X
|
||||
&& Y >= 0 && Y < Size.Y && Z >= 0 && Z < Size.Z;
|
||||
Result.bFirstViolationClaimedAir = bProvenAir;
|
||||
}
|
||||
++Result.CorrectProofViolations;
|
||||
}
|
||||
}
|
||||
@@ -2805,6 +2899,17 @@ FStep2dBoundaryStats ComputeStep2dBoundaryStats(
|
||||
return Result;
|
||||
}
|
||||
|
||||
bool Step2eBoundaryStatsPass(const FStep2dBoundaryStats& Stats)
|
||||
{
|
||||
return Stats.BrickBoundarySamples > 0
|
||||
&& Stats.InteriorSamples > 0
|
||||
&& Stats.ChunkBoundarySamples > 0
|
||||
&& Stats.FeatureCellBoundarySamples > 0
|
||||
&& Stats.BrickJumpRms <= Stats.InteriorJumpRms * 2.0 + 0.25
|
||||
&& Stats.ChunkBoundaryJumpRms <= Stats.InteriorJumpRms * 2.0 + 0.25
|
||||
&& Stats.FeatureCellJumpRms <= Stats.FeatureCellInteriorJumpRms * 2.0 + 0.25;
|
||||
}
|
||||
|
||||
FColor Step2dDensityColor(float Density)
|
||||
{
|
||||
if (FMath::Abs(Density) < 1.0f)
|
||||
@@ -2868,6 +2973,9 @@ struct FStep2eVarietyMetrics
|
||||
double SurfaceAreaSquareMeters = 0.0;
|
||||
double SurfaceAreaPerVolume = 0.0;
|
||||
double VerticalAdjacencyShare = 0.0;
|
||||
double VerticalAirColumnShare = 0.0;
|
||||
double MeanLongestVerticalAirRunVoxels = 0.0;
|
||||
int32 LongestVerticalAirRunVoxels = 0;
|
||||
double TunnelNeckShare = 0.0;
|
||||
int32 ConnectedComponentsAtOneMeter = 0;
|
||||
int64 LargestComponentCubicMeters = 0;
|
||||
@@ -2886,6 +2994,11 @@ FStep2eVarietyMetrics ComputeStep2eVarietyMetrics(
|
||||
uint64 SurfaceEdgeCount = 0;
|
||||
uint64 HorizontalAdjacencies = 0;
|
||||
uint64 VerticalAdjacencies = 0;
|
||||
const int32 ColumnCount = Dimension * Dimension;
|
||||
TArray<int32> CurrentVerticalRun;
|
||||
CurrentVerticalRun.SetNumZeroed(ColumnCount);
|
||||
TArray<int32> LongestVerticalRun;
|
||||
LongestVerticalRun.SetNumZeroed(ColumnCount);
|
||||
for (int32 Z = 0; Z < Dimension; ++Z)
|
||||
for (int32 Y = 0; Y < Dimension; ++Y)
|
||||
for (int32 X = 0; X < Dimension; ++X)
|
||||
@@ -2893,6 +3006,10 @@ FStep2eVarietyMetrics ComputeStep2eVarietyMetrics(
|
||||
const int32 Index = (Z * Dimension + Y) * Dimension + X;
|
||||
const bool bAir = Density[Index] > 0.0f;
|
||||
AirCount += bAir ? 1 : 0;
|
||||
const int32 ColumnIndex = Y * Dimension + X;
|
||||
CurrentVerticalRun[ColumnIndex] = bAir ? CurrentVerticalRun[ColumnIndex] + 1 : 0;
|
||||
LongestVerticalRun[ColumnIndex] = FMath::Max(
|
||||
LongestVerticalRun[ColumnIndex], CurrentVerticalRun[ColumnIndex]);
|
||||
if (X + 1 < Dimension)
|
||||
{
|
||||
const bool bNextAir = Density[Index + 1] > 0.0f;
|
||||
@@ -2922,6 +3039,22 @@ FStep2eVarietyMetrics ComputeStep2eVarietyMetrics(
|
||||
const uint64 AllAdjacencies = HorizontalAdjacencies + VerticalAdjacencies;
|
||||
Result.VerticalAdjacencyShare = AllAdjacencies > 0
|
||||
? static_cast<double>(VerticalAdjacencies) / AllAdjacencies : 0.0;
|
||||
uint64 ColumnsWithAir = 0;
|
||||
uint64 TotalLongestRunVoxels = 0;
|
||||
for (const int32 LongestRun : LongestVerticalRun)
|
||||
{
|
||||
if (LongestRun > 0)
|
||||
{
|
||||
++ColumnsWithAir;
|
||||
TotalLongestRunVoxels += static_cast<uint64>(LongestRun);
|
||||
Result.LongestVerticalAirRunVoxels = FMath::Max(
|
||||
Result.LongestVerticalAirRunVoxels, LongestRun);
|
||||
}
|
||||
}
|
||||
Result.VerticalAirColumnShare = ColumnCount > 0
|
||||
? static_cast<double>(ColumnsWithAir) / ColumnCount : 0.0;
|
||||
Result.MeanLongestVerticalAirRunVoxels = ColumnsWithAir > 0
|
||||
? static_cast<double>(TotalLongestRunVoxels) / ColumnsWithAir : 0.0;
|
||||
|
||||
constexpr int32 CoarseStep = 4;
|
||||
const int32 CoarseDimension = (Dimension - 1) / CoarseStep + 1;
|
||||
@@ -3056,6 +3189,90 @@ TSharedRef<FJsonObject> Step2eParametersJson(
|
||||
return Json;
|
||||
}
|
||||
|
||||
TSharedRef<FJsonObject> Step2eChamberVolumeQuantilesJson(
|
||||
const VoxelForgeRedefinedDensityField::FGenerationParameters& P)
|
||||
{
|
||||
TSharedRef<FJsonObject> Json = MakeShared<FJsonObject>();
|
||||
constexpr double Pi = 3.14159265358979323846;
|
||||
constexpr double CubicMetersPerVoxel = 0.25 * 0.25 * 0.25;
|
||||
const double Quantiles[] = {0.10, 0.50, 0.90};
|
||||
const TCHAR* Names[] = {TEXT("p10_m3"), TEXT("p50_m3"), TEXT("p90_m3")};
|
||||
for (int32 Index = 0; Index < UE_ARRAY_COUNT(Quantiles); ++Index)
|
||||
{
|
||||
const double RadiusFraction = FMath::Lerp(
|
||||
static_cast<double>(P.MinimumRoomRadiusFraction),
|
||||
static_cast<double>(P.MaximumRoomRadiusFraction), Quantiles[Index]);
|
||||
const double RadiusVoxels = RadiusFraction * P.RoomPitchVoxels;
|
||||
const double VolumeCubicVoxels = Pi * RadiusVoxels * RadiusVoxels
|
||||
* P.RoomHeightVoxels;
|
||||
Json->SetNumberField(Names[Index], VolumeCubicVoxels * CubicMetersPerVoxel);
|
||||
}
|
||||
return Json;
|
||||
}
|
||||
|
||||
TSharedRef<FJsonObject> Step2eParameterRangesJson()
|
||||
{
|
||||
using FParameters = VoxelForgeRedefinedDensityField::FGenerationParameters;
|
||||
struct FParameterRange
|
||||
{
|
||||
const TCHAR* Name;
|
||||
float FParameters::*Value;
|
||||
};
|
||||
static const FParameterRange Fields[] = {
|
||||
{TEXT("room_pitch_voxels"), &FParameters::RoomPitchVoxels},
|
||||
{TEXT("room_radius_fraction_min"), &FParameters::MinimumRoomRadiusFraction},
|
||||
{TEXT("room_radius_fraction_max"), &FParameters::MaximumRoomRadiusFraction},
|
||||
{TEXT("room_height_voxels"), &FParameters::RoomHeightVoxels},
|
||||
{TEXT("floor_relief_voxels"), &FParameters::FloorReliefVoxels},
|
||||
{TEXT("tunnel_radius_voxels"), &FParameters::TunnelRadiusVoxels},
|
||||
{TEXT("tunnel_half_height_voxels"), &FParameters::TunnelHalfHeightVoxels},
|
||||
{TEXT("loop_probability"), &FParameters::LoopProbability},
|
||||
{TEXT("vertical_shaft_probability"), &FParameters::VerticalShaftProbability},
|
||||
{TEXT("shaft_radius_voxels"), &FParameters::ShaftRadiusVoxels},
|
||||
{TEXT("pillar_probability"), &FParameters::PillarProbability},
|
||||
{TEXT("ledge_probability"), &FParameters::LedgeProbability},
|
||||
{TEXT("floating_mass_probability"), &FParameters::FloatingMassProbability},
|
||||
{TEXT("stalactite_stalagmite_probability"), &FParameters::SpireProbability},
|
||||
{TEXT("basin_probability"), &FParameters::BasinProbability},
|
||||
{TEXT("basin_depth_voxels"), &FParameters::BasinDepthVoxels},
|
||||
{TEXT("water_level_fraction"), &FParameters::WaterLevelFraction},
|
||||
};
|
||||
|
||||
TSharedRef<FJsonObject> Result = MakeShared<FJsonObject>();
|
||||
for (const FParameterRange& Field : Fields)
|
||||
{
|
||||
float Minimum = FLT_MAX;
|
||||
float Maximum = -FLT_MAX;
|
||||
for (int32 ProfileIndex = 0;
|
||||
ProfileIndex < VoxelForgeRedefinedDensityField::GetParameterSetCount();
|
||||
++ProfileIndex)
|
||||
{
|
||||
const TCHAR* Name = nullptr;
|
||||
FParameters Parameters;
|
||||
if (!VoxelForgeRedefinedDensityField::GetParameterSetInfo(
|
||||
ProfileIndex, Name, Parameters))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const float Value = Parameters.*(Field.Value);
|
||||
Minimum = FMath::Min(Minimum, Value);
|
||||
Maximum = FMath::Max(Maximum, Value);
|
||||
}
|
||||
TSharedRef<FJsonObject> Bounds = MakeShared<FJsonObject>();
|
||||
Bounds->SetNumberField(TEXT("minimum_across_profiles"), Minimum);
|
||||
Bounds->SetNumberField(TEXT("maximum_across_profiles"), Maximum);
|
||||
Result->SetObjectField(Field.Name, Bounds);
|
||||
}
|
||||
return Result;
|
||||
}
|
||||
|
||||
bool Step2eSameWorkerRun(
|
||||
const VoxelForgeRegionEval::FTiming& A,
|
||||
const VoxelForgeRegionEval::FTiming& B)
|
||||
{
|
||||
return A.QuantizedHash == B.QuantizedHash && A.RawFloatHash == B.RawFloatHash;
|
||||
}
|
||||
|
||||
TSharedRef<FJsonObject> Step2dTimingJson(const VoxelForgeRegionEval::FTiming& Timing)
|
||||
{
|
||||
TSharedRef<FJsonObject> Json = MakeShared<FJsonObject>();
|
||||
@@ -3653,6 +3870,8 @@ int32 RunStep2e(const FString& Params)
|
||||
Row->SetNumberField(TEXT("profile_index"), Profile);
|
||||
Row->SetStringField(TEXT("name"), ProfileName);
|
||||
Row->SetObjectField(TEXT("parameters"), Step2eParametersJson(ProfileParameters));
|
||||
Row->SetObjectField(TEXT("nominal_chamber_volume_quantiles_m3"),
|
||||
Step2eChamberVolumeQuantilesJson(ProfileParameters));
|
||||
Row->SetNumberField(TEXT("six_worker_ring_median_ms"), MedianMs);
|
||||
TArray<TSharedPtr<FJsonValue>> TrialValues;
|
||||
TrialValues.Add(MakeShared<FJsonValueNumber>(Times[0]));
|
||||
@@ -3664,6 +3883,11 @@ int32 RunStep2e(const FString& Params)
|
||||
Row->SetNumberField(TEXT("estimated_surface_area_per_volume_m_inv"),
|
||||
Variety.SurfaceAreaPerVolume);
|
||||
Row->SetNumberField(TEXT("vertical_air_adjacency_share"), Variety.VerticalAdjacencyShare);
|
||||
Row->SetNumberField(TEXT("vertical_air_column_share"), Variety.VerticalAirColumnShare);
|
||||
Row->SetNumberField(TEXT("mean_longest_vertical_air_run_voxels"),
|
||||
Variety.MeanLongestVerticalAirRunVoxels);
|
||||
Row->SetNumberField(TEXT("longest_vertical_air_run_voxels"),
|
||||
Variety.LongestVerticalAirRunVoxels);
|
||||
Row->SetNumberField(TEXT("one_meter_tunnel_neck_share"), Variety.TunnelNeckShare);
|
||||
Row->SetNumberField(TEXT("one_meter_connected_components"),
|
||||
Variety.ConnectedComponentsAtOneMeter);
|
||||
@@ -3675,6 +3899,17 @@ int32 RunStep2e(const FString& Params)
|
||||
Row->SetNumberField(TEXT("skipped_bricks"), static_cast<double>(LastTiming.SkippedBricks));
|
||||
Row->SetNumberField(TEXT("skipped_sample_fraction"), LastTiming.SampleCount > 0
|
||||
? static_cast<double>(LastTiming.SkippedSamples) / LastTiming.SampleCount : 0.0);
|
||||
Row->SetNumberField(TEXT("evaluated_samples"),
|
||||
static_cast<double>(LastTiming.EvaluatedSamples));
|
||||
Row->SetNumberField(TEXT("worker_cpu_seconds"), LastTiming.WorkerCpuSeconds);
|
||||
Row->SetNumberField(TEXT("brick_classification_worker_ms"),
|
||||
LastTiming.BrickClassificationSeconds * 1000.0);
|
||||
Row->SetNumberField(TEXT("density_evaluation_worker_ms"),
|
||||
LastTiming.DensityEvaluationSeconds * 1000.0);
|
||||
Row->SetNumberField(TEXT("uniform_fill_worker_ms"),
|
||||
LastTiming.UniformFillSeconds * 1000.0);
|
||||
Row->SetNumberField(TEXT("longest_worker_ms"),
|
||||
LastTiming.LongestWorkerWallSeconds * 1000.0);
|
||||
|
||||
FString SafeName(ProfileName);
|
||||
SafeName.ToLowerInline();
|
||||
@@ -3778,26 +4013,41 @@ int32 RunStep2e(const FString& Params)
|
||||
const FStep2dBoundaryStats BoundaryStats = ComputeStep2dBoundaryStats(
|
||||
HardestFullDensity, Dimension, Origin,
|
||||
FMath::RoundToInt(HardestParameters.RoomPitchVoxels));
|
||||
TArray<float> SeamFailureDensity = HardestFullDensity;
|
||||
int64 DeliberateSeamSamplesMutated = 0;
|
||||
for (int32 Z = 1; Z < Dimension - 1; ++Z)
|
||||
for (int32 Y = 1; Y < Dimension - 1; ++Y)
|
||||
for (int32 X = 1; X < Dimension - 1; ++X)
|
||||
{
|
||||
const int32 Index = (Z * Dimension + Y) * Dimension + X;
|
||||
if (((Origin.X + X) % 8) == 0 && FMath::Abs(HardestFullDensity[Index]) <= 12.0f)
|
||||
{
|
||||
SeamFailureDensity[Index + 1] += 64.0f;
|
||||
++DeliberateSeamSamplesMutated;
|
||||
}
|
||||
}
|
||||
const FStep2dBoundaryStats SeamFailureStats = ComputeStep2dBoundaryStats(
|
||||
SeamFailureDensity, Dimension, Origin,
|
||||
FMath::RoundToInt(HardestParameters.RoomPitchVoxels));
|
||||
const FStep2dBrickProofAudit ProofAudit = AuditStep2dBrickProofs(
|
||||
*World.Generator, Origin, Dimension, true);
|
||||
const uint64 HardestHash = VoxelForgeRegionEval::HashQuantized(HardestFullDensity);
|
||||
const uint64 RepeatHash = VoxelForgeRegionEval::HashQuantized(RepeatFullDensity);
|
||||
const uint64 OneWorkerHash = VoxelForgeRegionEval::HashQuantized(OneWorkerDensity);
|
||||
const bool bDeterminism = HardestHash == RepeatHash && HardestHash == OneWorkerHash
|
||||
&& HardestFullTiming.RawFloatHash == RepeatTiming.RawFloatHash
|
||||
&& HardestFullTiming.RawFloatHash == OneWorkerTiming.RawFloatHash;
|
||||
&& Step2eSameWorkerRun(HardestFullTiming, RepeatTiming)
|
||||
&& Step2eSameWorkerRun(HardestFullTiming, OneWorkerTiming);
|
||||
VoxelForgeRegionEval::FTiming DeliberateMismatch = HardestFullTiming;
|
||||
DeliberateMismatch.QuantizedHash ^= 1u;
|
||||
const bool bDeliberateDeterminismMismatchCaught =
|
||||
!Step2eSameWorkerRun(HardestFullTiming, DeliberateMismatch);
|
||||
const bool bDetailAtLeastLive = NewSpectrum.RMSLag1 >= OldSpectrum.RMSLag1
|
||||
&& NewSpectrum.RMSLag2 >= OldSpectrum.RMSLag2;
|
||||
const bool bSmoothingControlCaught = SmoothSpectrum.RMSLag1 < NewSpectrum.RMSLag1 * 0.80
|
||||
|| SmoothSpectrum.RMSLag2 < NewSpectrum.RMSLag2 * 0.80;
|
||||
const bool bBoundaryPass = BoundaryStats.BrickBoundarySamples > 0
|
||||
&& BoundaryStats.InteriorSamples > 0
|
||||
&& BoundaryStats.ChunkBoundarySamples > 0
|
||||
&& BoundaryStats.FeatureCellBoundarySamples > 0
|
||||
&& BoundaryStats.BrickJumpRms <= BoundaryStats.InteriorJumpRms * 2.0 + 0.25
|
||||
&& BoundaryStats.ChunkBoundaryJumpRms <= BoundaryStats.InteriorJumpRms * 2.0 + 0.25
|
||||
&& BoundaryStats.FeatureCellJumpRms
|
||||
<= BoundaryStats.FeatureCellInteriorJumpRms * 2.0 + 0.25;
|
||||
const bool bBoundaryPass = Step2eBoundaryStatsPass(BoundaryStats);
|
||||
const bool bDeliberateSeamFailureCaught = DeliberateSeamSamplesMutated > 0
|
||||
&& !Step2eBoundaryStatsPass(SeamFailureStats);
|
||||
const bool bBoundAudit = ProofAudit.CorrectlySkippedBricksAudited > 0
|
||||
&& ProofAudit.CorrectProofSamplesChecked > 0
|
||||
&& ProofAudit.CorrectProofViolations == 0;
|
||||
@@ -3810,6 +4060,7 @@ int32 RunStep2e(const FString& Params)
|
||||
const bool bSpeedPass = Workers == 6 && bProfilePasses && WorstMedianMs <= 600.0;
|
||||
const bool bPassed = bSpeedPass && bDeterminism && bDetailAtLeastLive
|
||||
&& bSmoothingControlCaught && bDetailParity && bBoundaryPass
|
||||
&& bDeliberateSeamFailureCaught && bDeliberateDeterminismMismatchCaught
|
||||
&& bBoundAudit && bUndersizedBoundCaught
|
||||
&& HardestFullTiming.NonFiniteSamples == 0;
|
||||
|
||||
@@ -3832,13 +4083,19 @@ int32 RunStep2e(const FString& Params)
|
||||
"rock masses and a bowl floor with an explicit water level. Passage pads and anchor "
|
||||
"tunnels join the authored inter-strate route to the generated network."));
|
||||
Report->SetStringField(TEXT("parameter_space"),
|
||||
TEXT("Eight named profiles can be assigned per strate from a seed hash (-1 mode), or "
|
||||
"forced for measurement. Each profile rolls cell placement and feature choices from "
|
||||
"the world seed and strate index; see parameters and documented ranges in the report."));
|
||||
TEXT("Eight named profiles can be assigned per strate from a stable seed hash (-1 mode), "
|
||||
"or forced for measurement. Each profile supplies nominal room, tunnel, shaft, "
|
||||
"feature-probability and basin values. Per-cell hashes deterministically roll room "
|
||||
"jitter and feature presence. Profile minima and maxima are recorded below; room "
|
||||
"height is clamped to the strate span, room radii to 0.20-0.72/0.80 of pitch, "
|
||||
"loop probability to 0-0.8, probabilities and water level to 0-1, and basin depth "
|
||||
"to 0-48 voxels."));
|
||||
Report->SetObjectField(TEXT("parameter_ranges_across_eight_profiles"),
|
||||
Step2eParameterRangesJson());
|
||||
Report->SetStringField(TEXT("resolution_contract"),
|
||||
TEXT("One exact field sample per 25 cm lattice point. The four existing 8/4/2/1-sample "
|
||||
"detail bands are evaluated for every potentially surface-affecting point; no coarse "
|
||||
"field is interpolated onto the lattice. 8-cubed skips require the final macro field "
|
||||
"field is interpolated onto the lattice. 4-cubed step 2e skips require the final macro field "
|
||||
"Lipschitz interval plus the full 5.25-unit detail supremum and marching-cubes halo."));
|
||||
Report->SetStringField(TEXT("finer_lattice_scaling"),
|
||||
TEXT("For 12.5 cm voxels, double room pitch, room height, tunnel/feature dimensions and "
|
||||
@@ -3848,9 +4105,11 @@ int32 RunStep2e(const FString& Params)
|
||||
"remain cheap. This scale has not been timed."));
|
||||
Report->SetStringField(TEXT("variety_metric_method"),
|
||||
TEXT("Open fraction uses every ring sample. Surface area estimates sign-changing lattice "
|
||||
"edges times 0.25 m squared. Chamber-size bins, connected components and tunnel-neck "
|
||||
"share use a 1 m downsampled six-neighbor occupancy grid; verticality is the share of "
|
||||
"open 1-cell adjacencies that point vertically."));
|
||||
"edges times 0.25 m squared. Nominal chamber-volume p10/p50/p90 values use the "
|
||||
"uniform per-cell radius roll and room height as circular-cylinder volumes. Tunnel-neck "
|
||||
"share and connected-component sizes use a 1 m downsampled six-neighbor occupancy grid. "
|
||||
"Verticality is the mean longest contiguous open run per XY column, with open-column "
|
||||
"coverage reported separately."));
|
||||
Report->SetStringField(TEXT("water_geometry_limit"),
|
||||
TEXT("Basin profiles generate the bowl floor and water-level parameter; this density field "
|
||||
"does not render or simulate water."));
|
||||
@@ -3884,6 +4143,10 @@ int32 RunStep2e(const FString& Params)
|
||||
Boundary->SetNumberField(TEXT("feature_cell_boundary_gradient_jump_rms"), BoundaryStats.FeatureCellJumpRms);
|
||||
Boundary->SetNumberField(TEXT("feature_cell_interior_gradient_jump_rms"), BoundaryStats.FeatureCellInteriorJumpRms);
|
||||
Boundary->SetBoolField(TEXT("boundary_artifact_check_pass"), bBoundaryPass);
|
||||
Boundary->SetNumberField(TEXT("deliberate_seam_samples_mutated"),
|
||||
static_cast<double>(DeliberateSeamSamplesMutated));
|
||||
Boundary->SetBoolField(TEXT("deliberate_seam_failure_caught"),
|
||||
bDeliberateSeamFailureCaught);
|
||||
Report->SetObjectField(TEXT("boundary_artifact_check"), Boundary);
|
||||
|
||||
TSharedRef<FJsonObject> Proofs = MakeShared<FJsonObject>();
|
||||
@@ -3893,6 +4156,32 @@ int32 RunStep2e(const FString& Params)
|
||||
static_cast<double>(ProofAudit.CorrectProofSamplesChecked));
|
||||
Proofs->SetNumberField(TEXT("correct_proof_sign_violations"),
|
||||
static_cast<double>(ProofAudit.CorrectProofViolations));
|
||||
Proofs->SetNumberField(TEXT("first_violation_brick_x"), ProofAudit.FirstViolationBrickOrigin.X);
|
||||
Proofs->SetNumberField(TEXT("first_violation_brick_y"), ProofAudit.FirstViolationBrickOrigin.Y);
|
||||
Proofs->SetNumberField(TEXT("first_violation_brick_z"), ProofAudit.FirstViolationBrickOrigin.Z);
|
||||
Proofs->SetNumberField(TEXT("first_violation_brick_size_x"), ProofAudit.FirstViolationBrickSize.X);
|
||||
Proofs->SetNumberField(TEXT("first_violation_brick_size_y"), ProofAudit.FirstViolationBrickSize.Y);
|
||||
Proofs->SetNumberField(TEXT("first_violation_brick_size_z"), ProofAudit.FirstViolationBrickSize.Z);
|
||||
Proofs->SetNumberField(TEXT("first_violation_sample_x"), ProofAudit.FirstViolationSample.X);
|
||||
Proofs->SetNumberField(TEXT("first_violation_sample_y"), ProofAudit.FirstViolationSample.Y);
|
||||
Proofs->SetNumberField(TEXT("first_violation_sample_z"), ProofAudit.FirstViolationSample.Z);
|
||||
Proofs->SetNumberField(TEXT("first_violation_density"), ProofAudit.FirstViolationDensity);
|
||||
Proofs->SetNumberField(TEXT("first_violation_center_macro"),
|
||||
ProofAudit.FirstViolationCenterMacro);
|
||||
Proofs->SetNumberField(TEXT("first_violation_sample_macro"),
|
||||
ProofAudit.FirstViolationSampleMacro);
|
||||
Proofs->SetNumberField(TEXT("first_violation_sample_detail"),
|
||||
ProofAudit.FirstViolationSampleDetail);
|
||||
Proofs->SetNumberField(TEXT("first_violation_macro_delta_per_voxel"),
|
||||
ProofAudit.FirstViolationMacroDeltaPerVoxel);
|
||||
Proofs->SetNumberField(TEXT("first_violation_path_max_gradient"),
|
||||
ProofAudit.FirstViolationPathMaxGradient);
|
||||
Proofs->SetNumberField(TEXT("first_violation_tiny_step_max_gradient"),
|
||||
ProofAudit.FirstViolationTinyStepMaxGradient);
|
||||
Proofs->SetBoolField(TEXT("first_violation_inside_proven_brick"),
|
||||
ProofAudit.bFirstViolationWasInsideBrick);
|
||||
Proofs->SetBoolField(TEXT("first_violation_claimed_air"),
|
||||
ProofAudit.bFirstViolationClaimedAir);
|
||||
Proofs->SetNumberField(TEXT("undersized_bound_claims_checked"),
|
||||
static_cast<double>(ProofAudit.DeliberatelyUndersizedBoundClaimsChecked));
|
||||
Proofs->SetNumberField(TEXT("wrong_sign_samples_caught_by_undersized_bound"),
|
||||
@@ -3915,6 +4204,8 @@ int32 RunStep2e(const FString& Params)
|
||||
Determinism->SetStringField(TEXT("one_worker_raw_float"), FString::Printf(
|
||||
TEXT("%016llx"), static_cast<unsigned long long>(OneWorkerTiming.RawFloatHash)));
|
||||
Determinism->SetBoolField(TEXT("same_across_two_runs_and_1_vs_6_workers"), bDeterminism);
|
||||
Determinism->SetBoolField(TEXT("deliberate_quantized_hash_mismatch_rejected"),
|
||||
bDeliberateDeterminismMismatchCaught);
|
||||
Report->SetObjectField(TEXT("determinism"), Determinism);
|
||||
Report->SetBoolField(TEXT("entrance_exit_walkability_test_added"), true);
|
||||
Report->SetBoolField(TEXT("inter_strate_passage_open_space_test_added"), true);
|
||||
|
||||
@@ -181,27 +181,30 @@ namespace VoxelForgeRegionEval
|
||||
TArray<FResearchBrick> Bricks;
|
||||
const FIntVector Last = OriginVoxels
|
||||
+ FIntVector(Dimension - 1, Dimension - 1, Dimension - 1);
|
||||
const FIntVector ProofBrickSize = bParameterized
|
||||
? FIntVector(4, 4, 4) : FIntVector(8, 8, 8);
|
||||
const FIntVector FirstBrick(
|
||||
FMath::FloorToInt(static_cast<float>(OriginVoxels.X) / 8.0f),
|
||||
FMath::FloorToInt(static_cast<float>(OriginVoxels.Y) / 8.0f),
|
||||
FMath::FloorToInt(static_cast<float>(OriginVoxels.Z) / 8.0f));
|
||||
FMath::FloorToInt(static_cast<float>(OriginVoxels.X) / ProofBrickSize.X),
|
||||
FMath::FloorToInt(static_cast<float>(OriginVoxels.Y) / ProofBrickSize.Y),
|
||||
FMath::FloorToInt(static_cast<float>(OriginVoxels.Z) / ProofBrickSize.Z));
|
||||
const FIntVector LastBrick(
|
||||
FMath::FloorToInt(static_cast<float>(Last.X) / 8.0f),
|
||||
FMath::FloorToInt(static_cast<float>(Last.Y) / 8.0f),
|
||||
FMath::FloorToInt(static_cast<float>(Last.Z) / 8.0f));
|
||||
FMath::FloorToInt(static_cast<float>(Last.X) / ProofBrickSize.X),
|
||||
FMath::FloorToInt(static_cast<float>(Last.Y) / ProofBrickSize.Y),
|
||||
FMath::FloorToInt(static_cast<float>(Last.Z) / ProofBrickSize.Z));
|
||||
Bricks.Reserve((LastBrick.X - FirstBrick.X + 1)
|
||||
* (LastBrick.Y - FirstBrick.Y + 1) * (LastBrick.Z - FirstBrick.Z + 1));
|
||||
for (int32 BZ = FirstBrick.Z; BZ <= LastBrick.Z; ++BZ)
|
||||
for (int32 BY = FirstBrick.Y; BY <= LastBrick.Y; ++BY)
|
||||
for (int32 BX = FirstBrick.X; BX <= LastBrick.X; ++BX)
|
||||
{
|
||||
const FIntVector BrickWorldMin(BX * 8, BY * 8, BZ * 8);
|
||||
const FIntVector BrickWorldMin(
|
||||
BX * ProofBrickSize.X, BY * ProofBrickSize.Y, BZ * ProofBrickSize.Z);
|
||||
FResearchBrick& Brick = Bricks.AddDefaulted_GetRef();
|
||||
Brick.Origin = FIntVector(
|
||||
FMath::Max(OriginVoxels.X, BrickWorldMin.X),
|
||||
FMath::Max(OriginVoxels.Y, BrickWorldMin.Y),
|
||||
FMath::Max(OriginVoxels.Z, BrickWorldMin.Z));
|
||||
const FIntVector BrickEnd = BrickWorldMin + FIntVector(8, 8, 8);
|
||||
const FIntVector BrickEnd = BrickWorldMin + ProofBrickSize;
|
||||
const FIntVector RingEnd = OriginVoxels
|
||||
+ FIntVector(Dimension, Dimension, Dimension);
|
||||
const FIntVector End(
|
||||
@@ -315,28 +318,62 @@ namespace VoxelForgeRegionEval
|
||||
VoxelForgeRedefinedDensityField::BuildParameterizedBrickContext(
|
||||
Generator, Brick.Origin, Brick.Size, ParameterizedBrickContext);
|
||||
}
|
||||
for (int32 Z = 0; Z < Brick.Size.Z; ++Z)
|
||||
for (int32 Y = 0; Y < Brick.Size.Y; ++Y)
|
||||
for (int32 X = 0; X < Brick.Size.X; ++X)
|
||||
if (bParameterized)
|
||||
{
|
||||
const int32 WorldX = Brick.Origin.X + X;
|
||||
const int32 WorldY = Brick.Origin.Y + Y;
|
||||
const int32 WorldZ = Brick.Origin.Z + Z;
|
||||
const int64 LatticeIndex = LinearIndex(
|
||||
Brick.Lattice.X + X, Brick.Lattice.Y + Y,
|
||||
Brick.Lattice.Z + Z, Dimension);
|
||||
const float DetailValue = BrickDetail[
|
||||
(Z * Brick.Size.Y + Y) * Brick.Size.X + X];
|
||||
OutDensities[static_cast<int32>(LatticeIndex)] = bParameterized
|
||||
? VoxelForgeRedefinedDensityField::EvaluateParameterizedWithDetailValue(
|
||||
Generator, static_cast<float>(WorldX), static_cast<float>(WorldY),
|
||||
static_cast<float>(WorldZ), DetailValue, nullptr, DetailScale,
|
||||
&ParameterizedBrickContext)
|
||||
: VoxelForgeRedefinedDensityField::EvaluateWithDetailValue(
|
||||
Generator, static_cast<float>(WorldX), static_cast<float>(WorldY),
|
||||
static_cast<float>(WorldZ), DetailValue,
|
||||
nullptr, DetailScale, &BrickContext);
|
||||
++WorkerEvaluated[WorkerIndex];
|
||||
const int32 DetailStride = Brick.Size.X * Brick.Size.Y;
|
||||
float ColumnValues[8] = {};
|
||||
float ParameterizedBrickValues[8 * 8 * 8];
|
||||
for (int32 Y = 0; Y < Brick.Size.Y; ++Y)
|
||||
for (int32 X = 0; X < Brick.Size.X; ++X)
|
||||
{
|
||||
const int32 DetailBase = Y * Brick.Size.X + X;
|
||||
VoxelForgeRedefinedDensityField::EvaluateParameterizedColumnWithDetailValues(
|
||||
Generator, static_cast<float>(Brick.Origin.X + X),
|
||||
static_cast<float>(Brick.Origin.Y + Y),
|
||||
static_cast<float>(Brick.Origin.Z),
|
||||
BrickDetail.GetData() + DetailBase, DetailStride,
|
||||
Brick.Size.Z, ColumnValues,
|
||||
&ParameterizedBrickContext, DetailScale);
|
||||
for (int32 Z = 0; Z < Brick.Size.Z; ++Z)
|
||||
{
|
||||
ParameterizedBrickValues[(Z * Brick.Size.Y + Y)
|
||||
* Brick.Size.X + X] = ColumnValues[Z];
|
||||
}
|
||||
}
|
||||
for (int32 Z = 0; Z < Brick.Size.Z; ++Z)
|
||||
for (int32 Y = 0; Y < Brick.Size.Y; ++Y)
|
||||
{
|
||||
const int64 LatticeIndex = LinearIndex(
|
||||
Brick.Lattice.X, Brick.Lattice.Y + Y,
|
||||
Brick.Lattice.Z + Z, Dimension);
|
||||
const int32 LocalIndex = (Z * Brick.Size.Y + Y) * Brick.Size.X;
|
||||
FMemory::Memcpy(OutDensities.GetData() + LatticeIndex,
|
||||
ParameterizedBrickValues + LocalIndex,
|
||||
static_cast<SIZE_T>(Brick.Size.X) * sizeof(float));
|
||||
}
|
||||
WorkerEvaluated[WorkerIndex] += static_cast<uint64>(Brick.SampleCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int32 Z = 0; Z < Brick.Size.Z; ++Z)
|
||||
for (int32 Y = 0; Y < Brick.Size.Y; ++Y)
|
||||
for (int32 X = 0; X < Brick.Size.X; ++X)
|
||||
{
|
||||
const int32 WorldX = Brick.Origin.X + X;
|
||||
const int32 WorldY = Brick.Origin.Y + Y;
|
||||
const int32 WorldZ = Brick.Origin.Z + Z;
|
||||
const int64 LatticeIndex = LinearIndex(
|
||||
Brick.Lattice.X + X, Brick.Lattice.Y + Y,
|
||||
Brick.Lattice.Z + Z, Dimension);
|
||||
const float DetailValue = BrickDetail[
|
||||
(Z * Brick.Size.Y + Y) * Brick.Size.X + X];
|
||||
OutDensities[static_cast<int32>(LatticeIndex)] =
|
||||
VoxelForgeRedefinedDensityField::EvaluateWithDetailValue(
|
||||
Generator, static_cast<float>(WorldX), static_cast<float>(WorldY),
|
||||
static_cast<float>(WorldZ), DetailValue,
|
||||
nullptr, DetailScale, &BrickContext);
|
||||
++WorkerEvaluated[WorkerIndex];
|
||||
}
|
||||
}
|
||||
WorkerEvaluate[WorkerIndex] += FPlatformTime::Seconds() - EvaluationStart;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user