Merge pull request #33209 from Jummit/soft-body-tutorial

Link SoftBody tutorial in docs
This commit is contained in:
Rémi Verschelde 2019-11-01 14:04:50 +01:00 committed by GitHub
commit 83d393a71a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 18 deletions

View File

@ -7,6 +7,7 @@
A deformable physics body. Used to create elastic or deformable objects such as cloth, rubber, or other flexible materials. A deformable physics body. Used to create elastic or deformable objects such as cloth, rubber, or other flexible materials.
</description> </description>
<tutorials> <tutorials>
<link>https://docs.godotengine.org/en/latest/tutorials/physics/soft_body.html</link>
</tutorials> </tutorials>
<methods> <methods>
<method name="add_collision_exception_with"> <method name="add_collision_exception_with">
@ -43,12 +44,6 @@
Returns an individual bit on the collision mask. Returns an individual bit on the collision mask.
</description> </description>
</method> </method>
<method name="is_ray_pickable" qualifiers="const">
<return type="bool">
</return>
<description>
</description>
</method>
<method name="remove_collision_exception_with"> <method name="remove_collision_exception_with">
<return type="void"> <return type="void">
</return> </return>
@ -80,25 +75,20 @@
Sets individual bits on the collision mask. Use this if you only need to change one layer's value. Sets individual bits on the collision mask. Use this if you only need to change one layer's value.
</description> </description>
</method> </method>
<method name="set_ray_pickable">
<return type="void">
</return>
<argument index="0" name="ray_pickable" type="bool">
</argument>
<description>
</description>
</method>
</methods> </methods>
<members> <members>
<member name="ray_pickable" type="bool" setter="set_ray_pickable" getter="is_ray_pickable" default="false">
If true, the [SoftBody] will respond to [RayCast]s.
</member>
<member name="areaAngular_stiffness" type="float" setter="set_areaAngular_stiffness" getter="get_areaAngular_stiffness" default="0.5"> <member name="areaAngular_stiffness" type="float" setter="set_areaAngular_stiffness" getter="get_areaAngular_stiffness" default="0.5">
</member> </member>
<member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1"> <member name="collision_layer" type="int" setter="set_collision_layer" getter="get_collision_layer" default="1">
The physics layers this area is in. The physics layers this SoftBody is in.
Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property. Collidable objects can exist in any of 32 different layers. These layers work like a tagging system, and are not visual. A collidable can use these layers to select with which objects it can collide, using the collision_mask property.
A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A. A contact is detected if object A is in any of the layers that object B scans, or object B is in any layer scanned by object A.
</member> </member>
<member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1">
The physics layers this area scans for collisions. The physics layers this SoftBody scans for collisions.
</member> </member>
<member name="damping_coefficient" type="float" setter="set_damping_coefficient" getter="get_damping_coefficient" default="0.01"> <member name="damping_coefficient" type="float" setter="set_damping_coefficient" getter="get_damping_coefficient" default="0.01">
</member> </member>
@ -107,6 +97,7 @@
<member name="linear_stiffness" type="float" setter="set_linear_stiffness" getter="get_linear_stiffness" default="0.5"> <member name="linear_stiffness" type="float" setter="set_linear_stiffness" getter="get_linear_stiffness" default="0.5">
</member> </member>
<member name="parent_collision_ignore" type="NodePath" setter="set_parent_collision_ignore" getter="get_parent_collision_ignore" default="NodePath(&quot;&quot;)"> <member name="parent_collision_ignore" type="NodePath" setter="set_parent_collision_ignore" getter="get_parent_collision_ignore" default="NodePath(&quot;&quot;)">
[NodePath] to a [CollisionObject] this SoftBody should avoid clipping.
</member> </member>
<member name="pose_matching_coefficient" type="float" setter="set_pose_matching_coefficient" getter="get_pose_matching_coefficient" default="0.0"> <member name="pose_matching_coefficient" type="float" setter="set_pose_matching_coefficient" getter="get_pose_matching_coefficient" default="0.0">
</member> </member>
@ -116,6 +107,7 @@
Increasing this value will improve the resulting simulation, but can affect performance. Use with care. Increasing this value will improve the resulting simulation, but can affect performance. Use with care.
</member> </member>
<member name="total_mass" type="float" setter="set_total_mass" getter="get_total_mass" default="1.0"> <member name="total_mass" type="float" setter="set_total_mass" getter="get_total_mass" default="1.0">
The SoftBody's mass.
</member> </member>
<member name="volume_stiffness" type="float" setter="set_volume_stiffness" getter="get_volume_stiffness" default="0.5"> <member name="volume_stiffness" type="float" setter="set_volume_stiffness" getter="get_volume_stiffness" default="0.5">
</member> </member>

View File

@ -115,7 +115,7 @@ SoftBody::PinnedPoint SoftBody::PinnedPoint::operator=(const PinnedPoint &obj) {
void SoftBody::_update_pickable() { void SoftBody::_update_pickable() {
if (!is_inside_tree()) if (!is_inside_tree())
return; return;
bool pickable = ray_pickable && is_inside_tree() && is_visible_in_tree(); bool pickable = ray_pickable && is_visible_in_tree();
PhysicsServer::get_singleton()->soft_body_set_ray_pickable(physics_rid, pickable); PhysicsServer::get_singleton()->soft_body_set_ray_pickable(physics_rid, pickable);
} }
@ -395,6 +395,8 @@ void SoftBody::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "damping_coefficient", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_damping_coefficient", "get_damping_coefficient"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "damping_coefficient", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_damping_coefficient", "get_damping_coefficient");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "drag_coefficient", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_coefficient", "get_drag_coefficient"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "drag_coefficient", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_drag_coefficient", "get_drag_coefficient");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "pose_matching_coefficient", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_pose_matching_coefficient", "get_pose_matching_coefficient"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "pose_matching_coefficient", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_pose_matching_coefficient", "get_pose_matching_coefficient");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ray_pickable"), "set_ray_pickable", "is_ray_pickable");
} }
String SoftBody::get_configuration_warning() const { String SoftBody::get_configuration_warning() const {
@ -700,7 +702,8 @@ SoftBody::SoftBody() :
collision_mask(1), collision_mask(1),
collision_layer(1), collision_layer(1),
simulation_started(false), simulation_started(false),
pinned_points_cache_dirty(true) { pinned_points_cache_dirty(true),
ray_pickable(true) {
PhysicsServer::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id()); PhysicsServer::get_singleton()->body_attach_object_instance_id(physics_rid, get_instance_id());
//set_notify_transform(true); //set_notify_transform(true);