internal unsafe HkShape CreateShape(MyIsoMesh mesh, bool simple = false) { // mk:NOTE This method must be thread safe. Called from worker threads. if (mesh == null || mesh.TrianglesCount == 0 || mesh.VerticesCount == 0) { return(HkShape.Empty); } if (s_indexList.Capacity < mesh.TrianglesCount * 3) { s_indexList.Capacity = mesh.TrianglesCount * 3; } if (s_vertexList.Capacity < mesh.VerticesCount) { s_vertexList.Capacity = mesh.VerticesCount; } for (int i = 0; i < mesh.TrianglesCount; i++) { s_indexList.Add(mesh.Triangles[i].VertexIndex0); s_indexList.Add(mesh.Triangles[i].VertexIndex2); s_indexList.Add(mesh.Triangles[i].VertexIndex1); } // mk:TODO Unify denormalizing of positions with what is in MyIsoMesh. var positionOffset = mesh.PositionOffset - m_voxelMap.StorageMin * MyVoxelConstants.VOXEL_SIZE_IN_METRES; var positions = mesh.Positions.GetInternalArray(); for (int i = 0; i < mesh.VerticesCount; i++) { s_vertexList.Add(positions[i] * mesh.PositionScale + positionOffset); } { HkShape result; if (simple) { result = new HkSimpleMeshShape(s_vertexList, s_indexList); } else { s_cellGeometry.SetGeometry(s_vertexList, s_indexList); result = new HkBvCompressedMeshShape(s_cellGeometry, null, null, HkWeldingType.None, MyPerGameSettings.PhysicsConvexRadius); } Debug.Assert(result.ReferenceCount == 1); s_vertexList.Clear(); s_indexList.Clear(); return(result); } }
internal HkShape BakeCompressedMeshShape(HkSimpleMeshShape simpleMesh) { return new HkBvCompressedMeshShape(simpleMesh); }
internal unsafe HkShape CreateShape(MyIsoMesh mesh, bool simple = false) { // mk:NOTE This method must be thread safe. Called from worker threads. if (mesh == null || mesh.TrianglesCount == 0 || mesh.VerticesCount == 0) return HkShape.Empty; if (s_indexList.Capacity < mesh.TrianglesCount * 3) s_indexList.Capacity = mesh.TrianglesCount * 3; if (s_vertexList.Capacity < mesh.VerticesCount) s_vertexList.Capacity = mesh.VerticesCount; for (int i = 0; i < mesh.TrianglesCount; i++) { s_indexList.Add(mesh.Triangles[i].VertexIndex0); s_indexList.Add(mesh.Triangles[i].VertexIndex2); s_indexList.Add(mesh.Triangles[i].VertexIndex1); } // mk:TODO Unify denormalizing of positions with what is in MyIsoMesh. var positionOffset = mesh.PositionOffset - m_voxelMap.StorageMin * MyVoxelConstants.VOXEL_SIZE_IN_METRES; var positions = mesh.Positions.GetInternalArray(); for (int i = 0; i < mesh.VerticesCount; i++) { s_vertexList.Add(positions[i] * mesh.PositionScale + positionOffset); } { HkShape result; if (simple) { result = new HkSimpleMeshShape(s_vertexList, s_indexList); } else { s_cellGeometry.SetGeometry(s_vertexList, s_indexList); result = new HkBvCompressedMeshShape(s_cellGeometry, null, null, HkWeldingType.None, MyPerGameSettings.PhysicsConvexRadius); } Debug.Assert(result.ReferenceCount == 1); s_vertexList.Clear(); s_indexList.Clear(); return result; } }
internal HkShape BakeCompressedMeshShape(HkSimpleMeshShape simpleMesh) { return(new HkBvCompressedMeshShape(simpleMesh)); }