Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 8 additions & 13 deletions Assets/Scripts/Utils/AvatarUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,27 +313,22 @@ private static void RemapBonesPreservingExtras(SkinnedMeshRenderer renderer,
private static void ReparentExtraBonesUnderAvatarSkeleton(GameObject wearableRoot,
Dictionary<string, Transform> avatarBoneMap)
{
// Collect all transforms in the wearable's hierarchy
var allTransforms = wearableRoot.GetComponentsInChildren<Transform>(true);

// Build a set of all live avatar transforms for fast identity checks
var liveAvatarTransforms = new HashSet<Transform>(avatarBoneMap.Values);

foreach (var transform in allTransforms)
{
// Skip the root itself
if (transform == wearableRoot.transform) continue;

// Skip if this transform is itself a live avatar bone
if (liveAvatarTransforms.Contains(transform)) continue;

// Only re-parent chain roots: transforms whose direct parent is a live avatar bone.
// Descendants within the chain keep their existing parent, preserving chain structure.
if (transform.parent == null || !liveAvatarTransforms.Contains(transform.parent)) continue;
// Skip transforms that correspond to standard avatar bones (by name).
if (avatarBoneMap.ContainsKey(transform.name)) continue;

// The direct parent is a live avatar bone by identity, but it may be the wearable's
// copy of that bone rather than the actual live instance. Re-parent under the live one.
if (avatarBoneMap.TryGetValue(transform.parent.name, out var liveParent) && transform.parent != liveParent)
// Extra bone (e.g. spring bone) whose direct parent is a wearable copy of an avatar bone.
// Re-parent under the live avatar bone so it follows the avatar during emotes.
// Descendants within the chain keep their existing parent, preserving chain structure.
Comment thread
RocioCM marked this conversation as resolved.
Outdated
if (transform.parent != null
&& avatarBoneMap.TryGetValue(transform.parent.name, out var liveParent)
&& transform.parent != liveParent)
{
transform.SetParent(liveParent, true);
}
Expand Down
Loading