[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [17242] branches/animsys2/source/blender: AnimSys2: Per-Segment Interpolation of IPO-Curves
Joshua Leung
aligorith at gmail.com
Fri Oct 31 09:43:38 CET 2008
Revision: 17242
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17242
Author: aligorith
Date: 2008-10-31 09:43:36 +0100 (Fri, 31 Oct 2008)
Log Message:
-----------
AnimSys2: Per-Segment Interpolation of IPO-Curves
It is now possible to define the interpolation that will be used to get from a keyframe until the next one is encountered.
With an Ipo-Curve in EditMode, only the selected keyframes will get the specified interpolation mode set.
Out of EditMode, the interpolation mode will be applied to all the keyframes of an IPO-curve that is selected.
- When inserting keyframes for curves that have multiple types of interpolation in use, the interpolation mode of the keyframe immediately before the added one is used.
- Old files get converted automatically
- Subversion has been bumped up to 2, so that old files get converted properly.
Modified Paths:
--------------
branches/animsys2/source/blender/blenkernel/BKE_blender.h
branches/animsys2/source/blender/blenkernel/BKE_ipo.h
branches/animsys2/source/blender/blenkernel/intern/ipo.c
branches/animsys2/source/blender/blenloader/intern/readfile.c
branches/animsys2/source/blender/include/BSE_editipo.h
branches/animsys2/source/blender/makesdna/DNA_curve_types.h
branches/animsys2/source/blender/python/api2_2x/Ipocurve.c
branches/animsys2/source/blender/src/drawipo.c
branches/animsys2/source/blender/src/editipo_mods.c
branches/animsys2/source/blender/src/header_ipo.c
branches/animsys2/source/blender/src/keyframing.c
branches/animsys2/source/blender/src/space.c
Modified: branches/animsys2/source/blender/blenkernel/BKE_blender.h
===================================================================
--- branches/animsys2/source/blender/blenkernel/BKE_blender.h 2008-10-31 06:25:51 UTC (rev 17241)
+++ branches/animsys2/source/blender/blenkernel/BKE_blender.h 2008-10-31 08:43:36 UTC (rev 17242)
@@ -41,7 +41,7 @@
struct MemFile;
#define BLENDER_VERSION 248
-#define BLENDER_SUBVERSION 1
+#define BLENDER_SUBVERSION 2
#define BLENDER_MINVERSION 245
#define BLENDER_MINSUBVERSION 15
Modified: branches/animsys2/source/blender/blenkernel/BKE_ipo.h
===================================================================
--- branches/animsys2/source/blender/blenkernel/BKE_ipo.h 2008-10-31 06:25:51 UTC (rev 17241)
+++ branches/animsys2/source/blender/blenkernel/BKE_ipo.h 2008-10-31 08:43:36 UTC (rev 17242)
@@ -24,7 +24,7 @@
*
* The Original Code is: all of this file.
*
- * Contributor(s): none yet.
+ * Contributor(s): 2008, Joshua Leung (Animation Cleanup)
*
* ***** END GPL LICENSE BLOCK *****
*/
@@ -87,6 +87,8 @@
void sort_time_ipocurve(struct IpoCurve *icu);
int test_time_ipocurve(struct IpoCurve *icu);
+void set_interpolation_ipocurve(struct IpoCurve *icu, short ipo);
+
/* -------- IPO-Curve (Bezier) Calculations ---------- */
void correct_bezpart(float *v1, float *v2, float *v3, float *v4);
Modified: branches/animsys2/source/blender/blenkernel/intern/ipo.c
===================================================================
--- branches/animsys2/source/blender/blenkernel/intern/ipo.c 2008-10-31 06:25:51 UTC (rev 17241)
+++ branches/animsys2/source/blender/blenkernel/intern/ipo.c 2008-10-31 08:43:36 UTC (rev 17242)
@@ -805,7 +805,6 @@
}
}
-#if 0 // TODO: enable when we have per-segment interpolation
/* This function sets the interpolation mode for an entire Ipo-Curve.
* It is primarily used for patching old files, but is also used in the interface
* to make sure that all segments of the curve use the same interpolation.
@@ -826,7 +825,6 @@
for (a=0, bezt=icu->bezt; a<icu->totvert; a++, bezt++)
bezt->ipo= ipo;
}
-#endif // TODO: enable when we have per-segment interpolation
/* ***************************** Curve Calculations ********************************* */
@@ -1030,7 +1028,6 @@
else
#endif /* DISABLE_PYTHON */
{
-
Object *ob= driver->ob;
/* must have an object to evaluate */
@@ -1142,7 +1139,7 @@
}
/* evaluate and return the value of the given IPO-curve at the specified frame ("evaltime") */
-float eval_icu(IpoCurve *icu, float evaltime)
+float eval_icu (IpoCurve *icu, float evaltime)
{
float cvalue = 0.0f;
@@ -1194,12 +1191,11 @@
}
/* evaluation time at or past endpoints? */
- // TODO: for per-bezt interpolation, replace all icu->ipo with (bezt)->ipo
if (prevbezt->vec[1][0] >= evaltime) {
/* before or on first keyframe */
- if ((icu->extrap & IPO_DIR) && (icu->ipo != IPO_CONST)) {
+ if ((icu->extrap & IPO_DIR) && (prevbezt->ipo != IPO_CONST)) {
/* linear or bezier interpolation */
- if (icu->ipo==IPO_LIN) {
+ if (prevbezt->ipo==IPO_LIN) {
/* Use the next center point instead of our own handle for
* linear interpolated extrapolate
*/
@@ -1244,9 +1240,9 @@
}
else if (lastbezt->vec[1][0] <= evaltime) {
/* after or on last keyframe */
- if( (icu->extrap & IPO_DIR) && (icu->ipo != IPO_CONST)) {
+ if( (icu->extrap & IPO_DIR) && (lastbezt->ipo != IPO_CONST)) {
/* linear or bezier interpolation */
- if (icu->ipo==IPO_LIN) {
+ if (lastbezt->ipo==IPO_LIN) {
/* Use the next center point instead of our own handle for
* linear interpolated extrapolate
*/
@@ -1291,16 +1287,15 @@
}
else {
/* evaltime occurs somewhere in the middle of the curve */
- // TODO: chould be optimised by using a binary search instead???
for (a=0; prevbezt && bezt && (a < icu->totvert-1); a++, prevbezt=bezt, bezt++) {
/* evaltime occurs within the interval defined by these two keyframes */
if ((prevbezt->vec[1][0] <= evaltime) && (bezt->vec[1][0] >= evaltime)) {
/* value depends on interpolation mode */
- if (icu->ipo == IPO_CONST) {
+ if (prevbezt->ipo == IPO_CONST) {
/* constant (evaltime not relevant, so no interpolation needed) */
cvalue= prevbezt->vec[1][1];
}
- else if (icu->ipo == IPO_LIN) {
+ else if (prevbezt->ipo == IPO_LIN) {
/* linear - interpolate between values of the two keyframes */
fac= bezt->vec[1][0] - prevbezt->vec[1][0];
@@ -1341,7 +1336,7 @@
}
/* apply y-offset (for 'cyclic extrapolation') to calculated value */
- cvalue+= cycyofs;
+ cvalue += cycyofs;
}
/* clamp evaluated value to lie within allowable value range for this channel */
Modified: branches/animsys2/source/blender/blenloader/intern/readfile.c
===================================================================
--- branches/animsys2/source/blender/blenloader/intern/readfile.c 2008-10-31 06:25:51 UTC (rev 17241)
+++ branches/animsys2/source/blender/blenloader/intern/readfile.c 2008-10-31 08:43:36 UTC (rev 17242)
@@ -127,6 +127,7 @@
#include "BKE_global.h" // for G
#include "BKE_group.h"
#include "BKE_image.h"
+#include "BKE_ipo.h"
#include "BKE_key.h" //void set_four_ipo
#include "BKE_lattice.h"
#include "BKE_library.h" // for wich_libbase
@@ -7977,6 +7978,16 @@
}
}
+ if (main->versionfile < 248 || (main->versionfile == 248 && main->subversionfile < 2)) {
+ Ipo *ipo;
+ IpoCurve *icu;
+
+ for (ipo=main->ipo.first; ipo; ipo= ipo->id.next) {
+ for (icu= ipo->curve.first; icu; icu= icu->next)
+ set_interpolation_ipocurve(icu, icu->ipo);
+ }
+ }
+
/* WATCH IT!!!: pointers from libdata have not been converted yet here! */
/* WATCH IT 2!: Userdef struct init has to be in src/usiblender.c! */
Modified: branches/animsys2/source/blender/include/BSE_editipo.h
===================================================================
--- branches/animsys2/source/blender/include/BSE_editipo.h 2008-10-31 06:25:51 UTC (rev 17241)
+++ branches/animsys2/source/blender/include/BSE_editipo.h 2008-10-31 08:43:36 UTC (rev 17242)
@@ -106,7 +106,7 @@
void sethandles_ipo(int code);
void select_ipo_bezier_keys(struct Ipo *ipo, int selectmode);
void select_icu_bezier_keys(struct IpoCurve *icu, int selectmode);
-void set_ipotype(void);
+void set_ipotype(short code);
void set_ipoextend(void);
void borderselect_ipo(void);
void del_ipo(int need_check);
Modified: branches/animsys2/source/blender/makesdna/DNA_curve_types.h
===================================================================
--- branches/animsys2/source/blender/makesdna/DNA_curve_types.h 2008-10-31 06:25:51 UTC (rev 17241)
+++ branches/animsys2/source/blender/makesdna/DNA_curve_types.h 2008-10-31 08:43:36 UTC (rev 17242)
@@ -88,7 +88,8 @@
typedef struct BezTriple {
float vec[3][3];
float alfa, weight, radius; /* alfa: tilt in 3D View, weight: used for softbody goal weight, radius: for bevel tapering */
- short h1, h2; /* h1, h2: the handle type of the two handles */
+ short ipo; /* ipo: interpolation mode for segment from this BezTriple to the next */
+ char h1, h2; /* h1, h2: the handle type of the two handles */
char f1, f2, f3, hide; /* f1, f2, f3: used for selection status, hide: used to indicate whether BezTriple is hidden */
} BezTriple;
Modified: branches/animsys2/source/blender/python/api2_2x/Ipocurve.c
===================================================================
--- branches/animsys2/source/blender/python/api2_2x/Ipocurve.c 2008-10-31 06:25:51 UTC (rev 17241)
+++ branches/animsys2/source/blender/python/api2_2x/Ipocurve.c 2008-10-31 08:43:36 UTC (rev 17242)
@@ -415,8 +415,8 @@
else
return EXPP_ReturnPyObjError( PyExc_TypeError,
"bad interpolation type" );
-
- self->ipocurve->ipo = id;
+
+ set_interpolation_ipocurve(self->ipocurve, id);
Py_RETURN_NONE;
}
@@ -435,6 +435,9 @@
case IPO_LIN:
str = "Linear";
break;
+ case IPO_MIXED:
+ str = "Mixed";
+ break;
default:
return EXPP_ReturnPyObjError( PyExc_TypeError,
"unknown interpolation type" );
Modified: branches/animsys2/source/blender/src/drawipo.c
===================================================================
--- branches/animsys2/source/blender/src/drawipo.c 2008-10-31 06:25:51 UTC (rev 17241)
+++ branches/animsys2/source/blender/src/drawipo.c 2008-10-31 08:43:36 UTC (rev 17242)
@@ -1192,7 +1192,7 @@
else { /* normal (non bit) curves */
if (edit) {
/* Only the vertex of the line, the
- * handler are draw below.
+ * handler are drawn later
*/
if ((bezt->f2 & SELECT) == sel) /* && G.v2d->cur.xmin < bezt->vec[1][0] < G.v2d->cur.xmax)*/
bglVertex3fv(bezt->vec[1]);
@@ -1211,6 +1211,7 @@
static void draw_ipovertices_handles(IpoCurve *icu, short disptype, short sel)
{
BezTriple *bezt= icu->bezt;
+ BezTriple *prevbezt = NULL;
int a;
/* Handles can be draw with different size to see them better */
@@ -1221,17 +1222,23 @@
else BIF_ThemeColor(TH_HANDLE_VERTEX);
bglBegin(GL_POINTS);
- for (a= 0; a < icu->totvert; a++, bezt++) {
+ for (a= 0; a < icu->totvert; a++, prevbezt=bezt, bezt++) {
if (disptype != IPO_DISPBITS) {
- if (icu->ipo == IPO_BEZ) {
- /* Draw the editmode hendels for a bezier curve (others don't have handles)
+ if (ELEM(icu->ipo, IPO_BEZ, IPO_MIXED)) {
+ /* Draw the editmode handels for a bezier curve (others don't have handles)
* if their selection status matches the selection status we're drawing for
+ * - first handle only if previous beztriple was bezier-mode
+ * - second handle only if current beztriple is bezier-mode
*/
- if ((bezt->f1 & SELECT) == sel)/* && G.v2d->cur.xmin < bezt->vec[0][0] < G.v2d->cur.xmax)*/
- bglVertex3fv(bezt->vec[0]);
+ if ((!prevbezt && (bezt->ipo==IPO_BEZ)) || (prevbezt->ipo==IPO_BEZ)) {
+ if ((bezt->f1 & SELECT) == sel)/* && G.v2d->cur.xmin < bezt->vec[0][0] < G.v2d->cur.xmax)*/
+ bglVertex3fv(bezt->vec[0]);
+ }
- if ((bezt->f3 & SELECT) == sel)/* && G.v2d->cur.xmin < bezt->vec[2][0] < G.v2d->cur.xmax)*/
- bglVertex3fv(bezt->vec[2]);
+ if (bezt->ipo==IPO_BEZ) {
+ if ((bezt->f3 & SELECT) == sel)/* && G.v2d->cur.xmin < bezt->vec[2][0] < G.v2d->cur.xmax)*/
+ bglVertex3fv(bezt->vec[2]);
+ }
}
}
}
@@ -1300,52 +1307,66 @@
{
extern unsigned int nurbcol[];
EditIpo *ei;
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list