| 734 | |
| 735 | #if !defined(PHYSICS_2D_DISABLED) || !defined(PHYSICS_3D_DISABLED) |
| 736 | void Viewport::_process_picking() { |
| 737 | if (!is_inside_tree()) { |
| 738 | return; |
| 739 | } |
| 740 | if (!physics_object_picking) { |
| 741 | return; |
| 742 | } |
| 743 | if (Object::cast_to<Window>(this) && Input::get_singleton()->get_mouse_mode() == Input::MOUSE_MODE_CAPTURED) { |
| 744 | return; |
| 745 | } |
| 746 | if (!gui.mouse_in_viewport || gui.subwindow_over) { |
| 747 | // Clear picking events if the mouse has left the viewport or is over an embedded window. |
| 748 | // These are locations, that are expected to not trigger physics picking. |
| 749 | physics_picking_events.clear(); |
| 750 | return; |
| 751 | } |
| 752 | #ifndef XR_DISABLED |
| 753 | if (use_xr) { |
| 754 | if (XRServer::get_singleton() != nullptr) { |
| 755 | Ref<XRInterface> xr_interface = XRServer::get_singleton()->get_primary_interface(); |
| 756 | if (xr_interface.is_valid() && xr_interface->is_initialized() && xr_interface->get_view_count() > 1) { |
| 757 | WARN_PRINT_ONCE("Object picking can't be used when stereo rendering, this will be turned off!"); |
| 758 | physics_object_picking = false; // don't try again. |
| 759 | return; |
| 760 | } |
| 761 | } |
| 762 | } |
| 763 | #endif // XR_DISABLED |
| 764 | |
| 765 | _drop_physics_mouseover(true); |
| 766 | |
| 767 | #ifndef PHYSICS_3D_DISABLED |
| 768 | Vector2 last_pos(1e20, 1e20); |
| 769 | CollisionObject3D *last_object = nullptr; |
| 770 | ObjectID last_id; |
| 771 | PhysicsDirectSpaceState3D::RayResult result; |
| 772 | #endif // PHYSICS_3D_DISABLED |
| 773 | |
| 774 | #ifndef PHYSICS_2D_DISABLED |
| 775 | PhysicsDirectSpaceState2D *ss2d = PhysicsServer2D::get_singleton()->space_get_direct_state(find_world_2d()->get_space()); |
| 776 | #endif // PHYSICS_2D_DISABLED |
| 777 | |
| 778 | SubViewportContainer *parent_svc = Object::cast_to<SubViewportContainer>(get_parent()); |
| 779 | bool parent_ignore_mouse = (parent_svc && parent_svc->get_mouse_filter_with_override() == Control::MOUSE_FILTER_IGNORE); |
| 780 | bool create_passive_hover_event = true; |
| 781 | if (gui.mouse_over || parent_ignore_mouse) { |
| 782 | // When the mouse is over a Control node, passive hovering would cause input events for Colliders, that are behind Control nodes. |
| 783 | // When parent SubViewportContainer ignores mouse, that setting should be respected. |
| 784 | create_passive_hover_event = false; |
| 785 | } else { |
| 786 | for (const Ref<InputEvent> &e : physics_picking_events) { |
| 787 | Ref<InputEventMouse> m = e; |
| 788 | if (m.is_valid()) { |
| 789 | // A mouse event exists, so passive hovering isn't necessary. |
| 790 | create_passive_hover_event = false; |
| 791 | break; |
| 792 | } |
| 793 | } |
nothing calls this directly
no test coverage detected