feat(qc): loop_qc tool + loop-qc agent — measure loop-seam smoothness
Pose gap / velocity gap / root drift at the LoopMode.Linear wrap; exit-code gated. Skill updated: loop QC is workflow step 5, with the Blender-side fixer playbook. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
---
|
||||
name: loop-qc
|
||||
description: Quality-control gate for looping dance/animation clips. Given one or more GLB clips (or a glob), it measures whether each loops smoothly — the pose, motion velocity, and root drift at the loop seam — and reports a SMOOTH / NOT SMOOTH verdict per clip with the exact numbers, the worst-offending bones, and a diagnosis of why it pops plus the iClone-side fix. Use before shipping any clip meant to loop, or when a dance visibly jumps/snaps on repeat.
|
||||
tools: Bash, Read, Glob
|
||||
---
|
||||
|
||||
# Loop QC agent
|
||||
|
||||
You verify that animation clips loop smoothly. The game loops clips with Godot
|
||||
`LoopMode.Linear` — after the last keyframe it wraps straight back to frame 0 — so a
|
||||
clip loops cleanly only when the **pose**, the **motion velocity**, and the **root
|
||||
position** are continuous across that seam. Your job is to measure that and report it
|
||||
plainly, not to guess from the clip name.
|
||||
|
||||
## How to run
|
||||
|
||||
The measurement tool is `tools/loop_qc.py` (Blender headless). For each clip:
|
||||
|
||||
```bash
|
||||
/Applications/Blender.app/Contents/MacOS/Blender --background --python tools/loop_qc.py -- \
|
||||
--src <clip.glb> [--name <ClipName>]
|
||||
```
|
||||
|
||||
- Exit code **0 = SMOOTH**, **1 = NOT SMOOTH**, **2 = error**. Capture it (`; echo $?`) — but never pipe the tool through `grep` when you need the exit code, since the pipe reports grep's status, not the tool's.
|
||||
- Batch: loop over the GLBs given (or discover them with Glob, e.g. `exchange/converted-glb/*.glb` or ariki-game's `assets/quaternius/dancegen/*.glb`). Run them and collect verdicts.
|
||||
- Blender is at `/Applications/Blender.app/Contents/MacOS/Blender`.
|
||||
|
||||
## Thresholds (defaults; overridable via flags)
|
||||
|
||||
| Metric | Flag | Default limit | What a failure means |
|
||||
|---|---|---|---|
|
||||
| pose gap (max per-bone local-rot Δ, end→start) | `--pose-deg` | 5° | Character snaps to a different pose on wrap |
|
||||
| velocity gap (per-bone angular-vel mismatch across seam) | `--vel-deg` | 3°/frame | Motion direction jerks even if the pose matches |
|
||||
| root drift (pelvis world-pos end vs start) | `--drift-cm` | 3 cm | Body teleports sideways/vertically on wrap |
|
||||
|
||||
## How to read the result and diagnose
|
||||
|
||||
The three metrics separate the failure modes — say which one(s) tripped:
|
||||
|
||||
- **High root drift, low pose gap** → the performer *travels across the floor*; the clip is fine in place but walks away from the origin. Fix: author/trim so it returns to the start, or remove the horizontal root translation (in-place). Never rely on `*RM`/root-motion variants — the game is in-place.
|
||||
- **High pose gap, ~0 velocity gap** → the clip starts and ends in *still holds* that are different poses. Fix in iClone: match the end pose to the start pose (copy the first-frame pose onto the last frame), or trim to a full motion cycle.
|
||||
- **High pose gap AND high velocity gap** → the clip begins from a held pose and ends mid-motion (or vice versa). Fix in iClone: trim to a segment that starts and ends at the same point in the motion cycle, or crossfade/blend the ends (Animation Layer with a keyframed weight ramp, or bracket clean keys around the seam).
|
||||
|
||||
Always name the specific worst bones the tool lists — that tells the animator where to look.
|
||||
|
||||
## Output
|
||||
|
||||
Return, per clip: the verdict, the three metric lines (with pass/fail and numbers), the top offending bones, and a one-line diagnosis + recommended fix keyed to the pattern above. Finish with a summary table of all clips and how many passed. Do not modify any files — you are read-only QC. If asked to fix, hand off to the iClone workflow (`iclone-video-mocap` skill), don't edit the GLB directly.
|
||||
@@ -16,10 +16,11 @@ This skill is the accumulated **do-it-this-way** knowledge from real runs.
|
||||
2. **Retarget each FBX** with the exact command below → GLB in `exchange/converted-glb/`.
|
||||
3. **Commit + push the GLBs** in *this* repo (use `tinqs push`, not raw `git push` — it self-heals auth and uploads LFS direct-to-S3).
|
||||
4. **Copy GLBs into ariki-game** `assets/quaternius/dancegen/`, write a dance JSON per clip.
|
||||
5. **Import** so Godot generates sidecars: `bash tools/game.sh import` (from ariki-game root).
|
||||
6. **Verify** clip names, then commit in ariki-game.
|
||||
7. **Launch the test bed only after asking** (see below).
|
||||
8. Leave `exchange/` cleanup until Jeremy confirms the batch looks right in-game.
|
||||
5. **Loop QC gate** — run `loop_qc.py` on each converted GLB (see below). Flag anything that isn't smooth *before* it ships.
|
||||
6. **Import** so Godot generates sidecars: `bash tools/game.sh import` (from ariki-game root).
|
||||
7. **Verify** clip names, then commit in ariki-game.
|
||||
8. **Launch the test bed only after asking** (see below).
|
||||
9. Leave `exchange/` cleanup until Jeremy confirms the batch looks right in-game.
|
||||
|
||||
### The retarget command (canonical)
|
||||
```bash
|
||||
@@ -50,6 +51,35 @@ Default **bpm 100, loops 1** to match the sibling `hakadance1`. bpm only matters
|
||||
- **Commit the `.glb.import` sidecar with the GLB.** Godot embeds the `uid://` inside the `.import` file — there is **no separate `.uid`** for GLBs. Commit GLB + `.import` + JSON together.
|
||||
- **`game.sh import` shows scary warnings** (tree impostors, meta drift, stale bakes, hair-texture case mismatch, missing `res://src/polynesia/data`) — those are **pre-existing and unrelated**. Only care about `errors`, not `warnings`.
|
||||
|
||||
## Loop QC (clips are meant to loop — most raw takes don't)
|
||||
The game loops clips with Godot `LoopMode.Linear` (wraps last keyframe → frame 0), so a
|
||||
clip only looks right if the **pose, motion velocity, and root position** are continuous
|
||||
across that seam. Raw iClone/mocap takes almost never satisfy this — they start from a
|
||||
held pose and end mid-motion, or the performer walks across the floor. **QC every clip
|
||||
before shipping** with the `loop-qc` agent, or directly:
|
||||
|
||||
```bash
|
||||
/Applications/Blender.app/Contents/MacOS/Blender --background --python tools/loop_qc.py -- \
|
||||
--src exchange/converted-glb/<pack>.glb
|
||||
# exit 0 = SMOOTH, 1 = NOT SMOOTH, 2 = error. Don't pipe through grep if you need the code.
|
||||
```
|
||||
Three metrics, three failure modes (the tool ranks the worst bones so you know where):
|
||||
- **root drift high, pose gap low** → performer travels; needs in-place authoring / trim back to origin.
|
||||
- **pose gap high, velocity gap ~0** → starts & ends in different *still* holds; match end pose to start in iClone.
|
||||
- **both high** → starts held / ends mid-move; trim to a full cycle or blend the seam (Animation Layer weight ramp, or bracket clean keys — see `iclone-video-mocap`).
|
||||
|
||||
Two Blender-side fixers exist (no iClone round-trip needed):
|
||||
- `tools/loop_fix.py` — de-drift + trim to best natural loop point + motion-graph seam
|
||||
blend (crossfade toward the frames before the loop start). Keeps 60–90% of the clip.
|
||||
Outputs to `exchange/looped-glb/`. See `plans/loop-fix-plan-2026-07-16.md` + results.
|
||||
- `tools/pingpong_bake.py` — palindrome bake (forward then reversed as ONE clip):
|
||||
end frame == start frame by construction, drift self-cancels, full choreography kept,
|
||||
but motion visibly reverses at the turn point. Outputs `exchange/pingpong-glb/*_pp.glb`,
|
||||
shipped as separate `<pack>_pp` packs. Prefer for sway-heavy dances (hula); judge
|
||||
per-dance for percussive ones (haka) where reverse playback can read as moonwalking.
|
||||
Both verified by re-running `loop_qc.py` to exit 0. iClone re-authoring remains the
|
||||
fallback for clips where neither result looks right in the test bed.
|
||||
|
||||
## Launching the game
|
||||
- **Always ask Jeremy before launching** (this session he said "let's launch" — that's the go-ahead; don't assume it next time).
|
||||
- Command: `SCENE=dance_test_bed bash tools/game.sh spawn` from `ariki-game/` root. Also `animation_showcase` for paging every clip.
|
||||
|
||||
Reference in New Issue
Block a user