standalone: owner review fixes -- paged streaming in Core, no LOD fins, LOD0 stair patches fixed

From the owner's fly-through ("very impressive, in some cases slightly better than the original"):
- Streaming: Core compiles world-aligned fine-detail pages for tiles entering the view and releases
  them when they leave; the viewer keeps resident tiles. One chunk crossing: 144 new tiles, 1,822
  kept (was a full rebuild). A tile built as a late page hashes identically (density, mesh, payload,
  topology) to the same tile from an initial build.
- LOD>=1 fins: off-surface planar connector panels are now checked against the source surface and
  projected onto it; coarse audit 0 off-surface panels; far survival passes, bad-shell still fails.
- LOD0 stair patches: 2,630 sign-changing edges had one endpoint at the fixed +-4.125 fallback
  (carve surfaces were excluded from distance storage); distances now completed analytically, 462
  packed signs corrected; the audit now fails on any sign edge missing either endpoint (0 of 952,997).
- W1/W8 hashes equal; routes 5642/5642; look, passage and far audits pass.
Verified by me, interleaved (8 workers, cold): 1.014 s vs 1.008 s for aeeedaa, no regression.
Open: a chunk crossing still costs ~1.2 s of page compilation.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MmSoF64BbRFmk9C3p1VsBJ
This commit is contained in:
Fr0zkaandClaude Opus 5.5 committed 2026-10-05 18:17:25 +02:00
1 parent aeeedaa73d
commit 3b37d5702e
6 files changed
+939 -25

No files matched your search

+187 -2
View File
@@ -255,6 +255,7 @@ inline void AppendFarConnectorShells(const FStandaloneShapeWorld& Shape,const FV
std::vector<FVector2f> NewUVs;
std::vector<FColor> NewColors;
std::vector<int32> NewTriangles;
std::vector<std::array<int32,4>> NewQuads;
const int32 OldVertexCount=Mesh.Vertices.Num();
const int32 OldSurfaceVertices=std::clamp(Mesh.NumSurfaceVertices,0,OldVertexCount);
const bool bHasUVs=Mesh.UVs.Num()==OldVertexCount;
@@ -579,7 +580,7 @@ inline void AppendFarConnectorShells(const FStandaloneShapeWorld& Shape,const FV
const int32 C=RingVertexIndex[Ring+1][FaceSide];
const int32 D=RingVertexIndex[Ring+1][Next];
// Shared panels are emitted once even when both adjoining radial rays are missing.
NewTriangles.insert(NewTriangles.end(),{A,C,B,B,C,D});
NewQuads.push_back({A,B,C,D});
}
}
}
@@ -587,7 +588,191 @@ inline void AppendFarConnectorShells(const FStandaloneShapeWorld& Shape,const FV
RunStart=RunEnd+1;
}
}
if(NewVertices.empty()||NewTriangles.empty())return;
if(NewVertices.empty()||NewQuads.empty())return;
// The survival repair normally emits long connected strips. A few isolated
// two-triangle panels can be assembled from a radius borrowed at another axial
// sample, though, leaving a free-edged fin away from the sampled density surface.
// Match the visible coarse-panel audit's topology and six density samples here.
std::vector<uint8> QuadUseCount(NewVertices.size(),0);
for(const auto& Quad:NewQuads)
for(const int32 Vertex:Quad)
if(Vertex>=0&&static_cast<size_t>(Vertex)<QuadUseCount.size()
&&QuadUseCount[static_cast<size_t>(Vertex)]<255)
++QuadUseCount[static_cast<size_t>(Vertex)];
std::vector<uint8> KeepQuad(NewQuads.size(),1);
std::vector<std::array<int32,4>> RefinedQuads;
const double ResidualLimit=std::max(2.0,Step*0.10);
const double TileMin[3]={static_cast<double>(TileOrigin.X),static_cast<double>(TileOrigin.Y),
static_cast<double>(TileOrigin.Z)};
const double TileMax[3]={TileMin[0]+TileExtent,TileMin[1]+TileExtent,TileMin[2]+TileExtent};
const auto ToVoxels=[&](int32 Vertex)
{
return FVector(NewVertices[Vertex].X*0.04,NewVertices[Vertex].Y*0.04,
NewVertices[Vertex].Z*0.04);
};
const auto IsTileBoundaryEdge=[&](const FVector& A,const FVector& B)
{
for(int32 AxisIndex=0;AxisIndex<3;++AxisIndex)
{
const double PA=AxisIndex==0?A.X:(AxisIndex==1?A.Y:A.Z);
const double PB=AxisIndex==0?B.X:(AxisIndex==1?B.Y:B.Z);
if((std::abs(PA-TileMin[AxisIndex])<0.75&&std::abs(PB-TileMin[AxisIndex])<0.75)
||(std::abs(PA-TileMax[AxisIndex])<0.75&&std::abs(PB-TileMax[AxisIndex])<0.75))
return true;
}
return false;
};
for(size_t QuadIndex=0;QuadIndex<NewQuads.size();++QuadIndex)
{
const auto& Quad=NewQuads[QuadIndex];
if(std::any_of(Quad.begin(),Quad.end(),[&](int32 Vertex)
{return Vertex<0||static_cast<size_t>(Vertex)>=QuadUseCount.size()
||QuadUseCount[static_cast<size_t>(Vertex)]!=1;}))continue;
const FVector A=ToVoxels(Quad[0]),B=ToVoxels(Quad[1]);
const FVector C=ToVoxels(Quad[2]),D=ToVoxels(Quad[3]);
const FVector N0=FVector::CrossProduct(C-A,B-A);
const FVector N1=FVector::CrossProduct(C-B,D-B);
const double Area0=N0.Size(),Area1=N1.Size();
const double AreaSum=Area0+Area1;
if(AreaSum<=1.0e-12)continue;
const double Coherence=(N0+N1).Size()/AreaSum;
if(Coherence<0.995)continue;
if(IsTileBoundaryEdge(A,B)&&IsTileBoundaryEdge(B,D)
&&IsTileBoundaryEdge(D,C)&&IsTileBoundaryEdge(C,A))continue;
const FVector Samples[6]={A,B,C,D,(A+C+B)/3.0,(B+C+D)/3.0};
int32 OffSourceSamples=0;
for(const FVector& P:Samples)
if(std::abs(Shape.DensityAt(static_cast<float>(P.X),static_cast<float>(P.Y),
static_cast<float>(P.Z)))>ResidualLimit)++OffSourceSamples;
if(OffSourceSamples*4<6)continue;
constexpr int32 Subdivisions=8;
const FVector PreferredNormal=(NewNormals[Quad[0]]+NewNormals[Quad[1]]
+NewNormals[Quad[2]]+NewNormals[Quad[3]]).GetSafeNormal();
const auto SourceGradient=[&](const FVector& P)
{
constexpr float H=2.0f;
const float GX=(Shape.DensityAt(static_cast<float>(P.X+H),static_cast<float>(P.Y),
static_cast<float>(P.Z))-Shape.DensityAt(static_cast<float>(P.X-H),
static_cast<float>(P.Y),static_cast<float>(P.Z)))*0.25f;
const float GY=(Shape.DensityAt(static_cast<float>(P.X),static_cast<float>(P.Y+H),
static_cast<float>(P.Z))-Shape.DensityAt(static_cast<float>(P.X),
static_cast<float>(P.Y-H),static_cast<float>(P.Z)))*0.25f;
const float GZ=(Shape.DensityAt(static_cast<float>(P.X),static_cast<float>(P.Y),
static_cast<float>(P.Z+H))-Shape.DensityAt(static_cast<float>(P.X),
static_cast<float>(P.Y),static_cast<float>(P.Z-H)))*0.25f;
return FVector(GX,GY,GZ);
};
std::vector<FVector> PatchVertices;
std::vector<FVector> PatchNormals;
std::vector<FVector2f> PatchUVs;
std::vector<FColor> PatchColors;
const auto ProjectToSurface=[&](FVector& P,FVector& Normal)
{
for(int32 Iteration=0;Iteration<12;++Iteration)
{
const double Density=Shape.DensityAt(static_cast<float>(P.X),
static_cast<float>(P.Y),static_cast<float>(P.Z));
if(std::abs(Density)<=0.25)break;
FVector Gradient=SourceGradient(P);
const double GradientSquared=Gradient.SizeSquared();
if(GradientSquared<1.0e-8)return false;
double Distance=std::clamp(Density/GradientSquared,-64.0,64.0);
P-=Gradient*Distance;
}
if(std::abs(Shape.DensityAt(static_cast<float>(P.X),static_cast<float>(P.Y),
static_cast<float>(P.Z)))>2.0)return false;
Normal=SourceGradient(P);
if(Normal.SizeSquared()<1.0e-8)return false;
Normal.Normalize();
if(PreferredNormal.SizeSquared()>1.0e-8&&FVector::DotProduct(Normal,PreferredNormal)<0.0)
Normal*= -1.0;
return true;
};
std::vector<int32> Grid(static_cast<size_t>(Subdivisions+1)*(Subdivisions+1),INDEX_NONE);
bool bProjectionSucceeded=true;
for(int32 Y=0;Y<=Subdivisions&&bProjectionSucceeded;++Y)
{
const double V=static_cast<double>(Y)/Subdivisions;
for(int32 X=0;X<=Subdivisions;++X)
{
const double U=static_cast<double>(X)/Subdivisions;
FVector P=A*((1.0-U)*(1.0-V))+B*(U*(1.0-V))+C*((1.0-U)*V)+D*(U*V);
FVector Normal;
if(!ProjectToSurface(P,Normal)){bProjectionSucceeded=false;break;}
const int32 LocalIndex=static_cast<int32>(PatchVertices.size());
Grid[static_cast<size_t>(Y)*(Subdivisions+1)+X]=LocalIndex;
PatchVertices.emplace_back(P.X*25.0,P.Y*25.0,P.Z*25.0);
PatchNormals.push_back(Normal);
if(bHasUVs)
{
const FVector2f UA=NewUVs[Quad[0]],UB=NewUVs[Quad[1]];
const FVector2f UC=NewUVs[Quad[2]],UD=NewUVs[Quad[3]];
PatchUVs.emplace_back(static_cast<float>(UA.X*((1-U)*(1-V))+UB.X*(U*(1-V))
+UC.X*((1-U)*V)+UD.X*(U*V)),
static_cast<float>(UA.Y*((1-U)*(1-V))+UB.Y*(U*(1-V))
+UC.Y*((1-U)*V)+UD.Y*(U*V)));
}
if(bHasColors)PatchColors.push_back(NewColors[Quad[0]]);
}
}
if(!bProjectionSucceeded)continue;
KeepQuad[QuadIndex]=0;
const int32 PatchBase=static_cast<int32>(NewVertices.size());
NewVertices.insert(NewVertices.end(),PatchVertices.begin(),PatchVertices.end());
NewNormals.insert(NewNormals.end(),PatchNormals.begin(),PatchNormals.end());
if(bHasUVs)NewUVs.insert(NewUVs.end(),PatchUVs.begin(),PatchUVs.end());
if(bHasColors)NewColors.insert(NewColors.end(),PatchColors.begin(),PatchColors.end());
for(int32 Y=0;Y<Subdivisions;++Y)
for(int32 X=0;X<Subdivisions;++X)
{
const int32 A0=PatchBase+Grid[static_cast<size_t>(Y)*(Subdivisions+1)+X];
const int32 B0=PatchBase+Grid[static_cast<size_t>(Y)*(Subdivisions+1)+X+1];
const int32 C0=PatchBase+Grid[static_cast<size_t>(Y+1)*(Subdivisions+1)+X];
const int32 D0=PatchBase+Grid[static_cast<size_t>(Y+1)*(Subdivisions+1)+X+1];
RefinedQuads.push_back({A0,B0,C0,D0});
}
}
std::vector<std::array<int32,4>> FinalQuads;
const size_t KeptQuadCount=static_cast<size_t>(std::count(KeepQuad.begin(),KeepQuad.end(),uint8{1}));
FinalQuads.reserve(KeptQuadCount+RefinedQuads.size());
for(size_t QuadIndex=0;QuadIndex<NewQuads.size();++QuadIndex)
if(KeepQuad[QuadIndex])FinalQuads.push_back(NewQuads[QuadIndex]);
FinalQuads.insert(FinalQuads.end(),RefinedQuads.begin(),RefinedQuads.end());
if(FinalQuads.empty())return;
std::vector<int32> Remap(NewVertices.size(),INDEX_NONE);
std::vector<FVector> KeptVertices,KeptNormals;
std::vector<FVector2f> KeptUVs;
std::vector<FColor> KeptColors;
KeptVertices.reserve(FinalQuads.size()*2);KeptNormals.reserve(FinalQuads.size()*2);
if(bHasUVs)KeptUVs.reserve(FinalQuads.size()*2);
if(bHasColors)KeptColors.reserve(FinalQuads.size()*2);
const auto RemapVertex=[&](int32 Vertex)
{
int32& Mapped=Remap[static_cast<size_t>(Vertex)];
if(Mapped==INDEX_NONE)
{
Mapped=static_cast<int32>(KeptVertices.size());
KeptVertices.push_back(NewVertices[static_cast<size_t>(Vertex)]);
KeptNormals.push_back(NewNormals[static_cast<size_t>(Vertex)]);
if(bHasUVs)KeptUVs.push_back(NewUVs[static_cast<size_t>(Vertex)]);
if(bHasColors)KeptColors.push_back(NewColors[static_cast<size_t>(Vertex)]);
}
return Mapped;
};
NewTriangles.reserve(KeptQuadCount*6);
for(const auto& Quad:FinalQuads)
{
const int32 A=RemapVertex(Quad[0]),B=RemapVertex(Quad[1]);
const int32 C=RemapVertex(Quad[2]),D=RemapVertex(Quad[3]);
NewTriangles.insert(NewTriangles.end(),{A,C,B,B,C,D});
}
NewVertices=std::move(KeptVertices);NewNormals=std::move(KeptNormals);
if(bHasUVs)NewUVs=std::move(KeptUVs);
if(bHasColors)NewColors=std::move(KeptColors);
const int32 AddedVertices=static_cast<int32>(NewVertices.size());
auto InsertVertices=[&](auto& Existing,const auto& Added)