Page MenuHome
Paste P470

D2150 ammend
ActivePublic

Authored by Bastien Montagne (mont29) on Apr 26 2017, 9:05 AM.
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 9f472d3b9d1..e67d5c6f0cf 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -212,7 +212,7 @@ typedef struct SculptSession {
unsigned int (*total_color)[3];
double *total_weight;
unsigned int *tot_loops_hit;
- float *max_weight;
+ float *stroke_accumulated_alpha;
unsigned int *previous_color;
bool building_vp_handle;
} vwpaint;
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index b8dbfc6f71b..ff3d7451595 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -668,7 +668,7 @@ void BKE_sculptsession_free_vwpaint_data(struct SculptSession *ss)
MEM_SAFE_FREE(ss->modes.vwpaint.tot_loops_hit);
MEM_SAFE_FREE(ss->modes.vwpaint.total_color);
MEM_SAFE_FREE(ss->modes.vwpaint.total_weight);
- MEM_SAFE_FREE(ss->modes.vwpaint.max_weight);
+ MEM_SAFE_FREE(ss->modes.vwpaint.stroke_accumulated_alpha);
MEM_SAFE_FREE(ss->modes.vwpaint.previous_color);
}
diff --git a/source/blender/editors/sculpt_paint/paint_vertex.c b/source/blender/editors/sculpt_paint/paint_vertex.c
index c934fc77274..f0ee89c0fea 100644
--- a/source/blender/editors/sculpt_paint/paint_vertex.c
+++ b/source/blender/editors/sculpt_paint/paint_vertex.c
@@ -1741,7 +1741,7 @@ static void vertex_paint_init_session_average_arrays(Object *ob)
MEM_callocN(totNode * sizeof(double), "total_weight");
ob->sculpt->modes.vwpaint.tot_loops_hit =
MEM_callocN(totNode * sizeof(unsigned int), "tot_loops_hit");
- ob->sculpt->modes.vwpaint.max_weight =
+ ob->sculpt->modes.vwpaint.stroke_accumulated_alpha =
MEM_callocN(me->totvert * sizeof(float), "max_weight");
ob->sculpt->modes.vwpaint.previous_color =
MEM_callocN(me->totloop * sizeof(unsigned int), "previous_color");
@@ -2209,8 +2209,7 @@ static bool wpaint_stroke_test_start(bContext *C, wmOperator *op, const float mo
vertex_paint_init_session_maps(ob);
vertex_paint_init_session_average_arrays(ob);
- for (int i = 0; i < me->totvert; i++)
- ss->modes.vwpaint.max_weight[i] = -1.0;
+ copy_vn_fl(ss->modes.vwpaint.stroke_accumulated_alpha, me->totvert, 0.0f);
return true;
}
@@ -2569,22 +2568,15 @@ static void do_wpaint_brush_draw_task_cb_ex(
const float brush_fade = BKE_brush_curve_strength(brush, sqrtf(test.dist), cache->radius);
float final_alpha = view_dot * brush_fade * brush_strength * grid_alpha * brush_alpha_pressure;
- /* Spray logic */
+ /* Non-spray logic: we want to limit effect of overlapping inside a single same stroke.
+ * For now, we simply accumulate all 'final_alpha' (i.e.c omputed strength) applied,
+ * and skip it when it reaches brush strength. */
if ((data->vp->flag & VP_SPRAY) == 0) {
- MDeformVert *dv = &data->me->dvert[v_index];
- const MDeformWeight *dw;
- dw = (data->vp->flag & VP_ONLYVGROUP) ?
- defvert_find_index(dv, data->wpi->active.index) :
- defvert_verify_index(dv, data->wpi->active.index);
- const float weight_curr = dw->weight;
- if (ss->modes.vwpaint.max_weight[v_index] < 0) {
- ss->modes.vwpaint.max_weight[v_index] = min_ff(brush_strength + weight_curr, 1.0f);
- }
- CLAMP(final_alpha, 0.0, ss->modes.vwpaint.max_weight[v_index] - weight_curr);
-
- if (weight_curr >= ss->modes.vwpaint.max_weight[v_index]) {
+ final_alpha = max_ff(0.0f, (brush_strength * brush_fade) - ss->modes.vwpaint.stroke_accumulated_alpha[v_index]);
+ if (final_alpha == 0.0f) {
continue;
}
+ ss->modes.vwpaint.stroke_accumulated_alpha[v_index] += final_alpha;
}
do_weight_paint_vertex(