From d785c64397bc6ec19cea0563fa1de982bdda28c6 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 12 Jan 2014 18:52:14 +0100 Subject: Fix T38124: Grease Pencil Line thickness Issue was in GP draw code: line thickness was not initiated properly (and a null one makes OGL draw a unity-width line). Also tweaked threshold (when to start a new, width-different OGL linestrip), to make it inversaly proportional to thickness (so that now, it's 0.2 for a thickness of 1, 0.1 for a thickness of 2, etc.), avoids too big steps when using large thickness. --- source/blender/editors/gpencil/drawgpencil.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/gpencil') diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index bb0a753d9c6..294a50909cb 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -206,18 +206,21 @@ static void gp_draw_stroke_point(bGPDspoint *points, short thickness, short dfla static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness, short debug) { bGPDspoint *pt; - float oldpressure = 0.0f; + float curpressure = points[0].pressure; int i; /* draw stroke curve */ + glLineWidth(curpressure * thickness); 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) + * Note: we want more visible levels of pressures when thickness is bigger. */ - if (fabsf(pt->pressure - oldpressure) > 0.2f) { + if (fabsf(pt->pressure - curpressure) > 0.2f / (float)thickness) { glEnd(); - glLineWidth(pt->pressure * thickness); + curpressure = pt->pressure; + glLineWidth(curpressure * thickness); glBegin(GL_LINE_STRIP); /* need to roll-back one point to ensure that there are no gaps in the stroke */ @@ -225,8 +228,6 @@ static void gp_draw_stroke_3d(bGPDspoint *points, int totpoints, short thickness /* now the point we want... */ glVertex3fv(&pt->x); - - oldpressure = pt->pressure; } else { glVertex3fv(&pt->x); -- cgit v1.2.3