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 'extern/curve_fit_nd/intern/curve_fit_cubic.c')
-rw-r--r--extern/curve_fit_nd/intern/curve_fit_cubic.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/extern/curve_fit_nd/intern/curve_fit_cubic.c b/extern/curve_fit_nd/intern/curve_fit_cubic.c
index 24b216d32ff..9b4f1869c02 100644
--- a/extern/curve_fit_nd/intern/curve_fit_cubic.c
+++ b/extern/curve_fit_nd/intern/curve_fit_cubic.c
@@ -614,7 +614,7 @@ static void cubic_from_points_offset_fallback(
double dists[2] = {0, 0};
- const double *pt = points_offset;
+ const double *pt = &points_offset[dims];
for (uint i = 1; i < points_offset_len - 1; i++, pt += dims) {
for (uint k = 0; k < 2; k++) {
sub_vn_vnvn(tmp, p0, pt, dims);
@@ -623,13 +623,13 @@ static void cubic_from_points_offset_fallback(
}
}
- float alpha_l = (dists[0] / 0.75) / dot_vnvn(tan_l, a[0], dims);
- float alpha_r = (dists[1] / 0.75) / -dot_vnvn(tan_r, a[1], dims);
+ double alpha_l = (dists[0] / 0.75) / dot_vnvn(tan_l, a[0], dims);
+ double alpha_r = (dists[1] / 0.75) / -dot_vnvn(tan_r, a[1], dims);
- if (!(alpha_l > 0.0f)) {
+ if (!(alpha_l > 0.0)) {
alpha_l = dir_dist / 3.0;
}
- if (!(alpha_r > 0.0f)) {
+ if (!(alpha_r > 0.0)) {
alpha_r = dir_dist / 3.0;
}
@@ -742,7 +742,11 @@ static void cubic_from_points(
!(alpha_r >= 0.0))
{
#ifdef USE_CIRCULAR_FALLBACK
- alpha_l = alpha_r = points_calc_cubic_scale(p0, p3, tan_l, tan_r, points_offset_coords_length, dims);
+ double alpha_test = points_calc_cubic_scale(p0, p3, tan_l, tan_r, points_offset_coords_length, dims);
+ if (!isfinite(alpha_test)) {
+ alpha_test = len_vnvn(p0, p3, dims) / 3.0;
+ }
+ alpha_l = alpha_r = alpha_test;
#else
alpha_l = alpha_r = len_vnvn(p0, p3, dims) / 3.0;
#endif
@@ -804,7 +808,11 @@ static void cubic_from_points(
p2_dist_sq > dist_sq_max)
{
#ifdef USE_CIRCULAR_FALLBACK
- alpha_l = alpha_r = points_calc_cubic_scale(p0, p3, tan_l, tan_r, points_offset_coords_length, dims);
+ double alpha_test = points_calc_cubic_scale(p0, p3, tan_l, tan_r, points_offset_coords_length, dims);
+ if (!isfinite(alpha_test)) {
+ alpha_test = len_vnvn(p0, p3, dims) / 3.0;
+ }
+ alpha_l = alpha_r = alpha_test;
#else
alpha_l = alpha_r = len_vnvn(p0, p3, dims) / 3.0;
#endif
@@ -888,7 +896,7 @@ static double points_calc_coord_length(
}
assert(!is_almost_zero(r_u[points_offset_len - 1]));
const double w = r_u[points_offset_len - 1];
- for (uint i = 0; i < points_offset_len; i++) {
+ for (uint i = 1; i < points_offset_len; i++) {
r_u[i] /= w;
}
return w;