diff options
Diffstat (limited to 'extern/curve_fit_nd/intern/curve_fit_cubic_refit.c')
-rw-r--r-- | extern/curve_fit_nd/intern/curve_fit_cubic_refit.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/extern/curve_fit_nd/intern/curve_fit_cubic_refit.c b/extern/curve_fit_nd/intern/curve_fit_cubic_refit.c index b5340efdcb2..83b2383f58c 100644 --- a/extern/curve_fit_nd/intern/curve_fit_cubic_refit.c +++ b/extern/curve_fit_nd/intern/curve_fit_cubic_refit.c @@ -324,7 +324,7 @@ static double knot_remove_error_value( /* Avoid having to re-calculate again */ double r_handle_factors[2], uint *r_error_index) { - double error_sq = FLT_MAX; + double error_sq = DBL_MAX; #ifdef USE_VLA double handle_factor_l[dims]; @@ -340,7 +340,7 @@ static double knot_remove_error_value( handle_factor_l, handle_factor_r, &error_sq, r_error_index); - assert(error_sq != FLT_MAX); + assert(error_sq != DBL_MAX); isub_vnvn(handle_factor_l, points_offset, dims); r_handle_factors[0] = dot_vnvn(tan_l, handle_factor_l, dims); @@ -465,7 +465,6 @@ static void knot_remove_error_recalculate( struct KnotRemoveState *r; if (k->heap_node) { r = HEAP_node_ptr(k->heap_node); - HEAP_remove(p->heap, k->heap_node); } else { #ifdef USE_TPOOL @@ -473,14 +472,13 @@ static void knot_remove_error_recalculate( #else r = malloc(sizeof(*r)); #endif - r->index = k->index; } r->handles[0] = handles[0]; r->handles[1] = handles[1]; - k->heap_node = HEAP_insert(p->heap, cost_sq, r); + HEAP_insert_or_update(p->heap, &k->heap_node, cost_sq, r); } else { if (k->heap_node) { @@ -624,7 +622,6 @@ static void knot_refit_error_recalculate( struct KnotRefitState *r; if (k->heap_node) { r = HEAP_node_ptr(k->heap_node); - HEAP_remove(p->heap, k->heap_node); } else { #ifdef USE_TPOOL @@ -645,7 +642,7 @@ static void knot_refit_error_recalculate( r->error_sq[0] = r->error_sq[1] = cost_sq; /* Always perform removal before refitting, (make a negative number) */ - k->heap_node = HEAP_insert(p->heap, cost_sq - error_sq_max, r); + HEAP_insert_or_update(p->heap, &k->heap_node, cost_sq - error_sq_max, r); return; } @@ -689,7 +686,6 @@ static void knot_refit_error_recalculate( struct KnotRefitState *r; if (k->heap_node) { r = HEAP_node_ptr(k->heap_node); - HEAP_remove(p->heap, k->heap_node); } else { #ifdef USE_TPOOL @@ -716,7 +712,7 @@ static void knot_refit_error_recalculate( assert(cost_sq_dst_max < cost_sq_src_max); /* Weight for the greatest improvement */ - k->heap_node = HEAP_insert(p->heap, cost_sq_src_max - cost_sq_dst_max, r); + HEAP_insert_or_update(p->heap, &k->heap_node, cost_sq_src_max - cost_sq_dst_max, r); } } else { @@ -895,7 +891,6 @@ static void knot_corner_error_recalculate( struct KnotCornerState *c; if (k_split->heap_node) { c = HEAP_node_ptr(k_split->heap_node); - HEAP_remove(p->heap, k_split->heap_node); } else { #ifdef USE_TPOOL @@ -920,7 +915,7 @@ static void knot_corner_error_recalculate( c->error_sq[1] = cost_sq_dst[1]; const double cost_max_sq = MAX2(cost_sq_dst[0], cost_sq_dst[1]); - k_split->heap_node = HEAP_insert(p->heap, cost_max_sq, c); + HEAP_insert_or_update(p->heap, &k_split->heap_node, cost_max_sq, c); } else { if (k_split->heap_node) { |