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-07-30 02:36:12 +0300
committerPablo Dobarro <pablodp606@gmail.com>2020-07-30 16:59:35 +0300
commit49c1359b5568109244aac384f8e50e5bb12da95f (patch)
tree7ef457d3c73fbd6c4961ddecbaab011d94842693 /source/blender/editors/sculpt_paint/sculpt_cloth.c
parent27b643d27adc0b135df2b69794885778ca5b5718 (diff)
Sculpt: Enable persistent base for the cloth brush
The cloth brush builds the constraints when the stroke starts usign the current state of the mesh. This means that deformations profuced by the simulattion will accumulate after multiple strokes as it will always start from the previous deformed state. While this is useful in many cases, for other uses it is convenient to always simulate the same initial shape, but applying different forces to it. The persistent base options work like the persistent base in the layer brush and allows the cloth brush to not accumulate deformation after each stroke. When enabled, constraints are created for the shape stored in the persistent base instead of from the current state of the mesh. Reviewed By: sergey Differential Revision: https://developer.blender.org/D8428
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_cloth.c')
-rw-r--r--source/blender/editors/sculpt_paint/sculpt_cloth.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c
index 434206c1584..763a765768f 100644
--- a/source/blender/editors/sculpt_paint/sculpt_cloth.c
+++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c
@@ -126,7 +126,8 @@ static void cloth_brush_reallocate_constraints(SculptClothSimulation *cloth_sim)
static void cloth_brush_add_length_constraint(SculptSession *ss,
SculptClothSimulation *cloth_sim,
const int v1,
- const int v2)
+ const int v2,
+ const bool use_persistent)
{
SculptClothLengthConstraint *length_constraint =
&cloth_sim->length_constraints[cloth_sim->tot_length_constraints];
@@ -137,7 +138,14 @@ static void cloth_brush_add_length_constraint(SculptSession *ss,
length_constraint->elem_position_a = cloth_sim->pos[v1];
length_constraint->elem_position_b = cloth_sim->pos[v2];
- length_constraint->length = len_v3v3(SCULPT_vertex_co_get(ss, v1), SCULPT_vertex_co_get(ss, v2));
+ if (use_persistent) {
+ length_constraint->length = len_v3v3(SCULPT_vertex_persistent_co_get(ss, v1),
+ SCULPT_vertex_persistent_co_get(ss, v2));
+ }
+ else {
+ length_constraint->length = len_v3v3(SCULPT_vertex_co_get(ss, v1),
+ SCULPT_vertex_co_get(ss, v2));
+ }
length_constraint->strength = 1.0f;
cloth_sim->tot_length_constraints++;
@@ -180,6 +188,8 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
PBVHVertexIter vd;
+ const bool use_persistent = brush != NULL && brush->flag & BRUSH_PERSISTENT;
+
BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE)
{
if (len_squared_v3v3(vd.co, data->cloth_sim_initial_location) <
@@ -211,7 +221,7 @@ static void do_cloth_brush_build_constraints_task_cb_ex(
if (c_i != c_j && !cloth_brush_sim_has_length_constraint(
data->cloth_sim, build_indices[c_i], build_indices[c_j])) {
cloth_brush_add_length_constraint(
- ss, data->cloth_sim, build_indices[c_i], build_indices[c_j]);
+ ss, data->cloth_sim, build_indices[c_i], build_indices[c_j], use_persistent);
}
}
}