Fix #32920: cloth physics with collision exploding in some cases, due to
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 19 Oct 2012 16:44:08 +0000 (16:44 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 19 Oct 2012 16:44:08 +0000 (16:44 +0000)
uninitialized memory usage.

source/blender/blenkernel/intern/collision.c

index 6631afcddaf5c444fcae78eb6bccc86bf5c4903b..05c916f936295fe19d474cb0fc7dffc639af5c1a 100644 (file)
@@ -458,7 +458,8 @@ static CollPair* cloth_collision(ModifierData *md1, ModifierData *md2,
                distance = 2.0 * (double)( epsilon1 + epsilon2 + ALMOST_ZERO );
 #endif
 
-               if (distance <= (epsilon1 + epsilon2 + ALMOST_ZERO)) {
+               // distance -1 means no collision result
+               if (distance != -1.0f && (distance <= (epsilon1 + epsilon2 + ALMOST_ZERO))) {
                        normalize_v3_v3(collpair->normal, collpair->vector);
 
                        collpair->distance = distance;