Author: Carlos Lopez <[email protected]>
Date: Wed Mar 16 22:07:07 2011 +0100
Effectively use the smoothness when rendering.
Fix error done in the previous commit where interpolation code was wrong.
---
.../src/modules/mod_geometry/advanced_outline.cpp | 10 +++++-----
synfig-core/src/synfig/valuenode_wplist.cpp | 5 ++---
synfig-core/src/synfig/valuenode_wplist.h | 2 +-
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/synfig-core/src/modules/mod_geometry/advanced_outline.cpp
b/synfig-core/src/modules/mod_geometry/advanced_outline.cpp
index 50d7b05..02ee173 100644
--- a/synfig-core/src/modules/mod_geometry/advanced_outline.cpp
+++ b/synfig-core/src/modules/mod_geometry/advanced_outline.cpp
@@ -200,11 +200,11 @@ Advanced_Outline::sync()
// if it is not exactly at 0.0
if(wpfront.get_norm_position()!=0.0)
// Add a fake widthpoint at position 0.0
-
wplist.push_back(WidthPoint(0.0, widthpoint_interpolate(wpback, wpfront, 0.0) ,
WidthPoint::TYPE_INTERPOLATE, WidthPoint::TYPE_INTERPOLATE));
+
wplist.push_back(WidthPoint(0.0, widthpoint_interpolate(wpback, wpfront, 0.0,
smoothness_) , WidthPoint::TYPE_INTERPOLATE, WidthPoint::TYPE_INTERPOLATE));
// If it is not exactly at 1.0
if(wpback.get_norm_position()!=1.0)
// Add a fake widthpoint at position 1.0
-
wplist.push_back(WidthPoint(1.0, widthpoint_interpolate(wpback, wpfront, 1.0) ,
WidthPoint::TYPE_INTERPOLATE, WidthPoint::TYPE_INTERPOLATE));
+
wplist.push_back(WidthPoint(1.0, widthpoint_interpolate(wpback, wpfront, 1.0,
smoothness_) , WidthPoint::TYPE_INTERPOLATE, WidthPoint::TYPE_INTERPOLATE));
}
}
else
@@ -283,7 +283,7 @@ Advanced_Outline::sync()
// Do cusp at ipos
if(ipos==biter_pos /*&& ipos!=0.0*/ &&
sharp_cusps_ && split_flag)
{
- add_cusp(side_a, side_b,
biter->get_vertex(), iter_t, last_tangent,
width_*0.5*widthpoint_interpolate(*witer, *wnext, ipos));
+ add_cusp(side_a, side_b,
biter->get_vertex(), iter_t, last_tangent,
width_*0.5*widthpoint_interpolate(*witer, *wnext, ipos, smoothness_));
}
if(bnext+1==bend && ipos == bnext_pos)
break;
@@ -313,7 +313,7 @@ Advanced_Outline::sync()
ipos=bnext_pos;
const Vector
d(deriv(bline_to_bezier(ipos, biter_pos, bezier_size)).perp().norm());
const Vector
p(curve(bline_to_bezier(ipos, biter_pos, bezier_size)));
- const Real
w(width_*0.5*synfig::widthpoint_interpolate(*witer, *wnext, ipos));
+ const Real
w(width_*0.5*widthpoint_interpolate(*witer, *wnext, ipos, smoothness_));
side_a.push_back(p+d*w);
side_b.push_back(p-d*w);
// Update iterators
@@ -330,7 +330,7 @@ Advanced_Outline::sync()
//synfig::info("ipos=%f", ipos);
const Vector d(deriv(bline_to_bezier(ipos,
biter_pos, bezier_size)).perp().norm());
const Vector p(curve(bline_to_bezier(ipos,
biter_pos, bezier_size)));
- const Real
w(width_*0.5*synfig::widthpoint_interpolate(*witer, *wnext, ipos));
+ const Real
w(width_*0.5*widthpoint_interpolate(*witer, *wnext, ipos, smoothness_));
side_a.push_back(p+d*w);
side_b.push_back(p-d*w);
ipos = ipos + step;
diff --git a/synfig-core/src/synfig/valuenode_wplist.cpp
b/synfig-core/src/synfig/valuenode_wplist.cpp
index 22fdd6d..80e6563 100644
--- a/synfig-core/src/synfig/valuenode_wplist.cpp
+++ b/synfig-core/src/synfig/valuenode_wplist.cpp
@@ -96,7 +96,7 @@ synfig::convert_bline_to_wplist(const ValueBase& bline)
}
Real
-synfig::widthpoint_interpolate(const WidthPoint& prev, const WidthPoint& next,
Real p, Real smoothness)
+synfig::widthpoint_interpolate(const WidthPoint& prev, const WidthPoint& next,
const Real p, const Real smoothness)
{
WidthPoint::SideType side_int(WidthPoint::TYPE_INTERPOLATE);
int nsb, nsa, psb, psa;
@@ -136,8 +136,7 @@ synfig::widthpoint_interpolate(const WidthPoint& prev,
const WidthPoint& next, R
Vector(0.0,0.0),
Vector(0.0,0.0)
);
- rw=curve(q)[0];
-
//rw=(pw+(nw-pw)*q)*(1.0-smoothness)+curve(q)[1]*smoothness;
+
rw=(pw+(nw-pw)*q)*(1.0-smoothness)+curve(q)[1]*smoothness;
}
else if(p < pp)
{
diff --git a/synfig-core/src/synfig/valuenode_wplist.h
b/synfig-core/src/synfig/valuenode_wplist.h
index 56a0976..fadaf66 100644
--- a/synfig-core/src/synfig/valuenode_wplist.h
+++ b/synfig-core/src/synfig/valuenode_wplist.h
@@ -51,7 +51,7 @@ synfig::ValueBase convert_bline_to_wplist(const ValueBase&
bline);
//! \param position the position to interpolate between prev and next
//! \param smoothness a [0,1] value that defines how is calculated the
interpolation
//! \return the interpolated width based on surrounding width points and its
values
-synfig::Real widthpoint_interpolate(const WidthPoint& prev, const WidthPoint&
next, Real position, Real smoothness=0.0);
+synfig::Real widthpoint_interpolate(const WidthPoint& prev, const WidthPoint&
next, const Real position, const Real smoothness=0.0);
/*! \class ValueNode_WPList
** \brief This class implements a list of Width Points
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl