Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Dobarro <pablodp606@gmail.com>2020-03-19 21:14:56 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-03-26 17:38:17 +0300
commitc32cf06e42fcfd0596d678a407c6e1bd5ca0732a (patch)
tree5da1f0b58bbc8949c10301738d63b4969624102c /source/blender/editors/sculpt_paint
parent4ff3d5adedcf92b5f2766ae912340358f83fc0d9 (diff)
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
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_cloth.c9
1 files changed, 8 insertions, 1 deletions
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)) *