Skip to content

Commit

Permalink
Physics interpolation - fix streaking when unhiding nodes
Browse files Browse the repository at this point in the history
The data flow to the VisualServer of current and previous transforms is essential for allowing correct interpolation. An optimization was present that disabled sending transforms when nodes were hidden, however this meant that when unhidden, nodes would interpolate incorrectly from the last transform received when hiding, rather than the up to date previous transform.

This PR disables the optimization and sends always sends transforms when a node is interpolated.
  • Loading branch information
lawnjelly committed Apr 28, 2022
1 parent 4cfc96f commit 49eaa7b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions scene/3d/visual_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,18 +97,16 @@ void VisualInstance::_notification(int p_what) {

} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
if (_is_vi_visible()) {
if (_is_vi_visible() || is_physics_interpolated_and_enabled()) {
if (!_is_using_identity_transform()) {
Transform gt = get_global_transform();
VisualServer::get_singleton()->instance_set_transform(instance, gt);
}
}
} break;
case NOTIFICATION_RESET_PHYSICS_INTERPOLATION: {
if (_is_vi_visible()) {
if (is_physics_interpolated()) {
VisualServer::get_singleton()->instance_reset_physics_interpolation(instance);
}
if (_is_vi_visible() && is_physics_interpolated()) {
VisualServer::get_singleton()->instance_reset_physics_interpolation(instance);
}
} break;
case NOTIFICATION_EXIT_WORLD: {
Expand Down

0 comments on commit 49eaa7b

Please sign in to comment.