summaryrefslogtreecommitdiffstats
path: root/scene/main/canvas_item.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/canvas_item.cpp')
-rw-r--r--scene/main/canvas_item.cpp40
1 files changed, 35 insertions, 5 deletions
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp
index 2d0da075ba..56aa453407 100644
--- a/scene/main/canvas_item.cpp
+++ b/scene/main/canvas_item.cpp
@@ -336,6 +336,19 @@ void CanvasItem::_notification(int p_what) {
get_parent()->connect(SNAME("child_order_changed"), callable_mp(get_viewport(), &Viewport::canvas_parent_mark_dirty).bind(get_parent()), CONNECT_REFERENCE_COUNTED);
}
+ // If using physics interpolation, reset for this node only,
+ // as a helper, as in most cases, users will want items reset when
+ // adding to the tree.
+ // In cases where they move immediately after adding,
+ // there will be little cost in having two resets as these are cheap,
+ // and it is worth it for convenience.
+ // Do not propagate to children, as each child of an added branch
+ // receives its own NOTIFICATION_ENTER_TREE, and this would
+ // cause unnecessary duplicate resets.
+ if (is_physics_interpolated_and_enabled()) {
+ notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
+ }
+
} break;
case NOTIFICATION_EXIT_TREE: {
ERR_MAIN_THREAD_GUARD;
@@ -360,6 +373,12 @@ void CanvasItem::_notification(int p_what) {
}
} break;
+ case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
+ if (is_visible_in_tree() && is_physics_interpolated()) {
+ RenderingServer::get_singleton()->canvas_item_reset_physics_interpolation(canvas_item);
+ }
+ } break;
+
case NOTIFICATION_VISIBILITY_CHANGED: {
ERR_MAIN_THREAD_GUARD;
@@ -921,6 +940,10 @@ void CanvasItem::_notify_transform(CanvasItem *p_node) {
}
}
+void CanvasItem::_physics_interpolated_changed() {
+ RenderingServer::get_singleton()->canvas_item_set_interpolated(canvas_item, is_physics_interpolated());
+}
+
Rect2 CanvasItem::get_viewport_rect() const {
ERR_READ_THREAD_GUARD_V(Rect2());
ERR_FAIL_COND_V(!is_inside_tree(), Rect2());
@@ -1378,14 +1401,17 @@ void CanvasItem::_refresh_texture_filter_cache() const {
}
}
+void CanvasItem::_update_self_texture_filter(RS::CanvasItemTextureFilter p_texture_filter) {
+ RS::get_singleton()->canvas_item_set_default_texture_filter(get_canvas_item(), p_texture_filter);
+ queue_redraw();
+}
+
void CanvasItem::_update_texture_filter_changed(bool p_propagate) {
if (!is_inside_tree()) {
return;
}
_refresh_texture_filter_cache();
-
- RS::get_singleton()->canvas_item_set_default_texture_filter(get_canvas_item(), texture_filter_cache);
- queue_redraw();
+ _update_self_texture_filter(texture_filter_cache);
if (p_propagate) {
for (CanvasItem *E : children_items) {
@@ -1429,14 +1455,18 @@ void CanvasItem::_refresh_texture_repeat_cache() const {
}
}
+void CanvasItem::_update_self_texture_repeat(RS::CanvasItemTextureRepeat p_texture_repeat) {
+ RS::get_singleton()->canvas_item_set_default_texture_repeat(get_canvas_item(), p_texture_repeat);
+ queue_redraw();
+}
+
void CanvasItem::_update_texture_repeat_changed(bool p_propagate) {
if (!is_inside_tree()) {
return;
}
_refresh_texture_repeat_cache();
+ _update_self_texture_repeat(texture_repeat_cache);
- RS::get_singleton()->canvas_item_set_default_texture_repeat(get_canvas_item(), texture_repeat_cache);
- queue_redraw();
if (p_propagate) {
for (CanvasItem *E : children_items) {
if (!E->top_level && E->texture_repeat == TEXTURE_REPEAT_PARENT_NODE) {