Fix force integration documentation

This commit is contained in:
Ricardo Buring 2023-08-02 14:57:15 +02:00
parent 006f5bc11c
commit e5632b0243
7 changed files with 29 additions and 20 deletions

View File

@ -13,7 +13,7 @@
<return type="void" /> <return type="void" />
<param index="0" name="state" type="PhysicsDirectBodyState3D" /> <param index="0" name="state" type="PhysicsDirectBodyState3D" />
<description> <description>
Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it works in addition to the usual physics behavior, but the [member custom_integrator] property allows you to disable the default behavior and do fully custom force integration for a body. Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it is called before the standard force integration, but the [member custom_integrator] property allows you to disable the standard force integration and do fully custom force integration for a body.
</description> </description>
</method> </method>
<method name="apply_central_impulse"> <method name="apply_central_impulse">
@ -67,7 +67,8 @@
If [code]true[/code], the body is deactivated when there is no movement, so it will not take part in the simulation until it is awakened by an external force. If [code]true[/code], the body is deactivated when there is no movement, so it will not take part in the simulation until it is awakened by an external force.
</member> </member>
<member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false"> <member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false">
If [code]true[/code], internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined. If [code]true[/code], the standard force integration (like gravity or damping) will be disabled for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] method, if that virtual method is overridden.
Setting this property will call the method [method PhysicsServer3D.body_set_omit_force_integration] internally.
</member> </member>
<member name="friction" type="float" setter="set_friction" getter="get_friction" default="1.0"> <member name="friction" type="float" setter="set_friction" getter="get_friction" default="1.0">
The body's friction, from [code]0[/code] (frictionless) to [code]1[/code] (max friction). The body's friction, from [code]0[/code] (frictionless) to [code]1[/code] (max friction).

View File

@ -202,7 +202,7 @@
<method name="integrate_forces"> <method name="integrate_forces">
<return type="void" /> <return type="void" />
<description> <description>
Calls the built-in force integration code. Updates the body's linear and angular velocity by applying gravity and damping for the equivalent of one physics tick.
</description> </description>
</method> </method>
<method name="set_constant_force"> <method name="set_constant_force">

View File

@ -202,7 +202,7 @@
<method name="integrate_forces"> <method name="integrate_forces">
<return type="void" /> <return type="void" />
<description> <description>
Calls the built-in force integration code. Updates the body's linear and angular velocity by applying gravity and damping for the equivalent of one physics tick.
</description> </description>
</method> </method>
<method name="set_constant_force"> <method name="set_constant_force">

View File

@ -501,7 +501,7 @@
<return type="bool" /> <return type="bool" />
<param index="0" name="body" type="RID" /> <param index="0" name="body" type="RID" />
<description> <description>
Returns [code]true[/code] if the body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]). Returns [code]true[/code] if the body is omitting the standard force integration. See [method body_set_omit_force_integration].
</description> </description>
</method> </method>
<method name="body_remove_collision_exception"> <method name="body_remove_collision_exception">
@ -592,11 +592,12 @@
<param index="1" name="callable" type="Callable" /> <param index="1" name="callable" type="Callable" />
<param index="2" name="userdata" type="Variant" default="null" /> <param index="2" name="userdata" type="Variant" default="null" />
<description> <description>
Sets the function used to calculate physics for the body, if that body allows it (see [method body_set_omit_force_integration]). Sets the body's custom force integration callback function to [param callable]. Use an empty [Callable] ([code skip-lint]Callable()[/code]) to clear the custom callback.
The force integration function takes the following two parameters: The function [param callable] will be called every physics tick, before the standard force integration (see [method body_set_omit_force_integration]). It can be used for example to update the body's linear and angular velocity based on contact with other bodies.
1. a [PhysicsDirectBodyState2D] [code]state[/code]: used to retrieve and modify the body's state, If [param userdata] is not [code]null[/code], the function [param callable] must take the following two parameters:
2. a [Variant] [param userdata]: optional user data. 1. [code]state[/code]: a [PhysicsDirectBodyState2D] used to retrieve and modify the body's state,
[b]Note:[/b] This callback is currently not called in Godot Physics. 2. [code skip-lint]userdata[/code]: a [Variant]; its value will be the [param userdata] passed into this method.
If [param userdata] is [code]null[/code], then [param callable] must take only the [code]state[/code] parameter.
</description> </description>
</method> </method>
<method name="body_set_max_contacts_reported"> <method name="body_set_max_contacts_reported">
@ -620,7 +621,8 @@
<param index="0" name="body" type="RID" /> <param index="0" name="body" type="RID" />
<param index="1" name="enable" type="bool" /> <param index="1" name="enable" type="bool" />
<description> <description>
Sets whether the body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]). Sets whether the body omits the standard force integration. If [param enable] is [code]true[/code], the body will not automatically use applied forces, torques, and damping to update the body's linear and angular velocity. In this case, [method body_set_force_integration_callback] can be used to manually update the linear and angular velocity instead.
This method is called when the property [member RigidBody2D.custom_integrator] is set.
</description> </description>
</method> </method>
<method name="body_set_param"> <method name="body_set_param">

View File

@ -482,7 +482,7 @@
<return type="bool" /> <return type="bool" />
<param index="0" name="body" type="RID" /> <param index="0" name="body" type="RID" />
<description> <description>
Returns whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]). Returns [code]true[/code] if the body is omitting the standard force integration. See [method body_set_omit_force_integration].
</description> </description>
</method> </method>
<method name="body_remove_collision_exception"> <method name="body_remove_collision_exception">
@ -582,9 +582,12 @@
<param index="1" name="callable" type="Callable" /> <param index="1" name="callable" type="Callable" />
<param index="2" name="userdata" type="Variant" default="null" /> <param index="2" name="userdata" type="Variant" default="null" />
<description> <description>
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: Sets the body's custom force integration callback function to [param callable]. Use an empty [Callable] ([code skip-lint]Callable()[/code]) to clear the custom callback.
- [code]state[/code] — [PhysicsDirectBodyState3D] used to retrieve and modify the body's state. The function [param callable] will be called every physics tick, before the standard force integration (see [method body_set_omit_force_integration]). It can be used for example to update the body's linear and angular velocity based on contact with other bodies.
- [code skip-lint]userdata[/code] — optional user data passed to [method body_set_force_integration_callback]. If [param userdata] is not [code]null[/code], the function [param callable] must take the following two parameters:
1. [code]state[/code]: a [PhysicsDirectBodyState3D], used to retrieve and modify the body's state,
2. [code skip-lint]userdata[/code]: a [Variant]; its value will be the [param userdata] passed into this method.
If [param userdata] is [code]null[/code], then [param callable] must take only the [code]state[/code] parameter.
</description> </description>
</method> </method>
<method name="body_set_max_contacts_reported"> <method name="body_set_max_contacts_reported">
@ -608,7 +611,8 @@
<param index="0" name="body" type="RID" /> <param index="0" name="body" type="RID" />
<param index="1" name="enable" type="bool" /> <param index="1" name="enable" type="bool" />
<description> <description>
Sets whether a body uses a callback function to calculate its own physics (see [method body_set_force_integration_callback]). Sets whether the body omits the standard force integration. If [param enable] is [code]true[/code], the body will not automatically use applied forces, torques, and damping to update the body's linear and angular velocity. In this case, [method body_set_force_integration_callback] can be used to manually update the linear and angular velocity instead.
This method is called when the property [member RigidBody3D.custom_integrator] is set.
</description> </description>
</method> </method>
<method name="body_set_param"> <method name="body_set_param">

View File

@ -19,7 +19,7 @@
<return type="void" /> <return type="void" />
<param index="0" name="state" type="PhysicsDirectBodyState2D" /> <param index="0" name="state" type="PhysicsDirectBodyState2D" />
<description> <description>
Allows you to read and safely modify the simulation state for the object. Use this instead of [method Node._physics_process] if you need to directly change the body's [code]position[/code] or other physics properties. By default, it works in addition to the usual physics behavior, but [member custom_integrator] allows you to disable the default behavior and write custom force integration for a body. Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it is called before the standard force integration, but the [member custom_integrator] property allows you to disable the standard force integration and do fully custom force integration for a body.
</description> </description>
</method> </method>
<method name="add_constant_central_force"> <method name="add_constant_central_force">
@ -159,7 +159,8 @@
Continuous collision detection tries to predict where a moving body will collide instead of moving it and correcting its movement after collision. Continuous collision detection is slower, but more precise and misses fewer collisions with small, fast-moving objects. Raycasting and shapecasting methods are available. See [enum CCDMode] for details. Continuous collision detection tries to predict where a moving body will collide instead of moving it and correcting its movement after collision. Continuous collision detection is slower, but more precise and misses fewer collisions with small, fast-moving objects. Raycasting and shapecasting methods are available. See [enum CCDMode] for details.
</member> </member>
<member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false"> <member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false">
If [code]true[/code], internal force integration is disabled for this body. Aside from collision response, the body will only move as determined by the [method _integrate_forces] function. If [code]true[/code], the standard force integration (like gravity or damping) will be disabled for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] method, if that virtual method is overridden.
Setting this property will call the method [method PhysicsServer2D.body_set_omit_force_integration] internally.
</member> </member>
<member name="freeze" type="bool" setter="set_freeze_enabled" getter="is_freeze_enabled" default="false"> <member name="freeze" type="bool" setter="set_freeze_enabled" getter="is_freeze_enabled" default="false">
If [code]true[/code], the body is frozen. Gravity and forces are not applied anymore. If [code]true[/code], the body is frozen. Gravity and forces are not applied anymore.

View File

@ -20,7 +20,7 @@
<return type="void" /> <return type="void" />
<param index="0" name="state" type="PhysicsDirectBodyState3D" /> <param index="0" name="state" type="PhysicsDirectBodyState3D" />
<description> <description>
Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it works in addition to the usual physics behavior, but the [member custom_integrator] property allows you to disable the default behavior and do fully custom force integration for a body. Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it is called before the standard force integration, but the [member custom_integrator] property allows you to disable the standard force integration and do fully custom force integration for a body.
</description> </description>
</method> </method>
<method name="add_constant_central_force"> <method name="add_constant_central_force">
@ -166,7 +166,8 @@
Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. Continuous collision detection is more precise, and misses fewer impacts by small, fast-moving objects. Not using continuous collision detection is faster to compute, but can miss small, fast-moving objects. Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. Continuous collision detection is more precise, and misses fewer impacts by small, fast-moving objects. Not using continuous collision detection is faster to compute, but can miss small, fast-moving objects.
</member> </member>
<member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false"> <member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator" default="false">
If [code]true[/code], internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] function, if defined. If [code]true[/code], the standard force integration (like gravity or damping) will be disabled for this body. Other than collision response, the body will only move as determined by the [method _integrate_forces] method, if that virtual method is overridden.
Setting this property will call the method [method PhysicsServer3D.body_set_omit_force_integration] internally.
</member> </member>
<member name="freeze" type="bool" setter="set_freeze_enabled" getter="is_freeze_enabled" default="false"> <member name="freeze" type="bool" setter="set_freeze_enabled" getter="is_freeze_enabled" default="false">
If [code]true[/code], the body is frozen. Gravity and forces are not applied anymore. If [code]true[/code], the body is frozen. Gravity and forces are not applied anymore.