From 34c133a488bdd78a1bd5027e1dcc8c60da86d25a Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sat, 19 Jul 2014 18:52:32 +0900 Subject: Freestyle: an improved workflow of line style shading nodes. Removed the previous changes for passing a line style through the Controller, and revised the BlenderTextureShader to assign the shader node tree of a line style (if specified) to strokes. This way the assignment of shading nodes can be done through both the Freestyle GUI and Python scripting. --- .../StrokeShader/BPy_BlenderTextureShader.cpp | 36 +++++++++++++--------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'source/blender/freestyle/intern/python/StrokeShader') diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp index c8b9d7098e4..379fb7e1b12 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_BlenderTextureShader.cpp @@ -41,38 +41,46 @@ static char BlenderTextureShader___doc__[] = "\n" "[Texture shader]\n" "\n" -".. method:: __init__(LineStyleTextureSlot)\n" +".. method:: __init__(texture)\n" "\n" " Builds a BlenderTextureShader object.\n" "\n" -" :arg mtex: texture slot to add to stroke shading.\n" -" :type mtex: LineStyleTextureSlot\n" - +" :arg texture: A line style texture slot or a shader node tree to define\n" +" a set of textures.\n" +" :type texture: :class:`LineStyleTextureSlot` or :class:`ShaderNodeTree`\n" "\n" ".. method:: shade(stroke)\n" "\n" -" Assigns a blender texture slot to the stroke shading\n" -" in order to simulate marks.\n" +" Assigns a blender texture slot to the stroke shading in order to\n" +" simulate marks.\n" "\n" " :arg stroke: A Stroke object.\n" " :type stroke: :class:`Stroke`\n"; static int BlenderTextureShader___init__(BPy_BlenderTextureShader *self, PyObject *args, PyObject *kwds) { - static const char *kwlist[] = {"LineStyleTextureSlot", NULL}; - PyObject *py_mtex; + static const char *kwlist[] = {"texture", NULL}; + PyObject *obj; MTex *_mtex; + bNodeTree *_nodetree; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &py_mtex)) + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O", (char **)kwlist, &obj)) return -1; - - _mtex = (MTex*)PyC_RNA_AsPointer(py_mtex, "LineStyleTextureSlot"); - + _mtex = (MTex *)PyC_RNA_AsPointer(obj, "LineStyleTextureSlot"); if (_mtex) { self->py_ss.ss = new StrokeShaders::BlenderTextureShader(_mtex); + return 0; } - - return 0; + PyErr_Clear(); + _nodetree = (bNodeTree *)PyC_RNA_AsPointer(obj, "ShaderNodeTree"); + if (_nodetree) { + self->py_ss.ss = new StrokeShaders::BlenderTextureShader(_nodetree); + return 0; + } + PyErr_Format(PyExc_TypeError, + "expected either 'LineStyleTextureSlot' or 'ShaderNodeTree', " + "found '%.200s' instead", Py_TYPE(obj)->tp_name); + return -1; } /*-----------------------BPy_BlenderTextureShader type definition ------------------------------*/ -- cgit v1.2.3