Official Codebase of 3DCodeVerse
Python
scene: the zone director must keep the shots clear — cameras join the layout
gaoypeng586df5397a97
diff --git a/harness/codeverse/prompts/tracks/plan_zone_layout.j2 b/harness/codeverse/prompts/tracks/plan_zone_layout.j2index fde23d74..0cc32a19 100644--- a/harness/codeverse/prompts/tracks/plan_zone_layout.j2+++ b/harness/codeverse/prompts/tracks/plan_zone_layout.j2@@ -14,6 +14,12 @@ Neighbouring zones (do not place into them):{% for n in neighbours %}- {{ n }}{% endfor %}+## Authored cameras (the shots this scene is graded on — their first metres MUST stay clear)+{% for c in cameras %}- {{ c }}+{% endfor %}No cluster centre may sit within ~2 m + half the asset's footprint of any camera position —+a counter placed at a camera puts the lens INSIDE the geometry and caps the whole run.+Foreground framing near a camera is the zone builder's hand-placed job, never a cluster.+## Assets to place (measured sizes){% for a in assets %}- {{ a }}{% endfor %}diff --git a/harness/codeverse/tracks/zone_layout.py b/harness/codeverse/tracks/zone_layout.pyindex 5e6d31a4..9317ef99 100644--- a/harness/codeverse/tracks/zone_layout.py+++ b/harness/codeverse/tracks/zone_layout.py@@ -16,6 +16,7 @@ returns no layout for that zone and generation proceeds exactly as before.from __future__ import annotationsimport logging+import mathfrom typing import Anyfrom codeverse.contracts.chat import ChatMessage, ChatRequest@@ -34,6 +35,12 @@ LAYOUT_WAIT_S = 300.0COUNT_SLACK = 4#: cluster centres may sit this far outside the zone bbox (assets have radius)BBOX_MARGIN_M = 1.0+#: base clearance a camera needs beyond half the asset's footprint. Measured on+#: fv_izakaya_night (2026-08-30): the director placed BarCounter 0.7 m from the+#: PotDetail camera — the camera sat INSIDE the counter, camera_in_geometry ++#: 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.2def validate_layout(layout: ZoneLayout, zone: ZonePlan, plan: ScenePlan) -> str:@@ -53,6 +60,15 @@ def validate_layout(layout: ZoneLayout, zone: ZonePlan, plan: ScenePlan) -> str:f"x {lo[0]:.1f}..{hi[0]:.1f}, z {lo[2]:.1f}..{hi[2]:.1f}")if p.count > COUNT_SLACK * hints[k]:problems.append(f"{p.asset} count {p.count} is over {COUNT_SLACK}x the plan's instances_hint {hints[k]}")+ # the shot must survive the layout: a cluster whose footprint reaches a camera+ # puts geometry inside the lens (fv_izakaya_night), and nothing downstream can fix it+ foot = max(known[k].approx_size_m[0], known[k].approx_size_m[2])+ need = CAMERA_CLEAR_M + foot / 2 + p.spread_m+ for cam in plan.cameras:+ dist = math.hypot(x - cam.position[0], z - cam.position[2])+ if dist < need:+ problems.append(f"{p.asset} cluster ({x:.1f}, {z:.1f}) is {dist:.1f} m from camera {cam.name} "+ f"— keep >= {need:.1f} m (its footprint plus lens clearance) so the shot stays clear")placed = {to_snake(p.asset) for p in layout.placements}missing = [c for c in zone.contents if to_snake(c) not in placed]if missing:@@ -88,9 +104,11 @@ def _one_layout(zone: ZonePlan, plan: ScenePlan, model: Any, budget: Any, eventsfor z in plan.zones if z.name != zone.name]assets = [f"{a.name}: {a.approx_size_m[0]:g}x{a.approx_size_m[1]:g}x{a.approx_size_m[2]:g} m, ~{a.instances_hint} planned"for a in plan.assets if to_snake(a.name) in {to_snake(c) for c in zone.contents}] or ["(no planned assets — dressing only)"]+ cameras = [f"{c.name} at ({c.position[0]:.1f}, {c.position[2]:.1f}), fov {c.fov:.0f} — {c.purpose}"+ for c in plan.cameras]system = render(LAYOUT_TEMPLATE, title=plan.title, setting=plan.setting, mood=plan.mood,environment=plan.environment[:600], zone=zone, neighbours=neighbours, assets=assets,- schema_fields=", ".join(ZoneLayout.model_fields))+ cameras=cameras, schema_fields=", ".join(ZoneLayout.model_fields))user = f"Lay out zone {zone.name}. Description (binding): {zone.description}\nContents to place: {', '.join(zone.contents) or '(none)'}"complaint = ""for attempt in (0, 1):diff --git a/harness/tests/orchestrator_tracks/test_zone_layout.py b/harness/tests/orchestrator_tracks/test_zone_layout.pyindex b87a7873..8c8a25fc 100644--- a/harness/tests/orchestrator_tracks/test_zone_layout.py+++ b/harness/tests/orchestrator_tracks/test_zone_layout.py@@ -42,6 +42,17 @@ def test_validator_accepts_a_buildable_layout_and_names_every_problem():assert "no placement for planned contents: FishingBoat" in complaint+def test_validator_rejects_a_cluster_that_swallows_a_camera():+ """fv_izakaya_night: BarCounter 0.7 m from the PotDetail camera — the lens sat inside+ the counter and camera_in_geometry capped all three rounds. The camera list is an+ input to the layout, so the validator must reject this before a builder sees it."""+ plan = _plan() # camera 'overview' at (1, 1, 1)+ bad = _layout(placements=[{"asset": "Stall", "count": 1, "cluster": (1.2, 0.8), "spread_m": 0.0}],+ zone="Market")+ complaint = validate_layout(bad, plan.zones[1], plan)+ assert "from camera overview" in complaint and "shot stays clear" in complaint++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"))