diff --git a/Editor/Utils/Utils.VRCSDK.cs b/Editor/Utils/Utils.VRCSDK.cs new file mode 100644 index 000000000..bc4a82af1 --- /dev/null +++ b/Editor/Utils/Utils.VRCSDK.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using UnityEngine; +using VRC.Dynamics; + +namespace Anatawa12.AvatarOptimizer +{ + partial class Utils + { + public static Transform GetTarget(this VRCPhysBoneBase physBoneBase) => + physBoneBase.rootTransform ? physBoneBase.rootTransform : physBoneBase.transform; + + public static IEnumerable GetAffectedTransforms(this VRCPhysBoneBase physBoneBase) + { + var ignores = new HashSet(physBoneBase.ignoreTransforms); + var queue = new Queue(); + queue.Enqueue(physBoneBase.GetTarget()); + + while (queue.Count != 0) + { + var transform = queue.Dequeue(); + yield return transform; + + foreach (var child in transform.DirectChildrenEnumerable()) + if (!ignores.Contains(child)) + queue.Enqueue(child); + } + } + } +} \ No newline at end of file diff --git a/Editor/Utils/Utils.VRCSDK.cs.meta b/Editor/Utils/Utils.VRCSDK.cs.meta new file mode 100644 index 000000000..fcc751ec4 --- /dev/null +++ b/Editor/Utils/Utils.VRCSDK.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 456c4b01ce34433d8ca9cc8bb6f0902c +timeCreated: 1698634433 \ No newline at end of file diff --git a/Editor/Utils/Utils.cs b/Editor/Utils/Utils.cs index db5f345a0..e664dbf6a 100644 --- a/Editor/Utils/Utils.cs +++ b/Editor/Utils/Utils.cs @@ -75,28 +75,6 @@ public static T GetOrAddComponent(this GameObject go) where T : Component return component; } -#if AAO_VRCSDK3_AVATARS - public static Transform GetTarget(this VRC.Dynamics.VRCPhysBoneBase physBoneBase) => - physBoneBase.rootTransform ? physBoneBase.rootTransform : physBoneBase.transform; - - public static IEnumerable GetAffectedTransforms(this VRC.Dynamics.VRCPhysBoneBase physBoneBase) - { - var ignores = new HashSet(physBoneBase.ignoreTransforms); - var queue = new Queue(); - queue.Enqueue(physBoneBase.GetTarget()); - - while (queue.Count != 0) - { - var transform = queue.Dequeue(); - yield return transform; - - foreach (var child in transform.DirectChildrenEnumerable()) - if (!ignores.Contains(child)) - queue.Enqueue(child); - } - } -#endif - public static GameObject NewGameObject(string name, Transform parent) { var rootObject = new GameObject(name);