Merge branch 'main' of github.com:JLChnToZ/modular-avatar

This commit is contained in:
JLChnToZ 2024-10-30 22:37:21 +08:00
commit 91b4414e60
31 changed files with 176 additions and 51 deletions

View File

@ -158,6 +158,7 @@ namespace nadena.dev.modular_avatar.animation
#if MA_VRCSDK3_AVATARS #if MA_VRCSDK3_AVATARS
var avatarDescriptor = context.AvatarDescriptor; var avatarDescriptor = context.AvatarDescriptor;
if (!avatarDescriptor) return;
foreach (var layer in avatarDescriptor.baseAnimationLayers) foreach (var layer in avatarDescriptor.baseAnimationLayers)
{ {

View File

@ -92,6 +92,8 @@ namespace nadena.dev.modular_avatar.animation
public void AddPropertyDefinition(AnimatorControllerParameter paramDef) public void AddPropertyDefinition(AnimatorControllerParameter paramDef)
{ {
#if MA_VRCSDK3_AVATARS #if MA_VRCSDK3_AVATARS
if (!_context.AvatarDescriptor) return;
var fx = (AnimatorController) var fx = (AnimatorController)
_context.AvatarDescriptor.baseAnimationLayers _context.AvatarDescriptor.baseAnimationLayers
.First(l => l.type == VRCAvatarDescriptor.AnimLayerType.FX) .First(l => l.type == VRCAvatarDescriptor.AnimLayerType.FX)

View File

@ -53,6 +53,8 @@ namespace nadena.dev.modular_avatar.animation
// This helps reduce the risk that we'll accidentally modify the original assets. // This helps reduce the risk that we'll accidentally modify the original assets.
#if MA_VRCSDK3_AVATARS #if MA_VRCSDK3_AVATARS
if (!context.AvatarDescriptor) return;
context.AvatarDescriptor.baseAnimationLayers = context.AvatarDescriptor.baseAnimationLayers =
CloneLayers(context, context.AvatarDescriptor.baseAnimationLayers); CloneLayers(context, context.AvatarDescriptor.baseAnimationLayers);
context.AvatarDescriptor.specialAnimationLayers = context.AvatarDescriptor.specialAnimationLayers =

View File

@ -369,6 +369,8 @@ namespace nadena.dev.modular_avatar.animation
Profiler.EndSample(); Profiler.EndSample();
#if MA_VRCSDK3_AVATARS #if MA_VRCSDK3_AVATARS
if (context.AvatarDescriptor)
{
var layers = context.AvatarDescriptor.baseAnimationLayers var layers = context.AvatarDescriptor.baseAnimationLayers
.Concat(context.AvatarDescriptor.specialAnimationLayers); .Concat(context.AvatarDescriptor.specialAnimationLayers);
@ -384,6 +386,7 @@ namespace nadena.dev.modular_avatar.animation
ApplyMappingsToAvatarMask(acLayer.avatarMask); ApplyMappingsToAvatarMask(acLayer.avatarMask);
} }
Profiler.EndSample(); Profiler.EndSample();
}
#endif #endif
Profiler.EndSample(); Profiler.EndSample();

View File

@ -19,6 +19,8 @@ namespace nadena.dev.modular_avatar.core.editor
internal static void FixupExpressionsMenu(BuildContext context) internal static void FixupExpressionsMenu(BuildContext context)
{ {
if (!context.AvatarDescriptor) return;
context.AvatarDescriptor.customExpressions = true; context.AvatarDescriptor.customExpressions = true;
var expressionsMenu = context.AvatarDescriptor.expressionsMenu; var expressionsMenu = context.AvatarDescriptor.expressionsMenu;

View File

@ -65,6 +65,7 @@ namespace nadena.dev.modular_avatar.core.editor
mergeSessions.Clear(); mergeSessions.Clear();
var descriptor = avatarGameObject.GetComponent<VRCAvatarDescriptor>(); var descriptor = avatarGameObject.GetComponent<VRCAvatarDescriptor>();
if (!descriptor) return;
if (descriptor.baseAnimationLayers != null) InitSessions(descriptor.baseAnimationLayers); if (descriptor.baseAnimationLayers != null) InitSessions(descriptor.baseAnimationLayers);
if (descriptor.specialAnimationLayers != null) InitSessions(descriptor.specialAnimationLayers); if (descriptor.specialAnimationLayers != null) InitSessions(descriptor.specialAnimationLayers);

View File

@ -11,7 +11,19 @@ namespace nadena.dev.modular_avatar.core
{ {
private static ComputeContext _context; private static ComputeContext _context;
private static PrefabStage _lastStage; private static int? _lastStage;
private static int? GetCurrentContentsRootId(out GameObject contentsRoot)
{
contentsRoot = null;
var stage = PrefabStageUtility.GetCurrentPrefabStage();
if (stage == null || stage.prefabContentsRoot == null) return null;
contentsRoot = stage.prefabContentsRoot;
return stage.prefabContentsRoot.GetInstanceID();
}
[InitializeOnLoadMethod] [InitializeOnLoadMethod]
private static void Init() private static void Init()
@ -19,22 +31,31 @@ namespace nadena.dev.modular_avatar.core
EditorApplication.delayCall += ProcessObjectReferences; EditorApplication.delayCall += ProcessObjectReferences;
EditorApplication.update += () => EditorApplication.update += () =>
{ {
if (PrefabStageUtility.GetCurrentPrefabStage() != _lastStage) _context?.Invalidate?.Invoke(); var curStage = GetCurrentContentsRootId(out _);
Debug.Log($"{_lastStage} => {curStage}");
if (curStage != _lastStage)
{
_context?.Invalidate?.Invoke();
}
}; };
} }
private static void ProcessObjectReferences() private static void ProcessObjectReferences()
{ {
_lastStage = PrefabStageUtility.GetCurrentPrefabStage(); _lastStage = GetCurrentContentsRootId(out var contentsRoot);
AvatarObjectReference.InvalidateAll();
_context = new ComputeContext("ObjectReferenceFixer"); _context = new ComputeContext("ObjectReferenceFixer");
_context.InvokeOnInvalidate<object>(typeof(ObjectReferenceFixer), _ => ProcessObjectReferences()); _context.InvokeOnInvalidate<object>(typeof(ObjectReferenceFixer), _ => ProcessObjectReferences());
IEnumerable<IHaveObjReferences> withReferences = _context.GetComponentsByType<IHaveObjReferences>(); IEnumerable<IHaveObjReferences> withReferences = _context.GetComponentsByType<IHaveObjReferences>();
if (_lastStage != null) if (contentsRoot != null)
withReferences = withReferences =
withReferences.Concat( withReferences.Concat(
_context.GetComponentsInChildren<IHaveObjReferences>(_lastStage.prefabContentsRoot, true) _context.GetComponentsInChildren<IHaveObjReferences>(contentsRoot, true)
); );
foreach (var obj in withReferences) foreach (var obj in withReferences)
@ -56,10 +77,26 @@ namespace nadena.dev.modular_avatar.core
foreach (var (targetObject, referencePath, objRef) in references) foreach (var (targetObject, referencePath, objRef) in references)
{ {
if (targetObject == null) continue; var resolvedTarget = objRef.Get(component);
_context.ObservePath(targetObject.transform); if (objRef.Get(component) == null) continue;
if (targetObject == null)
{
Undo.RecordObject(component, "");
objRef.targetObject = resolvedTarget;
dirty = true;
}
else
{
// Direct object reference always wins in the event of a conflict.
resolvedTarget = targetObject;
}
if (!targetObject.transform.IsChildOf(avatar.transform)) continue; foreach (var t in _context.ObservePath(resolvedTarget.transform))
{
_context.Observe(t.gameObject, g => g.name);
}
if (!resolvedTarget.transform.IsChildOf(avatar.transform)) continue;
if (objRef.IsConsistent(avatar)) continue; if (objRef.IsConsistent(avatar)) continue;

View File

@ -9,6 +9,8 @@ namespace nadena.dev.modular_avatar.core.editor
{ {
protected override void Execute(ndmf.BuildContext context) protected override void Execute(ndmf.BuildContext context)
{ {
if (!context.AvatarDescriptor) return;
var expParams = context.AvatarDescriptor.expressionParameters; var expParams = context.AvatarDescriptor.expressionParameters;
if (expParams != null && context.IsTemporaryAsset(expParams)) if (expParams != null && context.IsTemporaryAsset(expParams))
{ {

View File

@ -34,6 +34,8 @@ namespace nadena.dev.modular_avatar.core.editor
internal void Execute() internal void Execute()
{ {
if (!context.AvatarDescriptor) return;
// Having a WD OFF layer after WD ON layers can break WD. We match the behavior of the existing states, // Having a WD OFF layer after WD ON layers can break WD. We match the behavior of the existing states,
// and if mixed, use WD ON to maximize compatibility. // and if mixed, use WD ON to maximize compatibility.
_writeDefaults = MergeAnimatorProcessor.ProbeWriteDefaults(FindFxController().animatorController as AnimatorController) ?? true; _writeDefaults = MergeAnimatorProcessor.ProbeWriteDefaults(FindFxController().animatorController as AnimatorController) ?? true;

View File

@ -159,6 +159,8 @@ namespace nadena.dev.modular_avatar.core.editor
public void OnPreprocessAvatar(GameObject avatar, BuildContext context) public void OnPreprocessAvatar(GameObject avatar, BuildContext context)
{ {
if (!context.AvatarDescriptor) return;
_context = context; _context = context;
var syncParams = WalkTree(avatar); var syncParams = WalkTree(avatar);

View File

@ -30,6 +30,11 @@ namespace nadena.dev.modular_avatar.core
} }
#endif #endif
internal static void InvalidateAll()
{
HIERARCHY_CHANGED_SEQ++;
}
public AvatarObjectReference Clone() public AvatarObjectReference Clone()
{ {
return new AvatarObjectReference return new AvatarObjectReference

View File

@ -218,6 +218,8 @@ namespace nadena.dev.modular_avatar.core.ArmatureAwase
return; return;
} }
if (transform.parent == null) return;
var pos = transform.localPosition; var pos = transform.localPosition;
var rot = transform.localRotation; var rot = transform.localRotation;
var scale = transform.localScale; var scale = transform.localScale;

View File

@ -1,4 +1,6 @@
using nadena.dev.modular_avatar.core.editor; #if MA_VRCSDK3_AVATARS
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework; using NUnit.Framework;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@ -37,3 +39,5 @@ namespace modular_avatar_tests
} }
} }
} }
#endif

View File

@ -1,4 +1,6 @@
using System; #if MA_VRCSDK3_AVATARS
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using nadena.dev.ndmf; using nadena.dev.ndmf;
@ -159,3 +161,5 @@ namespace modular_avatar_tests
} }
} }
} }
#endif

View File

@ -1,4 +1,6 @@
using System.Linq; #if MA_VRCSDK3_AVATARS
using System.Linq;
using nadena.dev.ndmf; using nadena.dev.ndmf;
using NUnit.Framework; using NUnit.Framework;
using UnityEditor.Animations; using UnityEditor.Animations;
@ -27,3 +29,5 @@ namespace modular_avatar_tests
} }
} }
} }
#endif

View File

@ -1,9 +1,10 @@
using nadena.dev.modular_avatar.core.editor; #if MA_VRCSDK3_AVATARS_3_5_2_OR_NEWER
using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework; using NUnit.Framework;
using UnityEditor.Animations; using UnityEditor.Animations;
using VRC.SDK3.Avatars.Components; using VRC.SDK3.Avatars.Components;
#if MA_VRCSDK3_AVATARS_3_5_2_OR_NEWER
namespace modular_avatar_tests namespace modular_avatar_tests
{ {
public class PlayAudioRemapping : TestBase public class PlayAudioRemapping : TestBase
@ -28,4 +29,5 @@ namespace modular_avatar_tests
} }
} }
} }
#endif #endif

View File

@ -1,4 +1,6 @@
using modular_avatar_tests; #if MA_VRCSDK3_AVATARS
using modular_avatar_tests;
using nadena.dev.modular_avatar.animation; using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.core; using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor; using nadena.dev.modular_avatar.core.editor;
@ -48,3 +50,5 @@ namespace UnitTests.MergeAnimatorTests
} }
} }
} }
#endif

View File

@ -1,3 +1,5 @@
#if MA_VRCSDK3_AVATARS
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq; using System.Linq;
@ -35,3 +37,4 @@ public class PreexistingParamsTest : TestBase
} }
} }
#endif

View File

@ -1,4 +1,6 @@
using modular_avatar_tests; #if MA_VRCSDK3_AVATARS
using modular_avatar_tests;
using nadena.dev.modular_avatar.core; using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor; using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework; using NUnit.Framework;
@ -26,3 +28,5 @@ namespace UnitTests.MergeAnimatorTests.ProxyAnim
} }
} }
} }
#endif

View File

@ -1,4 +1,6 @@
using modular_avatar_tests; #if MA_VRCSDK3_AVATARS
using modular_avatar_tests;
using nadena.dev.ndmf; using nadena.dev.ndmf;
using NUnit.Framework; using NUnit.Framework;
using UnityEditor.Animations; using UnityEditor.Animations;
@ -39,3 +41,5 @@ namespace UnitTests.MergeAnimatorTests.SyncedLayerOverrideInSubStatemachine
} }
} }
} }
#endif

View File

@ -1,3 +1,5 @@
#if MA_VRCSDK3_AVATARS
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Linq; using System.Linq;
@ -268,3 +270,4 @@ public class ConvertTransitionTypes : TestBase
} }
} }
#endif

View File

@ -1,3 +1,5 @@
#if MA_VRCSDK3_AVATARS
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
@ -24,3 +26,5 @@ public class MergeDirectBlendTreeTests : TestBase
Assert.AreEqual(0, parameters["DEF"]); Assert.AreEqual(0, parameters["DEF"]);
} }
} }
#endif

View File

@ -1,4 +1,6 @@
using System.Linq; #if MA_VRCSDK3_AVATARS
using System.Linq;
using modular_avatar_tests; using modular_avatar_tests;
using nadena.dev.modular_avatar.core.editor; using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework; using NUnit.Framework;
@ -59,3 +61,5 @@ namespace UnitTests.ReactiveComponent
} }
} }
} }
#endif

View File

@ -1,4 +1,6 @@
using System.Linq; #if MA_VRCSDK3_AVATARS
using System.Linq;
using modular_avatar_tests; using modular_avatar_tests;
using nadena.dev.modular_avatar.core; using nadena.dev.modular_avatar.core;
using nadena.dev.modular_avatar.core.editor; using nadena.dev.modular_avatar.core.editor;
@ -48,3 +50,5 @@ namespace UnitTests.ReactiveComponent
} }
} }
} }
#endif

View File

@ -1,4 +1,6 @@
using System; #if MA_VRCSDK3_AVATARS
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using modular_avatar_tests; using modular_avatar_tests;
@ -113,3 +115,5 @@ namespace UnitTests.ReactiveComponent.ParameterAssignment
} }
} }
} }
#endif

View File

@ -1,4 +1,6 @@
using System; #if MA_VRCSDK3_AVATARS
using System;
using System.Linq; using System.Linq;
using modular_avatar_tests; using modular_avatar_tests;
using nadena.dev.modular_avatar.core; using nadena.dev.modular_avatar.core;
@ -83,3 +85,5 @@ namespace UnitTests.ReactiveComponent.ParameterAssignment
} }
} }
} }
#endif

View File

@ -1,3 +1,5 @@
#if MA_VRCSDK3_AVATARS
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -96,3 +98,5 @@ public class ShapeDeletionAnalysis : TestBase
Assert.AreEqual(originalSharedMesh, mesh.sharedMesh); Assert.AreEqual(originalSharedMesh, mesh.sharedMesh);
} }
} }
#endif

View File

@ -1,4 +1,6 @@
using modular_avatar_tests; #if MA_VRCSDK3_AVATARS
using modular_avatar_tests;
using nadena.dev.modular_avatar.animation; using nadena.dev.modular_avatar.animation;
using nadena.dev.modular_avatar.core.editor; using nadena.dev.modular_avatar.core.editor;
using NUnit.Framework; using NUnit.Framework;
@ -122,3 +124,5 @@ namespace ShapeChangerTests
} }
} }
} }
#endif

View File

@ -1,4 +1,6 @@
using System.Collections.Generic; #if MA_VRCSDK3_AVATARS
using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
using System.Diagnostics.CodeAnalysis; using System.Diagnostics.CodeAnalysis;
using System.Linq; using System.Linq;
@ -58,3 +60,5 @@ namespace UnitTests.VisibleHeadAccessoryTest
} }
} }
} }
#endif

View File

@ -28,7 +28,7 @@ Mesh Settingsコンポーネントを使用すると、特定のゲームオブ
- 継承このコンポーネントはこの設定に対して何もしません。親のMesh Settingsで設定された値を継承します。 - 継承このコンポーネントはこの設定に対して何もしません。親のMesh Settingsで設定された値を継承します。
- 設定:このコンポーネントは、そのゲームオブジェクトとその子にあるメッシュの対応する設定を設定します。 - 設定:このコンポーネントは、そのゲームオブジェクトとその子にあるメッシュの対応する設定を設定します。
- 設定しないこのコンポーネントは、親のMesh Settingsの影響を受けないようにします。メッシュはデフォルトの設定のままです。 - 設定しないこのコンポーネントは、親のMesh Settingsの影響を受けないようにします。メッシュはデフォルトの設定のままです。
- 親が継承された時は継承、または設定親のMesh Settingsが設定モードにある場合、それが使用されます。親のMesh - 親が継承された時は継承、それ以外では設定親のMesh Settingsが設定モードにある場合、それが使用されます。親のMesh
Settingsが適用されない場合、 Settingsが適用されない場合、
このコンポーネントの設定が使用されます。衣装プレハブなどに、アバター全体の設定が優先されるようにするために便利です。 このコンポーネントの設定が使用されます。衣装プレハブなどに、アバター全体の設定が優先されるようにするために便利です。

View File

@ -6378,8 +6378,8 @@ __metadata:
linkType: hard linkType: hard
"http-proxy-middleware@npm:^2.0.3": "http-proxy-middleware@npm:^2.0.3":
version: 2.0.6 version: 2.0.7
resolution: "http-proxy-middleware@npm:2.0.6" resolution: "http-proxy-middleware@npm:2.0.7"
dependencies: dependencies:
"@types/http-proxy": ^1.17.8 "@types/http-proxy": ^1.17.8
http-proxy: ^1.18.1 http-proxy: ^1.18.1
@ -6391,7 +6391,7 @@ __metadata:
peerDependenciesMeta: peerDependenciesMeta:
"@types/express": "@types/express":
optional: true optional: true
checksum: 2ee85bc878afa6cbf34491e972ece0f5be0a3e5c98a60850cf40d2a9a5356e1fc57aab6cff33c1fc37691b0121c3a42602d2b1956c52577e87a5b77b62ae1c3a checksum: 18caa21145917aa1054740353916e8f03f5a3a93bede9106f1f44d84f7b174df17af1c72bf5fade5cc440c2058ee813f47cbb2bdd6ae6874af1cf33e0ac575f3
languageName: node languageName: node
linkType: hard linkType: hard