[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [59064] branches/soc-2013-paint: Spacing gradient strokes.

Antony Riakiotakis kalast at gmail.com
Sun Aug 11 12:35:26 CEST 2013


Revision: 59064
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=59064
Author:   psy-fi
Date:     2013-08-11 10:35:26 +0000 (Sun, 11 Aug 2013)
Log Message:
-----------
Spacing gradient strokes. The gradient circles after a certain gradient
spacing which is set in the gradient properties.

Modified Paths:
--------------
    branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py
    branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
    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
    branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2013-paint/source/blender/makesdna/DNA_brush_types.h
    branches/soc-2013-paint/source/blender/makesrna/intern/rna_brush.c

Modified: branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py
===================================================================
--- branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py	2013-08-11 10:35:16 UTC (rev 59063)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_image.py	2013-08-11 10:35:26 UTC (rev 59064)
@@ -714,6 +714,8 @@
                 if brush.use_gradient:
                     if brush.image_tool == 'DRAW':
                         col.prop(brush, "gradient_source")
+                        if brush.gradient_source == 'SPACING':
+                            col.prop(brush, "grad_spacing")
                     col.template_color_ramp(brush, "gradient", expand=True)
                 else:
                     col = layout.column(align=True)            

Modified: branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py
===================================================================
--- branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-08-11 10:35:16 UTC (rev 59063)
+++ branches/soc-2013-paint/release/scripts/startup/bl_ui/space_view3d_toolbar.py	2013-08-11 10:35:26 UTC (rev 59064)
@@ -691,6 +691,8 @@
                 if brush.use_gradient:
                     if brush.image_tool == 'DRAW':
                         col.prop(brush, "gradient_source")
+                        if brush.gradient_source == 'SPACING':
+                            col.prop(brush, "grad_spacing")
                     col.template_color_ramp(brush, "gradient", expand=True)
                 else:
                     col = layout.column(align=True)            

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-11 10:35:16 UTC (rev 59063)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image.c	2013-08-11 10:35:26 UTC (rev 59064)
@@ -676,6 +676,7 @@
 	float mouse[2];
 	float pressure;
 	float size;
+	float distance = paint_stroke_distance_get(stroke);
 	int eraser;
 
 	RNA_float_get_array(itemptr, "mouse", mouse);
@@ -702,10 +703,10 @@
 	}
 
 	if (pop->mode == PAINT_MODE_3D_PROJECT) {
-		paint_proj_stroke(C, pop->custom_paint, pop->prevmouse, mouse, pressure);
+		paint_proj_stroke(C, pop->custom_paint, pop->prevmouse, mouse, pressure, distance);
 	}
 	else {
-		paint_2d_stroke(pop->custom_paint, pop->prevmouse, mouse, eraser, pressure);
+		paint_2d_stroke(pop->custom_paint, pop->prevmouse, mouse, eraser, pressure, distance);
 	}
 
 	pop->prevmouse[0] = mouse[0];

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-08-11 10:35:16 UTC (rev 59063)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_2d.c	2013-08-11 10:35:26 UTC (rev 59064)
@@ -267,7 +267,7 @@
 
 
 /* create imbuf with brush color */
-static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size, float pressure)
+static ImBuf *brush_painter_imbuf_new(BrushPainter *painter, int size, float pressure, float distance)
 {
 	Scene *scene = painter->scene;
 	Brush *brush = painter->brush;
@@ -303,7 +303,11 @@
 						do_colorband(brush->gradient, pressure, brush_rgb);
 						break;
 					case BRUSH_GRADIENT_SPACING:
+					{
+						float coord = fmod(distance / brush->gradient_spacing, 1.0);
+						do_colorband(brush->gradient, coord, brush_rgb);
 						break;
+					}
 				}
 			}
 			else
@@ -592,7 +596,7 @@
 	}
 }
 
-static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *painter, const float pos[2], const float mouse[2], float pressure)
+static void brush_painter_2d_refresh_cache(ImagePaintState *s, BrushPainter *painter, const float pos[2], const float mouse[2], float pressure, float distance)
 {
 	const Scene *scene = painter->scene;
 	UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
@@ -710,7 +714,7 @@
 		}
 		else {
 			/* create brush and mask from scratch */
-			cache->ibuf = brush_painter_imbuf_new(painter, size, pressure);
+			cache->ibuf = brush_painter_imbuf_new(painter, size, pressure, distance);
 		}
 
 		cache->lastsize = diameter;
@@ -1093,7 +1097,7 @@
 		image_undo_remove_masks();
 }
 
-void paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], int eraser, float pressure)
+void paint_2d_stroke(void *ps, const float prev_mval[2], const float mval[2], int eraser, float pressure, float distance)
 {
 	float newuv[2], olduv[2];
 	ImagePaintState *s = ps;
@@ -1138,7 +1142,7 @@
 	 */
 	brush_painter_2d_require_imbuf(painter, (ibuf->rect_float != NULL), !is_data, s->do_masking);
 
-	brush_painter_2d_refresh_cache(s, painter, newuv, mval, pressure);
+	brush_painter_2d_refresh_cache(s, painter, newuv, mval, pressure, distance);
 
 	if (paint_2d_op(s, painter->cache.ibuf, painter->cache.curve_mask, painter->cache.max_mask, olduv, newuv))
 		s->need_redraw = 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-11 10:35:16 UTC (rev 59063)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_image_proj.c	2013-08-11 10:35:26 UTC (rev 59064)
@@ -193,7 +193,6 @@
 	/* the paint color. It can change depending of interted mode or not */
 	float paint_color[3];
 	float paint_color_linear[3];
-	bool invert_color;
 
 	Brush *brush;
 	short tool, blend, mode;
@@ -4309,7 +4308,7 @@
 }
 
 
-void paint_proj_stroke(bContext *C, void *pps, const float prev_pos[2], const float pos[2], float pressure)
+void paint_proj_stroke(bContext *C, void *pps, const float prev_pos[2], const float pos[2], float pressure, float distance)
 {
 	ProjPaintState *ps = pps;
 	Brush *brush = ps->brush;
@@ -4333,7 +4332,7 @@
 	}
 
 	if (brush->imagepaint_tool == PAINT_TOOL_DRAW) {
-		if (ps->invert_color)
+		if (ps->mode == BRUSH_STROKE_INVERT)
 			copy_v3_v3(ps->paint_color, brush->secondary_rgb);
 		else {
 			if (brush->flag & BRUSH_USE_GRADIENT) {
@@ -4342,7 +4341,11 @@
 						do_colorband(brush->gradient, pressure, ps->paint_color);
 						break;
 					case BRUSH_GRADIENT_SPACING:
+					{
+						float coord = fmod(distance / brush->gradient_spacing, 1.0);
+						do_colorband(brush->gradient, coord, ps->paint_color);
 						break;
+					}
 				}
 			}
 			else
@@ -4433,11 +4436,6 @@
 	if (ps->normal_angle_range <= 0.0f)
 		ps->do_mask_normal = FALSE;  /* no need to do blending */
 
-	if (ps->tool == PAINT_TOOL_DRAW) {
-		if (mode == BRUSH_STROKE_INVERT) {
-			ps->invert_color = true;
-		}
-	}
 	return;
 }
 

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-11 10:35:16 UTC (rev 59063)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_intern.h	2013-08-11 10:35:26 UTC (rev 59064)
@@ -82,6 +82,7 @@
 int paint_stroke_cancel(struct bContext *C, struct wmOperator *op);
 struct ViewContext *paint_stroke_view_context(struct PaintStroke *stroke);
 void *paint_stroke_mode_data(struct PaintStroke *stroke);
+float paint_stroke_distance_get(struct PaintStroke *stroke);
 void paint_stroke_set_mode_data(struct PaintStroke *stroke, void *mode_data);
 int paint_poll(struct bContext *C);
 void paint_cursor_start(struct bContext *C, int (*poll)(struct bContext *C));
@@ -157,11 +158,11 @@
 void *paint_2d_new_stroke(struct bContext *, struct wmOperator *, int mode);
 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);
+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_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);
+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_redraw(const bContext *C, void *pps, bool final);
 void paint_proj_stroke_done(void *ps);
 

Modified: branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_stroke.c	2013-08-11 10:35:16 UTC (rev 59063)
+++ branches/soc-2013-paint/source/blender/editors/sculpt_paint/paint_stroke.c	2013-08-11 10:35:26 UTC (rev 59064)
@@ -91,6 +91,8 @@
 	int cur_sample;
 
 	float last_mouse_position[2];
+	/* space distance covered so far */
+	float stroke_distance;
 
 	/* Set whether any stroke step has yet occurred
 	 * e.g. in sculpt mode, stroke doesn't start until cursor
@@ -305,10 +307,12 @@
 			copy_v2_v2(mouse, halfway);
 			ups->anchored_size /= 2.0f;
 			ups->pixel_radius  /= 2.0f;
+			stroke->stroke_distance = ups->pixel_radius;
 		}
 		else {
 			copy_v2_v2(ups->anchored_initial_mouse, stroke->initial_mouse);
 			copy_v2_v2(mouse, stroke->initial_mouse);
+			stroke->stroke_distance = ups->pixel_radius;
 		}
 		ups->pixel_radius /= stroke->zoom_2d;
 		ups->draw_anchored = 1;
@@ -551,6 +555,7 @@
 
 			ups->overlap_factor = paint_stroke_integrate_overlap(stroke->brush, spacing/stroke->zoom_2d);
 
+			stroke->stroke_distance += spacing / stroke->zoom_2d;
 			paint_brush_stroke_add_step(C, op, mouse, pressure);
 
 			length -= spacing;
@@ -931,6 +936,9 @@
 						redraw = true;
 				}
 				else {
+					float dmouse[2];
+					sub_v2_v2v2(dmouse, mouse, stroke->last_mouse_position);
+					stroke->stroke_distance += len_v2(dmouse);

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list