X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Flyr_std%2Fcurvewarp.cpp;h=3a10076817421df2da2f15ce1db693f1e531150c;hb=9ad41b0d8487c57ababec0da386adb620e7f06a7;hp=6b544e68d5291cddae4c01167d8e5da6b0ecf26c;hpb=5ae346e017651b10ea2b2b6e1391db5d4bc4243f;p=synfig.git diff --git a/synfig-core/trunk/src/modules/lyr_std/curvewarp.cpp b/synfig-core/trunk/src/modules/lyr_std/curvewarp.cpp index 6b544e6..3a10076 100644 --- a/synfig-core/trunk/src/modules/lyr_std/curvewarp.cpp +++ b/synfig-core/trunk/src/modules/lyr_std/curvewarp.cpp @@ -102,10 +102,8 @@ find_closest_to_bline(bool fast, const std::vector& bline,co bool first = true, last = false; extreme = false; - // printf(" loop\n"); for(;next!=end;iter=next++) { - // printf(" top\n"); // Setup the curve etl::hermite curve(iter->get_vertex(), next->get_vertex(), iter->get_tangent2(), next->get_tangent1()); float thisdist(0); @@ -128,36 +126,24 @@ find_closest_to_bline(bool fast, const std::vector& bline,co dist=thisdist; best_pos = pos; best_curve = curve; - // printf("set best_curve\n"); best_len = total_len; last = true; - // printf(" *last\n"); } } total_len += curve.length(); first = false; } - // printf(" after\n"); t = best_pos; if (fast) { len = best_len + best_curve.find_distance(0,best_curve.find_closest(fast, p)); - // printf("fast set len = %f + %f = %f\n", best_len, best_curve.find_distance(0,best_curve.find_closest(fast, p)), len); if (last && t > .99) extreme = true; } else { len = best_len + best_curve.find_distance(0,best_pos); - // printf("slow set len = %f + %f = %f\n", best_len, best_curve.find_distance(0,best_pos), len); - // printf("find_distance from 0 to %f is %f\n", best_pos, best_curve.find_distance(0,best_pos)); - // if (last) printf("last\n"); - - if (last && t > .999) - { - extreme = true; - // printf("extreme end\n"); - } + if (last && t == 1) extreme = true; } return ret; } @@ -169,22 +155,21 @@ CurveWarp::sync() { curve_length_=calculate_distance(bline); perp_ = (end_point - start_point).perp().norm(); - // printf("curve_length_ = %f\n", curve_length_); } CurveWarp::CurveWarp(): origin(0,0), - width(1), - start_point(-3,-1), - end_point(3,1), + perp_width(1), + start_point(-2.5,-0.5), + end_point(2.5,-0.3), fast(true) { bline.push_back(BLinePoint()); bline.push_back(BLinePoint()); bline[0].set_vertex(Point(-2.5,0)); - bline[1].set_vertex(Point(2.5,0)); - bline[0].set_tangent(Point(1, 1)); - bline[1].set_tangent(Point(1, -1)); + bline[1].set_vertex(Point( 2.5,0)); + bline[0].set_tangent(Point(1, 0.1)); + bline[1].set_tangent(Point(1, -0.1)); bline[0].set_width(1.0f); bline[1].set_width(1.0f); @@ -321,7 +306,7 @@ CurveWarp::transform(const Point &point_, int quality, float supersample)const synfig::BLinePoint start(bline[0]); // Point a(start.get_vertex()); tangent = start.get_tangent1().norm(); - diff = tangent.perp()*thickness*width; + diff = tangent.perp()*thickness*perp_width; len = (point_-origin - p1)*tangent; } else @@ -330,7 +315,7 @@ CurveWarp::transform(const Point &point_, int quality, float supersample)const iter=bline.end(); iter--; tangent = iter->get_tangent2().norm(); - diff = tangent.perp()*thickness*width; + diff = tangent.perp()*thickness*perp_width; len = (point_-origin - p1)*tangent + curve_length_; } } @@ -338,10 +323,10 @@ CurveWarp::transform(const Point &point_, int quality, float supersample)const { diff=(p1-(point_-origin)); if(diff*tangent.perp()<0) diff=-diff; - diff=diff.norm()*thickness*width; + diff=diff.norm()*thickness*perp_width; } else - diff=tangent.perp()*thickness*width; + diff=tangent.perp()*thickness*perp_width; const Real mag(diff.inv_mag()); supersample=supersample*mag; @@ -350,9 +335,7 @@ CurveWarp::transform(const Point &point_, int quality, float supersample)const len /= curve_length_; - // printf("len %6.2f dist %6.2f\n", len, dist); - return ((start_point + (end_point - start_point) * len) + - perp_ * dist); + return (start_point + (end_point - start_point) * len) + perp_ * dist; } float @@ -374,7 +357,7 @@ CurveWarp::set_param(const String & param, const ValueBase &value) IMPORT(start_point); IMPORT(end_point); IMPORT(fast); - IMPORT(width); + IMPORT(perp_width); if(param=="bline" && value.get_type()==ValueBase::TYPE_LIST) { @@ -397,7 +380,7 @@ CurveWarp::get_param(const String & param)const EXPORT(end_point); EXPORT(bline); EXPORT(fast); - EXPORT(width); + EXPORT(perp_width); EXPORT_NAME(); EXPORT_VERSION(); @@ -413,11 +396,13 @@ CurveWarp::get_param_vocab()const ret.push_back(ParamDesc("origin") .set_local_name(_("Origin"))); - ret.push_back(ParamDesc("width") - .set_local_name(_("Width"))); + ret.push_back(ParamDesc("perp_width") + .set_local_name(_("Width")) + .set_origin("start_point")); ret.push_back(ParamDesc("start_point") - .set_local_name(_("Start Point"))); + .set_local_name(_("Start Point")) + .set_connect("end_point")); ret.push_back(ParamDesc("end_point") .set_local_name(_("End Point")));