From d97e3e55273c6c381eead86f807514ef1d4a3941 Mon Sep 17 00:00:00 2001 From: Stephen Swaney Date: Sun, 6 Jun 2004 19:42:12 +0000 Subject: patch for bug #1347. IpoCurve.evaluate() missing/disappeared. Contributed by Philip Wainwright. --- source/blender/python/api2_2x/Ipocurve.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'source') diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c index f3e8c3873e2..2fb99f08cfd 100644 --- a/source/blender/python/api2_2x/Ipocurve.c +++ b/source/blender/python/api2_2x/Ipocurve.c @@ -83,6 +83,8 @@ static PyObject *IpoCurve_setExtrapolation (C_IpoCurve * self, PyObject * args); static PyObject *IpoCurve_getExtrapolation (C_IpoCurve * self); static PyObject *IpoCurve_getPoints (C_IpoCurve * self); +static int IpoCurve_setPoints (C_IpoCurve * self, PyObject * value); +static PyObject *IpoCurve_evaluate (C_IpoCurve * self, PyObject * args); /*****************************************************************************/ /* Python C_IpoCurve methods table: */ @@ -109,6 +111,8 @@ static PyMethodDef C_IpoCurve_methods[] = { "(str) - Change IpoCurve Data name"}, {"getPoints", (PyCFunction) IpoCurve_getPoints, METH_NOARGS, "(str) - Change IpoCurve Data name"}, + {"evaluate", (PyCFunction) IpoCurve_evaluate, METH_VARARGS, + "(float) - Evaluate curve at given time"}, {NULL, NULL, 0, NULL} }; @@ -155,8 +159,6 @@ PyTypeObject IpoCurve_Type = { static PyObject * M_IpoCurve_New (PyObject * self, PyObject * args) { - - return 0; } @@ -526,3 +528,26 @@ IpoCurve_FromPyObject (PyObject * pyobj) { return ((C_IpoCurve *) pyobj)->ipocurve; } + +/***************************************************************************/ +/* Function: IpoCurve_evaluate( time ) */ +/* Description: Evaluates IPO curve at the given time. */ +/***************************************************************************/ + +static PyObject * +IpoCurve_evaluate (C_IpoCurve * self, PyObject * args) +{ + + float time = 0; + double eval = 0; + + /* expecting float */ + if (!PyArg_ParseTuple (args, "f", &time)) + return (EXPP_ReturnPyObjError + (PyExc_TypeError, "expected float argument")); + + eval= (double)eval_icu(self->ipocurve, time); + + return PyFloat_FromDouble(eval); + +} -- cgit v1.2.3