[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [36154] trunk/blender/source/blender/ editors/gpencil/drawgpencil.c: A better fix than r36151 for the Grease Pencil drawing issues in the

Joshua Leung aligorith at gmail.com
Thu Apr 14 06:22:52 CEST 2011


Revision: 36154
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36154
Author:   aligorith
Date:     2011-04-14 04:22:52 +0000 (Thu, 14 Apr 2011)
Log Message:
-----------
A better fix than r36151 for the Grease Pencil drawing issues in the
Image Editor.

There's already a flag in use for tagging the "special drawing in
Image Editor" case, so make use of that now.
Most of the changes here are just whitespace tweaks...

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=36151

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

Modified: trunk/blender/source/blender/editors/gpencil/drawgpencil.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/drawgpencil.c	2011-04-13 22:30:25 UTC (rev 36153)
+++ trunk/blender/source/blender/editors/gpencil/drawgpencil.c	2011-04-14 04:22:52 UTC (rev 36154)
@@ -75,15 +75,17 @@
 /* ----- General Defines ------ */
 
 /* flags for sflag */
-enum {
+typedef enum eDrawStrokeFlags {
 	GP_DRAWDATA_NOSTATUS 	= (1<<0),	/* don't draw status info */
 	GP_DRAWDATA_ONLY3D		= (1<<1),	/* only draw 3d-strokes */
 	GP_DRAWDATA_ONLYV2D		= (1<<2),	/* only draw 'canvas' strokes */
 	GP_DRAWDATA_ONLYI2D		= (1<<3),	/* only draw 'image' strokes */
 	GP_DRAWDATA_IEDITHACK	= (1<<4),	/* special hack for drawing strokes in Image Editor (weird coordinates) */
 	GP_DRAWDATA_NO_XRAY		= (1<<5),	/* dont draw xray in 3D view (which is default) */
-};
+} eDrawStrokeFlags;
 
+
+
 /* thickness above which we should use special drawing */
 #define GP_DRAWTHICKNESS_SPECIAL 	3
 
@@ -152,7 +154,7 @@
 /* ----- Existing Strokes Drawing (3D and Point) ------ */
 
 /* draw a given stroke - just a single dot (only one point) */
-static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short sflag, int offsx, int offsy, int winx, int winy)
+static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy)
 {
 	/* draw point */
 	if (sflag & GP_STROKE_3DSPACE) {
@@ -161,7 +163,6 @@
 		glEnd();
 	}
 	else {
-		// int spacetype= 0; // XXX make local gpencil state var?
 		float co[2];
 		
 		/* get coordinates of point */
@@ -181,12 +182,8 @@
 		/* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, simple dot looks ok
 		 * 	- also mandatory in if Image Editor 'image-based' dot
 		 */
-#if 0
 		if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) ||
-			 ((spacetype==SPACE_IMAGE) && (sflag & GP_STROKE_2DSPACE)) )
-#else
-		if(1) /* when spacetype is back uncomment the check above */
-#endif
+			 ((dflag & GP_DRAWDATA_IEDITHACK) && (sflag & GP_STROKE_2DSPACE)) )
 		{
 			glBegin(GL_POINTS);
 				glVertex2fv(co);
@@ -510,15 +507,16 @@
 		
 		/* check which stroke-drawer to use */
 		if (gps->totpoints == 1)
-			gp_draw_stroke_point(gps->points, lthick, gps->flag, offsx, offsy, winx, winy);
+			gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy);
 		else if (dflag & GP_DRAWDATA_ONLY3D) {
 			const int no_xray= (dflag & GP_DRAWDATA_NO_XRAY);
-			int mask_orig;
-			if(no_xray) {
+			int mask_orig = 0;
+			
+			if (no_xray) {
 				glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig);
 				glDepthMask(0);
 				glEnable(GL_DEPTH_TEST);
-
+				
 				/* first arg is normally rv3d->dist, but this isnt available here and seems to work quite well without */
 				bglPolygonOffset(1.0f, 1.0f);
 				/*
@@ -526,13 +524,13 @@
 				glPolygonOffset(-1.0f, -1.0f);
 				*/
 			}
-
+			
 			gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, debug);
-
-			if(no_xray) {
+			
+			if (no_xray) {
 				glDepthMask(mask_orig);
 				glDisable(GL_DEPTH_TEST);
-
+				
 				bglPolygonOffset(0.0, 0.0);
 				/*
 				glDisable(GL_POLYGON_OFFSET_LINE);
@@ -549,7 +547,6 @@
 static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag)
 {
 	bGPDlayer *gpl;
-	// bGPDlayer *actlay=NULL; // UNUSED
 	
 	/* reset line drawing style (in case previous user didn't reset) */
 	setlinestyle(0);
@@ -573,10 +570,6 @@
 		if (gpl->flag & GP_LAYER_HIDE) 
 			continue;
 		
-		/* if layer is active one, store pointer to it */
-		// if (gpl->flag & GP_LAYER_ACTIVE)
-		// 	actlay= gpl;
-		
 		/* get frame to draw */
 		gpf= gpencil_layer_getframe(gpl, cfra, 0);
 		if (gpf == NULL) 
@@ -588,11 +581,11 @@
 		QUATCOPY(tcolor, gpl->color); // additional copy of color (for ghosting)
 		glColor4f(color[0], color[1], color[2], color[3]);
 		glPointSize((float)(gpl->thickness + 2));
-
+		
 		/* apply xray layer setting */
-		if(gpl->flag & GP_LAYER_NO_XRAY)	dflag |=  GP_DRAWDATA_NO_XRAY;
+		if (gpl->flag & GP_LAYER_NO_XRAY)	dflag |=  GP_DRAWDATA_NO_XRAY;
 		else								dflag &= ~GP_DRAWDATA_NO_XRAY;
-
+		
 		/* draw 'onionskins' (frame left + right) */
 		if (gpl->flag & GP_LAYER_ONIONSKIN) {
 			/* drawing method - only immediately surrounding (gstep = 0), or within a frame range on either side (gstep > 0)*/			
@@ -791,11 +784,11 @@
 
 	/* check that we have grease-pencil stuff to draw */
 	gpd= gpencil_data_get_active_v3d(scene); // XXX
-	if(gpd == NULL) return;
+	if (gpd == NULL) return;
 
 	/* when rendering to the offscreen buffer we dont want to
 	 * deal with the camera border, otherwise map the coords to the camera border. */
-	if(rv3d->persp == RV3D_CAMOB && !(G.f & G_RENDER_OGL)) {
+	if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_RENDER_OGL)) {
 		rctf rectf;
 		view3d_calc_camera_border(scene, ar, rv3d, v3d, &rectf, -1); /* negative shift */
 		BLI_copy_rcti_rctf(&rect, &rectf);




More information about the Bf-blender-cvs mailing list