From f917b8f37288379a04cf483fea80fd6c8b78b9c7 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Mon, 6 Nov 2023 19:47:06 +0900 Subject: [PATCH] mesh empty --- .../Runtime/MeshUtility/MeshFreezer.cs | 4 ---- .../Runtime/MeshUtility/Vrm10MeshUtility.cs | 21 ++++++++++++++++++- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Assets/UniGLTF/Runtime/MeshUtility/MeshFreezer.cs b/Assets/UniGLTF/Runtime/MeshUtility/MeshFreezer.cs index 77ea08113..98c4f8af1 100644 --- a/Assets/UniGLTF/Runtime/MeshUtility/MeshFreezer.cs +++ b/Assets/UniGLTF/Runtime/MeshUtility/MeshFreezer.cs @@ -356,10 +356,6 @@ namespace UniGLTF.MeshUtility } } - if (report.Count > 0) - { - Debug.LogFormat("{0}", report.ToString()); - } // restore blendshape weights for (int i = 0; i < backcup.Count; ++i) { diff --git a/Assets/VRM10/Runtime/MeshUtility/Vrm10MeshUtility.cs b/Assets/VRM10/Runtime/MeshUtility/Vrm10MeshUtility.cs index 39614d2d9..6834557cb 100644 --- a/Assets/VRM10/Runtime/MeshUtility/Vrm10MeshUtility.cs +++ b/Assets/VRM10/Runtime/MeshUtility/Vrm10MeshUtility.cs @@ -152,6 +152,23 @@ namespace UniVRM10 } } + static GameObject GetOrCreateEmpty(GameObject go, string name) + { + foreach (var child in go.transform.GetChildren()) + { + if (child.name == name + && child.localPosition == Vector3.zero + && child.localScale == Vector3.one + && child.localRotation == Quaternion.identity) + { + return child.gameObject; + } + } + var empty = new GameObject(name); + empty.transform.SetParent(go.transform, false); + return empty; + } + public void Process(GameObject go) { var vrmInstance = go.GetComponent(); @@ -226,6 +243,8 @@ namespace UniVRM10 } { + var empty = GetOrCreateEmpty(go, "mesh"); + // TODO: UNDO var results = new List(); foreach (var group in copy) @@ -235,7 +254,7 @@ namespace UniVRM10 : MeshIntegrator.BlendShapeOperation.None); results.Add(result); - result.AddIntegratedRendererTo(go); + result.AddIntegratedRendererTo(empty); if (generateFirstPerson && group.Name == "auto") {