fix(core): smooth tunnel entrance floor; verifier keeps baselines out of /tmp (L47); research R14
The demo tunnel's hard floor cap used a vertical Z - floorZ on a sloped Bezier floor, which is not a signed distance, so marching cubes produced a staircase through the first 7 m (40-51 mm ripple, 82 mm steps). The cap now uses the grade-normalised signed distance with a floor-adjacent bore re-application fading over the entrance; mesh tile Z bounds include cavern bounds. New three-rail entrance audit: L46 fails, L47 passes. verify: the cost baseline exports only build inputs into Saved/Linux/<out>/baseline-<commit> and removes it; /tmp unchanged after a full tier. Demo off: owner hashes identical to L46. fast/medium/full PASS. Known: sawtooth at the tunnel wall foot (next round). Research R14: Windows/MSVC readiness review. 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
e016f6a20f
commit
c091e4434f
13 files changed
+839
-27
No files matched your search
@@ -5973,6 +5973,10 @@ private:
|
||||
}
|
||||
const float centerX=bezier(t,0),centerY=bezier(t,1);
|
||||
const float floorZ=bezier(t,2);
|
||||
const float floorHorizontalSpeed=std::hypot(derivative(t,0),derivative(t,1));
|
||||
const float floorGrade=floorHorizontalSpeed>1.0e-5f
|
||||
?derivative(t,2)/floorHorizontalSpeed:0.0f;
|
||||
const float floorDistanceScale=1.0f/std::sqrt(1.0f+floorGrade*floorGrade);
|
||||
const float radial=std::hypot(X-centerX,Y-centerY);
|
||||
const float radius=feature.boreRadiusVoxels;
|
||||
const float vertical=(Z-floorZ)/feature.boreHeightVoxels;
|
||||
@@ -6000,11 +6004,12 @@ private:
|
||||
return;
|
||||
}
|
||||
composed=SmoothMaxDistance(composed,-distance,feature.smoothWidthVoxels);
|
||||
// The hard profile cap is deliberately applied after the smooth union and
|
||||
// relief. Below it, native rock remains untouched; the narrow support above
|
||||
// fills only baseline air.
|
||||
// Apply a signed distance to the sloped floor plane. The old vertical
|
||||
// height field made Marching Cubes quantize the shallow ramp into terraces.
|
||||
// Below it, native rock remains untouched; the narrow support above fills
|
||||
// only baseline air.
|
||||
if(radial<=radius)
|
||||
composed=std::min(composed,Z-floorZ);
|
||||
composed=std::min(composed,(Z-floorZ)*floorDistanceScale);
|
||||
};
|
||||
if(scoped)
|
||||
for(const auto index:tileQueries->cavernFeatureCandidates())apply(index);
|
||||
@@ -6097,12 +6102,17 @@ private:
|
||||
t=std::clamp(t-(dx*vx+dy*vy)/denominator,0.0f,1.0f);
|
||||
}
|
||||
const float floorZ=bezier(t,2);
|
||||
const float floorHorizontalSpeed=std::hypot(derivative(t,0),derivative(t,1));
|
||||
const float floorGrade=floorHorizontalSpeed>1.0e-5f
|
||||
?derivative(t,2)/floorHorizontalSpeed:0.0f;
|
||||
const float floorDistanceScale=1.0f/std::sqrt(1.0f+floorGrade*floorGrade);
|
||||
const float radial=std::hypot(X-bezier(t,0),Y-bezier(t,1));
|
||||
if(Z<floorZ)
|
||||
const float floorDistance=(Z-floorZ)*floorDistanceScale;
|
||||
const float floorSdfBand=std::max(1.0f,feature.floorSupportDepthVoxels);
|
||||
if(Z<floorZ-floorSdfBand)
|
||||
{
|
||||
// Re-evaluate the narrow fallback after passages and stamps, since
|
||||
// those later operations may open air beneath an otherwise native
|
||||
// floor. Negative native density is preserved by the min operation.
|
||||
// Preserve the existing narrow support outside the signed-distance
|
||||
// band beneath the floor.
|
||||
if(capped>0.0f&&feature.floorSupportDepthVoxels>0.0f
|
||||
&&Z>=floorZ-feature.floorSupportDepthVoxels
|
||||
&&radial<feature.boreRadiusVoxels-0.12f)
|
||||
@@ -6114,8 +6124,36 @@ private:
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(radial<=feature.boreRadiusVoxels&&Z<=floorZ+0.8f)
|
||||
{
|
||||
const float vertical=(Z-floorZ)/feature.boreHeightVoxels;
|
||||
const float normalized=std::sqrt((radial/feature.boreRadiusVoxels)
|
||||
*(radial/feature.boreRadiusVoxels)+vertical*vertical);
|
||||
float tunnelDistance=(normalized-1.0f)*std::min(
|
||||
feature.boreRadiusVoxels,feature.boreHeightVoxels);
|
||||
if(feature.irregularityAmplitudeVoxels>0.0f)
|
||||
{
|
||||
const float fade=SmoothUnit((Z-floorZ)/0.8f);
|
||||
tunnelDistance+=StampValueNoise(
|
||||
X-feature.controlPointsVoxels[0][0],
|
||||
Y-feature.controlPointsVoxels[0][1],Z-floorZ,
|
||||
feature.irregularityWavelengthVoxels,feature.irregularitySeed)
|
||||
*feature.irregularityAmplitudeVoxels*fade;
|
||||
}
|
||||
// Reapply the tunnel SDF in the floor-adjacent strip. Keep a narrow
|
||||
// correction along the ramp, with a wider fade only at the stamped mouth.
|
||||
const float heightAboveFloor=Z-floorZ;
|
||||
const float mouthFade=1.0f-SmoothUnit(t/0.10f);
|
||||
const float recarveWeight=heightAboveFloor<=0.25f?1.0f:mouthFade;
|
||||
if(recarveWeight>0.0f)
|
||||
{
|
||||
const float recarved=SmoothMaxDistance(capped,-tunnelDistance,
|
||||
feature.smoothWidthVoxels);
|
||||
capped=std::lerp(capped,recarved,recarveWeight);
|
||||
}
|
||||
}
|
||||
if(radial<=feature.boreRadiusVoxels)
|
||||
capped=std::min(capped,Z-floorZ);
|
||||
capped=std::min(capped,floorDistance);
|
||||
};
|
||||
if(scoped)
|
||||
for(const auto index:tileQueries->cavernFeatureCandidates())apply(index);
|
||||
|
||||
Reference in new issue
Block a user