public PxMesh buildMesh(Mesh mesh) { PxMesh ret; if (!m_index.TryGetValue(mesh, out ret)) { ret = new PxMesh(m_meshes.Count); ret.vertices = mesh.vertices; uint indexCount = 0; for (int i = 0; i < mesh.subMeshCount; ++i) { indexCount += mesh.GetIndexCount(i); } ret.indices = new ushort[indexCount]; int index = 0; for (int i = 0; i < mesh.subMeshCount; ++i) { var indices = mesh.GetIndices(i); for (int j = 0; j < indices.Length; ++j) { ret.indices[index++] = (ushort)indices[j]; } } m_meshes.Add(ret); m_index.Add(mesh, ret); } return(ret); }
public PxMeshCollider(MeshCollider source, PxMeshDictionary meshDictionary) { _setPositionAndRotation(source.transform); scale = source.transform.lossyScale; mesh = meshDictionary.buildMesh(source.sharedMesh); }