[3.x] Physics Interpolation - Add 3D helper for using servers directly. #112119
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Also uses the helper to provide FTI for debug collision shapes.
Fixes #110824 (for 3.x)
Supersedes #104518
(This PR seems a little easier to use than #104518, and the PR is a bit more polished, and handles debug collision shapes as an example.)
Introduction
#103685 by design removes server side physics interpolation, which has the side effect of removing in-built physics interpolation for users who create 3D nodes directly using servers, rather than via
SceneTreenodes, and ideally we don't want these users to feel they are "losing out".This use case is far simpler than
SceneTreeinterpolation, because only global xforms need be supported.There are several options to deal with this area, including:
addonThis PR provides a simple solution for (3) for
instanceson the server, via a wrapper object calledfti_instance.It should be fairly simple to use, although admittedly there are a couple more lines to type than the old system.
The
fti_instanceis created inVisualServerlike an instance, and it creates a regularinstanceinternally.Then the user should call
fti_set_transform()on thefti_instanceinstead ofinstance_set_transform(), and can callfti_instance_reset()to reset physics interpolation.All the regular instance functions can be called after retrieving the regular instance via
fti_instance_get_instance().Everything else should work automagically. Nearly everything in 3D works via instances so this should cover most cases.
Camerasare not covered and would have to be interpolated manually, but as far as I remember this was also the case before #103685.Model at 5 ticks per second with FTI
2025-04-03.09-27-22.mp4
Usage Example
Notes
instanceto the user, whereas this version handles theinstancelifetime automatically.instance_get_instance()can possibly cause a stall as it is retrieving data from the server, but it should be called as a one off when creating thefti_instance.create_fti_instance()call, however I'm welcome to suggestions. (The existingcreatefunctions assume returning a singleRID. It is just possible we could add a specific macro for this case, but I'm not sure it is worth it.)