From 48fd10a77dd8e53eb0ef063ce11bf4086fdb9f17 Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Sun, 18 Oct 2020 01:10:19 +0200 Subject: Sculpt: Reduce the displacement step in the cloth solver Previously the base displacement for solving the constraints was always using 0.5, which may introduce artifacts when multiple constraints of different types are computed for the same vertex. This introduces a factor that reduces the base displacement of the solver, reducing the artifacts. Reviewed By: sergey Differential Revision: https://developer.blender.org/D9202 --- source/blender/editors/sculpt_paint/sculpt_cloth.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'source/blender/editors/sculpt_paint') diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c index 591168fd3a2..1a1200bb6c2 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.c +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c @@ -153,6 +153,8 @@ static float cloth_brush_simulation_falloff_get(const Brush *brush, #define CLOTH_LENGTH_CONSTRAINTS_BLOCK 100000 #define CLOTH_SIMULATION_ITERATIONS 5 + +#define CLOTH_SOLVER_DISPLACEMENT_FACTOR 0.6f #define CLOTH_MAX_CONSTRAINTS_PER_VERTEX 1024 #define CLOTH_SIMULATION_TIME_STEP 0.01f #define CLOTH_DEFORMATION_SNAKEHOOK_STRENGTH 0.35f @@ -805,10 +807,13 @@ static void cloth_brush_satisfy_constraints(SculptSession *ss, (cloth_sim->length_constraint_tweak[v2] * 0.5f); if (current_distance > 0.0f) { - mul_v3_v3fl(correction_vector, v1_to_v2, 1.0f - (constraint_distance / current_distance)); + mul_v3_v3fl(correction_vector, + v1_to_v2, + CLOTH_SOLVER_DISPLACEMENT_FACTOR * + (1.0f - (constraint_distance / current_distance))); } else { - copy_v3_v3(correction_vector, v1_to_v2); + mul_v3_v3fl(correction_vector, v1_to_v2, CLOTH_SOLVER_DISPLACEMENT_FACTOR); } mul_v3_v3fl(correction_vector_half, correction_vector, 0.5f); -- cgit v1.2.3