Browse Source

Merge pull request #98766 from Calinou/tree-drag-and-drop-use-process

Fix Tree drag-and-drop scrolling having low FPS at low Physics Ticks per Second
Rémi Verschelde 8 months ago
parent
commit
9d10e42a41
1 changed files with 11 additions and 11 deletions
  1. 11 11
      scene/gui/tree.cpp

+ 11 - 11
scene/gui/tree.cpp

@@ -3845,7 +3845,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
 					if (drag_speed == 0) {
 					if (drag_speed == 0) {
 						drag_touching_deaccel = false;
 						drag_touching_deaccel = false;
 						drag_touching = false;
 						drag_touching = false;
-						set_physics_process_internal(false);
+						set_process_internal(false);
 					} else {
 					} else {
 						drag_touching_deaccel = true;
 						drag_touching_deaccel = true;
 					}
 					}
@@ -3932,7 +3932,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
 				}
 				}
 
 
 				if (drag_touching) {
 				if (drag_touching) {
-					set_physics_process_internal(false);
+					set_process_internal(false);
 					drag_touching_deaccel = false;
 					drag_touching_deaccel = false;
 					drag_touching = false;
 					drag_touching = false;
 					drag_speed = 0;
 					drag_speed = 0;
@@ -3947,7 +3947,7 @@ void Tree::gui_input(const Ref<InputEvent> &p_event) {
 					drag_touching = DisplayServer::get_singleton()->is_touchscreen_available();
 					drag_touching = DisplayServer::get_singleton()->is_touchscreen_available();
 					drag_touching_deaccel = false;
 					drag_touching_deaccel = false;
 					if (drag_touching) {
 					if (drag_touching) {
-						set_physics_process_internal(true);
+						set_process_internal(true);
 					}
 					}
 
 
 					if (mb->get_button_index() == MouseButton::LEFT) {
 					if (mb->get_button_index() == MouseButton::LEFT) {
@@ -4427,7 +4427,7 @@ void Tree::_notification(int p_what) {
 		case NOTIFICATION_DRAG_END: {
 		case NOTIFICATION_DRAG_END: {
 			drop_mode_flags = 0;
 			drop_mode_flags = 0;
 			scrolling = false;
 			scrolling = false;
-			set_physics_process_internal(false);
+			set_process_internal(false);
 			queue_redraw();
 			queue_redraw();
 		} break;
 		} break;
 
 
@@ -4435,21 +4435,21 @@ void Tree::_notification(int p_what) {
 			single_select_defer = nullptr;
 			single_select_defer = nullptr;
 			if (theme_cache.scroll_speed > 0) {
 			if (theme_cache.scroll_speed > 0) {
 				scrolling = true;
 				scrolling = true;
-				set_physics_process_internal(true);
+				set_process_internal(true);
 			}
 			}
 		} break;
 		} break;
 
 
-		case NOTIFICATION_INTERNAL_PHYSICS_PROCESS: {
+		case NOTIFICATION_INTERNAL_PROCESS: {
 			if (drag_touching) {
 			if (drag_touching) {
 				if (drag_touching_deaccel) {
 				if (drag_touching_deaccel) {
 					float pos = v_scroll->get_value();
 					float pos = v_scroll->get_value();
-					pos += drag_speed * get_physics_process_delta_time();
+					pos += drag_speed * get_process_delta_time();
 
 
 					bool turnoff = false;
 					bool turnoff = false;
 					if (pos < 0) {
 					if (pos < 0) {
 						pos = 0;
 						pos = 0;
 						turnoff = true;
 						turnoff = true;
-						set_physics_process_internal(false);
+						set_process_internal(false);
 						drag_touching = false;
 						drag_touching = false;
 						drag_touching_deaccel = false;
 						drag_touching_deaccel = false;
 					}
 					}
@@ -4461,7 +4461,7 @@ void Tree::_notification(int p_what) {
 					v_scroll->set_value(pos);
 					v_scroll->set_value(pos);
 					float sgn = drag_speed < 0 ? -1 : 1;
 					float sgn = drag_speed < 0 ? -1 : 1;
 					float val = Math::abs(drag_speed);
 					float val = Math::abs(drag_speed);
-					val -= 1000 * get_physics_process_delta_time();
+					val -= 1000 * get_process_delta_time();
 
 
 					if (val < 0) {
 					if (val < 0) {
 						turnoff = true;
 						turnoff = true;
@@ -4469,7 +4469,7 @@ void Tree::_notification(int p_what) {
 					drag_speed = sgn * val;
 					drag_speed = sgn * val;
 
 
 					if (turnoff) {
 					if (turnoff) {
-						set_physics_process_internal(false);
+						set_process_internal(false);
 						drag_touching = false;
 						drag_touching = false;
 						drag_touching_deaccel = false;
 						drag_touching_deaccel = false;
 					}
 					}
@@ -4492,7 +4492,7 @@ void Tree::_notification(int p_what) {
 					point.y = mouse_position.y - (get_size().height - theme_cache.scroll_border);
 					point.y = mouse_position.y - (get_size().height - theme_cache.scroll_border);
 				}
 				}
 
 
-				point *= theme_cache.scroll_speed * get_physics_process_delta_time();
+				point *= theme_cache.scroll_speed * get_process_delta_time();
 				point += get_scroll();
 				point += get_scroll();
 				h_scroll->set_value(point.x);
 				h_scroll->set_value(point.x);
 				v_scroll->set_value(point.y);
 				v_scroll->set_value(point.y);