Fixed blendShapeCopy before normalize for mesh without boneWeight

This commit is contained in:
ousttrue
2018-08-03 14:55:55 +09:00
parent 5a4488a5e6
commit 6fe746b08d
4 changed files with 98 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ namespace VRM
{
public static class MeshExtensions
{
public static Mesh Copy(this Mesh src)
public static Mesh Copy(this Mesh src, bool copyBlendShape)
{
var dst = new Mesh();
dst.name = src.name + "(copy)";
@@ -33,6 +33,24 @@ namespace VRM
dst.RecalculateBounds();
if (copyBlendShape)
{
var vertices = src.vertices;
var normals = src.normals;
var tangents = src.tangents.Select(x => (Vector3)x).ToArray();
for (int i = 0; i < src.blendShapeCount; ++i)
{
src.GetBlendShapeFrameVertices(i, 0, vertices, normals, tangents);
dst.AddBlendShapeFrame(
src.GetBlendShapeName(i),
src.GetBlendShapeFrameWeight(i, 0),
vertices,
normals,
tangents
);
}
}
return dst;
}