diff options
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/curve.cpp | 10 | ||||
-rw-r--r-- | scene/resources/curve.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index 7f902fc982..f2fd919f20 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -479,6 +479,16 @@ real_t Curve::interpolate_baked(real_t offset) { } } +void Curve::ensure_default_setup(float p_min, float p_max) { + if (_points.size() == 0 && _min_value == 0 && _max_value == 1) { + + add_point(Vector2(0, 1)); + add_point(Vector2(1, 1)); + set_min_value(p_min); + set_max_value(p_max); + } +} + void Curve::_bind_methods() { ClassDB::bind_method(D_METHOD("add_point", "position", "left_tangent", "right_tangent", "left_mode", "right_mode"), &Curve::add_point, DEFVAL(0), DEFVAL(0), DEFVAL(TANGENT_FREE), DEFVAL(TANGENT_FREE)); diff --git a/scene/resources/curve.h b/scene/resources/curve.h index 9cb12a4345..058c4f1bc2 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -128,6 +128,8 @@ public: void set_bake_resolution(int p_resolution); real_t interpolate_baked(real_t offset); + void ensure_default_setup(float p_min, float p_max); + protected: static void _bind_methods(); |