diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-11-22 20:55:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-22 20:55:42 +0100 |
commit | 91b60a74dfbbc23bf589a6e0edda5b957aa48df3 (patch) | |
tree | 72ff835bd2d190c9a563cf3e11b00aee5d6c3eb6 | |
parent | b7ea22c5d203da1b592a743a4c893de25cd34408 (diff) | |
parent | 80b1604fa95b048307815c5eee96426942dd207a (diff) |
Merge pull request #33799 from fire/gltf2-scene
33714 glTF2 scene count change try two.
-rw-r--r-- | editor/import/editor_scene_importer_gltf.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index c7c1cc9708..a10d27f7cd 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -229,9 +229,16 @@ Error EditorSceneImporterGLTF::_parse_scenes(GLTFState &state) { ERR_FAIL_COND_V(!state.json.has("scenes"), ERR_FILE_CORRUPT); const Array &scenes = state.json["scenes"]; - ERR_FAIL_COND_V(!scenes.size(), ERR_FILE_CORRUPT); - for (int i = 0; i < 1; i++) { //only first scene is imported - const Dictionary &s = scenes[i]; + int loaded_scene = 0; + if (state.json.has("scene")) { + loaded_scene = state.json["scene"]; + } else { + WARN_PRINT("The load-time scene is not defined in the glTF2 file. Picking the first scene.") + } + + if (scenes.size()) { + ERR_FAIL_COND_V(loaded_scene >= scenes.size(), ERR_FILE_CORRUPT); + const Dictionary &s = scenes[loaded_scene]; ERR_FAIL_COND_V(!s.has("nodes"), ERR_UNAVAILABLE); const Array &nodes = s["nodes"]; for (int j = 0; j < nodes.size(); j++) { |