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-06-13 08:21:48 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2003-06-13 08:21:48 +0400
commitf70302670e0ecb263819c3ed74e0079d46181e61 (patch)
treef11c7f6304ad5d0b681d369619452d3fb2997482 /source/blender
parentbbf8fe932f226314a097ac868d1909546949d53f (diff)
* Bugs item #169 fixed:
Now Blender.NMesh.PutRaw() doesn't destroy vertex color info anymore. Both exppython's NMesh.c and bpython's opy_nmesh.c were updated. * Minor changes in other files.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/bpython/intern/opy_nmesh.c2
-rw-r--r--source/blender/python/api2_2x/Blender.c2
-rw-r--r--source/blender/python/api2_2x/Camera.c176
-rw-r--r--source/blender/python/api2_2x/Draw.c2
-rw-r--r--source/blender/python/api2_2x/Draw.h94
-rw-r--r--source/blender/python/api2_2x/Metaball.c2
-rw-r--r--source/blender/python/api2_2x/Metaball.h2
-rw-r--r--source/blender/python/api2_2x/NMesh.c39
-rw-r--r--source/blender/python/api2_2x/NMesh.h6
-rw-r--r--source/blender/python/api2_2x/Types.c4
10 files changed, 183 insertions, 146 deletions
diff --git a/source/blender/bpython/intern/opy_nmesh.c b/source/blender/bpython/intern/opy_nmesh.c
index 46680278896..418d953f59e 100644
--- a/source/blender/bpython/intern/opy_nmesh.c
+++ b/source/blender/bpython/intern/opy_nmesh.c
@@ -1548,7 +1548,7 @@ static int convert_NMeshToMesh(Mesh *mesh, NMesh *nmesh)
Py_DECREF(mf);
newmf++;
- if (newmc) newmc++;
+ if (newmc) newmc += 4; /* there are 4 MCol's per face */
}
}
return 1;
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c
index d1fd7c93cb6..a8d6bf1f886 100644
--- a/source/blender/python/api2_2x/Blender.c
+++ b/source/blender/python/api2_2x/Blender.c
@@ -195,7 +195,7 @@ PyObject *Blender_ReleaseGlobalDict(PyObject *self, PyObject *args)
"expected int argument (or nothing)");
}
- return Py_BuildValue("i", (EXPP_releaseGlobalDict?1:0));
+ return Py_BuildValue("i", (EXPP_releaseGlobalDict ? 1:0));
}
/*****************************************************************************/
diff --git a/source/blender/python/api2_2x/Camera.c b/source/blender/python/api2_2x/Camera.c
index c1c6e5011fc..fc14f78532f 100644
--- a/source/blender/python/api2_2x/Camera.c
+++ b/source/blender/python/api2_2x/Camera.c
@@ -29,11 +29,13 @@
* ***** END GPL/BL DUAL LICENSE BLOCK *****
*/
-/**
+/*!
* \file Camera.c
* \ingroup scripts
* \brief Blender.Camera Module and Camera Data PyObject implementation.
*
+ * This file is kept as a reference for new developers. If you want to
+ * create a new Python Module for Blender, Camera.c is a good starting point.
*/
#include <BKE_main.h>
@@ -44,6 +46,7 @@
#include "Camera.h"
+
/*****************************************************************************/
/* Python BPy_Camera defaults: */
/*****************************************************************************/
@@ -81,6 +84,12 @@ static PyObject *M_Camera_Get (PyObject *self, PyObject *args);
/* In Python these will be written to the console when doing a */
/* Blender.Camera.__doc__ */
/*****************************************************************************/
+
+/*!
+ * \var M_Camera_doc
+ * \brief Doc string for the Blender.Camera module
+ */
+
static char M_Camera_doc[] =
"The Blender Camera module\n\
\n\
@@ -95,7 +104,12 @@ Example::\n\
ob = Object.New('Camera') # make camera object\n\
ob.link(c) # link camera data with this object\n\
cur.link(ob) # link object into scene\n\
- cur.setCurrentCamera(ob) # make this camera the active\n";
+ cur.setCurrentCamera(ob) # make this camera the active";
+
+/*!
+ * \var M_Camera_New_doc
+ * \brief Doc string for the Blender.Camera.New() module function
+ */
static char M_Camera_New_doc[] =
"Blender.Camera.New (type = 'persp', name = 'CamData'):\n\
@@ -104,6 +118,11 @@ static char M_Camera_New_doc[] =
which can be 'persp' or 'ortho';\n\
() - Return a new Camera Data object of type 'persp'.";
+/*!
+ * \var M_Camera_Get_doc
+ * \brief Doc string for the Blender.Camera.Get() module function
+ */
+
static char M_Camera_Get_doc[] =
"Blender.Camera.Get (name = None):\n\
\n\
@@ -114,6 +133,16 @@ static char M_Camera_Get_doc[] =
/*****************************************************************************/
/* Python method structure definition for Blender.Camera module: */
/*****************************************************************************/
+
+/*!
+ * \var M_Camera_methods
+ * \brief Table of module functions.
+ *
+ * The Blender.Camera functions are registered with this table.
+ * Each entry defines: the method name in Python, the pointer to its C
+ * function, the argument list expected and a doc string.
+ */
+
struct PyMethodDef M_Camera_methods[] = {
{"New",(PyCFunction)M_Camera_New, METH_VARARGS|METH_KEYWORDS,
M_Camera_New_doc},
@@ -145,6 +174,17 @@ static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args);
/*****************************************************************************/
/* Python BPy_Camera methods table: */
/*****************************************************************************/
+
+/*!
+ * \var BPy_Camera_methods
+ * \showinitializer
+ * \brief Table of Camera member functions
+ *
+ * This table registers the Camera PyObject methods.
+ * Each entry defines: the method name in Python, the pointer to its C
+ * function, the argument list expected and a doc string.
+ */
+
static PyMethodDef BPy_Camera_methods[] = {
/* name, method, flags, doc */
{"getName", (PyCFunction)Camera_getName, METH_NOARGS,
@@ -189,46 +229,53 @@ static int Camera_Compare (BPy_Camera *a, BPy_Camera *b);
static PyObject *Camera_GetAttr (BPy_Camera *self, char *name);
static PyObject *Camera_Repr (BPy_Camera *self);
+/*!
+ * \var Camera_Type
+ * \brief Definition for the Camera PyObject struct
+ *
+ * Here we define the Camera PyType: its name, size, available function
+ * pointers and table of bound methods.
+ */
+
/*****************************************************************************/
/* Python Camera_Type structure definition: */
/*****************************************************************************/
PyTypeObject Camera_Type =
{
PyObject_HEAD_INIT(NULL)
- 0, /* ob_size */
- "Camera", /* tp_name */
- sizeof (BPy_Camera), /* tp_basicsize */
- 0, /* tp_itemsize */
+ 0, /* ob_size */
+ "Camera", /* tp_name */
+ sizeof (BPy_Camera), /* tp_basicsize */
+ 0, /* tp_itemsize */
/* methods */
- (destructor)Camera_DeAlloc, /* tp_dealloc */
- (printfunc)Camera_Print, /* 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 */
+ (destructor)Camera_DeAlloc, /* tp_dealloc */
+ (printfunc)Camera_Print, /* 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, /* tp_doc */
0,0,0,0,0,0,
- BPy_Camera_methods, /* tp_methods */
- 0, /* tp_members */
+ BPy_Camera_methods, /* tp_methods */
+ 0, /* tp_members */
};
-/**
- * \defgroup Camera_Module Blender.Camera module functions
- *
+/*!
+ * \defgroup M_Functions Blender.Camera functions
*/
-/*@{*/
+/*! @{ */
-/**
+/*!
* \brief Python module function: Blender.Camera.New()
*
* This is the .New() function of the Blender.Camera submodule. It creates
- * new Camera Data in Blender and returns its Python wrapper object. The
+ * new Camera Data in Blender and returns its wrapper PyObject. The
* parameters are optional and default to type = 'persp' and name = 'CamData'.
* \param <type> - string: The Camera type: 'persp' or 'ortho';
* \param <name> - string: The Camera Data name.
@@ -286,7 +333,7 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
return pycam;
}
-/**
+/*!
* \brief Python module function: Blender.Camera.Get()
*
* This is the .Get() function of the Blender.Camera submodule. It searches
@@ -361,9 +408,9 @@ static PyObject *M_Camera_Get(PyObject *self, PyObject *args)
}
}
-/*@}*/
+/*@} Cam_M_Functions */
-/**
+/*!
* \brief Initializes the Blender.Camera submodule
*
* This function is used by Blender_Init() in Blender.c to register the
@@ -387,7 +434,7 @@ PyObject *M_Camera_Init (void)
/* Three Python Camera_Type helper functions needed by the Object module: */
-/**
+/*!
* \brief Creates a new Python wrapper from an existing Blender Camera Data obj
*
* This is also used in Object.c when defining the object.data member variable
@@ -411,7 +458,7 @@ PyObject *Camera_CreatePyObject (Camera *cam)
return (PyObject *)pycam;
}
-/**
+/*!
* \brief Checks if the given object is of type BPy_Camera
*
* This is also used in Object.c when handling the object.data member variable
@@ -425,7 +472,7 @@ int Camera_CheckPyObject (PyObject *pyobj)
return (pyobj->ob_type == &Camera_Type);
}
-/**
+/*!
* \brief Returns the Blender Camera object from the given PyObject
*
* This is also used in Object.c when handling the object.data member variable
@@ -443,16 +490,14 @@ Camera *Camera_FromPyObject (PyObject *pyobj)
/* Python BPy_Camera methods: */
/*****************************************************************************/
-/**
- * \defgroup Camera_Methods Camera Method Functions
+/*!
+ * \defgroup CamMethods Camera Method Functions
*
- * These are the Camera PyObject method functions. They are used to get and
- * set values for the Camera Data member variables.
+ * These are the Camera PyObject methods.
+ * @{
*/
-/*@{*/
-
-/**
+/*!
* \brief Camera PyMethod getName
*
* \return string: The Camera Data name.
@@ -468,7 +513,7 @@ static PyObject *Camera_getName(BPy_Camera *self)
"couldn't get Camera.name attribute");
}
-/**
+/*!
* \brief Camera PyMethod getType
*
* \return int: The Camera Data type.
@@ -484,7 +529,7 @@ static PyObject *Camera_getType(BPy_Camera *self)
"couldn't get Camera.type attribute");
}
-/**
+/*!
* \brief Camera PyMethod getMode
*
* \return int: The Camera Data mode flags.
@@ -500,7 +545,7 @@ static PyObject *Camera_getMode(BPy_Camera *self)
"couldn't get Camera.Mode attribute");
}
-/**
+/*!
* \brief Camera PyMethod getLens
*
* \return float: The Camera Data lens value
@@ -516,7 +561,7 @@ static PyObject *Camera_getLens(BPy_Camera *self)
"couldn't get Camera.lens attribute");
}
-/**
+/*!
* \brief Camera PyMethod getClipStart
*
* \return float: The Camera Data clip start value.
@@ -532,7 +577,7 @@ static PyObject *Camera_getClipStart(BPy_Camera *self)
"couldn't get Camera.clipStart attribute");
}
-/**
+/*!
* \brief Camera PyMethod getClipEnd
* \return float: The Camera Data clip end value.
*/
@@ -547,7 +592,7 @@ static PyObject *Camera_getClipEnd(BPy_Camera *self)
"couldn't get Camera.clipEnd attribute");
}
-/**
+/*!
* \brief Camera method getDrawSize
* \return float: The Camera Data draw size value.
*/
@@ -562,7 +607,7 @@ static PyObject *Camera_getDrawSize(BPy_Camera *self)
"couldn't get Camera.drawSize attribute");
}
-/**
+/*!
* \brief Camera PyMethod setName
* \param name - string: The new Camera Data name.
*/
@@ -584,7 +629,7 @@ static PyObject *Camera_setName(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/**
+/*!
* \brief Camera PyMethod setType
* \param type - string: The new Camera Data type: 'persp' or 'ortho'.
*/
@@ -615,7 +660,7 @@ static PyObject *Camera_setType(BPy_Camera *self, PyObject *args)
* the method setType expects a string ('persp' or 'ortho') or an empty
* argument, this function should receive an int (0 or 1). */
-/**
+/*!
* \brief Internal helper function
*
* This one is not a PyMethod. It is just an internal helper function.
@@ -640,7 +685,7 @@ static PyObject *Camera_setIntType(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/**
+/*!
* \brief Camera PyMethod setMode
*
* There are two mode flags for Cameras: 'showLimits' and 'showMist'.
@@ -689,7 +734,7 @@ static PyObject *Camera_setMode(BPy_Camera *self, PyObject *args)
/* Another helper function, for the same reason.
* (See comment before Camera_setIntType above). */
-/**
+/*!
* \brief Internal helper function
*
* This one is not a PyMethod. It is just an internal helper function.
@@ -714,7 +759,7 @@ static PyObject *Camera_setIntMode(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/**
+/*!
* \brief Camera PyMethod setLens
* \param lens - float: The new Camera Data lens value.
*/
@@ -734,7 +779,7 @@ static PyObject *Camera_setLens(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/**
+/*!
* \brief Camera PyMethod setClipStart
* \param clipStart - float: The new Camera Data clip start value.
*/
@@ -754,7 +799,7 @@ static PyObject *Camera_setClipStart(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/**
+/*!
* \brief Camera PyMethod setClipEnd
* \param clipEnd - float: The new Camera Data clip end value.
*/
@@ -774,7 +819,7 @@ static PyObject *Camera_setClipEnd(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/**
+/*!
* \brief Camera PyMethod setDrawSize
* \param drawSize - float: The new Camera Data draw size value.
*/
@@ -794,18 +839,9 @@ static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args)
return Py_None;
}
-/*@}*/
-
-/**
- * \defgroup Camera_callbacks Callback functions for the Camera PyType
- *
- * These callbacks are called by the Python interpreter when dealing with
- * PyObjects of type Camera.
- */
-
-/*@{*/
+/*@} Cam_Methods group */
-/**
+/*!
* \brief The Camera PyType destructor
*/
@@ -814,7 +850,7 @@ static void Camera_DeAlloc (BPy_Camera *self)
PyObject_DEL (self);
}
-/**
+/*!
* \brief The Camera PyType attribute getter
*
* This is the callback called when a user tries to retrieve the contents of
@@ -866,7 +902,7 @@ static PyObject *Camera_GetAttr (BPy_Camera *self, char *name)
return Py_FindMethod(BPy_Camera_methods, (PyObject *)self, name);
}
-/**
+/*!
* \brief The Camera PyType attribute setter
*
* This is the callback called when the user tries to change the value of some
@@ -932,7 +968,7 @@ static int Camera_SetAttr (BPy_Camera *self, char *name, PyObject *value)
return 0; /* normal exit */
}
-/**
+/*!
* \brief The Camera PyType compare function
*
* This function compares two given Camera PyObjects, returning 0 for equality
@@ -949,7 +985,7 @@ static int Camera_Compare (BPy_Camera *a, BPy_Camera *b)
return (pa == pb) ? 0:-1;
}
-/**
+/*!
* \brief The Camera PyType print callback
*
* This function is called when the user tries to print a PyObject of type
@@ -962,7 +998,7 @@ static int Camera_Print(BPy_Camera *self, FILE *fp, int flags)
return 0;
}
-/**
+/*!
* \brief The Camera PyType repr callback
*
* This function is called when the statement "repr(mycamera)" is executed in
@@ -973,5 +1009,3 @@ static PyObject *Camera_Repr (BPy_Camera *self)
{
return PyString_FromString(self->camera->id.name+2);
}
-
-/*@}*/
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index 48b0c4c1abb..c08b0015470 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -636,7 +636,7 @@ PyObject *M_Draw_Init (void)
printf("In M_Draw_Init()\n");
- Button_Type.ob_type = &PyType_Type;
+ Button_Type.ob_type = &PyType_Type;
submodule = Py_InitModule3("Blender.Draw", Draw_methods, Draw_doc);
diff --git a/source/blender/python/api2_2x/Draw.h b/source/blender/python/api2_2x/Draw.h
index 8a4cdfa3cbb..3c7abb90b16 100644
--- a/source/blender/python/api2_2x/Draw.h
+++ b/source/blender/python/api2_2x/Draw.h
@@ -84,35 +84,35 @@ void initDraw (void);
/* Button Object */
typedef struct _Button {
- PyObject_VAR_HEAD
-
- int type; /*@ 1 == int, 2 == float, 3 == string */
- int slen; /*@ length of string (if type == 3) */
- union {
- int asint;
- float asfloat;
- char *asstr;
- } val;
+ PyObject_VAR_HEAD
+
+ int type; /*@ 1 == int, 2 == float, 3 == string */
+ int slen; /*@ length of string (if type == 3) */
+ union {
+ int asint;
+ float asfloat;
+ char *asstr;
+ } val;
} Button;
static void Button_dealloc(PyObject *self);
static PyObject *Button_getattr(PyObject *self, char *name);
-static int Button_setattr(PyObject *self, char *name, PyObject *v);
static PyObject *Button_repr(PyObject *self);
+static int Button_setattr(PyObject *self, char *name, PyObject *v);
PyTypeObject Button_Type =
{
- PyObject_HEAD_INIT(NULL)
- 0, /*ob_size*/
- "Button", /*tp_name*/
- sizeof(Button), /*tp_basicsize*/
- 0, /*tp_itemsize*/
- (destructor) Button_dealloc, /*tp_dealloc*/
- (printfunc) 0, /*tp_print*/
- (getattrfunc) Button_getattr, /*tp_getattr*/
- (setattrfunc) Button_setattr, /*tp_setattr*/
- (cmpfunc) 0, /*tp_cmp*/
- (reprfunc) Button_repr, /*tp_repr*/
+ PyObject_HEAD_INIT(NULL)
+ 0, /*ob_size*/
+ "Button", /*tp_name*/
+ sizeof(Button), /*tp_basicsize*/
+ 0, /*tp_itemsize*/
+ (destructor) Button_dealloc, /*tp_dealloc*/
+ (printfunc) 0, /*tp_print*/
+ (getattrfunc) Button_getattr, /*tp_getattr*/
+ (setattrfunc) Button_setattr, /*tp_setattr*/
+ (cmpfunc) 0, /*tp_cmp*/
+ (reprfunc) Button_repr, /*tp_repr*/
};
static Button *newbutton (void);
@@ -135,10 +135,10 @@ static char Method_Register_doc[] =
"(draw, event, button) - Register callbacks for windowing\n\n\
(draw) A function to draw the screen, taking no arguments\n\
(event) A function to handle events, taking 2 arguments (evt, val)\n\
- (evt) The event number\n\
- (val) The value modifier (for key and mouse press/release)\n\
+ (evt) The event number\n\
+ (val) The value modifier (for key and mouse press/release)\n\
(button) A function to handle button events, taking 1 argument (evt)\n\
- (evt) The button number\n\n\
+ (evt) The button number\n\n\
A None object can be passed if a callback is unused.";
static PyObject *Method_Register (PyObject *self, PyObject *args);
@@ -192,8 +192,8 @@ The menu options are specified through the name of the\n\
button. Options are followed by a format code and seperated\n\
by the '|' (pipe) character.\n\
Valid format codes are\n\
- %t - The option should be used as the title\n\
- %xN - The option should set the integer N in the button value.";
+ %t - The option should be used as the title\n\
+ %xN - The option should set the integer N in the button value.";
static PyObject *Method_Menu (PyObject *self, PyObject *args);
@@ -218,10 +218,10 @@ Create a new Slider button\n\n\
(x, y) The lower left coordinate of the button\n\
(width, height) The button width and height\n\
(initial, min, max) Three values (int or float) specifying the initial \
- and limit values.\n\
+ and limit values.\n\
[update=1] A value controlling whether the slider will emit events as it \
is edited.\n\
- A non-zero value (default) enables the events. A zero value supresses them.\n\
+ A non-zero value (default) enables the events. A zero value supresses them.\n\
[tooltip=""] The button's tooltip";
static PyObject *Method_Slider (PyObject *self, PyObject *args);
@@ -234,7 +234,7 @@ new Scrollbar\n\n\
(width, height) The button width and height\n\
(initial, min, max) Three values (int or float) specifying the initial and limit values.\n\
[update=1] A value controlling whether the slider will emit events as it is edited.\n\
- A non-zero value (default) enables the events. A zero value supresses them.\n\
+ A non-zero value (default) enables the events. A zero value supresses them.\n\
[tooltip=""] The button's tooltip";
static PyObject *Method_Scrollbar (PyObject *self, PyObject *args);
@@ -272,7 +272,7 @@ static char Method_Text_doc[] =
static PyObject *Method_Text (PyObject *self, PyObject *args);
#define _MethodDef(func, prefix) \
- {#func, prefix##_##func, METH_VARARGS, prefix##_##func##_doc}
+ {#func, prefix##_##func, METH_VARARGS, prefix##_##func##_doc}
/* So that _MethodDef(delete, Scene) expands to:
* {"delete", Scene_delete, METH_VARARGS, Scene_delete_doc} */
@@ -281,23 +281,23 @@ static PyObject *Method_Text (PyObject *self, PyObject *args);
#define MethodDef(func) _MethodDef(func, Method)
static struct PyMethodDef Draw_methods[] = {
- MethodDef(Create),
- MethodDef(Button),
- MethodDef(Toggle),
- MethodDef(Menu),
- MethodDef(Slider),
- MethodDef(Scrollbar),
- MethodDef(Number),
- MethodDef(String),
-
- MethodDef(Text),
-
- MethodDef(Exit),
- MethodDef(Redraw),
- MethodDef(Draw),
- MethodDef(Register),
-
- {NULL, NULL}
+ MethodDef(Create),
+ MethodDef(Button),
+ MethodDef(Toggle),
+ MethodDef(Menu),
+ MethodDef(Slider),
+ MethodDef(Scrollbar),
+ MethodDef(Number),
+ MethodDef(String),
+
+ MethodDef(Text),
+
+ MethodDef(Exit),
+ MethodDef(Redraw),
+ MethodDef(Draw),
+ MethodDef(Register),
+
+ {NULL, NULL}
};
PyObject *M_Draw_Init (void);
diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c
index 629d1868425..66a4e4d6acc 100644
--- a/source/blender/python/api2_2x/Metaball.c
+++ b/source/blender/python/api2_2x/Metaball.c
@@ -144,6 +144,8 @@ PyObject *M_Metaball_Init (void)
{
PyObject *submodule;
+ Metaball_Type.ob_type = &PyType_Type;
+
printf ("In M_Metaball_Init()\n");
submodule = Py_InitModule3("Blender.Metaball",
M_Metaball_methods, M_Metaball_doc);
diff --git a/source/blender/python/api2_2x/Metaball.h b/source/blender/python/api2_2x/Metaball.h
index 919cbe234b0..c79406862bd 100644
--- a/source/blender/python/api2_2x/Metaball.h
+++ b/source/blender/python/api2_2x/Metaball.h
@@ -280,7 +280,7 @@ static PyObject *MetaballRepr (C_Metaball *self);
/*****************************************************************************/
PyTypeObject Metaball_Type =
{
- PyObject_HEAD_INIT(&PyType_Type)
+ PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"Metaball", /* tp_name */
sizeof (C_Metaball), /* tp_basicsize */
diff --git a/source/blender/python/api2_2x/NMesh.c b/source/blender/python/api2_2x/NMesh.c
index 2bc2b009496..0142fd046bd 100644
--- a/source/blender/python/api2_2x/NMesh.c
+++ b/source/blender/python/api2_2x/NMesh.c
@@ -142,7 +142,6 @@ static void NMFace_dealloc (PyObject *self)
Py_DECREF(mf->v);
Py_DECREF(mf->uv);
Py_DECREF(mf->col);
- Py_XDECREF(mf->image);
PyObject_DEL(self);
}
@@ -218,7 +217,7 @@ static PyObject *NMFace_getattr(PyObject *self, char *name)
else if (strcmp(name, "image") == 0) {
if (mf->image)
- return Py_BuildValue("O", (PyObject *)mf->image);
+ return Image_CreatePyObject (mf->image);
else
return EXPP_incr_ret(Py_None);
}
@@ -298,18 +297,18 @@ static int NMFace_setattr(PyObject *self, char *name, PyObject *v)
return 0;
}
else if (strcmp(name, "image") == 0) {
- PyObject *img;
- if (!PyArg_Parse(v, "O!", &Image_Type, &img))
+ PyObject *pyimg;
+ if (!PyArg_Parse(v, "O!", &Image_Type, &pyimg))
return EXPP_ReturnIntError(PyExc_TypeError,
"expected image object");
- if (img == Py_None) {
+ if (pyimg == Py_None) {
mf->image = NULL;
return 0;
}
- mf->image = (C_Image *)img;
+ mf->image = ((C_Image *)pyimg)->image;
return 0;
}
@@ -869,8 +868,8 @@ static C_NMFace *nmface_from_data(C_NMesh *mesh, int vidxs[4],
C_NMFace *newf = PyObject_NEW (C_NMFace, &NMFace_Type);
int i, len;
- if(vidxs[3]) len = 4;
- else if(vidxs[2]) len = 3;
+ if (vidxs[3]) len = 4;
+ else if (vidxs[2]) len = 3;
else len = 2;
newf->v = PyList_New(len);
@@ -888,14 +887,14 @@ static C_NMFace *nmface_from_data(C_NMesh *mesh, int vidxs[4],
}
if (tface->tpage) /* pointer to image per face: */
- newf->image = (C_Image *)Image_CreatePyObject (tface->tpage);
+ newf->image = (Image *)tface->tpage;
else
newf->image = NULL;
newf->mode = tface->mode; /* draw mode */
newf->flag = tface->flag; /* select flag */
newf->transp = tface->transp; /* transparency flag */
- col = (MCol *) (tface->col);
+ col = (MCol *) (tface->col); /* XXX weird, tface->col is uint[4] */
}
else {
newf->image = NULL;
@@ -907,9 +906,10 @@ static C_NMFace *nmface_from_data(C_NMesh *mesh, int vidxs[4],
if (col) {
newf->col = PyList_New(4);
- for(i = 0; i < 4; i++, col++)
+ for(i = 0; i < 4; i++, col++) {
PyList_SetItem(newf->col, i,
(PyObject *)newcol(col->b, col->g, col->r, col->a));
+ }
}
else newf->col = PyList_New(0);
@@ -1196,7 +1196,7 @@ static int assignFaceUV(TFace *tf, C_NMFace *nmface)
}
if (nmface->image) /* image assigned ? */
{
- tf->tpage = nmface->image->image;
+ tf->tpage = (void *)nmface->image;
}
else
tf->tpage = 0;
@@ -1270,7 +1270,7 @@ static void mface_from_data(MFace *mf, TFace *tf, MCol *col, C_NMFace *from)
continue;
}
- col->b = mc->r;
+ col->b = mc->r;
col->g = mc->g;
col->r = mc->b;
col->a = mc->a;
@@ -1355,11 +1355,10 @@ PyObject *NMesh_assignMaterials_toObject(C_NMesh *nmesh, Object *ob)
ma = pymat->material;
assign_material(ob, ma, i+1);/*@ XXX don't use this function anymore*/
}
-
else {
Py_DECREF (pymat);
return EXPP_ReturnPyObjError (PyExc_TypeError,
- "Material type in attribute list 'materials' expected!");
+ "expected Material type in attribute list 'materials'!");
}
Py_DECREF (pymat);
@@ -1487,7 +1486,7 @@ static int convert_NMeshToMesh (Mesh *mesh, C_NMesh *nmesh)
Py_DECREF(mf);
newmf++;
- if (newmc) newmc++;
+ if (newmc) newmc += 4; /* there are 4 MCol's per face */
}
}
return 1;
@@ -1529,7 +1528,8 @@ static PyObject *M_NMesh_PutRaw(PyObject *self, PyObject *args)
if(!mesh || mesh->id.us == 0) {
ob = add_object(OB_MESH);
if (!ob) {
- PyErr_SetString(PyExc_RuntimeError, "Fatal: could not create mesh object");
+ PyErr_SetString(PyExc_RuntimeError,
+ "Fatal: could not create mesh object");
return 0;
}
if (mesh)
@@ -1697,5 +1697,8 @@ int NMesh_CheckPyObject (PyObject *pyobj)
Mesh *NMesh_FromPyObject (PyObject *pyobj)
{
- return ((C_NMesh *)pyobj)->mesh;
+ if (pyobj->ob_type == &NMesh_Type)
+ return Mesh_fromNMesh ((C_NMesh *)pyobj);
+
+ return NULL;
}
diff --git a/source/blender/python/api2_2x/NMesh.h b/source/blender/python/api2_2x/NMesh.h
index 860de6cfdac..252265b0354 100644
--- a/source/blender/python/api2_2x/NMesh.h
+++ b/source/blender/python/api2_2x/NMesh.h
@@ -158,10 +158,6 @@ static char M_NMesh_PutRaw_doc[] =
If the name of a mesh to replace is not given a new\n\
object is created and returned.";
-/* the color, vertex, face and mesh types below have their own variables
- * because they don't need to be linked to real Blender data -- e.g.: they
- * can be created with .New() methods */
-
/* Typedefs for the new types */
typedef struct {
@@ -187,7 +183,7 @@ typedef struct {
short mode;
short flag;
unsigned char transp;
- C_Image *image;
+ Image *image;
char mat_nr, smooth;
} C_NMFace; /* an NMesh face */
diff --git a/source/blender/python/api2_2x/Types.c b/source/blender/python/api2_2x/Types.c
index 2a22c59c014..28339c78134 100644
--- a/source/blender/python/api2_2x/Types.c
+++ b/source/blender/python/api2_2x/Types.c
@@ -41,12 +41,14 @@ PyObject *M_Types_Init (void)
PyObject *submodule, *dict;
/* These are only set when some object initializes them. But unless we
- * do it now, we get two easy ways to crash Blender. Maybe we'd better
+ * do it now, we get an easy way to crash Blender. Maybe we'd better
* have an Init function for all these internal types that more than one
* module can use. We could call it after setting the Blender dictionary */
vector_Type.ob_type = &PyType_Type;
rgbTuple_Type.ob_type = &PyType_Type;
constant_Type.ob_type = &PyType_Type;
+ buffer_Type.ob_type = &PyType_Type;
+ Button_Type.ob_type = &PyType_Type;
submodule = Py_InitModule3 ("Blender.Types", Null_methods, M_Types_doc);