diff --git a/Scripts/Format/VRMVersion.cs b/Scripts/Format/VRMVersion.cs index 08bf74be2..3d4a3dd0d 100644 --- a/Scripts/Format/VRMVersion.cs +++ b/Scripts/Format/VRMVersion.cs @@ -4,11 +4,11 @@ namespace VRM public static class VRMVersion { public const int MAJOR = 0; - public const int MINOR = 13; + public const int MINOR = 14; - public const string VERSION = "0.13"; + public const string VERSION = "0.14"; - public const string DecrementMenuName = "VRM/Version(0.13) Decrement"; - public const string IncrementMenuName = "VRM/Version(0.13) Increment"; + public const string DecrementMenuName = "VRM/Version(0.14) Decrement"; + public const string IncrementMenuName = "VRM/Version(0.14) Increment"; } } diff --git a/Scripts/SkinnedMeshUtility/Editor/BoneNormalizer.cs b/Scripts/SkinnedMeshUtility/Editor/BoneNormalizer.cs index c055eb70f..e12f30103 100644 --- a/Scripts/SkinnedMeshUtility/Editor/BoneNormalizer.cs +++ b/Scripts/SkinnedMeshUtility/Editor/BoneNormalizer.cs @@ -161,6 +161,7 @@ namespace VRM } mesh.boneWeights = srcMesh.boneWeights; + var meshVertices = mesh.vertices; var blendShapeMesh = new Mesh(); for (int i = 0; i < srcMesh.blendShapeCount; ++i) { @@ -168,22 +169,41 @@ namespace VRM srcRenderer.BakeMesh(blendShapeMesh); srcRenderer.SetBlendShapeWeight(i, 0); + if (blendShapeMesh.vertices.Length!=mesh.vertices.Length){ + throw new Exception("diffrent vertex count"); + } + + var weight = srcMesh.GetBlendShapeFrameWeight(i, 0); + var vertices = blendShapeMesh.vertices; + var normals = blendShapeMesh.normals; + var tangents = blendShapeMesh.tangents.Select(x => (Vector3)x).ToArray(); + + for (int j = 0; j < vertices.Length; ++j) { + vertices[j]= m.MultiplyPoint(vertices[j]) - meshVertices[j]; + } + for (int j = 0; j < normals.Length; ++j) + { + normals[j] = m.MultiplyVector(normals[j]).normalized; + } + for(int j=0; j m.MultiplyPoint(x) - mesh.vertices[j]).ToArray(), - blendShapeMesh.normals.Select(x => m.MultiplyVector(x).normalized).ToArray(), - blendShapeMesh.tangents.Select(x => m.MultiplyVector(x).normalized).ToArray() + vertices.Length == meshVertices.Length ? vertices : null, + normals.Length == meshVertices.Length ? normals : null, + tangents.Length == meshVertices.Length ? tangents : null ); } catch (Exception)