summaryrefslogtreecommitdiffstats
path: root/scene/2d/light_2d.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/light_2d.cpp')
-rw-r--r--scene/2d/light_2d.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp
index c03786caef..79732d7861 100644
--- a/scene/2d/light_2d.cpp
+++ b/scene/2d/light_2d.cpp
@@ -197,6 +197,10 @@ Light2D::BlendMode Light2D::get_blend_mode() const {
return blend_mode;
}
+void Light2D::_physics_interpolated_changed() {
+ RenderingServer::get_singleton()->canvas_light_set_interpolated(canvas_light, is_physics_interpolated());
+}
+
void Light2D::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_ENTER_TREE: {
@@ -212,6 +216,17 @@ void Light2D::_notification(int p_what) {
_update_light_visibility();
} break;
+ case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
+ if (is_visible_in_tree() && is_physics_interpolated()) {
+ // Explicitly make sure the transform is up to date in RenderingServer before
+ // resetting. This is necessary because NOTIFICATION_TRANSFORM_CHANGED
+ // is normally deferred, and a client change to transform will not always be sent
+ // before the reset, so we need to guarantee this.
+ RS::get_singleton()->canvas_light_set_transform(canvas_light, get_global_transform());
+ RS::get_singleton()->canvas_light_reset_physics_interpolation(canvas_light);
+ }
+ } break;
+
case NOTIFICATION_EXIT_TREE: {
RS::get_singleton()->canvas_light_attach_to_canvas(canvas_light, RID());
_update_light_visibility();