Skip to content

Official Codebase of 3DCodeVerse

Python

scene: no_backdrop check — the world edge is measurable

gaoypenga555db1e2fd9
diff --git a/harness/codeverse/spatial/scene_placement.py b/harness/codeverse/spatial/scene_placement.py
index 91934b33..b6555ed7 100644
--- a/harness/codeverse/spatial/scene_placement.py
+++ b/harness/codeverse/spatial/scene_placement.py
@@ -266,6 +266,13 @@ BOUNDS_MARGIN_MIN_M = 2.0
#: budget mixes props with instanced tufts, and only a gross shortfall should gate.
DENSITY_FRACTION = 0.5
DENSITY_MIN_BUDGET = 20
+#: an outdoor scene with no geometry reaching past this multiple of the bounds
+#: half-extent has no backdrop ring — the world edge shows from every overview camera.
+#: world_edge_visible stood in 11/19 scene_final_v1 verdicts and 3/6 of the density
+#: arm while the plan's env contract demands a silhouette ring at ~0.6 x fog-far
+#: (well beyond bounds); 1.25x the half-extent is a deliberately lenient floor.
+BACKDROP_REACH_FACTOR = 1.25
+BACKDROP_MIN_HEIGHT_M = 2.0
def _plan_zones(plan: Any) -> list[tuple[str, list[str]]]:
@@ -358,6 +365,33 @@ def contract_findings(census: dict[str, Any] | None, plan: Any,
out.append(_f(Severity.ERROR, "scene.background is not set (renders on the raw clear colour)",
target="env", kind="no_background",
hint="in buildEnv set scene.background to the sky colour or sky texture the plan names"))
+ # -- backdrop ring: outdoor worlds must have geometry past the play area
+ bounds = _plan_bounds(plan)
+ groups = census.get("groups")
+ if bounds and isinstance(groups, list) and not infer_indoor(setting_text(plan)):
+ lo, hi = bounds
+ cx, cz = (lo[0] + hi[0]) / 2, (lo[2] + hi[2]) / 2
+ half = max(hi[0] - lo[0], hi[2] - lo[2]) / 2
+ need = BACKDROP_REACH_FACTOR * half
+ reach = 0.0
+ for g in groups:
+ b = g.get("bbox") if isinstance(g, dict) else None
+ if not (isinstance(b, dict) and b.get("min") and b.get("max")):
+ continue
+ if g.get("kind") not in ("content", "ground"):
+ continue
+ if (b["max"][1] - b["min"][1]) < BACKDROP_MIN_HEIGHT_M:
+ continue
+ r = max(abs(b["min"][0] - cx), abs(b["max"][0] - cx), abs(b["min"][2] - cz), abs(b["max"][2] - cz))
+ reach = max(reach, r)
+ if 0 < reach < need:
+ out.append(_f(Severity.ERROR,
+ f"no backdrop ring: the farthest standing geometry reaches {reach:.0f} m from centre "
+ f"but the world edge hides only past ~{need:.0f} m",
+ target="env", kind="no_backdrop", reach_m=round(reach, 1), need_m=round(need, 1),
+ hint="build the env plan's silhouette ring (24-40 SOLID pieces — hills / treeline / "
+ "rooftops — at ~0.6 x fog-far radius, 3-8 m tall, darkened): the fog supplies the "
+ "haze, the ring hides the edge"))
table = census.get("placement") if isinstance(census.get("placement"), dict) else None
rows = [AssetRow.model_validate(r) for r in (table.get("assets") or [])] if table else []
if not rows:
diff --git a/harness/tests/scene_gates/test_placement.py b/harness/tests/scene_gates/test_placement.py
index da254c17..44c3b2d9 100644
--- a/harness/tests/scene_gates/test_placement.py
+++ b/harness/tests/scene_gates/test_placement.py
@@ -247,3 +247,25 @@ def test_density_gate_fires_on_a_zone_far_under_its_layout_budget():
rep = placement_gate_safe(census, plan=_contract_plan(), layouts=layouts)
assert not [f for f in rep.findings if f.data.get("kind") == "underdressed"]
+
+def test_no_backdrop_fires_outdoors_and_stays_quiet_with_a_ring_or_indoors():
+ """world_edge_visible stood in 11/19 scene_final_v1 verdicts; the env contract's
+ silhouette ring is measurable: standing geometry must reach past the play area."""
+ base = {"fog": {"type": "Fog"}, "background": "#aabbcc",
+ "placement": _table(_row("Lantern_3", h=0.6), _row("Bench", h=0.9),
+ _row("BenchB", zone="House", h=0.9))}
+ near_only = dict(base, groups=[
+ {"name": "Yard", "kind": "content", "bbox": {"min": [-10, 0, -10], "max": [10, 4, 10]}}])
+ rep = placement_gate_safe(near_only, plan=_contract_plan(), layouts=None)
+ hits = [f for f in rep.findings if f.data.get("kind") == "no_backdrop"]
+ assert len(hits) == 1 and hits[0].target == "env" and "25 m" in hits[0].message
+ # a silhouette ring past 1.25x the half-extent quiets it
+ ringed = dict(base, groups=near_only["groups"] + [
+ {"name": "BackdropHills", "kind": "content", "bbox": {"min": [-40, 0, -40], "max": [40, 5, 40]}}])
+ rep = placement_gate_safe(ringed, plan=_contract_plan(), layouts=None)
+ assert not [f for f in rep.findings if f.data.get("kind") == "no_backdrop"]
+ # an interior never asks for one
+ indoor = _contract_plan().model_copy(update={"setting": "a candlelit library interior"})
+ rep = placement_gate_safe(near_only, plan=indoor, layouts=None)
+ assert not [f for f in rep.findings if f.data.get("kind") == "no_backdrop"]
+