From eeeb845d33e81afbc8ed127e6ab4ae7b18472a54 Mon Sep 17 00:00:00 2001 From: Folkert de Vries Date: Fri, 10 Jul 2015 21:57:23 +0900 Subject: 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 --- .../freestyle/intern/python/BPy_FrsNoise.cpp | 32 ++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'source/blender/freestyle/intern/python/BPy_FrsNoise.cpp') 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 #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} }; -- cgit v1.2.3