Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFolkert de Vries <flokkievids@gmail.com>2015-07-10 15:57:23 +0300
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2015-07-10 17:15:56 +0300
commiteeeb845d33e81afbc8ed127e6ab4ae7b18472a54 (patch)
tree78f8f3ecf9c4dd3bf4383ccc73520bcd2c6b2c7b /source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
parent7837f0e8332f3726e0322b0c48b0da4d7c2d5813 (diff)
Freestyle: new stroke modifiers
This patch introduces a couple new stroke modifiers. The ones currently implemented are based on prototypes by @kjym3 and myself. The new modifiers: - Tangent - Thickness noise - Crease Angle - Simplification - Curvature 3D The documentation for these new modifier types can be found [[ http://www.blender.org/manual/render/freestyle/parameter_editor/index.html | in the manual ]]: {F134441} (left: AnisotropicThicknessShader, right: NoiseThicknessShader) {F140499} (left: Curvature 3D, right: Simplification) Author: Folkert de Vries (flokkievids) Reviewers: kjym3 Subscribers: #user_interface, plasmasolutions, kjym3 Projects: #bf_blender Differential Revision: https://developer.blender.org/D963
Diffstat (limited to 'source/blender/freestyle/intern/python/BPy_FrsNoise.cpp')
-rw-r--r--source/blender/freestyle/intern/python/BPy_FrsNoise.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
index 39e4aed7cc0..21a5ceaa3b2 100644
--- a/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
+++ b/source/blender/freestyle/intern/python/BPy_FrsNoise.cpp
@@ -25,6 +25,8 @@
#include "BPy_FrsNoise.h"
#include "BPy_Convert.h"
+#include "../system/RandGen.h"
+
#include <sstream>
#ifdef __cplusplus
@@ -69,12 +71,14 @@ static int FrsNoise_init(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|l", (char **)kwlist, &seed))
return -1;
self->n = new Noise(seed);
+ self->pn = new PseudoNoise();
return 0;
}
static void FrsNoise_dealloc(BPy_FrsNoise *self)
{
delete self->n;
+ delete self->pn;
Py_TYPE(self)->tp_free((PyObject *)self);
}
@@ -99,6 +103,32 @@ PyDoc_STRVAR(FrsNoise_turbulence1_doc,
" :return: A noise value.\n"
" :rtype: float");
+static PyObject *FrsNoise_drand(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
+{
+ static const char *kwlist[] = {"seed", NULL};
+ long seed = 0;
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "|I", (char **)kwlist, &seed)) {
+ PyErr_SetString(PyExc_TypeError, "optional argument 1 must be of type int");
+ return NULL;
+ }
+ if (seed){
+ RandGen::srand48(seed);
+ }
+ return PyFloat_FromDouble(RandGen::drand48());
+}
+
+static PyObject *FrsNoise_turbulence_smooth(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
+{
+ static const char *kwlist[] = {"v", "oct", NULL};
+
+ double x; // note: this has to be a double (not float)
+ unsigned nbOctaves = 8;
+
+ if (!PyArg_ParseTupleAndKeywords(args, kwds, "d|I", (char **)kwlist, &x, &nbOctaves))
+ return NULL;
+ return PyFloat_FromDouble(self->pn->turbulenceSmooth(x, nbOctaves));
+}
+
static PyObject *FrsNoise_turbulence1(BPy_FrsNoise *self, PyObject *args, PyObject *kwds)
{
static const char *kwlist[] = {"v", "freq", "amp", "oct", NULL};
@@ -257,6 +287,8 @@ static PyMethodDef BPy_FrsNoise_methods[] = {
{"smoothNoise1", (PyCFunction)FrsNoise_smoothNoise1, METH_VARARGS | METH_KEYWORDS, FrsNoise_smoothNoise1_doc},
{"smoothNoise2", (PyCFunction)FrsNoise_smoothNoise2, METH_VARARGS | METH_KEYWORDS, FrsNoise_smoothNoise2_doc},
{"smoothNoise3", (PyCFunction)FrsNoise_smoothNoise3, METH_VARARGS | METH_KEYWORDS, FrsNoise_smoothNoise3_doc},
+ {"rand", (PyCFunction)FrsNoise_drand, METH_VARARGS | METH_KEYWORDS, NULL},
+ {"turbulence_smooth", (PyCFunction)FrsNoise_turbulence_smooth, METH_VARARGS | METH_KEYWORDS, NULL},
{NULL, NULL, 0, NULL}
};