diff options
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/api2_2x/Draw.c | 25 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Object.c | 39 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Particle.c | 2 | ||||
-rw-r--r-- | source/blender/python/api2_2x/doc/Object.py | 7 |
4 files changed, 59 insertions, 14 deletions
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c index cd7ec781b2b..3d4546613be 100644 --- a/source/blender/python/api2_2x/Draw.c +++ b/source/blender/python/api2_2x/Draw.c @@ -2063,22 +2063,22 @@ static PyObject *Method_Image( PyObject * self, PyObject * args ) /*GLfloat scissorBox[4];*/ /* parse the arguments passed-in from Python */ - if( !PyArg_ParseTuple( args, "Off|ffiiii", &pyObjImage, + if( !PyArg_ParseTuple( args, "O!ff|ffiiii", &Image_Type, &pyObjImage, &originX, &originY, &zoomX, &zoomY, &clipX, &clipY, &clipW, &clipH ) ) return EXPP_ReturnPyObjError( PyExc_TypeError, "expected a Blender.Image and 2 floats, and " \ "optionally 2 floats and 4 ints as arguments" ); - /* check that the first PyObject is actually a Blender.Image */ - if( !BPy_Image_Check( pyObjImage ) ) - return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected a Blender.Image and 2 floats, and " \ - "optionally 2 floats and 4 ints as arguments" ); /* check that the zoom factors are valid */ - if( ( zoomX <= 0.0 ) || ( zoomY <= 0.0 ) ) + if( ( zoomX < 0.0 ) || ( zoomY < 0.0 ) ) return EXPP_ReturnPyObjError( PyExc_TypeError, - "invalid zoom factors - they must be >= 0.0" ); - + "invalid zoom factors - they must be > 0.0" ); + if ((zoomX == 0.0 ) || ( zoomY == 0.0 )) { + /* sometimes python doubles can be converted from small values to a zero float, in this case just dont draw */ + Py_RETURN_NONE; + } + + /* fetch a C Image pointer from the passed-in Python object */ py_img = ( BPy_Image * ) pyObjImage; image = py_img->image; @@ -2101,9 +2101,9 @@ static PyObject *Method_Image( PyObject * self, PyObject * args ) * the image as they can. */ clipX = EXPP_ClampInt( clipX, 0, ibuf->x ); clipY = EXPP_ClampInt( clipY, 0, ibuf->y ); - if( ( clipW < 0 ) || ( clipW > ( ibuf->x - clipW ) ) ) + if( ( clipW < 0 ) || ( clipX+clipW > ibuf->x ) ) clipW = ibuf->x - clipX; - if( ( clipH < 0 ) || ( clipH > ( ibuf->y - clipH ) ) ) + if( ( clipH < 0 ) || ( clipY+clipH > ibuf->y ) ) clipH = ibuf->y - clipY; /* -- we are "Go" to Draw! -- */ @@ -2165,8 +2165,7 @@ static PyObject *Method_Image( PyObject * self, PyObject * args ) glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 ); glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 ); - Py_INCREF( Py_None ); - return Py_None; + Py_RETURN_NONE; } diff --git a/source/blender/python/api2_2x/Object.c b/source/blender/python/api2_2x/Object.c index 82f99adcdb1..1a806932bdb 100644 --- a/source/blender/python/api2_2x/Object.c +++ b/source/blender/python/api2_2x/Object.c @@ -341,6 +341,7 @@ static int setupPI(Object* ob); static PyObject *Object_getParticleSys( BPy_Object * self ); /* fixme Object_newParticleSys( self, default-partsys-name ) */ +static PyObject *Object_addVertexGroupsFromArmature( BPy_Object * self, PyObject * args); static PyObject *Object_newParticleSys( BPy_Object * self ); static PyObject *Object_buildParts( BPy_Object * self ); static PyObject *Object_clearIpo( BPy_Object * self ); @@ -475,6 +476,8 @@ static PyMethodDef BPy_Object_methods[] = { "Return a list of particle systems"}, {"newParticleSystem", ( PyCFunction ) Object_newParticleSys, METH_NOARGS, "Create and link a new particle system"}, + {"addVertexGroupsFromArmature" , ( PyCFunction ) Object_addVertexGroupsFromArmature, METH_VARARGS, + "Add vertex groups from armature using the bone heat method"}, {"buildParts", ( PyCFunction ) Object_buildParts, METH_NOARGS, "Recalcs particle system (if any), (depricated, will always return an empty list in version 2.46)"}, {"getIpo", ( PyCFunction ) Object_getIpo, METH_NOARGS, @@ -1109,6 +1112,42 @@ PyObject *Object_newParticleSys( BPy_Object * self ){ return ParticleSys_CreatePyObject(rpsys,ob); } +/*****************************************************************************/ +/* attribute: addVertexGroupsFromArmature */ +/* Description: evaluate and add vertex groups to the current object */ +/* for each bone of the selected armature */ +/* Data: self Object, Bpy armature */ +/* Return: nothing */ +/*****************************************************************************/ +static PyObject *Object_addVertexGroupsFromArmature( BPy_Object * self, PyObject * args) +{ + + Object *ob = self->object; + BPy_Object *arm; + + if( ob->type != OB_MESH ) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "Only useable on Mesh type Objects" ); + + if( G.obedit != NULL) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "Not useable when inside edit mode" ); + + /* Check if the arguments passed to makeParent are valid. */ + if( !PyArg_ParseTuple( args, "O!",&Object_Type, &arm ) ) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "An armature object is expected." ); + + if( arm->object->type != OB_ARMATURE ) + return EXPP_ReturnPyObjError( PyExc_TypeError, + "An armature object is expected." ); + + add_verts_to_dgroups(ob, arm->object, 1, 0); + ob->recalc |= OB_RECALC_OB; + + Py_RETURN_NONE; +} + static PyObject *Object_buildParts( BPy_Object * self ) { /* This is now handles by modifiers */ diff --git a/source/blender/python/api2_2x/Particle.c b/source/blender/python/api2_2x/Particle.c index 15307cc2be5..f0a32db0623 100644 --- a/source/blender/python/api2_2x/Particle.c +++ b/source/blender/python/api2_2x/Particle.c @@ -828,7 +828,7 @@ static PyObject *Part_GetLoc( BPy_PartSys * self, PyObject * args ){ /* little hack to calculate hair steps in render mode */ psys->renderdata = (void*)(int)1; - psys_cache_paths(ob, psys, cfra, 0); + psys_cache_paths(ob, psys, cfra, 1); psys->renderdata = NULL; diff --git a/source/blender/python/api2_2x/doc/Object.py b/source/blender/python/api2_2x/doc/Object.py index 521be3b0cea..09167c0e117 100644 --- a/source/blender/python/api2_2x/doc/Object.py +++ b/source/blender/python/api2_2x/doc/Object.py @@ -651,6 +651,13 @@ class Object: Link a new particle system (see Blender.Particle). """ + def addVertexGroupsFromArmature(object): + """ + Add vertex groups from armature using the bone heat method + This method can be only used with an Object of the type Mesh when NOT in edit mode. + @type object: a bpy armature + """ + def buildParts(): """ Recomputes the particle system. This method only applies to an Object of |