From c9c9701e1d5f545ac92ec0e9208c1d9eb5ba9cda Mon Sep 17 00:00:00 2001 From: bd_ Date: Sun, 24 Sep 2023 14:37:10 +0900 Subject: [PATCH] chore: unexpose animation context for now This API is still a bit unstable; it'll probably be added in a future release. --- .../Animation/MiscAnimationTests.cs | 2 +- .../TrackObjectRenamesContextTests.cs | 2 +- .../MergeArmatureTests/MultiLevelMergeTest.cs | 2 +- .../ReplaceObject/ReplaceObjectTests.cs | 2 +- .../EditModeTests/RetargetMeshesTest.cs | 2 +- .../Editor/Animation/AnimationUtil.cs | 11 ++++++++--- .../Editor/Animation/AnimatorCombiner.cs | 11 +++++++---- .../Animation/IOnCommitObjectRenames.cs | 10 ++++++++-- .../Animation/TrackObjectRenamesContext.cs | 19 ++++++++++++++----- .../Editor/MergeArmatureHook.cs | 13 +++++++------ .../Editor/MeshRetargeter.cs | 4 ++-- .../PluginDefinition/PluginDefinition.cs | 2 +- .../Editor/ReplaceObjectPass.cs | 2 +- Packages/nadena.dev.ndmf | 2 +- 14 files changed, 54 insertions(+), 30 deletions(-) diff --git a/Assets/_ModularAvatar/EditModeTests/Animation/MiscAnimationTests.cs b/Assets/_ModularAvatar/EditModeTests/Animation/MiscAnimationTests.cs index 7e4a70ea..736c63d2 100644 --- a/Assets/_ModularAvatar/EditModeTests/Animation/MiscAnimationTests.cs +++ b/Assets/_ModularAvatar/EditModeTests/Animation/MiscAnimationTests.cs @@ -1,5 +1,5 @@ using nadena.dev.ndmf; -using nadena.dev.ndmf.animation; +using nadena.dev.modular_avatar.animation; using NUnit.Framework; using UnityEditor; diff --git a/Assets/_ModularAvatar/EditModeTests/Animation/TrackObjectRenamesContextTests.cs b/Assets/_ModularAvatar/EditModeTests/Animation/TrackObjectRenamesContextTests.cs index 88ba3fe4..80a39b99 100644 --- a/Assets/_ModularAvatar/EditModeTests/Animation/TrackObjectRenamesContextTests.cs +++ b/Assets/_ModularAvatar/EditModeTests/Animation/TrackObjectRenamesContextTests.cs @@ -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; diff --git a/Assets/_ModularAvatar/EditModeTests/MergeArmatureTests/MultiLevelMergeTest.cs b/Assets/_ModularAvatar/EditModeTests/MergeArmatureTests/MultiLevelMergeTest.cs index ff064040..832d8308 100644 --- a/Assets/_ModularAvatar/EditModeTests/MergeArmatureTests/MultiLevelMergeTest.cs +++ b/Assets/_ModularAvatar/EditModeTests/MergeArmatureTests/MultiLevelMergeTest.cs @@ -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; diff --git a/Assets/_ModularAvatar/EditModeTests/ReplaceObject/ReplaceObjectTests.cs b/Assets/_ModularAvatar/EditModeTests/ReplaceObject/ReplaceObjectTests.cs index 52a75087..98da7713 100644 --- a/Assets/_ModularAvatar/EditModeTests/ReplaceObject/ReplaceObjectTests.cs +++ b/Assets/_ModularAvatar/EditModeTests/ReplaceObject/ReplaceObjectTests.cs @@ -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; diff --git a/Assets/_ModularAvatar/EditModeTests/RetargetMeshesTest.cs b/Assets/_ModularAvatar/EditModeTests/RetargetMeshesTest.cs index d5759fa4..4481deb9 100644 --- a/Assets/_ModularAvatar/EditModeTests/RetargetMeshesTest.cs +++ b/Assets/_ModularAvatar/EditModeTests/RetargetMeshesTest.cs @@ -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; diff --git a/Packages/nadena.dev.modular-avatar/Editor/Animation/AnimationUtil.cs b/Packages/nadena.dev.modular-avatar/Editor/Animation/AnimationUtil.cs index 07c05bf3..8c4570b8 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/Animation/AnimationUtil.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/Animation/AnimationUtil.cs @@ -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"; diff --git a/Packages/nadena.dev.modular-avatar/Editor/Animation/AnimatorCombiner.cs b/Packages/nadena.dev.modular-avatar/Editor/Animation/AnimatorCombiner.cs index ebd1784b..156973d0 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/Animation/AnimatorCombiner.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/Animation/AnimatorCombiner.cs @@ -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; @@ -56,7 +59,7 @@ namespace nadena.dev.ndmf.animation private int controllerBaseLayer = 0; - public AnimatorCombiner(String assetName, UnityEngine.Object assetContainer) + public AnimatorCombiner(String assetName, Object assetContainer) { _combined = new AnimatorController(); if (assetContainer != null) diff --git a/Packages/nadena.dev.modular-avatar/Editor/Animation/IOnCommitObjectRenames.cs b/Packages/nadena.dev.modular-avatar/Editor/Animation/IOnCommitObjectRenames.cs index 64fa78c4..b7578946 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/Animation/IOnCommitObjectRenames.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/Animation/IOnCommitObjectRenames.cs @@ -1,10 +1,16 @@ -namespace nadena.dev.ndmf.animation +#region + +using nadena.dev.ndmf; + +#endregion + +namespace nadena.dev.modular_avatar.animation { /// /// 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. /// - public interface IOnCommitObjectRenames + internal interface IOnCommitObjectRenames { void OnCommitObjectRenames(BuildContext buildContext, TrackObjectRenamesContext renameContext); } diff --git a/Packages/nadena.dev.modular-avatar/Editor/Animation/TrackObjectRenamesContext.cs b/Packages/nadena.dev.modular-avatar/Editor/Animation/TrackObjectRenamesContext.cs index 88cb808d..1992f432 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/Animation/TrackObjectRenamesContext.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/Animation/TrackObjectRenamesContext.cs @@ -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; -namespace nadena.dev.ndmf.animation +#endregion + +namespace nadena.dev.modular_avatar.animation { - using UnityObject = UnityEngine.Object; + #region + + using UnityObject = Object; + + #endregion /// /// 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). /// - public sealed class TrackObjectRenamesContext : IExtensionContext + internal sealed class TrackObjectRenamesContext : IExtensionContext { private Dictionary> _objectToOriginalPaths = new Dictionary>(); diff --git a/Packages/nadena.dev.modular-avatar/Editor/MergeArmatureHook.cs b/Packages/nadena.dev.modular-avatar/Editor/MergeArmatureHook.cs index 4f7d19e8..663de664 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/MergeArmatureHook.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/MergeArmatureHook.cs @@ -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; @@ -422,24 +422,25 @@ namespace nadena.dev.modular_avatar.core.editor && ( 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() != 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); diff --git a/Packages/nadena.dev.modular-avatar/Editor/MeshRetargeter.cs b/Packages/nadena.dev.modular-avatar/Editor/MeshRetargeter.cs index ba7cecc3..2eb54555 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/MeshRetargeter.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/MeshRetargeter.cs @@ -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; @@ -252,7 +252,7 @@ namespace nadena.dev.modular_avatar.core.editor dst.bindposes = newBindPoses; renderer.sharedMesh = dst; } - + var newRootBone = _boneDatabase.GetRetargetedBone(rootBone, true); if (newRootBone == null) { diff --git a/Packages/nadena.dev.modular-avatar/Editor/PluginDefinition/PluginDefinition.cs b/Packages/nadena.dev.modular-avatar/Editor/PluginDefinition/PluginDefinition.cs index 7b7adea5..3be05e17 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/PluginDefinition/PluginDefinition.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/PluginDefinition/PluginDefinition.cs @@ -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; diff --git a/Packages/nadena.dev.modular-avatar/Editor/ReplaceObjectPass.cs b/Packages/nadena.dev.modular-avatar/Editor/ReplaceObjectPass.cs index 86163a3d..a14c7fa7 100644 --- a/Packages/nadena.dev.modular-avatar/Editor/ReplaceObjectPass.cs +++ b/Packages/nadena.dev.modular-avatar/Editor/ReplaceObjectPass.cs @@ -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; diff --git a/Packages/nadena.dev.ndmf b/Packages/nadena.dev.ndmf index f6caa431..d1cbaa4a 160000 --- a/Packages/nadena.dev.ndmf +++ b/Packages/nadena.dev.ndmf @@ -1 +1 @@ -Subproject commit f6caa431ab9c8e6071edfc0ac75595519161b9e2 +Subproject commit d1cbaa4aabd87b006b6e858de2a64192be5e42e9