diff options
author | Joshua Leung <aligorith@gmail.com> | 2009-03-22 12:54:13 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2009-03-22 12:54:13 +0300 |
commit | 7c86a10aba535dd68c79244487760e5b87c2eed8 (patch) | |
tree | 3bef26aadd0cea04aa8ec3b83f373b38a763a0d1 /source | |
parent | b995f4329a65278a229a32674ed2083ee04310a3 (diff) |
F-Curve Modifiers - Envelope: Bugfixes
* Envelope modifier now works correctly. Previously, the mapping was being done in the wrong order.
* Extra controls for modifiers now only draw when the F-Curve is the active one, so the view will be less cluttered in other cases.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/fcurve.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_draw.c | 11 |
2 files changed, 10 insertions, 8 deletions
diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index f58616cdf92..f087727dd9c 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -1464,10 +1464,11 @@ static void fcm_envelope_evaluate (FCurve *fcu, FModifier *fcm, float *cvalue, f } /* adjust *cvalue - * NOTE: env->min/max are relative to env->midval, and can be either +ve OR -ve, so we add... + * - fac is the ratio of how the current y-value corresponds to the reference range + * - thus, the new value is found by mapping the old range to the new! */ - fac= (*cvalue - min) / (max - min); - *cvalue= (env->midval + env->min) + (fac * (env->max - env->min)); + fac= (*cvalue - (env->midval + env->min)) / (env->max - env->min); + *cvalue= min + fac*(max - min); } static FModifierTypeInfo FMI_ENVELOPE = { diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c index dad4a771cd9..46d3f102b89 100644 --- a/source/blender/editors/space_graph/graph_draw.c +++ b/source/blender/editors/space_graph/graph_draw.c @@ -95,7 +95,7 @@ extern void gl_round_box(int mode, float minx, float miny, float maxx, float max /* Envelope -------------- */ -// TODO: draw a shaded poly showing the region of influence too? +// TODO: draw a shaded poly showing the region of influence too!!! static void draw_fcurve_modifier_controls_envelope (FCurve *fcu, FModifier *fcm, View2D *v2d) { FMod_Envelope *env= (FMod_Envelope *)fcm->data; @@ -104,7 +104,6 @@ static void draw_fcurve_modifier_controls_envelope (FCurve *fcu, FModifier *fcm, int i; /* draw two black lines showing the standard reference levels */ - // TODO: how to make these more distinctive? glColor3f(0.0f, 0.0f, 0.0f); setlinestyle(5); @@ -117,7 +116,6 @@ static void draw_fcurve_modifier_controls_envelope (FCurve *fcu, FModifier *fcm, glEnd(); // GL_LINES setlinestyle(0); - /* set size of vertices (non-adjustable for now) */ glPointSize(2.0f); @@ -821,11 +819,14 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri /* 2) draw handles and vertices as appropriate based on active */ if ( ((fcm) && (fcm->type != FMODIFIER_TYPE_CYCLES)) || (fcu->modifiers.first && !fcm) ) { - /* draw controls for the 'active' modifier (if applicable) + /* draw controls for the 'active' modifier + * - there may not be an 'active' modifier on this curve to draw + * - this curve may not be active, so modifier controls shouldn't get drawn either + * * NOTE: cycles modifier is currently an exception where the original points can still be edited, so * this branch is skipped... (TODO: set up the generic system for this so that we don't need special hacks like this) */ - if (fcm) { + if ((fcu->flag & FCURVE_ACTIVE) && (fcm)) { switch (fcm->type) { case FMODIFIER_TYPE_ENVELOPE: /* envelope */ draw_fcurve_modifier_controls_envelope(fcu, fcm, &ar->v2d); |