[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55668] trunk/blender/source/blender/ editors/sculpt_paint: Support for brush overlay in texture paint mode.

Antony Riakiotakis kalast at gmail.com
Fri Mar 29 15:02:28 CET 2013


Revision: 55668
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55668
Author:   psy-fi
Date:     2013-03-29 14:02:28 +0000 (Fri, 29 Mar 2013)
Log Message:
-----------
Support for brush overlay in texture paint mode. For the image editor,
the tiled overlay is still a bit off, investigating on how to better
correct this, though it may well be non trivial.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
    trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c	2013-03-29 13:33:15 UTC (rev 55667)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c	2013-03-29 14:02:28 UTC (rev 55668)
@@ -117,7 +117,7 @@
 	snap->winy = vc->ar->winy;
 }
 
-static int load_tex(Brush *br, ViewContext *vc)
+static int load_tex(Brush *br, ViewContext *vc, float zoom)
 {
 	static GLuint overlay_texture = 0;
 	static int init = 0;
@@ -125,6 +125,7 @@
 	static int curve_changed_timestamp = -1;
 	static Snapshot snap;
 	static int old_size = -1;
+	static int old_zoom = -1;
 
 	GLubyte *buffer = NULL;
 
@@ -141,10 +142,13 @@
 	      br->mtex.tex->preview->changed_timestamp[0] != tex_changed_timestamp)) ||
 	    !br->curve ||
 	    br->curve->changed_timestamp != curve_changed_timestamp ||
+	    old_zoom != zoom ||
 	    !same_snap(&snap, br, vc);
 
 	if (refresh) {
 		struct ImagePool *pool = NULL;
+		const float rotation = -br->mtex.rot;
+		float radius = BKE_brush_size_get(vc->scene, br) * zoom;
 
 		if (br->mtex.tex && br->mtex.tex->preview)
 			tex_changed_timestamp = br->mtex.tex->preview->changed_timestamp[0];
@@ -152,6 +156,7 @@
 		if (br->curve)
 			curve_changed_timestamp = br->curve->changed_timestamp;
 
+		old_zoom = zoom;
 		make_snap(&snap, br, vc);
 
 		if (br->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) {
@@ -198,8 +203,6 @@
 
 				// largely duplicated from tex_strength
 
-				const float rotation = -br->mtex.rot;
-				float radius = BKE_brush_size_get(vc->scene, br);
 				int index = j * size + i;
 				float x;
 				float avg;
@@ -382,7 +385,7 @@
  * have on brush strength */
 /* TODO: sculpt only for now */
 static void paint_draw_alpha_overlay(UnifiedPaintSettings *ups, Brush *brush,
-                                     ViewContext *vc, int x, int y)
+                                     ViewContext *vc, int x, int y, float zoom)
 {
 	rctf quad;
 
@@ -406,7 +409,7 @@
 	             GL_VIEWPORT_BIT |
 	             GL_TEXTURE_BIT);
 
-	if (load_tex(brush, vc)) {
+	if (load_tex(brush, vc, zoom)) {
 		glEnable(GL_BLEND);
 
 		glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
@@ -439,7 +442,7 @@
 				quad.ymax = aim[1] + ups->anchored_size;
 			}
 			else {
-				const int radius = BKE_brush_size_get(vc->scene, brush);
+				const int radius = BKE_brush_size_get(vc->scene, brush)*zoom;
 				quad.xmin = x - radius;
 				quad.ymin = y - radius;
 				quad.xmax = x + radius;
@@ -519,14 +522,8 @@
 	float final_radius;
 	float translation[2];
 	float outline_alpha, *outline_col;
+	float zoomx, zoomy;
 	
-	/* set various defaults */
-	translation[0] = x;
-	translation[1] = y;
-	outline_alpha = 0.5;
-	outline_col = brush->add_col;
-	final_radius = BKE_brush_size_get(scene, brush);
-
 	/* check that brush drawing is enabled */
 	if (!(paint->flags & PAINT_SHOW_BRUSH))
 		return;
@@ -535,12 +532,24 @@
 	 * mouse over too, not just during a stroke */
 	view3d_set_viewcontext(C, &vc);
 
+	get_imapaint_zoom(C, &zoomx, &zoomy);
+	zoomx = max_ff(zoomx, zoomy);
+
+	/* set various defaults */
+	translation[0] = x;
+	translation[1] = y;
+	outline_alpha = 0.5;
+	outline_col = brush->add_col;
+	final_radius = BKE_brush_size_get(scene, brush)*zoomx;
+
 	if (brush->flag & BRUSH_RAKE)
 		/* here, translation contains the mouse coordinates. */
 		paint_calculate_rake_rotation(ups, translation);
+	else if (!(brush->flag & BRUSH_ANCHORED))
+		ups->brush_rotation = 0.0;
 
 	/* draw overlay */
-	paint_draw_alpha_overlay(ups, brush, &vc, x, y);
+	paint_draw_alpha_overlay(ups, brush, &vc, x, y, zoomx);
 
 	/* TODO: as sculpt and other paint modes are unified, this
 	 * special mode of drawing will go away */
@@ -611,3 +620,9 @@
 	if (p && !p->paint_cursor)
 		p->paint_cursor = WM_paint_cursor_activate(CTX_wm_manager(C), poll, paint_draw_cursor, NULL);
 }
+
+void paint_cursor_start_explicit(Paint *p, wmWindowManager *wm, int (*poll)(bContext *C))
+{
+	if (p && !p->paint_cursor)
+		p->paint_cursor = WM_paint_cursor_activate(wm, poll, paint_draw_cursor, NULL);
+}

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-03-29 13:33:15 UTC (rev 55667)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_image.c	2013-03-29 14:02:28 UTC (rev 55668)
@@ -721,8 +721,7 @@
 		settings->imapaint.paintcursor = NULL;
 	}
 	else if (enable)
-		settings->imapaint.paintcursor =
-			WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor_texpaint_uvsculpt, NULL);
+		paint_cursor_start(C, image_paint_poll);
 }
 
 /* enable the paint cursor if it isn't already.
@@ -746,11 +745,7 @@
 	if (enabled) {
 		BKE_paint_init(&imapaint->paint, PAINT_CURSOR_TEXTURE_PAINT);
 
-		if (!imapaint->paintcursor) {
-			imapaint->paintcursor =
-			        WM_paint_cursor_activate(wm, image_paint_poll,
-			                                 brush_drawcursor_texpaint_uvsculpt, NULL);
-		}
+		paint_cursor_start_explicit(&imapaint->paint, wm, image_paint_poll);
 	}
 }
 

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h	2013-03-29 13:33:15 UTC (rev 55667)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_intern.h	2013-03-29 14:02:28 UTC (rev 55668)
@@ -41,6 +41,7 @@
 struct Mesh;
 struct Object;
 struct PaintStroke;
+struct Paint;
 struct PointerRNA;
 struct rcti;
 struct Scene;
@@ -51,6 +52,7 @@
 struct wmOperator;
 struct wmOperatorType;
 struct ImagePaintState;
+struct wmWindowManager;
 enum PaintMode;
 
 /* paint_stroke.c */
@@ -79,6 +81,7 @@
 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));
+void paint_cursor_start_explicit(struct Paint *p, struct wmWindowManager *wm, int (*poll)(struct bContext *C));
 
 /* paint_vertex.c */
 int weight_paint_poll(struct bContext *C);

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2013-03-29 13:33:15 UTC (rev 55667)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2013-03-29 14:02:28 UTC (rev 55668)
@@ -174,9 +174,7 @@
 		ups->pixel_radius *= stroke->cached_pressure;
 	}
 
-	if (!(brush->flag & BRUSH_ANCHORED ||
-	      ELEM4(brush->sculpt_tool, SCULPT_TOOL_GRAB, SCULPT_TOOL_SNAKE_HOOK,
-	            SCULPT_TOOL_THUMB, SCULPT_TOOL_ROTATE)))
+	if (paint_supports_dynamic_tex_coords(brush, mode))
 	{
 		if (((brush->mtex.brush_map_mode == MTEX_MAP_MODE_VIEW) ||
 		    (brush->mtex.brush_map_mode == MTEX_MAP_MODE_RANDOM)) &&




More information about the Bf-blender-cvs mailing list