diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-03-18 13:58:18 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-03-18 13:58:18 +0300 |
commit | 43d4e3fa7efca3ae2cedfd35fa344bf2ef298a7f (patch) | |
tree | c1d535aeb889a116ced221744d6bc0bbd828e4d6 /source/blender/blenkernel | |
parent | aeb2225a287e68d8ee03861bec112ce3459a468a (diff) |
Graph Editor: F-Curves which can only take integral values are now drawn stair-stepped using the sampling code.
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r-- | source/blender/blenkernel/BKE_fcurve.h | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 26 |
2 files changed, 28 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_fcurve.h b/source/blender/blenkernel/BKE_fcurve.h index a53785adf17..9503c569e8b 100644 --- a/source/blender/blenkernel/BKE_fcurve.h +++ b/source/blender/blenkernel/BKE_fcurve.h @@ -94,13 +94,15 @@ FModifierTypeInfo *get_fmodifier_typeinfo(int type); /* ---------------------- */ -struct FModifier *fcurve_active_modifier(struct FCurve *fcu); struct FModifier *fcurve_add_modifier(struct FCurve *fcu, int type); void fcurve_copy_modifiers(ListBase *dst, ListBase *src); void fcurve_remove_modifier(struct FCurve *fcu, struct FModifier *fcm); void fcurve_free_modifiers(struct FCurve *fcu); void fcurve_bake_modifiers(struct FCurve *fcu, int start, int end); +struct FModifier *fcurve_find_active_modifier(struct FCurve *fcu); +void fcurve_set_active_modifier(struct FCurve *fcu, struct FModifier *fcm); + /* ************** F-Curves API ******************** */ /* -------- Data Managemnt -------- */ diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 6f6d40c33ba..72321eb7292 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1892,7 +1892,7 @@ void fcurve_bake_modifiers (FCurve *fcu, int start, int end) } /* Find the active F-Curve Modifier */ -FModifier *fcurve_active_modifier (FCurve *fcu) +FModifier *fcurve_find_active_modifier (FCurve *fcu) { FModifier *fcm; @@ -1910,6 +1910,24 @@ FModifier *fcurve_active_modifier (FCurve *fcu) return NULL; } +/* Set the active F-Curve Modifier */ +void fcurve_set_active_modifier (FCurve *fcu, FModifier *fcm) +{ + FModifier *fm; + + /* sanity checks */ + if ELEM(NULL, fcu, fcu->modifiers.first) + return NULL; + + /* deactivate all, and set current one active */ + for (fm= fcu->modifiers.first; fm; fm= fm->next) + fm->flag &= ~FMODIFIER_FLAG_ACTIVE; + + /* make given modifier active */ + if (fcm) + fcm->flag |= FMODIFIER_FLAG_ACTIVE; +} + /* ***************************** F-Curve - Evaluation ********************************* */ /* Evaluate and return the value of the given F-Curve at the specified frame ("evaltime") @@ -1946,6 +1964,12 @@ float evaluate_fcurve (FCurve *fcu, float evaltime) } } + /* if curve can only have integral values, perform truncation (i.e. drop the decimal part) + * here so that the curve can be sampled correctly + */ + if (fcu->flag & FCURVE_INT_VALUES) + cvalue= (float)((int)cvalue); + /* return evaluated value */ return cvalue; } |