From a13258785f63cd733a3f177512b2a82d5231d613 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Thu, 15 Apr 2021 19:26:15 +0900 Subject: [PATCH] =?UTF-8?q?VRM10SpringBone=20=E3=82=92=20SpringBone=20?= =?UTF-8?q?=E3=81=AB=E3=81=97=E3=81=9F=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/Components/SpringBone/VRM10SpringBone.cs | 9 ++++++++- .../SpringBone/VRM10SpringBoneColliderGroup.cs | 1 - Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBone.cs b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBone.cs index ee75cabbe..f834791c5 100644 --- a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBone.cs +++ b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBone.cs @@ -8,9 +8,16 @@ namespace UniVRM10 /// /// The base algorithm is http://rocketjump.skr.jp/unity3d/109/ of @ricopin416 /// DefaultExecutionOrder(11000) means calculate springbone after FinalIK( VRIK ) + /// + /// Setup の Editor の都合から、VRM10SpringBone は MonoBehaviour にする。 + /// Data置き場。Updateは使わない。 + /// + /// Springの根元のTranform (Joints.First()) に AddComponent して使う。 + /// /// + [DisallowMultipleComponent] [Serializable] - public class VRM10SpringBone + public class VRM10SpringBone : MonoBehaviour { [SerializeField] public string Comment; diff --git a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroup.cs b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroup.cs index 2fb4e3a58..149f59bde 100644 --- a/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroup.cs +++ b/Assets/VRM10/Runtime/Components/SpringBone/VRM10SpringBoneColliderGroup.cs @@ -7,7 +7,6 @@ namespace UniVRM10 /// /// VRMC_node_collider /// - [DisallowMultipleComponent] [AddComponentMenu("VRM10/VRM10SpringBoneColliderGroup")] public class VRM10SpringBoneColliderGroup : MonoBehaviour { diff --git a/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs b/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs index f5c4dd71d..926e02826 100644 --- a/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs +++ b/Assets/VRM10/Runtime/IO/RuntimeUnityBuilder.cs @@ -353,7 +353,12 @@ namespace UniVRM10 { foreach (var gltfSpring in gltfVrmSpringBone.Springs) { - var springBone = new VRM10SpringBone(); + if (gltfSpring.Joints == null || gltfSpring.Joints.Count == 0) + { + continue; + } + var firstJointNode = Nodes[gltfSpring.Joints.First().Node.Value]; + var springBone = firstJointNode.gameObject.AddComponent(); springBone.Comment = gltfSpring.Name; // joint