From deffce3c19ced621f3432a145b5b21b323ef9d6a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 May 2007 12:58:46 +0000 Subject: Key.c/h - Removed unneeded functions. and ipo in struct wasnt being used. Lattice.c - removed warning Mesh.c - (own error) when running me.update(key="...") didnt update the right keyframe. mesh_cleanup.py - Bugfix from a report by plumiferos that started uncovering all the memory leaks. Removing NAN verts didnt work with mesh keyframes. --- source/blender/python/api2_2x/Key.c | 51 +++++++++------------------------ source/blender/python/api2_2x/Key.h | 2 +- source/blender/python/api2_2x/Lattice.c | 2 +- source/blender/python/api2_2x/Mesh.c | 4 +-- 4 files changed, 16 insertions(+), 43 deletions(-) (limited to 'source') diff --git a/source/blender/python/api2_2x/Key.c b/source/blender/python/api2_2x/Key.c index b32f063ffc4..49fd55ed5c2 100644 --- a/source/blender/python/api2_2x/Key.c +++ b/source/blender/python/api2_2x/Key.c @@ -289,23 +289,12 @@ PyTypeObject KeyBlock_Type = { NULL }; -static PyObject *new_Key(Key * oldkey) +PyObject *Key_CreatePyObject( Key * blenkey ) { - BPy_Key *k = PyObject_NEW( BPy_Key, &Key_Type ); - - if( !oldkey ) { - k->key = 0; - } else { - k->key = oldkey; - } - return ( PyObject * ) k; -} - -PyObject *Key_CreatePyObject( Key * k ) -{ - BPy_Key *key = ( BPy_Key * ) new_Key( k ); - - return ( PyObject * ) key; + BPy_Key *bpykey = PyObject_NEW( BPy_Key, &Key_Type ); + /* blenkey may be NULL so be careful */ + bpykey->key = blenkey; + return ( PyObject * ) bpykey; } static void Key_dealloc( BPy_Key * self ) @@ -325,15 +314,9 @@ static PyObject *Key_repr( BPy_Key * self ) static PyObject *Key_getIpo( BPy_Key * self ) { - BPy_Ipo *new_ipo; - - if (self->key->ipo) { - new_ipo = ( BPy_Ipo * ) PyObject_NEW( BPy_Ipo, &Ipo_Type ); - new_ipo->ipo = self->key->ipo; - return (PyObject *) new_ipo; - } else { - Py_RETURN_NONE; - } + if (self->key->ipo) + Ipo_CreatePyObject( self->key->ipo ); + Py_RETURN_NONE; } static int Key_setIpo( BPy_Key * self, PyObject * value ) @@ -404,20 +387,12 @@ static PyObject *Key_getValue( BPy_Key * self ) } /* ------------ Key Block Functions -------------- */ - -static PyObject *new_KeyBlock( KeyBlock * keyblock, Key *key) +PyObject *KeyBlock_CreatePyObject( KeyBlock * keyblock, Key *parentKey ) { - BPy_KeyBlock *kb = PyObject_NEW( BPy_KeyBlock, &KeyBlock_Type ); - kb->key = key; - kb->keyblock = keyblock; /* keyblock maye be NULL, thats ok */ - return ( PyObject * ) kb; -} - -PyObject *KeyBlock_CreatePyObject( KeyBlock * kb, Key *parentKey ) -{ - BPy_KeyBlock *keyBlock = ( BPy_KeyBlock * ) new_KeyBlock( kb, parentKey ); - - return ( PyObject * ) keyBlock; + BPy_KeyBlock *bpykb = PyObject_NEW( BPy_KeyBlock, &KeyBlock_Type ); + bpykb->key = parentKey; + bpykb->keyblock = keyblock; /* keyblock maye be NULL, thats ok */ + return ( PyObject * ) bpykb; } static PyObject *KeyBlock_getCurval( BPy_KeyBlock * self ) { diff --git a/source/blender/python/api2_2x/Key.h b/source/blender/python/api2_2x/Key.h index 6def2944d89..87cb55d10eb 100644 --- a/source/blender/python/api2_2x/Key.h +++ b/source/blender/python/api2_2x/Key.h @@ -50,7 +50,7 @@ typedef struct { Key * key; /* libdata must be second */ /* Object *object;*/ /* for vertex grouping info, since it's stored on the object */ /*PyObject *keyBlock;*/ - PyObject *ipo; + /*PyObject *ipo;*/ } BPy_Key; typedef struct { diff --git a/source/blender/python/api2_2x/Lattice.c b/source/blender/python/api2_2x/Lattice.c index 5c8df29d5d0..e58967a712b 100644 --- a/source/blender/python/api2_2x/Lattice.c +++ b/source/blender/python/api2_2x/Lattice.c @@ -677,7 +677,7 @@ static PyObject *Lattice_getLatSize(BPy_Lattice * self) static PyObject *Lattice_getAxisType(BPy_Lattice * self, void * type) { - char interp_type = (char)NULL; + char interp_type = 0; switch ( (int)type ) { case 0: interp_type = self->lattice->typeu; diff --git a/source/blender/python/api2_2x/Mesh.c b/source/blender/python/api2_2x/Mesh.c index 212298e3dce..acb95919916 100644 --- a/source/blender/python/api2_2x/Mesh.c +++ b/source/blender/python/api2_2x/Mesh.c @@ -5408,15 +5408,13 @@ static PyObject *Mesh_Update( BPy_Mesh * self, PyObject *args, PyObject *kwd ) "Cannot update the key for this mesh, it has no shape keys"); for (kb = key->block.first; kb; kb=kb->next) - if (strcmp(blockname, kb->name)) + if (strcmp(blockname, kb->name)==0) break; if (!kb) return EXPP_ReturnPyObjError( PyExc_ValueError, "This requested key to update does not exist"); - printf("KEYBLOCKNAME %s\n", kb->name); - for(i=0, co= kb->data; itotvert; i++, mv++, co++) VECCOPY(*co, mv->co); } else { -- cgit v1.2.3