[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [50885] trunk/blender/source/blender/ editors/gpencil/gpencil_paint.c: Bugfix [#32647] PolyLine tool for Grease Pencil was broken

Joshua Leung aligorith at gmail.com
Tue Sep 25 14:10:28 CEST 2012


Revision: 50885
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=50885
Author:   aligorith
Date:     2012-09-25 12:10:27 +0000 (Tue, 25 Sep 2012)
Log Message:
-----------
Bugfix [#32647] PolyLine tool for Grease Pencil was broken

This was broken in r.46589, although it doesn't seem that these changes have any
relevance to the main fix being performed there.

The problem was that the offending changes made the Grease Pencil modal handler
exit when an RMB event occurs meant that the operator was exiting after the
initial click, meaning that it was only possible to draw single dots at a time
when using the hotkey version of PolyLine. The toolbox version however was
unaffected.

I've noted this specific problem in the code as a warning.

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-09-25 10:21:51 UTC (rev 50884)
+++ trunk/blender/source/blender/editors/gpencil/gpencil_paint.c	2012-09-25 12:10:27 UTC (rev 50885)
@@ -1736,25 +1736,32 @@
 
 	//printf("\tGP - handle modal event...\n");
 	
-	/* exit painting mode (and/or end current stroke) */
-	if (ELEM5(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY, RIGHTMOUSE)) {
+	/* exit painting mode (and/or end current stroke) 
+	 * NOTE: cannot do RIGHTMOUSE (as is standard for cancelling) as that would break polyline [#32647] 
+	 */
+	if (ELEM4(event->type, RETKEY, PADENTER, ESCKEY, SPACEKEY)) {
 		/* exit() ends the current stroke before cleaning up */
 		//printf("\t\tGP - end of paint op + end of stroke\n");
 		p->status = GP_STATUS_DONE;
 		estate = OPERATOR_FINISHED;
 	}
 	
-	/* toggle painting mode upon mouse-button movement */
-	if (event->type == LEFTMOUSE) {
+	/* toggle painting mode upon mouse-button movement 
+	 *  - LEFTMOUSE  = standard drawing (all) / straight line drawing (all) / polyline (toolbox only)
+	 *  - RIGHTMOUSE = polyline (hotkey) / eraser (all)
+	 *    (Disabling RIGHTMOUSE case here results in bugs like [#32647])
+	 */
+	if (ELEM(event->type, LEFTMOUSE, RIGHTMOUSE)) {
 		/* if painting, end stroke */
 		if (p->status == GP_STATUS_PAINTING) {
 			int sketch = 0;
+			
 			/* basically, this should be mouse-button up = end stroke 
 			 * BUT what happens next depends on whether we 'painting sessions' is enabled
 			 */
 			sketch |= GPENCIL_SKETCH_SESSIONS_ON(p->scene);
 			/* polyline drawing is also 'sketching' -- all knots should be added during one session */
-			sketch |= p->paintmode == GP_PAINTMODE_DRAW_POLY;
+			sketch |= (p->paintmode == GP_PAINTMODE_DRAW_POLY);
 			
 			if (sketch) {
 				/* end stroke only, and then wait to resume painting soon */




More information about the Bf-blender-cvs mailing list