diff options
author | Sybren A. Stüvel <sybren@stuvel.eu> | 2017-10-29 17:14:04 +0300 |
---|---|---|
committer | Sybren A. Stüvel <sybren@stuvel.eu> | 2017-10-29 17:14:04 +0300 |
commit | 7530c54c3cf38016d9038e6879c8ee2b1bd14c9e (patch) | |
tree | a43bf60f8267855f7950017b53c04fd88a5207ac /source/blender/blenlib/intern/polyfill2d_beautify.c | |
parent | 1186dec916737b69afecd15030736f6d3361694e (diff) | |
parent | d9000495e1273052c895c754fd2aa56c9dbe6175 (diff) |
Merge branch 'master' into blender2.8
Diffstat (limited to 'source/blender/blenlib/intern/polyfill2d_beautify.c')
-rw-r--r-- | source/blender/blenlib/intern/polyfill2d_beautify.c | 27 |
1 files changed, 11 insertions, 16 deletions
diff --git a/source/blender/blenlib/intern/polyfill2d_beautify.c b/source/blender/blenlib/intern/polyfill2d_beautify.c index f2a1c194eb1..c0c95da5c63 100644 --- a/source/blender/blenlib/intern/polyfill2d_beautify.c +++ b/source/blender/blenlib/intern/polyfill2d_beautify.c @@ -219,23 +219,18 @@ 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) { + BLI_heap_insert_or_update(eheap, &eheap_table[i], 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) { - eheap_table[i] = BLI_heap_insert(eheap, cost, e); - } - else { + else { + if (eheap_table[i]) { + BLI_heap_remove(eheap, eheap_table[i]); eheap_table[i] = NULL; } } |