diff options
Diffstat (limited to 'scene/3d/light.cpp')
-rw-r--r-- | scene/3d/light.cpp | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 7177e21e1e..1566743e1b 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -30,7 +30,7 @@ #include "globals.h" #include "scene/resources/surface_tool.h" - +#include "baked_light_instance.h" bool Light::_can_gizmo_scale() const { @@ -168,9 +168,37 @@ void Light::_update_visibility() { void Light::_notification(int p_what) { - if (p_what==NOTIFICATION_ENTER_TREE || p_what==NOTIFICATION_VISIBILITY_CHANGED) { + + if (p_what==NOTIFICATION_VISIBILITY_CHANGED) { + _update_visibility(); + + } + + if (p_what==NOTIFICATION_ENTER_TREE) { + _update_visibility(); + + Node *node = this; + + while(node) { + + baked_light=node->cast_to<BakedLight>(); + if (baked_light) { + baked_light->lights.insert(this); + break; + } + + node=node->get_parent(); + } } + + if (p_what==NOTIFICATION_EXIT_TREE) { + + if (baked_light) { + baked_light->lights.erase(this); + } + } + } @@ -247,6 +275,8 @@ Light::Light(VisualServer::LightType p_type) { light=VisualServer::get_singleton()->light_create(p_type); VS::get_singleton()->instance_set_base(get_instance(),light); + baked_light=NULL; + editor_only=false; set_color(Color(1,1,1,1)); set_shadow(false); |