Bind PhysicsServer*D::body_set_state_sync_callback

This commit is contained in:
Mikael Hermansson 2024-07-23 13:11:34 +02:00
parent 4e5ed0bbfb
commit a559a1c6d8
5 changed files with 27 additions and 1 deletions

View File

@ -694,6 +694,17 @@
[b]Note:[/b] The state change doesn't take effect immediately. The state will change on the next physics frame. [b]Note:[/b] The state change doesn't take effect immediately. The state will change on the next physics frame.
</description> </description>
</method> </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"> <method name="body_test_motion">
<return type="bool" /> <return type="bool" />
<param index="0" name="body" type="RID" /> <param index="0" name="body" type="RID" />

View File

@ -713,7 +713,7 @@
<param index="1" name="callable" type="Callable" /> <param index="1" name="callable" type="Callable" />
<description> <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]. 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> </description>
</method> </method>
<method name="_body_test_motion" qualifiers="virtual const"> <method name="_body_test_motion" qualifiers="virtual const">

View File

@ -678,6 +678,17 @@
Sets a body state (see [enum BodyState] constants). Sets a body state (see [enum BodyState] constants).
</description> </description>
</method> </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"> <method name="body_test_motion">
<return type="bool" /> <return type="bool" />
<param index="0" name="body" type="RID" /> <param index="0" name="body" type="RID" />

View File

@ -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_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_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_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())); ClassDB::bind_method(D_METHOD("body_test_motion", "body", "parameters", "result"), &PhysicsServer2D::_body_test_motion, DEFVAL(Variant()));

View File

@ -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_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_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_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); ClassDB::bind_method(D_METHOD("body_set_ray_pickable", "body", "enable"), &PhysicsServer3D::body_set_ray_pickable);