1
0
Fork 0

Physics Interpolation - reduce xforms in non-interpolated nodes

In the specific case of non-interpolated nodes, if ancestor nodes were moved on the physics tick this would lead to unnecessary NOTIFICATION_TRANSFORM_CHANGED and calls to `VisualServer`.

This would lower performance and lead to unwanted physics interpolation warnings about movement on physics ticks.

Here we remove these unnecessary notifications.
This commit is contained in:
lawnjelly 2025-02-27 09:03:17 +00:00
parent 53faed5351
commit 5dcf234d13
2 changed files with 21 additions and 1 deletions

View File

@ -104,14 +104,33 @@ void Node3D::_propagate_transform_changed_deferred() {
}
void Node3D::_propagate_transform_changed(Node3D *p_origin) {
// Wrapper function, to do the heavy lifting to decide
// whether we need to check interpolation on / off for each node
// to determine whether to send notifications.
_propagate_transform_changed(p_origin,
Engine::get_singleton()->is_in_physics_frame() && is_inside_tree() && get_tree()->is_physics_interpolation_enabled());
}
void Node3D::_propagate_transform_changed(Node3D *p_origin, bool p_check_physics_interpolation_state) {
if (!is_inside_tree()) {
return;
}
for (Node3D *&E : data.children) {
// Don't propagate to a top_level.
if (E->data.top_level) {
continue; //don't propagate to a top_level
continue;
}
// The first non-interpolated child is responsible for grabbing
// the interpolated xform from the parent / target on each frame.
// If this is not done, there will be judder, because the non-interpolated child
// will be matching the PHYSICS xform of the parent, rather than the interpolated
// xform.
if (p_check_physics_interpolation_state && !E->is_physics_interpolated() && p_origin->is_physics_interpolated()) {
continue;
}
E->_propagate_transform_changed(p_origin);
}
#ifdef TOOLS_ENABLED

View File

@ -151,6 +151,7 @@ private:
void _update_gizmos();
void _notify_dirty();
void _propagate_transform_changed(Node3D *p_origin);
void _propagate_transform_changed(Node3D *p_origin, bool p_check_physics_interpolation_state);
void _propagate_visibility_changed();