Skip to content

Commit

Permalink
Bind PhysicsServer*D::body_set_state_sync_callback
Browse files Browse the repository at this point in the history
  • Loading branch information
mihe committed Jul 23, 2024
1 parent 4e5ed0b commit a559a1c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
11 changes: 11 additions & 0 deletions doc/classes/PhysicsServer2D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,17 @@
[b]Note:[/b] The state change doesn't take effect immediately. The state will change on the next physics frame.
</description>
</method>
<method name="body_set_state_sync_callback">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="callable" type="Callable" />
<description>
Sets the body's state synchronization callback function to [param callable]. Use an empty [Callable] ([code skip-lint]Callable()[/code]) to clear the callback.
The function [param callable] will be called every physics frame, assuming that the body was active during the previous physics tick, and can be used to fetch the latest state from the physics server.
The function [param callable] must take the following parameters:
1. [code]state[/code]: a [PhysicsDirectBodyState2D], used to retrieve the body's state.
</description>
</method>
<method name="body_test_motion">
<return type="bool" />
<param index="0" name="body" type="RID" />
Expand Down
2 changes: 1 addition & 1 deletion doc/classes/PhysicsServer2DExtension.xml
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@
<param index="1" name="callable" type="Callable" />
<description>
Assigns the [param body] to call the given [param callable] during the synchronization phase of the loop, before [method _step] is called. See also [method _sync].
Overridable version of [PhysicsServer2D]'s internal [code]body_set_state_sync_callback[/code] method.
Overridable version of [method PhysicsServer2D.body_set_state_sync_callback].
</description>
</method>
<method name="_body_test_motion" qualifiers="virtual const">
Expand Down
11 changes: 11 additions & 0 deletions doc/classes/PhysicsServer3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,17 @@
Sets a body state (see [enum BodyState] constants).
</description>
</method>
<method name="body_set_state_sync_callback">
<return type="void" />
<param index="0" name="body" type="RID" />
<param index="1" name="callable" type="Callable" />
<description>
Sets the body's state synchronization callback function to [param callable]. Use an empty [Callable] ([code skip-lint]Callable()[/code]) to clear the callback.
The function [param callable] will be called every physics frame, assuming that the body was active during the previous physics tick, and can be used to fetch the latest state from the physics server.
The function [param callable] must take the following parameters:
1. [code]state[/code]: a [PhysicsDirectBodyState3D], used to retrieve the body's state.
</description>
</method>
<method name="body_test_motion">
<return type="bool" />
<param index="0" name="body" type="RID" />
Expand Down
2 changes: 2 additions & 0 deletions servers/physics_server_2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,8 @@ void PhysicsServer2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("body_set_omit_force_integration", "body", "enable"), &PhysicsServer2D::body_set_omit_force_integration);
ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration", "body"), &PhysicsServer2D::body_is_omitting_force_integration);

ClassDB::bind_method(D_METHOD("body_set_state_sync_callback", "body", "callable"), &PhysicsServer2D::body_set_state_sync_callback);

ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "callable", "userdata"), &PhysicsServer2D::body_set_force_integration_callback, DEFVAL(Variant()));

ClassDB::bind_method(D_METHOD("body_test_motion", "body", "parameters", "result"), &PhysicsServer2D::_body_test_motion, DEFVAL(Variant()));
Expand Down
2 changes: 2 additions & 0 deletions servers/physics_server_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -829,6 +829,8 @@ void PhysicsServer3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("body_set_omit_force_integration", "body", "enable"), &PhysicsServer3D::body_set_omit_force_integration);
ClassDB::bind_method(D_METHOD("body_is_omitting_force_integration", "body"), &PhysicsServer3D::body_is_omitting_force_integration);

ClassDB::bind_method(D_METHOD("body_set_state_sync_callback", "body", "callable"), &PhysicsServer3D::body_set_state_sync_callback);

ClassDB::bind_method(D_METHOD("body_set_force_integration_callback", "body", "callable", "userdata"), &PhysicsServer3D::body_set_force_integration_callback, DEFVAL(Variant()));

ClassDB::bind_method(D_METHOD("body_set_ray_pickable", "body", "enable"), &PhysicsServer3D::body_set_ray_pickable);
Expand Down

0 comments on commit a559a1c

Please sign in to comment.