Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/classes/SoftBody3D.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
<member name="parent_collision_ignore" type="NodePath" setter="set_parent_collision_ignore" getter="get_parent_collision_ignore" default="NodePath(&quot;&quot;)">
[NodePath] to a [CollisionObject3D] this SoftBody3D should avoid clipping.
</member>
<member name="point_count" type="int" setter="" getter="get_point_count">
The number of vertices (points) on the soft body mesh.
</member>
<member name="pressure_coefficient" type="float" setter="set_pressure_coefficient" getter="get_pressure_coefficient" default="0.0">
The pressure coefficient of this soft body. Simulate pressure build-up from inside this body. Higher values increase the strength of this effect.
</member>
Expand Down
14 changes: 14 additions & 0 deletions scene/3d/physics/soft_body_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,8 @@ void SoftBody3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_point_pinned", "point_index", "pinned", "attachment_path", "insert_at"), &SoftBody3D::pin_point, DEFVAL(NodePath()), DEFVAL(-1));
ClassDB::bind_method(D_METHOD("is_point_pinned", "point_index"), &SoftBody3D::is_point_pinned);

ClassDB::bind_method(D_METHOD("get_point_count"), &SoftBody3D::get_point_count);

Comment thread
LordDeatHunter marked this conversation as resolved.
ClassDB::bind_method(D_METHOD("set_ray_pickable", "ray_pickable"), &SoftBody3D::set_ray_pickable);
ClassDB::bind_method(D_METHOD("is_ray_pickable"), &SoftBody3D::is_ray_pickable);

Expand All @@ -396,6 +398,8 @@ void SoftBody3D::_bind_methods() {

ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ray_pickable"), "set_ray_pickable", "is_ray_pickable");

ADD_PROPERTY(PropertyInfo(Variant::INT, "point_count", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NONE), "", "get_point_count");

ADD_PROPERTY(PropertyInfo(Variant::INT, "disable_mode", PROPERTY_HINT_ENUM, "Remove,KeepActive"), "set_disable_mode", "get_disable_mode");

BIND_ENUM_CONSTANT(DISABLE_MODE_REMOVE);
Expand Down Expand Up @@ -692,6 +696,16 @@ Vector3 SoftBody3D::get_point_transform(int p_point_index) {
return PhysicsServer3D::get_singleton()->soft_body_get_point_global_position(physics_rid, p_point_index);
}

int SoftBody3D::get_point_count() const {
if (mesh.is_null()) {
return 0;
}

const int vertex_count = mesh->surface_get_array_len(0);
ERR_FAIL_COND_V(vertex_count < 0, 0);
return vertex_count;
}

void SoftBody3D::apply_impulse(int p_point_index, const Vector3 &p_impulse) {
PhysicsServer3D::get_singleton()->soft_body_apply_point_impulse(physics_rid, p_point_index, p_impulse);
}
Expand Down
1 change: 1 addition & 0 deletions scene/3d/physics/soft_body_3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class SoftBody3D : public MeshInstance3D {

void set_parent_collision_ignore(const NodePath &p_parent_collision_ignore);
const NodePath &get_parent_collision_ignore() const;
int get_point_count() const;

void set_pinned_points_indices(Vector<PinnedPoint> p_pinned_points_indices);
Vector<PinnedPoint> get_pinned_points_indices();
Expand Down
Loading