diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2016-12-13 08:44:40 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-12-13 08:44:40 +0100 |
commit | afbe013ba12d68f20ef1dfe2d7a895105a440bd9 (patch) | |
tree | 52cdfef7fbed4910e013ff4e6f8c1d96463788f2 | |
parent | b59b37649ab1ef24740f76d5c8eb2ad97d9bd48c (diff) | |
parent | e741da869a11533ec46ed86bad1fd8c8c70a6178 (diff) |
Merge pull request #7283 from Hinsbart/clear_curve
Curve2D/3D: Add clear_points method.
-rw-r--r-- | scene/resources/curve.cpp | 19 | ||||
-rw-r--r-- | scene/resources/curve.h | 2 |
2 files changed, 21 insertions, 0 deletions
diff --git a/scene/resources/curve.cpp b/scene/resources/curve.cpp index 29460790ff..b771c0e392 100644 --- a/scene/resources/curve.cpp +++ b/scene/resources/curve.cpp @@ -464,6 +464,14 @@ void Curve2D::remove_point(int p_index) { emit_signal(CoreStringNames::get_singleton()->changed); } +void Curve2D::clear_points() { + if (!points.empty()) { + points.clear(); + baked_cache_dirty=true; + emit_signal(CoreStringNames::get_singleton()->changed); + } +} + Vector2 Curve2D::interpolate(int p_index, float p_offset) const { int pc = points.size(); @@ -790,6 +798,7 @@ void Curve2D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_point_out","idx","pos"),&Curve2D::set_point_out); ObjectTypeDB::bind_method(_MD("get_point_out","idx"),&Curve2D::get_point_out); ObjectTypeDB::bind_method(_MD("remove_point","idx"),&Curve2D::remove_point); + ObjectTypeDB::bind_method(_MD("clear_points"),&Curve2D::clear_points); ObjectTypeDB::bind_method(_MD("interpolate","idx","t"),&Curve2D::interpolate); ObjectTypeDB::bind_method(_MD("interpolatef","fofs"),&Curve2D::interpolatef); //ObjectTypeDB::bind_method(_MD("bake","subdivs"),&Curve2D::bake,DEFVAL(10)); @@ -930,6 +939,15 @@ void Curve3D::remove_point(int p_index) { emit_signal(CoreStringNames::get_singleton()->changed); } +void Curve3D::clear_points() { + + if (!points.empty()) { + points.clear(); + baked_cache_dirty=true; + emit_signal(CoreStringNames::get_singleton()->changed); + } +} + Vector3 Curve3D::interpolate(int p_index, float p_offset) const { int pc = points.size(); @@ -1322,6 +1340,7 @@ void Curve3D::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_point_out","idx","pos"),&Curve3D::set_point_out); ObjectTypeDB::bind_method(_MD("get_point_out","idx"),&Curve3D::get_point_out); ObjectTypeDB::bind_method(_MD("remove_point","idx"),&Curve3D::remove_point); + ObjectTypeDB::bind_method(_MD("clear_points"),&Curve3D::clear_points); ObjectTypeDB::bind_method(_MD("interpolate","idx","t"),&Curve3D::interpolate); ObjectTypeDB::bind_method(_MD("interpolatef","fofs"),&Curve3D::interpolatef); //ObjectTypeDB::bind_method(_MD("bake","subdivs"),&Curve3D::bake,DEFVAL(10)); diff --git a/scene/resources/curve.h b/scene/resources/curve.h index 262f22b7d1..21b564f2a2 100644 --- a/scene/resources/curve.h +++ b/scene/resources/curve.h @@ -133,6 +133,7 @@ public: void set_point_out(int p_index, const Vector2& p_out); Vector2 get_point_out(int p_index) const; void remove_point(int p_index); + void clear_points(); Vector2 interpolate(int p_index, float p_offset) const; Vector2 interpolatef(real_t p_findex) const; @@ -211,6 +212,7 @@ public: void set_point_out(int p_index, const Vector3& p_out); Vector3 get_point_out(int p_index) const; void remove_point(int p_index); + void clear_points(); Vector3 interpolate(int p_index, float p_offset) const; Vector3 interpolatef(real_t p_findex) const; |