Skip to content

Commit

Permalink
33714 glTF2 handle undefined load-time scene.
Browse files Browse the repository at this point in the history
  • Loading branch information
fire committed Nov 22, 2019
1 parent b7ea22c commit 80b1604
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions editor/import/editor_scene_importer_gltf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down

0 comments on commit 80b1604

Please sign in to comment.