Page Menu
Home
Search
Configure Global Search
Log In
Files
F22659
bmo_triangulate.c.diff
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Authored By
Campbell Barton (campbellbarton)
Nov 13 2013, 5:06 PM
Size
2 KB
Subscribers
None
bmo_triangulate.c.diff
View Options
Index: source/blender/bmesh/operators/bmo_triangulate.c
===================================================================
--- source/blender/bmesh/operators/bmo_triangulate.c (revision 54483)
+++ source/blender/bmesh/operators/bmo_triangulate.c (working copy)
@@ -55,6 +55,9 @@
BMO_slot_buffer_from_enabled_hflag(bm, op, op->slots_out, "faces.out", BM_FACE, BM_ELEM_TAG);
}
+
+#define BEAUTY_EPSILON 0.000001f
+
void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
{
BMOIter siter;
@@ -91,16 +94,38 @@
{
float *v1, *v2, *v3, *v4;
- float no_a[3], no_b[3];
+ bool is_zero_a, is_zero_b;
+
v1 = e->l->prev->v->co;
v2 = e->l->v->co;
v3 = e->l->radial_next->prev->v->co;
v4 = e->l->next->v->co;
- normal_tri_v3(no_a, v1, v2, v3);
- normal_tri_v3(no_b, v1, v3, v4);
- add_v3_v3v3(no, no_a, no_b);
- normalize_v3(no);
+ is_zero_a = area_tri_v3(v2, v3, v4) <= BEAUTY_EPSILON;
+ is_zero_b = area_tri_v3(v2, v4, v1) <= BEAUTY_EPSILON;
+
+ if (LIKELY(is_zero_a == false && is_zero_b == false)) {
+ float no_a[3], no_b[3];
+ normal_tri_v3(no_a, v2, v3, v4); /* a */
+ normal_tri_v3(no_b, v2, v4, v1); /* b */
+ add_v3_v3v3(no, no_a, no_b);
+ if (UNLIKELY(normalize_v3(no) <= BEAUTY_EPSILON)) {
+ continue;
+ }
+ }
+ else if (is_zero_a == false) {
+ normal_tri_v3(no, v2, v3, v4); /* a */
+ }
+ else if (is_zero_b == false) {
+ normal_tri_v3(no, v2, v4, v1); /* b */
+ }
+ else {
+ /* both zero area, no useful normal can be calculated */
+ continue;
+ }
+
+// { float a = angle_normalized_v3v3(no_a, no_b); printf("~ %.7f\n", a); fflush(stdout);}
+
axis_dominant_v3_to_m3(axis_mat, no);
mul_v2_m3v3(v1_xy, axis_mat, v1);
mul_v2_m3v3(v2_xy, axis_mat, v2);
@@ -130,7 +155,8 @@
fac2 = opp1 / (len2 + len3 + len6) + opp2 / (len4 + len1 + len6);
- if (fac1 > fac2) {
+ /* need to use an epsilon value else we can keep rotating forever [#34214] */
+ if ((fac1 - BEAUTY_EPSILON) > fac2) {
e = BM_edge_rotate(bm, e, false, BM_EDGEROT_CHECK_EXISTS);
if (e) {
BMO_elem_flag_enable(bm, e, ELE_NEW | EDGE_MARK);
File Metadata
Details
Mime Type
text/x-diff
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
4d/d6/f386ee2c587ee064f0fe7d03ff7e
Event Timeline
Log In to Comment