GreasePencil: division by zero when stroke has one point

Error "runtime error: division by zero" when opening:
"Sketch 1 demo by Brain Graft.blend"
This commit is contained in:
Dalai Felinto 2018-11-09 09:57:37 -02:00
parent ab77f5b5fe
commit 494ba42254
1 changed files with 6 additions and 0 deletions

View File

@ -1835,15 +1835,21 @@ void ED_gpencil_calc_stroke_uv(Object *ob, bGPDstroke *gps)
totlen += len_v3v3(&pt->x, &ptb->x) / pixsize;
pt->uv_fac = totlen;
}
/* normalize the distance using a factor */
float factor;
/* if image, use texture width */
if ((gp_style) && (gp_style->sima)) {
factor = gp_style->sima->gen_x;
}
else if (totlen == 0) {
return;
}
else {
factor = totlen;
}
for (i = 0; i < gps->totpoints; i++) {
pt = &gps->points[i];
pt->uv_fac /= factor;