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.
This commit is contained in:
Bastien Montagne 2014-01-12 18:52:14 +01:00
parent 190809d8ab
commit d785c64397
Notes: blender-bot 2023-02-14 20:12:00 +01:00
Referenced by issue blender/blender-addons#38124, Grease Pencil Line thickness
1 changed files with 6 additions and 5 deletions

View File

@ -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);