Skip to content

Commit

Permalink
Continue when glTF2 lights fail to parse.
Browse files Browse the repository at this point in the history
  • Loading branch information
fire committed Aug 7, 2021
1 parent 820496c commit 3a8b0b1
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions modules/gltf/gltf_document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4539,9 +4539,9 @@ Error GLTFDocument::_parse_lights(Ref<GLTFState> state) {
const Dictionary &spot = d["spot"];
light->inner_cone_angle = spot["innerConeAngle"];
light->outer_cone_angle = spot["outerConeAngle"];
ERR_FAIL_COND_V_MSG(light->inner_cone_angle >= light->outer_cone_angle, ERR_PARSE_ERROR, "The inner angle must be smaller than the outer angle.");
ERR_CONTINUE_MSG(light->inner_cone_angle >= light->outer_cone_angle, "The inner angle must be smaller than the outer angle.");
} else if (type != "point" && type != "directional") {
ERR_FAIL_V_MSG(ERR_PARSE_ERROR, "Light type is unknown.");
ERR_CONTINUE_MSG(ERR_PARSE_ERROR, "Light type is unknown.");
}

state->lights.push_back(light);
Expand Down Expand Up @@ -5431,18 +5431,19 @@ void GLTFDocument::_generate_scene_node(Ref<GLTFState> state, Node *scene_parent
// and attach it to the bone_attachment
scene_parent = bone_attachment;
}

// We still have not managed to make a node
if (gltf_node->mesh >= 0) {
current_node = _generate_mesh_instance(state, scene_parent, node_index);
} else if (gltf_node->camera >= 0) {
current_node = _generate_camera(state, scene_parent, node_index);
} else if (gltf_node->light >= 0) {
current_node = _generate_light(state, scene_parent, node_index);
} else {
current_node = _generate_spatial(state, scene_parent, node_index);
}

// We still have not managed to make a node
if (!current_node) {
current_node = _generate_spatial(state, scene_parent, node_index);
}

scene_parent->add_child(current_node);
if (current_node != scene_root) {
current_node->set_owner(scene_root);
Expand Down

0 comments on commit 3a8b0b1

Please sign in to comment.