From 3f75ef68aec103d29751f5754edf4439d271c3c1 Mon Sep 17 00:00:00 2001 From: Max Vollmer Date: Wed, 11 Mar 2020 09:30:04 +0000 Subject: [PATCH] Assimp guarantees in its docs that mRootNode is never NULL. glTF2Importer::ImportNodes therefore must always create a root node, or throw an exception. A GLTF2 file is invalid without a scene, so the importer should throw in that case. For GLTF2 files with a scene without nodes, it should create an empty root node. --- code/glTF2/glTF2Importer.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/glTF2/glTF2Importer.cpp b/code/glTF2/glTF2Importer.cpp index 8c33674e1..56645b737 100644 --- a/code/glTF2/glTF2Importer.cpp +++ b/code/glTF2/glTF2Importer.cpp @@ -953,8 +953,8 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector & void glTF2Importer::ImportNodes(glTF2::Asset &r) { if (!r.scene) { - return; - } + throw DeadlyImportError("GLTF: No scene"); + } std::vector> rootNodes = r.scene->nodes; @@ -971,6 +971,8 @@ void glTF2Importer::ImportNodes(glTF2::Asset &r) { root->mChildren[root->mNumChildren++] = node; } mScene->mRootNode = root; + } else { + mScene->mRootNode = new aiNode("ROOT"); } }