From aa4cf47e403ba3f098d89e991dafc9fec30423c4 Mon Sep 17 00:00:00 2001 From: Philipp Oeser Date: Mon, 31 Aug 2020 16:00:24 +0200 Subject: [PATCH] Fix T80273: Restrict option in weight paint doesn't work with gradient With the 'Restrict' option, the gradient should be restricted to the assigned vertex, just like the other weight paint tools. Maniphest Tasks: T80273 Differential Revision: https://developer.blender.org/D8761 --- .../editors/sculpt_paint/paint_vertex_weight_ops.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c index 73014f9f2de..9b8252e1add 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c +++ b/source/blender/editors/sculpt_paint/paint_vertex_weight_ops.c @@ -594,6 +594,7 @@ typedef struct WPGradient_userData { /* options */ bool use_select; + bool use_vgroup_restrict; short type; float weightpaint; } WPGradient_userData; @@ -602,8 +603,13 @@ static void gradientVert_update(WPGradient_userData *grad_data, int index) { Mesh *me = grad_data->me; WPGradient_vertStore *vs = &grad_data->vert_cache->elem[index]; - float alpha; + /* Optionally restrict to assigned verices only. */ + if (grad_data->use_vgroup_restrict && ((vs->flag & VGRAD_STORE_DW_EXIST) == 0)) { + return; + } + + float alpha; if (grad_data->type == WPAINT_GRADIENT_TYPE_LINEAR) { alpha = line_point_factor_v2(vs->sco, grad_data->sco_start, grad_data->sco_end); } @@ -815,6 +821,7 @@ static int paint_weight_gradient_exec(bContext *C, wmOperator *op) data.brush = brush; data.weightpaint = BKE_brush_weight_get(scene, brush); + data.use_vgroup_restrict = (ts->wpaint->flag & VP_FLAG_VGROUP_RESTRICT) != 0; } ED_view3d_init_mats_rv3d(ob, region->regiondata);