diff options
author | Hans Goudey <h.goudey@me.com> | 2020-11-03 07:35:15 +0300 |
---|---|---|
committer | Hans Goudey <h.goudey@me.com> | 2020-11-03 07:35:15 +0300 |
commit | 6290bc4a372f6499397fb9c489fee7e9b45c744c (patch) | |
tree | 05d3b13dfefea33a83a4500b747e2a5bf8e8a8c5 /source/blender/bmesh/tools | |
parent | 23f3c30b5843c69c0eb2f531793a470fadb612e3 (diff) | |
parent | c6d8300823b4e21729450531f2d5a6826ab5a4fa (diff) |
Merge branch 'blender-v2.91-release'
Diffstat (limited to 'source/blender/bmesh/tools')
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.c | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 3a6ae9883e2..e8ded83dfbe 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -59,6 +59,8 @@ #define BEVEL_SMALL_ANG DEG2RADF(10.0f) /** Difference in dot products that corresponds to 10 degree difference between vectors. */ #define BEVEL_SMALL_ANG_DOT 1 - cosf(BEVEL_SMALL_ANG) +/** Difference in dot products that corresponds to 2.0 degree difference between vectors. */ +#define BEVEL_EPSILON_ANG_DOT 1 - cosf(BEVEL_EPSILON_ANG) #define BEVEL_MAX_ADJUST_PCT 10.0f #define BEVEL_MAX_AUTO_ADJUST_PCT 300.0f #define BEVEL_MATCH_SPEC_WEIGHT 0.2 @@ -432,6 +434,18 @@ static bool nearly_parallel(const float d1[3], const float d2[3]) return (fabsf(ang) < BEVEL_EPSILON_ANG) || (fabsf(ang - (float)M_PI) < BEVEL_EPSILON_ANG); } +/** + * \return True if d1 and d2 are parallel or nearly parallel. + */ +static bool nearly_parallel_normalized(const float d1[3], const float d2[3]) +{ + BLI_ASSERT_UNIT_V3(d1); + BLI_ASSERT_UNIT_V3(d2); + + const float direction_dot = dot_v3v3(d1, d2); + return compare_ff(fabsf(direction_dot), 1.0f, BEVEL_EPSILON_ANG_DOT); +} + /* Make a new BoundVert of the given kind, inserting it at the end of the circular linked * list with entry point bv->boundstart, and return it. */ static BoundVert *add_new_bound_vert(MemArena *mem_arena, VMesh *vm, const float co[3]) @@ -1096,6 +1110,12 @@ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v) sub_v3_v3v3(dir2, v->co, v2->co); normalize_v3(dir1); normalize_v3(dir2); + + /* First check for in-line edges using a simpler test. */ + if (nearly_parallel_normalized(dir1, dir2)) { + return ANGLE_STRAIGHT; + } + /* Angles are in [0,pi]. Need to compare cross product with normal to see if they are reflex. */ float cross[3]; cross_v3_v3v3(cross, dir1, dir2); @@ -1110,11 +1130,8 @@ static int edges_angle_kind(EdgeHalf *e1, EdgeHalf *e2, BMVert *v) else { no = v->no; } - float dot = dot_v3v3(cross, no); - if (fabsf(dot) < BEVEL_EPSILON_BIG) { - return ANGLE_STRAIGHT; - } - if (dot < 0.0f) { + + if (dot_v3v3(cross, no) < 0.0f) { return ANGLE_LARGER; } return ANGLE_SMALLER; |