From 6a9ed72185a910f803fff91ef1f408ad91884d20 Mon Sep 17 00:00:00 2001 From: PouleyKetchoupp Date: Fri, 4 Jun 2021 16:09:41 -0700 Subject: Clean physics direct body state usage in 2D and 3D physics Use a C++ callback instead of Callable for synchronizing physics nodes' state with physics servers. Remove usage of PhysicsDirectBodyState in physics nodes when not necessary. Store PhysicsDirectBodyState for bodies individually instead of a singleton to avoid issues when accessing direct body state for multiple bodies. PhysicsDirectBodyState is initialized only when needed, so it doesn't have to be created when using the physics server directly. Move PhysicsDirectBodyState2D and PhysicsDirectBodyState3D to separate cpp files. --- doc/classes/PhysicsServer2D.xml | 3 +++ doc/classes/PhysicsServer3D.xml | 3 +++ 2 files changed, 6 insertions(+) (limited to 'doc') diff --git a/doc/classes/PhysicsServer2D.xml b/doc/classes/PhysicsServer2D.xml index 1df2fd0158..6cb3678fec 100644 --- a/doc/classes/PhysicsServer2D.xml +++ b/doc/classes/PhysicsServer2D.xml @@ -489,6 +489,9 @@ Sets the function used to calculate physics for an object, if that object allows it (see [method body_set_omit_force_integration]). + The force integration function takes 2 arguments: + [code]state:[/code] [PhysicsDirectBodyState2D] used to retrieve and modify the body's state. + [code]userdata:[/code] Optional user data, if it was passed when calling [code]body_set_force_integration_callback[/code]. diff --git a/doc/classes/PhysicsServer3D.xml b/doc/classes/PhysicsServer3D.xml index 33eb0de698..fa4ec55783 100644 --- a/doc/classes/PhysicsServer3D.xml +++ b/doc/classes/PhysicsServer3D.xml @@ -478,6 +478,9 @@ Sets the function used to calculate physics for an object, if that object allows it (see [method body_set_omit_force_integration]). + The force integration function takes 2 arguments: + [code]state:[/code] [PhysicsDirectBodyState3D] used to retrieve and modify the body's state. + [code]userdata:[/code] Optional user data, if it was passed when calling [code]body_set_force_integration_callback[/code]. -- cgit v1.2.3