research: passage exclusion envelope at plan time (L148, 7/16; kept as patch)
Seed-2 shell carver measured: vertical-shafts route-edge-0, the layer's own connection edge from the 2-3 lower mouth. Connection edges legitimately run beside the passage 12-20 m from the mouth, so an 8 m mouth-sphere exclusion rejects 9/16 otherwise valid plans. Points to one continuous tube across the mouth instead of two overlapping ones. 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
a0d7ab3a1a
commit
f21aab775f
6 files changed
+825
No files matched your search
@@ -0,0 +1,29 @@
|
||||
# Linux148 — passage exclusion envelope
|
||||
|
||||
**Result:** The shared plan-time bounds audit and its negative control work, and the L147 seed-2 carver is identified. The 8 m mouth joint is too small for the existing route candidates: both composed matrices pass only **7/16** seeds. Per the three-failure stop rule, this round stops without another planner adjustment and is not ready to promote.
|
||||
|
||||
## Root cause and rule
|
||||
|
||||
The L147 Vertical Shafts seed-2 wall sample at `(-21.678, -1.714, -888.614) m` is carved by `vertical-shafts/strate-3/route-edge-0`. At that point its native tube/floor SDF combines to about `-0.553 m`, predicting `+2.21` Core voxels of air; the observed native density is `+2.341949`. No other cave primitive has a negative native SDF there. The edge's start anchor is `passage/2-3/0/lower-mouth`, confirming this sample lies in its passage connection.
|
||||
|
||||
The shared gate samples the resolved passage spline, expands it by the 1.053 m shell/influence reach, and checks each layer primitive's conservative AABB against that envelope. It permits overlap only for a named passage mouth, within an 8 m sphere (the planner's 2 m overlap plus 6 m lead). Other overlap rejects the graph before it is written into the layout. A forced AABB at a passage centerline is rejected as the negative control.
|
||||
|
||||
The shared Core API is generic; this round wires it through `PlanResolvedCavernNetworkV1`, used by Tunnel Network and Vertical Shafts. Other layer planners must call it when they resolve their primitive bounds.
|
||||
|
||||
The mouth radius is the limiting assumption. Existing route-edge bounds in Tunnel Network seeds 0, 1, 4, and 7 meet passage `1-2` at 12.5–19.6 m from the mouth; seed 8 also has room bounds at 17.5–20.5 m. These are connected route candidates, but they fall outside the 8 m sphere. In seed 10, `vertical-shafts/strate-3/shaft-1/primitive-0` also overlaps passage `2-3`; it has no mouth association and remains a separate candidate to resolve.
|
||||
|
||||
## Measurements and checks
|
||||
|
||||
- Clang 19 and GCC builds passed with source stamp `593551a985ec0d1acc271260e4c8f15a5261c90edb60e33a56ed6df27e269ffb`.
|
||||
- Tunnel Network: **7/16**; full runs were seeds 2, 3, 5, 6, 9, 11, and 12. Vertical Shafts: **7/16**, the same seeds. The other nine seeds in each matrix were rejected by the plan-time exclusion audit. The run logs and per-seed layouts are under `Saved/Linux/l148/seeds/`.
|
||||
- Across the seven full runs in each matrix: 2,186,289 passage-interior capsule samples, zero solid; 53,262 shell wall samples, zero violations. Passage, ripple, and negative-control gates passed on those runs. Seed 2's passage `2-3` had zero wall samples outside the mouth joint, so its shell result has no wall coverage beyond that joint.
|
||||
- The passing layouts match their L147 stable identities. Seed 2 is `resolved-layout-v3-fnv64:64988eac83c0220c`.
|
||||
- Fast tier passed in 362.6 s: `Saved/Linux/l148/fast/fast-summary.json`.
|
||||
- Clang/GCC W1/W8/W12 passed on seed 2: 13 pipeline hash lines and the resolved-layout identity matched across all six runs. Summary: `Saved/Linux/l148/determinism/summary.json`.
|
||||
- `git diff --check` and Python syntax checks passed. No Unreal build was run.
|
||||
|
||||
The successful outputs remain evaluator v237 and layout-identical to L147. No baselines or captures were added. The nine rejected seeds produced no resolved layout, so there is no accepted before/after scene to capture. This is an incomplete, unpromoted planner change.
|
||||
|
||||
## Remaining risk
|
||||
|
||||
The audit catches conservative-bounds conflicts, but the current mouth sphere does not cover the existing connected-route bounds, and the optional shaft collision needs a deterministic candidate decision. The 16/16 requirement is unmet. No Unreal `Source/` files changed.
|
||||
@@ -0,0 +1,97 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Compare L148 composed owner hashes and layout identity at W1/W8/W12."""
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[4]
|
||||
OUT = ROOT / "Saved/Linux/l148/determinism"
|
||||
DATA = ROOT / "Standalone/data/owner_world.json"
|
||||
BINARIES = {
|
||||
"clang": ROOT / "Standalone/bin/linux/VoxelForgeCoreHeadless-l148-clang",
|
||||
"gcc": ROOT / "Standalone/bin/linux/VoxelForgeCoreHeadless-l148-gcc",
|
||||
}
|
||||
CAMERA = "-20.062500,-5.068359,-900.353516,0,0"
|
||||
HASH_RE = re.compile(
|
||||
r"^\[Pipeline(?:FullDetailHash|WholeViewHash|MaterialHash|LODHash|ExactQueryHash)\].*$",
|
||||
re.M)
|
||||
STAMP_RE = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=([0-9a-f]+)$", re.M)
|
||||
EXCLUSION_RE = re.compile(
|
||||
r"^\[CavernPassageExclusionAudit\] strate=[23] primitives=\d+ "
|
||||
r"outside_joint=0 mouth_joint=\d+ negative_controls=1/1 "
|
||||
r"first_primitive=none first_passage=none status=PASS$", re.M)
|
||||
|
||||
|
||||
def main() -> int:
|
||||
if any(not path.is_file() for path in (DATA, *BINARIES.values())):
|
||||
raise SystemExit("missing L148 Clang/GCC binary or composed owner fixture")
|
||||
OUT.mkdir(parents=True, exist_ok=True)
|
||||
rows = []
|
||||
reference_hashes: tuple[str, ...] | None = None
|
||||
reference_identity: str | None = None
|
||||
reference_stamp: str | None = None
|
||||
for compiler, binary in BINARIES.items():
|
||||
for workers in (1, 8, 12):
|
||||
name = f"determinism-{compiler}-w{workers}"
|
||||
log, layout = OUT / f"{name}.log", OUT / f"{name}.json"
|
||||
command = ["taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--",
|
||||
"timeout", "1740s", str(binary), str(DATA), "--world-assembler-prototype",
|
||||
"--stream-benchmark", "--stream-pipeline", f"--workers={workers}",
|
||||
"--clip-radius=3", "--max-clip-level=8", "--max-level=0",
|
||||
f"--camera={CAMERA}", "--stream-hash", "--force-generate", "--seed=2",
|
||||
"--recipe=surface-world", "--render-distance-chunks=0",
|
||||
"--density-dispatch-report", "--audit-resolved-layout-passages",
|
||||
"--audit-passage-tile-seams", f"--resolved-layout-output={layout}"]
|
||||
started = time.monotonic()
|
||||
with log.open("w", encoding="utf-8") as output:
|
||||
proc = subprocess.run(command, cwd=ROOT, stdout=output,
|
||||
stderr=subprocess.STDOUT, check=False, timeout=1740)
|
||||
content = log.read_text(encoding="utf-8", errors="replace")
|
||||
stamp_match = STAMP_RE.search(content)
|
||||
stamp = stamp_match.group(1) if stamp_match else None
|
||||
hashes = tuple(HASH_RE.findall(content))
|
||||
identity = (json.loads(layout.read_text(encoding="utf-8")).get("stable_identity")
|
||||
if layout.is_file() else None)
|
||||
audits = EXCLUSION_RE.findall(content)
|
||||
shell_ok = bool(re.search(
|
||||
r"^\[PassageShellAuditSummary\].*status=PASS$", content, re.M))
|
||||
passed = (proc.returncode == 0 and stamp is not None and bool(hashes)
|
||||
and len(audits) == 2 and shell_ok and bool(identity))
|
||||
if reference_stamp is None and passed:
|
||||
reference_stamp, reference_hashes, reference_identity = stamp, hashes, identity
|
||||
else:
|
||||
passed = (passed and stamp == reference_stamp and hashes == reference_hashes
|
||||
and identity == reference_identity)
|
||||
row = {"compiler": compiler, "workers": workers, "exit": proc.returncode,
|
||||
"stamp": stamp, "hash_lines": len(hashes),
|
||||
"hashes_match_first": hashes == reference_hashes,
|
||||
"layout_identity": identity,
|
||||
"layout_matches_first": identity == reference_identity,
|
||||
"exclusion_audits": len(audits), "shell_gate": shell_ok,
|
||||
"passed": bool(passed),
|
||||
"elapsed_s": round(time.monotonic() - started, 3),
|
||||
"log": str(log.relative_to(ROOT)), "layout": str(layout.relative_to(ROOT))}
|
||||
rows.append(row)
|
||||
print("[L148DeterminismRun] " + json.dumps(row, sort_keys=True), flush=True)
|
||||
(OUT / "runs-partial.json").write_text(json.dumps(rows, indent=2) + "\n",
|
||||
encoding="utf-8")
|
||||
if not passed:
|
||||
(OUT / "summary.json").write_text(json.dumps(
|
||||
{"status": "FAIL", "runs": rows}, indent=2) + "\n", encoding="utf-8")
|
||||
raise SystemExit(f"composed owner determinism mismatch; see {log}")
|
||||
summary = {"status": "PASS", "stamp": reference_stamp,
|
||||
"layout_identity": reference_identity, "runs": rows}
|
||||
(OUT / "summary.json").write_text(json.dumps(summary, indent=2) + "\n",
|
||||
encoding="utf-8")
|
||||
print(f"[L148DeterminismSummary] runs={len(rows)} source_stamp={reference_stamp} "
|
||||
f"status=PASS")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
@@ -0,0 +1,158 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run the L148 composed passage gates for all 16 owner seeds."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import re
|
||||
import subprocess
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[4]
|
||||
OUT = ROOT / "Saved/Linux/l148/seeds"
|
||||
BIN = ROOT / "Standalone/bin/linux/VoxelForgeCoreHeadless-l148-clang"
|
||||
DATA = ROOT / "Standalone/data/owner_world.json"
|
||||
STAMP = "593551a985ec0d1acc271260e4c8f15a5261c90edb60e33a56ed6df27e269ffb"
|
||||
STAMP_RE = re.compile(r"^\[VoxelForgeSourceStamp\] sha256=([0-9a-f]+)$", re.M)
|
||||
BASELINES = {
|
||||
"tunnel-network": ROOT / "Saved/Linux/l135/optimized-seed-sweep.json",
|
||||
"vertical-shafts": ROOT / "Saved/Linux/l139/seeds/summary.json",
|
||||
}
|
||||
DISPATCH = {
|
||||
"tunnel-network": re.compile(
|
||||
r"^\[DensityDispatch\] strate=2 generator=TunnelNetwork "
|
||||
r"recipe=Core\.Caves\.PrimitiveField version=1 "
|
||||
r"bound_path=Caves-native adapter=FCavesFieldAdapter$", re.M),
|
||||
"vertical-shafts": re.compile(
|
||||
r"^\[DensityDispatch\] strate=3 generator=VerticalShafts "
|
||||
r"recipe=Core\.Caves\.PrimitiveField version=1 "
|
||||
r"bound_path=Caves-native adapter=FCavesFieldAdapter$", re.M),
|
||||
}
|
||||
ROUTES = {
|
||||
"tunnel-network": re.compile(
|
||||
r"^\[ResolvedStrateRouteAudit\] strate=2 .*unsupported=0 "
|
||||
r"grade_failures=0 .*status=PASS$", re.M),
|
||||
"vertical-shafts": re.compile(
|
||||
r"^\[ResolvedStrateRouteAudit\] strate=3 .*unsupported=0 "
|
||||
r"grade_failures=0 .*status=PASS$", re.M),
|
||||
}
|
||||
CONTROLS = {
|
||||
"tunnel-network": re.compile(
|
||||
r"^\[TunnelNetworkBlockedRouteControl\].*expected=FAIL status=PASS$", re.M),
|
||||
"vertical-shafts": re.compile(
|
||||
r"^\[VerticalShaftsBlockedRouteControl\].*expected=FAIL status=PASS$", re.M),
|
||||
}
|
||||
REQUIRED = {
|
||||
"passages": re.compile(r"^\[ResolvedPassageAuditSummary\].*status=PASS$", re.M),
|
||||
"seams": re.compile(r"^\[PassageTileSeamAudit\].*status=PASS$", re.M),
|
||||
"shell": re.compile(r"^\[PassageShellAuditSummary\].*status=PASS$", re.M),
|
||||
"naturalness": re.compile(r"^\[PassageNaturalnessSummary\].*status=PASS$", re.M),
|
||||
"mouth_profile": re.compile(r"^\[PassageMouthProfileSummary\].*status=PASS$", re.M),
|
||||
"ripple": re.compile(r"^\[PassageRippleAuditSummary\].*status=PASS$", re.M),
|
||||
"passage_interior": re.compile(
|
||||
r"^\[PassageInteriorCapsuleAuditSummary\].*status=PASS$", re.M),
|
||||
}
|
||||
EXCLUSION = {
|
||||
strate: re.compile(
|
||||
rf"^\[CavernPassageExclusionAudit\] strate={strate} primitives=\d+ "
|
||||
r"outside_joint=0 mouth_joint=\d+ negative_controls=1/1 "
|
||||
r"first_primitive=none first_passage=none status=PASS$", re.M)
|
||||
for strate in (2, 3)
|
||||
}
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description=__doc__)
|
||||
parser.add_argument("--kind", choices=tuple(BASELINES), required=True)
|
||||
args = parser.parse_args()
|
||||
if not BIN.is_file() or not DATA.is_file():
|
||||
raise SystemExit("missing L148 Clang binary or composed owner fixture")
|
||||
baseline_path = BASELINES[args.kind]
|
||||
baseline = json.loads(baseline_path.read_text(encoding="utf-8"))
|
||||
baseline_results = {int(row["seed"]): row for row in baseline["results"]}
|
||||
OUT.mkdir(parents=True, exist_ok=True)
|
||||
mode_out = OUT / args.kind
|
||||
mode_out.mkdir(parents=True, exist_ok=True)
|
||||
results = []
|
||||
partial = mode_out / "runs-partial.json"
|
||||
for seed in range(16):
|
||||
log = mode_out / f"seed{seed}.log"
|
||||
layout = mode_out / f"seed{seed}.json"
|
||||
old_layout = ROOT / f"Saved/Linux/l147/seeds/{args.kind}/seed{seed}.json"
|
||||
command = ["taskset", "-c", "0-11", "prlimit", "--as=6442450944", "--",
|
||||
"timeout", "1740s", str(BIN), str(DATA), "--world-assembler-prototype",
|
||||
"--stream-benchmark", "--stream-pipeline", "--workers=8", "--clip-radius=3",
|
||||
"--max-clip-level=8", "--max-level=0", "--force-generate", f"--seed={seed}",
|
||||
"--recipe=surface-world", "--density-dispatch-report",
|
||||
"--audit-resolved-layout-passages", "--audit-passage-tile-seams",
|
||||
f"--resolved-layout-output={layout}"]
|
||||
started = time.monotonic()
|
||||
with log.open("w", encoding="utf-8") as output:
|
||||
proc = subprocess.run(command, cwd=ROOT, stdout=output,
|
||||
stderr=subprocess.STDOUT, check=False, timeout=1740)
|
||||
content = log.read_text(encoding="utf-8", errors="replace")
|
||||
stamp = STAMP_RE.search(content)
|
||||
checks = {name: bool(pattern.search(content)) for name, pattern in REQUIRED.items()}
|
||||
checks["source_stamp"] = stamp is not None and stamp.group(1) == STAMP
|
||||
checks["dispatch"] = bool(DISPATCH[args.kind].search(content))
|
||||
checks["route"] = bool(ROUTES[args.kind].search(content))
|
||||
checks["blocked_route_control"] = bool(CONTROLS[args.kind].search(content))
|
||||
checks["strate2_exclusion_audit"] = bool(EXCLUSION[2].search(content))
|
||||
checks["strate3_exclusion_audit"] = bool(EXCLUSION[3].search(content))
|
||||
checks["three_passage_interiors"] = len(re.findall(
|
||||
r"^\[ResolvedPassageAudit\].*interior_air=PASS", content, re.M)) == 3
|
||||
checks["three_interior_negative_controls"] = len(re.findall(
|
||||
r"^\[ResolvedPassageInteriorNegativeControl\].*detected=true status=PASS$",
|
||||
content, re.M)) == 3
|
||||
checks["three_ripple_gap_controls"] = len(re.findall(
|
||||
r"^\[PassageRippleSamplingControl\].*status=PASS$", content, re.M)) == 3
|
||||
checks["three_blocked_passage_controls"] = len(re.findall(
|
||||
r"^\[ResolvedPassageBlockedControl\].*detected=true$", content, re.M)) == 3
|
||||
checks["passage_count"] = len(re.findall(
|
||||
r"^\[ResolvedPassageAudit\].*walkability=PASS$", content, re.M)) == 3
|
||||
checks["layout_output"] = layout.is_file()
|
||||
old_identity = None
|
||||
new_identity = None
|
||||
if layout.is_file():
|
||||
new_identity = json.loads(layout.read_text(encoding="utf-8")).get("stable_identity")
|
||||
if old_layout.is_file():
|
||||
old_identity = json.loads(old_layout.read_text(encoding="utf-8")).get("stable_identity")
|
||||
checks["layout_identity_matches_l147"] = (
|
||||
old_identity is not None and new_identity is not None
|
||||
and old_identity == new_identity)
|
||||
passed = proc.returncode == 0 and all(checks.values())
|
||||
prior = baseline_results.get(seed, {})
|
||||
prior_passed = bool(prior.get("passed", False))
|
||||
change = ("newly failing" if prior_passed and not passed else
|
||||
"newly passing" if not prior_passed and passed else
|
||||
"still passing" if prior_passed else "still failing")
|
||||
failed_checks = [name for name, ok in checks.items() if not ok]
|
||||
reason = (", ".join(failed_checks) if failed_checks else
|
||||
"all gates pass and resolved identity matches L147" if passed else
|
||||
f"process exit {proc.returncode}")
|
||||
row = {"kind": args.kind, "seed": seed,
|
||||
"prior_verdict": "PASS" if prior_passed else "FAIL",
|
||||
"verdict": "PASS" if passed else "FAIL", "change": change,
|
||||
"reason": reason, "exit": proc.returncode, "checks": checks,
|
||||
"layout_identity": new_identity,
|
||||
"elapsed_s": round(time.monotonic() - started, 3),
|
||||
"log": str(log.relative_to(ROOT)), "layout": str(layout.relative_to(ROOT))}
|
||||
results.append(row)
|
||||
print("[L148SeedSweep] " + json.dumps(row, sort_keys=True), flush=True)
|
||||
partial.write_text(json.dumps(results, indent=2) + "\n", encoding="utf-8")
|
||||
passed_count = sum(row["verdict"] == "PASS" for row in results)
|
||||
summary = {"kind": args.kind, "source_stamp": STAMP,
|
||||
"baseline": str(baseline_path.relative_to(ROOT)), "seeds": list(range(16)),
|
||||
"passed": passed_count, "failed": 16 - passed_count, "results": results}
|
||||
summary_path = mode_out / "summary.json"
|
||||
summary_path.write_text(json.dumps(summary, indent=2) + "\n", encoding="utf-8")
|
||||
print(f"[L148SeedSweepSummary] kind={args.kind} passed={passed_count}/16 "
|
||||
f"failed={16-passed_count} status={'PASS' if passed_count == 16 else 'FAIL'}",
|
||||
flush=True)
|
||||
return 0 if passed_count == 16 else 1
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,541 @@
|
||||
diff --git a/Standalone/Core/include/VoxelForgeCore/VoxelForgeCore.h b/Standalone/Core/include/VoxelForgeCore/VoxelForgeCore.h
|
||||
index 8c44461..a271b75 100644
|
||||
--- a/Standalone/Core/include/VoxelForgeCore/VoxelForgeCore.h
|
||||
+++ b/Standalone/Core/include/VoxelForgeCore/VoxelForgeCore.h
|
||||
@@ -1226,6 +1226,39 @@ namespace VoxelForgeCore
|
||||
std::vector<ResolvedLayoutPassagePointV1> controlPoints;
|
||||
};
|
||||
|
||||
+ // Passage shell, relief, smooth-max support, and rounding guard in the shared
|
||||
+ // planner's integer micrometre coordinate space. Keep this aligned with the
|
||||
+ // passage evaluator's L130 reach contract.
|
||||
+ inline constexpr double ResolvedPassageInfluenceReachMicrometresV1 =
|
||||
+ (0.75 + 0.21 + 0.50 / 6.0 + 0.01) * 1000000.0;
|
||||
+ // The bounded joint covers the planner's 2 m mouth overlap and 6 m portal lead.
|
||||
+ inline constexpr std::int64_t ResolvedPassageMouthJointRadiusMicrometresV1 = 8000000;
|
||||
+
|
||||
+ // A planner passes the conservative bounds of each layer primitive through this
|
||||
+ // shared gate. Only explicitly associated mouth-joint primitives may overlap
|
||||
+ // the bounded spatial joint around their named passage mouth.
|
||||
+ struct ResolvedLayoutPrimitiveBoundsV1
|
||||
+ {
|
||||
+ std::string stableId;
|
||||
+ std::int32_t strateIndex = -1;
|
||||
+ std::array<std::int64_t, 3> boundsMinimumMicrometres{};
|
||||
+ std::array<std::int64_t, 3> boundsMaximumMicrometres{};
|
||||
+ std::string mouthJointPassageStableId;
|
||||
+ std::int64_t mouthJointRadiusMicrometres = 0;
|
||||
+ };
|
||||
+
|
||||
+ struct ResolvedLayoutPassageExclusionAuditV1
|
||||
+ {
|
||||
+ std::uint64_t primitivesChecked = 0;
|
||||
+ std::uint64_t overlapsOutsideJoint = 0;
|
||||
+ std::uint64_t mouthJointAssociations = 0;
|
||||
+ std::uint32_t negativeControlsRun = 0;
|
||||
+ std::uint32_t negativeControlsRejected = 0;
|
||||
+ std::string firstOverlappingPrimitive;
|
||||
+ std::string firstOverlappingPassage;
|
||||
+ bool passed = false;
|
||||
+ };
|
||||
+
|
||||
struct ResolvedLayoutPassageConfigV1
|
||||
{
|
||||
std::int32_t upperStrateIndex = -1;
|
||||
@@ -1340,6 +1373,14 @@ namespace VoxelForgeCore
|
||||
std::vector<ResolvedCavernRoomV1>& rooms,
|
||||
std::vector<ResolvedCavernEdgeV1>& edges,
|
||||
std::string& error);
|
||||
+ VFCORE_API bool IsResolvedLayoutPrimitiveOutsidePassageEnvelopeV1(
|
||||
+ const ResolvedLayoutSnapshotV3& layout,
|
||||
+ const ResolvedLayoutPrimitiveBoundsV1& primitive,
|
||||
+ std::string& conflictingPassageStableId);
|
||||
+ VFCORE_API ResolvedLayoutPassageExclusionAuditV1
|
||||
+ AuditResolvedLayoutPassageExclusionV1(
|
||||
+ const ResolvedLayoutSnapshotV3& layout,
|
||||
+ std::span<const ResolvedLayoutPrimitiveBoundsV1> primitives);
|
||||
VFCORE_API bool ResolveResolvedLayoutOreVeinsV1(
|
||||
ResolvedLayoutSnapshotV3& layout, std::int32_t seed,
|
||||
std::span<const ResolvedLayoutOreVeinRequestV1> requests,
|
||||
diff --git a/Standalone/Core/src/ResolvedLayoutInternal.h b/Standalone/Core/src/ResolvedLayoutInternal.h
|
||||
index 7b7520a..2550c77 100644
|
||||
--- a/Standalone/Core/src/ResolvedLayoutInternal.h
|
||||
+++ b/Standalone/Core/src/ResolvedLayoutInternal.h
|
||||
@@ -2306,6 +2306,301 @@ bool ResolveResolvedCavernGraphV1(ResolvedLayoutSnapshotV3& layout,std::int32_t
|
||||
layout=std::move(candidate);return true;
|
||||
}
|
||||
|
||||
+namespace
|
||||
+{
|
||||
+ struct FResolvedPassageEnvelopeSegment
|
||||
+ {
|
||||
+ std::string stableId;
|
||||
+ std::int32_t upperStrateIndex=-1,lowerStrateIndex=-1;
|
||||
+ std::array<double,3> a{},b{};
|
||||
+ std::array<double,3> upperMouthCenter{},lowerMouthCenter{};
|
||||
+ double radiusMicrometres=0.0;
|
||||
+ double alongMicrometres=0.0,lengthMicrometres=0.0,totalLengthMicrometres=0.0;
|
||||
+ };
|
||||
+
|
||||
+ std::vector<FResolvedPassageEnvelopeSegment> BuildResolvedPassageEnvelopeSegments(
|
||||
+ const ResolvedLayoutSnapshotV3& layout)
|
||||
+ {
|
||||
+ std::vector<FResolvedPassageEnvelopeSegment> result;
|
||||
+ for(const auto& passage:layout.passages)
|
||||
+ {
|
||||
+ if(passage.controlPoints.size()<2||layout.coreVoxelSizeMicrometres==0)continue;
|
||||
+ const std::size_t routeEnd=std::clamp<std::size_t>(
|
||||
+ passage.lowerMouthControlIndex,1,passage.controlPoints.size()-1);
|
||||
+ std::vector<PassageSpline::FPoint> controls;
|
||||
+ controls.reserve(passage.controlPoints.size());
|
||||
+ const double scale=static_cast<double>(layout.coreVoxelSizeMicrometres)
|
||||
+ /WorldAssemblySubvoxelsPerVoxel;
|
||||
+ for(const auto& point:passage.controlPoints)
|
||||
+ controls.push_back({point.positionSubvoxels[0]*scale,
|
||||
+ point.positionSubvoxels[1]*scale,point.positionSubvoxels[2]*scale,
|
||||
+ point.radiusSubvoxels*scale});
|
||||
+ const auto segments=PassageSpline::BuildSegments(controls,routeEnd,2.0,
|
||||
+ 1000000.0);
|
||||
+ if(segments.empty())continue;
|
||||
+ const double totalLength=(segments.back().alongMetres
|
||||
+ +segments.back().lengthMetres)*1000000.0;
|
||||
+ const std::size_t lowerMouthIndex=std::min(routeEnd,controls.size()-1);
|
||||
+ for(const auto& segment:segments)
|
||||
+ {
|
||||
+ FResolvedPassageEnvelopeSegment envelope;
|
||||
+ envelope.stableId=passage.stableId;
|
||||
+ envelope.upperStrateIndex=passage.upperStrateIndex;
|
||||
+ envelope.lowerStrateIndex=passage.lowerStrateIndex;
|
||||
+ for(std::size_t axis=0;axis<3;++axis)
|
||||
+ {
|
||||
+ envelope.a[axis]=segment.a[axis];
|
||||
+ envelope.b[axis]=segment.b[axis];
|
||||
+ envelope.upperMouthCenter[axis]=controls.front()[axis];
|
||||
+ envelope.lowerMouthCenter[axis]=controls[lowerMouthIndex][axis];
|
||||
+ }
|
||||
+ envelope.radiusMicrometres=std::max(segment.a[3],segment.b[3]);
|
||||
+ envelope.alongMicrometres=segment.alongMetres*1000000.0;
|
||||
+ envelope.lengthMicrometres=segment.lengthMetres*1000000.0;
|
||||
+ envelope.totalLengthMicrometres=totalLength;
|
||||
+ result.push_back(std::move(envelope));
|
||||
+ }
|
||||
+ }
|
||||
+ return result;
|
||||
+ }
|
||||
+
|
||||
+ bool ResolvedPrimitiveBoundsOverlap(const ResolvedLayoutPrimitiveBoundsV1& primitive,
|
||||
+ const std::array<double,3>& segmentA,const std::array<double,3>& segmentB,
|
||||
+ double envelopeRadius)
|
||||
+ {
|
||||
+ std::array<double,3> direction{};
|
||||
+ std::vector<double> breakpoints{0.0,1.0};
|
||||
+ for(std::size_t axis=0;axis<3;++axis)
|
||||
+ {
|
||||
+ direction[axis]=segmentB[axis]-segmentA[axis];
|
||||
+ if(std::abs(direction[axis])<=1.0e-18)continue;
|
||||
+ for(const auto boundary:{static_cast<double>(primitive.boundsMinimumMicrometres[axis]),
|
||||
+ static_cast<double>(primitive.boundsMaximumMicrometres[axis])})
|
||||
+ {
|
||||
+ const double t=(boundary-segmentA[axis])/direction[axis];
|
||||
+ if(t>0.0&&t<1.0)breakpoints.push_back(t);
|
||||
+ }
|
||||
+ }
|
||||
+ std::sort(breakpoints.begin(),breakpoints.end());
|
||||
+ breakpoints.erase(std::unique(breakpoints.begin(),breakpoints.end()),
|
||||
+ breakpoints.end());
|
||||
+ const auto distanceSquared=[&](double t)
|
||||
+ {
|
||||
+ double result=0.0;
|
||||
+ for(std::size_t axis=0;axis<3;++axis)
|
||||
+ {
|
||||
+ const double position=segmentA[axis]+direction[axis]*t;
|
||||
+ const double gap=position<primitive.boundsMinimumMicrometres[axis]
|
||||
+ ?primitive.boundsMinimumMicrometres[axis]-position
|
||||
+ :position>primitive.boundsMaximumMicrometres[axis]
|
||||
+ ?position-primitive.boundsMaximumMicrometres[axis]:0.0;
|
||||
+ result+=gap*gap;
|
||||
+ }
|
||||
+ return result;
|
||||
+ };
|
||||
+ double closestSquared=std::min(distanceSquared(0.0),distanceSquared(1.0));
|
||||
+ for(std::size_t index=1;index<breakpoints.size();++index)
|
||||
+ {
|
||||
+ const double low=breakpoints[index-1],high=breakpoints[index];
|
||||
+ const double middle=(low+high)*0.5;
|
||||
+ double quadratic=0.0,linear=0.0;
|
||||
+ for(std::size_t axis=0;axis<3;++axis)
|
||||
+ {
|
||||
+ const double position=segmentA[axis]+direction[axis]*middle;
|
||||
+ double boundary=0.0;
|
||||
+ bool active=false;
|
||||
+ if(position<primitive.boundsMinimumMicrometres[axis])
|
||||
+ {boundary=primitive.boundsMinimumMicrometres[axis];active=true;}
|
||||
+ else if(position>primitive.boundsMaximumMicrometres[axis])
|
||||
+ {boundary=primitive.boundsMaximumMicrometres[axis];active=true;}
|
||||
+ if(!active)continue;
|
||||
+ quadratic+=direction[axis]*direction[axis];
|
||||
+ linear+=direction[axis]*(segmentA[axis]-boundary);
|
||||
+ }
|
||||
+ if(quadratic>1.0e-18)
|
||||
+ {
|
||||
+ const double closest=std::clamp(-linear/quadratic,low,high);
|
||||
+ closestSquared=std::min(closestSquared,distanceSquared(closest));
|
||||
+ }
|
||||
+ closestSquared=std::min(closestSquared,distanceSquared(low));
|
||||
+ closestSquared=std::min(closestSquared,distanceSquared(high));
|
||||
+ }
|
||||
+ return closestSquared<=envelopeRadius*envelopeRadius;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+bool IsResolvedLayoutPrimitiveOutsidePassageEnvelopeV1(
|
||||
+ const ResolvedLayoutSnapshotV3& layout,
|
||||
+ const ResolvedLayoutPrimitiveBoundsV1& primitive,
|
||||
+ std::string& conflictingPassageStableId)
|
||||
+{
|
||||
+ conflictingPassageStableId.clear();
|
||||
+ for(std::size_t axis=0;axis<3;++axis)
|
||||
+ if(primitive.boundsMinimumMicrometres[axis]
|
||||
+ >primitive.boundsMaximumMicrometres[axis])
|
||||
+ {conflictingPassageStableId="invalid-primitive-bounds";return false;}
|
||||
+ if(primitive.mouthJointRadiusMicrometres<0
|
||||
+ ||primitive.mouthJointRadiusMicrometres
|
||||
+ >ResolvedPassageMouthJointRadiusMicrometresV1)
|
||||
+ {conflictingPassageStableId="invalid-mouth-joint-radius";return false;}
|
||||
+
|
||||
+ const auto envelope=BuildResolvedPassageEnvelopeSegments(layout);
|
||||
+ bool matchedMouthJoint=primitive.mouthJointPassageStableId.empty();
|
||||
+ for(const auto& segment:envelope)
|
||||
+ {
|
||||
+ const bool isUpper=primitive.strateIndex==segment.upperStrateIndex;
|
||||
+ const bool isLower=primitive.strateIndex==segment.lowerStrateIndex;
|
||||
+ if(!isUpper&&!isLower)continue;
|
||||
+ const bool authorized=primitive.mouthJointPassageStableId==segment.stableId;
|
||||
+ if(authorized)matchedMouthJoint=true;
|
||||
+ const double radius=segment.radiusMicrometres
|
||||
+ +ResolvedPassageInfluenceReachMicrometresV1+1000.0;
|
||||
+ const auto rejectAt=[&](double t)
|
||||
+ {
|
||||
+ conflictingPassageStableId=segment.stableId;
|
||||
+ const std::array<double,3> center{
|
||||
+ std::lerp(segment.a[0],segment.b[0],t),
|
||||
+ std::lerp(segment.a[1],segment.b[1],t),
|
||||
+ std::lerp(segment.a[2],segment.b[2],t)};
|
||||
+ const auto mouthDistance=[&](const auto& mouth)
|
||||
+ {
|
||||
+ const double dx=center[0]-mouth[0],dy=center[1]-mouth[1],
|
||||
+ dz=center[2]-mouth[2];
|
||||
+ return std::sqrt(dx*dx+dy*dy+dz*dz)/1.0e6;
|
||||
+ };
|
||||
+ std::printf("[PassageExclusionConflictDetail] primitive=%s passage=%s station_m=%.3f authorized_joint=%s joint_radius_m=%.3f envelope_radius_m=%.3f nearest_mouth_m=%.3f center_m=(%.3f,%.3f,%.3f) bounds_min_m=(%.3f,%.3f,%.3f) bounds_max_m=(%.3f,%.3f,%.3f)\n",
|
||||
+ primitive.stableId.c_str(),segment.stableId.c_str(),
|
||||
+ (segment.alongMicrometres+segment.lengthMicrometres*t)/1.0e6,
|
||||
+ authorized?"true":"false",
|
||||
+ primitive.mouthJointRadiusMicrometres/1.0e6,radius/1.0e6,
|
||||
+ std::min(mouthDistance(segment.upperMouthCenter),
|
||||
+ mouthDistance(segment.lowerMouthCenter)),
|
||||
+ center[0]/1.0e6,center[1]/1.0e6,center[2]/1.0e6,
|
||||
+ primitive.boundsMinimumMicrometres[0]/1.0e6,
|
||||
+ primitive.boundsMinimumMicrometres[1]/1.0e6,
|
||||
+ primitive.boundsMinimumMicrometres[2]/1.0e6,
|
||||
+ primitive.boundsMaximumMicrometres[0]/1.0e6,
|
||||
+ primitive.boundsMaximumMicrometres[1]/1.0e6,
|
||||
+ primitive.boundsMaximumMicrometres[2]/1.0e6);
|
||||
+ return false;
|
||||
+ };
|
||||
+ const auto overlaps=[&](double t0,double t1)
|
||||
+ {
|
||||
+ if(t1<=t0)return false;
|
||||
+ std::array<double,3> a{},b{};
|
||||
+ for(std::size_t axis=0;axis<3;++axis)
|
||||
+ {
|
||||
+ a[axis]=std::lerp(segment.a[axis],segment.b[axis],t0);
|
||||
+ b[axis]=std::lerp(segment.a[axis],segment.b[axis],t1);
|
||||
+ }
|
||||
+ return ResolvedPrimitiveBoundsOverlap(primitive,a,b,radius);
|
||||
+ };
|
||||
+ if(authorized&&primitive.mouthJointRadiusMicrometres>0)
|
||||
+ {
|
||||
+ const auto& center=isUpper?segment.upperMouthCenter:segment.lowerMouthCenter;
|
||||
+ std::array<double,3> delta{};
|
||||
+ double quadratic=0.0,linear=0.0,constant=0.0;
|
||||
+ for(std::size_t axis=0;axis<3;++axis)
|
||||
+ {
|
||||
+ delta[axis]=segment.b[axis]-segment.a[axis];
|
||||
+ const double offset=segment.a[axis]-center[axis];
|
||||
+ quadratic+=delta[axis]*delta[axis];
|
||||
+ linear+=offset*delta[axis];
|
||||
+ constant+=offset*offset;
|
||||
+ }
|
||||
+ const double jointReach=primitive.mouthJointRadiusMicrometres+radius;
|
||||
+ constant-=jointReach*jointReach;
|
||||
+ const double discriminant=linear*linear-quadratic*constant;
|
||||
+ if(quadratic<=1.0e-18)
|
||||
+ {
|
||||
+ // A degenerate segment that is wholly in the joint is authorized;
|
||||
+ // one outside it remains subject to the full envelope check.
|
||||
+ if(constant<=0.0)continue;
|
||||
+ if(overlaps(0.0,1.0))
|
||||
+ return rejectAt(0.5);
|
||||
+ continue;
|
||||
+ }
|
||||
+ if(discriminant<0.0)
|
||||
+ {
|
||||
+ if(overlaps(0.0,1.0))
|
||||
+ return rejectAt(0.5);
|
||||
+ continue;
|
||||
+ }
|
||||
+ const double root=std::sqrt(discriminant);
|
||||
+ const double insideFirst=(-linear-root)/quadratic;
|
||||
+ const double insideLast=(-linear+root)/quadratic;
|
||||
+ const double clippedFirst=std::clamp(insideFirst,0.0,1.0);
|
||||
+ const double clippedLast=std::clamp(insideLast,0.0,1.0);
|
||||
+ if(insideFirst>=1.0||insideLast<=0.0)
|
||||
+ {
|
||||
+ if(overlaps(0.0,1.0))
|
||||
+ return rejectAt(0.5);
|
||||
+ continue;
|
||||
+ }
|
||||
+ if(overlaps(0.0,clippedFirst)||overlaps(clippedLast,1.0))
|
||||
+ return rejectAt(clippedFirst>0.0?clippedFirst*0.5:
|
||||
+ (1.0+clippedLast)*0.5);
|
||||
+ continue;
|
||||
+ }
|
||||
+ if(overlaps(0.0,1.0))
|
||||
+ return rejectAt(0.5);
|
||||
+ }
|
||||
+ if(!matchedMouthJoint)
|
||||
+ {conflictingPassageStableId=primitive.mouthJointPassageStableId;return false;}
|
||||
+ return true;
|
||||
+}
|
||||
+
|
||||
+ResolvedLayoutPassageExclusionAuditV1 AuditResolvedLayoutPassageExclusionV1(
|
||||
+ const ResolvedLayoutSnapshotV3& layout,
|
||||
+ std::span<const ResolvedLayoutPrimitiveBoundsV1> primitives)
|
||||
+{
|
||||
+ ResolvedLayoutPassageExclusionAuditV1 result;
|
||||
+ for(const auto& primitive:primitives)
|
||||
+ {
|
||||
+ ++result.primitivesChecked;
|
||||
+ if(!primitive.mouthJointPassageStableId.empty())
|
||||
+ ++result.mouthJointAssociations;
|
||||
+ std::string conflict;
|
||||
+ if(!IsResolvedLayoutPrimitiveOutsidePassageEnvelopeV1(layout,primitive,conflict))
|
||||
+ {
|
||||
+ ++result.overlapsOutsideJoint;
|
||||
+ if(result.firstOverlappingPrimitive.empty())
|
||||
+ {
|
||||
+ result.firstOverlappingPrimitive=primitive.stableId;
|
||||
+ result.firstOverlappingPassage=std::move(conflict);
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ const auto passage=std::find_if(layout.passages.begin(),layout.passages.end(),
|
||||
+ [](const auto& value){return value.controlPoints.size()>=2;});
|
||||
+ if(passage!=layout.passages.end()&&layout.coreVoxelSizeMicrometres>0)
|
||||
+ {
|
||||
+ const auto& point=passage->controlPoints[passage->controlPoints.size()/2]
|
||||
+ .positionSubvoxels;
|
||||
+ ResolvedLayoutPrimitiveBoundsV1 control;
|
||||
+ control.stableId="negative-control/forced-inside-passage-envelope";
|
||||
+ control.strateIndex=passage->lowerStrateIndex;
|
||||
+ const double scale=static_cast<double>(layout.coreVoxelSizeMicrometres)
|
||||
+ /WorldAssemblySubvoxelsPerVoxel;
|
||||
+ for(std::size_t axis=0;axis<3;++axis)
|
||||
+ {
|
||||
+ const auto center=static_cast<std::int64_t>(std::llround(point[axis]*scale));
|
||||
+ control.boundsMinimumMicrometres[axis]=center-250000;
|
||||
+ control.boundsMaximumMicrometres[axis]=center+250000;
|
||||
+ }
|
||||
+ ++result.negativeControlsRun;
|
||||
+ std::string conflict;
|
||||
+ if(!IsResolvedLayoutPrimitiveOutsidePassageEnvelopeV1(layout,control,conflict)
|
||||
+ &&conflict==passage->stableId)
|
||||
+ ++result.negativeControlsRejected;
|
||||
+ }
|
||||
+ result.passed=result.overlapsOutsideJoint==0
|
||||
+ &&result.negativeControlsRun==1
|
||||
+ &&result.negativeControlsRejected==result.negativeControlsRun;
|
||||
+ return result;
|
||||
+}
|
||||
+
|
||||
bool PlanResolvedCavernNetworkV1(const ResolvedLayoutSnapshotV3& layout,
|
||||
std::int32_t seed,std::int32_t strateIndex,
|
||||
const ResolvedCavernPlannerSettingsV1& settings,
|
||||
@@ -3484,6 +3779,127 @@ bool PlanResolvedCavernNetworkV1(const ResolvedLayoutSnapshotV3& layout,
|
||||
std::atan2(static_cast<double>(rise),static_cast<double>(run))
|
||||
*180.0/3.14159265358979323846);
|
||||
}
|
||||
+ auto boundedGraph=layout;
|
||||
+ std::string boundsError;
|
||||
+ if(!ResolveResolvedCavernGraphV1(boundedGraph,seed,rooms,edges,boundsError))
|
||||
+ {error="cavern planner could not validate primitive bounds: "+boundsError;return false;}
|
||||
+ std::vector<ResolvedLayoutPrimitiveBoundsV1> primitiveBounds;
|
||||
+ primitiveBounds.reserve(boundedGraph.cavernRooms.size()+boundedGraph.cavernEdges.size());
|
||||
+ const std::int64_t mouthJointFeatureSpanMicrometres=
|
||||
+ MouthOverlap+PortalLeadLength+2*settings.destinationRadiusMicrometres;
|
||||
+ const auto mouthJointAtProfileDistance=[&](std::int64_t distance)
|
||||
+ ->std::string
|
||||
+ {
|
||||
+ if(distance<=mouthJointFeatureSpanMicrometres)
|
||||
+ return arrivalPassage->stableId;
|
||||
+ if(departurePassage&&totalRouteLength-distance
|
||||
+ <=mouthJointFeatureSpanMicrometres)
|
||||
+ return departurePassage->stableId;
|
||||
+ return {};
|
||||
+ };
|
||||
+ const auto associateSpatialMouthJoint=[&](ResolvedLayoutPrimitiveBoundsV1& bounds)
|
||||
+ {
|
||||
+ if(!bounds.mouthJointPassageStableId.empty())return;
|
||||
+ const double jointRadius=
|
||||
+ static_cast<double>(ResolvedPassageMouthJointRadiusMicrometresV1);
|
||||
+ double nearestSquared=jointRadius*jointRadius;
|
||||
+ for(const auto& passage:layout.passages)
|
||||
+ {
|
||||
+ if(bounds.strateIndex!=passage.upperStrateIndex
|
||||
+ &&bounds.strateIndex!=passage.lowerStrateIndex)
|
||||
+ continue;
|
||||
+ if(passage.controlPoints.size()<2)continue;
|
||||
+ const std::size_t lowerMouthIndex=std::min(
|
||||
+ passage.lowerMouthControlIndex,passage.controlPoints.size()-1);
|
||||
+ const std::array<std::size_t,2> mouthIndices={0,lowerMouthIndex};
|
||||
+ double passageDistanceSquared=std::numeric_limits<double>::infinity();
|
||||
+ for(const auto mouthIndex:mouthIndices)
|
||||
+ {
|
||||
+ double distanceSquared=0.0;
|
||||
+ for(std::size_t axis=0;axis<3;++axis)
|
||||
+ {
|
||||
+ const double center=static_cast<double>(qToMicrometres(
|
||||
+ passage.controlPoints[mouthIndex].positionSubvoxels[axis]));
|
||||
+ const double gap=center<bounds.boundsMinimumMicrometres[axis]
|
||||
+ ?bounds.boundsMinimumMicrometres[axis]-center
|
||||
+ :center>bounds.boundsMaximumMicrometres[axis]
|
||||
+ ?center-bounds.boundsMaximumMicrometres[axis]:0.0;
|
||||
+ distanceSquared+=gap*gap;
|
||||
+ }
|
||||
+ passageDistanceSquared=std::min(passageDistanceSquared,distanceSquared);
|
||||
+ }
|
||||
+ if(passageDistanceSquared<=nearestSquared)
|
||||
+ {
|
||||
+ if(bounds.mouthJointPassageStableId.empty()
|
||||
+ ||passageDistanceSquared<nearestSquared
|
||||
+ ||passage.stableId<bounds.mouthJointPassageStableId)
|
||||
+ {
|
||||
+ bounds.mouthJointPassageStableId=passage.stableId;
|
||||
+ nearestSquared=passageDistanceSquared;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+ if(!bounds.mouthJointPassageStableId.empty())
|
||||
+ bounds.mouthJointRadiusMicrometres=
|
||||
+ ResolvedPassageMouthJointRadiusMicrometresV1;
|
||||
+ };
|
||||
+ for(const auto& room:boundedGraph.cavernRooms)
|
||||
+ {
|
||||
+ ResolvedLayoutPrimitiveBoundsV1 bounds{room.stableId,room.strateIndex,
|
||||
+ room.boundsMinimumMicrometres,room.boundsMaximumMicrometres};
|
||||
+ if(room.floorProfileStableId==backboneFloorProfileId
|
||||
+ &&room.floorProfileDistanceMicrometres>=0)
|
||||
+ bounds.mouthJointPassageStableId=mouthJointAtProfileDistance(
|
||||
+ room.floorProfileDistanceMicrometres);
|
||||
+ if(!bounds.mouthJointPassageStableId.empty())
|
||||
+ bounds.mouthJointRadiusMicrometres=
|
||||
+ ResolvedPassageMouthJointRadiusMicrometresV1;
|
||||
+ associateSpatialMouthJoint(bounds);
|
||||
+ primitiveBounds.push_back(std::move(bounds));
|
||||
+ }
|
||||
+ const auto mouthJointForAnchor=[](const std::string& anchor)
|
||||
+ {
|
||||
+ constexpr std::string_view Lower="/lower-mouth";
|
||||
+ constexpr std::string_view Upper="/upper-mouth";
|
||||
+ if(anchor.ends_with(Lower))return anchor.substr(0,anchor.size()-Lower.size());
|
||||
+ if(anchor.ends_with(Upper))return anchor.substr(0,anchor.size()-Upper.size());
|
||||
+ return std::string{};
|
||||
+ };
|
||||
+ for(const auto& edge:boundedGraph.cavernEdges)
|
||||
+ {
|
||||
+ ResolvedLayoutPrimitiveBoundsV1 bounds{edge.stableId,edge.strateIndex,
|
||||
+ edge.boundsMinimumMicrometres,edge.boundsMaximumMicrometres};
|
||||
+ bounds.mouthJointPassageStableId=mouthJointForAnchor(edge.startAnchorStableId);
|
||||
+ if(bounds.mouthJointPassageStableId.empty()
|
||||
+ &&edge.floorProfileStableId==backboneFloorProfileId
|
||||
+ &&edge.floorProfileStartDistanceMicrometres>=0
|
||||
+ &&edge.floorProfileEndDistanceMicrometres>=0)
|
||||
+ {
|
||||
+ const auto midpoint=(edge.floorProfileStartDistanceMicrometres
|
||||
+ +edge.floorProfileEndDistanceMicrometres)/2;
|
||||
+ bounds.mouthJointPassageStableId=mouthJointAtProfileDistance(midpoint);
|
||||
+ }
|
||||
+ if(!bounds.mouthJointPassageStableId.empty())
|
||||
+ bounds.mouthJointRadiusMicrometres=
|
||||
+ ResolvedPassageMouthJointRadiusMicrometresV1;
|
||||
+ associateSpatialMouthJoint(bounds);
|
||||
+ primitiveBounds.push_back(std::move(bounds));
|
||||
+ }
|
||||
+ const auto exclusionAudit=AuditResolvedLayoutPassageExclusionV1(layout,primitiveBounds);
|
||||
+ std::printf("[CavernPassageExclusionAudit] strate=%d primitives=%llu outside_joint=%llu mouth_joint=%llu negative_controls=%u/%u first_primitive=%s first_passage=%s status=%s\n",
|
||||
+ strateIndex,static_cast<unsigned long long>(exclusionAudit.primitivesChecked),
|
||||
+ static_cast<unsigned long long>(exclusionAudit.overlapsOutsideJoint),
|
||||
+ static_cast<unsigned long long>(exclusionAudit.mouthJointAssociations),
|
||||
+ exclusionAudit.negativeControlsRejected,exclusionAudit.negativeControlsRun,
|
||||
+ exclusionAudit.firstOverlappingPrimitive.empty()?"none":exclusionAudit.firstOverlappingPrimitive.c_str(),
|
||||
+ exclusionAudit.firstOverlappingPassage.empty()?"none":exclusionAudit.firstOverlappingPassage.c_str(),
|
||||
+ exclusionAudit.passed?"PASS":"FAIL");
|
||||
+ if(!exclusionAudit.passed)
|
||||
+ {
|
||||
+ error="cavern planner primitive bounds overlap a passage exclusion envelope outside its mouth joint: "+
|
||||
+ exclusionAudit.firstOverlappingPrimitive+" -> "+exclusionAudit.firstOverlappingPassage;
|
||||
+ return false;
|
||||
+ }
|
||||
const double plannerMilliseconds=std::chrono::duration<double,std::milli>(
|
||||
std::chrono::steady_clock::now()-plannerStarted).count();
|
||||
std::printf("[CavernPlannerV1] strate=%d seed=%d route=%s->%s route_nodes=%zu room_primitives=%zu shafts=%zu edges=%zu branches=%zu route_horizontal_m=%.3f floor_delta_m=%.3f max_grade_deg=%.3f mouth_tangent_min_dot=%.3f grade_limit_deg=11.310 clearance_radius_m=%.3f clearance_height_m=%.3f destination_radius_m=%.3f plan_ms=%.3f status=PASS\n",
|
||||
diff --git a/Standalone/Source/StreamBenchmarkPipeline.h b/Standalone/Source/StreamBenchmarkPipeline.h
|
||||
index 48b5a30..80677e3 100644
|
||||
--- a/Standalone/Source/StreamBenchmarkPipeline.h
|
||||
+++ b/Standalone/Source/StreamBenchmarkPipeline.h
|
||||
@@ -4709,6 +4709,19 @@ namespace StandaloneStreamBenchmark
|
||||
const auto& route=allPassageSmoothRoutes[passageIndex];
|
||||
if(route.size()<2)return audit;
|
||||
const double totalRouteLength=route.back().distance;
|
||||
+ const double mouthJointRadiusMetres=
|
||||
+ static_cast<double>(VoxelForgeCore::
|
||||
+ ResolvedPassageMouthJointRadiusMicrometresV1)/1000000.0;
|
||||
+ const auto insideMouthJoint=[&](double x,double y,double z)
|
||||
+ {
|
||||
+ const auto inside=[&](const auto& mouth)
|
||||
+ {
|
||||
+ const double dx=x-mouth.x,dy=y-mouth.y,dz=z-mouth.z;
|
||||
+ return dx*dx+dy*dy+dz*dz
|
||||
+ <=mouthJointRadiusMetres*mouthJointRadiusMetres;
|
||||
+ };
|
||||
+ return inside(route.front())||inside(route.back());
|
||||
+ };
|
||||
const double bodyFloorDepth=allPassageBodyFloorDepths[passageIndex];
|
||||
constexpr std::array<std::array<double,2>,5> floorOffsets{{
|
||||
{{0.0,0.0}},{{0.30,0.0}},{{-0.30,0.0}},
|
||||
@@ -4859,11 +4872,6 @@ namespace StandaloneStreamBenchmark
|
||||
}
|
||||
const double tangentLength=std::hypot(dx,dy);
|
||||
if(tangentLength<=1.0e-6)continue;
|
||||
- if(std::min(along,totalRouteLength-along)<5.0)
|
||||
- {
|
||||
- audit.wallMouthBlendSkips+=5;
|
||||
- continue;
|
||||
- }
|
||||
const double nx=-dy/tangentLength,ny=dx/tangentLength;
|
||||
const double floorDepth=passageTubeDepthAt(radius,bodyFloorDepth);
|
||||
double floorZ=passageFloorAtXY(passageIndex,centerX,centerY,
|
||||
@@ -4897,6 +4905,11 @@ namespace StandaloneStreamBenchmark
|
||||
}
|
||||
sampleZ=floorZ+probe.height;
|
||||
}
|
||||
+ if(insideMouthJoint(sampleX,sampleY,sampleZ))
|
||||
+ {
|
||||
+ ++audit.wallMouthBlendSkips;
|
||||
+ continue;
|
||||
+ }
|
||||
const VoxelForgeCore::Vec3d wallPosition{sampleX/coreMetres,
|
||||
sampleY/coreMetres,sampleZ/coreMetres};
|
||||
if(passageInteriorWinsAt(sampleX,sampleY,sampleZ))
|
||||
Reference in new issue
Block a user