diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-04-19 12:13:39 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-04-20 00:50:48 +0300 |
commit | bde7439816371499a04bd551db0d4c64b01192b9 (patch) | |
tree | c4875c34d56feb7963fb08078f0f7f4e0dbccd5b /source/blender/bmesh | |
parent | ccbfbeba743f87c5491cdf9010bc1cf6b5c92b03 (diff) |
Minor optimization for limited-dissolve
Use dot product instead of angle.
Diffstat (limited to 'source/blender/bmesh')
-rw-r--r-- | source/blender/bmesh/tools/bmesh_decimate_dissolve.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c index 0777cb9727b..5a7a2f3ee29 100644 --- a/source/blender/bmesh/tools/bmesh_decimate_dissolve.c +++ b/source/blender/bmesh/tools/bmesh_decimate_dissolve.c @@ -91,9 +91,6 @@ static float bm_edge_calc_dissolve_error( const BMEdge *e, const BMO_Delimit delimit, const struct DelimitData *delimit_data) { - const bool is_contig = BM_edge_is_contiguous(e); - float angle; - if (!BM_edge_is_manifold(e)) { goto fail; } @@ -116,6 +113,8 @@ static float bm_edge_calc_dissolve_error( goto fail; } + const bool is_contig = BM_edge_is_contiguous(e); + if ((delimit & BMO_DELIM_NORMAL) && (is_contig == false)) { @@ -128,12 +127,12 @@ static float bm_edge_calc_dissolve_error( goto fail; } - angle = BM_edge_calc_face_angle(e); - if (is_contig == false) { - angle = (float)M_PI - angle; + float angle_cos_neg = dot_v3v3(e->l->f->no, e->l->radial_next->f->no); + if (is_contig) { + angle_cos_neg *= -1; } - return angle; + return angle_cos_neg; fail: return COST_INVALID; @@ -259,6 +258,7 @@ void BM_mesh_decimate_dissolve_ex( BMEdge **einput_arr, const int einput_len, const short oflag_out) { + const float angle_limit_cos_neg = -cosf(angle_limit); struct DelimitData delimit_data = {0}; const int eheap_table_len = do_dissolve_boundaries ? einput_len : max_ii(einput_len, vinput_len); void *_heap_table = MEM_mallocN(sizeof(HeapNode *) * eheap_table_len, __func__); @@ -308,7 +308,7 @@ void BM_mesh_decimate_dissolve_ex( } while ((BLI_heap_is_empty(eheap) == false) && - (BLI_heap_node_value((enode_top = BLI_heap_top(eheap))) < angle_limit)) + (BLI_heap_node_value((enode_top = BLI_heap_top(eheap))) < angle_limit_cos_neg)) { BMFace *f_new = NULL; BMEdge *e; |