feat(core): slab + sparse motifs, slice 1 -- flat field, monolith, platform at 0.52 s (L56); research R25
Motif vocabulary v3: version-1 records keyed by (seed, strate, stable ID) with route keepouts, band clearance and pairwise spacing. A rounded capped-cylinder monolith (r 1.4 m, 24 m tall) and a rounded-box plinth, smooth-unioned into a flatField floor with a 0.55 m geometric rounding (measured fillets 0.73-1.17 m). Exact radial/box interval bounds, a BVH, isTileShapeFree aware (0 brute-force misses, false-proof controls rejected). Final-field route passes; whole-surface audit covers foot, cap and platform edges. Cold whole view 0.524 s. Owner world unchanged. fast/medium/full PASS (Clang and GCC). Research R25 (self-checked): FloatingIslands LOD0 column cache conflicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
This commit is contained in:
1 parent
aee1487410
commit
4e64b75044
15 files changed
+1560
-12
No files matched your search
@@ -3281,6 +3281,7 @@ private:
|
||||
float smoothWidthVoxels=0.0f;
|
||||
float irregularityAmplitudeVoxels=0.0f;
|
||||
float irregularityWavelengthVoxels=0.0f;
|
||||
float roundingRadiusVoxels=0.0f;
|
||||
std::uint64_t irregularitySeed=0;
|
||||
std::uint8_t quarterTurns=0;
|
||||
};
|
||||
@@ -3452,6 +3453,9 @@ private:
|
||||
runtime.irregularityWavelengthVoxels=static_cast<float>(
|
||||
static_cast<double>(stamp.irregularityWavelengthMicrometres)
|
||||
/Owner->CoreVoxelSizeMicrons);
|
||||
runtime.roundingRadiusVoxels=static_cast<float>(
|
||||
static_cast<double>(stamp.roundingRadiusMicrometres)
|
||||
/Owner->CoreVoxelSizeMicrons);
|
||||
runtime.irregularitySeed=stamp.irregularitySeed;
|
||||
runtime.quarterTurns=stamp.yawQuarterTurns;
|
||||
StampRuntime.push_back(runtime);
|
||||
@@ -5370,6 +5374,7 @@ public:
|
||||
else ++Counts.MixedBoxes;
|
||||
return Result;
|
||||
};
|
||||
std::vector<std::uint32_t> stampCandidates;
|
||||
if(!StampSpatialBounds.empty())
|
||||
{
|
||||
constexpr std::int64_t Q=VoxelForgeCore::WorldAssemblySubvoxelsPerVoxel;
|
||||
@@ -5381,8 +5386,18 @@ public:
|
||||
static_cast<std::int64_t>(BMax[0])*Q,
|
||||
static_cast<std::int64_t>(BMax[1])*Q,
|
||||
static_cast<std::int64_t>(BMax[2])*Q};
|
||||
if(!BuildStampTileList(minimum,maximum).empty())
|
||||
return Finish(EVoxelTileClass::Mixed,true);
|
||||
stampCandidates=BuildStampTileList(minimum,maximum);
|
||||
for(const std::uint32_t index:stampCandidates)
|
||||
{
|
||||
if(index>=StampRuntime.size())return Finish(EVoxelTileClass::Mixed,true);
|
||||
const auto& stamp=StampRuntime[index];
|
||||
if(!stamp.record||(stamp.record->kind
|
||||
!=VoxelForgeCore::ResolvedSdfStampKindV1::fillMonolith
|
||||
&&stamp.record->kind
|
||||
!=VoxelForgeCore::ResolvedSdfStampKindV1::fillPlatform)
|
||||
||!SurfacePlan||stamp.record->strateIndex!=SurfacePlan->strateIndex)
|
||||
return Finish(EVoxelTileClass::Mixed,true);
|
||||
}
|
||||
}
|
||||
if(!CavernRuntime.empty())
|
||||
{
|
||||
@@ -5471,6 +5486,44 @@ public:
|
||||
{
|
||||
if(!WorldAssembly||!SurfacePlan||!SurfaceField)
|
||||
return Finish(EVoxelTileClass::Mixed,true);
|
||||
if(!stampCandidates.empty())
|
||||
{
|
||||
constexpr std::int64_t Scale=VoxelForgeCore::WorldAssemblySubvoxelsPerVoxel;
|
||||
const auto interval=SurfaceField->Evaluator.interval(
|
||||
static_cast<std::int64_t>(BMin[0])*Scale,
|
||||
static_cast<std::int64_t>(BMin[1])*Scale,
|
||||
static_cast<std::int64_t>(BMin[2])*Scale,
|
||||
static_cast<std::int64_t>(BMax[0])*Scale,
|
||||
static_cast<std::int64_t>(BMax[1])*Scale,
|
||||
static_cast<std::int64_t>(BMax[2])*Scale);
|
||||
if(!interval.known||interval.minimumDensitySubvoxels
|
||||
>interval.maximumDensitySubvoxels)
|
||||
return Finish(EVoxelTileClass::Mixed,true);
|
||||
FMetricInterval composed{
|
||||
static_cast<double>(interval.minimumDensitySubvoxels)/Scale,
|
||||
static_cast<double>(interval.maximumDensitySubvoxels)/Scale,true};
|
||||
for(const std::uint32_t index:stampCandidates)
|
||||
{
|
||||
const auto& stamp=StampRuntime[index];
|
||||
const auto feature=StampDistanceInterval(stamp,BMin,BMax);
|
||||
if(!feature.known)return Finish(EVoxelTileClass::Mixed,true);
|
||||
composed.minimum=SmoothMinDistance(static_cast<float>(composed.minimum),
|
||||
static_cast<float>(feature.minimum),stamp.smoothWidthVoxels);
|
||||
composed.maximum=SmoothMinDistance(static_cast<float>(composed.maximum),
|
||||
static_cast<float>(feature.maximum),stamp.smoothWidthVoxels);
|
||||
}
|
||||
constexpr double outwardPadding=2.0e-5;
|
||||
composed.minimum=std::nextafter(composed.minimum-outwardPadding,
|
||||
-std::numeric_limits<double>::infinity());
|
||||
composed.maximum=std::nextafter(composed.maximum+outwardPadding,
|
||||
std::numeric_limits<double>::infinity());
|
||||
if(!std::isfinite(composed.minimum)||!std::isfinite(composed.maximum)
|
||||
||composed.minimum>composed.maximum)
|
||||
return Finish(EVoxelTileClass::Mixed,true);
|
||||
if(composed.minimum>=0.0)return Finish(EVoxelTileClass::AllAir);
|
||||
if(composed.maximum<0.0)return Finish(EVoxelTileClass::AllSolid);
|
||||
return Finish(EVoxelTileClass::Mixed);
|
||||
}
|
||||
// classifyLatticeBox takes the exact extrema of ground/cap columns at every
|
||||
// MC lattice XY in this box. Since density is min(z-ground, cap-z), those extrema
|
||||
// bound every lattice sample in Z without a noise amplitude guess.
|
||||
@@ -6503,6 +6556,19 @@ private:
|
||||
+std::max(vertical,0.0f)*std::max(vertical,0.0f));
|
||||
return outside+std::min(std::max(radial,vertical),0.0f);
|
||||
}
|
||||
static float StampRoundedCappedCylinderSdf(float x,float y,float z,
|
||||
const std::array<float,3>& halfSize,float rounding)
|
||||
{
|
||||
const float radius=halfSize[0];
|
||||
if(!(radius>0.0f&&halfSize[0]==halfSize[1]&&halfSize[2]>0.0f)
|
||||
||rounding<0.0f||rounding>std::min(radius,halfSize[2]))
|
||||
return std::numeric_limits<float>::infinity();
|
||||
const float radial=std::sqrt(x*x+y*y)-(radius-rounding);
|
||||
const float vertical=std::abs(z)-(halfSize[2]-rounding);
|
||||
const float outside=std::sqrt(std::max(radial,0.0f)*std::max(radial,0.0f)
|
||||
+std::max(vertical,0.0f)*std::max(vertical,0.0f));
|
||||
return outside+std::min(std::max(radial,vertical),0.0f)-rounding;
|
||||
}
|
||||
static float StampArchSdf(float x,float y,float z,
|
||||
const std::array<float,3>& halfSize)
|
||||
{
|
||||
@@ -6533,6 +6599,12 @@ private:
|
||||
distance=StampArchSdf(localX,localY,localZ,stamp.halfExtentsVoxels);break;
|
||||
case VoxelForgeCore::ResolvedSdfStampKindV1::fillPillar:
|
||||
distance=StampPillarSdf(localX,localY,localZ,stamp.halfExtentsVoxels);break;
|
||||
case VoxelForgeCore::ResolvedSdfStampKindV1::fillMonolith:
|
||||
distance=StampRoundedCappedCylinderSdf(localX,localY,localZ,
|
||||
stamp.halfExtentsVoxels,stamp.roundingRadiusVoxels);break;
|
||||
case VoxelForgeCore::ResolvedSdfStampKindV1::fillPlatform:
|
||||
distance=StampRoundedBoxSdf(localX,localY,localZ,
|
||||
stamp.halfExtentsVoxels,stamp.roundingRadiusVoxels);break;
|
||||
case VoxelForgeCore::ResolvedSdfStampKindV1::fillDais:
|
||||
if(ResolvedLayout&&ResolvedLayout->stampVocabularyVersion
|
||||
>=VoxelForgeCore::ResolvedLayoutStampVocabularyVersionV2)
|
||||
@@ -6550,6 +6622,93 @@ private:
|
||||
*stamp.irregularityAmplitudeVoxels;
|
||||
return distance;
|
||||
}
|
||||
|
||||
static double StampAbsMinimum(double minimum,double maximum)
|
||||
{return minimum<=0.0&&maximum>=0.0?0.0:std::min(std::abs(minimum),std::abs(maximum));}
|
||||
static double StampRoundedBoxSdfDouble(const std::array<double,3>& absolute,
|
||||
const std::array<double,3>& halfSize,double rounding)
|
||||
{
|
||||
const double qx=absolute[0]-halfSize[0]+rounding;
|
||||
const double qy=absolute[1]-halfSize[1]+rounding;
|
||||
const double qz=absolute[2]-halfSize[2]+rounding;
|
||||
const double outside=std::sqrt(std::max(qx,0.0)*std::max(qx,0.0)
|
||||
+std::max(qy,0.0)*std::max(qy,0.0)
|
||||
+std::max(qz,0.0)*std::max(qz,0.0));
|
||||
return outside+std::min(std::max({qx,qy,qz}),0.0)-rounding;
|
||||
}
|
||||
FMetricInterval StampDistanceInterval(const FStampRuntime& stamp,
|
||||
const int32 bMin[3],const int32 bMax[3]) const
|
||||
{
|
||||
if(!stamp.record||(stamp.record->kind
|
||||
!=VoxelForgeCore::ResolvedSdfStampKindV1::fillMonolith
|
||||
&&stamp.record->kind!=VoxelForgeCore::ResolvedSdfStampKindV1::fillPlatform))
|
||||
return {0.0,0.0,false};
|
||||
std::array<double,3> localMinimum{},localMaximum{};
|
||||
const std::array<double,3> center={stamp.positionVoxels[0],
|
||||
stamp.positionVoxels[1],stamp.positionVoxels[2]};
|
||||
const auto axisRange=[&](std::size_t axis)
|
||||
{
|
||||
return std::array<double,2>{static_cast<double>(bMin[axis]),
|
||||
static_cast<double>(bMax[axis])};
|
||||
};
|
||||
const auto xRange=axisRange(0),yRange=axisRange(1),zRange=axisRange(2);
|
||||
switch(stamp.quarterTurns&3u)
|
||||
{
|
||||
case 1:
|
||||
localMinimum={yRange[0]-center[1],center[0]-xRange[1],zRange[0]-center[2]};
|
||||
localMaximum={yRange[1]-center[1],center[0]-xRange[0],zRange[1]-center[2]};
|
||||
break;
|
||||
case 2:
|
||||
localMinimum={center[0]-xRange[1],center[1]-yRange[1],zRange[0]-center[2]};
|
||||
localMaximum={center[0]-xRange[0],center[1]-yRange[0],zRange[1]-center[2]};
|
||||
break;
|
||||
case 3:
|
||||
localMinimum={center[1]-yRange[1],xRange[0]-center[0],zRange[0]-center[2]};
|
||||
localMaximum={center[1]-yRange[0],xRange[1]-center[0],zRange[1]-center[2]};
|
||||
break;
|
||||
default:
|
||||
localMinimum={xRange[0]-center[0],yRange[0]-center[1],zRange[0]-center[2]};
|
||||
localMaximum={xRange[1]-center[0],yRange[1]-center[1],zRange[1]-center[2]};
|
||||
break;
|
||||
}
|
||||
std::array<double,3> absoluteMinimum{},absoluteMaximum{};
|
||||
for(std::size_t axis=0;axis<3;++axis)
|
||||
{
|
||||
absoluteMinimum[axis]=StampAbsMinimum(localMinimum[axis],localMaximum[axis]);
|
||||
absoluteMaximum[axis]=std::max(std::abs(localMinimum[axis]),
|
||||
std::abs(localMaximum[axis]));
|
||||
}
|
||||
double minimum=0.0,maximum=0.0;
|
||||
if(stamp.record->kind==VoxelForgeCore::ResolvedSdfStampKindV1::fillMonolith)
|
||||
{
|
||||
const double radialMinimum=std::hypot(absoluteMinimum[0],absoluteMinimum[1]);
|
||||
const double radialMaximum=std::hypot(absoluteMaximum[0],absoluteMaximum[1]);
|
||||
const double round=stamp.roundingRadiusVoxels;
|
||||
const double side=stamp.halfExtentsVoxels[0]-round;
|
||||
const double cap=stamp.halfExtentsVoxels[2]-round;
|
||||
const auto eval=[&](double radial,double vertical)
|
||||
{
|
||||
const double qr=radial-side,qz=vertical-cap;
|
||||
return std::hypot(std::max(qr,0.0),std::max(qz,0.0))
|
||||
+std::min(std::max(qr,qz),0.0)-round;
|
||||
};
|
||||
minimum=eval(radialMinimum,absoluteMinimum[2]);
|
||||
maximum=eval(radialMaximum,absoluteMaximum[2]);
|
||||
}
|
||||
else if(stamp.record->kind==VoxelForgeCore::ResolvedSdfStampKindV1::fillPlatform)
|
||||
{
|
||||
const std::array<double,3> half={stamp.halfExtentsVoxels[0],
|
||||
stamp.halfExtentsVoxels[1],stamp.halfExtentsVoxels[2]};
|
||||
minimum=StampRoundedBoxSdfDouble(absoluteMinimum,half,stamp.roundingRadiusVoxels);
|
||||
maximum=StampRoundedBoxSdfDouble(absoluteMaximum,half,stamp.roundingRadiusVoxels);
|
||||
}
|
||||
else return {0.0,0.0,false};
|
||||
constexpr double outwardPadding=2.0e-5;
|
||||
return {std::nextafter(minimum-outwardPadding,
|
||||
-std::numeric_limits<double>::infinity()),
|
||||
std::nextafter(maximum+outwardPadding,
|
||||
std::numeric_limits<double>::infinity()),true};
|
||||
}
|
||||
float ApplyResolvedSdfStamps(float density,float X,float Y,float Z) const
|
||||
{
|
||||
if(StampRuntime.empty()||!Owner||Owner->CoreVoxelSizeMicrons==0)return density;
|
||||
|
||||
Reference in new issue
Block a user