Skip to content

fix: spring bones fixed position#55

Merged
RocioCM merged 20 commits into
mainfrom
feat/spring-bones-min
Apr 10, 2026
Merged

fix: spring bones fixed position#55
RocioCM merged 20 commits into
mainfrom
feat/spring-bones-min

Conversation

@RocioCM

@RocioCM RocioCM commented Apr 9, 2026

Copy link
Copy Markdown
Member

Summary

Problem

Wearables that include spring bone chains in their GLB files (e.g. hair physics, cloth physics using DCL_spring_bone_joint or VRMC_springBone extensions) had broken animation: wearables with more bones than the avatar skeleton (the extra bones being the spring bone chain) were rendered statically at a fixed world position during emotes. The avatar body would move but the spring bone wearable stayed behind.

Changes

AvatarUtils.cs — Handle bone remapping for meshes with extra bones

SetupColors previously did a blanket replacement of every SkinnedMeshRenderer's bone array with the avatar's fixed skeleton. For wearables with spring bones this destroyed all extra bone references, causing broken joints.

Now, when a wearable's renderer has more bones than the avatar skeleton, the code takes a different path:

  • RemapBonesPreservingExtras — instead of replacing the whole bone array, maps each bone slot by name to the corresponding live avatar Transform, preserving any slots whose names don't appear in the avatar skeleton (the spring bone chain transforms).

  • ReparentExtraBonesUnderAvatarSkeleton — after per-renderer remapping, walks the entire wearable hierarchy and re-parents any transform that is not a live avatar bone under its nearest ancestor that is. This fixes the fixed-world-position bug: without it, spring bone chain roots remained as children of the wearable's own (unanimated) GameObject, so they stayed in place while the avatar moved during emotes. After re-parenting, they follow the live animated avatar bone (e.g., hair chains become children of the live Head transform).

SetupColors calls ReparentExtraBonesUnderAvatarSkeleton only when avatarBoneMap was actually built (i.e., at least one renderer had more bones than the avatar skeleton), so there is no cost for normal wearables.

GLTFLoader.cs — Remove dead commented-out code

Removed a large block of commented-out code left from an earlier iteration of the Sanitize method. No behaviour change.

Bootstrap.cs — Whitespace cleanup

Minor formatting change (added trailing newline). No behaviour change.

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

@RocioCM
RocioCM requested a review from Copilot April 9, 2026 12:51
@RocioCM RocioCM self-assigned this Apr 9, 2026

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

Fixes loading and animation behavior for wearables that include spring bone chains by ensuring GLTFast accepts vendor spring-bone extensions and by adjusting bone remapping so extra bones don’t get lost or left behind during emotes.

Changes:

  • Registers spring-bone vendor extensions with GLTFast at startup to prevent load failures.
  • Updates avatar/wearable bone remapping to preserve extra bones and attempts to reparent them under the live avatar skeleton so they follow emotes.
  • Removes a large block of dead commented-out code in GLTFLoader.Sanitize.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
Assets/Scripts/Utils/AvatarUtils.cs Remaps skinned mesh bones by name while preserving extra bones; adds hierarchy reparenting helper.
Assets/Scripts/Loading/GLTFLoader.cs Deletes obsolete commented-out sanitization logic.
Assets/Scripts/Bootstrap.cs Reflectively adds spring-bone extension(s) to GLTFast supported set on startup.

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

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

github-actions Bot commented Apr 9, 2026

Copy link
Copy Markdown

badge

Vercel Preview is ready!

Field Value
Preview https://aang-renderer-j65xg7av6-decentraland1.vercel.app
Commit 73198385262e00bbed0c5bbebaa2142d2c5f1221
Logs https://github.com/decentraland/aang-renderer/actions/runs/24246336362

@lorenzo-ranciaffi lorenzo-ranciaffi 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.

Left a couple of cosmetic comments, looks good otherwise 👍

Comment thread Assets/Scripts/Utils/AvatarUtils.cs Outdated
Comment thread Assets/Scripts/Utils/AvatarUtils.cs Outdated
Base automatically changed from feat/builder-mode-support to main April 10, 2026 13:27
@RocioCM
RocioCM merged commit 5e5a3d0 into main Apr 10, 2026
5 checks passed
@RocioCM
RocioCM deleted the feat/spring-bones-min branch April 10, 2026 14:01
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.

5 participants