Skip to content

Commit

Permalink
chore: unexpose animation context for now
Browse files Browse the repository at this point in the history
This API is still a bit unstable; it'll probably be added in a future release.
  • Loading branch information
bdunderscore committed Sep 24, 2023
1 parent 6332825 commit c9c9701
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using nadena.dev.ndmf;
using nadena.dev.ndmf.animation;
using nadena.dev.modular_avatar.animation;
using NUnit.Framework;
using UnityEditor;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Linq;
using nadena.dev.ndmf.animation;
using nadena.dev.modular_avatar.animation;
using NUnit.Framework;
using UnityEditor;
using UnityEditor.Animations;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.Linq;
using nadena.dev.ndmf.animation;
using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System;
using nadena.dev.ndmf.animation;
using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor;
using nadena.dev.modular_avatar.editor.ErrorReporting;
Expand Down
2 changes: 1 addition & 1 deletion Assets/_ModularAvatar/EditModeTests/RetargetMeshesTest.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using nadena.dev.ndmf.animation;
using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework;
using UnityEngine;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
using System;
#region

using System;
using System.Collections.Generic;
using nadena.dev.ndmf;
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
using VRC.SDK3.Avatars.Components;

namespace nadena.dev.ndmf.animation
#endregion

namespace nadena.dev.modular_avatar.animation
{
public static class AnimationUtil
internal static class AnimationUtil
{
private const string SAMPLE_PATH_PACKAGE =
"Packages/com.vrchat.avatars/Samples/AV3 Demo Assets/Animation/Controllers";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,22 @@
* SOFTWARE.
*/

#region

using System;
using System.Collections.Generic;
using System.Linq;
using nadena.dev.ndmf.util;
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
using VRC.SDK3.Avatars.Components;
using Object = UnityEngine.Object;

namespace nadena.dev.ndmf.animation
#endregion

namespace nadena.dev.modular_avatar.animation
{
public class AnimatorCombiner
internal class AnimatorCombiner
{
private readonly AnimatorController _combined;
private bool isSaved;
Expand All @@ -56,7 +59,7 @@ public class AnimatorCombiner

private int controllerBaseLayer = 0;

public AnimatorCombiner(String assetName, UnityEngine.Object assetContainer)
public AnimatorCombiner(String assetName, Object assetContainer)
{
_combined = new AnimatorController();
if (assetContainer != null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
namespace nadena.dev.ndmf.animation
#region

using nadena.dev.ndmf;

#endregion

namespace nadena.dev.modular_avatar.animation
{
/// <summary>
/// This interface tags components which supply additional animation controllers for merging. They will be given
/// an opportunity to apply animation path updates when the TrackObjectRenamesContext is committed.
/// </summary>
public interface IOnCommitObjectRenames
internal interface IOnCommitObjectRenames
{
void OnCommitObjectRenames(BuildContext buildContext, TrackObjectRenamesContext renameContext);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,33 @@
using System;
#region

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using nadena.dev.ndmf;
using nadena.dev.ndmf.util;
using UnityEditor;
using UnityEditor.Animations;
using UnityEngine;
using VRC.Core;
using VRC.SDK3.Avatars.Components;
using Object = UnityEngine.Object;

#endregion

namespace nadena.dev.ndmf.animation
namespace nadena.dev.modular_avatar.animation
{
using UnityObject = UnityEngine.Object;
#region

using UnityObject = Object;

#endregion

/// <summary>
/// This extension context tracks when objects are renamed, and updates animations accordingly.
/// Users of this context need to be aware that, when creating new curves (or otherwise introducing new motions,
/// use context.ObjectPath to obtain a suitable path for the target objects).
/// </summary>
public sealed class TrackObjectRenamesContext : IExtensionContext
internal sealed class TrackObjectRenamesContext : IExtensionContext
{
private Dictionary<GameObject, List<string>>
_objectToOriginalPaths = new Dictionary<GameObject, List<string>>();
Expand Down
13 changes: 7 additions & 6 deletions Packages/nadena.dev.modular-avatar/Editor/MergeArmatureHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using nadena.dev.ndmf.animation;
using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.editor.ErrorReporting;
using UnityEditor;
using UnityEngine;
Expand Down Expand Up @@ -422,24 +422,25 @@ private void RecursiveMerge(ModularAvatarMergeArmature config,
&& (
Vector3.SqrMagnitude(mergedSrcBone.transform.localScale - src.transform.localScale) > 0.00001f
|| Quaternion.Angle(mergedSrcBone.transform.localRotation, src.transform.localRotation) > 0.00001f
|| Vector3.SqrMagnitude(mergedSrcBone.transform.localPosition - src.transform.localPosition) > 0.00001f
|| Vector3.SqrMagnitude(mergedSrcBone.transform.localPosition - src.transform.localPosition) >
0.00001f
)
&& src.GetComponent<IConstraint>() != null
)
)
{
// Constraints are sensitive to changes in local reference frames in some cases. In this case we'll
// inject a dummy object in between in order to retain the local parent scale of the retargeted bone.
var objName = src.gameObject.name + "$ConstraintRef " + Guid.NewGuid();

var constraintScaleRef = new GameObject(objName);
constraintScaleRef.transform.SetParent(src.transform.parent);
constraintScaleRef.transform.localPosition = Vector3.zero;
constraintScaleRef.transform.localRotation = Quaternion.identity;
constraintScaleRef.transform.localScale = Vector3.one;

constraintScaleRef.transform.SetParent(newParent.transform, true);
mergedSrcBone = constraintScaleRef;

BoneDatabase.AddMergedBone(mergedSrcBone.transform);
BoneDatabase.RetainMergedBone(mergedSrcBone.transform);
PathMappings.MarkTransformLookthrough(mergedSrcBone);
Expand Down
4 changes: 2 additions & 2 deletions Packages/nadena.dev.modular-avatar/Editor/MeshRetargeter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using nadena.dev.ndmf.animation;
using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.editor.ErrorReporting;
using UnityEngine;

Expand Down Expand Up @@ -252,7 +252,7 @@ private void RetargetBones()
dst.bindposes = newBindPoses;
renderer.sharedMesh = dst;
}

var newRootBone = _boneDatabase.GetRetargetedBone(rootBone, true);
if (newRootBone == null)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.editor.ErrorReporting;
using nadena.dev.ndmf;
using nadena.dev.ndmf.animation;
using nadena.dev.ndmf.fluent;
using UnityEngine;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using nadena.dev.ndmf.animation;
using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.editor.ErrorReporting;
using UnityEditor;
using UnityEngine;
Expand Down

0 comments on commit c9c9701

Please sign in to comment.