X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fmodules%2Fmod_particle%2Frandom.cpp;h=783a34c5c34d4f343350102effd24ee650ab9abd;hb=ba4f6a9c499c64ebca84279cc44bf6449fd245c1;hp=f2950d7704240e4935027b8e49fefb8b47a7e633;hpb=70bcefce2ab011a11014f36fc129b473cc0bc61e;p=synfig.git diff --git a/synfig-core/trunk/src/modules/mod_particle/random.cpp b/synfig-core/trunk/src/modules/mod_particle/random.cpp index f2950d7..783a34c 100644 --- a/synfig-core/trunk/src/modules/mod_particle/random.cpp +++ b/synfig-core/trunk/src/modules/mod_particle/random.cpp @@ -2,7 +2,7 @@ /*! \file mod_particle/random.cpp ** \brief blehh ** -** $Id: random.cpp,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $ +** $Id$ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley @@ -57,6 +57,10 @@ Random::set_seed(int x) t_mask=rand()+rand()*RAND_MAX; } +// this picks one of the POOL_SIZE (256) preset values out of the pool +// and scales it to be in the range (-1, 1). is that what it was +// intended to do? the distribution is pretty terrible, too, with +// some elements being picked a hundred times more often than others float Random::operator()(const int salt,const int x,const int y,const int t)const { @@ -70,7 +74,7 @@ Random::operator()(const int salt,const int x,const int y,const int t)const } 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)); @@ -78,10 +82,11 @@ Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const 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 + // ( 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]; @@ -138,7 +143,7 @@ Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const 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) @@ -146,8 +151,8 @@ Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const #define FT(i,j,k) ((*this)(subseed,i+x,j+y,k+t)*(R((i)-a)*R(b-(j))*R((k)-c))) #define Z(i,j) ret+=F(i,j) #define ZT(i,j,k) ret+=FT(i,j,k) -#define X(i,j) // placeholder... To make box more symetric -#define XT(i,j,k) // placeholder... To make box more symetric +#define X(i,j) // placeholder... To make box more symmetric +#define XT(i,j,k) // placeholder... To make box more symmetric float a(xf-x), b(yf-y); @@ -161,7 +166,7 @@ Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const return ret; } - case 3: // Spline (animated) + case SMOOTH_SPLINE: // Spline (animated) { float a(xf-x), b(yf-y), c(tf-t); @@ -211,7 +216,7 @@ Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const #undef P #undef R - case 2: // Cosine + case SMOOTH_COSINE: if((float)t==tf) { int x((int)floor(xf)); @@ -258,7 +263,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); } - case 1: // Linear + case SMOOTH_LINEAR: if((float)t==tf) { int x((int)floor(xf)); @@ -298,7 +303,7 @@ Random::operator()(int smooth,int subseed,float xf,float yf,float tf)const (*this)(subseed,x2,y2,t2)*(a*b*c); } default: - case 0: + case SMOOTH_DEFAULT: return (*this)(subseed,x,y,t); } }