[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11083] branches/pyapi_devel/source/ blender/python: * a matrix can how point back to the data it came from ( ID library data)
Campbell Barton
cbarton at metavr.com
Wed Jun 27 04:44:18 CEST 2007
Revision: 11083
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11083
Author: campbellbarton
Date: 2007-06-27 04:44:01 +0200 (Wed, 27 Jun 2007)
Log Message:
-----------
* a matrix can how point back to the data it came from (ID library data)
* when the ID data has been removed, the matrix will raise an error when used
* a vector row from matrix also checks the matrix has not had its data removed.
* matrix does not coerce anymore (reuse the pointer for linking to the ID pyobject)
Modified Paths:
--------------
branches/pyapi_devel/source/blender/python/BPY_interface.c
branches/pyapi_devel/source/blender/python/api2_2x/Bone.c
branches/pyapi_devel/source/blender/python/api2_2x/Mathutils.c
branches/pyapi_devel/source/blender/python/api2_2x/Object.c
branches/pyapi_devel/source/blender/python/api2_2x/Pose.c
branches/pyapi_devel/source/blender/python/api2_2x/Window.c
branches/pyapi_devel/source/blender/python/api2_2x/euler.c
branches/pyapi_devel/source/blender/python/api2_2x/matrix.c
branches/pyapi_devel/source/blender/python/api2_2x/matrix.h
branches/pyapi_devel/source/blender/python/api2_2x/point.c
branches/pyapi_devel/source/blender/python/api2_2x/quat.c
branches/pyapi_devel/source/blender/python/api2_2x/vector.c
branches/pyapi_devel/source/blender/python/api2_2x/vector.h
Modified: branches/pyapi_devel/source/blender/python/BPY_interface.c
===================================================================
--- branches/pyapi_devel/source/blender/python/BPY_interface.c 2007-06-26 23:06:43 UTC (rev 11082)
+++ branches/pyapi_devel/source/blender/python/BPY_interface.c 2007-06-27 02:44:01 UTC (rev 11083)
@@ -1270,8 +1270,8 @@
globals = CreateGlobalDictionary();
- srcmat = newMatrixObject( (float*)obmat, 4, 4, Py_NEW );
- tarmat = newMatrixObject( (float*)targetmat, 4, 4, Py_NEW );
+ srcmat = newMatrixObject( (float*)obmat, 4, 4, Py_NEW, (BPy_GenericLib *)NULL );
+ tarmat = newMatrixObject( (float*)targetmat, 4, 4, Py_NEW, (BPy_GenericLib *)NULL );
idprop = BPy_Wrap_IDProperty( NULL, con->prop, NULL);
/* since I can't remember what the armature weakrefs do, I'll just leave this here
@@ -1408,7 +1408,7 @@
pchan = NULL;
subtar = PyPoseBone_FromPosechannel( pchan );
- tarmat = newMatrixObject( (float*)targetmat, 4, 4, Py_NEW );
+ tarmat = newMatrixObject( (float*)targetmat, 4, 4, Py_NEW, (BPy_GenericLib *)NULL );
idprop = BPy_Wrap_IDProperty( NULL, con->prop, NULL);
/* since I can't remember what the armature weakrefs do, I'll just leave this here
Modified: branches/pyapi_devel/source/blender/python/api2_2x/Bone.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Bone.c 2007-06-26 23:06:43 UTC (rev 11082)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Bone.c 2007-06-27 02:44:01 UTC (rev 11083)
@@ -560,7 +560,7 @@
vec_roll_to_mat3(axis, self->roll, boneMatrix);
}
- return newMatrixObject((float*)boneMatrix, 3, 3, Py_NEW);
+ return newMatrixObject((float*)boneMatrix, 3, 3, Py_NEW, (BPy_GenericLib *)NULL);
}
//------------------------EditBone.matrix (set)
static int EditBone_setMatrix(BPy_EditBone *self, PyObject *value, void *closure)
@@ -1118,8 +1118,8 @@
//------------------------Bone.matrix (get)
static PyObject *Bone_getMatrix(BPy_Bone *self, void *closure)
{
- PyObject *val1 = newMatrixObject((float*)self->bone->bone_mat, 3,3, Py_WRAP);
- PyObject *val2 = newMatrixObject((float*)self->bone->arm_mat, 4,4, Py_WRAP);
+ PyObject *val1 = newMatrixObject((float*)self->bone->bone_mat, 3,3, Py_WRAP, (BPy_GenericLib *)NULL);
+ PyObject *val2 = newMatrixObject((float*)self->bone->arm_mat, 4,4, Py_WRAP, (BPy_GenericLib *)NULL);
PyObject *ret = Py_BuildValue("{s:O, s:O}",
"BONESPACE", val1, "ARMATURESPACE", val2);
Py_DECREF(val1);
Modified: branches/pyapi_devel/source/blender/python/api2_2x/Mathutils.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Mathutils.c 2007-06-26 23:06:43 UTC (rev 11082)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Mathutils.c 2007-06-27 02:44:01 UTC (rev 11083)
@@ -584,7 +584,7 @@
return EXPP_ReturnPyObjError(PyExc_AttributeError,
"Mathutils.Matrix(): expects 0-4 numeric sequences of the same size\n");
} else if (argSize == 0) { //return empty 4D matrix
- return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW);
+ return (PyObject *) newMatrixObject(NULL, 4, 4, Py_NEW, (BPy_GenericLib *)NULL);
}else if (argSize == 1){
//copy constructor for matrix objects
argObject = PySequence_GetItem(args, 0);
@@ -647,7 +647,7 @@
Py_DECREF(m);
}
}
- return newMatrixObject(matrix, argSize, seqSize, Py_NEW);
+ return newMatrixObject(matrix, argSize, seqSize, Py_NEW, (BPy_GenericLib *)NULL);
}
//----------------------------------Mathutils.RotationMatrix() ----------
//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
@@ -769,7 +769,7 @@
mat[3] = 0.0f;
}
//pass to matrix creation
- return newMatrixObject(mat, matSize, matSize, Py_NEW);
+ return newMatrixObject(mat, matSize, matSize, Py_NEW, (BPy_GenericLib *)NULL);
}
//----------------------------------Mathutils.TranslationMatrix() -------
//creates a translation matrix
@@ -793,7 +793,7 @@
mat[13] = vec->vec[1];
mat[14] = vec->vec[2];
- return newMatrixObject(mat, 4, 4, Py_NEW);
+ return newMatrixObject(mat, 4, 4, Py_NEW, (BPy_GenericLib *)NULL);
}
//----------------------------------Mathutils.ScaleMatrix() -------------
//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
@@ -866,7 +866,7 @@
mat[3] = 0.0f;
}
//pass to matrix creation
- return newMatrixObject(mat, matSize, matSize, Py_NEW);
+ return newMatrixObject(mat, matSize, matSize, Py_NEW, (BPy_GenericLib *)NULL);
}
//----------------------------------Mathutils.OrthoProjectionMatrix() ---
//mat is a 1D array of floats - row[0][0],row[0][1], row[1][0], etc.
@@ -964,7 +964,7 @@
mat[3] = 0.0f;
}
//pass to matrix creation
- return newMatrixObject(mat, matSize, matSize, Py_NEW);
+ return newMatrixObject(mat, matSize, matSize, Py_NEW, (BPy_GenericLib *)NULL);
}
//----------------------------------Mathutils.ShearMatrix() -------------
//creates a shear matrix
@@ -1030,7 +1030,7 @@
mat[3] = 0.0f;
}
//pass to matrix creation
- return newMatrixObject(mat, matSize, matSize, Py_NEW);
+ return newMatrixObject(mat, matSize, matSize, Py_NEW, (BPy_GenericLib *)NULL);
}
//----------------------------------QUATERNION FUNCTIONS-----------------
//----------------------------------Mathutils.Quaternion() --------------
Modified: branches/pyapi_devel/source/blender/python/api2_2x/Object.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Object.c 2007-06-26 23:06:43 UTC (rev 11082)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Object.c 2007-06-27 02:44:01 UTC (rev 11083)
@@ -722,7 +722,7 @@
static PyObject *Object_getInverseMatrix( BPy_Object * self )
{
MatrixObject *inverse =
- ( MatrixObject * ) newMatrixObject( NULL, 4, 4, Py_NEW );
+ ( MatrixObject * ) newMatrixObject( NULL, 4, 4, Py_NEW, (BPy_GenericLib *)NULL );
Mat4Invert( (float ( * )[4])*inverse->matrix, self->object->obmat );
return ( ( PyObject * ) inverse );
@@ -956,7 +956,7 @@
/* create vectors referencing object bounding box coords */
for( i = 0; i < 8; i++ ) {
- vector = newVectorObject( vec, 3, Py_WRAP, self );
+ vector = newVectorObject( vec, 3, Py_WRAP, (BPy_GenericLib *)self );
PyList_SET_ITEM( bbox, i, vector );
vec += 3;
}
@@ -2241,7 +2241,7 @@
pair = PyTuple_New( 2 );
PyTuple_SET_ITEM( pair, 0, Object_CreatePyObject(dupob->ob) );
- PyTuple_SET_ITEM( pair, 1, newMatrixObject((float*)dupob->mat,4,4,Py_NEW) );
+ PyTuple_SET_ITEM( pair, 1, newMatrixObject((float*)dupob->mat,4,4,Py_NEW, (BPy_GenericLib *)NULL) );
PyList_SET_ITEM( list, index, pair);
}
free_object_duplilist(duplilist);
@@ -3532,18 +3532,19 @@
static PyObject *Object_getMatrixLocal( BPy_Object * self )
{
+ /* TODO - This is silly, its returnes wrapped if their is no parent */
if( self->object->parent ) {
float matrix[4][4]; /* for the result */
float invmat[4][4]; /* for inverse of parent's matrix */
Mat4Invert(invmat, self->object->parent->obmat );
Mat4MulMat4(matrix, self->object->obmat, invmat);
- return newMatrixObject((float*)matrix,4,4,Py_NEW);
+ return newMatrixObject((float*)matrix,4,4,Py_NEW, (BPy_GenericLib *)NULL);
} else { /* no parent, so return world space matrix */
disable_where_script( 1 );
where_is_object( self->object );
disable_where_script( 0 );
- return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP);
+ return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP, (BPy_GenericLib *)self);
}
}
@@ -3554,14 +3555,14 @@
disable_where_script( 1 );
where_is_object( self->object );
disable_where_script( 0 );
- return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP);
+ return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP, (BPy_GenericLib *)self);
}
/* Parent Inverse matrix */
static PyObject *Object_getMatrixParentInverse( BPy_Object * self )
{
- return newMatrixObject((float*)self->object->parentinv,4,4,Py_WRAP);
+ return newMatrixObject((float*)self->object->parentinv,4,4,Py_WRAP, (BPy_GenericLib *)self);
}
/*
@@ -3569,10 +3570,10 @@
* script itself were not taken into account until a redraw happened, either
* called by the script or upon its exit.
*/
-
+/* TODO - remove this, well, see if theres any reason in keeping */
static PyObject *Object_getMatrixOldWorld( BPy_Object * self )
{
- return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP);
+ return newMatrixObject((float*)self->object->obmat,4,4,Py_WRAP, (BPy_GenericLib *)self);
}
/*
Modified: branches/pyapi_devel/source/blender/python/api2_2x/Pose.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Pose.c 2007-06-26 23:06:43 UTC (rev 11082)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Pose.c 2007-06-27 02:44:01 UTC (rev 11083)
@@ -568,7 +568,7 @@
//Gets the loc attribute
static PyObject *PoseBone_getLoc(BPy_PoseBone *self, void *closure)
{
- return newVectorObject(self->posechannel->loc, 3, Py_WRAP, (PyObject *)NULL);
+ return newVectorObject(self->posechannel->loc, 3, Py_WRAP, (BPy_GenericLib *)NULL);
}
//------------------------PoseBone.loc (setter)
//Sets the loc attribute
@@ -595,7 +595,7 @@
//Gets the size attribute
static PyObject *PoseBone_getSize(BPy_PoseBone *self, void *closure)
{
- return newVectorObject(self->posechannel->size, 3, Py_WRAP, (PyObject *)NULL);
+ return newVectorObject(self->posechannel->size, 3, Py_WRAP, (BPy_GenericLib *)NULL);
}
//------------------------PoseBone.size (setter)
//Sets the size attribute
@@ -647,7 +647,7 @@
//Gets the chan_mat
static PyObject *PoseBone_getLocalMatrix(BPy_PoseBone *self, void *closure)
{
- return newMatrixObject((float*)self->posechannel->chan_mat, 4, 4, Py_WRAP);
+ return newMatrixObject((float*)self->posechannel->chan_mat, 4, 4, Py_WRAP, (BPy_GenericLib *)NULL);
}
//------------------------PoseBone.localMatrix (setter)
//Sets the chan_mat
@@ -708,7 +708,7 @@
//Gets the pose_mat
static PyObject *PoseBone_getPoseMatrix(BPy_PoseBone *self, void *closure)
{
- return newMatrixObject((float*)self->posechannel->pose_mat, 4, 4, Py_WRAP);
+ return newMatrixObject((float*)self->posechannel->pose_mat, 4, 4, Py_WRAP, (BPy_GenericLib *)NULL);
}
//------------------------PoseBone.poseMatrix (setter)
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list