[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39154] branches/soc-2011-onion/source/ blender/editors/sculpt_paint: Revision: 30857

Jason Wilkins Jason.A.Wilkins at gmail.com
Sun Aug 7 18:52:34 CEST 2011


Revision: 39154
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39154
Author:   jwilkins
Date:     2011-08-07 16:52:32 +0000 (Sun, 07 Aug 2011)
Log Message:
-----------
Revision: 30857
Author: nicholasbishop
Date: 8:16:40 PM, Wednesday, July 28, 2010
Message:
== VPaint ==

* Bugfix: don't start until mouse goes over the mesh

----
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_intern.h
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_stroke.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/paint_vertex.c
Modified : /branches/soc-2010-nicolasbishop/source/blender/editors/sculpt_paint/sculpt.c

--
jwilkins:
I had already fixed this, however I had done it in a copy/paste way.  Again, this is a change more inspired by the original patch than applied directly.  One thing to make note of is that 'paint_get_location' is not considered to be a part of paint_stroke, so the thin wrapper function paint_mesh_over is not a part of paint_stroke either, but it is a compatible callback that can be reused between modes.

Modified Paths:
--------------
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.h
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
    branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h	2011-08-07 16:44:10 UTC (rev 39153)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_intern.h	2011-08-07 16:52:32 UTC (rev 39154)
@@ -473,4 +473,10 @@
 
 int paint_stroke_smooth_enabled(const struct PaintStrokeParams *params);
 
+int paint_over_mesh(
+	const struct bContext *C,
+	const struct PaintStroke *stroke,
+	int x,
+	int y);
+
 #endif /* ED_PAINT_INTERN_H */

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c	2011-08-07 16:44:10 UTC (rev 39153)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.c	2011-08-07 16:52:32 UTC (rev 39154)
@@ -150,9 +150,8 @@
 	/* stroke callbacks */
 	StrokeTempSwitch     temp_switch;
 	StrokeTempUnswitch   temp_unswitch;
-	StrokeIsBackground   is_background;
+	StrokeOverMesh       over_mesh;
 	StrokeSurfaceNew     surface_new;
-	StrokeTestStart      test_start;
 	StrokeStart          start;
 	StrokeCursor         cursor;
 	StrokeUpdateStep     update_step;
@@ -447,9 +446,8 @@
 	struct wmOperator   *op,
 	StrokeTempSwitch     temp_switch,
 	StrokeTempUnswitch   temp_unswitch,
-	StrokeIsBackground   is_background,
+	StrokeOverMesh       over_mesh,
 	StrokeSurfaceNew     surface_new,
-	StrokeTestStart      test_start,
 	StrokeStart          start,
 	StrokeCursor         cursor,
 	StrokeUpdateStep     update_step,
@@ -468,8 +466,7 @@
 
 	stroke->temp_switch=     temp_switch;
 	stroke->temp_unswitch=   temp_unswitch;
-	stroke->is_background=   is_background;
-	stroke->test_start=      test_start;
+	stroke->over_mesh=       over_mesh;
 	stroke->surface_new=     surface_new;
 	stroke->start=           start;
 	stroke->cursor=          cursor;
@@ -576,9 +573,12 @@
 	const struct bContext *C,
 	struct PaintStroke *stroke)
 {
+	int x= stroke->current.mouse[0];
+	int y= stroke->current.mouse[1];
+
 	return
 		!(stroke->started) &&
-		((!stroke->test_start) || stroke->test_start(C, stroke));
+		((!stroke->over_mesh) || stroke->over_mesh(C, stroke, x, y));
 }
 
 static void stroke_done(
@@ -1424,8 +1424,8 @@
 		}
 
 		if (!ignore_background_click ||
-			!(stroke->is_background) ||
-			stroke->is_background(C, stroke, evt))
+			!(stroke->over_mesh) ||
+			stroke->over_mesh(C, stroke, evt->x, evt->y))
 		{
 			/* call modal callback to handle first event of stroke */
 			int op_ret= op->type->modal(C, op, evt);

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.h
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.h	2011-08-07 16:44:10 UTC (rev 39153)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_stroke.h	2011-08-07 16:52:32 UTC (rev 39154)
@@ -126,15 +126,12 @@
 	const struct bContext *C,
 	struct PaintStroke *stroke);
 
-typedef int (*StrokeIsBackground)(
+typedef int (*StrokeOverMesh)(
 	const struct bContext *C,
 	const struct PaintStroke *stroke,
-	const struct wmEvent *evt);
+	int x,
+	int y);
 
-typedef int (*StrokeTestStart)(
-	const struct bContext *C,
-	struct PaintStroke *stroke);
-
 typedef struct BrushLibSurface *(*StrokeSurfaceNew)(void);
 
 typedef void (*StrokeStart)(
@@ -185,9 +182,8 @@
 	struct wmOperator   *op,
 	StrokeTempSwitch     temp_switch,
 	StrokeTempUnswitch   temp_unswitch,
-	StrokeIsBackground   is_background,
+	StrokeOverMesh       over_mesh,
 	StrokeSurfaceNew     surface_new,
-	StrokeTestStart      test_start,
 	StrokeStart          start,
 	StrokeCursor         cursor,
 	StrokeUpdateStep     update_step,

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c	2011-08-07 16:44:10 UTC (rev 39153)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_utils.c	2011-08-07 16:52:32 UTC (rev 39154)
@@ -639,7 +639,33 @@
 	return prd.hit;
 }
 
+int paint_over_mesh(
+	const struct bContext *C,
+	const struct PaintStroke *stroke,
+	int x,
+	int y)
+{
+	struct Paint *paint= paint_get_active(CTX_data_scene(C));
 
+	if (paint && paint->cache && paint->cache->get_location) {
+		float location[3]; /* ignored */
+		float mouse[2];
+
+		mouse[0]= x;
+		mouse[1]= y;
+
+		return
+			paint->cache->get_location(
+				C,
+				location,
+				stroke,
+				mouse);
+	}
+	else {
+		return 0;
+	}
+}
+
 void paint_set_last_stroke(struct Object *ob, float location[3])
 {
 	/* update last stroke position */

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c	2011-08-07 16:44:10 UTC (rev 39153)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/paint_vertex.c	2011-08-07 16:52:32 UTC (rev 39154)
@@ -2417,37 +2417,6 @@
 	}
 }
 
-static int vpaint_stroke_is_background(
-	const struct bContext *C,
-	const struct PaintStroke *stroke,
-	const struct wmEvent *evt)
-{
-	float location[3]; /* ignored */
-	float mouse[2];
-
-	mouse[0]= evt->x;
-	mouse[1]= evt->y;
-
-	return
-		vpaint_stroke_get_location(
-			C,
-			location,
-			stroke,
-			mouse);
-}
-
-static int vpaint_stroke_test_start(const bContext *C, struct PaintStroke *stroke)
-{
-	float location[3]; /* ignored */
-
-	return
-		vpaint_stroke_get_location(
-			C,
-			location,
-			stroke,
-			paint_stroke_mouse(stroke));
-}
-
 static int vpaint_poll(const struct bContext *C);
 
 static void vpaint_stroke_start(
@@ -2607,9 +2576,8 @@
 		op,
 		paint_brush_temp_switch,
 		paint_brush_temp_unswitch,
-		vpaint_stroke_is_background,
+		paint_over_mesh,
 		vpaint_brushlib_surface_new,
-		vpaint_stroke_test_start,
 		vpaint_stroke_start,
 		paint_cursor,
 		vpaint_stroke_update_step,

Modified: branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c	2011-08-07 16:44:10 UTC (rev 39153)
+++ branches/soc-2011-onion/source/blender/editors/sculpt_paint/sculpt.c	2011-08-07 16:52:32 UTC (rev 39154)
@@ -219,43 +219,6 @@
 			use_orig_bb);
 }
 
-/* uses true mouse location to determine if ray hits object
-   this is used by the ignore_background_click property */
-static int sculpt_stroke_is_background(
-	const struct bContext *C,
-	const struct PaintStroke *stroke,
-	const struct wmEvent *evt)
-{
-	float location[3]; /* ignored */
-	float mouse[2];
-
-	mouse[0]= evt->x;
-	mouse[1]= evt->y;
-
-	return
-		sculpt_stroke_get_location(
-			C,
-			location,
-			stroke,
-			mouse);
-}
-
-/* sculpt stroke does not start until the modified mouse coordinate
-   derived from paint_stroke operator is over the active object */
-static int sculpt_stroke_test_start(
-	const struct bContext *C,
-	struct PaintStroke *stroke)
-{
-	float location[3]; /* ignored */
-
-	return
-		sculpt_stroke_get_location(
-			C,
-			location,
-			stroke,
-			paint_stroke_mouse(stroke));
-}
-
 static void sculpt_stroke_start(
 	const struct bContext *C,
 	struct PaintStroke *stroke)
@@ -350,9 +313,8 @@
 		op,
 		paint_brush_temp_switch,
 		paint_brush_temp_unswitch,
-		sculpt_stroke_is_background,
+		paint_over_mesh,
 		NULL,
-		sculpt_stroke_test_start,
 		sculpt_stroke_start,
 		paint_cursor,
 		sculpt_stroke_update_step, /* defined in sculpt_tools.c */




More information about the Bf-blender-cvs mailing list