Merge pull request #11375 from FigyTuna/rigid_body_docs

[DOCS] Modified/Added documentation for RigidBody and RigidBody2D

[ci skip]
This commit is contained in:
Rémi Verschelde 2017-09-18 20:05:41 +02:00 committed by GitHub
commit 3d06957f12
2 changed files with 43 additions and 19 deletions

View file

@ -1,10 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="RigidBody" inherits="PhysicsBody" category="Core" version="3.0.alpha.custom_build"> <class name="RigidBody" inherits="PhysicsBody" category="Core" version="3.0.alpha.custom_build">
<brief_description> <brief_description>
Rigid body node. Physics Body whose position is determined through physics simulation in 3D space.
</brief_description> </brief_description>
<description> <description>
Rigid body node. This node is used for placing rigid bodies in the scene. It can contain a number of shapes, and also shift mode between regular Rigid body, Kinematic, Character or Static. This is the node that implements full 3D physics. This means that you do not control a RigidBody directly. Instead you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.
This node can use custom force integration, for writing complex physics motion behavior per node.
This node can shift state between regular Rigid body, Kinematic, Character or Static.
Character mode forbids this node from being rotated.
As a warning, don't change RigidBody's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop will yield strange behavior.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -324,55 +328,56 @@
</methods> </methods>
<members> <members>
<member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp"> <member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp">
Dampens rotational forces of the Rigid body by the 'angular_damp' rate. Damps RigidBody's rotational forces.
</member> </member>
<member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity"> <member name="angular_velocity" type="Vector3" setter="set_angular_velocity" getter="get_angular_velocity">
The current rotational velocity of the Rigid body RigidBody's rotational velocity.
</member> </member>
<member name="axis_lock" type="int" setter="set_axis_lock" getter="get_axis_lock" enum="RigidBody.AxisLock"> <member name="axis_lock" type="int" setter="set_axis_lock" getter="get_axis_lock" enum="RigidBody.AxisLock">
Locks the rotational forces to a particular axis, preventing rotations on other axes. Locks the rotational forces to a particular axis, preventing rotations on other axes.
</member> </member>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce"> <member name="bounce" type="float" setter="set_bounce" getter="get_bounce">
Bounciness of the Rigid body. RigidBody's bounciness.
</member> </member>
<member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep"> <member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep">
If true, the Rigid body will no longer calculate forces when there is no movement and will act as a static body. It will wake up when other forces are applied through other collisions or when the 'apply_impulse' method is used. If [code]true[/code] the RigidBody will not calculate forces and will act as a static body while there is no movement. It will wake up when forces are applied through other collisions or when the [code]apply_impulse[/code] method is used.
</member> </member>
<member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled"> <member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled">
If true, the Rigid body will emit signals when it collides with another Rigid body. If true, the RigidBody will emit signals when it collides with another RigidBody.
</member> </member>
<member name="contacts_reported" type="int" setter="set_max_contacts_reported" getter="get_max_contacts_reported"> <member name="contacts_reported" type="int" setter="set_max_contacts_reported" getter="get_max_contacts_reported">
The maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0. The maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.
</member> </member>
<member name="continuous_cd" type="bool" setter="set_use_continuous_collision_detection" getter="is_using_continuous_collision_detection"> <member name="continuous_cd" type="bool" setter="set_use_continuous_collision_detection" getter="is_using_continuous_collision_detection">
Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. The first is more precise, and misses less impacts by small, fast-moving objects. The second is faster to compute, but can miss small, fast-moving objects. If [code]true[/code] continuous collision detection is used.
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 less 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"> <member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator">
If true, 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] 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.
</member> </member>
<member name="friction" type="float" setter="set_friction" getter="get_friction"> <member name="friction" type="float" setter="set_friction" getter="get_friction">
The body friction, from 0 (frictionless) to 1 (max friction). The body friction, from 0 (frictionless) to 1 (max friction).
</member> </member>
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale"> <member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale">
The 'gravity_scale' for this Rigid body will be multiplied by the global 3d gravity setting found in "Project &gt; Project Settings &gt; Physics &gt; 3d". A value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object. This is multiplied by the global 3D gravity setting found in "Project &gt; Project Settings &gt; Physics &gt; 3d" to produce RigidBody's gravity. E.g. a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
</member> </member>
<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp"> <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp">
The linear damp for this body. Default of -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden. RigidBody's linear damp. Default value: -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden.
</member> </member>
<member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity"> <member name="linear_velocity" type="Vector3" setter="set_linear_velocity" getter="get_linear_velocity">
The body linear velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state. RigidBody's linear velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state.
</member> </member>
<member name="mass" type="float" setter="set_mass" getter="get_mass"> <member name="mass" type="float" setter="set_mass" getter="get_mass">
The body mass. RigidBody's mass.
</member> </member>
<member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidBody.Mode"> <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidBody.Mode">
The body mode from the MODE_* enum. Modes include: MODE_STATIC, MODE_KINEMATIC, MODE_RIGID, and MODE_CHARACTER. The body mode from the MODE_* enum. Modes include: MODE_STATIC, MODE_KINEMATIC, MODE_RIGID, and MODE_CHARACTER.
</member> </member>
<member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping"> <member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping">
The current 'sleeping' state of the Rigid body. If [code]true[/code] RigidBody is sleeping and will not calculate forces until woken up by a collision or the [code]apply_impulse[/code] method.
</member> </member>
<member name="weight" type="float" setter="set_weight" getter="get_weight"> <member name="weight" type="float" setter="set_weight" getter="get_weight">
The body weight given standard earth-weight (gravity 9.8). RigidBody's weight based on its mass and the global 3D gravity. Global values are set in "Project &gt; Project Settings &gt; Physics &gt; 3d".
</member> </member>
</members> </members>
<signals> <signals>

View file

@ -1,12 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<class name="RigidBody2D" inherits="PhysicsBody2D" category="Core" version="3.0.alpha.custom_build"> <class name="RigidBody2D" inherits="PhysicsBody2D" category="Core" version="3.0.alpha.custom_build">
<brief_description> <brief_description>
Rigid body 2D node. Physics Body whose position is determined through physics simulation in 2D space.
</brief_description> </brief_description>
<description> <description>
Rigid body 2D node. This node is used for placing rigid bodies in the scene. It can contain a number of shapes, and also shift state between regular Rigid body, Kinematic, Character or Static. This is the node that implements full 2D physics. This means that you do not control a RigidBody2D directly. Instead you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.
Character mode forbids the node from being rotated. This node can have a custom force integrator function, for writing complex physics motion behavior per node. This node can use custom force integration, for writing complex physics motion behavior per node.
As a warning, don't change this node position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop will yield strange behavior. This node can shift state between regular Rigid body, Kinematic, Character or Static.
Character mode forbids this node from being rotated.
As a warning, don't change RigidBody2D's position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop will yield strange behavior.
</description> </description>
<tutorials> <tutorials>
</tutorials> </tutorials>
@ -382,36 +384,53 @@
</methods> </methods>
<members> <members>
<member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp"> <member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp">
Damps RigidBody2D's rotational forces.
</member> </member>
<member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity"> <member name="angular_velocity" type="float" setter="set_angular_velocity" getter="get_angular_velocity">
RigidBody2D's rotational velocity.
</member> </member>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce"> <member name="bounce" type="float" setter="set_bounce" getter="get_bounce">
RigidBody2D's bounciness.
</member> </member>
<member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep"> <member name="can_sleep" type="bool" setter="set_can_sleep" getter="is_able_to_sleep">
If [code]true[/code] RigidBody2D will not calculate forces and will act as a static body while there is no movement. It will wake up when other forces are applied through other collisions or when the [code]apply_impulse[/code] method is used. Default value: [code]true[/code]
</member> </member>
<member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled"> <member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled">
If [code]true[/code] RigidBody2D will emit signals when it collides with another RigidBody2D.
</member> </member>
<member name="contacts_reported" type="int" setter="set_max_contacts_reported" getter="get_max_contacts_reported"> <member name="contacts_reported" type="int" setter="set_max_contacts_reported" getter="get_max_contacts_reported">
The maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.
</member> </member>
<member name="continuous_cd" type="int" setter="set_continuous_collision_detection_mode" getter="get_continuous_collision_detection_mode" enum="RigidBody2D.CCDMode"> <member name="continuous_cd" type="int" setter="set_continuous_collision_detection_mode" getter="get_continuous_collision_detection_mode" enum="RigidBody2D.CCDMode">
If [code]true[/code] continuous collision detection is used. Default value: [code]false[/code]
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 less 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"> <member name="custom_integrator" type="bool" setter="set_use_custom_integrator" getter="is_using_custom_integrator">
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.
</member> </member>
<member name="friction" type="float" setter="set_friction" getter="get_friction"> <member name="friction" type="float" setter="set_friction" getter="get_friction">
The body friction, from 0 (frictionless) to 1 (max friction).
</member> </member>
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale"> <member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale">
This is multiplied by the global 2D gravity setting found in "Project &gt; Project Settings &gt; Physics &gt; 2d" to produce RigidBody2D's gravity. E.g. a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.
</member> </member>
<member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp"> <member name="linear_damp" type="float" setter="set_linear_damp" getter="get_linear_damp">
RigidBody2D's linear damp. Default of -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden.
</member> </member>
<member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity"> <member name="linear_velocity" type="Vector2" setter="set_linear_velocity" getter="get_linear_velocity">
RigidBody2D's linear velocity. Can be used sporadically, but [b]DON'T SET THIS IN EVERY FRAME[/b], because physics may run in another thread and runs at a different granularity. Use [method _integrate_forces] as your process loop for precise control of the body state.
</member> </member>
<member name="mass" type="float" setter="set_mass" getter="get_mass"> <member name="mass" type="float" setter="set_mass" getter="get_mass">
RigidBody2D's mass.
</member> </member>
<member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidBody2D.Mode"> <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="RigidBody2D.Mode">
The body mode from the MODE_* enum. Modes include: MODE_STATIC, MODE_KINEMATIC, MODE_RIGID, and MODE_CHARACTER.
</member> </member>
<member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping"> <member name="sleeping" type="bool" setter="set_sleeping" getter="is_sleeping">
If [code]true[/code] RigidBody2D is sleeping and will not calculate forces until woken up by a collision or the [code]apply_impulse[/code] method.
</member> </member>
<member name="weight" type="float" setter="set_weight" getter="get_weight"> <member name="weight" type="float" setter="set_weight" getter="get_weight">
RigidBody2D's weight based on its mass and the global 2D gravity. Global values are set in "Project &gt; Project Settings &gt; Physics &gt; 2d".
</member> </member>
</members> </members>
<signals> <signals>