No access to mesh.vertices and mesh.normals and use the arrays around

This commit is contained in:
shino
2024-05-31 19:10:01 +09:00
parent 12df224409
commit d29adf0a9d

View File

@@ -166,10 +166,13 @@ namespace UniGLTF
var targetNames = new List<string>();
int exportBlendShapes = 0;
Vector3[] blendShapePositions = new Vector3[mesh.vertexCount];
Vector3[] blendShapeNormals = new Vector3[mesh.vertexCount];
for (int j = 0; j < unityMesh.Mesh.blendShapeCount; ++j)
{
var morphTarget = ExportMorphTarget(data,
unityMesh.Mesh, j,
blendShapePositions, blendShapeNormals,
settings.UseSparseAccessorForMorphTarget,
settings.ExportOnlyBlendShapePosition, axisInverter);
if (morphTarget.POSITION < 0)
@@ -214,14 +217,13 @@ namespace UniGLTF
static gltfMorphTarget ExportMorphTarget(ExportingGltfData data,
Mesh mesh, int blendShapeIndex,
Vector3[] blendShapeVertices, Vector3[] blendShapeNormals,
bool useSparseAccessorForMorphTarget,
bool exportOnlyBlendShapePosition,
IAxisInverter axisInverter)
{
var blendShapeVertices = mesh.vertices;
var usePosition = blendShapeVertices != null && blendShapeVertices.Length > 0;
var blendShapeNormals = mesh.normals;
var useNormal = usePosition && blendShapeNormals != null && blendShapeNormals.Length == blendShapeVertices.Length;
// var useNormal = usePosition && blendShapeNormals != null && blendShapeNormals.Length == blendShapeVertices.Length && !exportOnlyBlendShapePosition;
@@ -244,18 +246,6 @@ namespace UniGLTF
blendShapeNormals[i] = axisInverter.InvertVector3(blendShapeNormals[i]);
}
var positions = mesh.vertices;
for (int i = 0; i < positions.Length; ++i)
{
positions[i] = axisInverter.InvertVector3(positions[i]);
}
var normals = mesh.normals;
for (int i = 0; i < normals.Length; ++i)
{
normals[i] = axisInverter.InvertVector3(normals[i]);
}
return BlendShapeExporter.Export(data,
blendShapeVertices,
exportOnlyBlendShapePosition && useNormal ? null : blendShapeNormals,