Browse Source

Fix execution of physics picking events

Fix that physics picking can happen after the mouse has left the viewport
Markus Sauermann 3 years ago
parent
commit
90b01d79af
1 changed files with 5 additions and 0 deletions
  1. 5 0
      scene/main/viewport.cpp

+ 5 - 0
scene/main/viewport.cpp

@@ -519,6 +519,11 @@ void Viewport::_process_picking() {
 	if (to_screen_rect != Rect2i() && Input::get_singleton()->get_mouse_mode() == Input::MOUSE_MODE_CAPTURED) {
 		return;
 	}
+	if (!gui.mouse_in_viewport) {
+		// Clear picking events if mouse has left viewport.
+		physics_picking_events.clear();
+		return;
+	}
 
 	_drop_physics_mouseover(true);