[Bf-blender-cvs] [c32cf06e42f] master: Fix T74808: Division by 0 in Cloth brush solver with overlapping vertices

Pablo Dobarro noreply at git.blender.org
Thu Mar 26 15:38:39 CET 2020


Commit: c32cf06e42fcfd0596d678a407c6e1bd5ca0732a
Author: Pablo Dobarro
Date:   Thu Mar 19 19:14:56 2020 +0100
Branches: master
https://developer.blender.org/rBc32cf06e42fcfd0596d678a407c6e1bd5ca0732a

Fix T74808: Division by 0 in Cloth brush solver with overlapping vertices

This checks that the distance of the current positions of two connected
vertices is not 0 before calculating the correction vectors for those
vertices.

Reviewed By: jbakker

Maniphest Tasks: T74808

Differential Revision: https://developer.blender.org/D7184

===================================================================

M	source/blender/editors/sculpt_paint/sculpt_cloth.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index a1ccae7b5ab..12aaf756cf3 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -446,7 +446,14 @@ static void cloth_brush_satisfy_constraints(SculptSession *ss,
       const float constraint_distance = constraint->length +
                                         (cloth_sim->length_constraint_tweak[v1] * 0.5f) +
                                         (cloth_sim->length_constraint_tweak[v2] * 0.5f);
-      mul_v3_v3fl(correction_vector, v1_to_v2, 1.0f - (constraint_distance / current_distance));
+
+      if (current_distance > 0.0f) {
+        mul_v3_v3fl(correction_vector, v1_to_v2, 1.0f - (constraint_distance / current_distance));
+      }
+      else {
+        copy_v3_v3(correction_vector, v1_to_v2);
+      }
+
       mul_v3_v3fl(correction_vector_half, correction_vector, 0.5f);
 
       const float mask_v1 = (1.0f - SCULPT_vertex_mask_get(ss, v1)) *



More information about the Bf-blender-cvs mailing list