Fix #112087: Float curve flickers with aligned points at x axis #112205

Merged
Hans Goudey merged 3 commits from guishe/blender:fix-float-curve-sort into main 2023-09-11 00:17:24 +02:00
1 changed files with 4 additions and 15 deletions

View File

@ -6,6 +6,7 @@
* \ingroup bke
*/
#include <algorithm>
#include <cfloat>
#include <cmath>
#include <cstdlib>
@ -873,20 +874,6 @@ void BKE_curvemapping_premultiply(CurveMapping *cumap, bool restore)
}
}
static int sort_curvepoints(const void *a1, const void *a2)
{
const CurveMapPoint *x1 = static_cast<const CurveMapPoint *>(a1),
*x2 = static_cast<const CurveMapPoint *>(a2);
if (x1->x > x2->x) {
return 1;
}
if (x1->x < x2->x) {
return -1;
}
return 0;
}
/* ************************ more CurveMapping calls *************** */
void BKE_curvemapping_changed(CurveMapping *cumap, const bool rem_doubles)
@ -936,7 +923,9 @@ void BKE_curvemapping_changed(CurveMapping *cumap, const bool rem_doubles)
}
}
qsort(cmp, cuma->totpoint, sizeof(CurveMapPoint), sort_curvepoints);
std::stable_sort(cuma->curve,
cuma->curve + cuma->totpoint,
[](const CurveMapPoint &a, const CurveMapPoint &b) { return a.x < b.x; });
/* remove doubles, threshold set on 1% of default range */
if (rem_doubles && cuma->totpoint > 2) {