diff options
author | Joshua Leung <aligorith@gmail.com> | 2014-03-21 17:50:24 +0400 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2014-03-21 18:00:27 +0400 |
commit | daccaa713b6e66af4b958fa373b31d557a4caa33 (patch) | |
tree | 9e257e0b6d9e641ab3c9843304c9644ff9ca76ab /source/blender/makesrna | |
parent | 6e99fb04b6cccef4d5685184dfd0d1406fc6e624 (diff) |
Patch T22084: Robert Penner Easing Equations for FCurves
This commit introduces support for a number of new interpolation types
which are useful for motion-graphics work. These define a number of
"easing equations" (basically, equations which define some preset
ways that one keyframe transitions to another) which reduce the amount
of manual work (inserting and tweaking keyframes) to achieve certain
common effects. For example, snappy movements, and fake-physics such
as bouncing/springing effects.
The additional interpolation types introduced in this commit can be found
in many packages and toolkits (notably Qt and all modern web browsers).
For more info and a few live demos, see [1] and [2].
Credits:
* Dan Eicher (dna) - Original patch
* Thomas Beck (plasmasolutions) - Porting/updating patch to 2.70 codebase
* Joshua Leung (aligorith) - Code review and a few polishing tweaks
Additional Resources:
[1] http://easings.net
[2] http://www.robertpenner.com/easing/
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r-- | source/blender/makesrna/RNA_enum_types.h | 1 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 22 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_fcurve.c | 32 |
3 files changed, 55 insertions, 0 deletions
diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 49ff04192b8..0b73fc932a9 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -72,6 +72,7 @@ extern EnumPropertyItem color_sets_items[]; extern EnumPropertyItem beztriple_keyframe_type_items[]; extern EnumPropertyItem beztriple_interpolation_mode_items[]; +extern EnumPropertyItem beztriple_interpolation_easing_items[]; extern EnumPropertyItem keyframe_handle_type_items[]; extern EnumPropertyItem keyblock_type_items[]; diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index 0c17b55d2c6..a4d099c69c7 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -34,6 +34,8 @@ #include "BLI_utildefines.h" #include "BLI_math.h" +#include "BLF_translation.h" + #include "BKE_font.h" #include "RNA_access.h" @@ -67,9 +69,29 @@ EnumPropertyItem keyframe_handle_type_items[] = { }; EnumPropertyItem beztriple_interpolation_mode_items[] = { + /* interpolation */ + {0, "", 0, N_("Interpolation"), "Standard transitions between keyframes"}, {BEZT_IPO_CONST, "CONSTANT", 0, "Constant", "No interpolation, value of A gets held until B is encountered"}, {BEZT_IPO_LIN, "LINEAR", 0, "Linear", "Straight-line interpolation between A and B (i.e. no ease in/out)"}, {BEZT_IPO_BEZ, "BEZIER", 0, "Bezier", "Smooth interpolation between A and B, with some control over curve shape"}, + + /* easing */ + {0, "", 0, N_("Easing (by strength)"), "Predefined inertial transitions, useful for motion graphics (from least to most ''dramatic'')"}, + {BEZT_IPO_QUAD, "QUAD", 0, "Quadratic", "Quadratic easing (weakest)"}, + {BEZT_IPO_CUBIC, "CUBIC", 0, "Cubic", "Cubic easing"}, + {BEZT_IPO_QUART, "QUART", 0, "Quartic", "Quartic easing"}, + {BEZT_IPO_QUINT, "QUINT", 0, "Quintic", "Quintic easing"}, + {BEZT_IPO_EXPO, "EXPO", 0, "Exponential", "Exponential easing (strongest)"}, + + {0, "", 0, N_("Dynamic Effects"), "Simple physics-inspired easing effects"}, + {BEZT_IPO_BACK, "BACK", 0, "Back", "Cubic easing with overshoot and settle"}, + {BEZT_IPO_BOUNCE, "BOUNCE", 0, "Bounce", "Exponentially decaying parabolic bounce, like when objects collide"}, + {BEZT_IPO_ELASTIC, "ELASTIC", 0, "Elastic", "Exponentially decaying sine wave, like an elastic band"}, + + {0, "", 0, N_("Other"), "Other easing equations"}, + {BEZT_IPO_SINE, "SINE", 0, "Sinusoidal", "Sinusoidal easing"}, + {BEZT_IPO_CIRC, "CIRC", 0, "Circular", "Circular easing"}, + {0, NULL, 0, NULL, NULL} }; diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index aad8d6057ed..81fa2ad62a4 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -27,6 +27,7 @@ #include <stdlib.h> #include "DNA_anim_types.h" +#include "DNA_curve_types.h" #include "DNA_object_types.h" #include "DNA_scene_types.h" @@ -76,6 +77,13 @@ EnumPropertyItem beztriple_keyframe_type_items[] = { {0, NULL, 0, NULL, NULL} }; +EnumPropertyItem beztriple_interpolation_easing_items[] = { + {BEZT_IPO_EASE_IN, "EASE_IN", 0, "Ease In", "Only on the end closest to the next keyframe"}, + {BEZT_IPO_EASE_OUT, "EASE_OUT", 0, "Ease Out", "Only on the end closest to the first keyframe"}, + {BEZT_IPO_EASE_IN_OUT, "EASE_IN_OUT", 0, "Ease In and Out", "Segment between both keyframes"}, + {0, NULL, 0, NULL, NULL} +}; + #ifdef RNA_RUNTIME #include "WM_api.h" @@ -1652,6 +1660,30 @@ static void rna_def_fkeyframe(BlenderRNA *brna) RNA_def_property_ui_text(prop, "Type", "Type of keyframe (for visual purposes only)"); RNA_def_property_update(prop, NC_ANIMATION | ND_KEYFRAME_PROP, NULL); + + prop = RNA_def_property(srna, "easing", PROP_ENUM, PROP_NONE); + RNA_def_property_enum_sdna(prop, NULL, "easing"); + RNA_def_property_enum_items(prop, beztriple_interpolation_easing_items); + RNA_def_property_ui_text(prop, "Easing", + "Which ends of the segment between this and the next keyframe easing " + "interpolation is applied to"); + RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + + prop = RNA_def_property(srna, "back", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "back"); + RNA_def_property_ui_text(prop, "Back", "Amount of overshoot for 'back' easing"); + RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + + prop = RNA_def_property(srna, "amplitude", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "amplitude"); + RNA_def_property_ui_text(prop, "Amplitude", "Amplitude of bounces for elastic easing"); + RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + + prop = RNA_def_property(srna, "period", PROP_FLOAT, PROP_NONE); + RNA_def_property_float_sdna(prop, NULL, "period"); + RNA_def_property_ui_text(prop, "Period", "Time between bounces for elastic easing"); + RNA_def_property_update(prop, NC_ANIMATION|ND_KEYFRAME_PROP, NULL); + /* Vector values */ prop = RNA_def_property(srna, "handle_left", PROP_FLOAT, PROP_COORDS); /* keyframes are dimensionless */ RNA_def_property_array(prop, 2); |