diff options
author | Jacques Guignot <guignot@wanadoo.fr> | 2003-07-19 12:32:01 +0400 |
---|---|---|
committer | Jacques Guignot <guignot@wanadoo.fr> | 2003-07-19 12:32:01 +0400 |
commit | 542f05451abea024972513968985495b81679e08 (patch) | |
tree | 9ab3a51cd2db17c1abc49b15060fa1707b0825e4 /source/blender | |
parent | d51107b80454459cc01078cee7fcab699e60ce2d (diff) |
World : got rid of debug messages
Blender : declatation of the module IpoCurve
Ipo : modifications (new attributes) to keep the compatibility with 227 api
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/python/api2_2x/Blender.c | 1 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Ipo.c | 87 | ||||
-rw-r--r-- | source/blender/python/api2_2x/Ipo.h | 9 | ||||
-rw-r--r-- | source/blender/python/api2_2x/World.c | 5 |
4 files changed, 91 insertions, 11 deletions
diff --git a/source/blender/python/api2_2x/Blender.c b/source/blender/python/api2_2x/Blender.c index f450fe09956..31a0014bff0 100644 --- a/source/blender/python/api2_2x/Blender.c +++ b/source/blender/python/api2_2x/Blender.c @@ -218,6 +218,7 @@ void M_Blender_Init (void) PyDict_SetItemString (dict, "Curve", Curve_Init()); PyDict_SetItemString (dict, "Armature", Armature_Init()); PyDict_SetItemString (dict, "Ipo", Ipo_Init()); + PyDict_SetItemString (dict, "IpoCurve", IpoCurve_Init()); PyDict_SetItemString (dict, "Metaball", Metaball_Init()); PyDict_SetItemString (dict, "Image", Image_Init()); PyDict_SetItemString (dict, "Window", Window_Init()); diff --git a/source/blender/python/api2_2x/Ipo.c b/source/blender/python/api2_2x/Ipo.c index de92d33ddf0..33727105589 100644 --- a/source/blender/python/api2_2x/Ipo.c +++ b/source/blender/python/api2_2x/Ipo.c @@ -30,7 +30,7 @@ */ #include "Ipo.h" - +#include"Ipocurve.c" /*****************************************************************************/ /* Function: M_Ipo_New */ /* Python equivalent: Blender.Ipo.New */ @@ -131,6 +131,22 @@ static PyObject *M_Ipo_Get(PyObject *self, PyObject *args) } } + +static PyObject * M_Ipo_Recalc(PyObject *self, PyObject *args) +{ + void testhandles_ipocurve(IpoCurve *icu); + +IpoCurve *icu; + //C_IpoCurve *p = (C_IpoCurve*)args; + icu = IpoCurve_FromPyObject(args); + printf("%d\n",IpoCurve_CheckPyObject(args)); + printf("%p\n",icu); + testhandles_ipocurve(icu); + +Py_INCREF(Py_None); + return Py_None; + +} /*****************************************************************************/ /* Function: Ipo_Init */ /*****************************************************************************/ @@ -153,18 +169,24 @@ static PyObject *Ipo_getName(C_Ipo *self) PyObject *attr = PyString_FromString(self->ipo->id.name+2); if (attr) return attr; - - return (EXPP_ReturnPyObjError (PyExc_RuntimeError, - "couldn't get Ipo.name attribute")); + Py_INCREF(Py_None); + return Py_None; } + + + + + + + + static PyObject *Ipo_setName(C_Ipo *self, PyObject *args) { char *name; char buf[21]; if (!PyArg_ParseTuple(args, "s", &name)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string argument")); + return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected string argument")); PyOS_snprintf(buf, sizeof(buf), "%s", name); @@ -237,6 +259,56 @@ static PyObject *Ipo_getNcurves(C_Ipo *self) } +static PyObject *Ipo_getCurves(C_Ipo *self) +{ + PyObject *attr = PyList_New(0); + IpoCurve *icu; + for (icu=self->ipo->curve.first; icu; icu=icu->next){ + PyList_Append(attr, IpoCurve_CreatePyObject(icu)); + } + return attr; +} + + +static PyObject *Ipo_getNBezPoints(C_Ipo *self, PyObject *args) +{ + int num = 0 , i = 0; + IpoCurve *icu = 0; + if (!PyArg_ParseTuple(args, "i",&num)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument")); + icu =self->ipo->curve.first; + if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); + for(i = 0;i<num;i++) + { + if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"Bad curve number")); + icu=icu->next; + + } + return (PyInt_FromLong(icu->totvert) ); +} + +static PyObject *Ipo_DeleteBezPoints(C_Ipo *self, PyObject *args) +{ + int num = 0 , i = 0; + IpoCurve *icu = 0; + if (!PyArg_ParseTuple(args, "i",&num)) + return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected int argument")); + icu =self->ipo->curve.first; + if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"No IPO curve")); + for(i = 0;i<num;i++) + { + if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"Bad curve number")); + icu=icu->next; + + } + icu->totvert--; + return (PyInt_FromLong(icu->totvert) ); +} + + + + + static PyObject *Ipo_getCurveBP(C_Ipo *self, PyObject *args) { struct BPoint *ptrbpoint; @@ -252,7 +324,7 @@ static PyObject *Ipo_getCurveBP(C_Ipo *self, PyObject *args) { if(!icu) return (EXPP_ReturnPyObjError (PyExc_TypeError,"Bad curve number")); icu=icu->next; - + } ptrbpoint = icu->bp; if(!ptrbpoint)return EXPP_ReturnPyObjError(PyExc_TypeError,"No base point"); @@ -370,6 +442,7 @@ static void IpoDeAlloc (C_Ipo *self) /*****************************************************************************/ static PyObject *IpoGetAttr (C_Ipo *self, char *name) { +if (strcmp (name, "curves") == 0)return Ipo_getCurves (self); return Py_FindMethod(C_Ipo_methods, (PyObject *)self, name); } diff --git a/source/blender/python/api2_2x/Ipo.h b/source/blender/python/api2_2x/Ipo.h index fda43df9705..16d9c00de88 100644 --- a/source/blender/python/api2_2x/Ipo.h +++ b/source/blender/python/api2_2x/Ipo.h @@ -51,6 +51,7 @@ /*****************************************************************************/ static PyObject *M_Ipo_New (PyObject *self, PyObject *args); static PyObject *M_Ipo_Get (PyObject *self, PyObject *args); +static PyObject *M_Ipo_Recalc (PyObject *self, PyObject *args); /*****************************************************************************/ /* The following string definitions are used for documentation strings. */ @@ -70,6 +71,7 @@ struct PyMethodDef M_Ipo_methods[] = { {"New",(PyCFunction)M_Ipo_New, METH_VARARGS|METH_KEYWORDS,M_Ipo_New_doc}, {"Get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc}, {"get", M_Ipo_Get, METH_VARARGS, M_Ipo_Get_doc}, + {"Recalc", M_Ipo_Recalc, METH_VARARGS, M_Ipo_Get_doc}, {NULL, NULL, 0, NULL} }; @@ -92,9 +94,12 @@ static PyObject *Ipo_getRctf(C_Ipo *self); static PyObject *Ipo_setRctf(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_setCurveBeztriple(C_Ipo *self, PyObject *args); static PyObject *Ipo_getCurveBeztriple(C_Ipo *self, PyObject *args); @@ -117,6 +122,10 @@ static PyMethodDef C_Ipo_methods[] = { "(str) - Change Ipo rctf"}, {"getNcurves", (PyCFunction)Ipo_getNcurves, METH_NOARGS, "() - Return Ipo ncurves"}, + {"getNBezPoints", (PyCFunction)Ipo_getNBezPoints, METH_VARARGS, + "() - Return curve number of Bez points"}, + {"delBezPoint", (PyCFunction)Ipo_DeleteBezPoints, METH_VARARGS, + "() - Return curve number of Bez points"}, {"getCurveBP", (PyCFunction)Ipo_getCurveBP, METH_VARARGS, "() - Return Ipo ncurves"}, {"getCurveCurval", (PyCFunction)Ipo_getCurvecurval, METH_VARARGS, diff --git a/source/blender/python/api2_2x/World.c b/source/blender/python/api2_2x/World.c index 5365969ed0d..9b5ac6e1450 100644 --- a/source/blender/python/api2_2x/World.c +++ b/source/blender/python/api2_2x/World.c @@ -259,11 +259,8 @@ static PyObject *World_setName(BPy_World *self, PyObject *args) { char *name = 0; char buf[21]; - puts("mlmlml"); if (!PyArg_ParseTuple(args, "s", &name)) - return (EXPP_ReturnPyObjError (PyExc_TypeError, - "expected string argument")); - puts(name); + return (EXPP_ReturnPyObjError (PyExc_TypeError,"expected string argument")); snprintf(buf, sizeof(buf), "%s", name); rename_id(&self->world->id, buf); |