#include "OwnerWorldLoader.h" #include "StandaloneCoreScheduler.h" #include "StreamBenchmarkPipeline.h" #include "WorldAssemblyPrototype.h" #include "StandaloneTlsProbe.h" #include "../Core/src/StandaloneSnapshotAdapter.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace { struct FOptions { std::filesystem::path DataPath; int WorkerCount=8; int ClipRadius=3; int MaxClipLevel=8; int MaxLevel=-1; int FarHorizonLOD8InteriorStepVoxels=0; bool WorldAssemblerPrototype=false; bool StreamBenchmark=false; bool StreamPipeline=false; bool StreamHash=false; bool ProfileColumnOverlap=false; bool UseSharedColumnCache=true; bool ForceGenerate=false; bool MeshCoverage=false; bool ScreenSpaceGate=false; bool AuditUniformBlockProofs=false; bool ProfileLodWork=false; bool AuditBasePageEquivalence=false; bool AuditRouteParity=false; bool RegionCrossing=false; bool AuditTileShapeReadiness=false; int DiagnosticSlowShapeCompileMs=0; bool HasSeedOverride=false; int SeedOverride=0; bool HasRenderDistanceOverride=false; int RenderDistanceOverride=0; bool FloatingIslandsRecipe=false; bool TlsProbeRequested=false; int TlsProbeWorkers=0; std::string TlsProbeTouch="none"; bool HasCamera=false; bool HasCameraStep=false; bool AutoSurfaceCamera=false; FVector CameraMeters=FVector::ZeroVector; FVector CameraStepMeters=FVector::ZeroVector; float CameraYawDegrees=0.0f; float CameraPitchDegrees=0.0f; std::filesystem::path MeshExportPath; std::filesystem::path ResolvedLayoutOutputPath; bool ResolvedLayoutOnly=false; bool AuditResolvedLayoutBoundaries=false; bool AuditResolvedLayoutPassages=false; bool AuditSurfaceClearance=false; bool AuditStrateTransitions=false; int TransitionModeOverride=-1; int TransitionWidthChunksOverride=-1; }; bool ParseInteger(std::string_view text,int& output) { if(text.empty())return false; char* end=nullptr; const std::string value(text); const long parsed=std::strtol(value.c_str(),&end,10); if(end==value.c_str()||*end!='\0'||parsedINT32_MAX)return false; output=static_cast(parsed); return true; } bool ParseCamera(std::string_view text,FVector& meters,float& yawDegrees,float& pitchDegrees) { const std::string values(text); float x=0.0f,y=0.0f,z=0.0f,yaw=0.0f,pitch=0.0f; if(std::sscanf(values.c_str(),"%f,%f,%f,%f,%f",&x,&y,&z,&yaw,&pitch)!=5) return false; meters={x,y,z}; yawDegrees=yaw; pitchDegrees=pitch; return true; } bool ParseCameraStep(std::string_view text,FVector& meters) { const std::string values(text); float x=0.0f,y=0.0f,z=0.0f; if(std::sscanf(values.c_str(),"%f,%f,%f",&x,&y,&z)!=3)return false; meters={x,y,z}; return true; } bool OverrideTransitions(VFJson::Value& root,int mode,int widthChunks,std::string& error) { auto* object=std::get_if(&root.Data); if(!object){error="transition fixture override requires an owner JSON object";return false;} const auto stratesIt=object->find("strates"); if(stratesIt==object->end()) {error="transition fixture override cannot find the resolved strate array";return false;} auto* strates=std::get_if(&stratesIt->second.Data); if(!strates||strates->empty()) {error="transition fixture override found an empty or invalid strate array";return false;} for(auto& strate:*strates) { auto* strateObject=std::get_if(&strate.Data); if(!strateObject){error="transition fixture contains a malformed strate";return false;} const auto assetIt=strateObject->find("asset"); if(assetIt==strateObject->end())continue; auto* asset=std::get_if(&assetIt->second.Data); if(!asset)continue; if(mode>=0) { VFJson::Value value;value.Data=static_cast(mode); (*asset)["TransitionType"]=std::move(value); } if(widthChunks>=0) { VFJson::Value value;value.Data=static_cast(widthChunks); (*asset)["TransitionBlendChunks"]=std::move(value); } } return true; } bool ParseOptions(int argc,char** argv,FOptions& options) { const std::filesystem::path executable=std::filesystem::absolute(argv[0]); options.DataPath=executable.parent_path().parent_path()/"data/owner_world.json"; for(int index=1;index(mode.size()),mode.data());return false;} } else if(arg.starts_with("--transition-width-chunks=")) { if(!readInt("--transition-width-chunks=",options.TransitionWidthChunksOverride) ||options.TransitionWidthChunksOverride<0||options.TransitionWidthChunksOverride>64) {std::fprintf(stderr,"transition width chunks must be in 0..64\n");return false;} } else if(arg=="--stream-benchmark")options.StreamBenchmark=true; else if(arg=="--stream-pipeline")options.StreamPipeline=true; else if(arg=="--stream-hash")options.StreamHash=true; else if(arg=="--profile-column-overlap")options.ProfileColumnOverlap=true; else if(arg=="--force-generate")options.ForceGenerate=true; else if(arg=="--mesh-coverage")options.MeshCoverage=true; else if(arg=="--screen-space-gate")options.ScreenSpaceGate=true; else if(arg=="--audit-uniform-block-proofs")options.AuditUniformBlockProofs=true; else if(arg=="--profile-lod-work")options.ProfileLodWork=true; else if(arg=="--audit-base-page-equivalence")options.AuditBasePageEquivalence=true; else if(arg=="--audit-route-parity")options.AuditRouteParity=true; else if(arg=="--region-crossing")options.RegionCrossing=true; else if(arg=="--audit-tile-shape-readiness")options.AuditTileShapeReadiness=true; else if(arg=="--auto-surface-camera")options.AutoSurfaceCamera=true; else if(arg.starts_with("--recipe=")) { const std::string_view recipe=arg.substr(std::string_view("--recipe=").size()); if(recipe=="surface-world")options.FloatingIslandsRecipe=false; else if(recipe=="floating-islands")options.FloatingIslandsRecipe=true; else {std::fprintf(stderr,"Invalid --recipe value: %.*s\n",static_cast(recipe.size()),recipe.data());return false;} } else if(arg.starts_with("--resolved-layout-output=")) options.ResolvedLayoutOutputPath=std::string(arg.substr(std::string_view("--resolved-layout-output=").size())); else if(arg.starts_with("--seed=")) {if(!readInt("--seed=",options.SeedOverride))return false;options.HasSeedOverride=true;} else if(arg.starts_with("--render-distance-chunks=")) { if(!readInt("--render-distance-chunks=",options.RenderDistanceOverride))return false; options.RenderDistanceOverride=std::max(0,options.RenderDistanceOverride); options.HasRenderDistanceOverride=true; } else if(arg.starts_with("--tls-probe=")) { if(!readInt("--tls-probe=",options.TlsProbeWorkers))return false; if(options.TlsProbeWorkers<0||options.TlsProbeWorkers>12) {std::fprintf(stderr,"--tls-probe must be in 0..12\n");return false;} options.TlsProbeRequested=true; } else if(arg.starts_with("--tls-probe-touch=")) { const std::string_view touch=arg.substr(std::string_view("--tls-probe-touch=").size()); if(touch!="none"&&touch!="surface-world"&&touch!="floating-islands") {std::fprintf(stderr,"Invalid --tls-probe-touch value: %.*s\n",static_cast(touch.size()),touch.data());return false;} options.TlsProbeTouch=touch; } else if(arg.starts_with("--camera=")) { if(!ParseCamera(arg.substr(9),options.CameraMeters, options.CameraYawDegrees,options.CameraPitchDegrees)) {std::fprintf(stderr,"Invalid --camera value: %.*s\n",static_cast(arg.size()),arg.data());return false;} options.HasCamera=true; } else if(arg.starts_with("--camera-step=")) { if(!ParseCameraStep(arg.substr(std::string_view("--camera-step=").size()), options.CameraStepMeters)) {std::fprintf(stderr,"Invalid --camera-step value: %.*s\n",static_cast(arg.size()),arg.data());return false;} options.HasCameraStep=true; } else if(arg.starts_with("--column-cache=")) { const std::string_view mode=arg.substr(std::string_view("--column-cache=").size()); if(mode=="shared")options.UseSharedColumnCache=true; else if(mode=="thread-local")options.UseSharedColumnCache=false; else {std::fprintf(stderr,"Invalid --column-cache value: %.*s\n",static_cast(arg.size()),arg.data());return false;} } else if(arg.starts_with("--mesh-export=")) { options.MeshExportPath=std::filesystem::path(arg.substr(14)); if(options.MeshExportPath.empty()) {std::fprintf(stderr,"--mesh-export needs a file path\n");return false;} } else if(arg.starts_with("--workers=")) {if(!readInt("--workers=",options.WorkerCount))return false;} else if(arg.starts_with("--clip-radius=")) {if(!readInt("--clip-radius=",options.ClipRadius))return false;} else if(arg.starts_with("--max-clip-level=")) {if(!readInt("--max-clip-level=",options.MaxClipLevel))return false;} else if(arg.starts_with("--max-level=")) {if(!readInt("--max-level=",options.MaxLevel))return false;} else if(arg.starts_with("--far-horizon-lod8-step=")) {if(!readInt("--far-horizon-lod8-step=",options.FarHorizonLOD8InteriorStepVoxels))return false;} else if(arg.starts_with("--diagnostic-slow-shape-compile-ms=")) {if(!readInt("--diagnostic-slow-shape-compile-ms=",options.DiagnosticSlowShapeCompileMs))return false;} else if(arg.starts_with("--process-affinity=")||arg.starts_with("--process-priority=") ||arg.starts_with("--frame-limit=")) { // These viewer switches are accepted for command-line parity. The caller pins // this headless process with taskset, and a headless run has no frame limiter. } else if(!arg.empty()&&arg.front()!='-')options.DataPath=std::filesystem::path(arg); else {std::fprintf(stderr,"Unknown option: %.*s\n",static_cast(arg.size()),arg.data());return false;} } options.WorkerCount=std::clamp(options.WorkerCount,1,16); options.ClipRadius=std::clamp(options.ClipRadius,1,64); options.MaxClipLevel=std::clamp(options.MaxClipLevel,0,8); options.FarHorizonLOD8InteriorStepVoxels=std::max(0,options.FarHorizonLOD8InteriorStepVoxels); options.DiagnosticSlowShapeCompileMs=std::clamp(options.DiagnosticSlowShapeCompileMs,0,30000); if(!options.TlsProbeRequested&&options.TlsProbeTouch!="none") {std::fprintf(stderr,"--tls-probe-touch requires --tls-probe=N\n");return false;} if(options.RegionCrossing&&!options.HasCameraStep) {std::fprintf(stderr,"--region-crossing requires --camera-step=X,Y,Z\n");return false;} if(options.TlsProbeRequested)return true; if(!options.WorldAssemblerPrototype||!options.StreamBenchmark||!options.StreamPipeline) { std::fprintf(stderr,"This headless target runs the world-assembler streaming pipeline; pass --world-assembler-prototype --stream-benchmark --stream-pipeline.\n"); return false; } return true; } } int main(int argc,char** argv) { using Clock=std::chrono::steady_clock; const auto coldStart=Clock::now(); FOptions options; if(!ParseOptions(argc,argv,options))return 2; if(options.TlsProbeRequested) return StandaloneTlsProbe::Run(options.TlsProbeWorkers,options.TlsProbeTouch); std::printf("[HeadlessConfig] data=%s workers=%d clip_radius=%d max_clip_level=%d max_level=%d hash=%s column_overlap=%s force_generate=%s recipe=%s shared_column_cache=%s camera_step_m=(%.3f,%.3f,%.3f) seed_override=%s render_distance_override=%s\n", options.DataPath.string().c_str(),options.WorkerCount,options.ClipRadius,options.MaxClipLevel, options.MaxLevel,options.StreamHash?"on":"off",options.ProfileColumnOverlap?"on":"off", options.ForceGenerate?"on":"off",options.FloatingIslandsRecipe?"floating-islands":"surface-world", options.UseSharedColumnCache?"on":"off",options.CameraStepMeters.X,options.CameraStepMeters.Y, options.CameraStepMeters.Z, options.HasSeedOverride?"yes":"no",options.HasRenderDistanceOverride?"yes":"no"); std::printf("[ColdTimeline] stage=owner_data_load begin_ms=%.3f\n", std::chrono::duration(Clock::now()-coldStart).count()); std::string error; auto ownerWorld=std::make_shared(); VFJson::Value ownerJsonRoot; { std::ifstream jsonFile(options.DataPath,std::ios::binary); if(!jsonFile) {std::fprintf(stderr,"Owner data load failed: cannot open %s\n",options.DataPath.string().c_str());return 2;} std::string ownerJsonText{std::istreambuf_iterator(jsonFile),std::istreambuf_iterator{}}; if(!jsonFile&&!jsonFile.eof()) {std::fprintf(stderr,"Owner data load failed: read error for %s\n",options.DataPath.string().c_str());return 2;} if(!VFJson::Parser(std::move(ownerJsonText)).Parse(ownerJsonRoot,error)) {std::fprintf(stderr,"Owner data load failed: %s\n",error.c_str());return 2;} } if(options.HasSeedOverride &&!StandaloneWorldAssemblyPrototype::OverrideStandaloneSeed(ownerJsonRoot,options.SeedOverride,error)) {std::fprintf(stderr,"Seed override failed: %s\n",error.c_str());return 2;} if(options.HasRenderDistanceOverride &&!StandaloneWorldAssemblyPrototype::OverrideStandaloneRenderDistance( ownerJsonRoot,options.RenderDistanceOverride,error)) {std::fprintf(stderr,"Render-distance override failed: %s\n",error.c_str());return 2;} if(options.FloatingIslandsRecipe &&!StandaloneWorldAssemblyPrototype::SelectTopStrateAsFloatingIslands(ownerJsonRoot,error)) {std::fprintf(stderr,"Floating-island recipe selection failed: %s\n",error.c_str());return 2;} if((options.TransitionModeOverride>=0||options.TransitionWidthChunksOverride>=0) &&!OverrideTransitions(ownerJsonRoot,options.TransitionModeOverride, options.TransitionWidthChunksOverride,error)) {std::fprintf(stderr,"Transition fixture override failed: %s\n",error.c_str());return 2;} if(!StandaloneOwnerLoader::Resolve(ownerJsonRoot,*ownerWorld,error)) {std::fprintf(stderr,"Owner data load failed: %s\n",error.c_str());return 2;} std::printf("[ColdTimeline] stage=owner_data_load end_ms=%.3f\n", std::chrono::duration(Clock::now()-coldStart).count()); const int seed=ownerWorld->Seed; const int exportedMaxClipLevel=ownerWorld->MaxClipLevel; ownerWorld->ClipRadius=options.ClipRadius; ownerWorld->Settings->ClipRadius=options.ClipRadius; ownerWorld->MaxClipLevel=options.MaxClipLevel; ownerWorld->Settings->MaxClipLevel=options.MaxClipLevel; if(exportedMaxClipLevel!=options.MaxClipLevel) std::printf("Standalone max clip level override: exported=%d -> max_level=%d.\n", exportedMaxClipLevel,options.MaxClipLevel); FVector cameraVoxels=ownerWorld->ViewerStartVoxels; if(options.HasCamera) { const float VoxelsPerMetre=1000000.0f/std::max(1,ownerWorld->CoreVoxelSizeMicrons); cameraVoxels=FVector(options.CameraMeters.X*VoxelsPerMetre, options.CameraMeters.Y*VoxelsPerMetre,options.CameraMeters.Z*VoxelsPerMetre); } const auto planStart=Clock::now(); VoxelForgeCore::WorldAssemblyManifest worldAssembly; if(!StandaloneWorldAssemblyPrototype::AttachRound1WorldAssemblyPrototype( *ownerWorld,ownerJsonRoot,error,{},&worldAssembly)) {std::fprintf(stderr,"World assembler prototype setup failed: %s\n",error.c_str());return 2;} if(options.FloatingIslandsRecipe &&!StandaloneWorldAssemblyPrototype::AttachFloatingIslandWorldAssembly( *ownerWorld,ownerJsonRoot,worldAssembly,error)) {std::fprintf(stderr,"Floating-island assembly setup failed: %s\n",error.c_str());return 2;} VoxelForgeCore::ResolvedLayoutSnapshotV3 resolvedLayout; { const std::string_view variant=options.FloatingIslandsRecipe?"floating-islands":"surface-world"; if(!StandaloneWorldAssemblyPrototype::BuildResolvedLayoutSnapshot( *ownerWorld,worldAssembly,variant,resolvedLayout,error)) {std::fprintf(stderr,"Resolved-layout snapshot failed: %s\n",error.c_str());return 2;} const std::string layoutJson=resolvedLayout.ToJson(); const auto roundTrip=VoxelForgeCore::ResolvedLayoutSnapshotV3::FromJson(layoutJson,error); if(!roundTrip||roundTrip->ToJson()!=layoutJson||roundTrip->stableIdentity!=resolvedLayout.stableIdentity) {if(error.empty())error="resolved-layout canonical serialization did not round-trip"; std::fprintf(stderr,"Resolved-layout round trip failed: %s\n",error.c_str());return 2;} if(!options.ResolvedLayoutOutputPath.empty()) { if(!options.ResolvedLayoutOutputPath.parent_path().empty()) std::filesystem::create_directories(options.ResolvedLayoutOutputPath.parent_path()); std::ofstream output(options.ResolvedLayoutOutputPath,std::ios::binary); if(!output){std::fprintf(stderr,"Could not write resolved-layout snapshot: %s\n",options.ResolvedLayoutOutputPath.c_str());return 2;} output.write(layoutJson.data(),static_cast(layoutJson.size())); if(!output){std::fprintf(stderr,"Resolved-layout snapshot write failed: %s\n",options.ResolvedLayoutOutputPath.c_str());return 2;} } const auto controls=VoxelForgeCore::AuditResolvedLayoutValidatorV3(); std::vector compatibilityIssues; std::string compatibilityError; const bool compatibilityAccepted=resolvedLayout.validate( VoxelForgeCore::ResolvedLayoutValidationModeV3::compatibility, compatibilityIssues,compatibilityError); std::vector strictIssues; std::string strictError; const bool strictAccepted=resolvedLayout.validate( VoxelForgeCore::ResolvedLayoutValidationModeV3::strict,strictIssues,strictError); std::printf("[ResolvedLayoutSnapshot] schema=%u stable_identity=%s strata=%zu bytes=%zu round_trip=PASS\n", resolvedLayout.schemaVersion,resolvedLayout.stableIdentity.c_str(),resolvedLayout.strates.size(),layoutJson.size()); std::printf("[ResolvedLayoutCompatibility] accepted=%s issues=%zu error=%s\n", compatibilityAccepted?"true":"false",compatibilityIssues.size(),compatibilityError.c_str()); for(const auto& issue:compatibilityIssues) std::printf("[ResolvedLayoutCompatibilityIssue] code=%s detail=%s\n", issue.code.c_str(),issue.detail.c_str()); if(!compatibilityAccepted) {std::fprintf(stderr,"Resolved-layout compatibility validation failed: %s\n",compatibilityError.c_str());return 2;} std::printf("[ResolvedLayoutStrict] accepted=%s issues=%zu error=%s\n", strictAccepted?"true":"false",strictIssues.size(),strictError.c_str()); for(const auto& issue:strictIssues) std::printf("[ResolvedLayoutStrictIssue] code=%s detail=%s\n",issue.code.c_str(),issue.detail.c_str()); if(!strictAccepted) {std::fprintf(stderr,"Resolved-layout strict validation failed: %s\n",strictError.c_str());return 2;} std::printf("[ResolvedLayoutValidatorControls] rejected=%u/%u status=%s\n", controls.controlsRejectedAsExpected,controls.controlsRun,controls.passed?"PASS":"FAIL"); if(!controls.passed) {for(const auto& failure:controls.failures)std::printf("[ResolvedLayoutValidatorControlFailure] %s %s\n",failure.code.c_str(),failure.detail.c_str());return 2;} if(!options.ResolvedLayoutOutputPath.empty()) std::printf("[ResolvedLayoutSnapshotOutput] path=%s\n",options.ResolvedLayoutOutputPath.c_str()); if(auto* root=std::get_if(&ownerJsonRoot.Data)) {VFJson::Value layoutText;layoutText.Data=layoutJson;(*root)["resolved_layout_json"]=std::move(layoutText);} else {std::fprintf(stderr,"Owner snapshot root cannot carry its resolved layout.\n");return 2;} if(options.AuditSurfaceClearance) { if(options.FloatingIslandsRecipe) {std::fprintf(stderr,"--audit-surface-clearance requires --recipe=surface-world\n");return 2;} const auto surface=std::find_if(resolvedLayout.strates.begin(),resolvedLayout.strates.end(), [](const auto& Stratum){return Stratum.generatorKind=="SurfaceWorld";}); const auto plan=surface==resolvedLayout.strates.end()?worldAssembly.plan.strates.end() :std::find_if(worldAssembly.plan.strates.begin(),worldAssembly.plan.strates.end(), [&](const auto& Stratum){return Stratum.strateIndex==surface->strateIndex;}); if(surface==resolvedLayout.strates.end()||plan==worldAssembly.plan.strates.end() ||!surface->ceiling.presentInCurrentField) {std::fprintf(stderr,"SurfaceWorld clearance audit could not resolve its plan/ceiling\n");return 2;} const VoxelForgeCore::Heightfield2D Field(worldAssembly.recipe,*plan); if(!Field.isValid()) {std::fprintf(stderr,"SurfaceWorld clearance audit field is invalid\n");return 2;} constexpr std::int64_t HalfExtentMetres=2048,StepMetres=1; const double CoreMicrometres=std::max(1,ownerWorld->CoreVoxelSizeMicrons); const double MetresPerSubvoxel=CoreMicrometres /(1000000.0*VoxelForgeCore::WorldAssemblySubvoxelsPerVoxel); double CenterX=0.0,CenterY=0.0; if(!plan->route.empty()) {CenterX=plan->route.front().positionSubvoxels[0]*MetresPerSubvoxel; CenterY=plan->route.front().positionSubvoxels[1]*MetresPerSubvoxel;} const std::int64_t CenterXQ=static_cast(std::llround( CenterX/MetresPerSubvoxel)); const std::int64_t CenterYQ=static_cast(std::llround( CenterY/MetresPerSubvoxel)); const std::int64_t StepQ=static_cast(std::llround( StepMetres/MetresPerSubvoxel)); struct FBiomeClearance { std::uint64_t Samples=0; double MaximumGround=-std::numeric_limits::infinity(); double MaximumCap=-std::numeric_limits::infinity(); double MaximumSurface=-std::numeric_limits::infinity(); double MinimumClearance=std::numeric_limits::infinity(); double AtX=0.0,AtY=0.0,AtHeight=0.0; std::int64_t MaximumCapQ=std::numeric_limits::min(); }; std::map ByBiome; const double CeilingFace=static_cast(surface->ceiling.bottomMicrometres)/1000000.0; for(std::int64_t Y=-HalfExtentMetres;Y<=HalfExtentMetres;Y+=StepMetres) for(std::int64_t X=-HalfExtentMetres;X<=HalfExtentMetres;X+=StepMetres) { const auto Sample=Field.point(CenterXQ+(X/StepMetres)*StepQ, CenterYQ+(Y/StepMetres)*StepQ,0); const double Ground=Sample.groundHeightSubvoxels*MetresPerSubvoxel; const double Cap=Sample.capHeightSubvoxels*MetresPerSubvoxel; const double SurfaceHeight=std::max(Ground,Cap); auto& Stats=ByBiome[Sample.biomeId]; ++Stats.Samples; Stats.MaximumGround=std::max(Stats.MaximumGround,Ground); Stats.MaximumCap=std::max(Stats.MaximumCap,Cap); Stats.MaximumCapQ=std::max(Stats.MaximumCapQ,Sample.capHeightSubvoxels); Stats.MaximumSurface=std::max(Stats.MaximumSurface,SurfaceHeight); const double Clearance=CeilingFace-SurfaceHeight; if(Clearance::infinity(); for(const auto& Point:plan->route) MaximumRouteZ=std::max(MaximumRouteZ,Point.positionSubvoxels[2]*MetresPerSubvoxel); const auto CapBounds=Field.capHeightBounds(); const auto RouteSample=plan->route.empty()?VoxelForgeCore::HeightfieldPointSample{} :Field.point(plan->route.front().positionSubvoxels[0], plan->route.front().positionSubvoxels[1],0); std::printf("[SurfaceClearancePlan] has_recipe_override=%s layout_chunk_q=%lld plan_cap_q=%lld cap_bounds_q=(%lld,%lld)\n", plan->hasRecipeOverride?"true":"false", static_cast(worldAssembly.recipe.layoutChunkWidthSubvoxels), static_cast(plan->capHeightSubvoxels), static_cast(CapBounds[0]),static_cast(CapBounds[1])); for(const auto& Profile:worldAssembly.recipe.biomes) std::printf("[SurfaceClearanceProfile] biome_id=%u has_cap=%s cap_q=%lld undulation_q=%lld detail_q=%lld ridge_q=%lld\n", Profile.stableId,Profile.hasCapProfile?"true":"false", static_cast(Profile.capHeightSubvoxels), static_cast(Profile.capUndulationSubvoxels), static_cast(Profile.capDetailAmplitudeSubvoxels), static_cast(Profile.capRidgeAmplitudeSubvoxels)); std::printf("[SurfaceClearanceAudit] box_m=4096x4096 step_m=%lld samples=%lld ceiling_inner_face_m=%.3f unmodified_field=true\n", static_cast(StepMetres), static_cast((2*HalfExtentMetres/StepMetres+1)*(2*HalfExtentMetres/StepMetres+1)), CeilingFace); std::printf("[SurfaceClearanceCapRange] plan_min_m=%.3f plan_max_m=%.3f spawn_cap_m=%.3f spawn_ground_m=%.3f\n", CapBounds[0]*MetresPerSubvoxel,CapBounds[1]*MetresPerSubvoxel, RouteSample.capHeightSubvoxels*MetresPerSubvoxel, RouteSample.groundHeightSubvoxels*MetresPerSubvoxel); for(const auto& Feature:plan->features) std::printf("[SurfaceClearanceFeature] type=%u params_q=(%lld,%lld,%lld,%lld)\n", Feature.type,static_cast(Feature.parametersSubvoxels[0]), static_cast(Feature.parametersSubvoxels[1]), static_cast(Feature.parametersSubvoxels[2]), static_cast(Feature.parametersSubvoxels[3])); for(const auto& [BiomeId,Stats]:ByBiome) std::printf("[SurfaceClearanceBiome] biome_id=%u samples=%llu max_ground_m=%.3f max_cap_m=%.3f max_cap_q=%lld max_surface_m=%.3f min_clearance_m=%.3f at_m=(%.1f,%.1f,%.3f)\n", BiomeId,static_cast(Stats.Samples),Stats.MaximumGround, Stats.MaximumCap,static_cast(Stats.MaximumCapQ),Stats.MaximumSurface,Stats.MinimumClearance, Stats.AtX,Stats.AtY,Stats.AtHeight); std::printf("[SurfaceClearanceRoute] route_points=%zu max_route_z_m=%.3f clearance_m=%.3f status=%s\n", plan->route.size(),MaximumRouteZ,CeilingFace-MaximumRouteZ, MaximumRouteZchosen->radiusSubvoxels)chosen=&island; if(!chosen) {std::fprintf(stderr,"[SeedSurfacePlacement] FAIL: island plan has no anchors\n");return 2;} cameraVoxels={ static_cast(chosen->centerSubvoxels[0])/UnitsPerVoxel, static_cast(chosen->centerSubvoxels[1])/UnitsPerVoxel, static_cast(chosen->centerSubvoxels[2])/UnitsPerVoxel}; std::printf("[SeedSurfacePlacement] recipe=floating-islands seed=%d island_radius_vox=%.3f camera_voxel=(%.6f,%.6f,%.6f) status=PASS\n", seed,static_cast(chosen->radiusSubvoxels)/UnitsPerVoxel, cameraVoxels.X,cameraVoxels.Y,cameraVoxels.Z); } else { if(worldAssembly.plan.strates.empty()||worldAssembly.plan.strates.front().route.empty()) {std::fprintf(stderr,"[SeedSurfacePlacement] FAIL: route-derived spawn is missing\n");return 2;} const auto& spawn=worldAssembly.plan.strates.front().route.front(); cameraVoxels={static_cast(static_cast(spawn.positionSubvoxels[0])/UnitsPerVoxel), static_cast(static_cast(spawn.positionSubvoxels[1])/UnitsPerVoxel), static_cast(static_cast(spawn.positionSubvoxels[2])/UnitsPerVoxel)}; std::printf("[SeedSurfacePlacement] recipe=surface-world seed=%d source=route.front position_voxel=(%.6f,%.6f,%.6f) position_m=(%.3f,%.3f,%.3f) status=PASS\n", seed,cameraVoxels.X,cameraVoxels.Y,cameraVoxels.Z, cameraVoxels.X*ownerWorld->CoreVoxelSizeMicrons/1000000.0f, cameraVoxels.Y*ownerWorld->CoreVoxelSizeMicrons/1000000.0f, cameraVoxels.Z*ownerWorld->CoreVoxelSizeMicrons/1000000.0f); } } std::printf("[WorldAssemblerPlanTiming] total_ms=%.3f status=PASS\n", std::chrono::duration(Clock::now()-planStart).count()); auto snapshot=VoxelForgeCore::MakeStandaloneSnapshotFromParsedJson(ownerJsonRoot,seed, options.ClipRadius,options.MaxClipLevel,false,false,error); if(!snapshot) {std::fprintf(stderr,"Shape interval build failed: %s\n",error.c_str());return 2;} FStandaloneCoreScheduler scheduler; const FVector cameraStepVoxels=options.HasCameraStep ?FVector(options.CameraStepMeters.X*1000000.0f/std::max(1,ownerWorld->CoreVoxelSizeMicrons), options.CameraStepMeters.Y*1000000.0f/std::max(1,ownerWorld->CoreVoxelSizeMicrons), options.CameraStepMeters.Z*1000000.0f/std::max(1,ownerWorld->CoreVoxelSizeMicrons)):FVector::ZeroVector; return StandaloneStreamBenchmark::RunPipelinedStreamingBenchmark(ownerWorld,snapshot, cameraVoxels,options.WorkerCount,options.MaxLevel,VoxelForgeCore::DetailVariant::coherent, scheduler,options.StreamHash,false,false,false,false,coldStart, options.ProfileColumnOverlap,options.FarHorizonLOD8InteriorStepVoxels, options.MeshCoverage,options.MeshExportPath,options.CameraYawDegrees, options.CameraPitchDegrees,options.ScreenSpaceGate,options.UseSharedColumnCache, cameraStepVoxels,options.AuditUniformBlockProofs,options.ProfileLodWork, options.RegionCrossing,options.AuditTileShapeReadiness, options.DiagnosticSlowShapeCompileMs,options.AuditBasePageEquivalence, options.AuditRouteParity,options.AuditResolvedLayoutBoundaries, options.AuditResolvedLayoutPassages,options.AuditStrateTransitions, &resolvedLayout); }