projects
/
synfig.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Be stricter on the "c[0-9]" link names accepted.
[synfig.git]
/
synfig-core
/
trunk
/
src
/
modules
/
mod_noise
/
random.cpp
diff --git
a/synfig-core/trunk/src/modules/mod_noise/random.cpp
b/synfig-core/trunk/src/modules/mod_noise/random.cpp
index
d84f97e
..
7bc87e5
100644
(file)
--- a/
synfig-core/trunk/src/modules/mod_noise/random.cpp
+++ b/
synfig-core/trunk/src/modules/mod_noise/random.cpp
@@
-6,6
+6,7
@@
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
**
** \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
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
@@
-70,7
+71,7
@@
Random::operator()(const int salt,const int x,const int y,const int t)const
}
float
}
float
-Random::operator()(
int
smooth,int subseed,float xf,float yf,float tf)const
+Random::operator()(
SmoothType
smooth,int subseed,float xf,float yf,float tf)const
{
int x((int)floor(xf));
int y((int)floor(yf));
{
int x((int)floor(xf));
int y((int)floor(yf));
@@
-78,18
+79,17
@@
Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const
switch(smooth)
{
switch(smooth)
{
- case
4:
// cubic
+ case
SMOOTH_CUBIC:
// cubic
{
#define f(j,i,k) ((*this)(subseed,i,j,k))
//Using catmull rom interpolation because it doesn't blur at all
{
#define f(j,i,k) ((*this)(subseed,i,j,k))
//Using catmull rom interpolation because it doesn't blur at all
+ // ( http://www.gamedev.net/reference/articles/article1497.asp )
//bezier curve with intermediate ctrl pts: 0.5/3(p(i+1) - p(i-1)) and similar
float xfa [4], tfa[4];
//precalculate indices (all clamped) and offset
const int xa[] = {x-1,x,x+1,x+2};
//bezier curve with intermediate ctrl pts: 0.5/3(p(i+1) - p(i-1)) and similar
float xfa [4], tfa[4];
//precalculate indices (all clamped) and offset
const int xa[] = {x-1,x,x+1,x+2};
-
const int ya[] = {y-1,y,y+1,y+2};
const int ya[] = {y-1,y,y+1,y+2};
-
const int ta[] = {t-1,t,t+1,t+2};
const float dx(xf-x);
const int ta[] = {t-1,t,t+1,t+2};
const float dx(xf-x);
@@
-138,7
+138,7
@@
Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const
break;
break;
- case
5:
// Fast Spline (non-animated)
+ case
SMOOTH_FAST_SPLINE:
// Fast Spline (non-animated)
{
#define P(x) (((x)>0)?((x)*(x)*(x)):0.0f)
#define R(x) ( P(x+2) - 4.0f*P(x+1) + 6.0f*P(x) - 4.0f*P(x-1) )*(1.0f/6.0f)
{
#define P(x) (((x)>0)?((x)*(x)*(x)):0.0f)
#define R(x) ( P(x+2) - 4.0f*P(x+1) + 6.0f*P(x) - 4.0f*P(x-1) )*(1.0f/6.0f)
@@
-161,7
+161,7
@@
Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const
return ret;
}
return ret;
}
- case
3:
// Spline (animated)
+ case
SMOOTH_SPLINE:
// Spline (animated)
{
float a(xf-x), b(yf-y), c(tf-t);
{
float a(xf-x), b(yf-y), c(tf-t);
@@
-211,7
+211,7
@@
Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const
#undef P
#undef R
#undef P
#undef R
- case
2: // Cosine
+ case
SMOOTH_COSINE:
if((float)t==tf)
{
int x((int)floor(xf));
if((float)t==tf)
{
int x((int)floor(xf));
@@
-235,12
+235,12
@@
Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const
float b=yf-y;
float c=tf-t;
float b=yf-y;
float c=tf-t;
- a=(1.0f-cos(a*
3.1415927
))*0.5f;
- b=(1.0f-cos(b*
3.1415927
))*0.5f;
+ a=(1.0f-cos(a*
PI
))*0.5f;
+ b=(1.0f-cos(b*
PI
))*0.5f;
// We don't perform this on the time axis, otherwise we won't
// get smooth motion
// We don't perform this on the time axis, otherwise we won't
// get smooth motion
- //c=(1.0f-cos(c*
3.1415927
))*0.5f;
+ //c=(1.0f-cos(c*
PI
))*0.5f;
float d=1.0-a;
float e=1.0-b;
float d=1.0-a;
float e=1.0-b;
@@
-258,7
+258,7
@@
Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const
(*this)(subseed,x,y2,t2)*(d*b*c)+
(*this)(subseed,x2,y2,t2)*(a*b*c);
}
(*this)(subseed,x,y2,t2)*(d*b*c)+
(*this)(subseed,x2,y2,t2)*(a*b*c);
}
- case
1: // Linear
+ case
SMOOTH_LINEAR:
if((float)t==tf)
{
int x((int)floor(xf));
if((float)t==tf)
{
int x((int)floor(xf));
@@
-298,7
+298,7
@@
Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const
(*this)(subseed,x2,y2,t2)*(a*b*c);
}
default:
(*this)(subseed,x2,y2,t2)*(a*b*c);
}
default:
- case
0
:
+ case
SMOOTH_DEFAULT
:
return (*this)(subseed,x,y,t);
}
}
return (*this)(subseed,x,y,t);
}
}