diff options
author | Joshua Leung <aligorith@gmail.com> | 2014-12-01 15:18:46 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2014-12-01 15:19:49 +0300 |
commit | e7de96f5eb3526683a94afc407cf672be17180f4 (patch) | |
tree | 343e799e02b83205546a6540ed146400cead35c5 | |
parent | dfc56f1776cc0fffbafb6515353194c5b56fc91f (diff) |
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.
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 199d8701b9a..2584f578250 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; |