From fec3ddabb1d75ee6a3a28589813f2acc85215e18 Mon Sep 17 00:00:00 2001 From: Tamito Kajiyama Date: Sat, 25 Jul 2009 11:27:18 +0000 Subject: * Better support for vector-like objects in method arguments. Now the following methods in the Freestyle Python API accept not only Blender.Mathutils.Vector instances but also lists and tuples having an appropriate number of elements. FrsNoise::turbulence2() FrsNoise::turbulence3() FrsNoise::smoothNoise2() FrsNoise::smoothNoise3() SVertex::__init__() SVertex::setPoint3D() SVertex::setPoint2D() SVertex::AddNormal() FEdgeSharp::setNormalA() FEdgeSharp::setNormalB() FEdgeSmooth::setNormal() CalligraphicShader::__init__() StrokeAttribute::setAttributeVec2f() StrokeAttribute::setAttributeVec3f() StrokeAttribute::setColor() StrokeVertex::setPoint() * Added the following converters for the sake of the improvements mentioned above. Vec2f_ptr_from_PyObject() Vec3f_ptr_from_PyObject() Vec3r_ptr_from_PyObject() Vec2f_ptr_from_PyList() Vec3f_ptr_from_PyList() Vec3r_ptr_from_PyList() Vec2f_ptr_from_PyTuple() Vec3f_ptr_from_PyTuple() Vec3r_ptr_from_PyTuple() Those converters with the suffixes _PyList and _PyTuple accept only lists and tuples having an appropriate number of elements, respectively, while those with the suffix _PyObject accept lists, tuples, or Blender.Mathutils.Vector instances. * Fixed a null pointer reference in Interface0D___dealloc__(). * Corrected the names of 3 methods in the FEdgeSmooth class. --- .../intern/python/StrokeShader/BPy_CalligraphicShader.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp') diff --git a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp index 1d22be137e3..798b8a8e4ac 100644 --- a/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp +++ b/source/blender/freestyle/intern/python/StrokeShader/BPy_CalligraphicShader.cpp @@ -105,17 +105,16 @@ int CalligraphicShader___init__( BPy_CalligraphicShader* self, PyObject *args) PyObject *obj3 = 0, *obj4 = 0; - if(!( PyArg_ParseTuple(args, "ddO!O", &d1, &d2, &PyList_Type, &obj3, &obj4) )) + if(!( PyArg_ParseTuple(args, "ddOO", &d1, &d2, &obj3, &obj4) )) return -1; - if( PyList_Size(obj3) != 2 ) { - stringstream msg("CalligraphicShader() accepts a list of 2 elements ("); - msg << PyList_Size(obj3) << " found)"; - PyErr_SetString(PyExc_TypeError, msg.str().c_str()); + Vec2f *v = Vec2f_ptr_from_PyObject(obj3); + if( !v ) { + PyErr_SetString(PyExc_TypeError, "argument 3 must be a 2D vector (either a list of 2 elements or Vector)"); return -1; } + self->py_ss.ss = new CalligraphicShader(d1, d2, *v, bool_from_PyBool(obj4) ); + delete v; - Vec2f v( PyFloat_AsDouble(PyList_GetItem(obj3,0)), PyFloat_AsDouble(PyList_GetItem(obj3,1)) ); - self->py_ss.ss = new CalligraphicShader(d1, d2, v, bool_from_PyBool(obj4) ); return 0; } -- cgit v1.2.3