1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Rename Curve/Curve2D/Curve3D/Gradient interpolate() to sample()

"sampling" is a more accurate term than "interpolating" for what's
happening when using that function.
This commit is contained in:
Hugo Locurcio
2022-07-24 18:47:57 +02:00
parent de5f13e935
commit ae18928748
21 changed files with 199 additions and 198 deletions

View File

@@ -579,7 +579,7 @@ template <typename T>
static void plot_curve_accurate(const Curve &curve, float step, T plot_func) {
if (curve.get_point_count() <= 1) {
// Not enough points to make a curve, so it's just a straight line
float y = curve.interpolate(0);
float y = curve.sample(0);
plot_func(Vector2(0, y), Vector2(1.f, y), true);
} else {
@@ -603,7 +603,7 @@ static void plot_curve_accurate(const Curve &curve, float step, T plot_func) {
for (float x = step; x < len; x += step) {
pos.x = a.x + x;
pos.y = curve.interpolate_local_nocheck(i - 1, x);
pos.y = curve.sample_local_nocheck(i - 1, x);
plot_func(prev_pos, pos, true);
prev_pos = pos;
}
@@ -817,7 +817,7 @@ Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, cons
int prev_y = 0;
for (int x = 0; x < im.get_width(); ++x) {
float t = static_cast<float>(x) / im.get_width();
float v = (curve.interpolate_baked(t) - curve.get_min_value()) / range_y;
float v = (curve.sample_baked(t) - curve.get_min_value()) / range_y;
int y = CLAMP(im.get_height() - v * im.get_height(), 0, im.get_height());
// Plot point