diff options
author | Pablo Dobarro <pablodp606@gmail.com> | 2020-10-15 20:34:54 +0300 |
---|---|---|
committer | Pablo Dobarro <pablodp606@gmail.com> | 2020-10-15 20:35:37 +0300 |
commit | 6fe3521481b26ad6b6411b0863dfcd4ac2a81132 (patch) | |
tree | 31339c1ed545b1fa923ef8ec8fc1a3b5072b4144 /source/blender/editors/sculpt_paint/sculpt_cloth.c | |
parent | da7ace00d5fb534d8583c0b70497d7819bc7b273 (diff) |
Sculpt: Add global automasking settings support in filters
When using the sculpt filters, global automasking settings that affect
all brushes were ignored because the automasking system was not
implemented for filters, making filters and brushes react differently
to the global sculpt settings which creates confusion.
This makes all filter tools (mesh, cloth, color) use the same general
automasking settings and features as the brush tools. Filters will now
use the settings in the options panel to limit their effect.
This also removes the "use Face Sets" option from the Mesh filter code,
as it was duplicated from the automasking code just to have that
funcitonality. This is now handled by the regular automasking system.
The "Use Face Sets" option is still available in the cloth filter as that
option limits the action of the forces, not the displacement.
After this, it is possible to initialize the automasking system
independently from the StrokeCache and Brush settings, so it can also be
added to more tools and features in the future.
Fixes T81619
Reviewed By: dbystedt, sergey
Maniphest Tasks: T81619
Differential Revision: https://developer.blender.org/D9171
Diffstat (limited to 'source/blender/editors/sculpt_paint/sculpt_cloth.c')
-rw-r--r-- | source/blender/editors/sculpt_paint/sculpt_cloth.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c index 84d156122f3..efd80eef0cb 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.c +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c @@ -723,6 +723,8 @@ static void do_cloth_brush_solve_simulation_task_cb_ex( return; } + AutomaskingCache *automasking = SCULPT_automasking_active_cache_get(ss); + BKE_pbvh_vertex_iter_begin(ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { float sim_location[3]; @@ -743,7 +745,7 @@ static void do_cloth_brush_solve_simulation_task_cb_ex( mul_v3_fl(pos_diff, (1.0f - cloth_sim->damping) * sim_factor); const float mask_v = (1.0f - (vd.mask ? *vd.mask : 0.0f)) * - SCULPT_automasking_factor_get(ss, vd.index); + SCULPT_automasking_factor_get(automasking, ss, vd.index); madd_v3_v3fl(cloth_sim->pos[i], pos_diff, mask_v); madd_v3_v3fl(cloth_sim->pos[i], cloth_sim->acceleration[i], mask_v); @@ -775,6 +777,9 @@ static void cloth_brush_satisfy_constraints(SculptSession *ss, Brush *brush, SculptClothSimulation *cloth_sim) { + + AutomaskingCache *automasking = SCULPT_automasking_active_cache_get(ss); + for (int constraint_it = 0; constraint_it < CLOTH_SIMULATION_ITERATIONS; constraint_it++) { for (int i = 0; i < cloth_sim->tot_length_constraints; i++) { const SculptClothLengthConstraint *constraint = &cloth_sim->length_constraints[i]; @@ -807,9 +812,9 @@ static void cloth_brush_satisfy_constraints(SculptSession *ss, mul_v3_v3fl(correction_vector_half, correction_vector, 0.5f); const float mask_v1 = (1.0f - SCULPT_vertex_mask_get(ss, v1)) * - SCULPT_automasking_factor_get(ss, v1); + SCULPT_automasking_factor_get(automasking, ss, v1); const float mask_v2 = (1.0f - SCULPT_vertex_mask_get(ss, v2)) * - SCULPT_automasking_factor_get(ss, v2); + SCULPT_automasking_factor_get(automasking, ss, v2); float sim_location[3]; cloth_brush_simulation_location_get(ss, brush, sim_location); @@ -1354,6 +1359,7 @@ static void cloth_filter_apply_forces_task_cb(void *__restrict userdata, BKE_pbvh_vertex_iter_begin(ss->pbvh, node, vd, PBVH_ITER_UNIQUE) { float fade = vd.mask ? *vd.mask : 0.0f; + fade *= SCULPT_automasking_factor_get(ss->filter_cache->automasking, ss, vd.index); fade = 1.0f - fade; float force[3] = {0.0f, 0.0f, 0.0f}; float disp[3], temp[3], transform[3][3]; @@ -1498,6 +1504,8 @@ static int sculpt_cloth_filter_invoke(bContext *C, wmOperator *op, const wmEvent SCULPT_undo_push_begin("Cloth filter"); SCULPT_filter_cache_init(C, ob, sd, SCULPT_UNDO_COORDS); + ss->filter_cache->automasking = SCULPT_automasking_cache_init(sd, NULL, ob); + const float cloth_mass = RNA_float_get(op->ptr, "cloth_mass"); const float cloth_damping = RNA_float_get(op->ptr, "cloth_damping"); const bool use_collisions = RNA_boolean_get(op->ptr, "use_collisions"); |