Revision: 39539
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39539
Author: kjym3
Date: 2011-08-18 23:07:17 +0000 (Thu, 18 Aug 2011)
Log Message:
-----------
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.
Modified Paths:
--------------
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/shaders.py
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/Noise.cpp
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/Noise.h
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
Modified:
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/shaders.py
===================================================================
---
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/shaders.py
2011-08-18 22:56:41 UTC (rev 39538)
+++
branches/soc-2008-mxcurioni/release/scripts/freestyle/style_modules/shaders.py
2011-08-18 23:07:17 UTC (rev 39539)
@@ -913,9 +913,9 @@
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 @@
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
Modified:
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/Noise.cpp
===================================================================
---
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/Noise.cpp
2011-08-18 22:56:41 UTC (rev 39538)
+++
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/Noise.cpp
2011-08-18 23:07:17 UTC (rev 39539)
@@ -225,11 +225,11 @@
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;
Modified:
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/Noise.h
===================================================================
---
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/Noise.h
2011-08-18 22:56:41 UTC (rev 39538)
+++
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/geometry/Noise.h
2011-08-18 23:07:17 UTC (rev 39539)
@@ -45,7 +45,7 @@
public:
/*! Builds a Noise object */
- Noise();
+ Noise(long seed = -1);
/*! Destructor */
~Noise() {}
Modified:
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
===================================================================
---
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
2011-08-18 22:56:41 UTC (rev 39538)
+++
branches/soc-2008-mxcurioni/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
2011-08-18 23:07:17 UTC (rev 39539)
@@ -28,15 +28,21 @@
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;
}
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs