[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55032] trunk/blender/source/blender/ editors/sculpt_paint: Convert paint stroke code to write region instead of screen coordinates

Antony Riakiotakis kalast at gmail.com
Mon Mar 4 23:55:54 CET 2013


Revision: 55032
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55032
Author:   psy-fi
Date:     2013-03-04 22:55:53 +0000 (Mon, 04 Mar 2013)
Log Message:
-----------
Convert paint stroke code to write region instead of screen coordinates
on mouse event coordinates. Every paint mode operated on and converted
back to region coordinates, texture paint does so too so this will help
in unifying the systems.

ALERT! POSSIBLE BREAKING COMMIT:

I have tested all paint systems that use the stroke code and they look
like they work well but I would appreciate it if more eyes could test
this.

Modified Paths:
--------------
    trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
    trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
    trunk/blender/source/blender/editors/sculpt_paint/sculpt.c

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c	2013-03-04 22:30:05 UTC (rev 55031)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_cursor.c	2013-03-04 22:55:53 UTC (rev 55032)
@@ -345,14 +345,14 @@
 {
 	Scene *scene = CTX_data_scene(C);
 	Paint *paint = paint_get_active_from_context(C);
-	float window[2];
+	float mouse[2];
 	int hit;
 
-	window[0] = x + vc->ar->winrct.xmin;
-	window[1] = y + vc->ar->winrct.ymin;
+	mouse[0] = x;
+	mouse[1] = y;
 
 	if (vc->obact->sculpt && vc->obact->sculpt->pbvh &&
-	    sculpt_stroke_get_location(C, location, window))
+	    sculpt_stroke_get_location(C, location, mouse))
 	{
 		Brush *brush = paint_brush(paint);
 		*pixel_radius =

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2013-03-04 22:30:05 UTC (rev 55031)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_stroke.c	2013-03-04 22:55:53 UTC (rev 55032)
@@ -408,7 +408,7 @@
 	float mouse[2];
 	int first = 0;
 
-	paint_stroke_add_sample(p, stroke, event->x, event->y);
+	paint_stroke_add_sample(p, stroke, event->mval[0], event->mval[1]);
 	paint_stroke_sample_average(stroke, &sample_average);
 
 	/* let NDOF motion pass through to the 3D view so we can paint and rotate simultaneously!

Modified: trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2013-03-04 22:30:05 UTC (rev 55031)
+++ trunk/blender/source/blender/editors/sculpt_paint/paint_vertex.c	2013-03-04 22:55:53 UTC (rev 55032)
@@ -2239,12 +2239,7 @@
 	mult_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat);
 
 	RNA_float_get_array(itemptr, "mouse", mval);
-	mval[0] -= vc->ar->winrct.xmin;
-	mval[1] -= vc->ar->winrct.ymin;
 
-
-
-
 	/* *** setup WeightPaintInfo - pass onto do_weight_paint_vertex *** */
 	wpi.defbase_tot =        wpd->defbase_tot;
 	wpi.defbase_sel = BKE_objdef_selected_get(ob, wpi.defbase_tot, &wpi.defbase_tot_sel);
@@ -2872,10 +2867,6 @@
 	/* load projection matrix */
 	mult_m4_m4m4(mat, vc->rv3d->persmat, ob->obmat);
 
-	mval[0] -= vc->ar->winrct.xmin;
-	mval[1] -= vc->ar->winrct.ymin;
-
-
 	/* which faces are involved */
 	if (vp->flag & VP_AREA) {
 		totindex = sample_backbuf_area(vc, indexar, me->totpoly, mval[0], mval[1], brush_size_pressure);

Modified: trunk/blender/source/blender/editors/sculpt_paint/sculpt.c
===================================================================
--- trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2013-03-04 22:30:05 UTC (rev 55031)
+++ trunk/blender/source/blender/editors/sculpt_paint/sculpt.c	2013-03-04 22:55:53 UTC (rev 55032)
@@ -965,8 +965,8 @@
 			/* use pressure adjusted size for fixed mode */
 			radius = ss->cache->pixel_radius;
 
-			x = point_2d[0] + ss->cache->vc->ar->winrct.xmin;
-			y = point_2d[1] + ss->cache->vc->ar->winrct.ymin;
+			x = point_2d[0];
+			y = point_2d[1];
 		}
 		else if (mtex->brush_map_mode == MTEX_MAP_MODE_TILED) {
 			/* leave the coordinates relative to the screen */
@@ -3825,8 +3825,8 @@
 	SculptSession *ss = ob->sculpt;
 	StrokeCache *cache = ss->cache;
 	float mouse[2] = {
-		cache->mouse[0] - cache->vc->ar->winrct.xmin,
-		cache->mouse[1] - cache->vc->ar->winrct.ymin
+		cache->mouse[0],
+		cache->mouse[1]
 	};
 	int tool = brush->sculpt_tool;
 
@@ -4130,7 +4130,6 @@
 	StrokeCache *cache;
 	float ray_start[3], ray_end[3], ray_normal[3], dist;
 	float obimat[4][4];
-	float mval[2];
 	SculptRaycastData srd;
 
 	view3d_set_viewcontext(C, &vc);
@@ -4141,11 +4140,8 @@
 
 	sculpt_stroke_modifiers_check(C, ob);
 
-	mval[0] = mouse[0] - vc.ar->winrct.xmin;
-	mval[1] = mouse[1] - vc.ar->winrct.ymin;
-
 	/* TODO: what if the segment is totally clipped? (return == 0) */
-	ED_view3d_win_to_segment_clip(vc.ar, vc.v3d, mval, ray_start, ray_end);
+	ED_view3d_win_to_segment_clip(vc.ar, vc.v3d, mouse, ray_start, ray_end);
 
 	invert_m4_m4(obimat, ob->obmat);
 	mul_m4_v3(obimat, ray_start);




More information about the Bf-blender-cvs mailing list