[Bf-blender-cvs] [7bc1657d051] sculpt-dev: Fix cloth sim artifacts on planes
Pablo Dobarro
noreply at git.blender.org
Wed Dec 16 21:36:54 CET 2020
Commit: 7bc1657d05148a8634b3f8edc2057ca378d74e60
Author: Pablo Dobarro
Date: Tue Dec 15 22:13:11 2020 +0100
Branches: sculpt-dev
https://developer.blender.org/rB7bc1657d05148a8634b3f8edc2057ca378d74e60
Fix cloth sim artifacts on planes
===================================================================
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 0ac0d796ca4..3549284eae3 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -756,6 +756,17 @@ static void cloth_brush_solve_collision(Object *object,
}
}
}
+static void cloth_simulation_noise_get(float *r_noise,
+ SculptSession *ss,
+ const int index,
+ const float strength)
+{
+ const uint *hash_co = (const uint *)SCULPT_vertex_co_get(ss, index);
+ for (int i = 0; i < 3; i++) {
+ const uint hash = BLI_hash_int_2d(hash_co[0], hash_co[1]) ^ BLI_hash_int_2d(hash_co[2], i);
+ r_noise[i] = (hash * (1.0f / 0xFFFFFFFF) - 0.5f) * strength;
+ }
+}
static void do_cloth_brush_solve_simulation_task_cb_ex(
void *__restrict userdata, const int n, const TaskParallelTLS *__restrict UNUSED(tls))
@@ -801,6 +812,12 @@ static void do_cloth_brush_solve_simulation_task_cb_ex(
madd_v3_v3fl(cloth_sim->pos[i], pos_diff, mask_v);
madd_v3_v3fl(cloth_sim->pos[i], cloth_sim->acceleration[i], mask_v);
+ /* Prevents the vertices from sliding without creating folds when all vertices and forces are
+ * in the same plane. */
+ float noise[3];
+ cloth_simulation_noise_get(noise, ss, vd.index, 0.000001f);
+ add_v3_v3(cloth_sim->pos[i], noise);
+
if (cloth_sim->collider_list != NULL) {
cloth_brush_solve_collision(data->ob, cloth_sim, i);
}
More information about the Bf-blender-cvs
mailing list