diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-07-23 13:13:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-23 13:13:37 +0200 |
commit | dfdc48a9de28567ffaf1ce5463f604b81ecd6710 (patch) | |
tree | 135cf6d4d7b8062266f3abcbb9457633e277a707 /servers | |
parent | bd00ab75162fc1cbca539786d50f04b8e5f4024f (diff) | |
parent | acf32e87d57892e2a8541ab457ad20c9a8500b1b (diff) |
Merge pull request #40628 from reduz/fix-dynamic-light-crash
Fixes RenderingServer crashes reported by #39951
Diffstat (limited to 'servers')
-rw-r--r-- | servers/rendering/rendering_server_scene.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/servers/rendering/rendering_server_scene.cpp b/servers/rendering/rendering_server_scene.cpp index 75a5834791..2024f5b983 100644 --- a/servers/rendering/rendering_server_scene.cpp +++ b/servers/rendering/rendering_server_scene.cpp @@ -370,8 +370,8 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) { case RS::INSTANCE_LIGHT: { InstanceLightData *light = static_cast<InstanceLightData *>(instance->base_data); - if (RSG::storage->light_get_type(instance->base) != RS::LIGHT_DIRECTIONAL && light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { - instance->scenario->dynamic_lights.erase(light->instance); + if (scenario && RSG::storage->light_get_type(instance->base) != RS::LIGHT_DIRECTIONAL && light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { + scenario->dynamic_lights.erase(light->instance); } #ifdef DEBUG_ENABLED @@ -379,8 +379,8 @@ void RenderingServerScene::instance_set_base(RID p_instance, RID p_base) { ERR_PRINT("BUG, indexing did not unpair geometries from light."); } #endif - if (instance->scenario && light->D) { - instance->scenario->directional_lights.erase(light->D); + if (scenario && light->D) { + scenario->directional_lights.erase(light->D); light->D = nullptr; } RSG::scene_render->free(light->instance); @@ -986,13 +986,13 @@ void RenderingServerScene::_update_instance(Instance *p_instance) { RS::LightBakeMode bake_mode = RSG::storage->light_get_bake_mode(p_instance->base); if (RSG::storage->light_get_type(p_instance->base) != RS::LIGHT_DIRECTIONAL && bake_mode != light->bake_mode) { - if (light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { + if (p_instance->scenario && light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { p_instance->scenario->dynamic_lights.erase(light->instance); } light->bake_mode = bake_mode; - if (light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { + if (p_instance->scenario && light->bake_mode == RS::LIGHT_BAKE_DYNAMIC) { p_instance->scenario->dynamic_lights.push_back(light->instance); } } |