[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [48212] branches/soc-2012-bratwurst/source /blender/editors/sculpt_paint: Unification of display functions for sculpt/ image paint.

Antony Riakiotakis kalast at gmail.com
Fri Jun 22 23:47:36 CEST 2012


Revision: 48212
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=48212
Author:   psy-fi
Date:     2012-06-22 21:47:35 +0000 (Fri, 22 Jun 2012)
Log Message:
-----------
Unification of display functions for sculpt/image paint. Still it errors out in a few cases. Investigating

Modified Paths:
--------------
    branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c
    branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c
    branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_intern.h

Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c	2012-06-22 21:10:43 UTC (rev 48211)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_cursor.c	2012-06-22 21:47:35 UTC (rev 48212)
@@ -39,6 +39,7 @@
 #include "DNA_scene_types.h"
 #include "DNA_screen_types.h"
 #include "DNA_userdef_types.h"
+#include "DNA_space_types.h"
 
 #include "BKE_brush.h"
 #include "BKE_context.h"
@@ -496,7 +497,7 @@
 	}
 }
 
-static void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
+void paint_draw_cursor(bContext *C, int x, int y, void *UNUSED(unused))
 {
 	Scene *scene = CTX_data_scene(C);
 	UnifiedPaintSettings *ups = &scene->toolsettings->unified_paint_settings;
@@ -506,7 +507,10 @@
 	float final_radius;
 	float translation[2];
 	float outline_alpha, *outline_col;
-	
+	float location[3];
+	int pixel_radius, hit = 0, is_view3d;
+	ScrArea *sa = CTX_wm_area(C);
+
 	/* set various defaults */
 	translation[0] = x;
 	translation[1] = y;
@@ -518,67 +522,63 @@
 	if (!(paint->flags & PAINT_SHOW_BRUSH))
 		return;
 
+	is_view3d = (sa && sa->spacetype == SPACE_VIEW3D)? TRUE : FALSE;
 	/* can't use stroke vc here because this will be called during
 	 * mouse over too, not just during a stroke */
 	view3d_set_viewcontext(C, &vc);
 
-	/* TODO: as sculpt and other paint modes are unified, this
-	 * special mode of drawing will go away */
-	if (vc.obact->sculpt) {
-		float location[3];
-		int pixel_radius, hit;
 
-		/* this is probably here so that rake takes into
+	/* this is probably here so that rake takes into
 		 * account the brush movements before the stroke
 		 * starts, but this doesn't really belong in draw code
 		 *  TODO) */
-		{
-			const float u = 0.5f;
-			const float v = 1 - u;
-			const float r = RAKE_THRESHHOLD;
+	{
+		const float u = 0.5f;
+		const float v = 1 - u;
+		const float r = RAKE_THRESHHOLD;
 
-			const float dx = ups->last_pos[0] - x;
-			const float dy = ups->last_pos[1] - y;
+		const float dx = ups->last_pos[0] - x;
+		const float dy = ups->last_pos[1] - y;
 
-			if (dx * dx + dy * dy >= r * r) {
-				ups->last_angle = atan2(dx, dy);
+		if (dx * dx + dy * dy >= r * r) {
+			ups->last_angle = atan2(dx, dy);
 
-				ups->last_pos[0] = u * ups->last_pos[0] + v * x;
-				ups->last_pos[1] = u * ups->last_pos[1] + v * y;
-			}
+			ups->last_pos[0] = u * ups->last_pos[0] + v * x;
+			ups->last_pos[1] = u * ups->last_pos[1] + v * y;
 		}
+	}
 
-		/* test if brush is over the mesh */
+	if(is_view3d) {
+		/* test if brush is over the mesh. sculpt only for now */
 		hit = sculpt_get_brush_geometry(C, &vc, x, y, &pixel_radius, location);
+	}
+	/* draw overlay */
+	paint_draw_alpha_overlay(ups, brush, &vc, x, y);
 
-		/* draw overlay */
-		paint_draw_alpha_overlay(ups, brush, &vc, x, y);
+	if (BKE_brush_use_locked_size(scene, brush))
+		BKE_brush_size_set(scene, brush, pixel_radius);
 
-		if (BKE_brush_use_locked_size(scene, brush))
-			BKE_brush_size_set(scene, brush, pixel_radius);
-
-		/* check if brush is subtracting, use different color then */
-		/* TODO: no way currently to know state of pen flip or
+	/* check if brush is subtracting, use different color then */
+	/* TODO: no way currently to know state of pen flip or
 		 * invert key modifier without starting a stroke */
-		 /* TODO no.2 add interface to query the tool if it supports inversion */
-		if ((!(brush->flag & BRUSH_INVERTED) ^
-		     !(brush->flag & BRUSH_DIR_IN)) &&
-		    ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW,
-		          SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
-		          SCULPT_TOOL_PINCH, SCULPT_TOOL_CREASE))
-		{
-			outline_col = brush->sub_col;
-		}
+	/* TODO no.2 add interface to query the tool if it supports inversion */
+	if ((!(brush->flag & BRUSH_INVERTED) ^
+		 !(brush->flag & BRUSH_DIR_IN)) &&
+			ELEM5(brush->sculpt_tool, SCULPT_TOOL_DRAW,
+				  SCULPT_TOOL_INFLATE, SCULPT_TOOL_CLAY,
+				  SCULPT_TOOL_PINCH, SCULPT_TOOL_CREASE))
+	{
+		outline_col = brush->sub_col;
+	}
 
-		/* only do if brush is over the mesh */
-		if (hit)
-			paint_cursor_on_hit(ups, brush, &vc, location);
+	/* only do if brush is over the mesh */
+	if (hit)
+		paint_cursor_on_hit(ups, brush, &vc, location);
 
-		if (ups->draw_anchored) {
-			final_radius = ups->anchored_size;
-			translation[0] = ups->anchored_initial_mouse[0] - vc.ar->winrct.xmin;
-			translation[1] = ups->anchored_initial_mouse[1] - vc.ar->winrct.ymin;
-		}
+	if (ups->draw_anchored) {
+		final_radius = ups->anchored_size;
+		translation[0] = ups->anchored_initial_mouse[0] - vc.ar->winrct.xmin;
+		translation[1] = ups->anchored_initial_mouse[1] - vc.ar->winrct.ymin;
 	}
 
 	/* make lines pretty */

Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c	2012-06-22 21:10:43 UTC (rev 48211)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_image.c	2012-06-22 21:47:35 UTC (rev 48212)
@@ -5300,7 +5300,7 @@
 		settings->imapaint.paintcursor = NULL;
 	}
 	else if (enable)
-		settings->imapaint.paintcursor = WM_paint_cursor_activate(wm, image_paint_poll, brush_drawcursor, NULL);
+		settings->imapaint.paintcursor = WM_paint_cursor_activate(wm, image_paint_poll, paint_draw_cursor, NULL);
 }
 
 /* enable the paint cursor if it isn't already.
@@ -5315,7 +5315,7 @@
 	if (!imapaint->paintcursor) {
 		imapaint->paintcursor =
 		    WM_paint_cursor_activate(wm, image_paint_poll,
-		                             brush_drawcursor, NULL);
+									 paint_draw_cursor, NULL);
 	}
 }
 

Modified: branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_intern.h	2012-06-22 21:10:43 UTC (rev 48211)
+++ branches/soc-2012-bratwurst/source/blender/editors/sculpt_paint/paint_intern.h	2012-06-22 21:47:35 UTC (rev 48212)
@@ -72,6 +72,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_draw_cursor(struct bContext *C, int x, int y, void *UNUSED(unused));
 
 /* paint_vertex.c */
 int weight_paint_poll(struct bContext *C);




More information about the Bf-blender-cvs mailing list