diff options
author | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2022-11-10 22:55:57 +0100 |
---|---|---|
committer | Markus Sauermann <6299227+Sauermann@users.noreply.github.com> | 2023-02-04 22:44:36 +0100 |
commit | 6e855e38202862a806095c64b1a2fce7b1977b91 (patch) | |
tree | dd8704f12069be8ec23b233f6c6b3a33a0b1ab21 /scene/main/canvas_item.cpp | |
parent | 0810ecaafdbee3ea747219e6ab3a8de5d2216a09 (diff) | |
download | redot-engine-6e855e38202862a806095c64b1a2fce7b1977b91.tar.gz |
Fix propagation order for 2D physics picking events
This patch adds a viewport-configuration-option for sorting
physics-picking events by the Z-Index and the scene tree position
of the collision objects.
Diffstat (limited to 'scene/main/canvas_item.cpp')
-rw-r--r-- | scene/main/canvas_item.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/scene/main/canvas_item.cpp b/scene/main/canvas_item.cpp index cde3503bdf..0d9a02968e 100644 --- a/scene/main/canvas_item.cpp +++ b/scene/main/canvas_item.cpp @@ -491,6 +491,17 @@ int CanvasItem::get_z_index() const { return z_index; } +int CanvasItem::get_effective_z_index() const { + int effective_z_index = z_index; + if (is_z_relative()) { + CanvasItem *p = get_parent_item(); + if (p) { + effective_z_index += p->get_effective_z_index(); + } + } + return effective_z_index; +} + void CanvasItem::set_y_sort_enabled(bool p_enabled) { y_sort_enabled = p_enabled; RS::get_singleton()->canvas_item_set_sort_children_by_y(canvas_item, y_sort_enabled); |