Large mesh support.

This commit is contained in:
max 2021-02-17 00:11:49 +01:00
parent 894ddce76e
commit a8ffefa9d6
2 changed files with 21 additions and 1 deletions

View File

@ -211,6 +211,20 @@ namespace TAO.VertexAnimation
// Actually combine and recalculate mesh.
Mesh skinnedMesh = new Mesh();
// Large mesh support.
int vertexCount = 0;
foreach (var ci in combineInstances)
{
vertexCount += ci.mesh.vertexCount;
}
if (vertexCount > 65535)
{
skinnedMesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
}
// Combine meshes.
skinnedMesh.CombineMeshes(combineInstances.ToArray(), true, true);
skinnedMesh.RecalculateBounds();

View File

@ -261,7 +261,13 @@ namespace TAO.VertexAnimation
tris.Add(t * 3 + v - skipped);
}
}
// Large mesh support.
if (vertices.Count > 65535)
{
mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
}
mesh.vertices = vertices.ToArray();
mesh.normals = normals.ToArray();