From 133e5d197b00fcd8f4b967d2b0c99f14effa4478 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Sun, 4 Sep 2022 09:42:03 -0500 Subject: [PATCH] Don't try to read values from null cameras and lights in GLTF --- modules/gltf/extensions/gltf_light.cpp | 1 + modules/gltf/structures/gltf_camera.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/gltf/extensions/gltf_light.cpp b/modules/gltf/extensions/gltf_light.cpp index ab5a15c6710..6923c765cbc 100644 --- a/modules/gltf/extensions/gltf_light.cpp +++ b/modules/gltf/extensions/gltf_light.cpp @@ -109,6 +109,7 @@ void GLTFLight::set_outer_cone_angle(float p_outer_cone_angle) { Ref GLTFLight::from_node(const Light3D *p_light) { Ref l; l.instantiate(); + ERR_FAIL_COND_V_MSG(!p_light, l, "Tried to create a GLTFLight from a Light3D node, but the given node was null."); l->color = p_light->get_color(); if (cast_to(p_light)) { l->light_type = "directional"; diff --git a/modules/gltf/structures/gltf_camera.cpp b/modules/gltf/structures/gltf_camera.cpp index 5069f39c4bf..212b9b80c81 100644 --- a/modules/gltf/structures/gltf_camera.cpp +++ b/modules/gltf/structures/gltf_camera.cpp @@ -58,6 +58,7 @@ void GLTFCamera::_bind_methods() { Ref GLTFCamera::from_node(const Camera3D *p_camera) { Ref c; c.instantiate(); + ERR_FAIL_COND_V_MSG(!p_camera, c, "Tried to create a GLTFCamera from a Camera3D node, but the given node was null."); c->set_perspective(p_camera->get_projection() == Camera3D::ProjectionType::PROJECTION_PERSPECTIVE); // GLTF spec (yfov) is in radians, Godot's camera (fov) is in degrees. c->set_fov(Math::deg_to_rad(p_camera->get_fov()));