summaryrefslogtreecommitdiff
path: root/scene/main/viewport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/viewport.cpp')
-rw-r--r--scene/main/viewport.cpp47
1 files changed, 29 insertions, 18 deletions
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index 3ab6e12e01..6388b375d9 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1079,8 +1079,11 @@ Transform2D Viewport::_get_input_pre_xform() const {
}
Ref<InputEvent> Viewport::_make_input_local(const Ref<InputEvent> &ev) {
- Transform2D ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
+ if (ev.is_null()) {
+ return ev; // No transformation defined for null event
+ }
+ Transform2D ai = get_final_transform().affine_inverse() * _get_input_pre_xform();
return ev->xformed_by(ai);
}
@@ -1243,10 +1246,10 @@ void Viewport::_gui_call_input(Control *p_control, const Ref<InputEvent> &p_inpu
Ref<InputEventMouseButton> mb = p_input;
bool cant_stop_me_now = (mb.is_valid() &&
- (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN ||
- mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP ||
- mb->get_button_index() == MOUSE_BUTTON_WHEEL_LEFT ||
- mb->get_button_index() == MOUSE_BUTTON_WHEEL_RIGHT));
+ (mb->get_button_index() == MOUSE_BUTTON_WHEEL_DOWN ||
+ mb->get_button_index() == MOUSE_BUTTON_WHEEL_UP ||
+ mb->get_button_index() == MOUSE_BUTTON_WHEEL_LEFT ||
+ mb->get_button_index() == MOUSE_BUTTON_WHEEL_RIGHT));
Ref<InputEventPanGesture> pn = p_input;
cant_stop_me_now = pn.is_valid() || cant_stop_me_now;
@@ -2189,7 +2192,10 @@ void Viewport::_drop_physics_mouseover(bool p_paused_only) {
if (physics_object_over.is_valid()) {
CollisionObject3D *co = Object::cast_to<CollisionObject3D>(ObjectDB::get_instance(physics_object_over));
if (co) {
- if (!(p_paused_only && co->can_process())) {
+ if (!co->is_inside_tree()) {
+ physics_object_over = ObjectID();
+ physics_object_capture = ObjectID();
+ } else if (!(p_paused_only && co->can_process())) {
co->_mouse_exit();
physics_object_over = ObjectID();
physics_object_capture = ObjectID();
@@ -2210,7 +2216,7 @@ void Viewport::_cleanup_mouseover_colliders(bool p_clean_all_frames, bool p_paus
Object *o = ObjectDB::get_instance(E->key());
if (o) {
CollisionObject2D *co = Object::cast_to<CollisionObject2D>(o);
- if (co) {
+ if (co && co->is_inside_tree()) {
if (p_clean_all_frames && p_paused_only && co->can_process()) {
continue;
}
@@ -2236,7 +2242,7 @@ void Viewport::_cleanup_mouseover_colliders(bool p_clean_all_frames, bool p_paus
Object *o = ObjectDB::get_instance(E->key().first);
if (o) {
CollisionObject2D *co = Object::cast_to<CollisionObject2D>(o);
- if (co) {
+ if (co && co->is_inside_tree()) {
if (p_clean_all_frames && p_paused_only && co->can_process()) {
continue;
}
@@ -2878,9 +2884,8 @@ bool Viewport::gui_is_dragging() const {
void Viewport::set_input_as_handled() {
_drop_physics_mouseover();
- if (handle_input_locally) {
- local_input_handled = true;
- } else {
+
+ if (!handle_input_locally) {
ERR_FAIL_COND(!is_inside_tree());
Viewport *vp = this;
while (true) {
@@ -2892,16 +2897,19 @@ void Viewport::set_input_as_handled() {
}
vp = vp->get_parent()->get_viewport();
}
- vp->set_input_as_handled();
+ if (vp != this) {
+ vp->set_input_as_handled();
+ return;
+ }
}
+
+ local_input_handled = true;
}
bool Viewport::is_input_handled() const {
- if (handle_input_locally) {
- return local_input_handled;
- } else {
- const Viewport *vp = this;
+ if (!handle_input_locally) {
ERR_FAIL_COND_V(!is_inside_tree(), false);
+ const Viewport *vp = this;
while (true) {
if (Object::cast_to<Window>(vp)) {
break;
@@ -2911,8 +2919,11 @@ bool Viewport::is_input_handled() const {
}
vp = vp->get_parent()->get_viewport();
}
- return vp->is_input_handled();
+ if (vp != this) {
+ return vp->is_input_handled();
+ }
}
+ return local_input_handled;
}
void Viewport::set_handle_input_locally(bool p_enable) {
@@ -3849,7 +3860,7 @@ void SubViewport::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "size_2d_override_stretch"), "set_size_2d_override_stretch", "is_size_2d_override_stretch_enabled");
ADD_GROUP("Render Target", "render_target_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_clear_mode", PROPERTY_HINT_ENUM, "Always,Never,Next Frame"), "set_clear_mode", "get_clear_mode");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_update_mode", PROPERTY_HINT_ENUM, "Disabled,Once,When Visible,Always"), "set_update_mode", "get_update_mode");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "render_target_update_mode", PROPERTY_HINT_ENUM, "Disabled,Once,When Visible,When Parent Visible,Always"), "set_update_mode", "get_update_mode");
BIND_ENUM_CONSTANT(CLEAR_MODE_ALWAYS);
BIND_ENUM_CONSTANT(CLEAR_MODE_NEVER);