From 6019b007a85b2544f754fdc9d2fe88382e8e52eb Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Thu, 14 Apr 2011 04:22:52 +0000 Subject: A better fix than r36151 for the Grease Pencil drawing issues in the Image Editor. There's already a flag in use for tagging the "special drawing in Image Editor" case, so make use of that now. Most of the changes here are just whitespace tweaks... --- source/blender/editors/gpencil/drawgpencil.c | 47 ++++++++++++---------------- 1 file changed, 20 insertions(+), 27 deletions(-) (limited to 'source') diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 598c0e5fa26..1a9ef4be70f 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -75,14 +75,16 @@ /* ----- General Defines ------ */ /* flags for sflag */ -enum { +typedef enum eDrawStrokeFlags { GP_DRAWDATA_NOSTATUS = (1<<0), /* don't draw status info */ GP_DRAWDATA_ONLY3D = (1<<1), /* only draw 3d-strokes */ GP_DRAWDATA_ONLYV2D = (1<<2), /* only draw 'canvas' strokes */ GP_DRAWDATA_ONLYI2D = (1<<3), /* only draw 'image' strokes */ GP_DRAWDATA_IEDITHACK = (1<<4), /* special hack for drawing strokes in Image Editor (weird coordinates) */ GP_DRAWDATA_NO_XRAY = (1<<5), /* dont draw xray in 3D view (which is default) */ -}; +} eDrawStrokeFlags; + + /* thickness above which we should use special drawing */ #define GP_DRAWTHICKNESS_SPECIAL 3 @@ -152,7 +154,7 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick /* ----- Existing Strokes Drawing (3D and Point) ------ */ /* draw a given stroke - just a single dot (only one point) */ -static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short sflag, int offsx, int offsy, int winx, int winy) +static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short dflag, short sflag, int offsx, int offsy, int winx, int winy) { /* draw point */ if (sflag & GP_STROKE_3DSPACE) { @@ -161,7 +163,6 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short sfl glEnd(); } else { - // int spacetype= 0; // XXX make local gpencil state var? float co[2]; /* get coordinates of point */ @@ -181,12 +182,8 @@ static void gp_draw_stroke_point (bGPDspoint *points, short thickness, short sfl /* if thickness is less than GP_DRAWTHICKNESS_SPECIAL, simple dot looks ok * - also mandatory in if Image Editor 'image-based' dot */ -#if 0 if ( (thickness < GP_DRAWTHICKNESS_SPECIAL) || - ((spacetype==SPACE_IMAGE) && (sflag & GP_STROKE_2DSPACE)) ) -#else - if(1) /* when spacetype is back uncomment the check above */ -#endif + ((dflag & GP_DRAWDATA_IEDITHACK) && (sflag & GP_STROKE_2DSPACE)) ) { glBegin(GL_POINTS); glVertex2fv(co); @@ -510,15 +507,16 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int /* check which stroke-drawer to use */ if (gps->totpoints == 1) - gp_draw_stroke_point(gps->points, lthick, gps->flag, offsx, offsy, winx, winy); + gp_draw_stroke_point(gps->points, lthick, dflag, gps->flag, offsx, offsy, winx, winy); else if (dflag & GP_DRAWDATA_ONLY3D) { const int no_xray= (dflag & GP_DRAWDATA_NO_XRAY); - int mask_orig; - if(no_xray) { + int mask_orig = 0; + + if (no_xray) { glGetIntegerv(GL_DEPTH_WRITEMASK, &mask_orig); glDepthMask(0); glEnable(GL_DEPTH_TEST); - + /* first arg is normally rv3d->dist, but this isnt available here and seems to work quite well without */ bglPolygonOffset(1.0f, 1.0f); /* @@ -526,13 +524,13 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int glPolygonOffset(-1.0f, -1.0f); */ } - + gp_draw_stroke_3d(gps->points, gps->totpoints, lthick, debug); - - if(no_xray) { + + if (no_xray) { glDepthMask(mask_orig); glDisable(GL_DEPTH_TEST); - + bglPolygonOffset(0.0, 0.0); /* glDisable(GL_POLYGON_OFFSET_LINE); @@ -549,7 +547,6 @@ static void gp_draw_strokes (bGPDframe *gpf, int offsx, int offsy, int winx, int static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy, int cfra, int dflag) { bGPDlayer *gpl; - // bGPDlayer *actlay=NULL; // UNUSED /* reset line drawing style (in case previous user didn't reset) */ setlinestyle(0); @@ -573,10 +570,6 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy if (gpl->flag & GP_LAYER_HIDE) continue; - /* if layer is active one, store pointer to it */ - // if (gpl->flag & GP_LAYER_ACTIVE) - // actlay= gpl; - /* get frame to draw */ gpf= gpencil_layer_getframe(gpl, cfra, 0); if (gpf == NULL) @@ -588,11 +581,11 @@ static void gp_draw_data (bGPdata *gpd, int offsx, int offsy, int winx, int winy QUATCOPY(tcolor, gpl->color); // additional copy of color (for ghosting) glColor4f(color[0], color[1], color[2], color[3]); glPointSize((float)(gpl->thickness + 2)); - + /* apply xray layer setting */ - if(gpl->flag & GP_LAYER_NO_XRAY) dflag |= GP_DRAWDATA_NO_XRAY; + if (gpl->flag & GP_LAYER_NO_XRAY) dflag |= GP_DRAWDATA_NO_XRAY; else dflag &= ~GP_DRAWDATA_NO_XRAY; - + /* draw 'onionskins' (frame left + right) */ if (gpl->flag & GP_LAYER_ONIONSKIN) { /* drawing method - only immediately surrounding (gstep = 0), or within a frame range on either side (gstep > 0)*/ @@ -791,11 +784,11 @@ void draw_gpencil_view3d_ext (Scene *scene, View3D *v3d, ARegion *ar, short only /* check that we have grease-pencil stuff to draw */ gpd= gpencil_data_get_active_v3d(scene); // XXX - if(gpd == NULL) return; + if (gpd == NULL) return; /* when rendering to the offscreen buffer we dont want to * deal with the camera border, otherwise map the coords to the camera border. */ - if(rv3d->persp == RV3D_CAMOB && !(G.f & G_RENDER_OGL)) { + if ((rv3d->persp == RV3D_CAMOB) && !(G.f & G_RENDER_OGL)) { rctf rectf; view3d_calc_camera_border(scene, ar, rv3d, v3d, &rectf, -1); /* negative shift */ BLI_copy_rcti_rctf(&rect, &rectf); -- cgit v1.2.3