Browse Source

Do not create GLTF Mesh if no faces (#5878)

Previously GLTF meshes were created even if there were no faces, which lead to GLTFs which were not technically valid.

I believe this fixes the problem I was encountering, but I've not been able to test it because of some Mac compile errors. Will test on a windows machine at some point.

Fixes #5868

Co-authored-by: Kim Kulling <[email protected]>
Julian Knodt 10 months ago
parent
commit
ca17cdc1f9
1 changed files with 4 additions and 0 deletions
  1. 4 0
      code/AssetLib/glTF2/glTF2Exporter.cpp

+ 4 - 0
code/AssetLib/glTF2/glTF2Exporter.cpp

@@ -61,6 +61,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include <cinttypes>
 #include <cinttypes>
 #include <limits>
 #include <limits>
 #include <memory>
 #include <memory>
+#include <iostream>
 
 
 using namespace rapidjson;
 using namespace rapidjson;
 
 
@@ -1177,6 +1178,9 @@ void glTF2Exporter::ExportMeshes() {
 
 
     for (unsigned int idx_mesh = 0; idx_mesh < mScene->mNumMeshes; ++idx_mesh) {
     for (unsigned int idx_mesh = 0; idx_mesh < mScene->mNumMeshes; ++idx_mesh) {
         const aiMesh *aim = mScene->mMeshes[idx_mesh];
         const aiMesh *aim = mScene->mMeshes[idx_mesh];
+        if (aim->mNumFaces == 0) {
+            continue;
+        }
 
 
         std::string name = aim->mName.C_Str();
         std::string name = aim->mName.C_Str();