diff options
author | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2021-06-04 16:09:41 -0700 |
---|---|---|
committer | PouleyKetchoupp <pouleyketchoup@gmail.com> | 2021-08-25 08:57:42 -0700 |
commit | 6a9ed72185a910f803fff91ef1f408ad91884d20 (patch) | |
tree | c830ce6dca827a29305f2e28c960264ac55b9443 /servers/physics_server_2d.h | |
parent | 353bb45e21fadf8da1f6fbbaaf99b8ac8acafea9 (diff) |
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.
Diffstat (limited to 'servers/physics_server_2d.h')
-rw-r--r-- | servers/physics_server_2d.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/servers/physics_server_2d.h b/servers/physics_server_2d.h index 4c559dd7bd..deec3654f2 100644 --- a/servers/physics_server_2d.h +++ b/servers/physics_server_2d.h @@ -455,6 +455,10 @@ public: virtual void body_set_omit_force_integration(RID p_body, bool p_omit) = 0; virtual bool body_is_omitting_force_integration(RID p_body) const = 0; + // Callback for C++ use only. + typedef void (*BodyStateCallback)(void *p_instance, PhysicsDirectBodyState2D *p_state); + virtual void body_set_state_sync_callback(RID p_body, void *p_instance, BodyStateCallback p_callback) = 0; + virtual void body_set_force_integration_callback(RID p_body, const Callable &p_callable, const Variant &p_udata = Variant()) = 0; virtual bool body_collide_shape(RID p_body, int p_body_shape, RID p_shape, const Transform2D &p_shape_xform, const Vector2 &p_motion, Vector2 *r_results, int p_result_max, int &r_result_count) = 0; |