Commit: ae028ef206cff475ec314db68d6d111f83b96a5d
Author: Jacques Lucke
Date:   Thu Dec 20 10:58:50 2018 +0100
Branches: blender2.8
https://developer.blender.org/rBae028ef206cff475ec314db68d6d111f83b96a5d

Fix T57045: Unhandled degenerate case in bevel code

Reviewers: howardt

Differential Revision: https://developer.blender.org/D4104

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

M       source/blender/bmesh/tools/bmesh_bevel.c

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

diff --git a/source/blender/bmesh/tools/bmesh_bevel.c 
b/source/blender/bmesh/tools/bmesh_bevel.c
index 8499db2fdb5..f0c2a343d4a 100644
--- a/source/blender/bmesh/tools/bmesh_bevel.c
+++ b/source/blender/bmesh/tools/bmesh_bevel.c
@@ -1261,31 +1261,36 @@ static bool make_unit_square_map(
 
        sub_v3_v3v3(va_vmid, vmid, va);
        sub_v3_v3v3(vb_vmid, vmid, vb);
-       if (fabsf(angle_v3v3(va_vmid, vb_vmid) - (float)M_PI) > 
BEVEL_EPSILON_ANG) {
-               sub_v3_v3v3(vo, va, vb_vmid);
-               cross_v3_v3v3(vddir, vb_vmid, va_vmid);
-               normalize_v3(vddir);
-               add_v3_v3v3(vd, vo, vddir);
-
-               /* The cols of m are: {vmid - va, vmid - vb, vmid + vd - va 
-vb, va + vb - vmid;
-                * blender transform matrices are stored such that m[i][*] is 
ith column;
-                * the last elements of each col remain as they are in unity 
matrix */
-               sub_v3_v3v3(&r_mat[0][0], vmid, va);
-               r_mat[0][3] = 0.0f;
-               sub_v3_v3v3(&r_mat[1][0], vmid, vb);
-               r_mat[1][3] = 0.0f;
-               add_v3_v3v3(&r_mat[2][0], vmid, vd);
-               sub_v3_v3(&r_mat[2][0], va);
-               sub_v3_v3(&r_mat[2][0], vb);
-               r_mat[2][3] = 0.0f;
-               add_v3_v3v3(&r_mat[3][0], va, vb);
-               sub_v3_v3(&r_mat[3][0], vmid);
-               r_mat[3][3] = 1.0f;
 
-               return true;
+       if (is_zero_v3(va_vmid) || is_zero_v3(vb_vmid)) {
+               return false;
        }
-       else
+
+       if (fabsf(angle_v3v3(va_vmid, vb_vmid) - (float)M_PI) <= 
BEVEL_EPSILON_ANG) {
                return false;
+       }
+
+       sub_v3_v3v3(vo, va, vb_vmid);
+       cross_v3_v3v3(vddir, vb_vmid, va_vmid);
+       normalize_v3(vddir);
+       add_v3_v3v3(vd, vo, vddir);
+
+       /* The cols of m are: {vmid - va, vmid - vb, vmid + vd - va -vb, va + 
vb - vmid;
+               * blender transform matrices are stored such that m[i][*] is 
ith column;
+               * the last elements of each col remain as they are in unity 
matrix */
+       sub_v3_v3v3(&r_mat[0][0], vmid, va);
+       r_mat[0][3] = 0.0f;
+       sub_v3_v3v3(&r_mat[1][0], vmid, vb);
+       r_mat[1][3] = 0.0f;
+       add_v3_v3v3(&r_mat[2][0], vmid, vd);
+       sub_v3_v3(&r_mat[2][0], va);
+       sub_v3_v3(&r_mat[2][0], vb);
+       r_mat[2][3] = 0.0f;
+       add_v3_v3v3(&r_mat[3][0], va, vb);
+       sub_v3_v3(&r_mat[3][0], vmid);
+       r_mat[3][3] = 1.0f;
+
+       return true;
 }
 
 /* Like make_unit_square_map, but this one makes a matrix that transforms the

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to