From c1e33eb1e7dd0071bd4fd0c9e94e2938b6af2978 Mon Sep 17 00:00:00 2001 From: Stephen Swaney Date: Tue, 6 Apr 2004 21:13:12 +0000 Subject: [PATCH] fix for bug 1110. Updated epydoc. Function name is BezTriple.getTriple(). Set prototype to NOARGS in source. --- source/blender/python/api2_2x/BezTriple.c | 26 +++++++++++++++++++---- source/blender/python/api2_2x/BezTriple.h | 2 +- source/blender/python/api2_2x/doc/Ipo.py | 24 +++++++++++++++++++++ 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/source/blender/python/api2_2x/BezTriple.c b/source/blender/python/api2_2x/BezTriple.c index 94911cac1e7..0533bb8c584 100644 --- a/source/blender/python/api2_2x/BezTriple.c +++ b/source/blender/python/api2_2x/BezTriple.c @@ -85,8 +85,8 @@ static PyMethodDef C_BezTriple_methods[] = { "(str) - Change BezTriple point coordinates"}, {"getPoints", (PyCFunction) BezTriple_getPoints, METH_NOARGS, "() - return BezTriple knot point x and y coordinates"}, - {"getTriple", (PyCFunction) BezTriple_getTriple, METH_VARARGS, - "() - return list of floating point triplets. order is H1, knot, H2"}, + {"getTriple", (PyCFunction) BezTriple_getTriple, METH_NOARGS, + "() - return list of 3 floating point triplets. order is H1, knot, H2"}, {NULL, NULL, 0, NULL} }; @@ -169,6 +169,15 @@ BezTriple_getPoints (C_BezTriple * self) } +/* + * BezTriple_getTriple + * + * get the coordinate data for a BezTriple. + * returns a list of 3 points. + * list order is handle1, knot, handle2. + * each point consists of a list of x,y,z float values. + */ + static PyObject * BezTriple_getTriple (C_BezTriple * self) { @@ -200,7 +209,7 @@ BezTriple_setPoints (C_BezTriple * self, PyObject * args) if (!PyArg_ParseTuple (args, "O", &popo)) return (EXPP_ReturnPyObjError (PyExc_TypeError, "expected tuple argument")); - if (PyTuple_Check (popo) == 0) + if (PySequence_Check (popo) == 0) { puts ("error in BezTriple_setPoints"); Py_INCREF (Py_None); @@ -208,7 +217,12 @@ BezTriple_setPoints (C_BezTriple * self, PyObject * args) } for (i = 0; i < 2; i++) { - bezt->vec[1][i] = PyFloat_AsDouble (PyTuple_GetItem (popo, i)); + PyObject *o = PySequence_GetItem( popo, i ); + if( !o ) + printf("\n bad o. o no!\n"); + + /* bezt->vec[1][i] = PyFloat_AsDouble (PyTuple_GetItem (popo, i));*/ + bezt->vec[1][i] = PyFloat_AsDouble ( o ); bezt->vec[0][i] = bezt->vec[1][i] - 1; bezt->vec[2][i] = bezt->vec[1][i] + 1; } @@ -230,6 +244,10 @@ BezTripleGetAttr (C_BezTriple * self, char *name) { if (strcmp (name, "pt") == 0) return BezTriple_getPoints (self); + else if (strcmp (name, "vec") == 0) + return BezTriple_getTriple (self); + + /* look for default methods */ return Py_FindMethod (C_BezTriple_methods, (PyObject *) self, name); } diff --git a/source/blender/python/api2_2x/BezTriple.h b/source/blender/python/api2_2x/BezTriple.h index 26d9fd18593..10bfff9b332 100644 --- a/source/blender/python/api2_2x/BezTriple.h +++ b/source/blender/python/api2_2x/BezTriple.h @@ -41,7 +41,7 @@ typedef struct { - PyObject_HEAD BezTriple * beztriple; + PyObject_HEAD BezTriple *beztriple; } C_BezTriple; diff --git a/source/blender/python/api2_2x/doc/Ipo.py b/source/blender/python/api2_2x/doc/Ipo.py index 10b5a9b7bdb..4a40331660f 100644 --- a/source/blender/python/api2_2x/doc/Ipo.py +++ b/source/blender/python/api2_2x/doc/Ipo.py @@ -246,6 +246,15 @@ class IpoCurve: @return: the points of the ipo curve. """ + def evaluate( time ): + """ + Compute the value of the IpoCurve at a particular time. + @type time: float + @param time: value along the X axis + @rtype: float + @return: the Y value of the curve at the given time + """ + class BezTriple: """ @@ -271,3 +280,18 @@ class BezTriple: @rtype: PyNone @return: PyNone """ + + def getTriple(): + """ + Returns the x,y,z coordinates for each of the three points that make up a BezierTriple. + + The return list looks like this [ [H1x, H1y, H1z], [Px, Py, Pz], [H2x, H2y, H2z] ] . + + Example:: + # where bt is of type BezierTriple + # and h1, p, and h2 are lists of 3 floats + h1, p, h2 = bt.getTriple() + + @rtype: list consisting of 3 lists of 3 floats + @return: handle1, knot, handle2 + """