Commit: 6699590a0254c56d11bef2592d610abcc21344cd
Author: Alexander Gavrilov
Date:   Tue Jan 19 14:56:28 2016 +0300
Branches: master
https://developer.blender.org/rB6699590a0254c56d11bef2592d610abcc21344cd

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.

===================================================================

M       source/blender/editors/sculpt_paint/paint_vertex.c

===================================================================

diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c 
b/source/blender/editors/sculpt_paint/paint_vertex.c
index 496055b..78363ef 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

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to