mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-08 03:48:19 -05:00
Fixed blendShapeCopy before normalize for mesh without boneWeight
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user