Fixed bounding box calculation of parts without triangles.

This commit is contained in:
Leonardo Zide 2019-02-22 17:02:38 -08:00
parent 188860f90d
commit 5d06035187

View file

@ -1424,6 +1424,7 @@ lcMesh* lcPiecesLibrary::CreateMesh(PieceInfo* Info, lcLibraryMeshData& MeshData
lcVertex* DstVerts = (lcVertex*)Mesh->mVertexData;
lcVector3 Min(FLT_MAX, FLT_MAX, FLT_MAX), Max(-FLT_MAX, -FLT_MAX, -FLT_MAX);
bool UpdatedBoundingBox = false;
for (int MeshDataIdx = 0; MeshDataIdx < LC_NUM_MESHDATA_TYPES; MeshDataIdx++)
{
@ -1443,6 +1444,8 @@ lcMesh* lcPiecesLibrary::CreateMesh(PieceInfo* Info, lcLibraryMeshData& MeshData
if (Section->mPrimitiveType != LC_MESH_TRIANGLES)
continue;
UpdatedBoundingBox = true;
for (quint32 Index : Section->mIndices)
{
lcVector3 Position = lcVector3LDrawToLeoCAD(Vertices[Index].Position);
@ -1452,6 +1455,9 @@ lcMesh* lcPiecesLibrary::CreateMesh(PieceInfo* Info, lcLibraryMeshData& MeshData
}
}
if (!UpdatedBoundingBox)
Min = Max = lcVector3(0.0f, 0.0f, 0.0f);
lcVertexTextured* DstTexturedVerts = (lcVertexTextured*)DstVerts;
for (int MeshDataIdx = 0; MeshDataIdx < LC_NUM_MESHDATA_TYPES; MeshDataIdx++)