Skip to content

Commit

Permalink
Merge pull request #678 from anatawa12/fix-proxy-animation
Browse files Browse the repository at this point in the history
fix: proxy animation can be remapped
  • Loading branch information
anatawa12 authored Nov 2, 2023
2 parents 8dd613a + 164e610 commit aa3fcf8
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-PRERELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ The format is based on [Keep a Changelog].
### Removed

### Fixed
- proxy animation can be modified `#678`

### Security

Expand Down
6 changes: 6 additions & 0 deletions Editor/ObjectMapping/AnimationObjectMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ public EditorCurveBinding[] MapBinding(EditorCurveBinding binding)

if (componentInfo.PropertyMapping.TryGetValue(binding.propertyName, out var newProp))
{
// if mapped one is exactly same as original, return null
if (newProp.AllCopiedTo.Length == 1
&& newProp.AllCopiedTo[0].InstanceId == instanceId
&& newProp.AllCopiedTo[0].Name == binding.propertyName)
return null;

// there are mapping for property
var curveBindings = new EditorCurveBinding[newProp.AllCopiedTo.Length];
var copiedToIndex = 0;
Expand Down
4 changes: 4 additions & 0 deletions Editor/ObjectMapping/ObjectMappingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ private Object CustomClone(Object o)
{
if (o is AnimationClip clip)
{
#if AAO_VRCSDK3_AVATARS
// TODO: when BuildContext have property to check if it is for VRCSDK3, additionally use it.
if (clip.IsProxy()) return clip;
#endif
var newClip = new AnimationClip();
newClip.name = "rebased " + clip.name;

Expand Down
4 changes: 4 additions & 0 deletions Editor/Utils/Utils.VRCSDK.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using VRC.Dynamics;
Expand Down Expand Up @@ -25,5 +26,8 @@ public static IEnumerable<Transform> GetAffectedTransforms(this VRCPhysBoneBase
queue.Enqueue(child);
}
}

// https://creators.vrchat.com/avatars/#proxy-animations
public static bool IsProxy(this AnimationClip clip) => clip.name.StartsWith("proxy_", StringComparison.Ordinal);
}
}

0 comments on commit aa3fcf8

Please sign in to comment.