[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11161] branches/pyapi_devel/source/ blender/python: made matrix, euler and quats use getseters
Campbell Barton
cbarton at metavr.com
Tue Jul 3 21:13:27 CEST 2007
Revision: 11161
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11161
Author: campbellbarton
Date: 2007-07-03 21:13:26 +0200 (Tue, 03 Jul 2007)
Log Message:
-----------
made matrix, euler and quats use getseters
made quats and eulers reference PyObjects (so they can check if they are removed)
removed Mathutils.Point PyType since it does not do anything a 3D vector cant and a lot of the code for vectors would need to be duplicated to fully support them.
Modified Paths:
--------------
branches/pyapi_devel/source/blender/python/BPY_interface.c
branches/pyapi_devel/source/blender/python/api2_2x/Armature.c
branches/pyapi_devel/source/blender/python/api2_2x/Bone.c
branches/pyapi_devel/source/blender/python/api2_2x/Effect.c
branches/pyapi_devel/source/blender/python/api2_2x/Mathutils.c
branches/pyapi_devel/source/blender/python/api2_2x/Mathutils.h
branches/pyapi_devel/source/blender/python/api2_2x/Metaball.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/Types.c
branches/pyapi_devel/source/blender/python/api2_2x/Window.c
branches/pyapi_devel/source/blender/python/api2_2x/bpy_list.c
branches/pyapi_devel/source/blender/python/api2_2x/euler.c
branches/pyapi_devel/source/blender/python/api2_2x/euler.h
branches/pyapi_devel/source/blender/python/api2_2x/gen_utils.h
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/quat.c
branches/pyapi_devel/source/blender/python/api2_2x/quat.h
branches/pyapi_devel/source/blender/python/api2_2x/vector.c
branches/pyapi_devel/source/blender/python/api2_2x/vector.h
Removed Paths:
-------------
branches/pyapi_devel/source/blender/python/api2_2x/point.c
branches/pyapi_devel/source/blender/python/api2_2x/point.h
Modified: branches/pyapi_devel/source/blender/python/BPY_interface.c
===================================================================
--- branches/pyapi_devel/source/blender/python/BPY_interface.c 2007-07-03 17:55:32 UTC (rev 11160)
+++ branches/pyapi_devel/source/blender/python/BPY_interface.c 2007-07-03 19:13:26 UTC (rev 11161)
@@ -187,10 +187,10 @@
* to NULL, after this, using this data will raise an error.
****************************************************************************/
-const GHash *bpy_idhash_text;
-const GHash *bpy_idhash_scene;
-const GHash *bpy_idhash_object;
-const GHash *bpy_idhash_group;
+GHash *bpy_idhash_text;
+GHash *bpy_idhash_scene;
+GHash *bpy_idhash_object;
+GHash *bpy_idhash_group;
static GHash * idhash__internal(ID *id)
{
@@ -1270,8 +1270,8 @@
globals = CreateGlobalDictionary();
- srcmat = newMatrixObject( (float*)obmat, 4, 4, Py_NEW, (BPy_GenericLib *)NULL );
- tarmat = newMatrixObject( (float*)targetmat, 4, 4, Py_NEW, (BPy_GenericLib *)NULL );
+ srcmat = newMatrixObject( (float*)obmat, 4, 4, (PyObject *)NULL );
+ tarmat = newMatrixObject( (float*)targetmat, 4, 4, (PyObject *)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, (BPy_GenericLib *)NULL );
+ tarmat = newMatrixObject( (float*)targetmat, 4, 4, (PyObject *)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/Armature.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Armature.c 2007-07-03 17:55:32 UTC (rev 11160)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Armature.c 2007-07-03 19:13:26 UTC (rev 11161)
@@ -523,9 +523,9 @@
static PyObject *Armature_getAutoIK(BPy_Armature *self, void *closure)
{
if (self->armature->flag & ARM_AUTO_IK)
- return EXPP_incr_ret(Py_True);
+ Py_RETURN_TRUE;
else
- return EXPP_incr_ret(Py_False);
+ Py_RETURN_FALSE;
}
//------------------------Armature.autoIK (setter)
static int Armature_setAutoIK(BPy_Armature *self, PyObject *value, void *closure)
@@ -617,9 +617,9 @@
static PyObject *Armature_getMirrorEdit(BPy_Armature *self, void *closure)
{
if (self->armature->flag & ARM_MIRROR_EDIT)
- return EXPP_incr_ret(Py_True);
+ Py_RETURN_TRUE;
else
- return EXPP_incr_ret(Py_False);
+ Py_RETURN_FALSE;
}
//------------------------Armature.mirrorEdit (setter)
static int Armature_setMirrorEdit(BPy_Armature *self, PyObject *value, void *closure)
@@ -752,9 +752,9 @@
static PyObject *Armature_getDrawNames(BPy_Armature *self, void *closure)
{
if (self->armature->flag & ARM_DRAWNAMES)
- return EXPP_incr_ret(Py_True);
+ Py_RETURN_TRUE;
else
- return EXPP_incr_ret(Py_False);
+ Py_RETURN_FALSE;
}
//------------------------Armature.drawNames (setter)
static int Armature_setDrawNames(BPy_Armature *self, PyObject *value, void *closure)
@@ -780,9 +780,9 @@
static PyObject *Armature_getDrawAxes(BPy_Armature *self, void *closure)
{
if (self->armature->flag & ARM_DRAWAXES)
- return EXPP_incr_ret(Py_True);
+ Py_RETURN_TRUE;
else
- return EXPP_incr_ret(Py_False);
+ Py_RETURN_FALSE;
}
//------------------------Armature.drawAxes (setter)
static int Armature_setDrawAxes(BPy_Armature *self, PyObject *value, void *closure)
@@ -808,9 +808,9 @@
static PyObject *Armature_getDelayDeform(BPy_Armature *self, void *closure)
{
if (self->armature->flag & ARM_DELAYDEFORM)
- return EXPP_incr_ret(Py_True);
+ Py_RETURN_TRUE;
else
- return EXPP_incr_ret(Py_False);
+ Py_RETURN_FALSE;
}
//------------------------Armature.delayDeform (setter)
static int Armature_setDelayDeform(BPy_Armature *self, PyObject *value, void *closure)
@@ -836,9 +836,9 @@
static PyObject *Armature_getRestPosition(BPy_Armature *self, void *closure)
{
if (self->armature->flag & ARM_RESTPOS)
- return EXPP_incr_ret(Py_True);
+ Py_RETURN_TRUE;
else
- return EXPP_incr_ret(Py_False);
+ Py_RETURN_FALSE;
}
//------------------------Armature.restPosition (setter)
static int Armature_setRestPosition(BPy_Armature *self, PyObject *value, void *closure)
@@ -864,9 +864,9 @@
static PyObject *Armature_getEnvelopes(BPy_Armature *self, void *closure)
{
if (self->armature->deformflag & ARM_DEF_ENVELOPE)
- return EXPP_incr_ret(Py_True);
+ Py_RETURN_TRUE;
else
- return EXPP_incr_ret(Py_False);
+ Py_RETURN_FALSE;
}
//------------------------Armature.envelopes (setter)
static int Armature_setEnvelopes(BPy_Armature *self, PyObject *value, void *closure)
@@ -892,9 +892,9 @@
static PyObject *Armature_getVertexGroups(BPy_Armature *self, void *closure)
{
if (self->armature->deformflag & ARM_DEF_VGROUP)
- return EXPP_incr_ret(Py_True);
+ Py_RETURN_TRUE;
else
- return EXPP_incr_ret(Py_False);
+ Py_RETURN_FALSE;
}
//------------------------Armature.vertexGroups (setter)
static int Armature_setVertexGroups(BPy_Armature *self, PyObject *value, void *closure)
Modified: branches/pyapi_devel/source/blender/python/api2_2x/Bone.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Bone.c 2007-07-03 17:55:32 UTC (rev 11160)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Bone.c 2007-07-03 19:13:26 UTC (rev 11161)
@@ -560,7 +560,7 @@
vec_roll_to_mat3(axis, self->roll, boneMatrix);
}
- return newMatrixObject((float*)boneMatrix, 3, 3, Py_NEW, (BPy_GenericLib *)NULL);
+ return newMatrixObject((float*)boneMatrix, 3, 3, (PyObject *)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, (BPy_GenericLib *)NULL);
- PyObject *val2 = newMatrixObject((float*)self->bone->arm_mat, 4,4, Py_WRAP, (BPy_GenericLib *)NULL);
+ PyObject *val1 = newMatrixObject((float*)self->bone->bone_mat, 3,3, (PyObject *)NULL);
+ PyObject *val2 = newMatrixObject((float*)self->bone->arm_mat, 4,4, (PyObject *)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/Effect.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Effect.c 2007-07-03 17:55:32 UTC (rev 11160)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Effect.c 2007-07-03 19:13:26 UTC (rev 11161)
@@ -1563,7 +1563,7 @@
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"Couldn't append item to PyList" );
}
-
+ Py_DECREF( strand_list );
} else {
if(c_time > pa->time && c_time < pa->time+pa->lifetime ) {
/* vector particles are a tuple of 2 vectors */
Modified: branches/pyapi_devel/source/blender/python/api2_2x/Mathutils.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Mathutils.c 2007-07-03 17:55:32 UTC (rev 11160)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Mathutils.c 2007-07-03 19:13:26 UTC (rev 11161)
@@ -65,7 +65,6 @@
static char M_Mathutils_TriangleNormal_doc[] = "(v1, v2, v3) - returns the normal of the 3D triangle defined";
static char M_Mathutils_QuadNormal_doc[] = "(v1, v2, v3, v4) - returns the normal of the 3D quad defined";
static char M_Mathutils_LineIntersect_doc[] = "(v1, v2, v3, v4) - returns a tuple with the points on each line respectively closest to the other";
-static char M_Mathutils_Point_doc[] = "Creates a 2d or 3d point object";
//-----------------------METHOD DEFINITIONS ----------------------
struct PyMethodDef M_Mathutils_methods[] = {
{"Rand", (PyCFunction) M_Mathutils_Rand, METH_VARARGS, M_Mathutils_Rand_doc},
@@ -92,7 +91,6 @@
{"TriangleNormal", ( PyCFunction ) M_Mathutils_TriangleNormal, METH_VARARGS, M_Mathutils_TriangleNormal_doc},
{"QuadNormal", ( PyCFunction ) M_Mathutils_QuadNormal, METH_VARARGS, M_Mathutils_QuadNormal_doc},
{"LineIntersect", ( PyCFunction ) M_Mathutils_LineIntersect, METH_VARARGS, M_Mathutils_LineIntersect_doc},
- {"Point", (PyCFunction) M_Mathutils_Point, METH_VARARGS, M_Mathutils_Point_doc},
{NULL, NULL, 0, NULL}
};
//----------------------------MODULE INIT-------------------------
@@ -153,36 +151,7 @@
}
return newVectorObject(vecNew, vec->size, (PyObject *)NULL);
}
-//This is a helper for point/matrix translation
-PyObject *column_point_multiplication(MatrixObject * mat, PointObject* pt)
-{
- float ptNew[4], ptCopy[4];
- double dot = 0.0f;
- int x, y, z = 0;
-
- if(mat->rowSize != pt->size){
- if(mat->rowSize == 4 && pt->size != 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "matrix * point: matrix row size and point size must be the same\n");
- }else{
- ptCopy[3] = 0.0f;
- }
- }
-
- for(x = 0; x < pt->size; x++){
- ptCopy[x] = pt->coord[x];
- }
-
- for(x = 0; x < mat->rowSize; x++) {
- for(y = 0; y < mat->colSize; y++) {
- dot += mat->matrix[x][y] * ptCopy[y];
- }
- ptNew[z++] = (float)dot;
- dot = 0.0f;
- }
- return newPointObject(ptNew, pt->size, Py_NEW);
-}
//-----------------row_vector_multiplication (internal)-----------
//ROW VECTOR Multiplication - Vector X Matrix
//[x][y][z] * [1][2][3]
@@ -218,36 +187,7 @@
}
return newVectorObject(vecNew, vec_size, (PyObject *)NULL);
}
-//This is a helper for the point class
-PyObject *row_point_multiplication(PointObject* pt, MatrixObject * mat)
-{
- float ptNew[4], ptCopy[4];
- double dot = 0.0f;
- int x, y, z = 0, size;
- if(mat->colSize != pt->size){
- if(mat->rowSize == 4 && pt->size != 3){
- return EXPP_ReturnPyObjError(PyExc_AttributeError,
- "point * matrix: matrix column size and the point size must be the same\n");
- }else{
- ptCopy[3] = 0.0f;
- }
- }
- size = pt->size;
- for(x = 0; x < pt->size; x++){
- ptCopy[x] = pt->coord[x];
- }
-
- //muliplication
- for(x = 0; x < mat->colSize; x++) {
- for(y = 0; y < mat->rowSize; y++) {
- dot += mat->matrix[y][x] * ptCopy[y];
- }
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list