Fix crash when importing mesh with incorrect triangulation

This commit is contained in:
Wojtek Figat
2025-07-02 17:23:04 +02:00
parent b08f218f30
commit 7f783bb7da

View File

@@ -692,8 +692,12 @@ int Triangulate(OpenFbxImporterData& data, const ofbx::GeometryData& geom, const
triangulatedIndices[i] = polygon.from_vertex + (earIndices[i] % polygon.vertex_count);
// Ensure that we've written enough ears
ASSERT(earIndices.Count() == 3 * (polygon.vertex_count - 2));
return earIndices.Count();
const int32 indexCount = 3 * (polygon.vertex_count - 2);
if (indexCount != earIndices.Count())
{
LOG(Error, "Invalid amount of vertices after triangulation. Expected {} but got {}. Use proper mesh triangulation when exporting source asset to the engine.", earIndices.Count(), indexCount);
}
return indexCount;
}
bool ProcessMesh(ModelData& result, OpenFbxImporterData& data, const ofbx::Mesh* aMesh, MeshData& mesh, String& errorMsg, int partitionIndex)
@@ -729,7 +733,7 @@ bool ProcessMesh(ModelData& result, OpenFbxImporterData& data, const ofbx::Mesh*
mesh.Positions.Get()[j] = ToFloat3(positions.get(triangulatedIndices[j]));
numIndicesTotal += numIndices;
}
ASSERT(numIndicesTotal == vertexCount);
ASSERT_LOW_LAYER(numIndicesTotal == vertexCount);
}
// Indices (dummy index buffer)