Commit: 494ba42254b4588f2c528a528741fd8f2e52bcb2
Author: Dalai Felinto
Date:   Fri Nov 9 09:57:37 2018 -0200
Branches: blender2.8
https://developer.blender.org/rB494ba42254b4588f2c528a528741fd8f2e52bcb2

GreasePencil: division by zero when stroke has one point

Error "runtime error: division by zero" when opening:
"Sketch 1 demo by Brain Graft.blend"

===================================================================

M       source/blender/editors/gpencil/gpencil_utils.c

===================================================================

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;

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to