[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17033] trunk/blender/source/blender/src: Grease Pencil Bugfixs:

Joshua Leung aligorith at gmail.com
Sun Oct 12 02:13:25 CEST 2008


Revision: 17033
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17033
Author:   aligorith
Date:     2008-10-12 02:13:25 +0200 (Sun, 12 Oct 2008)

Log Message:
-----------
Grease Pencil Bugfixs:

- Eraser now works in Sequence Editor. Cleaned up the code that handles Sequencer coordinate-conversions so that it should be a bit faster (doesn't need to recalculate offsets+scaling for every point that is made).

- Fixed mistake made in previous commit that made the pressure value (for tablets) an integer instead or a float. This should solve some of the reports of bits of strokes being missed on tablets.

Modified Paths:
--------------
    trunk/blender/source/blender/src/drawgpencil.c
    trunk/blender/source/blender/src/gpencil.c

Modified: trunk/blender/source/blender/src/drawgpencil.c
===================================================================
--- trunk/blender/source/blender/src/drawgpencil.c	2008-10-11 23:48:37 UTC (rev 17032)
+++ trunk/blender/source/blender/src/drawgpencil.c	2008-10-12 00:13:25 UTC (rev 17033)
@@ -958,6 +958,7 @@
 			else
 				zoomx = zoomy = zoom;
 			
+			/* calculate transforms (Note: we use ibuf here, as we have it) */
 			sizex= zoomx * ibuf->x;
 			sizey= zoomy * ibuf->y;
 			offsx= (sa->winx-sizex)/2 + sseq->xof;

Modified: trunk/blender/source/blender/src/gpencil.c
===================================================================
--- trunk/blender/source/blender/src/gpencil.c	2008-10-11 23:48:37 UTC (rev 17032)
+++ trunk/blender/source/blender/src/gpencil.c	2008-10-12 00:13:25 UTC (rev 17033)
@@ -1096,7 +1096,12 @@
 typedef struct tGPsdata {
 	ScrArea *sa;		/* area where painting originated */
 	View2D *v2d;		/* needed for GP_STROKE_2DSPACE */
+	
 	ImBuf *ibuf;		/* needed for GP_STROKE_2DIMAGE */
+	struct IBufViewSettings {
+		int offsx, offsy;			/* offsets */
+		int sizex, sizey;			/* dimensions to use as scale-factor */
+	} im2d_settings;	/* needed for GP_STROKE_2DIMAGE */
 	
 	bGPdata *gpd;		/* gp-datablock layer comes from */
 	bGPDlayer *gpl;		/* layer we're working on */
@@ -1108,8 +1113,8 @@
 	short mval[2];		/* current mouse-position */
 	short mvalo[2];		/* previous recorded mouse-position */
 	
-	short pressure;		/* current stylus pressure */
-	short opressure;	/* previous stylus pressure */
+	float pressure;		/* current stylus pressure */
+	float opressure;	/* previous stylus pressure */
 	
 	short radius;		/* radius of influence for eraser */
 } tGPsdata;
@@ -1213,43 +1218,20 @@
 	}
 	
 	/* 2d - on image 'canvas' (assume that p->v2d is set) */
-	else if ((gpd->sbuffer_sflag & GP_STROKE_2DIMAGE) && (p->v2d)) {
-		/* for now - space specific */
-		switch (p->sa->spacetype) {
-			case SPACE_SEQ: /* sequencer */
-			{
-				SpaceSeq *sseq= (SpaceSeq *)p->sa->spacedata.first;
-				int sizex, sizey, offsx, offsy, rectx, recty;
-				float zoom, zoomx, zoomy;
-				
-				/* calculate zoom factor */
-				zoom= SEQ_ZOOM_FAC(sseq->zoom);
-				if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
-					zoomx = zoom * ((float)G.scene->r.xasp / (float)G.scene->r.yasp);
-					zoomy = zoom;
-				} 
-				else
-					zoomx = zoomy = zoom;
-				
-				/* calculate rect size */
-				rectx= (G.scene->r.size*G.scene->r.xsch)/100;
-				recty= (G.scene->r.size*G.scene->r.ysch)/100; 
-				sizex= zoomx * rectx;
-				sizey= zoomy * recty;
-				offsx= (p->sa->winx-sizex)/2 + sseq->xof;
-				offsy= (p->sa->winy-sizey)/2 + sseq->yof;
-				
-				/* calculate new points */
-				out[0]= (float)(mval[0] - offsx) / (float)sizex;
-				out[1]= (float)(mval[1] - offsy) / (float)sizey;
-			}
-				break;
-				
-			default: /* just use raw mouse coordinates - BAD! */
-				out[0]= mval[0];
-				out[1]= mval[1];
-				break;
-		}		
+	else if (gpd->sbuffer_sflag & GP_STROKE_2DIMAGE) {
+		int sizex, sizey, offsx, offsy;
+		
+		/* get stored settings 
+		 *	- assume that these have been set already (there are checks that set sane 'defaults' just in case)
+		 */
+		sizex= p->im2d_settings.sizex;
+		sizey= p->im2d_settings.sizey;
+		offsx= p->im2d_settings.offsx;
+		offsy= p->im2d_settings.offsy;
+		
+		/* calculate new points */
+		out[0]= (float)(mval[0] - offsx) / (float)sizex;
+		out[1]= (float)(mval[1] - offsy) / (float)sizey;
 	}
 	
 	/* 2d - relative to screen (viewport area) */
@@ -1574,9 +1556,17 @@
 			y0= xyval[1];
 		}
 		else if (gps->flag & GP_STROKE_2DIMAGE) {			
-			ipoco_to_areaco_noclip(p->v2d, &gps->points->x, xyval);
-			x0= xyval[0];
-			y0= xyval[1];
+			int offsx, offsy, sizex, sizey;
+				
+			/* get stored settings */
+			sizex= p->im2d_settings.sizex;
+			sizey= p->im2d_settings.sizey;
+			offsx= p->im2d_settings.offsx;
+			offsy= p->im2d_settings.offsy;
+			
+			/* calculate new points */
+			x0= (gps->points->x * sizex) + offsx;
+			y0= (gps->points->y * sizey) + offsy;
 		}
 		else {
 			x0= (gps->points->x / 1000 * p->sa->winx);
@@ -1622,13 +1612,20 @@
 				y1= xyval[1];
 			}
 			else if (gps->flag & GP_STROKE_2DIMAGE) {
-				ipoco_to_areaco_noclip(p->v2d, &pt1->x, xyval);
-				x0= xyval[0];
-				y0= xyval[1];
+				int offsx, offsy, sizex, sizey;
 				
-				ipoco_to_areaco_noclip(p->v2d, &pt2->x, xyval);
-				x1= xyval[0];
-				y1= xyval[1];
+				/* get stored settings */
+				sizex= p->im2d_settings.sizex;
+				sizey= p->im2d_settings.sizey;
+				offsx= p->im2d_settings.offsx;
+				offsy= p->im2d_settings.offsy;
+				
+				/* calculate new points */
+				x0= (pt1->x * sizex) + offsx;
+				y0= (pt1->y * sizey) + offsy;
+				
+				x1= (pt2->x * sizex) + offsx;
+				y1= (pt2->y * sizey) + offsy;
 			}
 			else {
 				x0= (pt1->x / 1000 * p->sa->winx);
@@ -1800,6 +1797,10 @@
 	
 	/* clear out buffer (stored in gp-data) in case something contaminated it */
 	gp_session_validatebuffer(p);
+	
+	/* set 'default' im2d_settings just in case something that uses this doesn't set it */
+	p->im2d_settings.sizex= 1;
+	p->im2d_settings.sizey= 1;
 }
 
 /* cleanup after a painting session */
@@ -1870,7 +1871,35 @@
 				break;
 			case SPACE_SEQ:
 			{
+				SpaceSeq *sseq= (SpaceSeq *)p->sa->spacedata.first;
+				int rectx, recty;
+				float zoom, zoomx, zoomy;
+				
+				/* set draw 2d-stroke flag */
 				p->gpd->sbuffer_sflag |= GP_STROKE_2DIMAGE;
+				
+				/* calculate zoom factor */
+				zoom= SEQ_ZOOM_FAC(sseq->zoom);
+				if (sseq->mainb == SEQ_DRAW_IMG_IMBUF) {
+					zoomx = zoom * ((float)G.scene->r.xasp / (float)G.scene->r.yasp);
+					zoomy = zoom;
+				} 
+				else
+					zoomx = zoomy = zoom;
+				
+				/* calculate rect size to use to calculate the size of the drawing area
+				 *	- We use the size of the output image not the size of the ibuf being shown
+				 *	  as it is too messy getting the ibuf (and could be too slow). This should be
+				 *	  a reasonable for most cases anyway.
+				 */
+				rectx= (G.scene->r.size * G.scene->r.xsch) / 100;
+				recty= (G.scene->r.size * G.scene->r.ysch) / 100; 
+				
+				/* set offset and scale values for opertations to use */
+				p->im2d_settings.sizex= zoomx * rectx;
+				p->im2d_settings.sizey= zoomy * recty;
+				p->im2d_settings.offsx= (p->sa->winx-p->im2d_settings.sizex)/2 + sseq->xof;
+				p->im2d_settings.offsy= (p->sa->winy-p->im2d_settings.sizey)/2 + sseq->yof;
 			}
 				break;
 			case SPACE_IMAGE:





More information about the Bf-blender-cvs mailing list