From e702c9a7000bf4096546b876ae6a926acaa8d6ec Mon Sep 17 00:00:00 2001 From: Pablo Dobarro Date: Mon, 9 Mar 2020 19:04:37 +0100 Subject: Fix Cloth Brush not working with automasking The cloth brush was not using the automasking values when calculating the mask value on each vertex. Reviewed By: brecht Differential Revision: https://developer.blender.org/D7083 --- source/blender/editors/sculpt_paint/sculpt.c | 6 +++--- source/blender/editors/sculpt_paint/sculpt_cloth.c | 9 ++++++--- source/blender/editors/sculpt_paint/sculpt_intern.h | 3 +++ 3 files changed, 12 insertions(+), 6 deletions(-) (limited to 'source') diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c index 34d0d9a482b..85a606b4618 100644 --- a/source/blender/editors/sculpt_paint/sculpt.c +++ b/source/blender/editors/sculpt_paint/sculpt.c @@ -1470,7 +1470,7 @@ static bool sculpt_automasking_enabled(SculptSession *ss, const Brush *br) return false; } -static float sculpt_automasking_factor_get(SculptSession *ss, int vert) +float SCULPT_automasking_factor_get(SculptSession *ss, int vert) { if (ss->cache->automask) { return ss->cache->automask[vert]; @@ -2255,7 +2255,7 @@ float SCULPT_brush_strength_factor(SculptSession *ss, avg *= 1.0f - mask; /* Automasking. */ - avg *= sculpt_automasking_factor_get(ss, vertex_index); + avg *= SCULPT_automasking_factor_get(ss, vertex_index); return avg; } @@ -4038,7 +4038,7 @@ static void do_elastic_deform_brush_task_cb_ex(void *__restrict userdata, mul_v3_fl(final_disp, 1.0f - *vd.mask); } - mul_v3_fl(final_disp, sculpt_automasking_factor_get(ss, vd.index)); + mul_v3_fl(final_disp, SCULPT_automasking_factor_get(ss, vd.index)); copy_v3_v3(proxy[vd.i], final_disp); diff --git a/source/blender/editors/sculpt_paint/sculpt_cloth.c b/source/blender/editors/sculpt_paint/sculpt_cloth.c index 07a4dab926e..431f95d5509 100644 --- a/source/blender/editors/sculpt_paint/sculpt_cloth.c +++ b/source/blender/editors/sculpt_paint/sculpt_cloth.c @@ -384,7 +384,8 @@ static void do_cloth_brush_solve_simulation_task_cb_ex( sub_v3_v3v3(pos_diff, cloth_sim->pos[i], cloth_sim->prev_pos[i]); mul_v3_fl(pos_diff, (1.0f - cloth_sim->damping)); - const float mask_v = (1.0f - (vd.mask ? *vd.mask : 0.0f)); + const float mask_v = (1.0f - (vd.mask ? *vd.mask : 0.0f)) * + SCULPT_automasking_factor_get(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); @@ -448,8 +449,10 @@ static void cloth_brush_satisfy_constraints(SculptSession *ss, mul_v3_v3fl(correction_vector, v1_to_v2, 1.0f - (constraint_distance / current_distance)); mul_v3_v3fl(correction_vector_half, correction_vector, 0.5f); - const float mask_v1 = (1.0f - SCULPT_vertex_mask_get(ss, v1)); - const float mask_v2 = (1.0f - SCULPT_vertex_mask_get(ss, v2)); + const float mask_v1 = (1.0f - SCULPT_vertex_mask_get(ss, v1)) * + SCULPT_automasking_factor_get(ss, v1); + const float mask_v2 = (1.0f - SCULPT_vertex_mask_get(ss, v2)) * + SCULPT_automasking_factor_get(ss, v2); const float sim_factor_v1 = cloth_brush_simulation_falloff_get( brush, ss->cache->radius, ss->cache->initial_location, cloth_sim->init_pos[v1]); diff --git a/source/blender/editors/sculpt_paint/sculpt_intern.h b/source/blender/editors/sculpt_paint/sculpt_intern.h index 3d1c84511e6..090d1f33d74 100644 --- a/source/blender/editors/sculpt_paint/sculpt_intern.h +++ b/source/blender/editors/sculpt_paint/sculpt_intern.h @@ -203,6 +203,9 @@ void SCULPT_floodfill_execute( void *userdata); void SCULPT_floodfill_free(SculptFloodFill *flood); +/* Automasking. */ +float SCULPT_automasking_factor_get(SculptSession *ss, int vert); + /* Brushes. */ /* Cloth Brush. */ -- cgit v1.2.3