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>2011-07-07 17:59:28 +0400
committerJoshua Leung <aligorith@gmail.com>2011-07-07 17:59:28 +0400
commitc9d6989098e2defbaea36b767169f521c8a5d62a (patch)
tree9b2ef25a4e742d62bed4de2333aa57f3661c3eb3 /source/blender/editors/space_graph/graph_edit.c
parentbc9432b9056fc28b668949375b353a47215e3683 (diff)
Animation Goodie: Cyclic "Extrapolation" can be toggled from the "Set
Extrapolation" tool again Added "Make Cyclic" and "Clear Cyclic" options to "Set Extrapolation" tool (found from Channels menu) in Animation Editors. These options simply add or remove (respectively) Cycles FModifiers from the selected F-Curves, making them have cyclic extrapolation with a single click, instead of having to go through the FModifiers UI (or Graph- Editor only "Add FModifier" operator), which should make it easier to do this apparently common chore.
Diffstat (limited to 'source/blender/editors/space_graph/graph_edit.c')
-rw-r--r--source/blender/editors/space_graph/graph_edit.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 4abf00f82d3..d88a18ffcbc 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -1269,10 +1269,17 @@ void GRAPH_OT_sample (wmOperatorType *ot)
/* ******************** Set Extrapolation-Type Operator *********************** */
+/* defines for make/clear cyclic extrapolation tools */
+#define MAKE_CYCLIC_EXPO -1
+#define CLEAR_CYCLIC_EXPO -2
+
/* defines for set extrapolation-type for selected keyframes tool */
static EnumPropertyItem prop_graphkeys_expo_types[] = {
{FCURVE_EXTRAPOLATE_CONSTANT, "CONSTANT", 0, "Constant Extrapolation", ""},
{FCURVE_EXTRAPOLATE_LINEAR, "LINEAR", 0, "Linear Extrapolation", ""},
+
+ {MAKE_CYCLIC_EXPO, "MAKE_CYCLIC", 0, "Make Cyclic (F-Modifier)", "Add Cycles F-Modifier if one doesn't exist already"},
+ {CLEAR_CYCLIC_EXPO, "CLEAR_CYCLIC", 0, "Clear Cyclic (F-Modifier)", "Remove Cycles F-Modifier if not needed anymore"},
{0, NULL, 0, NULL, NULL}
};
@@ -1290,7 +1297,34 @@ static void setexpo_graph_keys(bAnimContext *ac, short mode)
/* loop through setting mode per F-Curve */
for (ale= anim_data.first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->data;
- fcu->extend= mode;
+
+ if (mode >= 0) {
+ /* just set mode setting */
+ fcu->extend= mode;
+ }
+ else {
+ /* shortcuts for managing Cycles F-Modifiers to make it easier to toggle cyclic animation
+ * without having to go through FModifier UI in Graph Editor to do so
+ */
+ if (mode == MAKE_CYCLIC_EXPO) {
+ /* only add if one doesn't exist */
+ if (list_has_suitable_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES, -1) == 0) {
+ // TODO: add some more preset versions which set different extrapolation options?
+ add_fmodifier(&fcu->modifiers, FMODIFIER_TYPE_CYCLES);
+ }
+ }
+ else if (mode == CLEAR_CYCLIC_EXPO) {
+ /* remove all the modifiers fitting this description */
+ FModifier *fcm, *fcn=NULL;
+
+ for (fcm = fcu->modifiers.first; fcm; fcm = fcn) {
+ fcn = fcm->next;
+
+ if (fcm->type == FMODIFIER_TYPE_CYCLES)
+ remove_fmodifier(&fcu->modifiers, fcm);
+ }
+ }
+ }
}
/* cleanup */