Fix T79482: Triangulate quads with 'Beauty' can make zero area faces

This commit is contained in:
Campbell Barton 2020-08-03 21:04:08 +10:00 committed by Jeroen Bakker
parent 6cbbe04ced
commit f2b71df549
Notes: blender-bot 2023-02-14 09:38:57 +01:00
Referenced by issue #85402, Triangulate non-planar faces with "beauty" method produces faces that point in different directions
Referenced by issue #79482, Triangulate faces with 'Beauty method' produces extra small triangles in certain cases
Referenced by issue #77348, Blender LTS: Maintenance Task 2.83
3 changed files with 13 additions and 4 deletions

View File

@ -39,7 +39,10 @@ void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
BMFace *f;
BMEdge *e;
const bool use_restrict_tag = BMO_slot_bool_get(op->slots_in, "use_restrict_tag");
const short flag = (use_restrict_tag ? VERT_RESTRICT_TAG : 0);
const short flag =
((use_restrict_tag ? VERT_RESTRICT_TAG : 0) |
/* Enable to avoid iterative edge rotation to cause the direction of faces to flip. */
EDGE_RESTRICT_DEGENERATE);
const short method = (short)BMO_slot_int_get(op->slots_in, "method");
BMEdge **edge_array;

View File

@ -141,7 +141,8 @@ static void erot_state_alternate(const BMEdge *e, EdRotState *e_state)
static float bm_edge_calc_rotate_beauty__area(const float v1[3],
const float v2[3],
const float v3[3],
const float v4[3])
const float v4[3],
const bool lock_degenerate)
{
/* not a loop (only to be able to break out) */
do {
@ -199,7 +200,8 @@ static float bm_edge_calc_rotate_beauty__area(const float v1[3],
* Allowing to rotate out of a degenerate state can flip the faces
* (when performed iteratively).
*/
return BLI_polyfill_beautify_quad_rotate_calc_ex(v1_xy, v2_xy, v3_xy, v4_xy, true, NULL);
return BLI_polyfill_beautify_quad_rotate_calc_ex(
v1_xy, v2_xy, v3_xy, v4_xy, lock_degenerate, NULL);
} while (false);
return FLT_MAX;
@ -262,7 +264,8 @@ float BM_verts_calc_rotate_beauty(const BMVert *v1,
switch (method) {
case 0:
return bm_edge_calc_rotate_beauty__area(v1->co, v2->co, v3->co, v4->co);
return bm_edge_calc_rotate_beauty__area(
v1->co, v2->co, v3->co, v4->co, flag & EDGE_RESTRICT_DEGENERATE);
default:
return bm_edge_calc_rotate_beauty__angle(v1->co, v2->co, v3->co, v4->co);
}

View File

@ -22,7 +22,10 @@
*/
enum {
/** Vertices tags must match (special case). */
VERT_RESTRICT_TAG = (1 << 0),
/** Don't rotate out of degenerate state (needed for iterative rotation). */
EDGE_RESTRICT_DEGENERATE = (1 << 1),
};
void BM_mesh_beautify_fill(BMesh *bm,