Merge pull request #101376 from ryevdokimov/movement-threshold-rotation-gizmo
Add movement threshold before activating viewport rotation gizmo dragging
This commit is contained in:
commit
d46512a89d
@ -425,7 +425,9 @@ void ViewportRotationControl::_process_click(int p_index, Vector2 p_position, bo
|
||||
}
|
||||
|
||||
void ViewportRotationControl::_process_drag(Ref<InputEventWithModifiers> p_event, int p_index, Vector2 p_position, Vector2 p_relative_position) {
|
||||
if (orbiting_index == p_index && gizmo_activated) {
|
||||
Point2 mouse_pos = get_local_mouse_position();
|
||||
const bool movement_threshold_passed = original_mouse_pos.distance_to(mouse_pos) > 4 * EDSCALE;
|
||||
if (orbiting_index == p_index && gizmo_activated && movement_threshold_passed) {
|
||||
if (Input::get_singleton()->get_mouse_mode() == Input::MOUSE_MODE_VISIBLE) {
|
||||
Input::get_singleton()->set_mouse_mode(Input::MOUSE_MODE_CAPTURED);
|
||||
orbiting_mouse_start = p_position;
|
||||
@ -460,6 +462,7 @@ void ViewportRotationControl::gui_input(const Ref<InputEvent> &p_event) {
|
||||
_process_click(100, mb->get_position(), mb->is_pressed());
|
||||
if (mb->is_pressed()) {
|
||||
gizmo_activated = true;
|
||||
original_mouse_pos = get_local_mouse_position();
|
||||
grab_focus();
|
||||
}
|
||||
} else if (mb->get_button_index() == MouseButton::RIGHT) {
|
||||
|
@ -82,6 +82,7 @@ class ViewportRotationControl : public Control {
|
||||
Vector<Color> axis_colors;
|
||||
Vector<int> axis_menu_options;
|
||||
Vector2i orbiting_mouse_start;
|
||||
Point2 original_mouse_pos;
|
||||
int orbiting_index = -1;
|
||||
int focused_axis = -2;
|
||||
bool gizmo_activated = false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user