Merge pull request #3069 from ms-maxvollmer/GLTF2_guarantee_rootnode_fix
GLTF2: Fixed behavior of glTF2Importer::ImportNodespull/3089/head
commit
da8b174ecb
|
@ -952,7 +952,7 @@ aiNode *ImportNode(aiScene *pScene, glTF2::Asset &r, std::vector<unsigned int> &
|
||||||
|
|
||||||
void glTF2Importer::ImportNodes(glTF2::Asset &r) {
|
void glTF2Importer::ImportNodes(glTF2::Asset &r) {
|
||||||
if (!r.scene) {
|
if (!r.scene) {
|
||||||
return;
|
throw DeadlyImportError("GLTF: No scene");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Ref<Node>> rootNodes = r.scene->nodes;
|
std::vector<Ref<Node>> rootNodes = r.scene->nodes;
|
||||||
|
@ -970,6 +970,8 @@ void glTF2Importer::ImportNodes(glTF2::Asset &r) {
|
||||||
root->mChildren[root->mNumChildren++] = node;
|
root->mChildren[root->mNumChildren++] = node;
|
||||||
}
|
}
|
||||||
mScene->mRootNode = root;
|
mScene->mRootNode = root;
|
||||||
|
} else {
|
||||||
|
mScene->mRootNode = new aiNode("ROOT");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"asset": {
|
||||||
|
"version": "2.0"
|
||||||
|
},
|
||||||
|
"scene": 0
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"asset": {
|
||||||
|
"version": "2.0"
|
||||||
|
},
|
||||||
|
"scene": 0,
|
||||||
|
"scenes": [
|
||||||
|
{
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -490,3 +490,16 @@ TEST_F(utglTF2ImportExport, texcoords) {
|
||||||
EXPECT_EQ(aiGetMaterialInteger(material, AI_MATKEY_GLTF_TEXTURE_TEXCOORD(aiTextureType_UNKNOWN, 0), &uvIndex), aiReturn_SUCCESS);
|
EXPECT_EQ(aiGetMaterialInteger(material, AI_MATKEY_GLTF_TEXTURE_TEXCOORD(aiTextureType_UNKNOWN, 0), &uvIndex), aiReturn_SUCCESS);
|
||||||
EXPECT_EQ(uvIndex, 1);
|
EXPECT_EQ(uvIndex, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(utglTF2ImportExport, norootnode_noscene) {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/TestNoRootNode/NoScene.gltf", aiProcess_ValidateDataStructure);
|
||||||
|
ASSERT_EQ(scene, nullptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(utglTF2ImportExport, norootnode_scenewithoutnodes) {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene* scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/glTF2/TestNoRootNode/SceneWithoutNodes.gltf", aiProcess_ValidateDataStructure);
|
||||||
|
ASSERT_NE(scene, nullptr);
|
||||||
|
ASSERT_NE(scene->mRootNode, nullptr);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue