Skip to content

[3.x] Physics Interpolation - Fix non-interpolated resting xforms#105141

Merged
lawnjelly merged 1 commit intogodotengine:3.xfrom
lawnjelly:fti_non_interp_fix
Apr 9, 2025
Merged

[3.x] Physics Interpolation - Fix non-interpolated resting xforms#105141
lawnjelly merged 1 commit intogodotengine:3.xfrom
lawnjelly:fti_non_interp_fix

Conversation

@lawnjelly
Copy link
Copy Markdown
Member

@lawnjelly lawnjelly commented Apr 8, 2025

Ensure servers are updated for non-interpolated Spatials, during the SceneTreeFTI traversal update.
Ensure properties and xforms are given a final server update in the final resting positions after removal from tick lists. Fixes dirty local xform bug.
Fixes dirty global xform bug.

As discussed with @rburing yesterday this fixes a number of last minute bugs I noticed in the new system.

Regression in non-interpolated objects

I noticed in WroughtFlesh that on the loading scene, some non-interpolated objects weren't in their correct positions. #104854 was leaving it to SceneTreeFTI to be in charge of updating non-interpolated object xforms, but one small snag, these were being ignored completely by SceneTreeFTI.

Now these nodes have a flag set which activates their processing during _update_dirty_spatials().

This should ensure they get one and (hopefully) only one update to the server, keeping things as efficient as possible. An alternative would have been to revert #104854 but I think this arrangement should be the most optimal solution for reducing server updates to bare minimum.

Ensure servers are updated when removing xforms and properties from their tick lists

This was a slight oversight, as it wasn't necessary with the old server based approach. Now we scene side FTI, we can't just pump the data on the nodes when removing from tick lists, we have to ensure the server is also updated.

For properties, we can update them immediately on removal from the tick list.

For xforms, for the best results, we not only need to update the spatial itself with the final resting xform, we want to ensure all the children are also updated with the final resting xform. We do this by adding another flag to the spatial, fti_frame_xform_force_update, which forces the scene tree traversal to do one last update of any node we choose. This flag is cleared on each traversal, but allows us a way of using the existing mechanisms to ensure the entire branch is updated to the resting xforms.

Ensure local_transform is up to date during interpolation

I noticed on 3D platformer on low tick rate that animated rotating coins were not interpolating as they should. It turned out that the set_rotate() call makes the local dirty, this means the local_transform can be stale at the time of interpolation.

The solution was rather simple, replace all the references to local_transform with get_transform() wrapper function, which ensures that any dirty data is updated.

The coins now interpolate correctly.

Ensure global_transform is up to date during interpolation

Noticed bone attachment wasn't working in WroughtFlesh. Worked out again it was due to a dirty transform, this time global, so now this is updated when dirty when traversing the scene tree in SceneTreeFTI.

Notes

  • I'll add these fixes to the 4.x PR.

@lawnjelly lawnjelly added this to the 3.7 milestone Apr 8, 2025
@lawnjelly lawnjelly requested review from a team as code owners April 8, 2025 08:23
@lawnjelly lawnjelly force-pushed the fti_non_interp_fix branch 4 times, most recently from 513f196 to 5649691 Compare April 8, 2025 14:20
Copy link
Copy Markdown
Member

@rburing rburing left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense as described, thanks for the quick fix!

Ensure servers are updated for non-interpolated Spatials, either during the scene tree update or a final pass.
Ensure properties and xforms are given a final server update in the final resting positions after removal from tick lists.
Fixes dirty local xform bug.
@lawnjelly lawnjelly force-pushed the fti_non_interp_fix branch from 5649691 to 2bb3273 Compare April 9, 2025 06:41
@lawnjelly lawnjelly merged commit 9fccb6b into godotengine:3.x Apr 9, 2025
14 checks passed
@lawnjelly
Copy link
Copy Markdown
Member Author

Thanks!

@lawnjelly lawnjelly deleted the fti_non_interp_fix branch April 9, 2025 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants