blob: e5acd99f5bc1d7cbefeab0123caae427a805a484 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
using UnityEngine;
namespace VRC.SDKBase.Validation.Performance
{
public static class MeshUtils
{
private const uint INDICES_PER_TRIANGLE = 3U;
public static uint GetMeshTriangleCount(Mesh sourceMesh)
{
if(sourceMesh == null)
{
return 0;
}
// We can't use GetIndexCount if the mesh isn't readable so just return a huge number.
// The SDK Control Panel should show a warning in this case.
if(!sourceMesh.isReadable)
{
return uint.MaxValue;
}
uint count = 0;
for(int i = 0; i < sourceMesh.subMeshCount; i++)
{
uint indexCount = sourceMesh.GetIndexCount(i);
count += indexCount / INDICES_PER_TRIANGLE;
}
return count;
}
}
}
|