[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11346] branches/pyapi_devel/source/ blender/python/api2_2x: remove old constant type.
Campbell Barton
cbarton at metavr.com
Mon Jul 23 08:16:25 CEST 2007
Revision: 11346
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11346
Author: campbellbarton
Date: 2007-07-23 08:16:25 +0200 (Mon, 23 Jul 2007)
Log Message:
-----------
remove old constant type. that has been replaced with khpython's
made the BPyPose reference a BPyObject rather then a bPose pointer (more reliable).
Modified Paths:
--------------
branches/pyapi_devel/source/blender/python/api2_2x/NLA.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/Pose.h
branches/pyapi_devel/source/blender/python/api2_2x/Texture.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_types.c
branches/pyapi_devel/source/blender/python/api2_2x/sceneRadio.c
branches/pyapi_devel/source/blender/python/api2_2x/sceneRender.c
Removed Paths:
-------------
branches/pyapi_devel/source/blender/python/api2_2x/constant.c
branches/pyapi_devel/source/blender/python/api2_2x/constant.h
Modified: branches/pyapi_devel/source/blender/python/api2_2x/NLA.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/NLA.c 2007-07-23 05:18:18 UTC (rev 11345)
+++ branches/pyapi_devel/source/blender/python/api2_2x/NLA.c 2007-07-23 06:16:25 UTC (rev 11346)
@@ -41,7 +41,6 @@
#include "BKE_main.h"
#include "BKE_library.h"
#include "BLI_blenlib.h"
-#include "constant.h"
#include "BIF_editaction.h"
#include "Object.h"
#include "Ipo.h"
Modified: branches/pyapi_devel/source/blender/python/api2_2x/Object.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Object.c 2007-07-23 05:18:18 UTC (rev 11345)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Object.c 2007-07-23 06:16:25 UTC (rev 11346)
@@ -213,7 +213,6 @@
static PyObject *Object_getInverseMatrix( BPyObject * self );
static PyObject *Object_getIpo( BPyObject * self );
static PyObject *Object_getLocation( BPyObject * self, PyObject * args );
-static PyObject *Object_getMatrix( BPyObject * self, PyObject * args );
static PyObject *Object_getParent( BPyObject * self );
static PyObject *Object_getParentBoneName( BPyObject * self );
static int Object_setParentBoneName( BPyObject * self, PyObject * value );
@@ -560,7 +559,7 @@
static PyObject * Object_getPose(BPyObject *self)
{
/*if there is no pose will return PyNone*/
- return PyPose_FromPose(self->object->pose, self->object->id.name+2);
+ return Pose_CreatePyObject(self);
}
static PyObject *Object_getSelected( BPyObject * self )
@@ -3555,14 +3554,10 @@
/*****************************************************************************/
PyObject *Object_Init( void )
{
- PyObject *module, *dict;
- module = Py_InitModule3( "Blender.Object", NULL, M_Object_doc );
+ PyObject *module = Py_InitModule3( "Blender.Object", NULL, M_Object_doc );
PyType_Ready( &BPySoftBody_Type ) ;
ObjectType_Init( );
- dict = PyModule_GetDict( module ); /*borrowed*/
- PyDict_SetItemString(dict, "Pose", Pose_Init()); /*creates a *new* module*/
-
return module;
}
Modified: branches/pyapi_devel/source/blender/python/api2_2x/Pose.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Pose.c 2007-07-23 05:18:18 UTC (rev 11345)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Pose.c 2007-07-23 06:16:25 UTC (rev 11346)
@@ -54,7 +54,6 @@
#include "NLA.h"
#include "gen_utils.h"
#include "gen_library.h"
-#include "constant.h"
#include "DNA_armature_types.h" /*used for pose bone select*/
extern void chan_calc_mat(bPoseChannel *chan);
@@ -259,7 +258,7 @@
goto RuntimeError;
//set listbase pointer
- py_posebonesdict->bones = &py_pose->pose->chanbase;
+ py_posebonesdict->bones = &py_pose->bpyob->object->pose->chanbase;
//now that everything is setup - init the mappings
if (!PoseBonesDict_InitBones(py_posebonesdict))
@@ -278,19 +277,9 @@
//------------------METHOD IMPLEMENTATIONS------------------------------
static PyObject *Pose_update(BPyPoseObject *self)
{
- Object *daddy = NULL;
+ self->bpyob->object->pose->flag |= POSE_RECALC;
+ where_is_pose(self->bpyob->object);
- self->pose->flag |= POSE_RECALC;
-
- for (daddy = G.main->object.first; daddy; daddy = daddy->id.next){
- if (daddy->pose == self->pose){
- break;
- }
- }
-
- if(daddy)
- where_is_pose(daddy);
-
Py_RETURN_NONE;
}
//------------------------tp_methods
@@ -329,6 +318,7 @@
//This tells how to 'tear-down' our object when ref count hits 0
static void Pose_dealloc(BPyPoseObject *self)
{
+ Py_DECREF(self->bpyob);
Py_DECREF(self->Bones);
BPyPose_Type.tp_free(self);
return;
@@ -337,13 +327,13 @@
//This compares 2 pose types
static int Pose_compare(BPyPoseObject *a, BPyPoseObject *b )
{
- return ( a->pose== b->pose ) ? 0 : -1;
+ return ( a->bpyob->object== b->bpyob->object ) ? 0 : -1;
}
//------------------------tp_repr
//This is the string representation of the object
static PyObject *Pose_repr(BPyPoseObject *self)
{
- return PyString_FromFormat( "[Pose \"%s\"]", self->name);
+ return PyString_FromFormat( "[Pose \"%s\"]", self->bpyob->object->id.name);
}
//------------------------tp_doc
//The __doc__ string for this object
@@ -451,18 +441,6 @@
Py_DECREF(item);
}
self->posechannel->flag = (short)numeric_value;
- }else if (BPyConstant_Check(constants)){
- if (constants == EXPP_GetModuleConstant("Blender.Object.Pose", "ROT")){
- numeric_value |= POSE_ROT;
- }else if (constants == EXPP_GetModuleConstant("Blender.Object.Pose", "LOC")){
- numeric_value |= POSE_LOC;
- }else if (constants == EXPP_GetModuleConstant("Blender.Object.Pose", "SIZE")){
- numeric_value |= POSE_SIZE;
- }else{
- self->posechannel->flag = (short)oldflag;
- goto AttributeError4;
- }
- self->posechannel->flag = (short)numeric_value;
}else{
goto AttributeError3;
}
@@ -1164,64 +1142,35 @@
0 //tp_del
};
//-------------------MODULE METHODS IMPLEMENTATION------------------------
-//-------------------MODULE INITIALIZATION--------------------------------
-PyObject *Pose_Init(void)
-{
- PyObject *module;
-
- //Initializes TypeObject.ob_type
- if (PyType_Ready(&BPyPose_Type) < 0 || PyType_Ready(&BPyPoseBone_Type) < 0 ||
- PyType_Ready(&BPyPoseBoneDict_Type) < 0) {
- Py_RETURN_NONE;
- }
-
- //Register the module
- module = Py_InitModule3("Blender.Object.Pose", NULL, "The Blender Pose module");
-
- //Add TYPEOBJECTS to the module
- PyModule_AddObject(module, "Pose",
- EXPP_incr_ret((PyObject *)&BPyPose_Type)); //*steals*
- PyModule_AddObject(module, "PoseBone",
- EXPP_incr_ret((PyObject *)&BPyPoseBone_Type)); //*steals*
-
- //Add CONSTANTS to the module
- PyModule_AddObject(module, "ROT",
- PyConstant_NewInt("ROT", POSE_ROT));
- PyModule_AddObject(module, "LOC",
- PyConstant_NewInt("LOC", POSE_LOC));
- PyModule_AddObject(module, "SIZE",
- PyConstant_NewInt("SIZE", POSE_SIZE));
-
- return module;
-}
//------------------VISIBLE PROTOTYPE IMPLEMENTATION-----------------------
-//------------------------------PyPose_FromPose (internal)
+//------------------------------Pose_CreatePyObject (internal)
//Returns a PyPose from a bPose - return PyNone if bPose is NULL
-PyObject *PyPose_FromPose(bPose *pose, char *name)
+PyObject *Pose_CreatePyObject(BPyObject *bpyob)
{
BPyPoseObject *py_pose = NULL;
- if (pose){
- py_pose = (BPyPoseObject*)BPyPose_Type.tp_alloc(&BPyPose_Type, 0);
- if (!py_pose)
- goto RuntimeError;
+ if (!bpyob->object->pose)
+ Py_RETURN_NONE;
+
+ py_pose =
+ ( BPyPoseObject * ) PyObject_NEW( BPyPoseObject, &BPyPose_Type );
- py_pose->pose = pose;
- BLI_strncpy(py_pose->name, name, 24);
+ if (!py_pose)
+ goto RuntimeError;
- //create armature.bones
- py_pose->Bones = (BPyPoseBoneDictObject*)PyPoseBonesDict_FromPyPose(py_pose);
- if (!py_pose->Bones)
- goto RuntimeError;
+ py_pose->bpyob = bpyob;
+ Py_INCREF(bpyob);
- return (PyObject*)py_pose;
- }else{
- Py_RETURN_NONE;
- }
+ //create armature.bones
+ py_pose->Bones = (BPyPoseBoneDictObject*)PyPoseBonesDict_FromPyPose(py_pose);
+ if (!py_pose->Bones)
+ goto RuntimeError;
+ return (PyObject*)py_pose;
+
RuntimeError:
return EXPP_objError(PyExc_RuntimeError, "%s%s%s",
- sPoseError, "PyPose_FromPose: ", "Internal Error Ocurred");
+ sPoseError, "Pose_CreatePyObject: ", "Internal Error Ocurred");
}
//------------------------------PyPoseBone_FromPosechannel (internal)
//Returns a PyPoseBone from a bPoseChannel - return PyNone if bPoseChannel is NULL
@@ -1264,3 +1213,31 @@
}
return obj;
}
+
+
+//-------------------MODULE INITIALIZATION--------------------------------
+
+PyObject *PoseType_Init(void)
+{
+ PyType_Ready( &BPyPose_Type );
+ return (PyObject *) &BPyPose_Type;
+}
+
+PyObject *PoseBoneType_Init(void)
+{
+ PyType_Ready( &BPyPoseBone_Type );
+ return (PyObject *) &BPyPoseBone_Type;
+}
+
+PyObject *PoseBoneDictType_Init(void)
+{
+ PyType_Ready( &BPyPoseBoneDict_Type );
+ return (PyObject *) &BPyPoseBoneDict_Type;
+}
+
+void Pose_Init(void)
+{
+ PoseType_Init();
+ PoseBoneType_Init();
+ PoseBoneDictType_Init();
+}
Modified: branches/pyapi_devel/source/blender/python/api2_2x/Pose.h
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Pose.h 2007-07-23 05:18:18 UTC (rev 11345)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Pose.h 2007-07-23 06:16:25 UTC (rev 11346)
@@ -34,6 +34,7 @@
#include <Python.h>
#include "DNA_action_types.h"
#include "DNA_object_types.h"
+#include "Object.h"
//-------------------TYPE CHECKS---------------------------------
#define BPyPose_Check(v) ((v)->ob_type == &BPyPose_Type)
@@ -52,8 +53,7 @@
typedef struct {
PyObject_HEAD
- bPose *pose;
- char name[24]; //because poses have not names :(
+ BPyObject *bpyob;
BPyPoseBoneDictObject *Bones;
} BPyPoseObject;
@@ -64,8 +64,13 @@
} BPyPoseBoneObject;
//-------------------VISIBLE PROTOTYPES-------------------------
-PyObject *Pose_Init(void);
-PyObject *PyPose_FromPose(bPose *pose, char *name);
+void Pose_Init(void);
+
+PyObject *PoseType_Init(void);
+PyObject *PoseBoneType_Init(void);
+PyObject *PoseBoneDictType_Init(void);
+
+PyObject *Pose_CreatePyObject(BPyObject *bpyob);
PyObject *PyPoseBone_FromPosechannel(bPoseChannel *pchan);
Object *Object_FromPoseChannel(bPoseChannel *curr_pchan);
#endif
Modified: branches/pyapi_devel/source/blender/python/api2_2x/Texture.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Texture.c 2007-07-23 05:18:18 UTC (rev 11345)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Texture.c 2007-07-23 06:16:25 UTC (rev 11346)
@@ -63,7 +63,6 @@
#include "color.h" /* for Texture_evaluate(vec) */
#include "Material.h" /* for EXPP_Colorband_fromPyList and EXPP_PyList_fromColorband */
#include "RE_shader_ext.h"
-#include "constant.h"
#include "Const.h"
#include "color.h"
#include "vector.h"
Modified: branches/pyapi_devel/source/blender/python/api2_2x/Types.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Types.c 2007-07-23 05:18:18 UTC (rev 11345)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Types.c 2007-07-23 06:16:25 UTC (rev 11346)
@@ -59,7 +59,7 @@
extern PyTypeObject BPyText_Type, BPyText3d_Type, BPyTexture_Type;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list