Module: synfig
Branch: genete_width_points
Commit: e7d54d68c8ae405e39abda9ac290e1cbb71a94b6
URL:
http://synfig.git.sourceforge.net/git/gitweb.cgi?p=synfig;a=commit;h=e7d54d68c8ae405e39abda9ac290e1cbb71a94b6
Author: Carlos Lopez <car...@pcnuevo.(none)>
Date: Tue Aug 4 11:40:21 2009 +0200
Modify the sync function to render better. Still failing though.
---
.../src/modules/mod_geometry/enhanced_outline.cpp | 75 ++++++++++++++++----
1 files changed, 61 insertions(+), 14 deletions(-)
diff --git a/synfig-core/trunk/src/modules/mod_geometry/enhanced_outline.cpp
b/synfig-core/trunk/src/modules/mod_geometry/enhanced_outline.cpp
index d86216f..e7c5cf8 100644
--- a/synfig-core/trunk/src/modules/mod_geometry/enhanced_outline.cpp
+++ b/synfig-core/trunk/src/modules/mod_geometry/enhanced_outline.cpp
@@ -180,6 +180,15 @@ EnhancedOutline::sync()
Vector first_tangent=bline.front().get_tangent2();
Vector last_tangent=iter->get_tangent1();
+ // ncurves is the number of curves to draw
+ // if the bline is looped then the ncurves is the number of blinepoints
-1
+ // otherwise it is the number of blinepoints.
+ int ncurves=bline.size();
+ if (!loop) ncurves--;
+ synfig::info("**************************************************");
+ synfig::info("ncurves = %i, loop=%i", ncurves, loop);
+
+
// if we are looped and drawing sharp cusps, we'll need a value for the
incoming tangent
if (loop && sharp_cusps && last_tangent.is_equal_to(Vector::zero()))
{
@@ -216,31 +225,30 @@ EnhancedOutline::sync()
iter_t,
next_t
);
- // ncurves is the number of curves to draw
- // if the bline is looped then the ncurves is the number of
blinepoints -1
- // otherwise it is the number of blinepoints.
- int ncurves=bline.size();
- if (!loop) ncurves--;
//calculate the integer values of the iterators in the vector
of blinepoints
- int iter_i=bline.begin()-iter;
- int next_i=bline.begin()-next;
+ int iter_i=iter-bline.begin();
+ int next_i=next-bline.begin();
+ //synfig::info(" Before: iter_i=%i next_i=%i", iter_i, next_i);
if (loop)
// it is looped and we need to correct the iter_i and next_i
{
next_i++;
- if (iter_i==ncurves)
+ if (iter_i==ncurves-1)
iter_i=0;
else
iter_i++;
-
}
+ //synfig::info(" After: iter_i=%i next_i=%i", iter_i, next_i);
+
//pos_iter_i and pos_next_i are the position [0,1] of the
blinepoints in the bline
// they are now comparable to the position parameter of the
wlinepoints.
Real pos_iter_i=iter_i/Real(ncurves);
Real pos_next_i=next_i/Real(ncurves);
+ synfig::info("pos_iter_i=%f pos_next_i=%f", pos_iter_i,
pos_next_i);
+
// this vector will strore the wlinepoints that are between
pos_iter_i
// and pos_next_i including two ones interpolated at the
extremes.
std::vector<WLinePoint> wlinepoints;
@@ -263,12 +271,12 @@ EnhancedOutline::sync()
if (pos_witer <0) pos_witer++;
// if pos_witer is between the two blinepoints (iter,
next)
// insert it in the list
- if((pos_witer < pos_next_i) && (pos_witer > pos_iter_i))
+ if((pos_witer <= pos_next_i) && (pos_witer >=
pos_iter_i))
wlinepoints.push_back(*witer);
//if pos_witer is lower than iter_i then keep it
if (pos_witer < pos_iter_i)
{
- if((pos_iter_i-pos_witer) < min_dist_iter)
+ if((pos_iter_i-pos_witer) <= min_dist_iter)
{
min_dist_iter = pos_iter_i-pos_witer;
prev_iter_i=witer_i;
@@ -277,7 +285,7 @@ EnhancedOutline::sync()
//if pos_witer is higher than next_i then keep it
else if (pos_witer > pos_next_i)
{
- if((pos_witer-pos_next_i) < min_dist_next)
+ if((pos_witer-pos_next_i) <= min_dist_next)
{
min_dist_next = pos_witer-pos_next_i;
next_next_i=witer_i;
@@ -424,6 +432,13 @@ EnhancedOutline::sync()
wlinepoints.insert(wlinepoints.begin(), 1, iter_wlp);
// Now the wlinepoints are ready for calculations! \o/
+ for (int i = 0; i < wlinepoints.size(); i++)
+ {
+ synfig::info("Position(%d)=%f", i,
wlinepoints[i].get_position());
+ synfig::info("Width (%d)=%f", i,
wlinepoints[i].get_width());
+ }
+
+
const float
iter_w((wlinepoints.front().get_width()*width)*0.5f+expand),
next_w((wlinepoints.back().get_width()*width)*0.5f+expand);
@@ -500,7 +515,7 @@ EnhancedOutline::sync()
wlp_i++;
continue;
}
- float w(width_i + (width_n-width_i)*(p_iter +
(dist/length-p_iter)/(p_next-p_iter)));
+ float w(width_i +
(width_n-width_i)*((dist/length-p_iter)/(p_next-p_iter)));
w=w*width*0.5f+expand;
//const float
w(((next_w-iter_w)*(dist/length)+iter_w)); /////////////////////////
@@ -578,7 +593,7 @@ EnhancedOutline::sync()
for(float n=0.0f;n<0.999999f;n+=1.0f/SAMPLES)
side_a.push_back(curve(n));
- }
+ } // end try
add_polygon(side_a);
@@ -724,3 +739,35 @@ EnhancedOutline::get_param_vocab()const
return ret;
}
+
+
+Real
+EnhancedOutline::interpolate(WLinePoint &p0, WLinePoint &p1, Real pos)
+{
+ Real pos0 = p0.get_position();
+ Real pos1 = p1.get_position();
+ if (pos0 > pos1)
+ // They are inversed so it is interpreted as a loop
+ {
+ if(pos < pos0)
+ {
+ pos0=p1.get_position()-1;
+ pos1=p0.get_position();
+ }
+ else if (pos > pos1)
+ {
+ pos0=p1.get_position();
+ pos1=p0.get_position()+1;
+ }
+ else
+ synfig::info("Found Width Interpolation swaped");
+ }
+ if (pos < pos0)
+ return p0.get_width();
+ else if (pos > pos1)
+ return p1.get_width();
+ else if (pos0==pos1)
+ return (p0.get_width()+p1.get_width())/2.0;
+ else
+ return (p0.get_width()+
(p1.get_width()-p0.get_width())*(pos-pos0)/(pos1-pos0));
+}
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Synfig-devl mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synfig-devl