[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [22884] branches/blender2.5/blender/source /blender/editors/gpencil/drawgpencil.c: Grease Pencil: Hacky fix for " broken strokes" bug (pun intended) ; )

Joshua Leung aligorith at gmail.com
Sun Aug 30 08:10:38 CEST 2009


Revision: 22884
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=22884
Author:   aligorith
Date:     2009-08-30 08:10:38 +0200 (Sun, 30 Aug 2009)

Log Message:
-----------
Grease Pencil: Hacky fix for "broken strokes" bug (pun intended) ;)

For the strokes drawn using OpenGL lines, moderately-sized changes in the pressure between two points could result in the stroke being disjointed, since a new GL_LINE_STRIP would need to be created with the new line thickness due to the new pressure value. 

(In reference to the summary of this commit, this bug was noticed by Matt Ebb (broken). This bug is also in 2.4x, but was suprisingly not really noticed.)

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c

Modified: branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c	2009-08-30 05:54:27 UTC (rev 22883)
+++ branches/blender2.5/blender/source/blender/editors/gpencil/drawgpencil.c	2009-08-30 06:10:38 UTC (rev 22884)
@@ -122,11 +122,21 @@
 		
 		glBegin(GL_LINE_STRIP);
 		for (i=0, pt=points; i < totpoints && pt; i++, pt++) {
+			/* if there was a significant pressure change, stop the curve, change the thickness of the stroke,
+			 * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP)
+			 */
 			if (fabs(pt->pressure - oldpressure) > 0.2f) {
 				glEnd();
 				glLineWidth(pt->pressure * thickness);
 				glBegin(GL_LINE_STRIP);
 				
+				/* need to roll-back one point to ensure that there are no gaps in the stroke */
+				if (i != 0) {
+					pt--;
+					glVertex2f(pt->x, pt->y);
+					pt++;
+				}
+				/* now the point we want... */
 				glVertex2f(pt->x, pt->y);
 				
 				oldpressure = pt->pressure;
@@ -206,11 +216,21 @@
 	/* draw stroke curve */
 	glBegin(GL_LINE_STRIP);
 	for (i=0, pt=points; i < totpoints && pt; i++, pt++) {
+		/* if there was a significant pressure change, stop the curve, change the thickness of the stroke,
+		 * and continue drawing again (since line-width cannot change in middle of GL_LINE_STRIP)
+		 */
 		if (fabs(pt->pressure - oldpressure) > 0.2f) {
 			glEnd();
 			glLineWidth(pt->pressure * thickness);
 			glBegin(GL_LINE_STRIP);
 			
+			/* need to roll-back one point to ensure that there are no gaps in the stroke */
+			if (i != 0) {
+				pt--;
+				glVertex3f(pt->x, pt->y, pt->z);
+				pt++;
+			}
+			/* now the point we want... */
 			glVertex3f(pt->x, pt->y, pt->z);
 			
 			oldpressure = pt->pressure;





More information about the Bf-blender-cvs mailing list