Ver Fonte

Fix Tree drag-and-drop scrolling having low FPS at low Physics Ticks per Second

Scrolling is now performed in process instead of physics process.
This makes scrolling much smoother if Physics Ticks per Second is lower
than the rendered FPS.
Hugo Locurcio há 10 meses atrás
pai
commit
bb813ba7bc
1 ficheiros alterados com 11 adições e 11 exclusões
  1. 11 11
      scene/gui/tree.cpp

+ 11 - 11
scene/gui/tree.cpp

@@ -3879,7 +3879,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;
 					}
 					}
@@ -3966,7 +3966,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;
@@ -3981,7 +3981,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) {
@@ -4461,7 +4461,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;
 
 
@@ -4469,21 +4469,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;
 					}
 					}
@@ -4495,7 +4495,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;
@@ -4503,7 +4503,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;
 					}
 					}
@@ -4526,7 +4526,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);