[Bf-blender-cvs] [365b387] GPencil_FillStrokes: Volumetric strokes draw in 2D views too now

Joshua Leung noreply at git.blender.org
Wed Oct 29 13:45:03 CET 2014


Commit: 365b38799acd841348398a330c1789b93686ec4c
Author: Joshua Leung
Date:   Thu Oct 30 01:37:50 2014 +1300
Branches: GPencil_FillStrokes
https://developer.blender.org/rB365b38799acd841348398a330c1789b93686ec4c

Volumetric strokes draw in 2D views too now

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

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

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

diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c
index 391bc81..189618f 100644
--- a/source/blender/editors/gpencil/drawgpencil.c
+++ b/source/blender/editors/gpencil/drawgpencil.c
@@ -161,7 +161,6 @@ static void gp_draw_stroke_volumetric_buffer(tGPspoint *points, int totpoints, s
 	tGPspoint *pt;
 	int i;
 	
-	
 	/* error checking */
 	if ((points == NULL) || (totpoints <= 0))
 		return;
@@ -170,11 +169,9 @@ static void gp_draw_stroke_volumetric_buffer(tGPspoint *points, int totpoints, s
 	if (dflag & (GP_DRAWDATA_ONLY3D | GP_DRAWDATA_ONLYV2D))
 		return;
 	
-	
 	/* get basic matrix - should be camera space (i.e "identity") */
 	glGetFloatv(GL_MODELVIEW_MATRIX, (float *)modelview);
 	
-	
 	/* draw points */
 	glPushMatrix();
 	
@@ -196,6 +193,56 @@ static void gp_draw_stroke_volumetric_buffer(tGPspoint *points, int totpoints, s
 	gluDeleteQuadric(qobj);
 }
 
+/* draw a 2D strokes in "volumetric" style */
+static void gp_draw_stroke_volumetric_2d(bGPDspoint *points, int totpoints, short thickness, short dflag, short sflag,
+                                         int offsx, int offsy, int winx, int winy)
+{
+	GLUquadricObj *qobj = gluNewQuadric();
+	float modelview[4][4];
+	float baseloc[3];
+	
+	bGPDspoint *pt;
+	int i;
+	
+	
+	/* get basic matrix */
+	glGetFloatv(GL_MODELVIEW_MATRIX, (float *)modelview);
+	copy_v3_v3(baseloc, modelview[3]);
+	
+	/* draw points */
+	glPushMatrix();
+	
+	for (i = 0, pt = points; i < totpoints; i++, pt++) {
+		/* set the transformed position */
+		if (sflag & GP_STROKE_2DSPACE) {
+			translate_m4(modelview, pt->x, pt->y, 0.0f);
+		}
+		else if (sflag & GP_STROKE_2DIMAGE) {
+			const float x = (float)((pt->x * winx) + offsx);
+			const float y = (float)((pt->y * winy) + offsy);
+			
+			translate_m4(modelview, x, y, 0.0f);
+		}
+		else {
+			const float x = (float)(pt->x / 100 * winx) + offsx;
+			const float y = (float)(pt->y / 100 * winy) + offsy;
+			
+			translate_m4(modelview, x, y, 0.0f);
+		}
+		
+		glLoadMatrixf((float *)modelview);
+		
+		/* draw the disk using the current state... */
+		gluDisk(qobj, 0.0,  pt->pressure * thickness, 32, 1);
+		
+		/* restore matrix */
+		copy_v3_v3(modelview[3], baseloc);
+	}
+	
+	glPopMatrix();
+	gluDeleteQuadric(qobj);
+}
+
 /* draw a 3D stroke in "volumetric" style */
 static void gp_draw_stroke_volumetric_3d(bGPDspoint *points, int totpoints, short thickness, short dflag, short sflag)
 {
@@ -664,11 +711,16 @@ static void gp_draw_strokes(bGPDframe *gpf, int offsx, int offsy, int winx, int
 		}
 		else {
 			/* 2D Strokes... */
-			if (gps->totpoints == 1) {
-				gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy);
+			if (dflag & GP_DRAWDATA_VOLUMETRIC) {
+				gp_draw_stroke_volumetric_2d(gps->points, gps->totpoints, lthick, dflag, gps->flag, offsx, offsy, winx, winy);
 			}
 			else {
-				gp_draw_stroke(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, offsx, offsy, winx, winy);
+				if (gps->totpoints == 1) {
+					gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy);
+				}
+				else {
+					gp_draw_stroke_2d(gps->points, gps->totpoints, lthick, dflag, gps->flag, debug, offsx, offsy, winx, winy);
+				}
 			}
 		}
 	}




More information about the Bf-blender-cvs mailing list