SoftBody3D: Add a property for scaling rest lengths of edge constraints
This commit is contained in:
parent
0d8f33a74a
commit
9f67bf96fa
19 changed files with 126 additions and 0 deletions
|
|
@ -202,6 +202,10 @@ bool JoltSoftBody3D::_ref_shared_data() {
|
|||
vertex_attrib.mCompliance = vertex_attrib.mShearCompliance = inverse_stiffness;
|
||||
|
||||
settings.CreateConstraints(&vertex_attrib, 1, JPH::SoftBodySharedSettings::EBendType::None);
|
||||
float multiplier = 1.0f - shrinking_factor;
|
||||
for (JPH::SoftBodySharedSettings::Edge &e : settings.mEdgeConstraints) {
|
||||
e.mRestLength *= multiplier;
|
||||
}
|
||||
settings.Optimize();
|
||||
} else {
|
||||
iter_shared_data->value.ref_count++;
|
||||
|
|
@ -454,6 +458,14 @@ void JoltSoftBody3D::set_stiffness_coefficient(float p_coefficient) {
|
|||
stiffness_coefficient = CLAMP(p_coefficient, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
float JoltSoftBody3D::get_shrinking_factor() const {
|
||||
return shrinking_factor;
|
||||
}
|
||||
|
||||
void JoltSoftBody3D::set_shrinking_factor(float p_shrinking_factor) {
|
||||
shrinking_factor = p_shrinking_factor;
|
||||
}
|
||||
|
||||
void JoltSoftBody3D::set_pressure(float p_pressure) {
|
||||
if (unlikely(pressure == p_pressure)) {
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue