From: Nikita Kitaev Date: Mon, 12 Oct 2009 01:35:15 +0000 (-0700) Subject: Change linking parameters in BLine points X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=e247b19b3926ff72ed36b4b1172abf00099558e4;p=synfig.git Change linking parameters in BLine points Instead of the old split_tangent parameter, bline points now use link_radius and link_theta. Old functions are retained for compatibility. Note: since get_split_tangent_flag() returns a pointer, the split_tangent_ parameter must remain for now. --- diff --git a/synfig-core/src/synfig/blinepoint.cpp b/synfig-core/src/synfig/blinepoint.cpp index 4291bbf..83e004d 100644 --- a/synfig-core/src/synfig/blinepoint.cpp +++ b/synfig-core/src/synfig/blinepoint.cpp @@ -49,15 +49,22 @@ using namespace synfig; void synfig::BLinePoint::reverse() { - if(split_tangent_) - { - std::swap(tangent_[0],tangent_[1]); - tangent_[0]=-tangent_[0]; - tangent_[1]=-tangent_[1]; - } - else - { - tangent_[0]=-tangent_[0]; - tangent_[1]=-tangent_[1]; - } + std::swap(tangent_[0],tangent_[1]); + tangent_[0]=-tangent_[0]; + tangent_[1]=-tangent_[1]; +} + +void +synfig::BLinePoint::normalize(int i) +{ + //i is the number of the tangent to modify + //other tangent is (1-i) + split_tangent_=(!link_radius_ && !link_theta_); + if (link_radius_ && link_theta_) + tangent_[i]=tangent_[1-i]; + else if (link_radius_) + tangent_[i]=tangent_[i].norm()*tangent_[1-i].mag(); + else if (link_theta_) + tangent_[i]=tangent_[1-i].norm()*tangent_[i].mag(); + } diff --git a/synfig-core/src/synfig/blinepoint.h b/synfig-core/src/synfig/blinepoint.h index 3a75d4b..9a07ba8 100644 --- a/synfig-core/src/synfig/blinepoint.h +++ b/synfig-core/src/synfig/blinepoint.h @@ -47,6 +47,8 @@ private: float width_; float origin_; bool split_tangent_; + bool link_radius_; + bool link_theta_; public: @@ -54,7 +56,9 @@ public: vertex_(Point(0,0)), width_(0.01), origin_(0.0), - split_tangent_(false) + split_tangent_(false), + link_radius_(true), + link_theta_(true) { tangent_[0] = Point(0,0); tangent_[1] = Point(0,0); } const Point& get_vertex()const { return vertex_; } @@ -62,10 +66,10 @@ public: const Vector& get_tangent1()const { return tangent_[0]; } - const Vector& get_tangent2()const { return split_tangent_?tangent_[1]:tangent_[0]; } + const Vector& get_tangent2()const { return tangent_[1]; } void set_tangent(const Vector& x) { tangent_[0]=tangent_[1]=x; } - void set_tangent1(const Vector& x) { tangent_[0]=x; } - void set_tangent2(const Vector& x) { tangent_[1]=x; } + void set_tangent1(const Vector& x) { tangent_[0]=x; normalize(1);} + void set_tangent2(const Vector& x) { tangent_[1]=x; normalize(0);} const float& get_width()const { return width_; } @@ -79,7 +83,16 @@ public: const bool& get_split_tangent_flag()const { return split_tangent_; } - void set_split_tangent_flag(bool x=true) { split_tangent_=x; } + void set_split_tangent_flag(bool x=true) { link_radius_=link_theta_=!x; normalize();} + + const bool& get_link_radius_flag()const { return link_radius_; } + void set_link_radius_flag(bool x=true) { link_radius_=x; normalize();} + + const bool& get_link_theta_flag()const { return link_theta_; } + void set_link_theta_flag(bool x=true) { link_theta_=x; normalize();} + + //normalize tangents, i.e. make sure their values correspond to the linkage + void normalize(int i=0); void reverse();