[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17016] trunk/blender/source/blender/ python/api2_2x: Quick PyAPI patch:
Joshua Leung
aligorith at gmail.com
Sat Oct 11 14:17:16 CEST 2008
Revision: 17016
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17016
Author: aligorith
Date: 2008-10-11 14:17:16 +0200 (Sat, 11 Oct 2008)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/python/api2_2x/Ipocurve.c
trunk/blender/source/blender/python/api2_2x/doc/IpoCurve.py
Modified: trunk/blender/source/blender/python/api2_2x/Ipocurve.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Ipocurve.c 2008-10-11 11:08:30 UTC (rev 17015)
+++ trunk/blender/source/blender/python/api2_2x/Ipocurve.c 2008-10-11 12:17:16 UTC (rev 17016)
@@ -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_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 @@
"() - 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 @@
}
+/***************************************************************************/
+/* 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 )
Modified: trunk/blender/source/blender/python/api2_2x/doc/IpoCurve.py
===================================================================
--- trunk/blender/source/blender/python/api2_2x/doc/IpoCurve.py 2008-10-11 11:08:30 UTC (rev 17015)
+++ trunk/blender/source/blender/python/api2_2x/doc/IpoCurve.py 2008-10-11 12:17:16 UTC (rev 17016)
@@ -216,6 +216,17 @@
@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}).
More information about the Bf-blender-cvs
mailing list