From 0e826fbb14dfe2f2420e5fd34360bebd1462ca71 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 17 Jun 2022 16:50:33 +0900 Subject: [PATCH] =?UTF-8?q?boneWeight=20=E3=81=8C=E3=81=99=E3=81=B9?= =?UTF-8?q?=E3=81=A6=200=20=E3=81=AE=E3=81=A8=E3=81=8D=E3=81=AB=20Export?= =?UTF-8?q?=20=E3=81=97=E3=81=AA=E3=81=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MeshExporter_DividedVertexBuffer.cs | 4 +++ .../MeshIO/MeshExporter_SharedVertexBuffer.cs | 26 ++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_DividedVertexBuffer.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_DividedVertexBuffer.cs index f3b65e5f0..fac86a104 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_DividedVertexBuffer.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_DividedVertexBuffer.cs @@ -34,6 +34,10 @@ namespace UniGLTF var normals = mesh.normals; var uv = mesh.uv; var boneWeights = mesh.boneWeights; + if (boneWeights.All(x => x.weight0 == 0 && x.weight1 == 0 && x.weight2 == 0 && x.weight3 == 0)) + { + boneWeights = null; + } var colors = mesh.colors; Func getJointIndex = null; diff --git a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs index e1885be1f..6da415fcd 100644 --- a/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs +++ b/Assets/UniGLTF/Runtime/UniGLTF/IO/MeshIO/MeshExporter_SharedVertexBuffer.cs @@ -57,15 +57,23 @@ namespace UniGLTF colorAccessorIndex = data.ExtendBufferAndGetAccessorIndex(mesh.colors, glBufferTarget.ARRAY_BUFFER); } - var boneweights = mesh.boneWeights; - var weightAccessorIndex = data.ExtendBufferAndGetAccessorIndex(boneweights.Select(y => new Vector4(y.weight0, y.weight1, y.weight2, y.weight3)).ToArray(), glBufferTarget.ARRAY_BUFFER); - var jointsAccessorIndex = data.ExtendBufferAndGetAccessorIndex(boneweights.Select(y => - new UShort4( - (ushort)unityMesh.GetJointIndex(y.boneIndex0), - (ushort)unityMesh.GetJointIndex(y.boneIndex1), - (ushort)unityMesh.GetJointIndex(y.boneIndex2), - (ushort)unityMesh.GetJointIndex(y.boneIndex3)) - ).ToArray(), glBufferTarget.ARRAY_BUFFER); + var boneWeights = mesh.boneWeights; + var weightAccessorIndex = -1; + var jointsAccessorIndex = -1; + if (boneWeights.All(x => x.weight0 == 0 && x.weight1 == 0 && x.weight2 == 0 && x.weight3 == 0)) + { + } + else + { + weightAccessorIndex = data.ExtendBufferAndGetAccessorIndex(boneWeights.Select(y => new Vector4(y.weight0, y.weight1, y.weight2, y.weight3)).ToArray(), glBufferTarget.ARRAY_BUFFER); + jointsAccessorIndex = data.ExtendBufferAndGetAccessorIndex(boneWeights.Select(y => + new UShort4( + (ushort)unityMesh.GetJointIndex(y.boneIndex0), + (ushort)unityMesh.GetJointIndex(y.boneIndex1), + (ushort)unityMesh.GetJointIndex(y.boneIndex2), + (ushort)unityMesh.GetJointIndex(y.boneIndex3)) + ).ToArray(), glBufferTarget.ARRAY_BUFFER); + } var attributes = new glTFAttributes {