Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Physics Interpolation - Auto-reset on set_physics_interpolation_mode() #102652

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scene/2d/camera_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions scene/3d/camera_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
5 changes: 5 additions & 0 deletions scene/main/scene_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down