Fix #20196: division by zero in edge slide with two overlapping loops.
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 21 Jul 2010 15:22:11 +0000 (15:22 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Wed, 21 Jul 2010 15:22:11 +0000 (15:22 +0000)
source/blender/editors/transform/transform.c
source/blender/editors/transform/transform_input.c

index beea3c9..86fdb81 100644 (file)
@@ -4780,10 +4780,11 @@ int doEdgeSlide(TransInfo *t, float perc)
                //Non prop code
                look = vertlist;
                while(look) {
-                       float newlen;
+                       float newlen, edgelen;
                        ev = look->link;
                        tempsv = BLI_ghash_lookup(vertgh,ev);
-                       newlen = (len / len_v3v3(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co));
+                       edgelen = len_v3v3(editedge_getOtherVert(tempsv->up,ev)->co,editedge_getOtherVert(tempsv->down,ev)->co);
+                       newlen = (edgelen != 0.0f)? (len / edgelen): 0.0f;
                        if(newlen > 1.0) {newlen = 1.0;}
                        if(newlen < 0.0) {newlen = 0.0;}
                        if(flip == 0) {
index d7ebd28..b7cb348 100644 (file)
@@ -197,17 +197,17 @@ void InputCustomRatio(TransInfo *t, MouseInput *mi, short mval[2], float output[
                        mdx = (mi->precision_mval[0] + (float)(mval[0] - mi->precision_mval[0]) / 10.0f) - data[2];
                        mdy = (mi->precision_mval[1] + (float)(mval[1] - mi->precision_mval[1]) / 10.0f) - data[3];
 
-                       distance = (mdx*dx + mdy*dy) / length;
+                       distance = (length != 0.0f)? (mdx*dx + mdy*dy) / length: 0.0f;
                }
                else {
                        short mdx, mdy;
                        mdx = mval[0] - data[2];
                        mdy = mval[1] - data[3];
 
-                       distance = (mdx*dx + mdy*dy) / length;
+                       distance = (length != 0.0f)? (mdx*dx + mdy*dy) / length: 0.0f;
                }
 
-               output[0] = distance / length;
+               output[0] = (length != 0.0f)? distance / length: 0.0f;
        }
 }