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:
authorJoshua Leung <aligorith@gmail.com>2008-10-11 16:17:16 +0400
committerJoshua Leung <aligorith@gmail.com>2008-10-11 16:17:16 +0400
commitf691752a34520f05e88b4a18f766aed9fe11d2e9 (patch)
treec7a660fa71607ce2f9cb7fb8ad6c7529968ac3ba
parentd35178ee61b4bd434a3a1cd05c06b4f56c2dbf69 (diff)
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.
-rw-r--r--source/blender/python/api2_2x/Ipocurve.c27
-rw-r--r--source/blender/python/api2_2x/doc/IpoCurve.py11
2 files changed, 38 insertions, 0 deletions
diff --git a/source/blender/python/api2_2x/Ipocurve.c b/source/blender/python/api2_2x/Ipocurve.c
index 4a8cba30e8e..5dfb52f2733 100644
--- a/source/blender/python/api2_2x/Ipocurve.c
+++ b/source/blender/python/api2_2x/Ipocurve.c
@@ -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 )
diff --git a/source/blender/python/api2_2x/doc/IpoCurve.py b/source/blender/python/api2_2x/doc/IpoCurve.py
index 54d9136ec1e..7b4a2db9929 100644
--- a/source/blender/python/api2_2x/doc/IpoCurve.py
+++ b/source/blender/python/api2_2x/doc/IpoCurve.py
@@ -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}).