Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/blenlib/intern/polyfill2d_beautify.c')
-rw-r--r--source/blender/blenlib/intern/polyfill2d_beautify.c27
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;
}
}