Files
VoxelForge/Source/VoxelForge/Public/VoxelRedefinedDensityField.h
T
Fr0zkaandClaude Opus 5.5 bc0f9ee791 wip(step3): 12.5 cm voxels, fall-through fixed, brick evaluator in game, organic tunnels -- speed gate FAILS
Stopped by the owner's decision (in-game lit captures were eating the round); he judges the look in
game instead.
1. Fall-through with the research field: fixed. Deep drop, gate on: 2 holds (0.50 s), min foot
   clearance +43 cm; gate off: penetrates (-278 cm). Stress fixture offsets converted to metres.
2. VOXEL_SIZE 25 -> 12.5 cm. Physical sizes kept in metres (player, steps, gate, insets, research
   field sizes, dig radii, test thresholds); class defaults that count chunks/voxels doubled
   (ClipRadius 6, RenderDistanceChunks 1536, ViewDistance*, StrateViewMargin 6,
   PawnCollisionRadius 2, SkirtCells 4, EdgeSealThickness 128, decoration spacings, density volume
   res 256). Asset values override these defaults: the owner must double his own.
   Ring scale, six workers, idle, step-2f field before the look changes: 64 m cube (519^3) 4.55 s;
   32 m cube (259^3) 0.95 s.
3. In game: tiles go through the brick evaluator (proved by a log marker); profile switch rebuilds
   the loaded world (~5,800 tiles); full-detail fill 12.4 s after spawn in the visible-window test.
4. Look: round winding tunnels, per-column ellipsoid/lattice caches. All step-2f geometry gates pass
   at 12.5 cm (0 crumbs, 1 solid component per profile, solid share 69-87%). 259^3 ring, six workers:
   1.08-2.02 s (worst HyperComplex) -- the 600 ms gate FAILS. Lit captures failed (hidden/off-screen
   window, then blank frames); not pursued.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
2026-10-01 21:21:45 +02:00

196 lines
8.9 KiB
C++

#pragma once
#include "CoreMinimal.h"
#include "VoxelTypes.h"
class UVoxelGenerator;
#if WITH_EDITOR
/**
* Step 2d editor research field. It is intentionally separate from the gameplay evaluator and
* is selected only by the default-off voxel.ResearchRedefinedDensityField console variable.
*
* The field is a connected, archetype-sized cave lattice with an authored walkable floor at each
* passage landing. Its macro shape is evaluated directly in world space; bounded, continuous
* hash-value noise is added at every full-resolution sample. The brick classifier is permitted to
* skip only when a Lipschitz bound on the macro field plus the exact maximum detail amplitude
* proves that the final sign is uniform throughout the brick and its marching-cubes halo.
*/
namespace VoxelForgeRedefinedDensityField
{
/** Proof sample width shared by the research mesher and the region-evaluation harness. */
constexpr int32 ParameterizedBrickSamples = 4;
/** Uniform fill magnitude used after a 16 metre sign proof. */
constexpr float ParameterizedUniformDensity = 16.0f * 100.0f / VOXEL_SIZE;
/** Per-worker, per-brick state. The opaque plan pointer is valid until the layout changes. */
struct FBrickEvaluationContext
{
const void* PlanToken = nullptr;
bool bPlanResolved = false;
bool bMayContainPassage = true;
bool bChunkResolved = false;
bool bIsGapChunk = false;
bool bHasDiffMods = false;
bool bMacroXYPrecomputed = false;
FIntVector BrickOrigin = FIntVector::ZeroValue;
FIntVector BrickSize = FIntVector::ZeroValue;
FIntVector Chunk = FIntVector::ZeroValue;
TArray<float> FloorByXY;
TArray<float> GridAirByXY;
TArray<float> DetailFadeByXY;
TArray<float> LandingHorizontalByXY;
TArray<float> LandingApproachByXY;
TArray<float> LandingBridgeHorizontalByXY;
TArray<float> LandingBridgeFloorByXY;
TArray<int32> PassageCandidates;
};
/** Cell-level controls for the separate editor-only parameterized cave field. */
struct FGenerationParameters
{
float RoomPitchVoxels = 144.0f;
float MinimumRoomRadiusFraction = 0.30f;
float MaximumRoomRadiusFraction = 0.45f;
float RoomHeightVoxels = 192.0f;
float FloorReliefVoxels = 8.0f;
float TunnelRadiusVoxels = 28.0f;
float TunnelHalfHeightVoxels = 26.0f;
float LoopProbability = 0.20f;
float VerticalShaftProbability = 0.10f;
float ShaftRadiusVoxels = 18.0f;
float PillarProbability = 0.10f;
float LedgeProbability = 0.20f;
float FloatingMassProbability = 0.10f;
float SpireProbability = 0.25f;
float BasinProbability = 0.0f;
float BasinDepthVoxels = 0.0f;
float WaterLevelFraction = 0.5f;
};
/** Brick-local immutable room cells used by step 2e evaluation and its final-field proof. */
struct FParameterizedBrickContext
{
const void* PlanToken = nullptr;
const void* RoomCellCacheToken = nullptr;
bool bPlanResolved = false;
bool bChunkResolved = false;
bool bIsGapChunk = false;
bool bHasDiffMods = false;
bool bMayContainPassage = true;
FIntVector BrickOrigin = FIntVector::ZeroValue;
FIntVector BrickSize = FIntVector::ZeroValue;
FIntVector Chunk = FIntVector::ZeroValue;
FIntPoint RoomCellCacheMin = FIntPoint::ZeroValue;
FIntPoint RoomCellCacheSize = FIntPoint::ZeroValue;
TArray<int32> PassageCandidates;
};
enum class EBrickFallbackReason : uint8
{
None,
UnsupportedState,
ChunkOrStrateBoundary,
PassageBounds,
MixedMacroInterval
};
struct FBrickCounters
{
uint64 Tested = 0;
uint64 Skipped = 0;
uint64 EvaluatedSamples = 0;
};
VOXELFORGE_API bool IsEnabled();
VOXELFORGE_API void SetEnabled(bool bEnabled);
VOXELFORGE_API float GetDetailScale();
VOXELFORGE_API void SetDetailScale(float Scale);
/** The parameterized cave field is editor-only and default-off. -1 rolls per strate. */
VOXELFORGE_API bool IsParameterizedEnabled();
VOXELFORGE_API void SetParameterizedEnabled(bool bEnabled);
/** Select the frozen step 2e implementation while the step 2f audit measures its gates. */
VOXELFORGE_API void SetLegacyStep2eAuditMode(bool bEnabled);
VOXELFORGE_API void SetParameterSet(int32 ParameterSet);
VOXELFORGE_API int32 GetParameterSet();
VOXELFORGE_API int32 GetParameterSetCount();
VOXELFORGE_API bool GetParameterSetInfo(
int32 ParameterSet, const TCHAR*& OutName, FGenerationParameters& OutParameters);
/** Evaluate the separate parameterized room / tunnel network, including edits/passages. */
VOXELFORGE_API float EvaluateParameterized(
const UVoxelGenerator& Generator, float WorldX, float WorldY, float WorldZ,
float* OutPreEditDensity = nullptr, float DetailScale = 1.0f);
/** Evaluate only the parameterized room/tunnel macro, before passage overlays and seals. */
VOXELFORGE_API float EvaluateParameterizedMacroOnly(
const UVoxelGenerator& Generator, float WorldX, float WorldY, float WorldZ);
/** Describe the candidate room SDF values at a point for step 2f proof diagnosis. */
VOXELFORGE_API FString DescribeParameterizedMacroAt(
const UVoxelGenerator& Generator, float WorldX, float WorldY, float WorldZ);
/** Return the active parameterized detail signal for the band-limit research gate. */
VOXELFORGE_API float EvaluateParameterizedDetail(
const UVoxelGenerator& Generator, float WorldX, float WorldY, float WorldZ);
VOXELFORGE_API float EvaluateParameterizedWithDetailValue(
const UVoxelGenerator& Generator, float WorldX, float WorldY, float WorldZ,
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,
int32 SampleStep = 1);
VOXELFORGE_API bool TryClassifyParameterizedBrick(
const UVoxelGenerator& Generator, FIntVector OriginVoxels, FIntVector Size,
bool& bOutAir, float DetailScale = 1.0f,
bool* bOutEvaluatedMacroCentre = nullptr,
EBrickFallbackReason* OutFallbackReason = nullptr,
int32 SampleStep = 1);
VOXELFORGE_API void BuildParameterizedBrickContext(
const UVoxelGenerator& Generator, FIntVector OriginVoxels, FIntVector Size,
FParameterizedBrickContext& OutContext, int32 SampleStep = 1);
/** Evaluate a mixed brick with one shared room/passage setup for all Z samples. */
VOXELFORGE_API void EvaluateParameterizedDensityBrick(
const UVoxelGenerator& Generator, FIntVector OriginVoxels, FIntVector Size,
float DetailScale, FParameterizedBrickContext& InOutContext,
TArray<float>& InOutDetail, TArray<float>& InOutColumnValues,
TArray<float>& OutValues, int32 SampleStep = 1);
/** Evaluate the new field, including existing passage carving and player diffs. */
VOXELFORGE_API float Evaluate(const UVoxelGenerator& Generator, float WorldX, float WorldY,
float WorldZ, float* OutPreEditDensity = nullptr,
float DetailScale = 1.0f);
/** Build mathematically identical multi-scale noise for one integer-lattice brick. */
VOXELFORGE_API void BuildDetailBrick(const UVoxelGenerator& Generator,
FIntVector OriginVoxels, FIntVector Size, float DetailScale,
TArray<float>& OutDetail, FBrickEvaluationContext* OutContext = nullptr,
bool bParameterized = false, int32 SampleStep = 1);
/** Evaluate with a detail value produced by BuildDetailBrick. */
VOXELFORGE_API float EvaluateWithDetailValue(const UVoxelGenerator& Generator,
float WorldX, float WorldY, float WorldZ, float DetailValue,
float* OutPreEditDensity = nullptr, float DetailScale = 1.0f,
const FBrickEvaluationContext* Context = nullptr);
/** Prove a world-aligned box has one final density sign; false means evaluate every point. */
VOXELFORGE_API bool TryClassifyBrick(
const UVoxelGenerator& Generator, FIntVector OriginVoxels, FIntVector Size,
bool& bOutAir, float DetailScale = 1.0f,
bool* bOutEvaluatedMacroCentre = nullptr,
EBrickFallbackReason* OutFallbackReason = nullptr);
/** Reset this thread's immutable plan cache; used by deterministic editor experiments. */
VOXELFORGE_API void ResetThreadCache();
}
#endif