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>2009-03-21 06:49:22 +0300
committerJoshua Leung <aligorith@gmail.com>2009-03-21 06:49:22 +0300
commitb4209c56565660c20718fc2e1ad74d4257683a3e (patch)
tree122710c4991e46fcdbfda575b517d8cff827da50 /source/blender/editors/space_graph/graph_draw.c
parent90a58790b24a7e0303f890f054ae7f730e242491 (diff)
F-Curve Modifiers: Envelope Modifier
Got the basic envelope modifier code working, including primitive drawing of relevant helper info in the graph view. It doesn't work in a very intuitive way yet, so I will recode it soon.
Diffstat (limited to 'source/blender/editors/space_graph/graph_draw.c')
-rw-r--r--source/blender/editors/space_graph/graph_draw.c68
1 files changed, 65 insertions, 3 deletions
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index f7f47760057..dad4a771cd9 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -91,7 +91,59 @@ extern void ui_rasterpos_safe(float x, float y, float aspect);
extern void gl_round_box(int mode, float minx, float miny, float maxx, float maxy, float rad);
/* *************************** */
-/* Curve Drawing */
+/* F-Curve Modifier Drawing */
+
+/* Envelope -------------- */
+
+// 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;
+ FCM_EnvelopeData *fed;
+ const float fac= 0.05f * (v2d->cur.xmax - v2d->cur.xmin);
+ 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);
+
+ glBegin(GL_LINES);
+ glVertex2f(v2d->cur.xmin, env->midval+env->min);
+ glVertex2f(v2d->cur.xmax, env->midval+env->min);
+
+ glVertex2f(v2d->cur.xmin, env->midval+env->max);
+ glVertex2f(v2d->cur.xmax, env->midval+env->max);
+ glEnd(); // GL_LINES
+ setlinestyle(0);
+
+
+ /* set size of vertices (non-adjustable for now) */
+ glPointSize(2.0f);
+
+ // for now, point color is fixed, and is white
+ glColor3f(1.0f, 1.0f, 1.0f);
+
+ /* we use bgl points not standard gl points, to workaround vertex
+ * drawing bugs that some drivers have (probably legacy ones only though)
+ */
+ bglBegin(GL_POINTS);
+ for (i=0, fed=env->data; i < env->totvert; i++, fed++) {
+ /* only draw if visible
+ * - min/max here are fixed, not relative
+ */
+ if IN_RANGE(fed->time, (v2d->cur.xmin - fac), (v2d->cur.xmax + fac)) {
+ glVertex2f(fed->time, fed->min);
+ glVertex2f(fed->time, fed->max);
+ }
+ }
+ bglEnd();
+
+ glPointSize(1.0f);
+}
+
+/* *************************** */
+/* F-Curve Drawing */
/* Points ---------------- */
@@ -768,8 +820,18 @@ 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) ) {
- // TODO: need to add code to show these... for cycles modifier, should fall through though...
+ if ( ((fcm) && (fcm->type != FMODIFIER_TYPE_CYCLES)) || (fcu->modifiers.first && !fcm) ) {
+ /* draw controls for the 'active' modifier (if applicable)
+ * 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) {
+ switch (fcm->type) {
+ case FMODIFIER_TYPE_ENVELOPE: /* envelope */
+ draw_fcurve_modifier_controls_envelope(fcu, fcm, &ar->v2d);
+ break;
+ }
+ }
}
else if ( ((fcu->bezt) || (fcu->fpt)) && (fcu->totvert) ) {
if (fcu->bezt) {