[3.x] Physics Interpolation - Add 3D helper for using servers directly.#112119
[3.x] Physics Interpolation - Add 3D helper for using servers directly.#112119lawnjelly wants to merge 1 commit intogodotengine:3.xfrom
Conversation
Also uses the helper to provide FTI for debug collision shapes.
There was a problem hiding this comment.
Tested locally, it works as expected. Code looks good to me.
The fti_ naming prefix for functions looks a bit strange to me though. It's not a standard acronym that is used often outside of Godot, and we call it "physics interpolation" elsewhere already. I would just name these functions interpolated_, e.g. interpolated_instance_reset().
It may be worth adding a project setting to disable debug shape interpolation as well, but this can be decided in a future PR.
Debug collision shapes at 10 TPS:
Before
fti_before.mp4
After
fti_after.mp4
|
On the naming, I wrote a little on this subject here: Key things in naming imo:
This is why I'm trying to push for at least internally using the correct fixed timestep interpolation terminology. It is the standard way of referring to fixed timestep interpolation: i.e. The correct term for fixed timestep interpolation IS fixed timestep interpolation. (The term was popularized by Gaffer on Games article 2004ish?), but the technique was in use beforehand, we used it certainly from 2000/2001 and I remember teaching it to our tech guys at the time (who then went on to use it at other companies), I probably read it from flipcode or similar). Imo we have the choice of either doubling down on the misnaming and using I actually had a look with Grok to find where I might have read it originally, and it didn't find much before 2004 initially, but with some prompting it found some articles by Tom Forsyth on flipcode from Jan 2002, and certainly I read a lot of Tom's stuff at the time (one of my friend's worked at same company if I remember right). If I remember I read at least 3 / 4 articles on it even back then, and got the impression it had been in use from at least the late 90s. |
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.)