diff options
author | Stephen Swaney <sswaney@centurytel.net> | 2005-05-22 21:40:00 +0400 |
---|---|---|
committer | Stephen Swaney <sswaney@centurytel.net> | 2005-05-22 21:40:00 +0400 |
commit | ece00ff04a90aa0aaa37f27185c25b0f7b19e77d (patch) | |
tree | 7c1143535c4828b4ca87ddda22df9fd4950e4607 /source/blender/python/api2_2x/Bone.c | |
parent | 910b0f2cda7b8ca45bf16d429bb8df986e69ce1f (diff) |
Roll back changes from Big Mathutils Commit on 2005/05/20.
Diffstat (limited to 'source/blender/python/api2_2x/Bone.c')
-rw-r--r-- | source/blender/python/api2_2x/Bone.c | 148 |
1 files changed, 104 insertions, 44 deletions
diff --git a/source/blender/python/api2_2x/Bone.c b/source/blender/python/api2_2x/Bone.c index c5175cb2d87..686b791a846 100644 --- a/source/blender/python/api2_2x/Bone.c +++ b/source/blender/python/api2_2x/Bone.c @@ -46,14 +46,12 @@ #include <BSE_editaction.h> #include <BKE_constraint.h> #include <MEM_guardedalloc.h> -#include <BKE_utildefines.h> #include "constant.h" #include "gen_utils.h" #include "NLA.h" #include "quat.h" #include "matrix.h" #include "vector.h" -#include "Types.h" //--------------------Python API function prototypes for the Bone module---- static PyObject *M_Bone_New( PyObject * self, PyObject * args ); @@ -539,19 +537,45 @@ PyObject *Bone_CreatePyObject( struct Bone * bone ) //allocate space for python vars blen_bone->name = PyMem_Malloc( 32 + 1 ); blen_bone->parent = PyMem_Malloc( 32 + 1 ); - blen_bone->head = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - blen_bone->tail = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - blen_bone->loc = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - blen_bone->dloc = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - blen_bone->size = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - blen_bone->dsize = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - blen_bone->quat = ( QuaternionObject *)newQuaternionObject( NULL, Py_NEW ); - blen_bone->dquat = ( QuaternionObject *)newQuaternionObject( NULL, Py_NEW ); - blen_bone->obmat = ( MatrixObject *)newMatrixObject( NULL, 4, 4 , Py_NEW); - blen_bone->parmat = ( MatrixObject *)newMatrixObject( NULL, 4, 4 , Py_NEW); - blen_bone->defmat = ( MatrixObject *)newMatrixObject( NULL, 4, 4 , Py_NEW); - blen_bone->irestmat = ( MatrixObject *)newMatrixObject( NULL, 4, 4 , Py_NEW); - blen_bone->posemat = ( MatrixObject *)newMatrixObject( NULL, 4, 4 , Py_NEW); + blen_bone->head = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + blen_bone->tail = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + blen_bone->loc = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + blen_bone->dloc = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + blen_bone->size = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + blen_bone->dsize = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + blen_bone->quat = + ( QuaternionObject * ) + newQuaternionObject( PyMem_Malloc( 4 * sizeof( float ) ) ); + blen_bone->dquat = + ( QuaternionObject * ) + newQuaternionObject( PyMem_Malloc( 4 * sizeof( float ) ) ); + blen_bone->obmat = + ( MatrixObject * ) + newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 ); + blen_bone->parmat = + ( MatrixObject * ) + newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 ); + blen_bone->defmat = + ( MatrixObject * ) + newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 ); + blen_bone->irestmat = + ( MatrixObject * ) + newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 ); + blen_bone->posemat = + ( MatrixObject * ) + newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 ); if( !updatePyBone( blen_bone ) ) return EXPP_ReturnPyObjError( PyExc_AttributeError, @@ -600,19 +624,45 @@ static PyObject *M_Bone_New( PyObject * self, PyObject * args ) //allocate space for python vars py_bone->name = PyMem_Malloc( 32 + 1 ); py_bone->parent = PyMem_Malloc( 32 + 1 ); - py_bone->head = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - py_bone->tail = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - py_bone->loc = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - py_bone->dloc = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - py_bone->size = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - py_bone->dsize = ( VectorObject *)newVectorObject( NULL, 3, Py_NEW ); - py_bone->quat = ( QuaternionObject *)newQuaternionObject( NULL, Py_NEW ); - py_bone->dquat = ( QuaternionObject *)newQuaternionObject( NULL, Py_NEW ); - py_bone->obmat = ( MatrixObject *)newMatrixObject( NULL, 4, 4 , Py_NEW); - py_bone->parmat = ( MatrixObject *)newMatrixObject( NULL, 4, 4 , Py_NEW); - py_bone->defmat = ( MatrixObject *)newMatrixObject( NULL, 4, 4 , Py_NEW); - py_bone->irestmat = ( MatrixObject *)newMatrixObject( NULL, 4, 4 , Py_NEW); - py_bone->posemat = ( MatrixObject *)newMatrixObject( NULL, 4, 4 , Py_NEW); + py_bone->head = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + py_bone->tail = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + py_bone->loc = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + py_bone->dloc = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + py_bone->size = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + py_bone->dsize = + ( VectorObject * ) + newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), 3 ); + py_bone->quat = + ( QuaternionObject * ) + newQuaternionObject( PyMem_Malloc( 4 * sizeof( float ) ) ); + py_bone->dquat = + ( QuaternionObject * ) + newQuaternionObject( PyMem_Malloc( 4 * sizeof( float ) ) ); + py_bone->obmat = + ( MatrixObject * ) + newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 ); + py_bone->parmat = + ( MatrixObject * ) + newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 ); + py_bone->defmat = + ( MatrixObject * ) + newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 ); + py_bone->irestmat = + ( MatrixObject * ) + newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 ); + py_bone->posemat = + ( MatrixObject * ) + newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 ); //default py values BLI_strncpy( py_bone->name, name_str, strlen( name_str ) + 1 ); @@ -709,17 +759,19 @@ static PyObject *Bone_getWeight( BPy_Bone * self ) static PyObject *Bone_getHead( BPy_Bone * self ) { PyObject *attr = NULL; - float vec[3]; + float *vec; int x; if( !self->bone ) { //test to see if linked to armature //use python vars + vec = PyMem_Malloc( 3 * sizeof( float ) ); for( x = 0; x < 3; x++ ) vec[x] = self->head->vec[x]; - attr = ( PyObject * ) newVectorObject( vec, 3, Py_NEW ); + attr = ( PyObject * ) newVectorObject( vec, 3 ); } else { //use bone datastruct - attr = newVectorObject( NULL, 3, Py_NEW ); + attr = newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), + 3 ); ( ( VectorObject * ) attr )->vec[0] = self->bone->head[0]; ( ( VectorObject * ) attr )->vec[1] = self->bone->head[1]; ( ( VectorObject * ) attr )->vec[2] = self->bone->head[2]; @@ -735,17 +787,19 @@ static PyObject *Bone_getHead( BPy_Bone * self ) static PyObject *Bone_getTail( BPy_Bone * self ) { PyObject *attr = NULL; - float vec[3]; + float *vec; int x; if( !self->bone ) { //test to see if linked to armature //use python vars + vec = PyMem_Malloc( 3 * sizeof( float ) ); for( x = 0; x < 3; x++ ) vec[x] = self->tail->vec[x]; - attr = ( PyObject * ) newVectorObject( vec, 3, Py_NEW ); + attr = ( PyObject * ) newVectorObject( vec, 3 ); } else { //use bone datastruct - attr = newVectorObject( NULL, 3, Py_NEW ); + attr = newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), + 3 ); ( ( VectorObject * ) attr )->vec[0] = self->bone->tail[0]; ( ( VectorObject * ) attr )->vec[1] = self->bone->tail[1]; ( ( VectorObject * ) attr )->vec[2] = self->bone->tail[2]; @@ -761,17 +815,19 @@ static PyObject *Bone_getTail( BPy_Bone * self ) static PyObject *Bone_getLoc( BPy_Bone * self ) { PyObject *attr = NULL; - float vec[3]; + float *vec; int x; if( !self->bone ) { //test to see if linked to armature //use python vars + vec = PyMem_Malloc( 3 * sizeof( float ) ); for( x = 0; x < 3; x++ ) vec[x] = self->loc->vec[x]; - attr = ( PyObject * ) newVectorObject( vec, 3, Py_NEW ); + attr = ( PyObject * ) newVectorObject( vec, 3 ); } else { //use bone datastruct - attr = newVectorObject( vec, 3, Py_NEW ); + attr = newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), + 3 ); ( ( VectorObject * ) attr )->vec[0] = self->bone->loc[0]; ( ( VectorObject * ) attr )->vec[1] = self->bone->loc[1]; ( ( VectorObject * ) attr )->vec[2] = self->bone->loc[2]; @@ -787,17 +843,19 @@ static PyObject *Bone_getLoc( BPy_Bone * self ) static PyObject *Bone_getSize( BPy_Bone * self ) { PyObject *attr = NULL; - float vec[3]; + float *vec; int x; if( !self->bone ) { //test to see if linked to armature //use python vars + vec = PyMem_Malloc( 3 * sizeof( float ) ); for( x = 0; x < 3; x++ ) vec[x] = self->size->vec[x]; - attr = ( PyObject * ) newVectorObject( vec, 3, Py_NEW ); + attr = ( PyObject * ) newVectorObject( vec, 3 ); } else { //use bone datastruct - attr = newVectorObject( vec, 3, Py_NEW ); + attr = newVectorObject( PyMem_Malloc( 3 * sizeof( float ) ), + 3 ); ( ( VectorObject * ) attr )->vec[0] = self->bone->size[0]; ( ( VectorObject * ) attr )->vec[1] = self->bone->size[1]; ( ( VectorObject * ) attr )->vec[2] = self->bone->size[2]; @@ -813,18 +871,20 @@ static PyObject *Bone_getSize( BPy_Bone * self ) static PyObject *Bone_getQuat( BPy_Bone * self ) { PyObject *attr = NULL; - float quat[4]; + float *quat; int x; if( !self->bone ) { //test to see if linked to armature //use python vars - p.s. - you must return a copy or else //python will trash the internal var + quat = PyMem_Malloc( 4 * sizeof( float ) ); for( x = 0; x < 4; x++ ) quat[x] = self->quat->quat[x]; - attr = ( PyObject * ) newQuaternionObject( quat, Py_NEW ); + attr = ( PyObject * ) newQuaternionObject( quat ); } else { //use bone datastruct - attr = newQuaternionObject( NULL, Py_NEW ); + attr = newQuaternionObject( PyMem_Malloc + ( 4 * sizeof( float ) ) ); ( ( QuaternionObject * ) attr )->quat[0] = self->bone->quat[0]; ( ( QuaternionObject * ) attr )->quat[1] = self->bone->quat[1]; ( ( QuaternionObject * ) attr )->quat[2] = self->bone->quat[2]; @@ -1625,7 +1685,7 @@ static PyObject *Bone_getRestMatrix( BPy_Bone * self, PyObject * args ) return ( EXPP_ReturnPyObjError( PyExc_AttributeError, "expected 'bonespace' or 'worldspace'" ) ); - matrix = newMatrixObject( NULL, 4, 4 , Py_NEW); + matrix = newMatrixObject( PyMem_Malloc( 16 * sizeof( float ) ), 4, 4 ); if( !self->bone ) { //test to see if linked to armature //use python vars |