* 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.
This commit is contained in:
2003-06-13 04:21:48 +00:00
parent bbf8fe932f
commit f70302670e
10 changed files with 179 additions and 142 deletions

View File

@@ -1548,7 +1548,7 @@ static int convert_NMeshToMesh(Mesh *mesh, NMesh *nmesh)
Py_DECREF(mf); Py_DECREF(mf);
newmf++; newmf++;
if (newmc) newmc++; if (newmc) newmc += 4; /* there are 4 MCol's per face */
} }
} }
return 1; return 1;

View File

@@ -195,7 +195,7 @@ PyObject *Blender_ReleaseGlobalDict(PyObject *self, PyObject *args)
"expected int argument (or nothing)"); "expected int argument (or nothing)");
} }
return Py_BuildValue("i", (EXPP_releaseGlobalDict?1:0)); return Py_BuildValue("i", (EXPP_releaseGlobalDict ? 1:0));
} }
/*****************************************************************************/ /*****************************************************************************/

View File

@@ -29,11 +29,13 @@
* ***** END GPL/BL DUAL LICENSE BLOCK ***** * ***** END GPL/BL DUAL LICENSE BLOCK *****
*/ */
/** /*!
* \file Camera.c * \file Camera.c
* \ingroup scripts * \ingroup scripts
* \brief Blender.Camera Module and Camera Data PyObject implementation. * \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> #include <BKE_main.h>
@@ -44,6 +46,7 @@
#include "Camera.h" #include "Camera.h"
/*****************************************************************************/ /*****************************************************************************/
/* Python BPy_Camera defaults: */ /* 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 */ /* In Python these will be written to the console when doing a */
/* Blender.Camera.__doc__ */ /* Blender.Camera.__doc__ */
/*****************************************************************************/ /*****************************************************************************/
/*!
* \var M_Camera_doc
* \brief Doc string for the Blender.Camera module
*/
static char M_Camera_doc[] = static char M_Camera_doc[] =
"The Blender Camera module\n\ "The Blender Camera module\n\
\n\ \n\
@@ -95,7 +104,12 @@ Example::\n\
ob = Object.New('Camera') # make camera object\n\ ob = Object.New('Camera') # make camera object\n\
ob.link(c) # link camera data with this object\n\ ob.link(c) # link camera data with this object\n\
cur.link(ob) # link object into scene\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[] = static char M_Camera_New_doc[] =
"Blender.Camera.New (type = 'persp', name = 'CamData'):\n\ "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\ which can be 'persp' or 'ortho';\n\
() - Return a new Camera Data object of type 'persp'."; () - 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[] = static char M_Camera_Get_doc[] =
"Blender.Camera.Get (name = None):\n\ "Blender.Camera.Get (name = None):\n\
\n\ \n\
@@ -114,6 +133,16 @@ static char M_Camera_Get_doc[] =
/*****************************************************************************/ /*****************************************************************************/
/* Python method structure definition for Blender.Camera module: */ /* 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[] = { struct PyMethodDef M_Camera_methods[] = {
{"New",(PyCFunction)M_Camera_New, METH_VARARGS|METH_KEYWORDS, {"New",(PyCFunction)M_Camera_New, METH_VARARGS|METH_KEYWORDS,
M_Camera_New_doc}, M_Camera_New_doc},
@@ -145,6 +174,17 @@ static PyObject *Camera_setDrawSize(BPy_Camera *self, PyObject *args);
/*****************************************************************************/ /*****************************************************************************/
/* Python BPy_Camera methods table: */ /* 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[] = { static PyMethodDef BPy_Camera_methods[] = {
/* name, method, flags, doc */ /* name, method, flags, doc */
{"getName", (PyCFunction)Camera_getName, METH_NOARGS, {"getName", (PyCFunction)Camera_getName, METH_NOARGS,
@@ -189,6 +229,14 @@ static int Camera_Compare (BPy_Camera *a, BPy_Camera *b);
static PyObject *Camera_GetAttr (BPy_Camera *self, char *name); static PyObject *Camera_GetAttr (BPy_Camera *self, char *name);
static PyObject *Camera_Repr (BPy_Camera *self); 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: */ /* Python Camera_Type structure definition: */
/*****************************************************************************/ /*****************************************************************************/
@@ -217,18 +265,17 @@ PyTypeObject Camera_Type =
0, /* tp_members */ 0, /* tp_members */
}; };
/** /*!
* \defgroup Camera_Module Blender.Camera module functions * \defgroup M_Functions Blender.Camera functions
*
*/ */
/*@{*/ /*! @{ */
/** /*!
* \brief Python module function: Blender.Camera.New() * \brief Python module function: Blender.Camera.New()
* *
* This is the .New() function of the Blender.Camera submodule. It creates * 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'. * parameters are optional and default to type = 'persp' and name = 'CamData'.
* \param <type> - string: The Camera type: 'persp' or 'ortho'; * \param <type> - string: The Camera type: 'persp' or 'ortho';
* \param <name> - string: The Camera Data name. * \param <name> - string: The Camera Data name.
@@ -286,7 +333,7 @@ static PyObject *M_Camera_New(PyObject *self, PyObject *args, PyObject *kwords)
return pycam; return pycam;
} }
/** /*!
* \brief Python module function: Blender.Camera.Get() * \brief Python module function: Blender.Camera.Get()
* *
* This is the .Get() function of the Blender.Camera submodule. It searches * 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 * \brief Initializes the Blender.Camera submodule
* *
* This function is used by Blender_Init() in Blender.c to register the * 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: */ /* Three Python Camera_Type helper functions needed by the Object module: */
/** /*!
* \brief Creates a new Python wrapper from an existing Blender Camera Data obj * \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 * 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; return (PyObject *)pycam;
} }
/** /*!
* \brief Checks if the given object is of type BPy_Camera * \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 * 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); return (pyobj->ob_type == &Camera_Type);
} }
/** /*!
* \brief Returns the Blender Camera object from the given PyObject * \brief Returns the Blender Camera object from the given PyObject
* *
* This is also used in Object.c when handling the object.data member variable * 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: */ /* 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 * These are the Camera PyObject methods.
* set values for the Camera Data member variables. * @{
*/ */
/*@{*/ /*!
/**
* \brief Camera PyMethod getName * \brief Camera PyMethod getName
* *
* \return string: The Camera Data name. * \return string: The Camera Data name.
@@ -468,7 +513,7 @@ static PyObject *Camera_getName(BPy_Camera *self)
"couldn't get Camera.name attribute"); "couldn't get Camera.name attribute");
} }
/** /*!
* \brief Camera PyMethod getType * \brief Camera PyMethod getType
* *
* \return int: The Camera Data type. * \return int: The Camera Data type.
@@ -484,7 +529,7 @@ static PyObject *Camera_getType(BPy_Camera *self)
"couldn't get Camera.type attribute"); "couldn't get Camera.type attribute");
} }
/** /*!
* \brief Camera PyMethod getMode * \brief Camera PyMethod getMode
* *
* \return int: The Camera Data mode flags. * \return int: The Camera Data mode flags.
@@ -500,7 +545,7 @@ static PyObject *Camera_getMode(BPy_Camera *self)
"couldn't get Camera.Mode attribute"); "couldn't get Camera.Mode attribute");
} }
/** /*!
* \brief Camera PyMethod getLens * \brief Camera PyMethod getLens
* *
* \return float: The Camera Data lens value * \return float: The Camera Data lens value
@@ -516,7 +561,7 @@ static PyObject *Camera_getLens(BPy_Camera *self)
"couldn't get Camera.lens attribute"); "couldn't get Camera.lens attribute");
} }
/** /*!
* \brief Camera PyMethod getClipStart * \brief Camera PyMethod getClipStart
* *
* \return float: The Camera Data clip start value. * \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"); "couldn't get Camera.clipStart attribute");
} }
/** /*!
* \brief Camera PyMethod getClipEnd * \brief Camera PyMethod getClipEnd
* \return float: The Camera Data clip end value. * \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"); "couldn't get Camera.clipEnd attribute");
} }
/** /*!
* \brief Camera method getDrawSize * \brief Camera method getDrawSize
* \return float: The Camera Data draw size value. * \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"); "couldn't get Camera.drawSize attribute");
} }
/** /*!
* \brief Camera PyMethod setName * \brief Camera PyMethod setName
* \param name - string: The new Camera Data name. * \param name - string: The new Camera Data name.
*/ */
@@ -584,7 +629,7 @@ static PyObject *Camera_setName(BPy_Camera *self, PyObject *args)
return Py_None; return Py_None;
} }
/** /*!
* \brief Camera PyMethod setType * \brief Camera PyMethod setType
* \param type - string: The new Camera Data type: 'persp' or 'ortho'. * \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 * the method setType expects a string ('persp' or 'ortho') or an empty
* argument, this function should receive an int (0 or 1). */ * argument, this function should receive an int (0 or 1). */
/** /*!
* \brief Internal helper function * \brief Internal helper function
* *
* This one is not a PyMethod. It is just an 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; return Py_None;
} }
/** /*!
* \brief Camera PyMethod setMode * \brief Camera PyMethod setMode
* *
* There are two mode flags for Cameras: 'showLimits' and 'showMist'. * 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. /* Another helper function, for the same reason.
* (See comment before Camera_setIntType above). */ * (See comment before Camera_setIntType above). */
/** /*!
* \brief Internal helper function * \brief Internal helper function
* *
* This one is not a PyMethod. It is just an 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; return Py_None;
} }
/** /*!
* \brief Camera PyMethod setLens * \brief Camera PyMethod setLens
* \param lens - float: The new Camera Data lens value. * \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; return Py_None;
} }
/** /*!
* \brief Camera PyMethod setClipStart * \brief Camera PyMethod setClipStart
* \param clipStart - float: The new Camera Data clip start value. * \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; return Py_None;
} }
/** /*!
* \brief Camera PyMethod setClipEnd * \brief Camera PyMethod setClipEnd
* \param clipEnd - float: The new Camera Data clip end value. * \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; return Py_None;
} }
/** /*!
* \brief Camera PyMethod setDrawSize * \brief Camera PyMethod setDrawSize
* \param drawSize - float: The new Camera Data draw size value. * \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; return Py_None;
} }
/*@}*/ /*@} Cam_Methods group */
/** /*!
* \defgroup Camera_callbacks Callback functions for the Camera PyType
*
* These callbacks are called by the Python interpreter when dealing with
* PyObjects of type Camera.
*/
/*@{*/
/**
* \brief The Camera PyType destructor * \brief The Camera PyType destructor
*/ */
@@ -814,7 +850,7 @@ static void Camera_DeAlloc (BPy_Camera *self)
PyObject_DEL (self); PyObject_DEL (self);
} }
/** /*!
* \brief The Camera PyType attribute getter * \brief The Camera PyType attribute getter
* *
* This is the callback called when a user tries to retrieve the contents of * 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); return Py_FindMethod(BPy_Camera_methods, (PyObject *)self, name);
} }
/** /*!
* \brief The Camera PyType attribute setter * \brief The Camera PyType attribute setter
* *
* This is the callback called when the user tries to change the value of some * 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 */ return 0; /* normal exit */
} }
/** /*!
* \brief The Camera PyType compare function * \brief The Camera PyType compare function
* *
* This function compares two given Camera PyObjects, returning 0 for equality * 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; return (pa == pb) ? 0:-1;
} }
/** /*!
* \brief The Camera PyType print callback * \brief The Camera PyType print callback
* *
* This function is called when the user tries to print a PyObject of type * 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; return 0;
} }
/** /*!
* \brief The Camera PyType repr callback * \brief The Camera PyType repr callback
* *
* This function is called when the statement "repr(mycamera)" is executed in * 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); return PyString_FromString(self->camera->id.name+2);
} }
/*@}*/

View File

@@ -97,8 +97,8 @@ typedef struct _Button {
static void Button_dealloc(PyObject *self); static void Button_dealloc(PyObject *self);
static PyObject *Button_getattr(PyObject *self, char *name); 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 PyObject *Button_repr(PyObject *self);
static int Button_setattr(PyObject *self, char *name, PyObject *v);
PyTypeObject Button_Type = PyTypeObject Button_Type =
{ {

View File

@@ -144,6 +144,8 @@ PyObject *M_Metaball_Init (void)
{ {
PyObject *submodule; PyObject *submodule;
Metaball_Type.ob_type = &PyType_Type;
printf ("In M_Metaball_Init()\n"); printf ("In M_Metaball_Init()\n");
submodule = Py_InitModule3("Blender.Metaball", submodule = Py_InitModule3("Blender.Metaball",
M_Metaball_methods, M_Metaball_doc); M_Metaball_methods, M_Metaball_doc);

View File

@@ -280,7 +280,7 @@ static PyObject *MetaballRepr (C_Metaball *self);
/*****************************************************************************/ /*****************************************************************************/
PyTypeObject Metaball_Type = PyTypeObject Metaball_Type =
{ {
PyObject_HEAD_INIT(&PyType_Type) PyObject_HEAD_INIT(NULL)
0, /* ob_size */ 0, /* ob_size */
"Metaball", /* tp_name */ "Metaball", /* tp_name */
sizeof (C_Metaball), /* tp_basicsize */ sizeof (C_Metaball), /* tp_basicsize */

View File

@@ -142,7 +142,6 @@ static void NMFace_dealloc (PyObject *self)
Py_DECREF(mf->v); Py_DECREF(mf->v);
Py_DECREF(mf->uv); Py_DECREF(mf->uv);
Py_DECREF(mf->col); Py_DECREF(mf->col);
Py_XDECREF(mf->image);
PyObject_DEL(self); PyObject_DEL(self);
} }
@@ -218,7 +217,7 @@ static PyObject *NMFace_getattr(PyObject *self, char *name)
else if (strcmp(name, "image") == 0) { else if (strcmp(name, "image") == 0) {
if (mf->image) if (mf->image)
return Py_BuildValue("O", (PyObject *)mf->image); return Image_CreatePyObject (mf->image);
else else
return EXPP_incr_ret(Py_None); return EXPP_incr_ret(Py_None);
} }
@@ -298,18 +297,18 @@ static int NMFace_setattr(PyObject *self, char *name, PyObject *v)
return 0; return 0;
} }
else if (strcmp(name, "image") == 0) { else if (strcmp(name, "image") == 0) {
PyObject *img; PyObject *pyimg;
if (!PyArg_Parse(v, "O!", &Image_Type, &img)) if (!PyArg_Parse(v, "O!", &Image_Type, &pyimg))
return EXPP_ReturnIntError(PyExc_TypeError, return EXPP_ReturnIntError(PyExc_TypeError,
"expected image object"); "expected image object");
if (img == Py_None) { if (pyimg == Py_None) {
mf->image = NULL; mf->image = NULL;
return 0; return 0;
} }
mf->image = (C_Image *)img; mf->image = ((C_Image *)pyimg)->image;
return 0; 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); C_NMFace *newf = PyObject_NEW (C_NMFace, &NMFace_Type);
int i, len; int i, len;
if(vidxs[3]) len = 4; if (vidxs[3]) len = 4;
else if(vidxs[2]) len = 3; else if (vidxs[2]) len = 3;
else len = 2; else len = 2;
newf->v = PyList_New(len); 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: */ if (tface->tpage) /* pointer to image per face: */
newf->image = (C_Image *)Image_CreatePyObject (tface->tpage); newf->image = (Image *)tface->tpage;
else else
newf->image = NULL; newf->image = NULL;
newf->mode = tface->mode; /* draw mode */ newf->mode = tface->mode; /* draw mode */
newf->flag = tface->flag; /* select flag */ newf->flag = tface->flag; /* select flag */
newf->transp = tface->transp; /* transparency flag */ newf->transp = tface->transp; /* transparency flag */
col = (MCol *) (tface->col); col = (MCol *) (tface->col); /* XXX weird, tface->col is uint[4] */
} }
else { else {
newf->image = NULL; newf->image = NULL;
@@ -907,10 +906,11 @@ static C_NMFace *nmface_from_data(C_NMesh *mesh, int vidxs[4],
if (col) { if (col) {
newf->col = PyList_New(4); newf->col = PyList_New(4);
for(i = 0; i < 4; i++, col++) for(i = 0; i < 4; i++, col++) {
PyList_SetItem(newf->col, i, PyList_SetItem(newf->col, i,
(PyObject *)newcol(col->b, col->g, col->r, col->a)); (PyObject *)newcol(col->b, col->g, col->r, col->a));
} }
}
else newf->col = PyList_New(0); else newf->col = PyList_New(0);
return newf; return newf;
@@ -1196,7 +1196,7 @@ static int assignFaceUV(TFace *tf, C_NMFace *nmface)
} }
if (nmface->image) /* image assigned ? */ if (nmface->image) /* image assigned ? */
{ {
tf->tpage = nmface->image->image; tf->tpage = (void *)nmface->image;
} }
else else
tf->tpage = 0; tf->tpage = 0;
@@ -1355,11 +1355,10 @@ PyObject *NMesh_assignMaterials_toObject(C_NMesh *nmesh, Object *ob)
ma = pymat->material; ma = pymat->material;
assign_material(ob, ma, i+1);/*@ XXX don't use this function anymore*/ assign_material(ob, ma, i+1);/*@ XXX don't use this function anymore*/
} }
else { else {
Py_DECREF (pymat); Py_DECREF (pymat);
return EXPP_ReturnPyObjError (PyExc_TypeError, return EXPP_ReturnPyObjError (PyExc_TypeError,
"Material type in attribute list 'materials' expected!"); "expected Material type in attribute list 'materials'!");
} }
Py_DECREF (pymat); Py_DECREF (pymat);
@@ -1487,7 +1486,7 @@ static int convert_NMeshToMesh (Mesh *mesh, C_NMesh *nmesh)
Py_DECREF(mf); Py_DECREF(mf);
newmf++; newmf++;
if (newmc) newmc++; if (newmc) newmc += 4; /* there are 4 MCol's per face */
} }
} }
return 1; return 1;
@@ -1529,7 +1528,8 @@ static PyObject *M_NMesh_PutRaw(PyObject *self, PyObject *args)
if(!mesh || mesh->id.us == 0) { if(!mesh || mesh->id.us == 0) {
ob = add_object(OB_MESH); ob = add_object(OB_MESH);
if (!ob) { if (!ob) {
PyErr_SetString(PyExc_RuntimeError, "Fatal: could not create mesh object"); PyErr_SetString(PyExc_RuntimeError,
"Fatal: could not create mesh object");
return 0; return 0;
} }
if (mesh) if (mesh)
@@ -1697,5 +1697,8 @@ int NMesh_CheckPyObject (PyObject *pyobj)
Mesh *NMesh_FromPyObject (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;
} }

View File

@@ -158,10 +158,6 @@ static char M_NMesh_PutRaw_doc[] =
If the name of a mesh to replace is not given a new\n\ If the name of a mesh to replace is not given a new\n\
object is created and returned."; 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 */ /* Typedefs for the new types */
typedef struct { typedef struct {
@@ -187,7 +183,7 @@ typedef struct {
short mode; short mode;
short flag; short flag;
unsigned char transp; unsigned char transp;
C_Image *image; Image *image;
char mat_nr, smooth; char mat_nr, smooth;
} C_NMFace; /* an NMesh face */ } C_NMFace; /* an NMesh face */

View File

@@ -41,12 +41,14 @@ PyObject *M_Types_Init (void)
PyObject *submodule, *dict; PyObject *submodule, *dict;
/* These are only set when some object initializes them. But unless we /* 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 * 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 */ * module can use. We could call it after setting the Blender dictionary */
vector_Type.ob_type = &PyType_Type; vector_Type.ob_type = &PyType_Type;
rgbTuple_Type.ob_type = &PyType_Type; rgbTuple_Type.ob_type = &PyType_Type;
constant_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); submodule = Py_InitModule3 ("Blender.Types", Null_methods, M_Types_doc);