Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-08-16 18:06:24 +0400
committerCampbell Barton <ideasman42@gmail.com>2006-08-16 18:06:24 +0400
commit9ef3e8092bf5185fa67ab45be5a769b04490c787 (patch)
treef28b2c48911eb82c9eb6893d5ffd26b5d8d7f9fa /source
parentb92837c7c36d1f8d890c66e3693ea1c24efd8c9c (diff)
Added python __copy__ to Camera, Lattice, Metaball and World.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/Camera.c28
-rw-r--r--source/blender/python/api2_2x/Lattice.c26
-rw-r--r--source/blender/python/api2_2x/Metaball.c31
-rw-r--r--source/blender/python/api2_2x/World.c30
4 files changed, 115 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c
index a8625def1c9..395eb25a06f 100644
--- a/source/blender/python/api2_2x/Camera.c
+++ b/source/blender/python/api2_2x/Camera.c
@@ -122,6 +122,7 @@ static PyObject *Camera_getScriptLinks( BPy_Camera * self, PyObject * args );
static PyObject *Camera_addScriptLink( BPy_Camera * self, PyObject * args );
static PyObject *Camera_clearScriptLinks( BPy_Camera * self, PyObject * args );
static PyObject *Camera_insertIpoKey( BPy_Camera * self, PyObject * args );
+static PyObject *Camera_copy( BPy_Camera * self );
Camera *GetCameraByName( char *name );
@@ -184,6 +185,8 @@ static PyMethodDef BPy_Camera_methods[] = {
METH_NOARGS,
"() - Delete all scriptlinks from this camera.\n"
"([s1<,s2,s3...>]) - Delete specified scriptlinks from this camera."},
+ {"__copy__", ( PyCFunction ) Camera_copy, METH_NOARGS,
+ "() - Return a copy of the camera."},
{NULL, NULL, 0, NULL}
};
@@ -811,6 +814,31 @@ static PyObject *Camera_getScriptLinks( BPy_Camera * self, PyObject * args )
return NULL;
}
+/* cam.__copy__ */
+static PyObject *Camera_copy( BPy_Camera * self )
+{
+ PyObject *pycam; /* for Camera Data object wrapper in Python */
+ Camera *blcam; /* for actual Camera Data we create in Blender */
+
+ blcam = copy_camera( self->camera ); /* first create the Camera Data in Blender */
+
+ if( blcam ) /* now create the wrapper obj in Python */
+ pycam = Camera_CreatePyObject( blcam );
+ else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Camera Data in Blender" );
+
+ /* let's return user count to zero, because ... */
+ blcam->id.us = 0; /* ... copy_camera() incref'ed it */
+ /* XXX XXX Do this in other modules, too */
+
+ if( pycam == NULL )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Camera PyObject" );
+
+ return pycam;
+}
+
static void Camera_dealloc( BPy_Camera * self )
{
PyObject_DEL( self );
diff --git a/source/blender/python/api2_2x/Lattice.c b/source/blender/python/api2_2x/Lattice.c
index 117699adeb7..a85a69c4be2 100644
--- a/source/blender/python/api2_2x/Lattice.c
+++ b/source/blender/python/api2_2x/Lattice.c
@@ -99,6 +99,7 @@ static PyObject *Lattice_setPoint( BPy_Lattice * self, PyObject * args );
static PyObject *Lattice_getPoint( BPy_Lattice * self, PyObject * args );
static PyObject *Lattice_applyDeform( BPy_Lattice * self, PyObject *args );
static PyObject *Lattice_insertKey( BPy_Lattice * self, PyObject * args );
+static PyObject *Lattice_copy( BPy_Lattice * self );
/*****************************************************************************/
/* Lattice Strings */
@@ -146,6 +147,9 @@ mode). If forced, the deformation will be applied over any previous one(s).";
static char Lattice_insertKey_doc[] =
"(str) - Set a new key for the lattice at specified frame";
+static char Lattice_copy_doc[] =
+ "() - Return a copy of the lattice.";
+
/*****************************************************************************/
/* Python BPy_Lattice methods table: */
/*****************************************************************************/
@@ -177,6 +181,8 @@ static PyMethodDef BPy_Lattice_methods[] = {
Lattice_applyDeform_doc},
{"insertKey", ( PyCFunction ) Lattice_insertKey, METH_VARARGS,
Lattice_insertKey_doc},
+ {"__copy__", ( PyCFunction ) Lattice_copy, METH_NOARGS,
+ Lattice_copy_doc},
{NULL, NULL, 0, NULL}
};
@@ -769,6 +775,26 @@ static PyObject *Lattice_insertKey( BPy_Lattice * self, PyObject * args )
return Py_None;
}
+static PyObject *Lattice_copy( BPy_Lattice * self )
+{
+ Lattice *bl_Lattice; // blender Lattice object
+ PyObject *py_Lattice; // python wrapper
+
+ bl_Lattice = copy_lattice( self->Lattice );
+ bl_Lattice->id.us = 0;
+
+ if( bl_Lattice )
+ py_Lattice = Lattice_CreatePyObject( bl_Lattice );
+ else
+ return EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create Lattice Object in Blender" );
+ if( !py_Lattice )
+ return EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create Lattice Object wrapper" );
+
+ return py_Lattice;
+}
+
//***************************************************************************
// Function: Lattice_dealloc
// Description: This is a callback function for the BPy_Lattice type. It is
diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c
index 5987cee9e7a..c4ddac7d684 100644
--- a/source/blender/python/api2_2x/Metaball.c
+++ b/source/blender/python/api2_2x/Metaball.c
@@ -108,6 +108,7 @@ static PyObject *Metaball_getrot( BPy_Metaball * self );
static PyObject *Metaball_setrot( BPy_Metaball * self, PyObject * args );
static PyObject *Metaball_getsize( BPy_Metaball * self );
static PyObject *Metaball_setsize( BPy_Metaball * self, PyObject * args );
+static PyObject *Metaball_copy( BPy_Metaball * self );
/*****************************************************************************/
/* Python BPy_Metaball methods table: */
@@ -180,6 +181,8 @@ static PyMethodDef BPy_Metaball_methods[] = {
METH_NOARGS, "() - Gets Metaball size values"},
{"setsize", ( PyCFunction ) Metaball_setsize,
METH_VARARGS, "(f f f) - Sets Metaball size values"},
+ {"__copy__", ( PyCFunction ) Metaball_copy,
+ METH_NOARGS, "() - Return a copy of this metaball"},
{NULL, NULL, 0, NULL}
};
@@ -678,6 +681,34 @@ static PyObject *Metaball_setThresh( BPy_Metaball * self, PyObject * args )
}
+static PyObject *Metaball_copy( BPy_Metaball * self )
+{
+ BPy_Metaball *pymball; /* for Data object wrapper in Python */
+ MetaBall *blmball; /* for actual Data we create in Blender */
+
+ blmball = copy_mball( self->metaball ); /* first create the MetaBall Data in Blender */
+
+ if( blmball ) {
+ /* return user count to zero since add_mball() incref'ed it */
+ blmball->id.us = 0;
+ /* now create the wrapper obj in Python */
+ pymball =
+ ( BPy_Metaball * ) PyObject_NEW( BPy_Metaball,
+ &Metaball_Type );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create MetaBall Data in Blender" ) );
+
+ if( pymball == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create MetaBall Data object" ) );
+
+ pymball->metaball = blmball;
+
+ return ( PyObject * ) pymball;
+}
+
+
/**************************************************************************/
/* get/set metaelems data, */
/***************************************************************************/
diff --git a/source/blender/python/api2_2x/World.c b/source/blender/python/api2_2x/World.c
index 2e3e6d2d136..6d097ba62e2 100644
--- a/source/blender/python/api2_2x/World.c
+++ b/source/blender/python/api2_2x/World.c
@@ -95,6 +95,7 @@ static PyObject *World_getScriptLinks( BPy_World * self, PyObject * args );
static PyObject *World_addScriptLink( BPy_World * self, PyObject * args );
static PyObject *World_clearScriptLinks( BPy_World * self, PyObject * args );
static PyObject *World_setCurrent( BPy_World * self );
+static PyObject *World_copy( BPy_World * self );
/*****************************************************************************/
@@ -222,6 +223,8 @@ static PyMethodDef BPy_World_methods[] = {
"please use setCurrent instead, this alias will be removed."},
{"insertIpoKey", ( PyCFunction ) World_insertIpoKey, METH_VARARGS,
"( World IPO type ) - Inserts a key into the IPO"},
+ {"__copy__", ( PyCFunction ) World_copy, METH_NOARGS,
+ "() - Makes a copy of this world."},
{NULL, NULL, 0, NULL}
};
@@ -897,6 +900,33 @@ static PyObject *World_setCurrent( BPy_World * self )
return Py_None;
}
+/* world.__copy__ */
+static PyObject *World_copy( BPy_World * self )
+{
+ BPy_World *pyworld;
+ World *blworld;
+
+ blworld = copy_world( self->world );
+
+ if( blworld ) {
+ /* return user count to zero because add_world() inc'd it */
+ blworld->id.us = 0;
+ /* create python wrapper obj */
+ pyworld =
+ ( BPy_World * ) PyObject_NEW( BPy_World, &World_Type );
+ } else
+ return ( EXPP_ReturnPyObjError( PyExc_RuntimeError,
+ "couldn't create World Data in Blender" ) );
+
+ if( pyworld == NULL )
+ return ( EXPP_ReturnPyObjError( PyExc_MemoryError,
+ "couldn't create World Data object" ) );
+
+ pyworld->world = blworld;
+
+ return ( PyObject * ) pyworld;
+}
+
/*@{*/