core: A/A noise floor (±1%) and small hot-path trims for the cave planner (L137, output = v236)

Identical builds differ <=0.6% median; residual near-ready vs assembler/world is real: Surface World +2.9..+3.6%,
Vertical Shafts +4.0..+4.3%, Tunnel Network -3.6/+6.8%. Profile points at column-cache reads and the sweep lookup.
Removed an unused sample field and per-lookup shared_ptr refcounting. 16/16 seeds, fast tier, Clang/GCC green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016dhxM43dnWvUu2B5Ph1iG1
This commit is contained in:
Fr0zkaandClaude Opus 5.5 committed 2026-11-01 03:22:55 +01:00
1 parent 08cc3bd89b
commit 05e78331fe
9 files changed
+786 -24

No files matched your search

+63 -24
View File
@@ -255,7 +255,6 @@ public:
{
double signedDistance=std::numeric_limits<double>::infinity();
double shellSignedDistance=std::numeric_limits<double>::infinity();
double floorShellSignedDistance=std::numeric_limits<double>::infinity();
double roundSignedDistance=std::numeric_limits<double>::infinity();
double centerZSubvoxels=0.0,floorCenterZSubvoxels=0.0;
double radiusSubvoxels=0.0,floorDepthSubvoxels=0.0;
@@ -379,7 +378,37 @@ public:
bool hasSweptTubeBase() const noexcept{return passageSweepData_!=nullptr;}
void copySweptTubeRuntimeCounts() const noexcept
{
if(!ownsPassageSweepDiagnostics_||!profileStats_||!passageSweepData_)return;
if(!profileStats_||!passageSweepData_)return;
const auto merge=[&](std::atomic<std::uint64_t>& target,
std::uint64_t value)
{
if(value)target.fetch_add(value,std::memory_order_relaxed);
};
merge(passageSweepData_->lookups,localSweepLookups_);
merge(passageSweepData_->cacheHits,localSweepCacheHits_);
merge(passageSweepData_->baseInfluenceHits,localSweepBaseInfluenceHits_);
merge(passageSweepData_->outOfInfluenceHits,localSweepOutOfInfluenceHits_);
merge(passageSweepData_->missingSamples,localSweepMissingSamples_);
merge(passageSweepData_->offGridMisses,localSweepOffGridMisses_);
merge(passageSweepData_->unpreparedMisses,localSweepUnpreparedMisses_);
for(std::size_t caller=0;caller<PassageDensityQueryCallerCount;++caller)
{
merge(passageSweepData_->missingLookupsByCaller[caller],
localMissingLookupsByCaller_[caller]);
merge(passageSweepData_->exactRouteFallbacksByCaller[caller],
localExactRouteFallbacksByCaller_[caller]);
merge(passageSweepData_->featureBoundSkipsByCaller[caller],
localFeatureBoundSkipsByCaller_[caller]);
merge(passageSweepData_->tileFreeSkipsByCaller[caller],
localTileFreeSkipsByCaller_[caller]);
merge(passageSweepData_->verticalBoundSkipsByCaller[caller],
localVerticalBoundSkipsByCaller_[caller]);
merge(passageSweepData_->negativeReachSkipsByCaller[caller],
localNegativeReachSkipsByCaller_[caller]);
merge(passageSweepData_->positiveReachSkipsByCaller[caller],
localPositiveReachSkipsByCaller_[caller]);
}
if(!ownsPassageSweepDiagnostics_)return;
profileStats_->passageSweepLookups=passageSweepData_->lookups.load(
std::memory_order_relaxed);
profileStats_->passageSweepCacheHits=passageSweepData_->cacheHits.load(
@@ -425,8 +454,7 @@ public:
const auto caller=static_cast<std::size_t>(
FStandaloneShapeWorld::CurrentPassageDensityQueryCaller());
if(caller<PassageDensityQueryCallerCount)
passageSweepData_->exactRouteFallbacksByCaller[caller].fetch_add(
1,std::memory_order_relaxed);
++localExactRouteFallbacksByCaller_[caller];
}
void recordFeatureBoundSkip() const noexcept
{
@@ -434,8 +462,7 @@ public:
const auto caller=static_cast<std::size_t>(
FStandaloneShapeWorld::CurrentPassageDensityQueryCaller());
if(caller<PassageDensityQueryCallerCount)
passageSweepData_->featureBoundSkipsByCaller[caller].fetch_add(
1,std::memory_order_relaxed);
++localFeatureBoundSkipsByCaller_[caller];
}
enum class ESweepMissSkipReason : std::uint8_t
{TileFree,VerticalBound,NegativeReach,PositiveReach};
@@ -445,19 +472,17 @@ public:
const auto caller=static_cast<std::size_t>(
FStandaloneShapeWorld::CurrentPassageDensityQueryCaller());
if(caller>=PassageDensityQueryCallerCount)return;
std::atomic<std::uint64_t>* counts=nullptr;
switch(reason)
{
case ESweepMissSkipReason::TileFree:
counts=&passageSweepData_->tileFreeSkipsByCaller[caller];break;
++localTileFreeSkipsByCaller_[caller];break;
case ESweepMissSkipReason::VerticalBound:
counts=&passageSweepData_->verticalBoundSkipsByCaller[caller];break;
++localVerticalBoundSkipsByCaller_[caller];break;
case ESweepMissSkipReason::NegativeReach:
counts=&passageSweepData_->negativeReachSkipsByCaller[caller];break;
++localNegativeReachSkipsByCaller_[caller];break;
case ESweepMissSkipReason::PositiveReach:
counts=&passageSweepData_->positiveReachSkipsByCaller[caller];break;
++localPositiveReachSkipsByCaller_[caller];break;
}
if(counts)counts->fetch_add(1,std::memory_order_relaxed);
}
static const FScopedPassageTileQueries* CurrentFor(
const FStandaloneShapeWorld& shape)
@@ -518,6 +543,15 @@ public:
double passageCarveReachMetres_=0.0;
std::shared_ptr<FPassageTileSweepData> passageSweepData_;
bool ownsPassageSweepDiagnostics_=true;
mutable std::uint64_t localSweepLookups_=0,localSweepCacheHits_=0,
localSweepBaseInfluenceHits_=0,localSweepOutOfInfluenceHits_=0,
localSweepMissingSamples_=0,localSweepOffGridMisses_=0,
localSweepUnpreparedMisses_=0;
mutable std::array<std::uint64_t,PassageDensityQueryCallerCount>
localMissingLookupsByCaller_{},localExactRouteFallbacksByCaller_{},
localFeatureBoundSkipsByCaller_{},localTileFreeSkipsByCaller_{},
localVerticalBoundSkipsByCaller_{},localNegativeReachSkipsByCaller_{},
localPositiveReachSkipsByCaller_{};
};
double GetCoreVoxelSizeCm() const
@@ -12401,28 +12435,30 @@ inline const FStandaloneShapeWorld::FScopedPassageTileQueries::FPassageSweepSamp
FStandaloneShapeWorld::FScopedPassageTileQueries::sweptSample(
std::size_t passageIndex,double qx,double qy,double qz) const
{
const auto sweep=passageSweepData_;
// This scope retains the sweep through the full query; avoid a shared_ptr
// refcount operation for every sample lookup.
auto* sweep=passageSweepData_.get();
if(!sweep)return nullptr;
sweep->lookups.fetch_add(1,std::memory_order_relaxed);
if(profileStats_)++localSweepLookups_;
const auto recordMissing=[&]()
{
sweep->missingSamples.fetch_add(1,std::memory_order_relaxed);
if(profileStats_)++localSweepMissingSamples_;
if(!profileStats_)return;
const auto caller=static_cast<std::size_t>(
FStandaloneShapeWorld::CurrentPassageDensityQueryCaller());
if(caller<PassageDensityQueryCallerCount)
sweep->missingLookupsByCaller[caller].fetch_add(1,std::memory_order_relaxed);
++localMissingLookupsByCaller_[caller];
};
if(passageIndex>=sweep->passageToSweep.size())
{
sweep->unpreparedMisses.fetch_add(1,std::memory_order_relaxed);
if(profileStats_)++localSweepUnpreparedMisses_;
recordMissing();
return nullptr;
}
const std::int32_t passageSweepIndex=sweep->passageToSweep[passageIndex];
if(passageSweepIndex<0||static_cast<std::size_t>(passageSweepIndex)>=sweep->passages.size())
{
sweep->unpreparedMisses.fetch_add(1,std::memory_order_relaxed);
if(profileStats_)++localSweepUnpreparedMisses_;
recordMissing();
return nullptr;
}
@@ -12436,7 +12472,7 @@ FStandaloneShapeWorld::FScopedPassageTileQueries::sweptSample(
if(rounded<0||rounded>=sweep->dimension
||std::abs(coordinate-static_cast<double>(rounded))>1.0e-5)
{
sweep->offGridMisses.fetch_add(1,std::memory_order_relaxed);
if(profileStats_)++localSweepOffGridMisses_;
recordMissing();
return nullptr;
}
@@ -12448,13 +12484,16 @@ FStandaloneShapeWorld::FScopedPassageTileQueries::sweptSample(
const auto& samples=sweep->passages[static_cast<std::size_t>(passageSweepIndex)].samples;
if(index>=samples.size()||!samples[index].valid)
{
sweep->unpreparedMisses.fetch_add(1,std::memory_order_relaxed);
if(profileStats_)++localSweepUnpreparedMisses_;
recordMissing();
return nullptr;
}
sweep->cacheHits.fetch_add(1,std::memory_order_relaxed);
if(samples[index].signedDistance<=sweep->influenceSubvoxels)
sweep->baseInfluenceHits.fetch_add(1,std::memory_order_relaxed);
else sweep->outOfInfluenceHits.fetch_add(1,std::memory_order_relaxed);
if(profileStats_)
{
++localSweepCacheHits_;
if(samples[index].signedDistance<=sweep->influenceSubvoxels)
++localSweepBaseInfluenceHits_;
else ++localSweepOutOfInfluenceHits_;
}
return &samples[index];
}