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-12 08:51:50 +0400
committerWillian Padovani Germano <wpgermano@gmail.com>2003-06-12 08:51:50 +0400
commit6cc45538efefe1062aa0bc0909903af3db5d338d (patch)
tree64cb07ec5761c70f06ac15c2d4633dd9602cbcb0 /source/blender/python/api2_2x/Metaball.c
parented6885d72891c63c39bb63a0eb936b454fef753c (diff)
* Small changes in many files:
- Trying to fix linking problems in OSX; - Making module .Get functions behave like the ones in Blender 2.25 - 2.27 (Guignot pointed the incompatibility); - Included more types to Blender.Types; - Found by luck and corrected two bugs that were making Blender crash; - Added/updated some simple functions.
Diffstat (limited to 'source/blender/python/api2_2x/Metaball.c')
-rw-r--r--source/blender/python/api2_2x/Metaball.c49
1 files changed, 45 insertions, 4 deletions
diff --git a/source/blender/python/api2_2x/Metaball.c b/source/blender/python/api2_2x/Metaball.c
index 0285d72e10f..629d1868425 100644
--- a/source/blender/python/api2_2x/Metaball.c
+++ b/source/blender/python/api2_2x/Metaball.c
@@ -111,7 +111,7 @@ static PyObject *M_Metaball_Get(PyObject *self, PyObject *args)
else { /* () - return a list of all mballs in the scene */
int index = 0;
- PyObject *mballlist, *pystr;
+ PyObject *mballlist, *pyobj;
mballlist = PyList_New (BLI_countlist (&(G.main->mball)));
@@ -120,13 +120,13 @@ static PyObject *M_Metaball_Get(PyObject *self, PyObject *args)
"couldn't create PyList"));
while (mball_iter) {
- pystr = PyString_FromString (mball_iter->id.name+2);
+ pyobj = Metaball_CreatePyObject (mball_iter);
- if (!pystr)
+ if (!pyobj)
return (PythonReturnErrorObject (PyExc_MemoryError,
"couldn't create PyString"));
- PyList_SET_ITEM (mballlist, index, pystr);
+ PyList_SET_ITEM (mballlist, index, pyobj);
mball_iter = mball_iter->id.next;
index++;
@@ -1039,3 +1039,44 @@ static PyObject *MetaballRepr (C_Metaball *self)
return PyString_FromString(self->metaball->id.name+2);
}
+/* Three Python Metaball_Type helper functions needed by the Object module: */
+
+/*****************************************************************************/
+/* Function: Metaball_CreatePyObject */
+/* Description: This function will create a new C_Metaball from an existing */
+/* Blender metaball structure. */
+/*****************************************************************************/
+PyObject *Metaball_CreatePyObject (MetaBall *metaball)
+{
+ C_Metaball *pymetaball;
+
+ pymetaball = (C_Metaball *)PyObject_NEW (C_Metaball, &Metaball_Type);
+
+ if (!pymetaball)
+ return EXPP_ReturnPyObjError (PyExc_MemoryError,
+ "couldn't create C_Metaball object");
+
+ pymetaball->metaball = metaball;
+
+ return (PyObject *)pymetaball;
+}
+
+/*****************************************************************************/
+/* Function: Metaball_CheckPyObject */
+/* Description: This function returns true when the given PyObject is of the */
+/* type Metaball. Otherwise it will return false. */
+/*****************************************************************************/
+int Metaball_CheckPyObject (PyObject *pyobj)
+{
+ return (pyobj->ob_type == &Metaball_Type);
+}
+
+/*****************************************************************************/
+/* Function: Metaball_FromPyObject */
+/* Description: This function returns the Blender metaball from the given */
+/* PyObject. */
+/*****************************************************************************/
+MetaBall *Metaball_FromPyObject (PyObject *pyobj)
+{
+ return ((C_Metaball *)pyobj)->metaball;
+}