Skip to content

review(pose-lib): D4 — mirror reads from stored snapshot, writes direct#598

Merged
fernandotonon merged 1 commit into
masterfrom
fix/pose-lib-mirror-from-snapshot
May 18, 2026
Merged

review(pose-lib): D4 — mirror reads from stored snapshot, writes direct#598
fernandotonon merged 1 commit into
masterfrom
fix/pose-lib-mirror-from-snapshot

Conversation

@fernandotonon
Copy link
Copy Markdown
Owner

@fernandotonon fernandotonon commented May 18, 2026

Codex P2 on PR #597 (merged):

The mirror code rebuilt the source pose by applying it to the live skeleton then re-capturing every bone. For saved poses that only covered a subset of the current skeleton (LOD swap, partial save), that pulled live state of un-mirrored bones into the result — non-deterministic and not faithful to the saved data.

Fix — two halves

Read source from m_byEntity directly

Member function has access to the private store. Look up the {entity, srcName} snapshot and iterate it. Only bones that were actually saved feed the mirror — matches applyPose's partial-apply contract on the read side.

Write mirrored result directly

Previously: apply → savePose → restore (3-step round-trip through the public API). Now that we're inside the class anyway, write mirrored straight into m_byEntity + the parallel order list, and emit posesChanged ourselves. Removes the temporary skeleton mutation entirely.

Behaviour preserved on the test-visible surface — same X-flip math, same posesChanged signal, same insertion-order semantics. The new path is just simpler and deterministic.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved pose mirroring performance and determinism through optimized data handling.

Review Change Stack

Codex P2 on PR #597 (merged):

The mirror code rebuilt the source pose by applying it to the live
skeleton then re-capturing every bone. For saved poses that only
covered a subset of the current skeleton (LOD swap, partial save),
that pulled live state of un-mirrored bones into the result —
non-deterministic and not faithful to the saved data.

## Fix — two halves

### Read source from m_byEntity directly
Member function has access to the private store. Look up the
`{entity, srcName}` snapshot directly and iterate it. Only bones
that were actually saved feed the mirror — matches `applyPose`'s
"partial apply" contract on the read side.

### Write mirrored result directly
Previously: applied mirrored snapshot to live skeleton, called
`savePose`, restored live state. That was a 3-step round-trip
through the public API only because the public API was the only
write surface I'd given the mirror code. Now that we're inside
the class anyway, write mirrored straight into `m_byEntity` plus
the parallel `order` list, and emit `posesChanged` ourselves.
Removes the temporary skeleton mutation entirely.

Behaviour preserved on the test-visible surface — same X-flip math,
same `posesChanged` signal, same insertion-order semantics. The
new path is just simpler and deterministic.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 8f49583f-e214-41da-8b65-b61b5d709aed

📥 Commits

Reviewing files that changed from the base of the PR and between 31a30ba and 0abef04.

📒 Files selected for processing (1)
  • src/PoseLibrary.cpp

📝 Walkthrough

Walkthrough

The mirrorPose method in PoseLibrary was refactored to use stored pose snapshots instead of applying and manipulating the live skeleton. It now reads the source pose snapshot directly from internal storage, builds the mirrored pose deterministically, and writes the result back without temporary skeleton state changes.

Changes

Snapshot-based pose mirroring

Layer / File(s) Summary
Snapshot source read and mirrored snapshot write
src/PoseLibrary.cpp
The source pose snapshot is located from storage, validated, mirrored by reflecting translation and quaternion components, and written directly to m_byEntity under the destination name without using savePose or live skeleton manipulation.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Poem

🐰 Snapshots stored safe and sound,
No skeleton tricks swirling round,
Mirror flows direct and true,
From pose data, old made new!
Pure and swift, no twist mid-air,
Rabbit grins—it's handled fair!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main refactoring: mirroring now reads from stored snapshot and writes directly instead of performing a live skeleton round-trip.
Description check ✅ Passed The description clearly explains the problem, the two-part fix, and confirms behavior is preserved; however, it deviates from the repository's template structure with no formal Summary or Technical Details sections.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/pose-lib-mirror-from-snapshot

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sonarqubecloud
Copy link
Copy Markdown

@fernandotonon fernandotonon merged commit 0bcd9d6 into master May 18, 2026
20 checks passed
@fernandotonon fernandotonon deleted the fix/pose-lib-mirror-from-snapshot branch May 18, 2026 04:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant