/* === S Y N F I G ========================================================= */
/*! \file warp.cpp
-** \brief Template File
+** \brief Implementation of the "Warp" layer
**
** $Id$
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
+** Copyright (c) 2007 Chris Moore
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
SYNFIG_LAYER_INIT(Warp);
SYNFIG_LAYER_SET_NAME(Warp,"warp");
-SYNFIG_LAYER_SET_LOCAL_NAME(Warp,_("Warp"));
-SYNFIG_LAYER_SET_CATEGORY(Warp,_("Distortions"));
+SYNFIG_LAYER_SET_LOCAL_NAME(Warp,N_("Warp"));
+SYNFIG_LAYER_SET_CATEGORY(Warp,N_("Distortions"));
SYNFIG_LAYER_SET_VERSION(Warp,"0.1");
SYNFIG_LAYER_SET_CVS_ID(Warp,"$Id$");
src_br (2,-2),
dest_tl (-1.8,2.1),
dest_tr (1.8,2.1),
- dest_br (2.2,-2),
dest_bl (-2.2,-2),
+ dest_br (2.2,-2),
clip (true)
{
sync();
// Real trans_z[4];
Real z,minz(10000000000000.0f),maxz(0);
-
+ //! \todo checking the 4 corners for 0<=z<horizon*2 and using
+ //! only 4 corners which satisfy this condition isn't the
+ //! right thing to do. It's possible that none of the 4
+ //! corners fall within that range, and yet content of the
+ //! tile does.
p=transform_forward(min);
z=transform_backward_z(p);
if(z>0 && z<horizon*2)
Point min_point(bounding_rect.get_min());
Point max_point(bounding_rect.get_max());
+ // we're going to divide by the different of these pairs soon;
+ // if they're the same, we'll be dividing by zero, and we don't
+ // want to do that!
+ // \todo what should we do in this case?
+ if (min_point[0] == max_point[0] || min_point[1] == max_point[1])
+ {
+ surface->set_wh(renddesc.get_w(),renddesc.get_h());
+ surface->clear();
+ return true;
+ }
if(tl[0]>br[0])
{
v=(tmp[1]-tl[1])*src_ph;
if(u<0 || v<0 || u>=source.get_w() || v>=source.get_h() || isnan(u) || isnan(v))
- {
(*surface)[y][x]=context.get_color(tmp);
- }
else
(*surface)[y][x]=source.cubic_sample(u,v);
}
v=(tmp[1]-tl[1])*src_ph;
if(u<0 || v<0 || u>=source.get_w() || v>=source.get_h() || isnan(u) || isnan(v))
- {
- if(clip)
- (*surface)[y][x]=Color::alpha();
- else
- (*surface)[y][x]=context.get_color(tmp);
- }
+ (*surface)[y][x]=context.get_color(tmp);
else
(*surface)[y][x]=source.linear_sample(u,v);
}
v=(tmp[1]-tl[1])*src_ph;
if(u<0 || v<0 || u>=source.get_w() || v>=source.get_h() || isnan(u) || isnan(v))
- {
- if(clip)
- (*surface)[y][x]=Color::alpha();
- else
- (*surface)[y][x]=context.get_color(tmp);
- }
+ (*surface)[y][x]=context.get_color(tmp);
else
- //pen.set_value(source[v][u]);
- (*surface)[y][x]=source[floor_to_int(v)][floor_to_int(u)];
+ //pen.set_value(source[v][u]);
+ (*surface)[y][x]=source[floor_to_int(v)][floor_to_int(u)];
}
if(y&31==0 && cb)
{