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:
authorCampbell Barton <ideasman42@gmail.com>2007-11-09 13:29:19 +0300
committerCampbell Barton <ideasman42@gmail.com>2007-11-09 13:29:19 +0300
commitddf2336084e7d9c2b1b07897acca2db5cb02fc95 (patch)
tree253150e45d2ee42f997219eae382871fa5ef113b /source/blender/python/api2_2x/Texture.c
parent95661081f9e25011a91e6263e83501ad74085bf8 (diff)
curve2tree - animation settings - speed and magnitude
Python api - texture.evaluate can now accept tuples of numbers as well as vectors
Diffstat (limited to 'source/blender/python/api2_2x/Texture.c')
-rw-r--r--source/blender/python/api2_2x/Texture.c33
1 files changed, 24 insertions, 9 deletions
diff --git a/source/blender/python/api2_2x/Texture.c b/source/blender/python/api2_2x/Texture.c
index 34906757ebd..e21d486a2ab 100644
--- a/source/blender/python/api2_2x/Texture.c
+++ b/source/blender/python/api2_2x/Texture.c
@@ -504,7 +504,7 @@ static int Texture_setNoiseBasis2( BPy_Texture *self, PyObject *args,
static PyObject *Texture_getColorband( BPy_Texture * self);
int Texture_setColorband( BPy_Texture * self, PyObject * value);
-static PyObject *Texture_evaluate( BPy_Texture *self, VectorObject *vec_in );
+static PyObject *Texture_evaluate( BPy_Texture *self, PyObject *value );
static PyObject *Texture_copy( BPy_Texture *self );
/*****************************************************************************/
@@ -2472,19 +2472,34 @@ int Texture_setColorband( BPy_Texture * self, PyObject * value)
return EXPP_Colorband_fromPyList( &self->texture->coba, value );
}
-static PyObject *Texture_evaluate( BPy_Texture * self, VectorObject * vec_in )
+static PyObject *Texture_evaluate( BPy_Texture * self, PyObject * value )
{
TexResult texres= {0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0, NULL};
float vec[4];
/* int rgbnor; dont use now */
- if(!VectorObject_Check(vec_in) || vec_in->size < 3)
- return EXPP_ReturnPyObjError(PyExc_TypeError,
- "expects a 3D vector object");
-
- /* rgbnor = .. we don't need this now */
- multitex_ext(self->texture, vec_in->vec, NULL, NULL, 1, &texres);
-
+ if (VectorObject_Check(value)) {
+ if(((VectorObject *)value)->size < 3)
+ return EXPP_ReturnPyObjError(PyExc_TypeError,
+ "expects a 3D vector object or a tuple of 3 numbers");
+
+ /* rgbnor = .. we don't need this now */
+ multitex_ext(self->texture, ((VectorObject *)value)->vec, NULL, NULL, 1, &texres);
+ } else {
+ float vec_in[3];
+ if (!PyTuple_Check(value) || PyTuple_Size(value) < 3)
+ return EXPP_ReturnPyObjError(PyExc_TypeError,
+ "expects a 3D vector object or a tuple of 3 numbers");
+
+ vec_in[0] = PyFloat_AsDouble(PyTuple_GET_ITEM(value, 0));
+ vec_in[1] = PyFloat_AsDouble(PyTuple_GET_ITEM(value, 1));
+ vec_in[2] = PyFloat_AsDouble(PyTuple_GET_ITEM(value, 2));
+ if (PyErr_Occurred())
+ return EXPP_ReturnPyObjError(PyExc_TypeError,
+ "expects a 3D vector object or a tuple of 3 numbers");
+
+ multitex_ext(self->texture, vec_in, NULL, NULL, 1, &texres);
+ }
vec[0] = texres.tr;
vec[1] = texres.tg;
vec[2] = texres.tb;