Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2018-12-20 12:58:50 +0300
committerJacques Lucke <mail@jlucke.com>2018-12-20 12:58:50 +0300
commitae028ef206cff475ec314db68d6d111f83b96a5d (patch)
treea761b32b15cf986fbd607f0d690743077cacc51e /source/blender/bmesh/tools/bmesh_bevel.c
parentb0478664597f87c29512b3909f39aa54fd5098c8 (diff)
Fix T57045: Unhandled degenerate case in bevel code
Reviewers: howardt Differential Revision: https://developer.blender.org/D4104
Diffstat (limited to 'source/blender/bmesh/tools/bmesh_bevel.c')
-rw-r--r--source/blender/bmesh/tools/bmesh_bevel.c49
1 files changed, 27 insertions, 22 deletions
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