diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-12-22 13:14:13 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-12-22 13:14:13 +0300 |
commit | 5a3ac3ceeb0d3550c14987f5cfd607e1ad126e64 (patch) | |
tree | a8745cb5bf1ad23a1702993f964a96ddf64092a3 /source/blender/editors | |
parent | e207d045322db4656f42f68ae9fa092ac1478635 (diff) |
Assorted F-Curve/Keyframe API stuff (for use with some Sequencer editing):
* Added function for F-Curves to find the F-Curves in a given list which affect some named data, such as bones, nodes, or sequence strips.
* Added a BezTriple offsetting callback to be used with the F-Curve+Keyframe loopers in use for many of the keyframe editing tools.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/animation/keyframes_edit.c | 16 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframes_general.c | 2 | ||||
-rw-r--r-- | source/blender/editors/include/ED_keyframes_edit.h | 18 |
3 files changed, 34 insertions, 2 deletions
diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 83acfbee940..9476aa479a7 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -559,6 +559,22 @@ short bezt_to_cfraelem(BeztEditData *bed, BezTriple *bezt) return 0; } +/* used to remap times from one range to another + * requires: bed->data = BeztEditCD_Remap + */ +short bezt_remap_times(BeztEditData *bed, BezTriple *bezt) +{ + BeztEditCD_Remap *rmap= (BeztEditCD_Remap*)bed->data; + const float scale = (rmap->newMax - rmap->newMin) / (rmap->oldMax - rmap->oldMin); + + /* perform transform on all three handles unless indicated otherwise */ + // TODO: need to include some checks for that + + bezt->vec[0][0]= scale*(bezt->vec[0][0] - rmap->oldMin) + rmap->newMin; + bezt->vec[1][0]= scale*(bezt->vec[1][0] - rmap->oldMin) + rmap->newMin; + bezt->vec[2][0]= scale*(bezt->vec[2][0] - rmap->oldMin) + rmap->newMin; +} + /* ******************************************* */ /* Transform */ diff --git a/source/blender/editors/animation/keyframes_general.c b/source/blender/editors/animation/keyframes_general.c index 3b717bafc70..fb9d4d53b0f 100644 --- a/source/blender/editors/animation/keyframes_general.c +++ b/source/blender/editors/animation/keyframes_general.c @@ -60,7 +60,7 @@ * fine to have these calls here. * * There are also a few tools here which cannot be easily coded for in the other system (yet). - * These may also be moved around at some point, but for now, they + * These may also be moved around at some point, but for now, they are best added here. * * - Joshua Leung, Dec 2008 */ diff --git a/source/blender/editors/include/ED_keyframes_edit.h b/source/blender/editors/include/ED_keyframes_edit.h index 4a0a3ee24db..26290d8771c 100644 --- a/source/blender/editors/include/ED_keyframes_edit.h +++ b/source/blender/editors/include/ED_keyframes_edit.h @@ -100,11 +100,19 @@ typedef struct BeztEditData { /* ------- Function Pointer Typedefs ---------------- */ - /* callback function that refreshes the IPO curve after use */ + /* callback function that refreshes the F-Curve after use */ typedef void (*FcuEditFunc)(struct FCurve *fcu); /* callback function that operates on the given BezTriple */ typedef short (*BeztEditFunc)(BeztEditData *bed, struct BezTriple *bezt); +/* ------- Custom Data Type Defines ------------------ */ + +/* Custom data for remapping one range to another in a fixed way */ +typedef struct BeztEditCD_Remap { + float oldMin, oldMax; /* old range */ + float newMin, newMax; /* new range */ +} BeztEditCD_Remap; + /* ---------------- Looping API --------------------- */ /* functions for looping over keyframes */ @@ -137,9 +145,17 @@ BeztEditFunc ANIM_editkeyframes_keytype(short mode); /* ----------- BezTriple Callback (Assorted Utilities) ---------- */ +/* used to calculate the the average location of all relevant BezTriples by summing their locations */ short bezt_calc_average(BeztEditData *bed, struct BezTriple *bezt); + +/* used to extract a set of cfra-elems from the keyframes */ short bezt_to_cfraelem(BeztEditData *bed, struct BezTriple *bezt); +/* used to remap times from one range to another + * requires: bed->custom = BeztEditCD_Remap + */ +short bezt_remap_times(BeztEditData *bed, struct BezTriple *bezt); + /* ************************************************ */ /* Destructive Editing API (keyframes_general.c) */ |