From c9facf16fa56da2649b158da4129a1b3fea739b7 Mon Sep 17 00:00:00 2001 From: Alexander Gessler Date: Sat, 25 Aug 2012 18:17:11 +0200 Subject: [PATCH] - fbx: support reading of scenes containing no geometry. --- code/FBXConverter.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/code/FBXConverter.cpp b/code/FBXConverter.cpp index c22a3118d..bd1d5b861 100644 --- a/code/FBXConverter.cpp +++ b/code/FBXConverter.cpp @@ -124,6 +124,13 @@ public: } TransferDataToScene(); + + // if we didn't read any meshes set the AI_SCENE_FLAGS_INCOMPLETE + // to make sure the scene passes assimp's validation. FBX files + // need not contain geometry (i.e. camera animations, raw armatures). + if (out->mNumMeshes == 0) { + out->mFlags |= AI_SCENE_FLAGS_INCOMPLETE; + } } @@ -2561,11 +2568,13 @@ private: // note: the trailing () ensures initialization with NULL - not // many C++ users seem to know this, so pointing it out to avoid // confusion why this code works. - out->mMeshes = new aiMesh*[meshes.size()](); - out->mNumMeshes = static_cast(meshes.size()); - std::swap_ranges(meshes.begin(),meshes.end(),out->mMeshes); + if(meshes.size()) { + out->mMeshes = new aiMesh*[meshes.size()](); + out->mNumMeshes = static_cast(meshes.size()); + std::swap_ranges(meshes.begin(),meshes.end(),out->mMeshes); + } if(materials.size()) { out->mMaterials = new aiMaterial*[materials.size()]();