[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [46587] trunk/blender/source/blender/ editors/gpencil/gpencil_paint.c: replace GP_PAINTFLAG_STROKEADDED with a NULL check, saves worrying about keeping the flag correct after undo.

Campbell Barton ideasman42 at gmail.com
Sat May 12 23:29:26 CEST 2012


Revision: 46587
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=46587
Author:   campbellbarton
Date:     2012-05-12 21:29:25 +0000 (Sat, 12 May 2012)
Log Message:
-----------
replace GP_PAINTFLAG_STROKEADDED with a NULL check, saves worrying about keeping the flag correct after undo.

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

Modified: trunk/blender/source/blender/editors/gpencil/gpencil_paint.c
===================================================================
--- trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2012-05-12 21:23:02 UTC (rev 46586)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2012-05-12 21:29:25 UTC (rev 46587)
@@ -128,8 +128,7 @@
 
 /* Runtime flags */
 enum {
-	GP_PAINTFLAG_FIRSTRUN       = (1 << 0),   /* operator just started */
-	GP_PAINTFLAG_STROKEADDED    = (1 << 1)    /* stroke was already added during draw session */
+	GP_PAINTFLAG_FIRSTRUN       = (1 << 0)    /* operator just started */
 };
 
 /* ------ */
@@ -143,6 +142,11 @@
 /* minimum length of new segment before new point can be added */
 #define MIN_EUCLIDEAN_PX    (U.gp_euclideandist)
 
+static int gp_stroke_is_added(tGPsdata *p)
+{
+	return (p->gpf && p->gpf->strokes.last);
+}
+
 /* ------ */
 /* Forward defines for some functions... */
 
@@ -322,11 +326,6 @@
 	bGPdata *gpd = p->gpd;
 	tGPspoint *pt;
 
-	/* sanity check, can happen after undo [#31427] */
-	if (p->flags & GP_PAINTFLAG_STROKEADDED && p->gpf->strokes.last == NULL) {
-		p->flags &= ~GP_PAINTFLAG_STROKEADDED;
-	}
-
 	/* check painting mode */
 	if (p->paintmode == GP_PAINTMODE_DRAW_STRAIGHT) {
 		/* straight lines only - i.e. only store start and end point in buffer */
@@ -395,7 +394,7 @@
 		 * to stroke. This allows to draw lines more interactively (see new segment
 		 * during mouse slide, i.e.) 
 		 */
-		if (p->flags & GP_PAINTFLAG_STROKEADDED) {
+		if (gp_stroke_is_added(p)) {
 			bGPDstroke *gps = p->gpf->strokes.last;
 			bGPDspoint *pts;
 
@@ -583,8 +582,9 @@
 	 * coordinates are getting added to stroke immediately to allow more
 	 * interactive behavior */
 	if (p->paintmode == GP_PAINTMODE_DRAW_POLY) {
-		if (p->flags & GP_PAINTFLAG_STROKEADDED)
+		if (gp_stroke_is_added(p)) {
 			return;
+		}
 	}
 
 	/* allocate memory for a new stroke */
@@ -715,8 +715,6 @@
 		if (depth_arr)
 			MEM_freeN(depth_arr);
 	}
-	
-	p->flags |= GP_PAINTFLAG_STROKEADDED;
 
 	/* add stroke to frame */
 	BLI_addtail(&p->gpf->strokes, gps);




More information about the Bf-blender-cvs mailing list