Commit: d5682b8bf64b35ad0042d7bcabe881aa8bd26f2d
Author: Lukas Tönne
Date: Wed Jun 8 10:32:11 2016 +0200
Branches: compositor-2016
https://developer.blender.org/rBd5682b8bf64b35ad0042d7bcabe881aa8bd26f2d
Fix cloth stability when in perfect rest shape.
The way cloth is coded, structural springs are only effective when stretched,
while bending springs act only when shrunk. However, when cloth is exactly in
its rest shape, neither have any effect, and effectively don't exist for the
implicit solver.
This creates a stability problem in the initial frames of the simulation,
especially considering that gravity seems to act so precisely that it doesn't
disturb the strict equality of lengths, so in parts of the cloth this
springless state can continue for quite a while.
Here is an example of things going haywire because of this and some suspicious
logic in collision code acting together: {F314558}
Changing the condition so that structural springs are active even at exactly
rest length fixes this test case. The use of >= is also supported by the
original paper that the cloth implementation in blender is based on.
Reviewers: lukastoenne
Reviewed By: lukastoenne
Projects: #bf_blender
Differential Revision: https://developer.blender.org/D2028
===================================================================
M source/blender/physics/intern/implicit_blender.c
===================================================================
diff --git a/source/blender/physics/intern/implicit_blender.c
b/source/blender/physics/intern/implicit_blender.c
index 832d516..2ad8ee0 100644
--- a/source/blender/physics/intern/implicit_blender.c
+++ b/source/blender/physics/intern/implicit_blender.c
@@ -1586,8 +1586,11 @@ bool BPH_mass_spring_force_spring_linear(Implicit_Data
*data, int i, int j, floa
// calculate elonglation
spring_length(data, i, j, extent, dir, &length, vel);
-
- if (length > restlen || no_compress) {
+
+ /* This code computes not only the force, but also its derivative.
+ Zero derivative effectively disables the spring for the implicit
solver.
+ Thus length > restlen makes cloth unconstrained at the start of
simulation. */
+ if ((length >= restlen && length > 0) || no_compress) {
float stretch_force, f[3], dfdx[3][3], dfdv[3][3];
stretch_force = stiffness * (length - restlen);
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs