forked from bartvdbraak/blender
Added an optional argument 'seed' to the Freestyle.Noise class constructor.
The value is used as a seed for random number generation if it is equal to or greater than zero; otherwise, time is used as a seed.
This commit is contained in:
parent
0ddf5b1da5
commit
4ec69d5a2b
@ -913,9 +913,9 @@ class pySinusDisplacementShader(StrokeShader):
|
||||
it.increment()
|
||||
|
||||
class pyPerlinNoise1DShader(StrokeShader):
|
||||
def __init__(self, freq = 10, amp = 10, oct = 4):
|
||||
def __init__(self, freq = 10, amp = 10, oct = 4, seed = -1):
|
||||
StrokeShader.__init__(self)
|
||||
self.__noise = Noise()
|
||||
self.__noise = Noise(seed)
|
||||
self.__freq = freq
|
||||
self.__amp = amp
|
||||
self.__oct = oct
|
||||
@ -932,9 +932,9 @@ class pyPerlinNoise1DShader(StrokeShader):
|
||||
it.increment()
|
||||
|
||||
class pyPerlinNoise2DShader(StrokeShader):
|
||||
def __init__(self, freq = 10, amp = 10, oct = 4):
|
||||
def __init__(self, freq = 10, amp = 10, oct = 4, seed = -1):
|
||||
StrokeShader.__init__(self)
|
||||
self.__noise = Noise()
|
||||
self.__noise = Noise(seed)
|
||||
self.__freq = freq
|
||||
self.__amp = amp
|
||||
self.__oct = oct
|
||||
|
@ -225,11 +225,11 @@ float Noise::smoothNoise3(Vec3f& vec)
|
||||
return lerp(sz, c, d);
|
||||
}
|
||||
|
||||
Noise::Noise()
|
||||
Noise::Noise(long seed)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
seednrand(time(NULL));
|
||||
seednrand((seed < 0) ? time(NULL) : seed);
|
||||
for (i = 0 ; i < _Noise_B_ ; i++)
|
||||
{
|
||||
p[i] = i;
|
||||
|
@ -45,7 +45,7 @@ class LIB_GEOMETRY_EXPORT Noise
|
||||
public:
|
||||
|
||||
/*! Builds a Noise object */
|
||||
Noise();
|
||||
Noise(long seed = -1);
|
||||
/*! Destructor */
|
||||
~Noise() {}
|
||||
|
||||
|
@ -28,15 +28,21 @@ int FrsNoise_Init( PyObject *module )
|
||||
static char FrsNoise___doc__[] =
|
||||
"Class to provide Perlin noise functionalities.\n"
|
||||
"\n"
|
||||
".. method:: __init__()\n"
|
||||
".. method:: __init__(seed = -1)\n"
|
||||
"\n"
|
||||
" Builds a Noise object.\n";
|
||||
" Builds a Noise object. Seed is an optional argument. The seed value is used\n"
|
||||
" as a seed for random number generation if it is equal to or greater than zero;\n"
|
||||
" otherwise, time is used as a seed.\n"
|
||||
"\n"
|
||||
" :arg seed: Seed for random number generation.\n"
|
||||
" :type seed: int\n";
|
||||
|
||||
static int FrsNoise___init__(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
|
||||
{
|
||||
if(!( PyArg_ParseTuple(args, "") ))
|
||||
long seed = -1;
|
||||
if(!( PyArg_ParseTuple(args, "|l", &seed) ))
|
||||
return -1;
|
||||
self->n = new Noise();
|
||||
self->n = new Noise(seed);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user