Skip to content

Commit

Permalink
Physical skeleton improvement and bug fixes
Browse files Browse the repository at this point in the history
Rework of the physical bone that aim to fix currently open issues and
also improve the current Physical Bone by adding stability and control.

The current Physical Bone implementation was using the normal rigid
bodies and joints, and it worked well but became unstable if the
complexity of the skeleton is not trivial, for this reason the
Featherstone algorithm was implemented to allowing to have not only a
stable body but also full control of it.

It is now not only possible to create ragdolls of non-animated bodies,
but is also possible to control its movement by adding forces with the
`motor_*` methods.
You don't have to deal with complex force systems, but instead you can
control it by simply changing the motor target and/or velocity and some
other parameters from the editor.

It is now possible to create active ragdolls directly from script, or
for example to create a completely physical walking robot, or to have a
stable ragdoll with dumpers and springs.

Fixes godotengine#19002
Fixes godotengine#22823
Fixes godotengine#24968
Fixes godotengine#25564
Fixes godotengine#26618
Fixes godotengine#28707
  • Loading branch information
AndreaCatania authored and akien-mga committed Jul 4, 2019
1 parent 7b569e9 commit c6712d2
Show file tree
Hide file tree
Showing 46 changed files with 6,133 additions and 1,961 deletions.
46 changes: 0 additions & 46 deletions doc/classes/Area.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@
<tutorials>
</tutorials>
<methods>
<method name="get_collision_layer_bit" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="bit" type="int">
</argument>
<description>
Returns an individual bit on the layer mask.
</description>
</method>
<method name="get_collision_mask_bit" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="bit" type="int">
</argument>
<description>
Returns an individual bit on the collision mask.
</description>
</method>
<method name="get_overlapping_areas" qualifiers="const">
<return type="Array">
</return>
Expand Down Expand Up @@ -62,28 +44,6 @@
The [code]body[/code] argument can either be a [PhysicsBody] or a [GridMap] instance (while GridMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body).
</description>
</method>
<method name="set_collision_layer_bit">
<return type="void">
</return>
<argument index="0" name="bit" type="int">
</argument>
<argument index="1" name="value" type="bool">
</argument>
<description>
Set/clear individual bits on the layer mask. This simplifies editing this [Area]'s layers.
</description>
</method>
<method name="set_collision_mask_bit">
<return type="void">
</return>
<argument index="0" name="bit" type="int">
</argument>
<argument index="1" name="value" type="bool">
</argument>
<description>
Set/clear individual bits on the collision mask. This simplifies editing which [Area] layers this [Area] scans.
</description>
</method>
</methods>
<members>
<member name="angular_damp" type="float" setter="set_angular_damp" getter="get_angular_damp" default="0.1">
Expand All @@ -95,12 +55,6 @@
<member name="audio_bus_override" type="bool" setter="set_audio_bus_override" getter="is_overriding_audio_bus" default="false">
If [code]true[/code], the area's audio bus overrides the default audio bus.
</member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
The area's physics layer(s). Collidable objects can exist in any of 32 different layers. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layers that object A scans. See also [member collision_mask].
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
The physics layers this area scans to determine collision detection.
</member>
<member name="gravity" type="float" setter="set_gravity" getter="get_gravity" default="9.8">
The area's gravity intensity (ranges from -1024 to 1024). This value multiplies the gravity vector. This is useful to alter the force of gravity without altering its direction.
</member>
Expand Down
13 changes: 13 additions & 0 deletions doc/classes/BoneBulletPhysicsDirectBodyState.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="BoneBulletPhysicsDirectBodyState" inherits="PhysicsDirectBodyState" category="Core" version="3.2">
<brief_description>
</brief_description>
<description>
</description>
<tutorials>
</tutorials>
<methods>
</methods>
<constants>
</constants>
</class>
62 changes: 62 additions & 0 deletions doc/classes/CollisionObject.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
Accepts unhandled [InputEvent]s. [code]click_position[/code] is the clicked location in world space and [code]click_normal[/code] is the normal vector extending from the clicked surface of the [Shape] at [code]shape_idx[/code]. Connect to the [code]input_event[/code] signal to easily pick up these events.
</description>
</method>
<method name="add_collision_exception_with">
<return type="void">
</return>
<argument index="0" name="body" type="Node">
</argument>
<description>
</description>
</method>
<method name="create_shape_owner">
<return type="int">
</return>
Expand All @@ -35,6 +43,28 @@
Creates a new shape owner for the given object. Returns [code]owner_id[/code] of the new owner for future reference.
</description>
</method>
<method name="get_collision_exceptions">
<return type="Array">
</return>
<description>
</description>
</method>
<method name="get_collision_layer_bit" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="bit" type="int">
</argument>
<description>
</description>
</method>
<method name="get_collision_mask_bit" qualifiers="const">
<return type="bool">
</return>
<argument index="0" name="bit" type="int">
</argument>
<description>
</description>
</method>
<method name="get_rid" qualifiers="const">
<return type="RID">
</return>
Expand All @@ -58,6 +88,14 @@
If [code]true[/code], the shape owner and its shapes are disabled.
</description>
</method>
<method name="remove_collision_exception_with">
<return type="void">
</return>
<argument index="0" name="body" type="Node">
</argument>
<description>
</description>
</method>
<method name="remove_shape_owner">
<return type="void">
</return>
Expand All @@ -67,6 +105,26 @@
Removes the given shape owner.
</description>
</method>
<method name="set_collision_layer_bit">
<return type="void">
</return>
<argument index="0" name="bit" type="int">
</argument>
<argument index="1" name="value" type="bool">
</argument>
<description>
</description>
</method>
<method name="set_collision_mask_bit">
<return type="void">
</return>
<argument index="0" name="bit" type="int">
</argument>
<argument index="1" name="value" type="bool">
</argument>
<description>
</description>
</method>
<method name="shape_find_owner" qualifiers="const">
<return type="int">
</return>
Expand Down Expand Up @@ -180,6 +238,10 @@
</method>
</methods>
<members>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
</member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
</member>
<member name="input_capture_on_drag" type="bool" setter="set_capture_input_on_drag" getter="get_capture_input_on_drag" default="false">
If [code]true[/code], the [CollisionObject] will continue to receive input events as the mouse is dragged across its shapes.
</member>
Expand Down
174 changes: 162 additions & 12 deletions doc/classes/PhysicalBone.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" ?>
<class name="PhysicalBone" inherits="PhysicsBody" category="Core" version="3.2">
<class name="PhysicalBone" inherits="CollisionObject" category="Core" version="3.2">
<brief_description>
</brief_description>
<description>
Expand All @@ -13,8 +13,26 @@
<description>
</description>
</method>
<method name="get_simulate_physics">
<return type="bool">
<method name="get_bone_name" qualifiers="const">
<return type="String">
</return>
<description>
</description>
</method>
<method name="get_colliding_bodies" qualifiers="const">
<return type="Array">
</return>
<description>
</description>
</method>
<method name="get_joint_force">
<return type="Vector3">
</return>
<description>
</description>
</method>
<method name="get_joint_torque">
<return type="Vector3">
</return>
<description>
</description>
Expand All @@ -25,9 +43,99 @@
<description>
</description>
</method>
<method name="is_static_body">
<return type="bool">
<method name="motor_set_active">
<return type="void">
</return>
<argument index="0" name="active" type="bool">
</argument>
<description>
</description>
</method>
<method name="motor_set_damping_constant">
<return type="void">
</return>
<argument index="0" name="damping_constant" type="float">
</argument>
<description>
</description>
</method>
<method name="motor_set_error_reduction_parameter">
<return type="void">
</return>
<argument index="0" name="error_reduction_parameter" type="float">
</argument>
<description>
</description>
</method>
<method name="motor_set_max_impulse">
<return type="void">
</return>
<argument index="0" name="max_impulse" type="float">
</argument>
<description>
</description>
</method>
<method name="motor_set_maximum_error">
<return type="void">
</return>
<argument index="0" name="maximum_error" type="float">
</argument>
<description>
</description>
</method>
<method name="motor_set_position_target">
<return type="void">
</return>
<argument index="0" name="position" type="float">
</argument>
<description>
</description>
</method>
<method name="motor_set_rotation_target">
<return type="void">
</return>
<argument index="0" name="rotation" type="Vector3">
</argument>
<description>
</description>
</method>
<method name="motor_set_rotation_target_basis">
<return type="void">
</return>
<argument index="0" name="rotation" type="Basis">
</argument>
<description>
</description>
</method>
<method name="motor_set_spring_constant">
<return type="void">
</return>
<argument index="0" name="spring_constant" type="float">
</argument>
<description>
</description>
</method>
<method name="motor_set_velocity">
<return type="void">
</return>
<argument index="0" name="velocity" type="Vector3">
</argument>
<description>
</description>
</method>
<method name="set_bone_id">
<return type="void">
</return>
<argument index="0" name="bone_id" type="int">
</argument>
<description>
</description>
</method>
<method name="set_bone_name">
<return type="void">
</return>
<argument index="0" name="bone_id" type="String">
</argument>
<description>
</description>
</method>
Expand All @@ -37,31 +145,73 @@
</member>
<member name="bounce" type="float" setter="set_bounce" getter="get_bounce" default="0.0">
</member>
<member name="friction" type="float" setter="set_friction" getter="get_friction" default="1.0">
<member name="contact_monitor" type="bool" setter="set_contact_monitor" getter="is_contact_monitor_enabled" default="false">
</member>
<member name="contacts_reported" type="int" setter="set_max_contacts_reported" getter="get_max_contacts_reported" default="0">
</member>
<member name="gravity_scale" type="float" setter="set_gravity_scale" getter="get_gravity_scale" default="1.0">
<member name="disable_parent_collision" type="bool" setter="set_disable_parent_collision" getter="get_disable_parent_collision" default="true">
</member>
<member name="friction" type="float" setter="set_friction" getter="get_friction" default="1.0">
</member>
<member name="joint_offset" type="Transform" setter="set_joint_offset" getter="get_joint_offset" default="Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )">
</member>
<member name="joint_type" type="int" setter="set_joint_type" getter="get_joint_type" enum="PhysicalBone.JointType" default="0">
</member>
<member name="mass" type="float" setter="set_mass" getter="get_mass" default="1.0">
<member name="link_mass" type="float" setter="set_link_mass" getter="get_link_mass" default="1.0">
</member>
<member name="weight" type="float" setter="set_weight" getter="get_weight" default="9.8">
</member>
</members>
<signals>
<signal name="body_entered">
<argument index="0" name="body" type="Node">
</argument>
<description>
</description>
</signal>
<signal name="body_exited">
<argument index="0" name="body" type="Node">
</argument>
<description>
</description>
</signal>
<signal name="body_shape_entered">
<argument index="0" name="body_id" type="int">
</argument>
<argument index="1" name="body" type="Node">
</argument>
<argument index="2" name="body_shape" type="int">
</argument>
<argument index="3" name="local_shape" type="int">
</argument>
<description>
</description>
</signal>
<signal name="body_shape_exited">
<argument index="0" name="body_id" type="int">
</argument>
<argument index="1" name="body" type="Node">
</argument>
<argument index="2" name="body_shape" type="int">
</argument>
<argument index="3" name="local_shape" type="int">
</argument>
<description>
</description>
</signal>
</signals>
<constants>
<constant name="JOINT_TYPE_NONE" value="0" enum="JointType">
</constant>
<constant name="JOINT_TYPE_PIN" value="1" enum="JointType">
<constant name="JOINT_TYPE_FIXED" value="1" enum="JointType">
</constant>
<constant name="JOINT_TYPE_CONE" value="2" enum="JointType">
<constant name="JOINT_TYPE_SLIDER" value="2" enum="JointType">
</constant>
<constant name="JOINT_TYPE_HINGE" value="3" enum="JointType">
</constant>
<constant name="JOINT_TYPE_SLIDER" value="4" enum="JointType">
<constant name="JOINT_TYPE_SPHERICAL" value="4" enum="JointType">
</constant>
<constant name="JOINT_TYPE_6DOF" value="5" enum="JointType">
<constant name="JOINT_TYPE_PLANAR" value="5" enum="JointType">
</constant>
</constants>
</class>
Loading

0 comments on commit c6712d2

Please sign in to comment.