Quick PyAPI patch:
Now it is possible to clean IPO-curves using the call: icu.clean() There's an optional value to specify the threshold to use for cleaning. This just wraps the internal clean_ipo_curve() function.
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
#include "MEM_guardedalloc.h"
|
||||
#include "DNA_ipo_types.h"
|
||||
#include "DNA_key_types.h"
|
||||
#include "DNA_scene_types.h"
|
||||
#include "BezTriple.h"
|
||||
#include "gen_utils.h"
|
||||
|
||||
@@ -80,6 +81,7 @@ static PyObject *IpoCurve_getExtrapolation( C_IpoCurve * self );
|
||||
static PyObject *IpoCurve_newgetExtend( C_IpoCurve * self );
|
||||
static int IpoCurve_newsetExtend( C_IpoCurve * self, PyObject * args );
|
||||
static PyObject *IpoCurve_getPoints( C_IpoCurve * self );
|
||||
static PyObject *IpoCurve_clean( C_IpoCurve * self, PyObject *value );
|
||||
static PyObject *IpoCurve_evaluate( C_IpoCurve * self, PyObject * args );
|
||||
static PyObject *IpoCurve_getDriver( C_IpoCurve * self );
|
||||
static int IpoCurve_setDriver( C_IpoCurve * self, PyObject * args );
|
||||
@@ -127,6 +129,8 @@ static PyMethodDef C_IpoCurve_methods[] = {
|
||||
"() - Returns list of all bezTriples of the curve"},
|
||||
{"evaluate", ( PyCFunction ) IpoCurve_evaluate, METH_VARARGS,
|
||||
"(float) - Evaluate curve at given time"},
|
||||
{"clean", ( PyCFunction ) IpoCurve_clean, METH_VARARGS,
|
||||
"(float) - Clean BezTriples using the given threshold value"},
|
||||
{NULL, NULL, 0, NULL}
|
||||
};
|
||||
|
||||
@@ -770,6 +774,29 @@ static PyObject *IpoCurve_evaluate( C_IpoCurve * self, PyObject * args )
|
||||
|
||||
}
|
||||
|
||||
/***************************************************************************/
|
||||
/* Function: IpoCurve_clean( thresh ) */
|
||||
/* Description: Cleans IPO curve with the (optional) threshold. */
|
||||
/***************************************************************************/
|
||||
static PyObject *IpoCurve_clean( C_IpoCurve * self, PyObject * args )
|
||||
{
|
||||
float thresh, othresh;
|
||||
|
||||
thresh= othresh= G.scene->toolsettings->clean_thresh;
|
||||
|
||||
/* expecting float */
|
||||
if( !PyArg_ParseTuple( args, "|f", &thresh ) )
|
||||
return ( EXPP_ReturnPyObjError
|
||||
( PyExc_TypeError, "expected float argument" ) );
|
||||
|
||||
/* set IPO-cleaning threshold based on value provided by user (temporarily) */
|
||||
G.scene->toolsettings->clean_thresh= thresh;
|
||||
clean_ipo_curve( self->ipocurve );
|
||||
G.scene->toolsettings->clean_thresh= othresh;
|
||||
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *IpoCurve_getDriver( C_IpoCurve * self )
|
||||
{
|
||||
if( !self->ipocurve->driver )
|
||||
|
@@ -216,6 +216,17 @@ class IpoCurve:
|
||||
@return: the points of the Ipo curve.
|
||||
"""
|
||||
|
||||
def clean( thresh=0.0000001 ):
|
||||
"""
|
||||
Calls the IPO-curve cleaning function on this IpoCurve.
|
||||
There is no need to recalculate curve manually.
|
||||
@type thresh: float
|
||||
@param thresh: The threshold to used to determine if two values are identical.
|
||||
By default, the IPO-editor tool's value is used.
|
||||
@rtype: None
|
||||
@return: None
|
||||
"""
|
||||
|
||||
def evaluate( time ):
|
||||
"""
|
||||
Compute the value of the Ipo curve at a particular time (B{deprecated}).
|
||||
|
Reference in New Issue
Block a user