diff options
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/BPY_interface.c | 14 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Armature.c | 3 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Draw.c | 47 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Image.c | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Mesh.c | 15 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Draw.py | 7 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Image.py | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/SConscript | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/matrix.c | 4 |
9 files changed, 62 insertions, 34 deletions
diff --git a/source/blender/python/BPY_interface.c b/source/blender/python/BPY_interface.c index 1c8b606ace3..331f72021f2 100644 --- a/source/blender/python/BPY_interface.c +++ b/source/blender/python/BPY_interface.c @@ -167,7 +167,7 @@ static void DoAllScriptsFromList( ListBase * list, short event ); static PyObject *importText( char *name ); static void init_ourImport( void ); static void init_ourReload( void ); -static PyObject *blender_import( PyObject * self, PyObject * args ); +static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * kw); static void BPY_Err_Handle( char *script_name ); @@ -2849,24 +2849,28 @@ static PyObject *importText( char *name ) } static PyMethodDef bimport[] = { - {"blimport", blender_import, METH_VARARGS, "our own import"} + {"blimport", blender_import, METH_KEYWORDS, "our own import"} }; -static PyObject *blender_import( PyObject * self, PyObject * args ) +static PyObject *blender_import( PyObject * self, PyObject * args, PyObject * kw) { PyObject *exception, *err, *tb; char *name; PyObject *globals = NULL, *locals = NULL, *fromlist = NULL; PyObject *m; + //PyObject_Print(args, stderr, 0); #if (PY_VERSION_HEX >= 0x02060000) int dummy_val; /* what does this do?*/ + static char *kwlist[] = {"name", "globals", "locals", "fromlist", "level", 0}; - if( !PyArg_ParseTuple( args, "s|OOOi:bimport", + if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOOi:bimport", kwlist, &name, &globals, &locals, &fromlist, &dummy_val) ) return NULL; #else - if( !PyArg_ParseTuple( args, "s|OOO:bimport", + static char *kwlist[] = {"name", "globals", "locals", "fromlist", 0}; + + if( !PyArg_ParseTupleAndKeywords( args, kw, "s|OOO:bimport", kwlist, &name, &globals, &locals, &fromlist ) ) return NULL; #endif diff --git a/source/blender/python/api2_2x/Armature.c b/source/blender/python/api2_2x/Armature.c index aa3ef82a3e8..99a4398ec89 100644 --- a/source/blender/python/api2_2x/Armature.c +++ b/source/blender/python/api2_2x/Armature.c @@ -244,7 +244,8 @@ static PyObject *BonesDict_GetItem(BPy_BonesDict *self, PyObject* key) } if(value == NULL){ /* item not found in dict. throw exception */ char* key_str = PyString_AsString( key ); - if (key_str) { + + if (key_str==NULL) { return EXPP_ReturnPyObjError(PyExc_KeyError, "bone key must be a string" ); } else { char buffer[128]; diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index e0111f099aa..c238fe5601c 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -258,7 +258,7 @@ Normal button (a sphere that you can roll to change the normal)\n\n\ [tooltip=] The button's tooltip"; static char Method_Number_doc[] = - "(name, event, x, y, width, height, initial, min, max, [tooltip]) - Create a \ + "(name, event, x, y, width, height, initial, min, max, [tooltip], [callback], [clickstep], [precision]) - Create a \ new Number button\n\n\ (name) A string to display on the button\n\ (event) The event number to pass to the button event function when activated\n\ @@ -266,7 +266,10 @@ new Number button\n\n\ (width, height) The button width and height\n\ (initial, min, max) Three values (int or float) specifying the initial and \ limit values.\n\ -[tooltip=] The button's tooltip"; +[tooltip=] The button's tooltip\n\ +[callback=] The button's callback\n\ +[clickstep=] Click step for the button\n\ +[precision=] How many decimal places to maintain, if not given, it is calculated depending on range, otherwise 1,2,3 or 4. Larger values are clamped to 4"; static char Method_String_doc[] = "(name, event, x, y, width, height, initial, length, [tooltip]) - Create a \ @@ -1600,6 +1603,8 @@ static PyObject *Method_Number( PyObject * self, PyObject * args ) Button *but; PyObject *mino, *maxo, *inio; PyObject *callback=NULL; + PyObject *a1=NULL; + PyObject *a2=NULL; uiBut *ubut= NULL; if (G.background) { @@ -1607,11 +1612,11 @@ static PyObject *Method_Number( PyObject * self, PyObject * args ) "Can't run Draw.Number() in background mode." ); } - if( !PyArg_ParseTuple( args, "siiiiiOOO|sO", &name, &event, - &x, &y, &w, &h, &inio, &mino, &maxo, &tip, &callback ) ) + if( !PyArg_ParseTuple( args, "siiiiiOOO|sOOO", &name, &event, + &x, &y, &w, &h, &inio, &mino, &maxo, &tip, &callback, &a1, &a2 ) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a string, five ints, three PyObjects and\n\ - optionally string and callback arguments" ); + optionally string, callback, range and precision arguments" ); UI_METHOD_ERRORCHECK; @@ -1632,14 +1637,30 @@ static PyObject *Method_Number( PyObject * self, PyObject * args ) min = (float)PyFloat_AsDouble( mino ); max = (float)PyFloat_AsDouble( maxo ); - range= (float)fabs(max-min); /* Click step will be a 10th of the range. */ - if (!range) range= 1.0f; /* avoid any odd errors */ + if(a1 && PyNumber_Check(a1)) { + if(PyFloat_Check(a1)) + range= (float)PyFloat_AsDouble(a1); + else + range= (float)PyInt_AsLong(a1); + } else { + range= (float)fabs(max-min); /* Click step will be a 10th of the range. */ + if (!range) range= 1.0f; /* avoid any odd errors */ + } - /* set the precission to display*/ - if (range>=1000.0f) precission=1.0f; - else if (range>=100.0f) precission=2.0f; - else if (range>=10.0f) precission=3.0f; - else precission=4.0f; + if(a2 && PyNumber_Check(a2)) { + if(PyFloat_Check(a2)) + precission= (float)PyFloat_AsDouble(a2); + else + precission= (float)PyInt_AsLong(a2); + } else { + /* set the precission to display*/ + if (range>=1000.0f) precission=1.0f; + else if (range>=100.0f) precission=2.0f; + else if (range>=10.0f) precission=3.0f; + else precission=4.0f; + + range *= 10; + } but->type = BFLOAT_TYPE; but->val.asfloat = ini; @@ -1647,7 +1668,7 @@ static PyObject *Method_Number( PyObject * self, PyObject * args ) if( block ) ubut= uiDefButF( block, NUM, event, name, (short)x, (short)y, (short)w, (short)h, - &but->val.asfloat, min, max, 10*range, precission, but->tooltip ); + &but->val.asfloat, min, max, range, precission, but->tooltip ); } else { int ini, min, max; diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c index 5ef2cbadbdc..dc15e008209 100644 --- a/source/blender/python/api2_2x/Image.c +++ b/source/blender/python/api2_2x/Image.c @@ -1380,6 +1380,8 @@ static PyGetSetDef BPy_Image_getseters[] = { "image odd fields toggle", (void *)IMA_STD_FIELD }, {"antialias", (getter)Image_getFlag, (setter)Image_setFlag, "image antialiasing toggle", (void *)IMA_ANTIALI }, + {"premul", (getter)Image_getFlag, (setter)Image_setFlag, + "image premultiply alpha toggle", (void *)IMA_DO_PREMUL }, {"reflect", (getter)Image_getFlag, (setter)Image_setFlag, "image reflect toggle", (void *)IMA_REFLECT }, {"clampX", (getter)Image_getFlagTpage, (setter)Image_setFlagTpage, diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index a97a55244ad..32ddb464c88 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -6271,19 +6271,12 @@ static PyObject *Mesh_getFromObject( BPy_Mesh * self, PyObject * args ) if( origmesh->mat ) { for( i = origmesh->totcol; i-- > 0; ) { /* are we an object material or data based? */ - if (ob->colbits & 1<<i) { + if (ob->colbits & 1<<i) self->mesh->mat[i] = ob->mat[i]; - - if (ob->mat[i]) - ob->mat[i]->id.us++; - if (origmesh->mat[i]) - origmesh->mat[i]->id.us--; - } else { + else self->mesh->mat[i] = origmesh->mat[i]; - - if (origmesh->mat[i]) - origmesh->mat[i]->id.us++; - } + if (self->mesh->mat[i]) + self->mesh->mat[i]->id.us++; } } } diff --git a/source/blender/python/api2_2x/doc/Draw.py b/source/blender/python/api2_2x/doc/Draw.py index 127f37bfbad..98e92196f8d 100644 --- a/source/blender/python/api2_2x/doc/Draw.py +++ b/source/blender/python/api2_2x/doc/Draw.py @@ -706,7 +706,7 @@ def Normal(event, x, y, width, height, initial, tooltip = None, callback = None) @note: Using the same button variable with more then 1 button at a time will corrupt memory. """ -def Number(name, event, x, y, width, height, initial, min, max, tooltip = None, callback = None): +def Number(name, event, x, y, width, height, initial, min, max, tooltip = None, callback = None, clickstep = None, precision = None): """ Create a new Number Button object. @type name: string @@ -735,6 +735,11 @@ def Number(name, event, x, y, width, height, initial, min, max, tooltip = None, @param callback: an optional argument so this button can have its own callback function. the function will run whenever this button is pressed. This function must accept 2 arguments (event, val). + @type clickstep: float + @param clickstep: an optional argument to control the amount of change per click on the button. + @type precision: float + @param precision: an optional argument to control the amount of places after the decimal. From 1 to 4 places with 1.0..4.0. + Larger values are clamped to 4 places. @rtype: Blender Button @return: The Button created. diff --git a/source/blender/python/api2_2x/doc/Image.py b/source/blender/python/api2_2x/doc/Image.py index 564cac3ef9b..e376b11c4fa 100644 --- a/source/blender/python/api2_2x/doc/Image.py +++ b/source/blender/python/api2_2x/doc/Image.py @@ -107,6 +107,8 @@ class Image: @type fields_odd: boolean @ivar antialias: enable or disable the antialias option for this image. @type antialias: boolean + @ivar premul: premultiply alpha toggle. + @type premul: boolean @ivar bindcode: Texture's bind code (readonly). @type bindcode: int @ivar source: Image source type. See L{the Sources dictionary<Sources>} . diff --git a/source/blender/python/api2_2x/doc/SConscript b/source/blender/python/api2_2x/doc/SConscript index 49d20894c58..eca5d9a615c 100644 --- a/source/blender/python/api2_2x/doc/SConscript +++ b/source/blender/python/api2_2x/doc/SConscript @@ -23,6 +23,6 @@ if epydoc: optvalues["names"] = names optparser = OptionParser() optparser.set_defaults(**optvalues) - (options, args) = optparser.parse_args() + (options, args) = optparser.parse_args([]) cli.write_html(docindex, options) diff --git a/source/blender/python/api2_2x/matrix.c b/source/blender/python/api2_2x/matrix.c index 79ca5e09b25..7802de822cb 100644 --- a/source/blender/python/api2_2x/matrix.c +++ b/source/blender/python/api2_2x/matrix.c @@ -246,8 +246,8 @@ PyObject *Matrix_Invert(MatrixObject * self) /*calculate the classical adjoint*/ if(self->rowSize == 2) { mat[0] = self->matrix[1][1]; - mat[1] = -self->matrix[1][0]; - mat[2] = -self->matrix[0][1]; + mat[1] = -self->matrix[0][1]; + mat[2] = -self->matrix[1][0]; mat[3] = self->matrix[0][0]; } else if(self->rowSize == 3) { Mat3Adj((float (*)[3]) mat,(float (*)[3]) *self->matrix); |