[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [11367] branches/pyapi_devel/source/ blender/python: TimeLine API rewrite

Campbell Barton cbarton at metavr.com
Wed Jul 25 15:01:45 CEST 2007


Revision: 11367
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=11367
Author:   campbellbarton
Date:     2007-07-25 15:01:44 +0200 (Wed, 25 Jul 2007)

Log Message:
-----------
TimeLine API rewrite
* now supports multiple markers per frame
* dictionary like access to data with the frame num as the key "sce.timeline[0] = ['marker1', 'marker2']"
* wont crash if the scene is removed from under it.

Some changes to sound as well as otehr misc changes.

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/BezTriple.c
    branches/pyapi_devel/source/blender/python/api2_2x/Curve.c
    branches/pyapi_devel/source/blender/python/api2_2x/Effect.c
    branches/pyapi_devel/source/blender/python/api2_2x/Lattice.c
    branches/pyapi_devel/source/blender/python/api2_2x/Mesh.c
    branches/pyapi_devel/source/blender/python/api2_2x/Modifier.c
    branches/pyapi_devel/source/blender/python/api2_2x/NLA.c
    branches/pyapi_devel/source/blender/python/api2_2x/Scene.c
    branches/pyapi_devel/source/blender/python/api2_2x/Sound.c
    branches/pyapi_devel/source/blender/python/api2_2x/Window.c
    branches/pyapi_devel/source/blender/python/api2_2x/World.c
    branches/pyapi_devel/source/blender/python/api2_2x/bpy_types.c
    branches/pyapi_devel/source/blender/python/api2_2x/matrix.c
    branches/pyapi_devel/source/blender/python/api2_2x/quat.c
    branches/pyapi_devel/source/blender/python/api2_2x/sceneTimeLine.c
    branches/pyapi_devel/source/blender/python/api2_2x/sceneTimeLine.h

Modified: branches/pyapi_devel/source/blender/python/BPY_interface.c
===================================================================
--- branches/pyapi_devel/source/blender/python/BPY_interface.c	2007-07-25 11:38:50 UTC (rev 11366)
+++ branches/pyapi_devel/source/blender/python/BPY_interface.c	2007-07-25 13:01:44 UTC (rev 11367)
@@ -1435,7 +1435,7 @@
 		return 0;
 	}
 
-	if (retval) {Py_XDECREF( retval );}
+	Py_XDECREF( retval );
 	retval = NULL;
 	
 	/* try to find USE_TARGET global constant */

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Armature.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Armature.c	2007-07-25 11:38:50 UTC (rev 11366)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Armature.c	2007-07-25 13:01:44 UTC (rev 11367)
@@ -511,12 +511,10 @@
 //------------------------Armature.__copy__()
 static PyObject *Armature_copy(BPyArmatureObject *self)
 {
-	PyObject *py_armature = NULL;
 	bArmature *bl_armature;
 	bl_armature= copy_armature(self->armature);
 	bl_armature->id.us= 0;
-	py_armature= Armature_CreatePyObject( bl_armature );
-	return py_armature;
+	return Armature_CreatePyObject( bl_armature );
 }
 
 //------------------ATTRIBUTE IMPLEMENTATION---------------------------

Modified: branches/pyapi_devel/source/blender/python/api2_2x/BezTriple.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/BezTriple.c	2007-07-25 11:38:50 UTC (rev 11366)
+++ branches/pyapi_devel/source/blender/python/api2_2x/BezTriple.c	2007-07-25 13:01:44 UTC (rev 11367)
@@ -567,6 +567,9 @@
 {
 	BPyBezTripleObject *pybeztriple;
 
+	if (!bzt)
+		Py_RETURN_NONE;
+	
 	pybeztriple =
 		( BPyBezTripleObject * ) PyObject_NEW( BPyBezTripleObject, &BPyBezTriple_Type );
 

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Curve.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Curve.c	2007-07-25 11:38:50 UTC (rev 11366)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Curve.c	2007-07-25 13:01:44 UTC (rev 11367)
@@ -905,12 +905,8 @@
 /* Description: Get the bevel object assign to the curve.                    */
 /*****************************************************************************/
 static PyObject *Curve_getBevOb( BPyCurveObject * self)
-{
-	if( self->curve->bevobj ) {
-		return Object_CreatePyObject( self->curve->bevobj );
-	}
-
-	return EXPP_incr_ret( Py_None );
+{	/* None is ok */
+	return Object_CreatePyObject( self->curve->bevobj );
 }
 
 /*****************************************************************************/
@@ -932,11 +928,8 @@
 /*****************************************************************************/
 
 static PyObject *Curve_getTaperOb( BPyCurveObject * self)
-{
-	if( self->curve->taperobj )
-		return Object_CreatePyObject( self->curve->taperobj );
-
-	Py_RETURN_NONE;
+{	/* None is ok */
+	return Object_CreatePyObject( self->curve->taperobj );
 }
 
 /*****************************************************************************/

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Effect.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Effect.c	2007-07-25 11:38:50 UTC (rev 11366)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Effect.c	2007-07-25 13:01:44 UTC (rev 11367)
@@ -875,7 +875,7 @@
 }
 
 static PyObject *Effect_getGroup( BPyEffectObject * self )
-{
+{	/* None is ok */
 	return Group_CreatePyObject( self->effect->group );
 }
 

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Lattice.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Lattice.c	2007-07-25 11:38:50 UTC (rev 11366)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Lattice.c	2007-07-25 13:01:44 UTC (rev 11367)
@@ -94,12 +94,7 @@
 
 static PyObject *Lattice_getKey( BPyLatticeObject * self )
 {
-	Key *key = self->lattice->key;
-
-	if (key)
-		return Key_CreatePyObject(key);
-	else
-		Py_RETURN_NONE;
+	return Key_CreatePyObject(self->lattice->key);
 }
 
 static PyObject *Lattice_setOutside( BPyLatticeObject * self, PyObject * value )

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Mesh.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Mesh.c	2007-07-25 11:38:50 UTC (rev 11366)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Mesh.c	2007-07-25 13:01:44 UTC (rev 11367)
@@ -7592,12 +7592,7 @@
 
 static PyObject *Mesh_getTexMesh( BPyMeshObject * self )
 {
-	Mesh *texme= self->mesh->texcomesh;
-	
-	if (texme)
-		return Mesh_CreatePyObject( texme, NULL );
-	else
-		Py_RETURN_NONE;
+	return Mesh_CreatePyObject( self->mesh->texcomesh, NULL );
 }
 
 static int Mesh_setTexMesh( BPyMeshObject * self, PyObject * value )
@@ -8001,7 +7996,12 @@
 
 PyObject *Mesh_CreatePyObject( Mesh * me, Object *obj )
 {
-	BPyMeshObject *nmesh = PyObject_NEW( BPyMeshObject, &BPyMesh_Type );
+	BPyMeshObject *nmesh;
+	
+	if (!me)
+		Py_RETURN_NONE;
+	
+	nmesh = PyObject_NEW( BPyMeshObject, &BPyMesh_Type );
 
 	if( !nmesh )
 		return EXPP_ReturnPyObjError( PyExc_MemoryError,

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Modifier.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Modifier.c	2007-07-25 11:38:50 UTC (rev 11366)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Modifier.c	2007-07-25 13:01:44 UTC (rev 11367)
@@ -881,8 +881,7 @@
 
 	switch( type ) {
 	case EXPP_MOD_TEXTURE:
-		if (md->texture)	Texture_CreatePyObject( md->texture );
-		else				Py_RETURN_NONE;
+		Texture_CreatePyObject( md->texture );
 	case EXPP_MOD_STRENGTH:
 		return PyFloat_FromDouble( (double)md->strength );
 	case EXPP_MOD_DIRECTION:

Modified: branches/pyapi_devel/source/blender/python/api2_2x/NLA.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/NLA.c	2007-07-25 11:38:50 UTC (rev 11366)
+++ branches/pyapi_devel/source/blender/python/api2_2x/NLA.c	2007-07-25 13:01:44 UTC (rev 11367)
@@ -644,12 +644,8 @@
 static PyObject *ActionStrip_getGroupTarget( BPyActionStripObject * self )
 {
 	ACTIONSTRIP_DEL_CHECK_PY(self);
-				
-	if (self->strip->object) {
-		return Object_CreatePyObject( self->strip->object );
-	} else {
-		Py_RETURN_NONE;
-	}
+	/* None is ok */
+	return Object_CreatePyObject( self->strip->object );
 }
 
 static int ActionStrip_setGroupTarget( BPyActionStripObject * self, PyObject * args )

Modified: branches/pyapi_devel/source/blender/python/api2_2x/Scene.c
===================================================================
--- branches/pyapi_devel/source/blender/python/api2_2x/Scene.c	2007-07-25 11:38:50 UTC (rev 11366)
+++ branches/pyapi_devel/source/blender/python/api2_2x/Scene.c	2007-07-25 13:01:44 UTC (rev 11367)
@@ -103,7 +103,6 @@
 static PyObject *Scene_getRadiosityContext( BPySceneObject * self );
 static PyObject *Scene_getSequence( BPySceneObject * self );
 static PyObject *Scene_play( BPySceneObject * self, PyObject * args );
-static PyObject *Scene_getTimeLine( BPySceneObject * self );
 
 
 /*internal*/
@@ -191,9 +190,6 @@
 static PyObject *Scene_getWorld( BPySceneObject * self )
 {
 	SCENE_DEL_CHECK_PY(self);
-	
-	if (!self->scene->world)
-		Py_RETURN_NONE;
 	return World_CreatePyObject(self->scene->world);
 }
 
@@ -242,7 +238,7 @@
 	 "Scene layer bitmask",
 	 NULL},
 	{"timeline",
-	 (getter)Scene_getTimeLine, (setter)NULL,
+	 (getter)TimeLine_CreatePyObject, (setter)NULL,
 	 "Scenes timeline (read only)",
 	 NULL},
 	{"render",
@@ -402,6 +398,9 @@
 {
 	BPySceneObject *pyscene;
 
+	if (!scene)
+		Py_RETURN_NONE;
+	
 	/* REUSE EXISTING DATA FROM HASH */
 	pyscene = (BPySceneObject *)BPY_idhash_get((ID *)scene);
 	if (pyscene)
@@ -478,10 +477,11 @@
 static PyObject *Scene_getSequence( BPySceneObject * self )
 {
 	SCENE_DEL_CHECK_PY(self);
-	if (self->scene->ed) /* we should create this if its not there :/ */
-		return SceneSeq_CreatePyObject( self->scene, NULL );
-	else
-		Py_RETURN_NONE;
+	if (!self->scene->ed) { /* we should create this if its not there :/ */
+		self->scene->ed = MEM_callocN( sizeof(Editing), "addseq");
+		((Editing *)self->scene->ed)->seqbasep= &((Editing *)self->scene->ed)->seqbase;
+	}
+	return SceneSeq_CreatePyObject( self->scene, NULL );
 }
 
 static PyObject *Scene_play( BPySceneObject * self, PyObject * args )
@@ -540,23 +540,6 @@
 	return ret;
 }
 
-static PyObject *Scene_getTimeLine( BPySceneObject *self ) 
-{
-	BPyTimeLineObject *tm; 
-
-	SCENE_DEL_CHECK_PY(self);
-	
-	tm= (BPyTimeLineObject *) PyObject_NEW (BPyTimeLineObject, &TimeLine_Type);
-	if (!tm)
-		return EXPP_ReturnPyObjError (PyExc_MemoryError,
-					      "couldn't create BPyTimeLineObject object");
-	tm->marker_list= &(self->scene->markers);
-	tm->sfra= (int) self->scene->r.sfra;
-	tm->efra= (int) self->scene->r.efra;
-
-	return (PyObject *)tm;
-}
-
 /************************************************************************
  *
  * Object Sequence 
@@ -690,7 +673,6 @@
 static PyObject *SceneObSeq_item( BPySceneObSeqObject * self, int i )
 {
 	int index=0;
-	PyObject *bpy_obj;
 	Base *base= NULL;
 	Scene *scene= self->bpyscene->scene;
 	
@@ -717,13 +699,7 @@
 		return EXPP_ReturnPyObjError( PyExc_IndexError,
 					      "array index out of range" );
 	
-	bpy_obj = Object_CreatePyObject( base->object );
-
-	if( !bpy_obj )
-		return EXPP_ReturnPyObjError( PyExc_RuntimeError,
-				"PyObject_New() failed" );
-
-	return (PyObject *)bpy_obj;
+	return Object_CreatePyObject( base->object );
 }
 
 static PySequenceMethods SceneObSeq_as_sequence = {
@@ -1045,9 +1021,7 @@
 
 PyObject *SceneObSeq_getActive(BPySceneObSeqObject *self)
 {
-	PyObject *pyob;
-	Base *base;
-	
+	Base *base;	
 	SCENE_DEL_CHECK_PY(self->bpyscene);
 	
 	if (self->mode!=EXPP_OBSEQ_NORMAL)
@@ -1058,13 +1032,7 @@
 	if (!base)
 		Py_RETURN_NONE;
 	
-	pyob = Object_CreatePyObject( base->object );
-	
-	if (!pyob)
-		return EXPP_ReturnPyObjError(PyExc_MemoryError,
-					"couldn't create new object wrapper!");
-	
-	return pyob;
+	return Object_CreatePyObject( base->object );
 }
 
 static int SceneObSeq_setActive(BPySceneObSeqObject *self, PyObject *value)
@@ -1098,26 +1066,13 @@
 
 PyObject *SceneObSeq_getCamera(BPySceneObSeqObject *self)
 {

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list