Explorar o código

Fix global position for `InputEventMouse` in `viewport::push_input`

Global position doesn't get adjusted within `InputEventMouse::xformed_by()`.

(cherry picked from commit 8de39911c8e4f628d585dc5c1c6af66bfbfb3720)
Markus Sauermann hai 1 ano
pai
achega
5dfaec5c29
Modificáronse 1 ficheiros con 7 adicións e 0 borrados
  1. 7 0
      scene/main/viewport.cpp

+ 7 - 0
scene/main/viewport.cpp

@@ -1344,6 +1344,13 @@ Ref<InputEvent> Viewport::_make_input_local(const Ref<InputEvent> &ev) {
 	}
 
 	Transform2D ai = get_final_transform().affine_inverse();
+	Ref<InputEventMouse> me = ev;
+	if (me.is_valid()) {
+		me = me->xformed_by(ai);
+		// For InputEventMouse, the global position is not adjusted by ev->xformed_by() and needs to be set separately.
+		me->set_global_position(me->get_position());
+		return me;
+	}
 	return ev->xformed_by(ai);
 }