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:
authorAlexander Gavrilov <angavrilov@gmail.com>2016-01-19 14:56:28 +0300
committerCampbell Barton <ideasman42@gmail.com>2016-01-20 23:27:29 +0300
commit6699590a0254c56d11bef2592d610abcc21344cd (patch)
tree168418f91b000c5e5d43c059e4e35e4eed94556d /source/blender/editors/sculpt_paint
parent42c984e2c3c0856b55e7c0be1761e4a516e4dbd2 (diff)
Weight Paint: Multi-paint support for blur tool
Use the collective weight when using blurring. This brings blur in sync with the rest of multi-paint modifications. Also, blur has no business calling `defvert_verify_index` anyway when it simply wants to read weights.
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r--source/blender/editors/sculpt_paint/paint_vertex.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index 496055bfb47..78363ef3ccf 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -2042,6 +2042,19 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float UN
return true;
}
+static float wpaint_blur_weight_single(MDeformVert *dv, WeightPaintInfo *wpi)
+{
+ return defvert_find_weight(dv, wpi->active.index);
+}
+
+static float wpaint_blur_weight_multi(MDeformVert *dv, WeightPaintInfo *wpi)
+{
+ float weight = BKE_defvert_multipaint_collective_weight(
+ dv, wpi->defbase_tot, wpi->defbase_sel, wpi->defbase_tot_sel, wpi->do_auto_normalize);
+ CLAMP(weight, 0.0f, 1.0f);
+ return weight;
+}
+
static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerRNA *itemptr)
{
Scene *scene = CTX_data_scene(C);
@@ -2063,11 +2076,8 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
bool use_face_sel;
bool use_depth;
- MDeformWeight *(*dw_func)(MDeformVert *, const int) =
- (brush->vertexpaint_tool == PAINT_BLEND_BLUR) ?
- ((wp->flag & VP_ONLYVGROUP) ?
- (MDeformWeight *(*)(MDeformVert *, const int))defvert_find_index :
- defvert_verify_index) : NULL;
+ float (*blur_weight_func)(MDeformVert *, WeightPaintInfo *) =
+ wpd->do_multipaint ? wpaint_blur_weight_multi : wpaint_blur_weight_single;
const float pressure = RNA_float_get(itemptr, "pressure");
const float brush_size_pressure = BKE_brush_size_get(scene, brush) * (BKE_brush_use_size_pressure(scene, brush) ? pressure : 1.0f);
@@ -2168,8 +2178,8 @@ static void wpaint_stroke_update_step(bContext *C, struct PaintStroke *stroke, P
const unsigned int vidx = v_idx_var; \
const float fac = calc_vp_strength_col_dl(wp, vc, wpd->vertexcosnos[vidx].co, mval, brush_size_pressure, NULL); \
if (fac > 0.0f) { \
- MDeformWeight *dw = dw_func(&me->dvert[vidx], wpi.active.index); \
- paintweight += dw ? (dw->weight * fac) : 0.0f; \
+ float weight = blur_weight_func(&me->dvert[vidx], &wpi); \
+ paintweight += weight * fac; \
totw += fac; \
} \
} (void)0