[Bf-blender-cvs] [e7de96f] master: Fix: Strokes in image editor can finally be drawn using "fancy" 2D stroke tesslation

Joshua Leung noreply at git.blender.org
Mon Dec 1 13:21:59 CET 2014


Commit: e7de96f5eb3526683a94afc407cf672be17180f4
Author: Joshua Leung
Date:   Tue Dec 2 01:18:46 2014 +1300
Branches: master
https://developer.blender.org/rBe7de96f5eb3526683a94afc407cf672be17180f4

Fix: Strokes in image editor can finally be drawn using "fancy" 2D stroke tesslation

Inspired by the previous commit, I've finally found a way to fix a long standing
limitation/bug which meant that Grease Pencil strokes in the Image Editor could
not be drawn using the fancy stroke tesselation code, and were instead done using
the plain old OpenGL strokes instead.

===================================================================

M	source/blender/editors/gpencil/drawgpencil.c

===================================================================

diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 199d870..2584f57 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -451,30 +451,18 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness
 {
 	/* otherwise thickness is twice that of the 3D view */
 	float thickness = (float)thickness_s * 0.5f;
-
-	/* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, 'smooth' opengl lines look better
-	 *  - 'smooth' opengl lines are also required if Image Editor 'image-based' stroke
-	 */
-	if ((thickness < GP_DRAWTHICKNESS_SPECIAL) ||
-	    ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)))
-	{
-		bGPDspoint *pt;
-		int i;
-		
-		glBegin(GL_LINE_STRIP);
-		for (i = 0, pt = points; i < totpoints && pt; i++, pt++) {
-			float co[2];
-			
-			gp_calc_2d_stroke_xy(pt, sflag, offsx, offsy, winx, winy, co);
-			glVertex2fv(co);
-		}
-		glEnd();
+	
+	/* strokes in Image Editor need a scale factor, since units there are not pixels! */
+	float scalefac  = 1.0f;
+	if ((dflag & GP_DRAWDATA_IEDITHACK) && (dflag & GP_DRAWDATA_ONLYV2D)) {
+		scalefac = 0.001f;
 	}
 	
+	
 	/* tessellation code - draw stroke as series of connected quads with connection
 	 * edges rotated to minimize shrinking artifacts, and rounded endcaps
 	 */
-	else {
+	{
 		bGPDspoint *pt1, *pt2;
 		float pm[2];
 		int i;
@@ -501,7 +489,7 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness
 			m2[0] = m1[1];
 			
 			/* always use pressure from first point here */
-			pthick = (pt1->pressure * thickness);
+			pthick = (pt1->pressure * thickness * scalefac);
 			
 			/* if the first segment, start of segment is segment's normal */
 			if (i == 0) {
@@ -576,7 +564,7 @@ static void gp_draw_stroke_2d(bGPDspoint *points, int totpoints, short thickness
 			/* if last segment, also draw end of segment (defined as segment's normal) */
 			if (i == totpoints - 2) {
 				/* for once, we use second point's pressure (otherwise it won't be drawn) */
-				pthick = (pt2->pressure * thickness);
+				pthick = (pt2->pressure * thickness * scalefac);
 				
 				/* calculate points for end of segment */
 				mt[0] = m2[0] * pthick;




More information about the Bf-blender-cvs mailing list