diff options
author | Campbell Barton <ideasman42@gmail.com> | 2017-10-28 21:23:27 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2017-10-28 21:28:00 +0300 |
commit | 336885bebaa8c7b60041b139f02a29da475cf3ea (patch) | |
tree | 7adb7022a3beee361e17fc94ba2369394baf5661 /source/blender/blenlib | |
parent | 4af1af70ad41015d0126837e856d87b930f61655 (diff) |
Use BLI_heap_reinsert for decimate and beautify
Improves performance for high poly meshes,
~70% faster for decimate, only ~10% for beautify.
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/polyfill2d_beautify.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/source/blender/blenlib/intern/polyfill2d_beautify.c b/source/blender/blenlib/intern/polyfill2d_beautify.c index f2a1c194eb1..56309a4b115 100644 --- a/source/blender/blenlib/intern/polyfill2d_beautify.c +++ b/source/blender/blenlib/intern/polyfill2d_beautify.c @@ -219,23 +219,23 @@ static void polyedge_beauty_cost_update_single( Heap *eheap, HeapNode **eheap_table) { const uint i = e->base_index; - - if (eheap_table[i]) { - BLI_heap_remove(eheap, eheap_table[i]); - eheap_table[i] = NULL; - } - - { - /* recalculate edge */ - const float cost = polyedge_rotate_beauty_calc(coords, edges, e); - /* We can get cases where both choices generate very small negative costs, which leads to infinite loop. - * Anyway, costs above that are not worth recomputing, maybe we could even optimize it to a smaller limit? - * Actually, FLT_EPSILON is too small in some cases, 1e-6f seems to work OK hopefully? - * See T43578, T49478. */ - if (cost < -1e-6f) { - eheap_table[i] = BLI_heap_insert(eheap, cost, e); + /* recalculate edge */ + const float cost = polyedge_rotate_beauty_calc(coords, edges, e); + /* We can get cases where both choices generate very small negative costs, which leads to infinite loop. + * Anyway, costs above that are not worth recomputing, maybe we could even optimize it to a smaller limit? + * Actually, FLT_EPSILON is too small in some cases, 1e-6f seems to work OK hopefully? + * See T43578, T49478. */ + if (cost < -1e-6f) { + if (eheap_table[i]) { + BLI_heap_reinsert(eheap, eheap_table[i], cost); } else { + eheap_table[i] = BLI_heap_insert(eheap, cost, e); + } + } + else { + if (eheap_table[i]) { + BLI_heap_remove(eheap, eheap_table[i]); eheap_table[i] = NULL; } } |