[Bf-blender-cvs] [f084e36] soc-2013-paint: Fix accumulated brushes. Those would never completely fill canvas because mask factor of brush never reached 1.0 due to it being calculated by geometric series with factor less than one. Now simply add new mask to the accumulated mask.

Antony Riakiotakis noreply at git.blender.org
Tue Apr 1 03:25:45 CEST 2014


Commit: f084e3691b4bb15beca85644a5405cf63d869569
Author: Antony Riakiotakis
Date:   Tue Apr 1 04:24:48 2014 +0300
https://developer.blender.org/rBf084e3691b4bb15beca85644a5405cf63d869569

Fix accumulated brushes. Those would never completely fill canvas
because mask factor of brush never reached 1.0 due to it being
calculated by geometric series with factor less than one. Now simply add
new mask to the accumulated mask.

Note - it may be preferable to handle airbrushes like that too, since
they suffer from the same issue.

2D case will be handled separately, things look unnecessarily complex
here already, and I have totally forgotten to handle correct masking in
float case.

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

M	source/blender/editors/sculpt_paint/paint_image.c
M	source/blender/editors/sculpt_paint/paint_image_proj.c

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

diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c
index 2eb6382..396c86c 100644
--- a/source/blender/editors/sculpt_paint/paint_image.c
+++ b/source/blender/editors/sculpt_paint/paint_image.c
@@ -637,16 +637,15 @@ typedef struct PaintOperation {
 
 bool paint_use_opacity_masking(Brush *brush)
 {
-	return ((brush->flag & BRUSH_AIRBRUSH) ||
-	        (brush->flag & BRUSH_DRAG_DOT) ||
-	        (brush->flag & BRUSH_ANCHORED) ||
-	        (brush->imagepaint_tool == PAINT_TOOL_SMEAR) ||
-	        (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) ||
-	        (brush->imagepaint_tool == PAINT_TOOL_FILL) ||
-	        (brush->flag & BRUSH_USE_GRADIENT) ||
-	        (brush->mtex.tex && !ELEM3(brush->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_3D)) ||
-	        brush->flag & BRUSH_ACCUMULATE) ?
-				false : true;
+	return (brush->flag & BRUSH_AIRBRUSH) ||
+	       (brush->flag & BRUSH_DRAG_DOT) ||
+	       (brush->flag & BRUSH_ANCHORED) ||
+	       (brush->imagepaint_tool == PAINT_TOOL_SMEAR) ||
+	       (brush->imagepaint_tool == PAINT_TOOL_SOFTEN) ||
+	       (brush->imagepaint_tool == PAINT_TOOL_FILL) ||
+	       (brush->flag & BRUSH_USE_GRADIENT) ||
+	       (brush->mtex.tex && !ELEM3(brush->mtex.brush_map_mode, MTEX_MAP_MODE_TILED, MTEX_MAP_MODE_STENCIL, MTEX_MAP_MODE_3D)) ?
+	            false : true;
 }
 
 void paint_brush_color_get(struct Brush *br, bool color_correction, bool invert, float distance, float pressure, float color[3])
diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.c b/source/blender/editors/sculpt_paint/paint_image_proj.c
index c9a2005..c06862f 100644
--- a/source/blender/editors/sculpt_paint/paint_image_proj.c
+++ b/source/blender/editors/sculpt_paint/paint_image_proj.c
@@ -4116,15 +4116,19 @@ static void *do_projectpaint_thread(void *ph_v)
 							 * Instead we use a formula that adds up but approaches brush_alpha slowly
 							 * and never exceeds it, which gives nice smooth results. */
 							float mask_accum = *projPixel->mask_accum;
+							float max_mask = brush_alpha * mask * 65535.0f;
 
 							if (ps->is_maskbrush) {
 								float texmask = BKE_brush_sample_masktex(ps->scene, ps->brush, projPixel->projCoSS, thread_index, pool);
 								CLAMP(texmask, 0.0f, 1.0f);
-								mask = mask_accum + (brush_alpha * texmask * 65535.0f - mask_accum) * mask;
-							}
-							else {
-								mask = mask_accum + (brush_alpha * 65535.0f - mask_accum) * mask;
+								max_mask *= texmask;
 							}
+
+							if (brush->flag & BRUSH_ACCUMULATE)
+								mask = min_ff(mask_accum + max_mask, 65535.0f);
+							else
+								mask = mask_accum + (max_mask - mask_accum) * mask;
+
 							mask_short = (unsigned short)mask;
 
 							if (mask_short > *projPixel->mask_accum) {




More information about the Bf-blender-cvs mailing list