From fcd4a936f56e3dfe2c62ce280514bfe627d57825 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 16 Oct 2024 17:33:56 +0900 Subject: [PATCH 1/4] =?UTF-8?q?springbone=20=E3=81=8C=E7=84=A1=E3=81=84?= =?UTF-8?q?=E6=99=82=E3=81=AB=E5=88=9D=E6=9C=9F=E5=8C=96=E3=81=95=E3=82=8C?= =?UTF-8?q?=E3=81=9A=E3=81=AB=20NullReferenceException=20=E3=81=AB?= =?UTF-8?q?=E3=81=AA=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs | 6 +++++- .../Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs b/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs index 1a398c2a3..466976e55 100644 --- a/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs +++ b/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs @@ -22,10 +22,14 @@ namespace VRM SpringBoneJobs.FastSpringBoneService m_service; FastSpringBoneBuffer m_buffer; + public Vrm0XFastSpringboneRuntime() + { + m_service = SpringBoneJobs.FastSpringBoneService.Instance; + } + public async Task InitializeAsync(GameObject vrm, IAwaitCaller awaitCaller) { m_vrm = vrm; - m_service = SpringBoneJobs.FastSpringBoneService.Instance; // default update の停止 foreach (VRMSpringBone sb in vrm.GetComponentsInChildren()) diff --git a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs index 75793c5b1..9815287e1 100644 --- a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs +++ b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs @@ -19,6 +19,11 @@ namespace UniVRM10 private FastSpringBones.FastSpringBoneService m_fastSpringBoneService; private FastSpringBoneBuffer m_fastSpringBoneBuffer; + public Vrm10FastSpringboneRuntime() + { + m_fastSpringBoneService = FastSpringBones.FastSpringBoneService.Instance; + } + public void SetJointLevel(Transform joint, BlittableJointMutable jointSettings) { if (m_fastSpringBoneService.BufferCombiner.Combined is FastSpringBoneCombinedBuffer combined) @@ -37,7 +42,6 @@ namespace UniVRM10 public async Task InitializeAsync(Vrm10Instance instance, IAwaitCaller awaitCaller) { - m_fastSpringBoneService = FastSpringBones.FastSpringBoneService.Instance; m_instance = instance; // NOTE: FastSpringBoneService は UnitTest などでは動作しない From 6402d55a555ddab96d051bd13a76eff36e8e7553 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 16 Oct 2024 17:42:55 +0900 Subject: [PATCH 2/4] =?UTF-8?q?springbone=20=E3=81=AE=E7=84=A1=E3=81=84?= =?UTF-8?q?=E3=83=A2=E3=83=87=E3=83=AB=E3=81=A7=E3=81=AF=20null?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs index 9815287e1..1732f5669 100644 --- a/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs +++ b/Assets/VRM10/Runtime/Components/Vrm10Runtime/Vrm10FastSpringboneRuntime.cs @@ -53,8 +53,11 @@ namespace UniVRM10 public void Dispose() { - m_fastSpringBoneService.BufferCombiner.Unregister(m_fastSpringBoneBuffer); - m_fastSpringBoneBuffer.Dispose(); + if (m_fastSpringBoneBuffer != null) + { + m_fastSpringBoneService.BufferCombiner.Unregister(m_fastSpringBoneBuffer); + m_fastSpringBoneBuffer.Dispose(); + } } /// From d9177359b60a4f12a18fcc25fa5dadef55f9b089 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 16 Oct 2024 17:43:28 +0900 Subject: [PATCH 3/4] =?UTF-8?q?=E4=B8=8D=E8=A6=81=E3=80=82AddComponent=20?= =?UTF-8?q?=E3=81=AE=E3=81=A8=E3=81=93=E3=82=8D=E3=81=A7=E5=87=A6=E7=90=86?= =?UTF-8?q?=E6=B8=88=E3=81=BF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs b/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs index 466976e55..9d8c8e5a6 100644 --- a/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs +++ b/Assets/VRM/Runtime/SpringBone/Jobs/Vrm0XFastSpringBoneRuntime.cs @@ -73,9 +73,8 @@ namespace VRM public void ReconstructSpringBone() { - var disposer = m_vrm.gameObject.GetComponent(); Unregister(); - var task = RegisterAsync(new ImmediateCaller()); + var _ = RegisterAsync(new ImmediateCaller()); } public void RestoreInitialTransform() From e8f221aed8445ea6c1fe787ed313551348c0e83b Mon Sep 17 00:00:00 2001 From: ousttrue Date: Wed, 16 Oct 2024 18:18:36 +0900 Subject: [PATCH 4/4] =?UTF-8?q?VRMC=5FspringBone=20=E3=81=8C=E7=84=A1?= =?UTF-8?q?=E3=81=8F=E3=81=A6=E3=82=82=E5=88=9D=E6=9C=9F=E5=8C=96=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM10/Runtime/IO/Vrm10Importer.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index 0543f9f6c..dacfdedf7 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -286,14 +286,15 @@ namespace UniVRM10 if (UniGLTF.Extensions.VRMC_springBone.GltfDeserializer.TryGet(Data.GLTF.extensions, out UniGLTF.Extensions.VRMC_springBone.VRMC_springBone springBone)) { await LoadSpringBoneAsync(awaitCaller, controller, springBone); + } - if (Application.isPlaying) - { - // EditorImport では呼ばない - // Vrm10Runtime で初期化していたが、 async にするためこちらに移動 v0.127 - // RuntimeGltfInstance にアクセスしたいのだが OnLoadHierarchy ではまだ attach されてなかった v0.128 - await m_springboneRuntime.InitializeAsync(controller, awaitCaller); - } + if (Application.isPlaying) + { + // EditorImport では呼ばない + // Vrm10Runtime で初期化していたが、 async にするためこちらに移動 v0.127 + // RuntimeGltfInstance にアクセスしたいのだが OnLoadHierarchy ではまだ attach されてなかった v0.128 + // VRMC_springBone が無くても初期化する v0.127.2 + await m_springboneRuntime.InitializeAsync(controller, awaitCaller); } // constraint