Merge pull request #102652 from lawnjelly/fti_auto_reset_mode_change_4

Physics Interpolation - Auto-reset on `set_physics_interpolation_mode()`
This commit is contained in:
Rémi Verschelde 2025-02-11 10:54:18 +01:00
commit ea0226c65d
4 changed files with 11 additions and 4 deletions

View file

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

View file

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

View file

@ -921,12 +921,12 @@ void Node::set_physics_interpolation_mode(PhysicsInterpolationMode p_mode) {
} 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_physics_interpolated(interpolate);
}
void Node::reset_physics_interpolation() {

View file

@ -482,6 +482,11 @@ void SceneTree::set_physics_interpolation_enabled(bool p_enabled) {
_physics_interpolation_enabled = p_enabled;
RenderingServer::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 {