[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60336] branches/soc-2013-paint/source/ blender/editors/sculpt_paint: Make fill tool listen to brush strength ( Allows to quickly do semi-

Antony Riakiotakis kalast at gmail.com
Mon Sep 23 17:34:46 CEST 2013


Revision: 60336
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60336
Author:   psy-fi
Date:     2013-09-23 15:34:45 +0000 (Mon, 23 Sep 2013)
Log Message:
-----------
Make fill tool listen to brush strength (Allows to quickly do semi-

Modified Paths:
--------------
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_2d.c
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c	2013-09-23 14:51:35 UTC (rev 60335)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c	2013-09-23 15:34:45 UTC (rev 60336)
@@ -822,7 +822,7 @@
 				float color[3];
 
 				srgb_to_linearrgb_v3_v3(color, brush->rgb);
-				paint_2d_bucket_fill(C, color);
+				paint_2d_bucket_fill(C, color, brush->alpha);
 			}
 			else {
 				paint_proj_stroke(C, pop->custom_paint, pop->startmouse, pop->prevmouse, 1.0, 0.0);
@@ -1435,7 +1435,7 @@
 	undo_paint_push_begin(UNDO_PAINT_IMAGE, op->type->name,
 	                      image_undo_restore, image_undo_free);
 
-	paint_2d_bucket_fill(C, color);
+	paint_2d_bucket_fill(C, color, 1.0);
 
 	undo_paint_push_end(UNDO_PAINT_IMAGE);
 }

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_2d.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_2d.c	2013-09-23 14:51:35 UTC (rev 60335)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_2d.c	2013-09-23 15:34:45 UTC (rev 60336)
@@ -1281,7 +1281,7 @@
 
 
 /* this function expects linear space color values */
-void paint_2d_bucket_fill (const bContext *C, float color[3])
+void paint_2d_bucket_fill (const bContext *C, float color[3], float strength)
 {
 	SpaceImage *sima = CTX_wm_space_image(C);
 	Image *ima = sima->image;
@@ -1307,10 +1307,10 @@
 
 	if (!do_float) {
 		linearrgb_to_srgb_uchar3((unsigned char *)&color_b, color);
-		*(((char *)&color_b) + 3) = 255;
+		*(((char *)&color_b) + 3) = strength*255;
 	} else {
 		copy_v3_v3(color_f, color);
-		color_f[3] = 1.0;
+		color_f[3] = strength;
 	}
 
 	/* this will be substituted by something else when selection is available */
@@ -1319,14 +1319,16 @@
 	if (do_float) {
 		for (; i < ibuf->x; i++) {
 			for (j = 0; j < ibuf->y; j++) {
-				copy_v4_v4(ibuf->rect_float + 4 * (j * ibuf->x + i), color_f);
+				blend_color_mix_float(ibuf->rect_float + 4 * (j * ibuf->x + i),
+				                      ibuf->rect_float + 4 * (j * ibuf->x + i), color_f);
 			}
 		}
 	}
 	else {
 		for (; i < ibuf->x; i++) {
 			for (j = 0; j < ibuf->y; j++) {
-				*(ibuf->rect + j * ibuf->x + i) =  color_b;
+				blend_color_mix_byte((unsigned char *)(ibuf->rect + j * ibuf->x + i),
+				                     (unsigned char *)(ibuf->rect + j * ibuf->x + i), (unsigned char *)&color_b);
 			}
 		}
 	}
@@ -1404,6 +1406,7 @@
 				do_colorband(br->gradient, f, color_f);
 				/* convert to premultiplied */
 				mul_v3_fl(color_f, color_f[3]);
+				color_f[3] *= br->alpha;
 				blend_color_mix_float(ibuf->rect_float + 4 * (j * ibuf->x + i),
 				                      ibuf->rect_float + 4 * (j * ibuf->x + i),
 				                      color_f);
@@ -1431,7 +1434,7 @@
 
 				do_colorband(br->gradient, f, color_f);
 				rgba_float_to_uchar((unsigned char *)&color_b, color_f);
-
+				((unsigned char *)&color_b)[3] *= br->alpha;
 				blend_color_mix_byte((unsigned char *)(ibuf->rect + j * ibuf->x + i),
 				                     (unsigned char *)(ibuf->rect + j * ibuf->x + i),
 				                     (unsigned char *)&color_b);

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-09-23 14:51:35 UTC (rev 60335)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-09-23 15:34:45 UTC (rev 60336)
@@ -4125,7 +4125,7 @@
 							}
 						}
 						do_colorband(brush->gradient, f, color_f);
-						color_f[3] *= ((float)projPixel->mask) * (1.0f / 65535.0f);
+						color_f[3] *= ((float)projPixel->mask) * (1.0f / 65535.0f) * brush->alpha;
 
 						if (is_floatbuf) {
 							/* convert to premultipied */
@@ -4142,7 +4142,7 @@
 					else {
 						if (is_floatbuf) {
 							float newColor_f[4];
-							newColor_f[3] = ((float)projPixel->mask) * (1.0f / 65535.0f);
+							newColor_f[3] = ((float)projPixel->mask) * (1.0f / 65535.0f) * brush->alpha;
 							copy_v3_v3(newColor_f, ps->paint_color_linear);
 
 							blend_color_mix_float(projPixel->pixel.f_pt,  projPixel->origColor.f_pt,
@@ -4150,7 +4150,7 @@
 						}
 						else {
 							float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
-							projPixel->newColor.ch[3] = mask * 255;
+							projPixel->newColor.ch[3] = mask * 255 * brush->alpha;
 
 							rgb_float_to_uchar(projPixel->newColor.ch, ps->paint_color);
 							blend_color_mix_byte(projPixel->pixel.ch_pt,  projPixel->origColor.ch_pt,

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h	2013-09-23 14:51:35 UTC (rev 60335)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h	2013-09-23 15:34:45 UTC (rev 60336)
@@ -159,7 +159,7 @@
 void paint_2d_redraw(const bContext *C, void *ps, bool final);
 void paint_2d_stroke_done(void *ps);
 void paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], int eraser, float pressure, float distance);
-void paint_2d_bucket_fill(const struct bContext *C, float color[3]);
+void paint_2d_bucket_fill(const struct bContext *C, float color[3], float strength);
 void paint_2d_gradient_fill (const struct bContext *C, struct Brush *br, float mouse_init[2], float mouse_final[2], void *ps);
 void *paint_proj_new_stroke(struct bContext *C, struct Object *ob, const float mouse[2], int mode);
 void paint_proj_stroke(const struct bContext *C, void *ps, const float prevmval_i[2], const float mval_i[2], float pressure, float distance);




More information about the Bf-blender-cvs mailing list