Skip to content

Turn any video into a Mixamo-rig animation - GVHMR estimator, spec-driven retarget, FK apply in Blender via MCP. Works with any Mixamo character; built to be operated end-to-end by an AI agent.

render_preview: bind the spec's action before rendering (pitfall #16)

Sacha9871975d10a1
diff --git a/docs/PITFALLS.md b/docs/PITFALLS.md
index d6d1a74..9c6f0b3 100644
--- a/docs/PITFALLS.md
+++ b/docs/PITFALLS.md
@@ -73,19 +73,26 @@ touching a clip a human has partially signed off.
15. **Stale stills burn passes.** After every re-key, delete and
re-render the stills before judging anything. An old PNG has
cost this project at least two decisions.
+16. **The live scene holds ONE action — the last one applied.** A
+ preview rendered after working on another clip silently shows the
+ wrong animation (a source-vs-retarget showcase then looks
+ "desynchronized" when it is in fact a different clip).
+ `render_preview.py` binds the spec's action before rendering for
+ exactly this reason; anything else that renders the scene must do
+ the same.
## Process
-16. **Beat sheet before any spec.** The 16-pass punch and the 4-pass
+17. **Beat sheet before any spec.** The 16-pass punch and the 4-pass
kick differ by exactly this discipline; the two shipped clips took
1–2 passes each.
-17. **One constraint per pass; signed-off regions are frozen.** The
+18. **One constraint per pass; signed-off regions are frozen.** The
single historical regression came from "improving" feet while
polishing something else after the upper body was approved.
-18. **Map human notes to the owning system before editing.** "Frames
+19. **Map human notes to the owning system before editing.** "Frames
18–50, punching side" once meant the *guard*, not the punch — a
pass was wasted editing the wrong function. Convert the frame range
to src frames, find the beat, find the spec field; only then edit.
-19. **QA passing ≠ done.** Numbers catch explosions, pops, skate and
+20. **QA passing ≠ done.** Numbers catch explosions, pops, skate and
drift; they cannot see a wrong silhouette. Play the clip, read the
stills, ask the human.
diff --git a/pipeline/render_preview.py b/pipeline/render_preview.py
index 12c2934..036b7c3 100644
--- a/pipeline/render_preview.py
+++ b/pipeline/render_preview.py
@@ -39,6 +39,24 @@ REPO = Path(__file__).resolve().parents[1]
RENDER_SEQ = """import bpy, math
from mathutils import Vector
scene = bpy.context.scene
+
+# Bind the SPEC's action before rendering — the live scene holds
+# whatever action was applied last, which may be a different clip.
+arm = bpy.data.objects["Armature"]
+act = bpy.data.actions.get("{action}")
+assert act is not None, "action '{action}' not found in the scene - run the apply first"
+if arm.animation_data is None:
+ arm.animation_data_create()
+arm.animation_data.action = act
+try:
+ for slot in act.slots:
+ arm.animation_data.action_slot = slot
+ break
+except Exception:
+ pass
+scene.frame_start = 1
+scene.frame_end = int(act.frame_range[1])
+
cam_data = bpy.data.cameras.new("QA_Camera")
cam = bpy.data.objects.new("QA_Camera", cam_data)
scene.collection.objects.link(cam)
@@ -107,7 +125,7 @@ def main() -> None:
frames_dir.mkdir(exist_ok=True)
# 1. PNG sequence from the live Blender.
- code = RENDER_SEQ.format(outdir=str(frames_dir))
+ code = RENDER_SEQ.format(outdir=str(frames_dir), action=spec["action_name"])
with tempfile.NamedTemporaryFile("w", suffix=".py", delete=False, encoding="utf-8") as f:
f.write(code)
tmp = f.name