You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-24 15:26:15 +00:00
Physics Interpolation - Move 3D FTI to SceneTree
Moves 3D interpolation from server to the client code (`SceneTree`). Complete rework of 3D physics interpolation, but using the same user API.
This commit is contained in:
@@ -588,6 +588,8 @@ void SceneTree::set_physics_interpolation_enabled(bool p_enabled) {
|
||||
_physics_interpolation_enabled = p_enabled;
|
||||
RenderingServer::get_singleton()->set_physics_interpolation_enabled(p_enabled);
|
||||
|
||||
get_scene_tree_fti().set_enabled(get_root(), p_enabled);
|
||||
|
||||
// Perform an auto reset on the root node for convenience for the user.
|
||||
if (root) {
|
||||
root->reset_physics_interpolation();
|
||||
@@ -615,6 +617,7 @@ void SceneTree::iteration_prepare() {
|
||||
// Make sure any pending transforms from the last tick / frame
|
||||
// are flushed before pumping the interpolation prev and currents.
|
||||
flush_transform_notifications();
|
||||
get_scene_tree_fti().tick_update();
|
||||
RenderingServer::get_singleton()->tick();
|
||||
}
|
||||
}
|
||||
@@ -669,6 +672,17 @@ void SceneTree::iteration_end() {
|
||||
}
|
||||
|
||||
bool SceneTree::process(double p_time) {
|
||||
// First pass of scene tree fixed timestep interpolation.
|
||||
if (get_scene_tree_fti().is_enabled()) {
|
||||
// Special, we need to ensure RenderingServer is up to date
|
||||
// with *all* the pending xforms *before* updating it during
|
||||
// the FTI update.
|
||||
// If this is not done, we can end up with a deferred `set_transform()`
|
||||
// overwriting the interpolated xform in the server.
|
||||
flush_transform_notifications();
|
||||
get_scene_tree_fti().frame_update(get_root(), true);
|
||||
}
|
||||
|
||||
if (MainLoop::process(p_time)) {
|
||||
_quit = true;
|
||||
}
|
||||
@@ -750,6 +764,11 @@ bool SceneTree::process(double p_time) {
|
||||
#endif // _3D_DISABLED
|
||||
#endif // TOOLS_ENABLED
|
||||
|
||||
// Second pass of scene tree fixed timestep interpolation.
|
||||
// ToDo: Possibly needs another flush_transform_notifications here
|
||||
// depending on whether there are side effects to _call_idle_callbacks().
|
||||
get_scene_tree_fti().frame_update(get_root(), false);
|
||||
|
||||
if (_physics_interpolation_enabled) {
|
||||
RenderingServer::get_singleton()->pre_draw(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user