[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59244] branches/soc-2013-paint/source/ blender/editors/sculpt_paint: Fill tool for projection painting.

Antony Riakiotakis kalast at gmail.com
Sun Aug 18 20:02:12 CEST 2013


Revision: 59244
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59244
Author:   psy-fi
Date:     2013-08-18 18:02:12 +0000 (Sun, 18 Aug 2013)
Log Message:
-----------
Fill tool for projection painting. This will only fill the part of the
model visible on the screen with the brush color

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_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-08-18 16:15:30 UTC (rev 59243)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c	2013-08-18 18:02:12 UTC (rev 59244)
@@ -745,12 +745,16 @@
 			}
 		}
 		else {
-			float color[3];
+			if (pop->mode == PAINT_MODE_2D) {
+				float color[3];
 
-			srgb_to_linearrgb_v3_v3(color, brush->rgb);
-
-			if (pop->mode == PAINT_MODE_2D) {
+				srgb_to_linearrgb_v3_v3(color, brush->rgb);
 				paint_2d_bucket_fill(C, color);
+			} else {
+				paint_proj_stroke(C, pop->custom_paint, pop->startmouse, pop->prevmouse, 1.0, 0.0);
+				/* two redraws, one for GPU update, one for notification */
+				paint_proj_redraw(C, pop->custom_paint, false);
+				paint_proj_redraw(C, pop->custom_paint, true);
 			}
 		}
 	}

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-08-18 16:15:30 UTC (rev 59243)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-08-18 18:02:12 UTC (rev 59244)
@@ -149,6 +149,7 @@
 #define PROJ_SRC_VIEW       1
 #define PROJ_SRC_IMAGE_CAM  2
 #define PROJ_SRC_IMAGE_VIEW 3
+#define PROJ_SRC_VIEW_FILL  4
 
 #define PROJ_VIEW_DATA_ID "view_data"
 #define PROJ_VIEW_DATA_SIZE (4 * 4 + 4 * 4 + 3) /* viewmat + winmat + clipsta + clipend + is_ortho */
@@ -4036,34 +4037,62 @@
 				}
 				/* end copy */
 
-				if (is_floatbuf) {
-					/* re-project buffer is assumed byte - TODO, allow float */
-					bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL,
-					                            projPixel->projCoSS[0], projPixel->projCoSS[1]);
-					if (projPixel->newColor.ch[3]) {
+				/* fill tools */
+				if (ps->source == PROJ_SRC_VIEW_FILL) {
+					if (is_floatbuf) {
 						float newColor_f[4];
-						float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
+						newColor_f[3] = ((float)projPixel->mask) * (1.0f / 65535.0f);
+						copy_v3_v3(newColor_f, ps->paint_color_linear);
 
-						straight_uchar_to_premul_float(newColor_f, projPixel->newColor.ch);
-						IMB_colormanagement_colorspace_to_scene_linear_v4(newColor_f, TRUE, ps->reproject_ibuf->rect_colorspace);
-						mul_v4_v4fl(newColor_f, newColor_f, mask);
-
 						blend_color_mix_float(projPixel->pixel.f_pt,  projPixel->origColor.f_pt,
 						                      newColor_f);
 					}
-				}
-				else {
-					/* re-project buffer is assumed byte - TODO, allow float */
-					bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL,
-					                            projPixel->projCoSS[0], projPixel->projCoSS[1]);
-					if (projPixel->newColor.ch[3]) {
+					else {
 						float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
-						projPixel->newColor.ch[3] *= mask;
+						projPixel->newColor.ch[3] = mask * 255;
 
+						rgb_float_to_uchar(projPixel->newColor.ch, ps->paint_color);
 						blend_color_mix_byte(projPixel->pixel.ch_pt,  projPixel->origColor.ch_pt,
 						                     projPixel->newColor.ch);
 					}
+
+					last_partial_redraw_cell = last_projIma->partRedrawRect + projPixel->bb_cell_index;
+					last_partial_redraw_cell->x1 = min_ii(last_partial_redraw_cell->x1, (int)projPixel->x_px);
+					last_partial_redraw_cell->y1 = min_ii(last_partial_redraw_cell->y1, (int)projPixel->y_px);
+
+					last_partial_redraw_cell->x2 = max_ii(last_partial_redraw_cell->x2, (int)projPixel->x_px + 1);
+					last_partial_redraw_cell->y2 = max_ii(last_partial_redraw_cell->y2, (int)projPixel->y_px + 1);
 				}
+				else {
+					if (is_floatbuf) {
+						/* re-project buffer is assumed byte - TODO, allow float */
+						bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL,
+						                            projPixel->projCoSS[0], projPixel->projCoSS[1]);
+						if (projPixel->newColor.ch[3]) {
+							float newColor_f[4];
+							float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
+
+							straight_uchar_to_premul_float(newColor_f, projPixel->newColor.ch);
+							IMB_colormanagement_colorspace_to_scene_linear_v4(newColor_f, TRUE, ps->reproject_ibuf->rect_colorspace);
+							mul_v4_v4fl(newColor_f, newColor_f, mask);
+
+							blend_color_mix_float(projPixel->pixel.f_pt,  projPixel->origColor.f_pt,
+							                      newColor_f);
+						}
+					}
+					else {
+						/* re-project buffer is assumed byte - TODO, allow float */
+						bicubic_interpolation_color(ps->reproject_ibuf, projPixel->newColor.ch, NULL,
+						                            projPixel->projCoSS[0], projPixel->projCoSS[1]);
+						if (projPixel->newColor.ch[3]) {
+							float mask = ((float)projPixel->mask) * (1.0f / 65535.0f);
+							projPixel->newColor.ch[3] *= mask;
+
+							blend_color_mix_byte(projPixel->pixel.ch_pt,  projPixel->origColor.ch_pt,
+							                     projPixel->newColor.ch);
+						}
+					}
+				}
 			}
 		}
 		else {
@@ -4308,7 +4337,7 @@
 }
 
 
-void paint_proj_stroke(bContext *C, void *pps, const float prev_pos[2], const float pos[2], float pressure, float distance)
+void paint_proj_stroke(const bContext *C, void *pps, const float prev_pos[2], const float pos[2], float pressure, float distance)
 {
 	ProjPaintState *ps = pps;
 	Brush *brush = ps->brush;
@@ -4331,7 +4360,8 @@
 		return;
 	}
 
-	if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
+	/* handle gradient and inverted stroke color here */
+	if (ELEM(ps->tool, PAINT_TOOL_DRAW, PAINT_TOOL_FILL)) {
 		if (ps->mode == BRUSH_STROKE_INVERT)
 			copy_v3_v3(ps->paint_color, brush->secondary_rgb);
 		else {
@@ -4482,6 +4512,10 @@
 
 	paint_proj_begin_clone(ps, mouse);
 
+	/* special full screen draw mode for fill tool */
+	if (ps->tool == PAINT_TOOL_FILL)
+		ps->source = PROJ_SRC_VIEW_FILL;
+
 	return ps;
 }
 

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-08-18 16:15:30 UTC (rev 59243)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h	2013-08-18 18:02:12 UTC (rev 59244)
@@ -162,7 +162,7 @@
 void paint_2d_bucket_fill(const struct bContext *C, float color[3]);
 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(struct bContext *C, void *ps, const float prevmval_i[2], const float mval_i[2], float pressure, float distance);
+void paint_proj_stroke(const struct bContext *C, void *ps, const float prevmval_i[2], const float mval_i[2], float pressure, float distance);
 void paint_proj_redraw(const bContext *C, void *pps, bool final);
 void paint_proj_stroke_done(void *ps);
 




More information about the Bf-blender-cvs mailing list