diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-08-30 10:10:38 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-08-30 10:10:38 +0400 |
commit | 46ba8b6edb242b5cf7605cf04c79c85159eb222c (patch) | |
tree | 4a59d6f07b0c35843efd7a3947da9334388a3713 /source | |
parent | 05ebac71ca72966efd2d5d8692f5959c33a9d621 (diff) |
Grease Pencil: Hacky fix for "broken strokes" bug (pun intended) ;)
For the strokes drawn using OpenGL lines, moderately-sized changes in the pressure between two points could result in the stroke being disjointed, since a new GL_LINE_STRIP would need to be created with the new line thickness due to the new pressure value.
(In reference to the summary of this commit, this bug was noticed by Matt Ebb (broken). This bug is also in 2.4x, but was suprisingly not really noticed.)
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/gpencil/drawgpencil.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/editors/gpencil/drawgpencil.c b/source/blender/editors/gpencil/drawgpencil.c index 4a48e9a4e3b..a89a038d760 100644 --- a/source/blender/editors/gpencil/drawgpencil.c +++ b/source/blender/editors/gpencil/drawgpencil.c @@ -122,11 +122,21 @@ static void gp_draw_stroke_buffer (tGPspoint *points, int totpoints, short thick 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) + */ if (fabs(pt->pressure - oldpressure) > 0.2f) { glEnd(); glLineWidth(pt->pressure * thickness); glBegin(GL_LINE_STRIP); + /* need to roll-back one point to ensure that there are no gaps in the stroke */ + if (i != 0) { + pt--; + glVertex2f(pt->x, pt->y); + pt++; + } + /* now the point we want... */ glVertex2f(pt->x, pt->y); oldpressure = pt->pressure; @@ -206,11 +216,21 @@ static void gp_draw_stroke_3d (bGPDspoint *points, int totpoints, short thicknes /* draw stroke curve */ 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) + */ if (fabs(pt->pressure - oldpressure) > 0.2f) { glEnd(); glLineWidth(pt->pressure * thickness); glBegin(GL_LINE_STRIP); + /* need to roll-back one point to ensure that there are no gaps in the stroke */ + if (i != 0) { + pt--; + glVertex3f(pt->x, pt->y, pt->z); + pt++; + } + /* now the point we want... */ glVertex3f(pt->x, pt->y, pt->z); oldpressure = pt->pressure; |