浏览代码

Merge pull request #101218 from lawnjelly/fti_auto_reset_mode_change

[3.x] Physics Interpolation - Auto-reset on `set_physics_interpolation_mode()`
lawnjelly 7 月之前
父节点
当前提交
aa9ad67ac9
共有 4 个文件被更改,包括 11 次插入5 次删除
  1. 1 0
      scene/2d/camera_2d.cpp
  2. 1 0
      scene/3d/camera.cpp
  3. 4 5
      scene/main/node.cpp
  4. 5 0
      scene/main/scene_tree.cpp

+ 1 - 0
scene/2d/camera_2d.cpp

@@ -294,6 +294,7 @@ void Camera2D::_notification(int p_what) {
 			// Force the limits etc to update.
 			// Force the limits etc to update.
 			_interpolation_data.xform_curr = get_camera_transform();
 			_interpolation_data.xform_curr = get_camera_transform();
 			_interpolation_data.xform_prev = _interpolation_data.xform_curr;
 			_interpolation_data.xform_prev = _interpolation_data.xform_curr;
+			_update_process_mode();
 		} break;
 		} break;
 		case NOTIFICATION_PAUSED: {
 		case NOTIFICATION_PAUSED: {
 			if (is_physics_interpolated_and_enabled()) {
 			if (is_physics_interpolated_and_enabled()) {

+ 1 - 0
scene/3d/camera.cpp

@@ -224,6 +224,7 @@ void Camera::_notification(int p_what) {
 			if (is_inside_tree()) {
 			if (is_inside_tree()) {
 				_interpolation_data.xform_curr = get_global_transform();
 				_interpolation_data.xform_curr = get_global_transform();
 				_interpolation_data.xform_prev = _interpolation_data.xform_curr;
 				_interpolation_data.xform_prev = _interpolation_data.xform_curr;
+				_update_process_mode();
 			}
 			}
 		} break;
 		} break;
 		case NOTIFICATION_PAUSED: {
 		case NOTIFICATION_PAUSED: {

+ 4 - 5
scene/main/node.cpp

@@ -894,13 +894,12 @@ void Node::set_physics_interpolation_mode(PhysicsInterpolationMode p_mode) {
 		} break;
 		} break;
 	}
 	}
 
 
-	// if swapping from interpolated to non-interpolated, use this as
-	// an extra means to cause a reset
-	if (is_physics_interpolated() && !interpolate && is_inside_tree()) {
+	_propagate_physics_interpolated(interpolate);
+
+	// Auto-reset on changing interpolation mode.
+	if (is_physics_interpolated() && is_inside_tree()) {
 		propagate_notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
 		propagate_notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
 	}
 	}
-
-	_propagate_physics_interpolated(interpolate);
 }
 }
 
 
 void Node::reset_physics_interpolation() {
 void Node::reset_physics_interpolation() {

+ 5 - 0
scene/main/scene_tree.cpp

@@ -537,6 +537,11 @@ void SceneTree::set_physics_interpolation_enabled(bool p_enabled) {
 
 
 	_physics_interpolation_enabled = p_enabled;
 	_physics_interpolation_enabled = p_enabled;
 	VisualServer::get_singleton()->set_physics_interpolation_enabled(p_enabled);
 	VisualServer::get_singleton()->set_physics_interpolation_enabled(p_enabled);
+
+	// Perform an auto reset on the root node for convenience for the user.
+	if (root) {
+		root->reset_physics_interpolation();
+	}
 }
 }
 
 
 bool SceneTree::is_physics_interpolation_enabled() const {
 bool SceneTree::is_physics_interpolation_enabled() const {