Skip to content

Official Codebase of 3DCodeVerse

Python

scene: layout validator rejects two large assets on one spot

gaoypengccf2517d4af8
diff --git a/harness/codeverse/tracks/zone_layout.py b/harness/codeverse/tracks/zone_layout.py
index 9317ef99..4e5ac1f8 100644
--- a/harness/codeverse/tracks/zone_layout.py
+++ b/harness/codeverse/tracks/zone_layout.py
@@ -41,6 +41,13 @@ BBOX_MARGIN_M = 1.0
#: dark_frame capped all three rounds (0.512 uncapped → 0.252), and refine cannot
#: fix it because cameras belong to the plan, not to any file an agent owns.
CAMERA_CLEAR_M = 1.2
+#: two LARGE assets whose cluster centres nearly coincide are stacked into each other —
+#: fv2_alpine_night's RetainingWall x PrayerBench interpenetration. Deliberately narrow:
+#: only same-spot (< 0.6 m) pairs where BOTH footprints are >= 0.8 m and neither stands on
+#: the other — a stool against a counter (small footprint) or bottles on a bar
+#: (support relation) must never be rejected.
+STACK_DIST_M = 0.6
+STACK_MIN_FOOT_M = 0.8
def validate_layout(layout: ZoneLayout, zone: ZonePlan, plan: ScenePlan) -> str:
@@ -73,6 +80,23 @@ def validate_layout(layout: ZoneLayout, zone: ZonePlan, plan: ScenePlan) -> str:
missing = [c for c in zone.contents if to_snake(c) not in placed]
if missing:
problems.append(f"no placement for planned contents: {', '.join(missing)}")
+ # two large assets on the same spot = stacked into each other
+ rows = [(p, known.get(to_snake(p.asset))) for p in layout.placements]
+ for i, (a, pa) in enumerate(rows):
+ for b, pb in rows[i + 1:]:
+ if pa is None or pb is None or to_snake(a.asset) == to_snake(b.asset):
+ continue
+ if to_snake(a.support) == to_snake(b.asset) or to_snake(b.support) == to_snake(a.asset):
+ continue # one stands on the other by design
+ fa = max(pa.approx_size_m[0], pa.approx_size_m[2])
+ fb = max(pb.approx_size_m[0], pb.approx_size_m[2])
+ if fa < STACK_MIN_FOOT_M or fb < STACK_MIN_FOOT_M:
+ continue
+ dist = math.hypot(a.cluster[0] - b.cluster[0], a.cluster[1] - b.cluster[1])
+ if dist < STACK_DIST_M:
+ problems.append(f"{a.asset} and {b.asset} share one spot ({dist:.1f} m apart, footprints "
+ f"{fa:.1f}/{fb:.1f} m) — they will interpenetrate; separate the clusters or "
+ f"make one the other's support")
return "; ".join(problems)
diff --git a/harness/tests/orchestrator_tracks/test_zone_layout.py b/harness/tests/orchestrator_tracks/test_zone_layout.py
index 8c8a25fc..d6d889ae 100644
--- a/harness/tests/orchestrator_tracks/test_zone_layout.py
+++ b/harness/tests/orchestrator_tracks/test_zone_layout.py
@@ -53,6 +53,29 @@ def test_validator_rejects_a_cluster_that_swallows_a_camera():
assert "from camera overview" in complaint and "shot stays clear" in complaint
+def test_validator_rejects_two_large_assets_on_one_spot_but_spares_adjacency():
+ """fv2_alpine: RetainingWall x PrayerBench interpenetrated because their clusters
+ coincided. The rule is deliberately narrow: small footprints (a stool against a
+ counter) and support relations (bottles ON the bar) must pass untouched."""
+ plan = _plan()
+ stacked = _layout(placements=[
+ {"asset": "FishingBoat", "count": 1, "cluster": (-12.0, 3.0), "spread_m": 0.0},
+ {"asset": "Stall", "count": 1, "cluster": (-12.2, 3.1), "spread_m": 0.0}])
+ # Stall is not Quay content, but the stacking rule should still name the pair
+ complaint = validate_layout(stacked, plan.zones[0], plan)
+ assert "share one spot" in complaint and "FishingBoat" in complaint and "Stall" in complaint
+ # small footprint: Bollard (0.3 m) right next to the boat is legitimate adjacency
+ adjacent = _layout(placements=[
+ {"asset": "FishingBoat", "count": 1, "cluster": (-12.0, 3.0), "spread_m": 0.0},
+ {"asset": "Bollard", "count": 6, "cluster": (-12.1, 3.2), "spread_m": 0.5}])
+ assert "share one spot" not in validate_layout(adjacent, plan.zones[0], plan)
+ # support relation: a Stall standing ON the boat (declared) passes
+ supported = _layout(placements=[
+ {"asset": "FishingBoat", "count": 1, "cluster": (-12.0, 3.0), "spread_m": 0.0},
+ {"asset": "Stall", "count": 1, "cluster": (-12.1, 3.1), "spread_m": 0.0, "support": "FishingBoat"}])
+ assert "share one spot" not in validate_layout(supported, plan.zones[0], plan)
+
+
def test_layout_block_renders_numbers_the_builder_can_follow():
text = layout_block(_layout(path_points=[(-18.0, 0.0), (-2.0, 4.0)], mid_props=12, ground_cover=400,
notes="boats face the quay"))