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
diff options
context:
space:
mode:
authorWillian Padovani Germano <wpgermano@gmail.com>2003-10-28 03:29:37 +0300
committerWillian Padovani Germano <wpgermano@gmail.com>2003-10-28 03:29:37 +0300
commit9c6275c55babe03f377b4897dbf87341c3f80fda (patch)
treed71f3f9526207bb3cb68850089ccb66f5a901849
parentbfef1d0d92a8a3e9e75ab337b7e9add9fae4e08b (diff)
Exppython:
- Small fix in NMesh.c - Updates to ipo related methods in Camera, World and Material - Doc updates
-rw-r--r--source/blender/python/api2_2x/Camera.c797
-rw-r--r--source/blender/python/api2_2x/Camera.h5
-rw-r--r--source/blender/python/api2_2x/Ipo.c76
-rw-r--r--source/blender/python/api2_2x/Ipo.h58
-rw-r--r--source/blender/python/api2_2x/Material.c86
-rw-r--r--source/blender/python/api2_2x/Material.h16
-rw-r--r--source/blender/python/api2_2x/NMesh.c20
-rw-r--r--source/blender/python/api2_2x/NMesh.h8
-rw-r--r--source/blender/python/api2_2x/World.c413
-rw-r--r--source/blender/python/api2_2x/World.h7
-rw-r--r--source/blender/python/api2_2x/doc/Camera.py29
-rw-r--r--source/blender/python/api2_2x/doc/Material.py31
-rw-r--r--source/blender/python/api2_2x/doc/NMesh.py4
-rw-r--r--source/blender/python/api2_2x/doc/World.py30
14 files changed, 892 insertions, 688 deletions
diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c
index 01bb3f91075..154e68673f8 100644
--- a/source/blender/python/api2_2x/Camera.c
+++ b/source/blender/python/api2_2x/Camera.c
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -37,193 +37,192 @@
#include "Camera.h"
-
/*****************************************************************************/
-/* Python Camera_Type structure definition: */
+/* Python Camera_Type structure definition: */
/*****************************************************************************/
PyTypeObject Camera_Type =
{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Blender Camera", /* tp_name */
- sizeof (BPy_Camera), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)Camera_dealloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)Camera_getAttr, /* tp_getattr */
- (setattrfunc)Camera_setAttr, /* tp_setattr */
- (cmpfunc)Camera_compare, /* tp_compare */
- (reprfunc)Camera_repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0,0,0,0,0,0,
- 0, /* tp_doc */
- 0,0,0,0,0,0,
- BPy_Camera_methods, /* tp_methods */
- 0, /* tp_members */
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "Blender Camera", /* tp_name */
+ sizeof (BPy_Camera), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)Camera_dealloc, /* tp_dealloc */
+ 0, /* tp_print */
+ (getattrfunc)Camera_getAttr, /* tp_getattr */
+ (setattrfunc)Camera_setAttr, /* tp_setattr */
+ (cmpfunc)Camera_compare, /* tp_compare */
+ (reprfunc)Camera_repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_as_hash */
+ 0,0,0,0,0,0,
+ 0, /* tp_doc */
+ 0,0,0,0,0,0,
+ BPy_Camera_methods, /* tp_methods */
+ 0, /* tp_members */
};
static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
{
- char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */
- char *name_str = "CamData";
- static char *kwlist[] = {"type_str", "name_str", NULL};
- PyObject *pycam; /* for Camera Data object wrapper in Python */
- Camera *blcam; /* for actual Camera Data we create in Blender */
- char buf[21];
-
- /* Parse the arguments passed in by the Python interpreter */
- if (!PyArg_ParseTupleAndKeywords(args, kwords, "|ss", kwlist,
- &type_str, &name_str))
- /* We expected string(s) (or nothing) as argument, but we didn't get that. */
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected zero, one or two strings as arguments");
-
- blcam = add_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; /* ... add_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");
-
- if (strcmp (type_str, "persp") == 0) /* default, no need to set, so */
- /*blcam->type = (short)EXPP_CAM_TYPE_PERSP*/; /* we comment this line */
- else if (strcmp (type_str, "ortho") == 0)
- blcam->type = (short)EXPP_CAM_TYPE_ORTHO;
- else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown camera type");
-
- if (strcmp (name_str, "CamData") == 0)
- return pycam;
- else { /* user gave us a name for the camera, use it */
- PyOS_snprintf (buf, sizeof(buf), "%s", name_str);
- rename_id (&blcam->id, buf); /* proper way in Blender */
- }
-
- return pycam;
+ char *type_str = "persp"; /* "persp" is type 0, "ortho" is type 1 */
+ char *name_str = "CamData";
+ static char *kwlist[] = {"type_str", "name_str", NULL};
+ PyObject *pycam; /* for Camera Data object wrapper in Python */
+ Camera *blcam; /* for actual Camera Data we create in Blender */
+ char buf[21];
+
+ /* Parse the arguments passed in by the Python interpreter */
+ if (!PyArg_ParseTupleAndKeywords(args, kwords, "|ss", kwlist,
+ &type_str, &name_str))
+ /* We expected string(s) (or nothing) as argument, but we didn't get that. */
+ return EXPP_ReturnPyObjError (PyExc_AttributeError,
+ "expected zero, one or two strings as arguments");
+
+ blcam = add_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; /* ... add_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");
+
+ if (strcmp (type_str, "persp") == 0) /* default, no need to set, so */
+ /*blcam->type = (short)EXPP_CAM_TYPE_PERSP*/; /* we comment this line */
+ else if (strcmp (type_str, "ortho") == 0)
+ blcam->type = (short)EXPP_CAM_TYPE_ORTHO;
+ else
+ return EXPP_ReturnPyObjError (PyExc_AttributeError,
+ "unknown camera type");
+
+ if (strcmp (name_str, "CamData") == 0)
+ return pycam;
+ else { /* user gave us a name for the camera, use it */
+ PyOS_snprintf (buf, sizeof(buf), "%s", name_str);
+ rename_id (&blcam->id, buf); /* proper way in Blender */
+ }
+
+ return pycam;
}
static PyObject *M_Camera_Get(PyObject *self, PyObject *args)
{
- char *name = NULL;
- Camera *cam_iter;
+ char *name = NULL;
+ Camera *cam_iter;
- if (!PyArg_ParseTuple(args, "|s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument (or nothing)");
+ if (!PyArg_ParseTuple(args, "|s", &name))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected string argument (or nothing)");
- cam_iter = G.main->camera.first;
+ cam_iter = G.main->camera.first;
- if (name) { /* (name) - Search camera by name */
+ if (name) { /* (name) - Search camera by name */
- PyObject *wanted_cam = NULL;
+ PyObject *wanted_cam = NULL;
- while (cam_iter && !wanted_cam) {
+ while (cam_iter && !wanted_cam) {
- if (strcmp (name, cam_iter->id.name+2) == 0) {
- wanted_cam = Camera_CreatePyObject (cam_iter);
- break;
- }
+ if (strcmp (name, cam_iter->id.name+2) == 0) {
+ wanted_cam = Camera_CreatePyObject (cam_iter);
+ break;
+ }
- cam_iter = cam_iter->id.next;
- }
+ cam_iter = cam_iter->id.next;
+ }
- if (!wanted_cam) { /* Requested camera doesn't exist */
- char error_msg[64];
- PyOS_snprintf(error_msg, sizeof(error_msg),
- "Camera \"%s\" not found", name);
- return EXPP_ReturnPyObjError (PyExc_NameError, error_msg);
- }
+ if (!wanted_cam) { /* Requested camera doesn't exist */
+ char error_msg[64];
+ PyOS_snprintf(error_msg, sizeof(error_msg),
+ "Camera \"%s\" not found", name);
+ return EXPP_ReturnPyObjError (PyExc_NameError, error_msg);
+ }
- return wanted_cam;
- }
+ return wanted_cam;
+ }
- else { /* () - return a list of wrappers for all cameras in the scene */
- int index = 0;
- PyObject *cam_pylist, *pyobj;
+ else { /* () - return a list of wrappers for all cameras in the scene */
+ int index = 0;
+ PyObject *cam_pylist, *pyobj;
- cam_pylist = PyList_New (BLI_countlist (&(G.main->camera)));
+ cam_pylist = PyList_New (BLI_countlist (&(G.main->camera)));
- if (!cam_pylist)
- return PythonReturnErrorObject (PyExc_MemoryError,
- "couldn't create PyList");
+ if (!cam_pylist)
+ return PythonReturnErrorObject (PyExc_MemoryError,
+ "couldn't create PyList");
- while (cam_iter) {
- pyobj = Camera_CreatePyObject (cam_iter);
+ while (cam_iter) {
+ pyobj = Camera_CreatePyObject (cam_iter);
- if (!pyobj)
- return PythonReturnErrorObject (PyExc_MemoryError,
- "couldn't create Camera PyObject");
+ if (!pyobj)
+ return PythonReturnErrorObject (PyExc_MemoryError,
+ "couldn't create Camera PyObject");
- PyList_SET_ITEM (cam_pylist, index, pyobj);
+ PyList_SET_ITEM (cam_pylist, index, pyobj);
- cam_iter = cam_iter->id.next;
- index++;
- }
+ cam_iter = cam_iter->id.next;
+ index++;
+ }
- return cam_pylist;
- }
+ return cam_pylist;
+ }
}
PyObject *Camera_Init (void)
{
- PyObject *submodule;
+ PyObject *submodule;
- Camera_Type.ob_type = &PyType_Type;
+ Camera_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.Camera",
- M_Camera_methods, M_Camera_doc);
+ submodule = Py_InitModule3("Blender.Camera",
+ M_Camera_methods, M_Camera_doc);
- return submodule;
+ return submodule;
}
/* Three Python Camera_Type helper functions needed by the Object module: */
PyObject *Camera_CreatePyObject (Camera *cam)
{
- BPy_Camera *pycam;
+ BPy_Camera *pycam;
- pycam = (BPy_Camera *)PyObject_NEW (BPy_Camera, &Camera_Type);
+ pycam = (BPy_Camera *)PyObject_NEW (BPy_Camera, &Camera_Type);
- if (!pycam)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create BPy_Camera PyObject");
+ if (!pycam)
+ return EXPP_ReturnPyObjError (PyExc_MemoryError,
+ "couldn't create BPy_Camera PyObject");
- pycam->camera = cam;
+ pycam->camera = cam;
- return (PyObject *)pycam;
+ return (PyObject *)pycam;
}
int Camera_CheckPyObject (PyObject *pyobj)
{
- return (pyobj->ob_type == &Camera_Type);
+ return (pyobj->ob_type == &Camera_Type);
}
Camera *Camera_FromPyObject (PyObject *pyobj)
{
- return ((BPy_Camera *)pyobj)->camera;
+ return ((BPy_Camera *)pyobj)->camera;
}
/*****************************************************************************/
-/* Description: Returns the object with the name specified by the argument */
-/* name. Note that the calling function has to remove the first */
-/* two characters of the object name. These two characters */
-/* specify the type of the object (OB, ME, WO, ...) */
-/* The function will return NULL when no object with the given */
-/* name is found. */
+/* Description: Returns the object with the name specified by the argument */
+/* name. Note that the calling function has to remove the first */
+/* two characters of the object name. These two characters */
+/* specify the type of the object (OB, ME, WO, ...) */
+/* The function will return NULL when no object with the given */
+/* name is found. */
/*****************************************************************************/
Camera * GetCameraByName (char * name)
{
@@ -244,145 +243,176 @@ Camera * GetCameraByName (char * name)
}
/*****************************************************************************/
-/* Python BPy_Camera methods: */
+/* Python BPy_Camera methods: */
/*****************************************************************************/
-
-#include <DNA_ipo_types.h>
-
-
static PyObject *Camera_getIpo(BPy_Camera *self)
{
-PyObject *Ipo_CreatePyObject (Ipo *ipo);
- struct Ipo*ipo = self->camera->ipo;
- if (!ipo) return EXPP_ReturnPyObjError(PyExc_RuntimeError,"Camera has no Ipo");
+ struct Ipo *ipo = self->camera->ipo;
+
+ if (!ipo) {
+ Py_INCREF (Py_None);
+ return Py_None;
+ }
+
return Ipo_CreatePyObject (ipo);
}
-
static PyObject *Camera_getName(BPy_Camera *self)
{
- PyObject *attr = PyString_FromString(self->camera->id.name+2);
+ PyObject *attr = PyString_FromString(self->camera->id.name+2);
- if (attr) return attr;
+ if (attr) return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.name attribute");
+ return EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "couldn't get Camera.name attribute");
}
static PyObject *Camera_getType(BPy_Camera *self)
{
- PyObject *attr = PyInt_FromLong(self->camera->type);
+ PyObject *attr = PyInt_FromLong(self->camera->type);
- if (attr) return attr;
+ if (attr) return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.type attribute");
+ return EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "couldn't get Camera.type attribute");
}
static PyObject *Camera_getMode(BPy_Camera *self)
{
- PyObject *attr = PyInt_FromLong(self->camera->flag);
+ PyObject *attr = PyInt_FromLong(self->camera->flag);
- if (attr) return attr;
+ if (attr) return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.Mode attribute");
+ return EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "couldn't get Camera.Mode attribute");
}
static PyObject *Camera_getLens(BPy_Camera *self)
{
- PyObject *attr = PyFloat_FromDouble(self->camera->lens);
+ PyObject *attr = PyFloat_FromDouble(self->camera->lens);
- if (attr) return attr;
+ if (attr) return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.lens attribute");
+ return EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "couldn't get Camera.lens attribute");
}
static PyObject *Camera_getClipStart(BPy_Camera *self)
{
- PyObject *attr = PyFloat_FromDouble(self->camera->clipsta);
+ PyObject *attr = PyFloat_FromDouble(self->camera->clipsta);
- if (attr) return attr;
+ if (attr) return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.clipStart attribute");
+ return EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "couldn't get Camera.clipStart attribute");
}
static PyObject *Camera_getClipEnd(BPy_Camera *self)
{
- PyObject *attr = PyFloat_FromDouble(self->camera->clipend);
+ PyObject *attr = PyFloat_FromDouble(self->camera->clipend);
- if (attr) return attr;
+ if (attr) return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.clipEnd attribute");
+ return EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "couldn't get Camera.clipEnd attribute");
}
static PyObject *Camera_getDrawSize(BPy_Camera *self)
{
- PyObject *attr = PyFloat_FromDouble(self->camera->drawsize);
+ PyObject *attr = PyFloat_FromDouble(self->camera->drawsize);
- if (attr) return attr;
+ if (attr) return attr;
- return EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get Camera.drawSize attribute");
+ return EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "couldn't get Camera.drawSize attribute");
}
-
static PyObject *Camera_setIpo(BPy_Camera *self, PyObject *args)
{
-int camera_assignIpo(Camera*,Ipo*);
- PyObject *ipo = 0;
- Ipo*ptr;
- Ipo *Ipo_FromPyObject (PyObject *pyobj);
+ PyObject *pyipo = 0;
+ Ipo *ipo = NULL;
+ Ipo *oldipo;
+
+ if (!PyArg_ParseTuple(args, "O!", &Ipo_Type, &pyipo))
+ return EXPP_ReturnPyObjError (PyExc_TypeError, "expected Ipo as argument");
+
+ ipo = Ipo_FromPyObject(pyipo);
+
+ if (!ipo) return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!");
- if (!PyArg_ParseTuple(args, "O", &ipo))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected ipo argument");
-ptr = Ipo_FromPyObject(ipo);
-//camera_assignIpo(self->camera, ptr);
+ if (ipo->blocktype != ID_CA)
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "this ipo is not a camera data ipo");
- Py_INCREF(Py_None);
- return Py_None;
+ oldipo = self->camera->ipo;
+ if (oldipo) {
+ ID *id = &oldipo->id;
+ if (id->us > 0) id->us--;
+ }
+
+ ((ID *)&ipo->id)->us++;
+
+ self->camera->ipo = ipo;
+
+ Py_INCREF(Py_None);
+ return Py_None;
}
-static PyObject *Camera_setName(BPy_Camera *self, PyObject *args)
-{
- char *name;
- char buf[21];
- if (!PyArg_ParseTuple(args, "s", &name))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+static PyObject *Camera_clearIpo(BPy_Camera *self)
+{
+ Camera *cam = self->camera;
+ Ipo *ipo = (Ipo *)cam->ipo;
- PyOS_snprintf(buf, sizeof(buf), "%s", name);
+ if (ipo) {
+ ID *id = &ipo->id;
+ if (id->us > 0) id->us--;
+ cam->ipo = NULL;
- rename_id(&self->camera->id, buf);
+ Py_INCREF (Py_True);
+ return Py_True;
+ }
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF (Py_False); /* no ipo found */
+ return Py_False;
}
-static PyObject *Camera_setType(BPy_Camera *self, PyObject *args)
+static PyObject *Camera_setName(BPy_Camera *self, PyObject *args)
{
- char *type;
+ char *name;
+ char buf[21];
- if (!PyArg_ParseTuple(args, "s", &type))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected string argument");
+ if (!PyArg_ParseTuple(args, "s", &name))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected string argument");
- if (strcmp (type, "persp") == 0)
- self->camera->type = (short)EXPP_CAM_TYPE_PERSP;
- else if (strcmp (type, "ortho") == 0)
- self->camera->type = (short)EXPP_CAM_TYPE_ORTHO;
- else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "unknown camera type");
+ PyOS_snprintf(buf, sizeof(buf), "%s", name);
- Py_INCREF(Py_None);
- return Py_None;
+ rename_id(&self->camera->id, buf);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *Camera_setType(BPy_Camera *self, PyObject *args)
+{
+ char *type;
+
+ if (!PyArg_ParseTuple(args, "s", &type))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected string argument");
+
+ if (strcmp (type, "persp") == 0)
+ self->camera->type = (short)EXPP_CAM_TYPE_PERSP;
+ else if (strcmp (type, "ortho") == 0)
+ self->camera->type = (short)EXPP_CAM_TYPE_ORTHO;
+ else
+ return EXPP_ReturnPyObjError (PyExc_AttributeError,
+ "unknown camera type");
+
+ Py_INCREF(Py_None);
+ return Py_None;
}
/* This one is 'private'. It is not really a method, just a helper function for
@@ -393,55 +423,55 @@ static PyObject *Camera_setType(BPy_Camera *self, PyObject *args)
static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args)
{
- short value;
+ short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument: 0 or 1");
+ if (!PyArg_ParseTuple(args, "h", &value))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected int argument: 0 or 1");
- if (value == 0 || value == 1)
- self->camera->type = value;
- else
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "expected int argument: 0 or 1");
+ if (value == 0 || value == 1)
+ self->camera->type = value;
+ else
+ return EXPP_ReturnPyObjError (PyExc_ValueError,
+ "expected int argument: 0 or 1");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args)
{
- char *mode_str1 = NULL, *mode_str2 = NULL;
- short flag = 0;
-
- if (!PyArg_ParseTuple(args, "|ss", &mode_str1, &mode_str2))
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected one or two strings as arguments");
-
- if (mode_str1 != NULL) {
- if (strcmp(mode_str1, "showLimits") == 0)
- flag |= (short)EXPP_CAM_MODE_SHOWLIMITS;
- else if (strcmp(mode_str1, "showMist") == 0)
- flag |= (short)EXPP_CAM_MODE_SHOWMIST;
- else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "first argument is an unknown camera flag");
-
- if (mode_str2 != NULL) {
- if (strcmp(mode_str2, "showLimits") == 0)
- flag |= (short)EXPP_CAM_MODE_SHOWLIMITS;
- else if (strcmp(mode_str2, "showMist") == 0)
- flag |= (short)EXPP_CAM_MODE_SHOWMIST;
- else
- return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "second argument is an unknown camera flag");
- }
- }
-
- self->camera->flag = flag;
-
- Py_INCREF(Py_None);
- return Py_None;
+ char *mode_str1 = NULL, *mode_str2 = NULL;
+ short flag = 0;
+
+ if (!PyArg_ParseTuple(args, "|ss", &mode_str1, &mode_str2))
+ return EXPP_ReturnPyObjError (PyExc_AttributeError,
+ "expected one or two strings as arguments");
+
+ if (mode_str1 != NULL) {
+ if (strcmp(mode_str1, "showLimits") == 0)
+ flag |= (short)EXPP_CAM_MODE_SHOWLIMITS;
+ else if (strcmp(mode_str1, "showMist") == 0)
+ flag |= (short)EXPP_CAM_MODE_SHOWMIST;
+ else
+ return EXPP_ReturnPyObjError (PyExc_AttributeError,
+ "first argument is an unknown camera flag");
+
+ if (mode_str2 != NULL) {
+ if (strcmp(mode_str2, "showLimits") == 0)
+ flag |= (short)EXPP_CAM_MODE_SHOWLIMITS;
+ else if (strcmp(mode_str2, "showMist") == 0)
+ flag |= (short)EXPP_CAM_MODE_SHOWMIST;
+ else
+ return EXPP_ReturnPyObjError (PyExc_AttributeError,
+ "second argument is an unknown camera flag");
+ }
+ }
+
+ self->camera->flag = flag;
+
+ Py_INCREF(Py_None);
+ return Py_None;
}
/* Another helper function, for the same reason.
@@ -449,203 +479,202 @@ static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args)
static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args)
{
- short value;
+ short value;
- if (!PyArg_ParseTuple(args, "h", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument in [0,3]");
+ if (!PyArg_ParseTuple(args, "h", &value))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected int argument in [0,3]");
- if (value >= 0 && value <= 3)
- self->camera->flag = value;
- else
- return EXPP_ReturnPyObjError (PyExc_ValueError,
- "expected int argument in [0,3]");
+ if (value >= 0 && value <= 3)
+ self->camera->flag = value;
+ else
+ return EXPP_ReturnPyObjError (PyExc_ValueError,
+ "expected int argument in [0,3]");
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
static PyObject *Camera_setLens(BPy_Camera *self, PyObject *args)
{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument");
+ float value;
+
+ if (!PyArg_ParseTuple(args, "f", &value))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected float argument");
- self->camera->lens = EXPP_ClampFloat (value,
- EXPP_CAM_LENS_MIN, EXPP_CAM_LENS_MAX);
-
- Py_INCREF(Py_None);
- return Py_None;
+ self->camera->lens = EXPP_ClampFloat (value,
+ EXPP_CAM_LENS_MIN, EXPP_CAM_LENS_MAX);
+
+ Py_INCREF(Py_None);
+ return Py_None;
}
static PyObject *Camera_setClipStart(BPy_Camera *self, PyObject *args)
{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument");
-
- self->camera->clipsta = EXPP_ClampFloat (value,
- EXPP_CAM_CLIPSTART_MIN, EXPP_CAM_CLIPSTART_MAX);
-
- Py_INCREF(Py_None);
- return Py_None;
+ float value;
+
+ if (!PyArg_ParseTuple(args, "f", &value))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected float argument");
+
+ self->camera->clipsta = EXPP_ClampFloat (value,
+ EXPP_CAM_CLIPSTART_MIN, EXPP_CAM_CLIPSTART_MAX);
+
+ Py_INCREF(Py_None);
+ return Py_None;
}
static PyObject *Camera_setClipEnd(BPy_Camera *self, PyObject *args)
{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected float argument");
+ float value;
+
+ if (!PyArg_ParseTuple(args, "f", &value))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected float argument");
- self->camera->clipend = EXPP_ClampFloat (value,
- EXPP_CAM_CLIPEND_MIN, EXPP_CAM_CLIPEND_MAX);
+ self->camera->clipend = EXPP_ClampFloat (value,
+ EXPP_CAM_CLIPEND_MIN, EXPP_CAM_CLIPEND_MAX);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args)
{
- float value;
-
- if (!PyArg_ParseTuple(args, "f", &value))
- return EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected a float number as argument");
+ float value;
+
+ if (!PyArg_ParseTuple(args, "f", &value))
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected a float number as argument");
- self->camera->drawsize = EXPP_ClampFloat (value,
- EXPP_CAM_DRAWSIZE_MIN, EXPP_CAM_DRAWSIZE_MAX);
+ self->camera->drawsize = EXPP_ClampFloat (value,
+ EXPP_CAM_DRAWSIZE_MIN, EXPP_CAM_DRAWSIZE_MAX);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
static void Camera_dealloc (BPy_Camera *self)
{
- PyObject_DEL (self);
+ PyObject_DEL (self);
}
static PyObject *Camera_getAttr (BPy_Camera *self, char *name)
{
- PyObject *attr = Py_None;
+ PyObject *attr = Py_None;
+
+ if (strcmp(name, "name") == 0)
+ attr = PyString_FromString(self->camera->id.name+2);
+ else if (strcmp(name, "type") == 0)
+ attr = PyInt_FromLong(self->camera->type);
+ else if (strcmp(name, "mode") == 0)
+ attr = PyInt_FromLong(self->camera->flag);
+ else if (strcmp(name, "lens") == 0)
+ attr = PyFloat_FromDouble(self->camera->lens);
+ else if (strcmp(name, "clipStart") == 0)
+ attr = PyFloat_FromDouble(self->camera->clipsta);
+ else if (strcmp(name, "clipEnd") == 0)
+ attr = PyFloat_FromDouble(self->camera->clipend);
+ else if (strcmp(name, "drawSize") == 0)
+ attr = PyFloat_FromDouble(self->camera->drawsize);
+ else if (strcmp(name, "ipo") == 0) {
+ Ipo *ipo = self->camera->ipo;
+ if (ipo) attr = Ipo_CreatePyObject (ipo);
+ }
- if (strcmp(name, "ipo") == 0)
- {
- struct Ipo*ipo = self->camera->ipo;
- if (ipo) attr = Ipo_CreatePyObject (ipo);
- }
- if (strcmp(name, "name") == 0)
- attr = PyString_FromString(self->camera->id.name+2);
- else if (strcmp(name, "type") == 0)
- attr = PyInt_FromLong(self->camera->type);
- else if (strcmp(name, "mode") == 0)
- attr = PyInt_FromLong(self->camera->flag);
- else if (strcmp(name, "lens") == 0)
- attr = PyFloat_FromDouble(self->camera->lens);
- else if (strcmp(name, "clipStart") == 0)
- attr = PyFloat_FromDouble(self->camera->clipsta);
- else if (strcmp(name, "clipEnd") == 0)
- attr = PyFloat_FromDouble(self->camera->clipend);
- else if (strcmp(name, "drawSize") == 0)
- attr = PyFloat_FromDouble(self->camera->drawsize);
-
- else if (strcmp(name, "Types") == 0) {
- attr = Py_BuildValue("{s:h,s:h}", "persp", EXPP_CAM_TYPE_PERSP,
- "ortho", EXPP_CAM_TYPE_ORTHO);
- }
-
- else if (strcmp(name, "Modes") == 0) {
- attr = Py_BuildValue("{s:h,s:h}", "showLimits", EXPP_CAM_MODE_SHOWLIMITS,
- "showMist", EXPP_CAM_MODE_SHOWMIST);
- }
-
- else if (strcmp(name, "__members__") == 0) {
- attr = Py_BuildValue("[s,s,s,s,s,s,s,s,s]",
- "name", "type", "mode", "lens", "clipStart",
- "clipEnd", "drawSize", "Types", "Modes");
- }
-
- if (!attr)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,
- "couldn't create PyObject");
-
- if (attr != Py_None) return attr; /* member attribute found, return it */
-
- /* not an attribute, search the methods table */
- return Py_FindMethod(BPy_Camera_methods, (PyObject *)self, name);
+ else if (strcmp(name, "Types") == 0) {
+ attr = Py_BuildValue("{s:h,s:h}", "persp", EXPP_CAM_TYPE_PERSP,
+ "ortho", EXPP_CAM_TYPE_ORTHO);
+ }
+
+ else if (strcmp(name, "Modes") == 0) {
+ attr = Py_BuildValue("{s:h,s:h}", "showLimits", EXPP_CAM_MODE_SHOWLIMITS,
+ "showMist", EXPP_CAM_MODE_SHOWMIST);
+ }
+
+ else if (strcmp(name, "__members__") == 0) {
+ attr = Py_BuildValue("[s,s,s,s,s,s,s,s,s,s]",
+ "name", "type", "mode", "lens", "clipStart", "ipo",
+ "clipEnd", "drawSize", "Types", "Modes");
+ }
+
+ if (!attr)
+ return EXPP_ReturnPyObjError (PyExc_MemoryError,
+ "couldn't create PyObject");
+
+ if (attr != Py_None) return attr; /* member attribute found, return it */
+
+ /* not an attribute, search the methods table */
+ return Py_FindMethod(BPy_Camera_methods, (PyObject *)self, name);
}
static int Camera_setAttr (BPy_Camera *self, char *name, PyObject *value)
{
- PyObject *valtuple;
- PyObject *error = NULL;
+ PyObject *valtuple;
+ PyObject *error = NULL;
-/* We're playing a trick on the Python API users here. Even if they use
+/* We're playing a trick on the Python API users here. Even if they use
* Camera.member = val instead of Camera.setMember(val), we end up using the
* function anyway, since it already has error checking, clamps to the right
* interval and updates the Blender Camera structure when necessary. */
/* First we put "value" in a tuple, because we want to pass it to functions
* that only accept PyTuples. */
- valtuple = Py_BuildValue("(O)", value);
+ valtuple = Py_BuildValue("(O)", value);
- if (!valtuple) /* everything OK with our PyObject? */
- return EXPP_ReturnIntError(PyExc_MemoryError,
- "CameraSetAttr: couldn't create PyTuple");
+ if (!valtuple) /* everything OK with our PyObject? */
+ return EXPP_ReturnIntError(PyExc_MemoryError,
+ "CameraSetAttr: couldn't create PyTuple");
/* Now we just compare "name" with all possible BPy_Camera member variables */
- if (strcmp (name, "name") == 0)
- error = Camera_setName (self, valtuple);
- else if (strcmp (name, "type") == 0)
- error = Camera_setIntType (self, valtuple); /* special case */
- else if (strcmp (name, "mode") == 0)
- error = Camera_setIntMode (self, valtuple); /* special case */
- else if (strcmp (name, "lens") == 0)
- error = Camera_setLens (self, valtuple);
- else if (strcmp (name, "clipStart") == 0)
- error = Camera_setClipStart (self, valtuple);
- else if (strcmp (name, "clipEnd") == 0)
- error = Camera_setClipEnd (self, valtuple);
- else if (strcmp (name, "drawSize") == 0)
- error = Camera_setDrawSize (self, valtuple);
-
- else { /* Error */
- Py_DECREF(valtuple);
-
- if ((strcmp (name, "Types") == 0) || /* user tried to change a */
- (strcmp (name, "Modes") == 0)) /* constant dict type ... */
- return EXPP_ReturnIntError (PyExc_AttributeError,
- "constant dictionary -- cannot be changed");
-
- else /* ... or no member with the given name was found */
- return EXPP_ReturnIntError (PyExc_KeyError,
- "attribute not found");
- }
+ if (strcmp (name, "name") == 0)
+ error = Camera_setName (self, valtuple);
+ else if (strcmp (name, "type") == 0)
+ error = Camera_setIntType (self, valtuple); /* special case */
+ else if (strcmp (name, "mode") == 0)
+ error = Camera_setIntMode (self, valtuple); /* special case */
+ else if (strcmp (name, "lens") == 0)
+ error = Camera_setLens (self, valtuple);
+ else if (strcmp (name, "clipStart") == 0)
+ error = Camera_setClipStart (self, valtuple);
+ else if (strcmp (name, "clipEnd") == 0)
+ error = Camera_setClipEnd (self, valtuple);
+ else if (strcmp (name, "drawSize") == 0)
+ error = Camera_setDrawSize (self, valtuple);
+
+ else { /* Error */
+ Py_DECREF(valtuple);
+
+ if ((strcmp (name, "Types") == 0) || /* user tried to change a */
+ (strcmp (name, "Modes") == 0)) /* constant dict type ... */
+ return EXPP_ReturnIntError (PyExc_AttributeError,
+ "constant dictionary -- cannot be changed");
+
+ else /* ... or no member with the given name was found */
+ return EXPP_ReturnIntError (PyExc_KeyError,
+ "attribute not found");
+ }
/* valtuple won't be returned to the caller, so we need to DECREF it */
- Py_DECREF (valtuple);
+ Py_DECREF (valtuple);
- if (error != Py_None) return -1;
+ if (error != Py_None) return -1;
/* Py_None was incref'ed by the called Camera_set* function. We probably
* don't need to decref Py_None (!), but since Python/C API manual tells us
* to treat it like any other PyObject regarding ref counting ... */
- Py_DECREF (Py_None);
- return 0; /* normal exit */
+ Py_DECREF (Py_None);
+ return 0; /* normal exit */
}
static int Camera_compare (BPy_Camera *a, BPy_Camera *b)
{
- Camera *pa = a->camera, *pb = b->camera;
- return (pa == pb) ? 0:-1;
+ Camera *pa = a->camera, *pb = b->camera;
+ return (pa == pb) ? 0:-1;
}
static PyObject *Camera_repr (BPy_Camera *self)
{
- return PyString_FromFormat("[Camera \"%s\"]", self->camera->id.name+2);
+ return PyString_FromFormat("[Camera \"%s\"]", self->camera->id.name+2);
}
diff --git a/source/blender/python/api2_2x/Camera.h b/source/blender/python/api2_2x/Camera.h
index eee0593a98d..ee36cc214bf 100644
--- a/source/blender/python/api2_2x/Camera.h
+++ b/source/blender/python/api2_2x/Camera.h
@@ -125,6 +125,7 @@ static PyObject *Camera_getClipStart(BPy_Camera *self);
static PyObject *Camera_getClipEnd(BPy_Camera *self);
static PyObject *Camera_getDrawSize(BPy_Camera *self);
static PyObject *Camera_setIpo(BPy_Camera *self, PyObject *args);
+static PyObject *Camera_clearIpo(BPy_Camera *self);
static PyObject *Camera_setName(BPy_Camera *self, PyObject *args);
static PyObject *Camera_setType(BPy_Camera *self, PyObject *args);
static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args);
@@ -158,7 +159,9 @@ static PyMethodDef BPy_Camera_methods[] = {
{"getDrawSize", (PyCFunction)Camera_getDrawSize, METH_NOARGS,
"() - Return Camera draw size value"},
{"setIpo", (PyCFunction)Camera_setIpo, METH_VARARGS,
- "(O) - Set Camera Ipo"},
+ "(Blender Ipo) - Set Camera Ipo"},
+ {"clearIpo", (PyCFunction)Camera_clearIpo, METH_NOARGS,
+ "() - Unlink Ipo from this Camera."},
{"setName", (PyCFunction)Camera_setName, METH_VARARGS,
"(s) - Set Camera Data name"},
{"setType", (PyCFunction)Camera_setType, METH_VARARGS,
diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c
index f243cfb9b23..9b99f22a2a4 100644
--- a/source/blender/python/api2_2x/Ipo.c
+++ b/source/blender/python/api2_2x/Ipo.c
@@ -42,7 +42,7 @@ static PyObject *M_Ipo_New(PyObject *self, PyObject *args)
Ipo *add_ipo(char *name, int idcode);
char*name = NULL,*code=NULL;
int idcode = -1;
- C_Ipo *pyipo;
+ BPy_Ipo *pyipo;
Ipo *blipo;
if (!PyArg_ParseTuple(args, "ss", &code,&name))
@@ -57,7 +57,7 @@ static PyObject *M_Ipo_New(PyObject *self, PyObject *args)
blipo = add_ipo(name,idcode);
if (blipo)
- pyipo = (C_Ipo *)PyObject_NEW(C_Ipo, &Ipo_Type);
+ pyipo = (BPy_Ipo *)PyObject_NEW(BPy_Ipo, &Ipo_Type);
else
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
"couldn't create Ipo Data in Blender"));
@@ -84,7 +84,7 @@ static PyObject *M_Ipo_Get(PyObject *self, PyObject *args)
char *name = NULL;
Ipo *ipo_iter;
PyObject *ipolist, *pyobj;
- C_Ipo *wanted_ipo = NULL;
+ BPy_Ipo *wanted_ipo = NULL;
char error_msg[64];
if (!PyArg_ParseTuple(args, "|s", &name))
@@ -96,7 +96,7 @@ static PyObject *M_Ipo_Get(PyObject *self, PyObject *args)
if (name) { /* (name) - Search ipo by name */
while ((ipo_iter) && (wanted_ipo == NULL)) {
if (strcmp (name, ipo_iter->id.name+2) == 0) {
- wanted_ipo = (C_Ipo *)PyObject_NEW(C_Ipo, &Ipo_Type);
+ wanted_ipo = (BPy_Ipo *)PyObject_NEW(BPy_Ipo, &Ipo_Type);
if (wanted_ipo) wanted_ipo->ipo = ipo_iter;
}
ipo_iter = ipo_iter->id.next;
@@ -167,9 +167,9 @@ PyObject *Ipo_Init (void)
}
/*****************************************************************************/
-/* Python C_Ipo methods: */
+/* Python BPy_Ipo methods: */
/*****************************************************************************/
-static PyObject *Ipo_getName(C_Ipo *self)
+static PyObject *Ipo_getName(BPy_Ipo *self)
{
PyObject *attr = PyString_FromString(self->ipo->id.name+2);
@@ -185,7 +185,7 @@ static PyObject *Ipo_getName(C_Ipo *self)
-static PyObject *Ipo_setName(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_setName(BPy_Ipo *self, PyObject *args)
{
char *name;
char buf[21];
@@ -201,7 +201,7 @@ static PyObject *Ipo_setName(C_Ipo *self, PyObject *args)
return Py_None;
}
-static PyObject *Ipo_getBlocktype(C_Ipo *self)
+static PyObject *Ipo_getBlocktype(BPy_Ipo *self)
{
PyObject *attr = PyInt_FromLong(self->ipo->blocktype);
if (attr) return attr;
@@ -209,7 +209,7 @@ static PyObject *Ipo_getBlocktype(C_Ipo *self)
}
-static PyObject *Ipo_setBlocktype(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_setBlocktype(BPy_Ipo *self, PyObject *args)
{
int blocktype = 0;
@@ -224,7 +224,7 @@ static PyObject *Ipo_setBlocktype(C_Ipo *self, PyObject *args)
-static PyObject *Ipo_getRctf(C_Ipo *self)
+static PyObject *Ipo_getRctf(BPy_Ipo *self)
{
PyObject* l = PyList_New(0);
PyList_Append( l, PyFloat_FromDouble(self->ipo->cur.xmin));
@@ -236,7 +236,7 @@ static PyObject *Ipo_getRctf(C_Ipo *self)
}
-static PyObject *Ipo_setRctf(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_setRctf(BPy_Ipo *self, PyObject *args)
{
float v[4];
if (!PyArg_ParseTuple(args, "ffff",v,v+1,v+2,v+3))
@@ -251,7 +251,7 @@ static PyObject *Ipo_setRctf(C_Ipo *self, PyObject *args)
return Py_None;
}
-static PyObject *Ipo_getNcurves(C_Ipo *self)
+static PyObject *Ipo_getNcurves(BPy_Ipo *self)
{
int i = 0;
@@ -331,7 +331,7 @@ char* type_from_num(int num,int ipotype)
}
-static PyObject *Ipo_addCurve(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_addCurve(BPy_Ipo *self, PyObject *args)
{
void *MEM_callocN(unsigned int len, char *str);
IpoCurve *ptr;
@@ -357,9 +357,9 @@ static PyObject *Ipo_addCurve(C_Ipo *self, PyObject *args)
return IpoCurve_CreatePyObject (ptr);
}
-static PyObject *Ipo_getCurve(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_getCurve(BPy_Ipo *self, PyObject *args)
{
- int num = 0 , i = 0;
+ //int num = 0 , i = 0;
char*str;
IpoCurve *icu = 0;
if (!PyArg_ParseTuple(args, "s",&str))
@@ -373,7 +373,7 @@ static PyObject *Ipo_getCurve(C_Ipo *self, PyObject *args)
return Py_None;
}
-static PyObject *Ipo_getCurves(C_Ipo *self)
+static PyObject *Ipo_getCurves(BPy_Ipo *self)
{
PyObject *attr = PyList_New(0);
IpoCurve *icu;
@@ -384,7 +384,7 @@ static PyObject *Ipo_getCurves(C_Ipo *self)
}
-static PyObject *Ipo_getNBezPoints(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_getNBezPoints(BPy_Ipo *self, PyObject *args)
{
int num = 0 , i = 0;
IpoCurve *icu = 0;
@@ -401,7 +401,7 @@ static PyObject *Ipo_getNBezPoints(C_Ipo *self, PyObject *args)
return (PyInt_FromLong(icu->totvert) );
}
-static PyObject *Ipo_DeleteBezPoints(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_DeleteBezPoints(BPy_Ipo *self, PyObject *args)
{
int num = 0 , i = 0;
IpoCurve *icu = 0;
@@ -423,7 +423,7 @@ static PyObject *Ipo_DeleteBezPoints(C_Ipo *self, PyObject *args)
-static PyObject *Ipo_getCurveBP(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_getCurveBP(BPy_Ipo *self, PyObject *args)
{
struct BPoint *ptrbpoint;
int num = 0,i;
@@ -449,7 +449,7 @@ static PyObject *Ipo_getCurveBP(C_Ipo *self, PyObject *args)
return l;
}
-static PyObject *Ipo_getCurveBeztriple(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_getCurveBeztriple(BPy_Ipo *self, PyObject *args)
{
struct BezTriple *ptrbt;
int num = 0,pos,i,j;
@@ -480,7 +480,7 @@ static PyObject *Ipo_getCurveBeztriple(C_Ipo *self, PyObject *args)
}
-static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_setCurveBeztriple(BPy_Ipo *self, PyObject *args)
{
struct BezTriple *ptrbt;
int num = 0,pos,i;
@@ -519,7 +519,7 @@ return (EXPP_ReturnPyObjError (PyExc_TypeError,"3rd arg should be a tuple"));
-static PyObject *Ipo_EvaluateCurveOn(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_EvaluateCurveOn(BPy_Ipo *self, PyObject *args)
{
float eval_icu(IpoCurve *icu, float ipotime) ;
@@ -541,7 +541,7 @@ static PyObject *Ipo_EvaluateCurveOn(C_Ipo *self, PyObject *args)
}
-static PyObject *Ipo_getCurvecurval(C_Ipo *self, PyObject *args)
+static PyObject *Ipo_getCurvecurval(BPy_Ipo *self, PyObject *args)
{
int num = 0,i;
IpoCurve *icu;
@@ -563,42 +563,42 @@ static PyObject *Ipo_getCurvecurval(C_Ipo *self, PyObject *args)
/*****************************************************************************/
/* Function: IpoDeAlloc */
-/* Description: This is a callback function for the C_Ipo type. It is */
+/* Description: This is a callback function for the BPy_Ipo type. It is */
/* the destructor function. */
/*****************************************************************************/
-static void IpoDeAlloc (C_Ipo *self)
+static void IpoDeAlloc (BPy_Ipo *self)
{
PyObject_DEL (self);
}
/*****************************************************************************/
/* Function: IpoGetAttr */
-/* Description: This is a callback function for the C_Ipo type. It is */
-/* the function that accesses C_Ipo "member variables" and */
+/* Description: This is a callback function for the BPy_Ipo type. It is */
+/* the function that accesses BPy_Ipo "member variables" and */
/* methods. */
/*****************************************************************************/
-static PyObject *IpoGetAttr (C_Ipo *self, char *name)
+static PyObject *IpoGetAttr (BPy_Ipo *self, char *name)
{
if (strcmp (name, "curves") == 0)return Ipo_getCurves (self);
- return Py_FindMethod(C_Ipo_methods, (PyObject *)self, name);
+ return Py_FindMethod(BPy_Ipo_methods, (PyObject *)self, name);
}
/*****************************************************************************/
/* Function: IpoSetAttr */
-/* Description: This is a callback function for the C_Ipo type. It is the */
+/* Description: This is a callback function for the BPy_Ipo type. It is the */
/* function that sets Ipo Data attributes (member variables).*/
/*****************************************************************************/
-static int IpoSetAttr (C_Ipo *self, char *name, PyObject *value)
+static int IpoSetAttr (BPy_Ipo *self, char *name, PyObject *value)
{
return 0; /* normal exit */
}
/*****************************************************************************/
/* Function: IpoRepr */
-/* Description: This is a callback function for the C_Ipo type. It */
+/* Description: This is a callback function for the BPy_Ipo type. It */
/* builds a meaninful string to represent ipo objects. */
/*****************************************************************************/
-static PyObject *IpoRepr (C_Ipo *self)
+static PyObject *IpoRepr (BPy_Ipo *self)
{
return PyString_FromFormat("[Ipo \"%s\" %d]", self->ipo->id.name+2,self->ipo->blocktype);
}
@@ -607,15 +607,15 @@ static PyObject *IpoRepr (C_Ipo *self)
/*****************************************************************************/
/* Function: Ipo_CreatePyObject */
-/* Description: This function will create a new C_Ipo from an existing */
+/* Description: This function will create a new BPy_Ipo from an existing */
/* Blender ipo structure. */
/*****************************************************************************/
PyObject *Ipo_CreatePyObject (Ipo *ipo)
{
- C_Ipo *pyipo;
- pyipo = (C_Ipo *)PyObject_NEW (C_Ipo, &Ipo_Type);
+ BPy_Ipo *pyipo;
+ pyipo = (BPy_Ipo *)PyObject_NEW (BPy_Ipo, &Ipo_Type);
if (!pyipo)
- return EXPP_ReturnPyObjError (PyExc_MemoryError,"couldn't create C_Ipo object");
+ return EXPP_ReturnPyObjError (PyExc_MemoryError,"couldn't create BPy_Ipo object");
pyipo->ipo = ipo;
return (PyObject *)pyipo;
}
@@ -637,5 +637,5 @@ int Ipo_CheckPyObject (PyObject *pyobj)
/*****************************************************************************/
Ipo *Ipo_FromPyObject (PyObject *pyobj)
{
- return ((C_Ipo *)pyobj)->ipo;
+ return ((BPy_Ipo *)pyobj)->ipo;
}
diff --git a/source/blender/python/api2_2x/Ipo.h b/source/blender/python/api2_2x/Ipo.h
index c71a38dca85..1f78b613903 100644
--- a/source/blender/python/api2_2x/Ipo.h
+++ b/source/blender/python/api2_2x/Ipo.h
@@ -76,41 +76,41 @@ struct PyMethodDef M_Ipo_methods[] = {
};
/*****************************************************************************/
-/* Python C_Ipo structure definition: */
+/* Python BPy_Ipo structure definition: */
/*****************************************************************************/
typedef struct {
PyObject_HEAD
Ipo *ipo;
-} C_Ipo;
+} BPy_Ipo;
/*****************************************************************************/
-/* Python C_Ipo methods declarations: */
+/* Python BPy_Ipo methods declarations: */
/*****************************************************************************/
-static PyObject *Ipo_getName(C_Ipo *self);
-static PyObject *Ipo_setName(C_Ipo *self, PyObject *args);
-static PyObject *Ipo_getBlocktype(C_Ipo *self);
-static PyObject *Ipo_setBlocktype(C_Ipo *self, PyObject *args);
-static PyObject *Ipo_getRctf(C_Ipo *self);
-static PyObject *Ipo_setRctf(C_Ipo *self, PyObject *args);
+static PyObject *Ipo_getName(BPy_Ipo *self);
+static PyObject *Ipo_setName(BPy_Ipo *self, PyObject *args);
+static PyObject *Ipo_getBlocktype(BPy_Ipo *self);
+static PyObject *Ipo_setBlocktype(BPy_Ipo *self, PyObject *args);
+static PyObject *Ipo_getRctf(BPy_Ipo *self);
+static PyObject *Ipo_setRctf(BPy_Ipo *self, PyObject *args);
-static PyObject *Ipo_getCurve(C_Ipo *self, PyObject *args);
-static PyObject *Ipo_getCurves(C_Ipo *self);
-static PyObject *Ipo_addCurve(C_Ipo *self, PyObject *args);
-static PyObject *Ipo_getNcurves(C_Ipo *self);
-static PyObject *Ipo_getNBezPoints(C_Ipo *self, PyObject *args);
-static PyObject *Ipo_DeleteBezPoints(C_Ipo *self, PyObject *args);
-static PyObject *Ipo_getCurveBP(C_Ipo *self, PyObject *args);
-static PyObject *Ipo_getCurvecurval(C_Ipo *self, PyObject *args);
-static PyObject *Ipo_EvaluateCurveOn(C_Ipo *self, PyObject *args);
+static PyObject *Ipo_getCurve(BPy_Ipo *self, PyObject *args);
+static PyObject *Ipo_getCurves(BPy_Ipo *self);
+static PyObject *Ipo_addCurve(BPy_Ipo *self, PyObject *args);
+static PyObject *Ipo_getNcurves(BPy_Ipo *self);
+static PyObject *Ipo_getNBezPoints(BPy_Ipo *self, PyObject *args);
+static PyObject *Ipo_DeleteBezPoints(BPy_Ipo *self, PyObject *args);
+static PyObject *Ipo_getCurveBP(BPy_Ipo *self, PyObject *args);
+static PyObject *Ipo_getCurvecurval(BPy_Ipo *self, PyObject *args);
+static PyObject *Ipo_EvaluateCurveOn(BPy_Ipo *self, PyObject *args);
-static PyObject *Ipo_setCurveBeztriple(C_Ipo *self, PyObject *args);
-static PyObject *Ipo_getCurveBeztriple(C_Ipo *self, PyObject *args);
+static PyObject *Ipo_setCurveBeztriple(BPy_Ipo *self, PyObject *args);
+static PyObject *Ipo_getCurveBeztriple(BPy_Ipo *self, PyObject *args);
/*****************************************************************************/
-/* Python C_Ipo methods table: */
+/* Python BPy_Ipo methods table: */
/*****************************************************************************/
-static PyMethodDef C_Ipo_methods[] = {
+static PyMethodDef BPy_Ipo_methods[] = {
/* name, method, flags, doc */
{"getName", (PyCFunction)Ipo_getName, METH_NOARGS,
"() - Return Ipo Data name"},
@@ -152,11 +152,11 @@ static PyMethodDef C_Ipo_methods[] = {
/*****************************************************************************/
/* Python Ipo_Type callback function prototypes: */
/*****************************************************************************/
-static void IpoDeAlloc (C_Ipo *self);
-//static int IpoPrint (C_Ipo *self, FILE *fp, int flags);
-static int IpoSetAttr (C_Ipo *self, char *name, PyObject *v);
-static PyObject *IpoGetAttr (C_Ipo *self, char *name);
-static PyObject *IpoRepr (C_Ipo *self);
+static void IpoDeAlloc (BPy_Ipo *self);
+//static int IpoPrint (BPy_Ipo *self, FILE *fp, int flags);
+static int IpoSetAttr (BPy_Ipo *self, char *name, PyObject *v);
+static PyObject *IpoGetAttr (BPy_Ipo *self, char *name);
+static PyObject *IpoRepr (BPy_Ipo *self);
/*****************************************************************************/
/* Python Ipo_Type structure definition: */
@@ -166,7 +166,7 @@ PyTypeObject Ipo_Type =
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"Ipo", /* tp_name */
- sizeof (C_Ipo), /* tp_basicsize */
+ sizeof (BPy_Ipo), /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)IpoDeAlloc, /* tp_dealloc */
@@ -182,7 +182,7 @@ PyTypeObject Ipo_Type =
0,0,0,0,0,0,
0, /* tp_doc */
0,0,0,0,0,0,
- C_Ipo_methods, /* tp_methods */
+ BPy_Ipo_methods, /* tp_methods */
0, /* tp_members */
};
diff --git a/source/blender/python/api2_2x/Material.c b/source/blender/python/api2_2x/Material.c
index 17111f38e7a..2d2de751aa0 100644
--- a/source/blender/python/api2_2x/Material.c
+++ b/source/blender/python/api2_2x/Material.c
@@ -38,6 +38,8 @@
#include "constant.h"
#include "gen_utils.h"
+#include "bpy_types.h"
+#include "modules.h"
#include "Material.h"
@@ -151,11 +153,11 @@ struct PyMethodDef M_Material_methods[] = {
static PyObject *M_Material_New(PyObject *self, PyObject *args,
PyObject *keywords)
{
- char *name = "Mat";
+ char *name = "Mat";
static char *kwlist[] = {"name", NULL};
- BPy_Material *pymat; /* for Material Data object wrapper in Python */
- Material *blmat; /* for actual Material Data we create in Blender */
- char buf[21];
+ BPy_Material *pymat; /* for Material Data object wrapper in Python */
+ Material *blmat; /* for actual Material Data we create in Blender */
+ char buf[21];
if (!PyArg_ParseTupleAndKeywords(args, keywords, "|s", kwlist, &name))
return (EXPP_ReturnPyObjError (PyExc_AttributeError,
@@ -343,6 +345,8 @@ static PyObject *Material_getNFlares(BPy_Material *self);
static PyObject *Material_getNStars(BPy_Material *self);
static PyObject *Material_getNLines(BPy_Material *self);
static PyObject *Material_getNRings(BPy_Material *self);
+static PyObject *Material_setIpo(BPy_Material *self, PyObject *args);
+static PyObject *Material_clearIpo(BPy_Material *self);
static PyObject *Material_setName(BPy_Material *self, PyObject *args);
static PyObject *Material_setMode(BPy_Material *self, PyObject *args);
static PyObject *Material_setIntMode(BPy_Material *self, PyObject *args);
@@ -379,9 +383,11 @@ static PyObject *Material_setColorComponent(BPy_Material *self, char *key,
static PyMethodDef BPy_Material_methods[] = {
/* name, method, flags, doc */
{"getName", (PyCFunction)Material_getName, METH_NOARGS,
- "() - Return Material Data name"},
+ "() - Return Material's name"},
+ {"getIpo", (PyCFunction)Material_getIpo, METH_NOARGS,
+ "() - Return Material's ipo or None if not found"},
{"getMode", (PyCFunction)Material_getMode, METH_NOARGS,
- "() - Return Material mode flags"},
+ "() - Return Material's mode flags"},
{"getRGBCol", (PyCFunction)Material_getRGBCol, METH_NOARGS,
"() - Return Material's rgb color triplet"},
/* {"getAmbCol", (PyCFunction)Material_getAmbCol, METH_NOARGS,
@@ -430,9 +436,13 @@ static PyMethodDef BPy_Material_methods[] = {
{"getNRings", (PyCFunction)Material_getNRings, METH_NOARGS,
"() - Return Material's number of rings in halo"},
{"setName", (PyCFunction)Material_setName, METH_VARARGS,
- "(s) - Change Material Data name"},
+ "(s) - Change Material's name"},
+ {"setIpo", (PyCFunction)Material_setIpo, METH_VARARGS,
+ "(Blender Ipo) - Change Material's Ipo"},
+ {"clearIpo", (PyCFunction)Material_clearIpo, METH_NOARGS,
+ "(Blender Ipo) - Unlink Ipo from this Material"},
{"setMode", (PyCFunction)Material_setMode, METH_VARARGS,
- "([s[,s]]) - Set Material mode flag(s)"},
+ "([s[,s]]) - Set Material's mode flag(s)"},
{"setRGBCol", (PyCFunction)Material_setRGBCol, METH_VARARGS,
"(f,f,f or [f,f,f]) - Set Material's rgb color triplet"},
/* {"setAmbCol", (PyCFunction)Material_setAmbCol, METH_VARARGS,
@@ -628,10 +638,13 @@ Material * GetMaterialByName (char * name)
static PyObject *Material_getIpo(BPy_Material *self)
{
- typedef struct Ipo Ipo;
-PyObject *Ipo_CreatePyObject (Ipo *ipo);
- struct Ipo*ipo = self->material->ipo;
- if (!ipo) return EXPP_ReturnPyObjError(PyExc_RuntimeError,"Material has no Ipo");
+ Ipo *ipo = self->material->ipo;
+
+ if (!ipo) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
return Ipo_CreatePyObject (ipo);
}
@@ -865,6 +878,55 @@ static PyObject *Material_getNRings(BPy_Material *self)
"couldn't get Material.nRings attribute");
}
+static PyObject *Material_setIpo(BPy_Material *self, PyObject *args)
+{
+ PyObject *pyipo = 0;
+ Ipo *ipo = NULL;
+ Ipo *oldipo;
+
+ if (!PyArg_ParseTuple(args, "O!", &Ipo_Type, &pyipo))
+ return EXPP_ReturnPyObjError (PyExc_TypeError, "expected Ipo as argument");
+
+ ipo = Ipo_FromPyObject(pyipo);
+
+ if (!ipo) return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!");
+
+ if (ipo->blocktype != ID_MA)
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "this ipo is not a Material type ipo");
+
+ oldipo = self->material->ipo;
+ if (oldipo) {
+ ID *id = &oldipo->id;
+ if (id->us > 0) id->us--;
+ }
+
+ ((ID *)&ipo->id)->us++;
+
+ self->material->ipo = ipo;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *Material_clearIpo(BPy_Material *self)
+{
+ Material *mat = self->material;
+ Ipo *ipo = (Ipo *)mat->ipo;
+
+ if (ipo) {
+ ID *id = &ipo->id;
+ if (id->us > 0) id->us--;
+ mat->ipo = NULL;
+
+ Py_INCREF (Py_True);
+ return Py_True;
+ }
+
+ Py_INCREF (Py_False); /* no ipo found */
+ return Py_False;
+}
+
static PyObject *Material_setName(BPy_Material *self, PyObject *args)
{
char *name;
diff --git a/source/blender/python/api2_2x/Material.h b/source/blender/python/api2_2x/Material.h
index b5ce6a113ab..d53c04a9cca 100644
--- a/source/blender/python/api2_2x/Material.h
+++ b/source/blender/python/api2_2x/Material.h
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -33,17 +33,17 @@
#define EXPP_MATERIAL_H
#include <Python.h>
-#include <BKE_material.h>
#include <DNA_material_types.h>
+#include <BKE_material.h>
#include "rgbTuple.h"
/*****************************************************************************/
-/* Python BPy_Material structure definition: */
+/* Python BPy_Material structure definition: */
/*****************************************************************************/
typedef struct {
- PyObject_HEAD
- Material *material;
+ PyObject_HEAD
+ Material *material;
BPy_rgbTuple *col, *amb, *spec, *mir;
} BPy_Material;
@@ -51,15 +51,15 @@ typedef struct {
extern PyTypeObject Material_Type; /* The Material PyType Object */
#define BPy_Material_Check(v) \
- ((v)->ob_type == &Material_Type) /* for type checking */
+ ((v)->ob_type == &Material_Type) /* for type checking */
/*****************************************************************************/
-/* Module Blender.Material - public functions */
+/* Module Blender.Material - public functions */
/*****************************************************************************/
PyObject *M_Material_Init (void);
PyObject *Material_CreatePyObject (Material *mat);
Material *Material_FromPyObject (PyObject *pyobj);
-int Material_CheckPyObject (PyObject *pyobj);
+int Material_CheckPyObject (PyObject *pyobj);
/* Some functions needed by NMesh.c */
PyObject *EXPP_PyList_fromMaterialList (Material **matlist, int len);
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
index d76d45de2e7..115cefe114a 100644
--- a/source/blender/python/api2_2x/NMesh.c
+++ b/source/blender/python/api2_2x/NMesh.c
@@ -31,6 +31,14 @@
#include "NMesh.h"
+/* EXPP Mesh defines */
+
+#define EXPP_NMESH_MODE_NOPUNOFLIP ME_NOPUNOFLIP
+#define EXPP_NMESH_MODE_TWOSIDED ME_TWOSIDED
+#define EXPP_NMESH_MODE_AUTOSMOOTH ME_AUTOSMOOTH
+#define EXPP_NMESH_MODE_SUBSURF ME_SUBSURF
+#define EXPP_NMESH_MODE_OPTIMAL ME_OPT_EDGES
+
#define NMESH_FRAME_MAX 18000
#define NMESH_SMOOTHRESH 30
#define NMESH_SMOOTHRESH_MIN 1
@@ -1018,14 +1026,14 @@ static PyObject *NMesh_getMode (BPy_NMesh *self)
static PyObject *NMesh_setMode (PyObject *self, PyObject *args)
{
BPy_NMesh *nmesh = (BPy_NMesh *)self;
- char *m[4] = {NULL, NULL, NULL, NULL};
+ char *m[5] = {NULL, NULL, NULL, NULL, NULL};
short i, mode = 0;
- if (!PyArg_ParseTuple(args, "|ssss", &m[0], &m[1], &m[2], &m[3]))
+ if (!PyArg_ParseTuple(args, "|sssss", &m[0], &m[1], &m[2], &m[3], &m[4]))
return EXPP_ReturnPyObjError (PyExc_AttributeError,
- "expected from none to 4 strings as argument(s)");
+ "expected from none to 5 strings as argument(s)");
- for (i = 0; i < 4; i++) {
+ for (i = 0; i < 5; i++) {
if (!m[i]) break;
if (strcmp(m[i], "NoVNormalsFlip") == 0)
mode |= EXPP_NMESH_MODE_NOPUNOFLIP;
@@ -1035,6 +1043,8 @@ static PyObject *NMesh_setMode (PyObject *self, PyObject *args)
mode |= EXPP_NMESH_MODE_AUTOSMOOTH;
else if (strcmp(m[i], "SubSurf") == 0)
mode |= EXPP_NMESH_MODE_SUBSURF;
+ else if (strcmp(m[i], "Optimal") == 0)
+ mode |= EXPP_NMESH_MODE_OPTIMAL;
else
return EXPP_ReturnPyObjError (PyExc_AttributeError,
"unknown NMesh mode");
@@ -1356,6 +1366,7 @@ static PyObject *new_NMesh_internal(Mesh *oldmesh,
{
BPy_NMesh *me = PyObject_NEW (BPy_NMesh, &NMesh_Type);
me->flags = 0;
+ me->mode = EXPP_NMESH_MODE_TWOSIDED; /* default for new meshes */
me->subdiv[0] = NMESH_SUBDIV;
me->subdiv[1] = NMESH_SUBDIV;
me->smoothresh = NMESH_SMOOTHRESH;
@@ -2060,6 +2071,7 @@ static PyObject *M_NMesh_Modes (void)
constant_insert(d, "TWOSIDED", PyInt_FromLong(EXPP_NMESH_MODE_TWOSIDED));
constant_insert(d, "AUTOSMOOTH",PyInt_FromLong(EXPP_NMESH_MODE_AUTOSMOOTH));
constant_insert(d, "SUBSURF", PyInt_FromLong(EXPP_NMESH_MODE_SUBSURF));
+ constant_insert(d, "OPTIMAL", PyInt_FromLong(EXPP_NMESH_MODE_OPTIMAL));
}
return Modes;
diff --git a/source/blender/python/api2_2x/NMesh.h b/source/blender/python/api2_2x/NMesh.h
index 4d0d0253fa1..27c1959c5a4 100644
--- a/source/blender/python/api2_2x/NMesh.h
+++ b/source/blender/python/api2_2x/NMesh.h
@@ -74,12 +74,6 @@
#include "gen_utils.h"
#include "modules.h"
-/* EXPP Mesh defines */
-#define EXPP_NMESH_MODE_NOPUNOFLIP ME_NOPUNOFLIP
-#define EXPP_NMESH_MODE_TWOSIDED ME_TWOSIDED
-#define EXPP_NMESH_MODE_AUTOSMOOTH ME_AUTOSMOOTH
-#define EXPP_NMESH_MODE_SUBSURF ME_SUBSURF
-
/* EXPP PyType Objects */
PyTypeObject NMesh_Type;
PyTypeObject NMFace_Type;
@@ -205,7 +199,7 @@ static char NMesh_getMode_doc[] =
"() - get the mode flags of this nmesh as an or'ed int value.";
static char NMesh_setMode_doc[] =
-"(none to 4 strings) - set the mode flags of this nmesh.\n\
+"(none to 5 strings) - set the mode flags of this nmesh.\n\
() - unset all flags.";
static char NMesh_getMaxSmoothAngle_doc[] =
diff --git a/source/blender/python/api2_2x/World.c b/source/blender/python/api2_2x/World.c
index 75ff9dcb53d..5b488e1688b 100644
--- a/source/blender/python/api2_2x/World.c
+++ b/source/blender/python/api2_2x/World.c
@@ -17,7 +17,7 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
- * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -35,7 +35,7 @@
* \brief Blender.World Module and World Data PyObject implementation.
*
* Note: Parameters between "<" and ">" are optional. But if one of them is
- * given, all preceding ones must be given, too. Of course, this only relates
+ * given, all preceding ones must be given, too. Of course, this only relates
* to the Python functions and methods described here and only inside Python
* code. [ This will go to another file later, probably the main exppython
* doc file]. XXX Better: put optional args with their default value:
@@ -52,7 +52,7 @@
/*****************************************************************************/
-/* Python World_Type callback function prototypes: */
+/* Python World_Type callback function prototypes: */
/*****************************************************************************/
static void World_DeAlloc (BPy_World *self);
//static int World_Print (BPy_World *self, FILE *fp, int flags);
@@ -62,31 +62,31 @@ static PyObject *World_GetAttr (BPy_World *self, char *name);
static PyObject *World_Repr (BPy_World *self);
/*****************************************************************************/
-/* Python World_Type structure definition: */
+/* Python World_Type structure definition: */
/*****************************************************************************/
PyTypeObject World_Type =
{
- PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "World", /* tp_name */
- sizeof (BPy_World), /* tp_basicsize */
- 0, /* tp_itemsize */
- /* methods */
- (destructor)World_DeAlloc, /* tp_dealloc */
- 0, /* tp_print */
- (getattrfunc)World_GetAttr, /* tp_getattr */
- (setattrfunc)World_SetAttr, /* tp_setattr */
- (cmpfunc)World_Compare, /* tp_compare */
- (reprfunc)World_Repr, /* tp_repr */
- 0, /* tp_as_number */
- 0, /* tp_as_sequence */
- 0, /* tp_as_mapping */
- 0, /* tp_as_hash */
- 0,0,0,0,0,0,
- 0, /* tp_doc */
- 0,0,0,0,0,0,
- BPy_World_methods, /* tp_methods */
- 0, /* tp_members */
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "World", /* tp_name */
+ sizeof (BPy_World), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ /* methods */
+ (destructor)World_DeAlloc, /* tp_dealloc */
+ 0, /* tp_print */
+ (getattrfunc)World_GetAttr, /* tp_getattr */
+ (setattrfunc)World_SetAttr, /* tp_setattr */
+ (cmpfunc)World_Compare, /* tp_compare */
+ (reprfunc)World_Repr, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_as_hash */
+ 0,0,0,0,0,0,
+ 0, /* tp_doc */
+ 0,0,0,0,0,0,
+ BPy_World_methods, /* tp_methods */
+ 0, /* tp_members */
};
/**
@@ -111,37 +111,37 @@ static PyObject *M_World_New(PyObject *self, PyObject *args, PyObject *kwords)
World *add_world(char *name);
char*name = NULL;
- BPy_World *pyworld;
- World *blworld;
+ BPy_World *pyworld;
+ World *blworld;
if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected int argument"));
- blworld = add_world(name);
+ blworld = add_world(name);
- if (blworld)
+ if (blworld)
pyworld = (BPy_World *)PyObject_NEW(BPy_World, &World_Type);
- else
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ else
+ return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
"couldn't create World Data in Blender"));
- if (pyworld == NULL)
- return (EXPP_ReturnPyObjError (PyExc_MemoryError,
+ if (pyworld == NULL)
+ return (EXPP_ReturnPyObjError (PyExc_MemoryError,
"couldn't create World Data object"));
- pyworld->world = blworld;
+ pyworld->world = blworld;
- return (PyObject *)pyworld;
+ return (PyObject *)pyworld;
}
/**
* \brief Python module function: Blender.World.Get()
*
- * This is the .Get() function of the Blender.World submodule. It searches
+ * This is the .Get() function of the Blender.World submodule. It searches
* the list of current World Data objects and returns a Python wrapper for
- * the one with the name provided by the user. If called with no arguments,
+ * the one with the name provided by the user. If called with no arguments,
* it returns a list of all current World Data object names in Blender.
* \param <name> - string: The name of an existing Blender World Data object.
* \return () - A list with the names of all current World Data objects;\n
@@ -152,48 +152,48 @@ static PyObject *M_World_New(PyObject *self, PyObject *args, PyObject *kwords)
static PyObject *M_World_Get(PyObject *self, PyObject *args)
{
- char *name = NULL;
- World *world_iter;
- PyObject *worldlist;
- BPy_World *wanted_world = NULL;
- char error_msg[64];
+ char *name = NULL;
+ World *world_iter;
+ PyObject *worldlist;
+ BPy_World *wanted_world = NULL;
+ char error_msg[64];
if (!PyArg_ParseTuple(args, "|s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected string argument (or nothing)"));
- world_iter = G.main->world.first;
+ world_iter = G.main->world.first;
if (name) { /* (name) - Search world by name */
- while ((world_iter) && (wanted_world == NULL)) {
- if (strcmp (name, world_iter->id.name+2) == 0) {
- wanted_world = (BPy_World *)PyObject_NEW(BPy_World, &World_Type);
+ while ((world_iter) && (wanted_world == NULL)) {
+ if (strcmp (name, world_iter->id.name+2) == 0) {
+ wanted_world = (BPy_World *)PyObject_NEW(BPy_World, &World_Type);
if (wanted_world) wanted_world->world = world_iter;
- }
- world_iter = world_iter->id.next;
- }
+ }
+ world_iter = world_iter->id.next;
+ }
- if (wanted_world == NULL) { /* Requested world doesn't exist */
- PyOS_snprintf(error_msg, sizeof(error_msg),
+ if (wanted_world == NULL) { /* Requested world doesn't exist */
+ PyOS_snprintf(error_msg, sizeof(error_msg),
"World \"%s\" not found", name);
- return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
- }
+ return (EXPP_ReturnPyObjError (PyExc_NameError, error_msg));
+ }
- return (PyObject *)wanted_world;
+ return (PyObject *)wanted_world;
}
else { /* return a list of all worlds in the scene */
- worldlist = PyList_New (0);
- if (worldlist == NULL)
- return (PythonReturnErrorObject (PyExc_MemoryError,
+ worldlist = PyList_New (0);
+ if (worldlist == NULL)
+ return (PythonReturnErrorObject (PyExc_MemoryError,
"couldn't create PyList"));
while (world_iter) {
BPy_World *found_world = (BPy_World *)PyObject_NEW(BPy_World, &World_Type);
found_world->world = world_iter;
- PyList_Append (worldlist , (PyObject *)found_world);
+ PyList_Append (worldlist , (PyObject *)found_world);
- world_iter = world_iter->id.next;
+ world_iter = world_iter->id.next;
}
return (worldlist);
}
@@ -211,31 +211,82 @@ static PyObject *M_World_Get(PyObject *self, PyObject *args)
PyObject *World_Init (void)
{
- PyObject *submodule;
+ PyObject *submodule;
- World_Type.ob_type = &PyType_Type;
+ World_Type.ob_type = &PyType_Type;
- submodule = Py_InitModule3("Blender.World",
- M_World_methods, M_World_doc);
+ submodule = Py_InitModule3("Blender.World",
+ M_World_methods, M_World_doc);
- return (submodule);
+ return (submodule);
}
/*****************************************************************************/
-/* Python BPy_World methods: */
+/* Python BPy_World methods: */
/*****************************************************************************/
-
-
static PyObject *World_getIpo(BPy_World *self)
{
-PyObject *Ipo_CreatePyObject (Ipo *ipo);
- struct Ipo*ipo = self->world->ipo;
- if (!ipo) return EXPP_ReturnPyObjError(PyExc_RuntimeError,"World has no Ipo");
+ struct Ipo *ipo = self->world->ipo;
+
+ if (!ipo) {
+ Py_INCREF (Py_None);
+ return Py_None;
+ }
+
return Ipo_CreatePyObject (ipo);
}
+static PyObject *World_setIpo(BPy_World *self, PyObject *args)
+{
+ PyObject *pyipo = 0;
+ Ipo *ipo = NULL;
+ Ipo *oldipo;
+
+ if (!PyArg_ParseTuple(args, "O!", &Ipo_Type, &pyipo))
+ return EXPP_ReturnPyObjError (PyExc_TypeError, "expected Ipo as argument");
+
+ ipo = Ipo_FromPyObject(pyipo);
+
+ if (!ipo) return EXPP_ReturnPyObjError (PyExc_RuntimeError, "null ipo!");
+
+ if (ipo->blocktype != ID_CA)
+ return EXPP_ReturnPyObjError (PyExc_TypeError,
+ "this ipo is not a World type ipo");
+
+ oldipo = self->world->ipo;
+ if (oldipo) {
+ ID *id = &oldipo->id;
+ if (id->us > 0) id->us--;
+ }
+
+ ((ID *)&ipo->id)->us++;
+
+ self->world->ipo = ipo;
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+static PyObject *World_clearIpo(BPy_World *self)
+{
+ World *world = self->world;
+ Ipo *ipo = (Ipo *)world->ipo;
+
+ if (ipo) {
+ ID *id = &ipo->id;
+ if (id->us > 0) id->us--;
+ world->ipo = NULL;
+
+ Py_INCREF (Py_True);
+ return Py_True;
+ }
+
+ Py_INCREF (Py_False); /* no ipo found */
+ return Py_False;
+}
+
/**
* \brief World PyMethod getName
*
@@ -244,12 +295,12 @@ PyObject *Ipo_CreatePyObject (Ipo *ipo);
static PyObject *World_getName(BPy_World *self)
{
- PyObject *attr = PyString_FromString(self->world->id.name+2);
+ PyObject *attr = PyString_FromString(self->world->id.name+2);
- if (attr) return attr;
+ if (attr) return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get World.name attribute"));
+ return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "couldn't get World.name attribute"));
}
/**
* \brief World PyMethod setName
@@ -258,15 +309,15 @@ static PyObject *World_getName(BPy_World *self)
static PyObject *World_setName(BPy_World *self, PyObject *args)
{
- char *name = 0;
- char buf[21];
- if (!PyArg_ParseTuple(args, "s", &name))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected string argument"));
- snprintf(buf, sizeof(buf), "%s", name);
- rename_id(&self->world->id, buf);
+ char *name = 0;
+ char buf[21];
+ if (!PyArg_ParseTuple(args, "s", &name))
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected string argument"));
+ snprintf(buf, sizeof(buf), "%s", name);
+ rename_id(&self->world->id, buf);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
@@ -281,12 +332,12 @@ static PyObject *World_setName(BPy_World *self, PyObject *args)
static PyObject *World_getSkytype(BPy_World *self)
{
- PyObject *attr = PyInt_FromLong((long)self->world->skytype);
+ PyObject *attr = PyInt_FromLong((long)self->world->skytype);
- if (attr) return attr;
+ if (attr) return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get World.skytype attribute"));
+ return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "couldn't get World.skytype attribute"));
}
@@ -298,14 +349,14 @@ static PyObject *World_getSkytype(BPy_World *self)
static PyObject *World_setSkytype(BPy_World *self, PyObject *args )
{
- int skytype;
+ int skytype;
- if (!PyArg_ParseTuple(args, "i", &skytype))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ if (!PyArg_ParseTuple(args, "i", &skytype))
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected int argument"));
self->world->skytype = skytype;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
@@ -317,12 +368,12 @@ static PyObject *World_setSkytype(BPy_World *self, PyObject *args )
static PyObject *World_getMode(BPy_World *self)
{
- PyObject *attr = PyInt_FromLong((long)self->world->mode);
+ PyObject *attr = PyInt_FromLong((long)self->world->mode);
- if (attr) return attr;
+ if (attr) return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get World.mode attribute"));
+ return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "couldn't get World.mode attribute"));
}
@@ -334,14 +385,14 @@ static PyObject *World_getMode(BPy_World *self)
static PyObject *World_setMode(BPy_World *self, PyObject *args )
{
- int mode;
+ int mode;
- if (!PyArg_ParseTuple(args, "i", &mode))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ if (!PyArg_ParseTuple(args, "i", &mode))
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected int argument"));
self->world->mode = mode;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
@@ -365,12 +416,12 @@ static PyObject *World_setMode(BPy_World *self, PyObject *args )
static PyObject *World_getMistype(BPy_World *self)
{
- PyObject *attr = PyInt_FromLong((long)self->world->mistype);
+ PyObject *attr = PyInt_FromLong((long)self->world->mistype);
- if (attr) return attr;
+ if (attr) return attr;
- return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't get World.mistype attribute"));
+ return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
+ "couldn't get World.mistype attribute"));
}
@@ -382,14 +433,14 @@ static PyObject *World_getMistype(BPy_World *self)
static PyObject *World_setMistype(BPy_World *self, PyObject *args )
{
- int mistype;
+ int mistype;
- if (!PyArg_ParseTuple(args, "i", &mistype))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
- "expected int argument"));
+ if (!PyArg_ParseTuple(args, "i", &mistype))
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,
+ "expected int argument"));
self->world->mistype = mistype;
- Py_INCREF(Py_None);
- return Py_None;
+ Py_INCREF(Py_None);
+ return Py_None;
}
@@ -398,10 +449,10 @@ static PyObject *World_setMistype(BPy_World *self, PyObject *args )
static PyObject *World_getHor(BPy_World *self)
{
- PyObject *attr = PyList_New(0);
+ PyObject *attr = PyList_New(0);
if (!attr)
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create list"));
+ "couldn't create list"));
PyList_Append(attr, PyFloat_FromDouble(self->world->horr));
PyList_Append(attr, PyFloat_FromDouble(self->world->horg));
PyList_Append(attr, PyFloat_FromDouble(self->world->horb));
@@ -412,8 +463,8 @@ static PyObject *World_getHor(BPy_World *self)
static PyObject *World_setHor(BPy_World *self, PyObject *args )
{
PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
+ if (!PyArg_ParseTuple(args, "O", &listargs))
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected list argument"));
self->world->horr = PyFloat_AsDouble(PyList_GetItem(listargs,0));
self->world->horg = PyFloat_AsDouble(PyList_GetItem(listargs,1));
@@ -425,10 +476,10 @@ static PyObject *World_setHor(BPy_World *self, PyObject *args )
static PyObject *World_getZen(BPy_World *self)
{
- PyObject *attr = PyList_New(0);
+ PyObject *attr = PyList_New(0);
if (!attr)
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create list"));
+ "couldn't create list"));
PyList_Append(attr, PyFloat_FromDouble(self->world->zenr));
PyList_Append(attr, PyFloat_FromDouble(self->world->zeng));
PyList_Append(attr, PyFloat_FromDouble(self->world->zenb));
@@ -439,8 +490,8 @@ static PyObject *World_getZen(BPy_World *self)
static PyObject *World_setZen(BPy_World *self, PyObject *args )
{
PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,
+ if (!PyArg_ParseTuple(args, "O", &listargs))
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,
"expected list argument"));
self->world->zenr = PyFloat_AsDouble(PyList_GetItem(listargs,0));
self->world->zeng = PyFloat_AsDouble(PyList_GetItem(listargs,1));
@@ -454,10 +505,10 @@ static PyObject *World_setZen(BPy_World *self, PyObject *args )
static PyObject *World_getAmb(BPy_World *self)
{
- PyObject *attr = PyList_New(0);
+ PyObject *attr = PyList_New(0);
if (!attr)
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,
- "couldn't create list"));
+ "couldn't create list"));
PyList_Append(attr, PyFloat_FromDouble(self->world->ambr));
PyList_Append(attr, PyFloat_FromDouble(self->world->ambg));
PyList_Append(attr, PyFloat_FromDouble(self->world->ambb));
@@ -468,12 +519,12 @@ static PyObject *World_getAmb(BPy_World *self)
static PyObject *World_setAmb(BPy_World *self, PyObject *args )
{
PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
+ if (!PyArg_ParseTuple(args, "O", &listargs))
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
if (PyList_Size(listargs)!=3)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"wrong list size"));
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"wrong list size"));
self->world->ambr = PyFloat_AsDouble(PyList_GetItem(listargs,0));
self->world->ambg = PyFloat_AsDouble(PyList_GetItem(listargs,1));
self->world->ambb = PyFloat_AsDouble(PyList_GetItem(listargs,2));
@@ -484,7 +535,7 @@ static PyObject *World_setAmb(BPy_World *self, PyObject *args )
static PyObject *World_getStar(BPy_World *self)
{
- PyObject *attr = PyList_New(0);
+ PyObject *attr = PyList_New(0);
if (!attr)
return (EXPP_ReturnPyObjError (PyExc_RuntimeError,"couldn't create list"));
PyList_Append(attr, PyFloat_FromDouble(self->world->starr));
@@ -501,14 +552,14 @@ static PyObject *World_getStar(BPy_World *self)
static PyObject *World_setStar(BPy_World *self, PyObject *args )
{
PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
+ if (!PyArg_ParseTuple(args, "O", &listargs))
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
if (PyList_Size(listargs)!=7)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"wrong list size"));
- self->world->starr = PyFloat_AsDouble(PyList_GetItem(listargs,0));
- self->world->starg = PyFloat_AsDouble(PyList_GetItem(listargs,1));
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"wrong list size"));
+ self->world->starr = PyFloat_AsDouble(PyList_GetItem(listargs,0));
+ self->world->starg = PyFloat_AsDouble(PyList_GetItem(listargs,1));
self->world->starb = PyFloat_AsDouble(PyList_GetItem(listargs,2));
self->world->starsize = PyFloat_AsDouble(PyList_GetItem(listargs,3));
self->world->starmindist = PyFloat_AsDouble(PyList_GetItem(listargs,4));
@@ -525,7 +576,7 @@ static PyObject *World_setStar(BPy_World *self, PyObject *args )
static PyObject *World_getMist(BPy_World *self)
{
- PyObject *attr = PyList_New(0);
+ PyObject *attr = PyList_New(0);
if (!attr)
return (EXPP_ReturnPyObjError (PyExc_RuntimeError, "couldn't create list"));
PyList_Append(attr, PyFloat_FromDouble(self->world->misi));
@@ -539,14 +590,14 @@ static PyObject *World_getMist(BPy_World *self)
static PyObject *World_setMist(BPy_World *self, PyObject *args )
{
PyObject *listargs=0;
- if (!PyArg_ParseTuple(args, "O", &listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
+ if (!PyArg_ParseTuple(args, "O", &listargs))
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
if (!PyList_Check(listargs))
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected list argument"));
if (PyList_Size(listargs)!=4)
- return (EXPP_ReturnPyObjError (PyExc_TypeError,"wrong list size"));
+ return (EXPP_ReturnPyObjError (PyExc_TypeError,"wrong list size"));
self->world->misi = PyFloat_AsDouble(PyList_GetItem(listargs,0));
- self->world->miststa = PyFloat_AsDouble(PyList_GetItem(listargs,1));
+ self->world->miststa = PyFloat_AsDouble(PyList_GetItem(listargs,1));
self->world->mistdist = PyFloat_AsDouble(PyList_GetItem(listargs,2));
self->world->misthi = PyFloat_AsDouble(PyList_GetItem(listargs,3));
Py_INCREF(Py_None);
@@ -564,7 +615,7 @@ static PyObject *World_setMist(BPy_World *self, PyObject *args )
static void World_DeAlloc (BPy_World *self)
{
- PyObject_DEL (self);
+ PyObject_DEL (self);
}
/**
@@ -578,15 +629,15 @@ static PyObject *World_GetAttr (BPy_World *self, char *name)
{
if (strcmp (name, "name") == 0)return World_getName (self);
-if (strcmp (name, "skytype") == 0)return World_getSkytype (self);
+if (strcmp (name, "skytype") == 0)return World_getSkytype (self);
if (strcmp (name, "mode") == 0)return World_getMode (self);
-if (strcmp (name, "mistype") == 0)return World_getMistype (self);
-if (strcmp (name, "hor") == 0)return World_getHor (self);
-if (strcmp (name, "zen") == 0)return World_getZen (self);
-if (strcmp (name, "amb") == 0)return World_getAmb (self);
+if (strcmp (name, "mistype") == 0)return World_getMistype (self);
+if (strcmp (name, "hor") == 0)return World_getHor (self);
+if (strcmp (name, "zen") == 0)return World_getZen (self);
+if (strcmp (name, "amb") == 0)return World_getAmb (self);
if (strcmp (name, "star") == 0)return World_getStar (self);
if (strcmp (name, "mist") == 0)return World_getMist (self);
- return Py_FindMethod(BPy_World_methods, (PyObject *)self, name);
+ return Py_FindMethod(BPy_World_methods, (PyObject *)self, name);
}
/**
@@ -598,10 +649,10 @@ if (strcmp (name, "mist") == 0)return World_getMist (self);
static int World_SetAttr (BPy_World *self, char *name, PyObject *value)
{
- PyObject *valtuple = Py_BuildValue("(O)", value);
+ PyObject *valtuple = Py_BuildValue("(O)", value);
- if (!valtuple)
- return EXPP_ReturnIntError(PyExc_MemoryError,
+ if (!valtuple)
+ return EXPP_ReturnIntError(PyExc_MemoryError,
"WorldSetAttr: couldn't parse args");
if (strcmp (name, "name") == 0) World_setName (self,valtuple);
if (strcmp (name, "skytype") == 0) World_setSkytype (self,valtuple);
@@ -619,17 +670,17 @@ return 0; /* normal exit */
* \brief The World PyType compare function
*
* This function compares two given World PyObjects, returning 0 for equality
- * and -1 otherwise. In Python it becomes 1 if they are equal and 0 case not.
+ * and -1 otherwise. In Python it becomes 1 if they are equal and 0 case not.
* The comparison is done with their pointers to Blender World Data objects,
* so any two wrappers pointing to the same Blender World Data will be
- * considered the same World PyObject. Currently, only the "==" and "!="
+ * considered the same World PyObject. Currently, only the "==" and "!="
* comparisons are meaninful -- the "<", "<=", ">" or ">=" are not.
*/
static int World_Compare (BPy_World *a, BPy_World *b)
{
- World *pa = a->world, *pb = b->world;
- return (pa == pb) ? 0:-1;
+ World *pa = a->world, *pb = b->world;
+ return (pa == pb) ? 0:-1;
}
/**
@@ -642,8 +693,8 @@ static int World_Compare (BPy_World *a, BPy_World *b)
/*
static int World_Print(BPy_World *self, FILE *fp, int flags)
{
- fprintf(fp, "[World \"%s\"]", self->world->id.name+2);
- return 0;
+ fprintf(fp, "[World \"%s\"]", self->world->id.name+2);
+ return 0;
}
*/
@@ -651,34 +702,34 @@ static int World_Print(BPy_World *self, FILE *fp, int flags)
* \brief The World PyType repr callback
*
* This function is called when the statement "repr(myworld)" is executed in
- * Python. Repr gives a string representation of a PyObject.
+ * Python. Repr gives a string representation of a PyObject.
*/
static PyObject *World_Repr (BPy_World *self)
{
- return PyString_FromFormat("[World \"%s\"]", self->world->id.name+2);
+ return PyString_FromFormat("[World \"%s\"]", self->world->id.name+2);
}
/*@}*/
-
+/*
static int World_compare (BPy_World *a, BPy_World *b)
{
- World *pa = a->world, *pb = b->world;
- return (pa == pb) ? 0:-1;
+ World *pa = a->world, *pb = b->world;
+ return (pa == pb) ? 0:-1;
}
-
+*/
PyObject* World_CreatePyObject (struct World *world)
{
- BPy_World * blen_object;
+ BPy_World * blen_object;
- blen_object = (BPy_World*)PyObject_NEW (BPy_World, &World_Type);
+ blen_object = (BPy_World*)PyObject_NEW (BPy_World, &World_Type);
- if (blen_object == NULL)
- {
- return (NULL);
- }
- blen_object->world = world;
- return ((PyObject*)blen_object);
+ if (blen_object == NULL)
+ {
+ return (NULL);
+ }
+ blen_object->world = world;
+ return ((PyObject*)blen_object);
}
@@ -690,20 +741,20 @@ return (py_obj->ob_type == &World_Type);
World* World_FromPyObject (PyObject *py_obj)
{
- BPy_World * blen_obj;
+ BPy_World * blen_obj;
- blen_obj = (BPy_World*)py_obj;
- return (blen_obj->world);
+ blen_obj = (BPy_World*)py_obj;
+ return (blen_obj->world);
}
/*****************************************************************************/
-/* Description: Returns the object with the name specified by the argument */
-/* name. Note that the calling function has to remove the first */
-/* two characters of the object name. These two characters */
-/* specify the type of the object (OB, ME, WO, ...) */
-/* The function will return NULL when no object with the given */
-/* name is found. */
+/* Description: Returns the object with the name specified by the argument */
+/* name. Note that the calling function has to remove the first */
+/* two characters of the object name. These two characters */
+/* specify the type of the object (OB, ME, WO, ...) */
+/* The function will return NULL when no object with the given */
+/* name is found. */
/*****************************************************************************/
World * GetWorldByName (char * name)
{
diff --git a/source/blender/python/api2_2x/World.h b/source/blender/python/api2_2x/World.h
index 4fec474aa5d..8889888320a 100644
--- a/source/blender/python/api2_2x/World.h
+++ b/source/blender/python/api2_2x/World.h
@@ -38,6 +38,7 @@
#include "constant.h"
#include "gen_utils.h"
#include "bpy_types.h"
+#include "modules.h"
/*****************************************************************************/
@@ -80,6 +81,8 @@ struct PyMethodDef M_World_methods[] = {
/* Python BPy_World methods declarations: */
/*****************************************************************************/
static PyObject *World_getIpo(BPy_World *self);
+static PyObject *World_setIpo(BPy_World *self, PyObject *args);
+static PyObject *World_clearIpo(BPy_World *self);
static PyObject *World_getName(BPy_World *self);
static PyObject *World_setName(BPy_World *self, PyObject *args);
static PyObject *World_getSkytype(BPy_World *self);
@@ -103,6 +106,10 @@ static PyObject *World_setMist(BPy_World *self, PyObject *args );
static PyMethodDef BPy_World_methods[] = {
{"getIpo", (PyCFunction)World_getIpo, METH_NOARGS,
"() - Return World Ipo"},
+ {"setIpo", (PyCFunction)World_setIpo, METH_VARARGS,
+ "() - Change this World's ipo"},
+ {"clearIpo", (PyCFunction)World_clearIpo, METH_VARARGS,
+ "() - Unlink Ipo from this World"},
{"getName", (PyCFunction)World_getName, METH_NOARGS,
"() - Return World Data name"},
{"setName", (PyCFunction)World_setName, METH_VARARGS,
diff --git a/source/blender/python/api2_2x/doc/Camera.py b/source/blender/python/api2_2x/doc/Camera.py
index a9fd6bf7a4b..77e2cf3830f 100644
--- a/source/blender/python/api2_2x/doc/Camera.py
+++ b/source/blender/python/api2_2x/doc/Camera.py
@@ -54,6 +54,8 @@ class Camera:
@cvar clipStart: The clip start value in [0.0, 100.0].
@cvar clipEnd: The clip end value in [1.0, 5000.0].
@cvar drawSize: The draw size value in [0.1, 10.0].
+ @type ipo: Blender Ipo
+ @cvar ipo: The "camera data" ipo linked to this camera data object.
@warning: Most member variables assume values in some [Min, Max] interval.
When trying to set them, the given parameter will be clamped to lie in
that range: if val < Min, then val = Min, if val > Max, then val = Max.
@@ -64,13 +66,6 @@ class Camera:
Get the name of this Camera Data object.
@rtype: string
"""
- def getIpo():
- """
- Retreives the Ipo (if any) of a camera object
- @rtype: Ipo object
- @return: the Ipo of the camera object.
- """
-
def setName(name):
"""
@@ -79,6 +74,26 @@ class Camera:
@param name: The new name.
"""
+ def getIpo():
+ """
+ Get the Ipo associated with this camera data object, if any.
+ @rtype: Ipo
+ @return: the wrapped ipo or None.
+ """
+
+ def setIpo(ipo):
+ """
+ Link an ipo to this camera data object.
+ @type ipo: Blender Ipo
+ @param ipo: a "camera data" ipo.
+ """
+
+ def clearIpo():
+ """
+ Unlink the ipo from this camera data object.
+ @return: True if there was an ipo linked or False otherwise.
+ """
+
def getType():
"""
Get this Camera's type.
diff --git a/source/blender/python/api2_2x/doc/Material.py b/source/blender/python/api2_2x/doc/Material.py
index 8ee69c842b9..ea85f841f09 100644
--- a/source/blender/python/api2_2x/doc/Material.py
+++ b/source/blender/python/api2_2x/doc/Material.py
@@ -110,18 +110,13 @@ class Material:
@cvar nStars: Number of points on the halo stars - [3, 50].
@cvar nLines: Number of star shaped lines on each halo - [0, 250].
@cvar nRings: Number of halo rings - [0, 24].
+ @type ipo: Blender Ipo
+ @cvar ipo: This Material's ipo.
@warning: Most member variables assume values in some [Min, Max] interval.
When trying to set them, the given parameter will be clamped to lie in
that range: if val < Min, then val = Min, if val > Max, then val = Max.
- """
-
+ """
- def getIpo():
- """
- Retreives the Ipo (if any) of an material object
- @rtype: Ipo object
- @return: the Ipo of the material object.
- """
def getName():
"""
Get the name of this Material object.
@@ -135,6 +130,26 @@ class Material:
@param name: The new name.
"""
+ def getIpo():
+ """
+ Get the Ipo associated with this material, if any.
+ @rtype: Ipo
+ @return: the wrapped ipo or None.
+ """
+
+ def setIpo(ipo):
+ """
+ Link an ipo to this material.
+ @type ipo: Blender Ipo
+ @param ipo: a material type ipo.
+ """
+
+ def clearIpo():
+ """
+ Unlink the ipo from this material.
+ @return: True if there was an ipo linked or False otherwise.
+ """
+
def getMode():
"""
Get this Material's mode flags.
diff --git a/source/blender/python/api2_2x/doc/NMesh.py b/source/blender/python/api2_2x/doc/NMesh.py
index 900821303f9..af70de42ea6 100644
--- a/source/blender/python/api2_2x/doc/NMesh.py
+++ b/source/blender/python/api2_2x/doc/NMesh.py
@@ -37,6 +37,7 @@ Example::
- TWOSIDED - double sided mesh.
- AUTOSMOOTH - turn auto smoothing of faces "on".
- SUBSURF - turn Catmull-Clark subdivision of surfaces "on".
+ - OPTIMAL - optimal drawing of edges when "SubSurf" is "on".
@var FaceFlags: The available face selection flags.
- SELECT - selected.
- HIDE - hidden.
@@ -374,11 +375,12 @@ class NMesh:
Modes not passed in are turned "off", so setMode() (without arguments)
unsets all mode flags.
@type m: string
- @param m: mode string. From none to 4 can be given:
+ @param m: mode string. From none to 5 can be given:
- "NoVNormalsFlip"
- "TwoSided"
- "AutoSmooth"
- "SubSurf"
+ - "Optimal"
"""
def addVertGroup(group):
diff --git a/source/blender/python/api2_2x/doc/World.py b/source/blender/python/api2_2x/doc/World.py
index 67a14fb4428..7cda8c853fd 100644
--- a/source/blender/python/api2_2x/doc/World.py
+++ b/source/blender/python/api2_2x/doc/World.py
@@ -52,6 +52,8 @@ class World:
@cvar amb: the ambient color of a world object.
@cvar star: the star parameters of a world object. See getStar for the semantics of these parameters.
@cvar mist: the mist parameters of a world object. See getMist for the semantics of these parameters.
+ @type ipo: Blender Ipo
+ @cvar ipo: The world type ipo linked to this world object.
"""
def getName():
@@ -61,14 +63,6 @@ class World:
@return: the name of the world object.
"""
- def getIpo():
- """
- Retreives the Ipo (if any) of an world object
- @rtype: Ipo object
- @return: the Ipo of the world object.
- """
-
-
def setName(name):
"""
Sets the name of a world object.
@@ -78,6 +72,26 @@ class World:
@return: PyNone
"""
+ def getIpo():
+ """
+ Get the Ipo associated with this world object, if any.
+ @rtype: Ipo
+ @return: the wrapped ipo or None.
+ """
+
+ def setIpo(ipo):
+ """
+ Link an ipo to this world object.
+ @type ipo: Blender Ipo
+ @param ipo: a "camera data" ipo.
+ """
+
+ def clearIpo():
+ """
+ Unlink the ipo from this world object.
+ @return: True if there was an ipo linked or False otherwise.
+ """
+
def getSkytype():
"""
Retreives the skytype of a world object.