diff options
author | Dalai Felinto <dfelinto@gmail.com> | 2018-11-09 14:57:37 +0300 |
---|---|---|
committer | Dalai Felinto <dfelinto@gmail.com> | 2018-11-09 14:57:37 +0300 |
commit | 494ba42254b4588f2c528a528741fd8f2e52bcb2 (patch) | |
tree | 979c6f4a318c085933165dec803774555f5a47fc /source/blender/editors/gpencil/gpencil_utils.c | |
parent | ab77f5b5fe59a8f0ff60b637883a53554b1de40c (diff) |
GreasePencil: division by zero when stroke has one point
Error "runtime error: division by zero" when opening:
"Sketch 1 demo by Brain Graft.blend"
Diffstat (limited to 'source/blender/editors/gpencil/gpencil_utils.c')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_utils.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/editors/gpencil/gpencil_utils.c b/source/blender/editors/gpencil/gpencil_utils.c index 41ea3a2138d..0098d99e581 100644 --- a/source/blender/editors/gpencil/gpencil_utils.c +++ b/source/blender/editors/gpencil/gpencil_utils.c @@ -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; |