Skip to content

Commit ea0226c

Browse files
committed
Merge pull request #102652 from lawnjelly/fti_auto_reset_mode_change_4
Physics Interpolation - Auto-reset on `set_physics_interpolation_mode()`
2 parents 0d4d70d + e46993f commit ea0226c

File tree

4 files changed

+11
-4
lines changed

4 files changed

+11
-4
lines changed

scene/2d/camera_2d.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ void Camera2D::_notification(int p_what) {
300300
// Force the limits etc. to update.
301301
_interpolation_data.xform_curr = get_camera_transform();
302302
_interpolation_data.xform_prev = _interpolation_data.xform_curr;
303+
_update_process_callback();
303304
} break;
304305

305306
case NOTIFICATION_SUSPENDED:

scene/3d/camera_3d.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ void Camera3D::_notification(int p_what) {
230230
if (is_inside_tree()) {
231231
_interpolation_data.xform_curr = get_global_transform();
232232
_interpolation_data.xform_prev = _interpolation_data.xform_curr;
233+
_update_process_mode();
233234
}
234235
} break;
235236

scene/main/node.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -921,12 +921,12 @@ void Node::set_physics_interpolation_mode(PhysicsInterpolationMode p_mode) {
921921
} break;
922922
}
923923

924-
// If swapping from interpolated to non-interpolated, use this as an extra means to cause a reset.
925-
if (is_physics_interpolated() && !interpolate && is_inside_tree()) {
924+
_propagate_physics_interpolated(interpolate);
925+
926+
// Auto-reset on changing interpolation mode.
927+
if (is_physics_interpolated() && is_inside_tree()) {
926928
propagate_notification(NOTIFICATION_RESET_PHYSICS_INTERPOLATION);
927929
}
928-
929-
_propagate_physics_interpolated(interpolate);
930930
}
931931

932932
void Node::reset_physics_interpolation() {

scene/main/scene_tree.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,11 @@ void SceneTree::set_physics_interpolation_enabled(bool p_enabled) {
482482

483483
_physics_interpolation_enabled = p_enabled;
484484
RenderingServer::get_singleton()->set_physics_interpolation_enabled(p_enabled);
485+
486+
// Perform an auto reset on the root node for convenience for the user.
487+
if (root) {
488+
root->reset_physics_interpolation();
489+
}
485490
}
486491

487492
bool SceneTree::is_physics_interpolation_enabled() const {

0 commit comments

Comments
 (0)