Skip to content

fix: spring bone root detection#56

Merged
RocioCM merged 2 commits into
mainfrom
fix/spring-bones-issue
Apr 14, 2026
Merged

fix: spring bone root detection#56
RocioCM merged 2 commits into
mainfrom
fix/spring-bones-issue

Conversation

@RocioCM

@RocioCM RocioCM commented Apr 13, 2026

Copy link
Copy Markdown
Member

Summary

Related PR: #55

This pull request refines the logic for reparenting extra bones (such as spring bones) in the ReparentExtraBonesUnderAvatarSkeleton method. The update ensures that only transforms not corresponding to standard avatar bones are considered for reparenting, and that extra bones are more reliably reparented under the correct live avatar bones by matching names rather than relying on object identity.

Bone reparenting improvements:

  • Updated the check to skip transforms that correspond to standard avatar bones by name instead of by object identity, making the logic more robust to different object instances.
  • Improved the condition for reparenting extra bones to ensure that only wearable copies of avatar bones are reparented under the live avatar bones, using name-based matching for the parent transform.

Screenshots

BEFORE:

Screen.Recording.2026-04-09.at.12.58.42.PM.mp4

AFTER:

Screen.Recording.2026-04-09.at.1.02.04.PM.mp4

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refines spring/extra bone reparenting so wearable “extra” bones reliably follow the live avatar skeleton during emotes by using name-based matching rather than object identity.

Changes:

  • Skip reparenting for transforms that correspond to standard avatar bones by name.
  • Reparent extra bone chain roots under the live avatar bone by matching the parent transform’s name in the avatar bone map.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Assets/Scripts/Utils/AvatarUtils.cs Outdated
@github-actions

github-actions Bot commented Apr 13, 2026

Copy link
Copy Markdown

badge

Vercel Preview is ready!

Field Value
Preview https://aang-renderer-8ktv5kgps-decentraland1.vercel.app
Commit 2094c70e725d40b392723d66dd74a5d0359e72b0
Logs https://github.com/decentraland/aang-renderer/actions/runs/24355122103

@decentraland-bot decentraland-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

PR: #56 — fix: spring bone root detection
Branch: fix/spring-bones-issue → main
Files changed: 1 (+7 -12)
CI: ✅ All checks passing


Verdict: ✅ Approve

This is a clean, correct fix. The old identity-based checks (HashSet<Transform>.Contains) were fundamentally broken because wearable bone transforms are different instances from the live avatar bones — the identity checks would never match, so spring bones would never get reparented. Switching to name-based matching via the existing avatarBoneMap dictionary is the right approach.

The code is simpler (5 net lines removed, one allocation eliminated, one concept removed) and the guard-clause consolidation reads clearly.


Findings

P3 — Nice-to-Have

  1. [Performance] Transform.name allocates a string per access in Unity — The old HashSet<Transform> used identity-based lookups (zero string alloc). The new code accesses transform.name and transform.parent.name per iteration, marshaling strings from native to managed memory. For typical wearable rigs (50–150 transforms) at equip time, this is negligible. If this ever becomes a hot path, you could cache the name in a local or build a HashSet<string> from avatarBoneMap.Keys up front.

  2. [Robustness] Name collision edge caseavatarBoneMap.ContainsKey(transform.name) will skip an extra bone that happens to share a name with a standard avatar bone. In practice this is unlikely for humanoid rigs, but if you want a tighter check you could verify identity too:

    if (avatarBoneMap.TryGetValue(transform.name, out var mapped) && mapped == transform)
        continue;

    This skips only transforms that are actually the live avatar bone, not just name-matches.

Neither finding blocks merge. The before/after videos clearly demonstrate the fix working correctly. Nice work!


Requested by Rocío Corral Mena via Slack

@RocioCM
RocioCM merged commit b8b8b38 into main Apr 14, 2026
5 checks passed
@RocioCM
RocioCM deleted the fix/spring-bones-issue branch April 14, 2026 14:07
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.

4 participants