diff options
-rw-r--r-- | source/blender/blenkernel/intern/anim_sys.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/ipo.c | 2 | ||||
-rw-r--r-- | source/blender/editors/animation/keyframes_draw.c | 27 | ||||
-rw-r--r-- | source/blender/editors/include/ED_keyframes_draw.h | 16 | ||||
-rw-r--r-- | source/blender/editors/space_action/action_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_nla/nla_draw.c | 128 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_anim_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_nla.c | 2 |
8 files changed, 102 insertions, 79 deletions
diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index ebe3d28cb21..19337f9de5d 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -859,7 +859,7 @@ static void nlaevalchan_accumulate (NlaEvalChannel *nec, NlaEvalStrip *nes, shor nec->value *= value; break; - case NLASTRIP_MODE_BLEND: + case NLASTRIP_MODE_REPLACE: default: // TODO: do we really want to blend by default? it seems more uses might prefer add... /* do linear interpolation * - the influence of the accumulated data (elsewhere, that is called dstweight) diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index c3c5483574e..cf7e486613b 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -1518,7 +1518,7 @@ static void nlastrips_to_animdata (ID *id, ListBase *strips) /* blending */ strip->blendin= as->blendin; strip->blendout= as->blendout; - strip->blendmode= (as->mode==ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD : NLASTRIP_MODE_BLEND; + strip->blendmode= (as->mode==ACTSTRIPMODE_ADD) ? NLASTRIP_MODE_ADD : NLASTRIP_MODE_REPLACE; if (as->flag & ACTSTRIP_AUTO_BLENDS) strip->flag |= NLASTRIP_FLAG_AUTO_BLENDS; /* assorted setting flags */ diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c index f122e045776..1db78beb2cb 100644 --- a/source/blender/editors/animation/keyframes_draw.c +++ b/source/blender/editors/animation/keyframes_draw.c @@ -243,7 +243,7 @@ static const float _unit_diamond_shape[4][2] = { }; /* draw a simple diamond shape with OpenGL */ -static void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel) +void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel, short mode) { static GLuint displist1=0; static GLuint displist2=0; @@ -281,16 +281,21 @@ static void draw_keyframe_shape (float x, float y, float xscale, float hsize, sh /* anti-aliased lines for more consistent appearance */ glEnable(GL_LINE_SMOOTH); - /* draw! ---------------------------- */ - - /* interior - hardcoded colors (for selected and unselected only) */ - if (sel) UI_ThemeColorShade(TH_STRIP_SELECT, 50);//glColor3ub(0xF1, 0xCA, 0x13); - else glColor3ub(0xE9, 0xE9, 0xE9); - glCallList(displist2); + /* draw! */ + if ELEM(mode, KEYFRAME_SHAPE_INSIDE, KEYFRAME_SHAPE_BOTH) { + /* interior - hardcoded colors (for selected and unselected only) */ + if (sel) UI_ThemeColorShade(TH_STRIP_SELECT, 50); + else glColor3ub(0xE9, 0xE9, 0xE9); + + glCallList(displist2); + } - /* exterior - black frame */ - glColor3ub(0, 0, 0); - glCallList(displist1); + if ELEM(mode, KEYFRAME_SHAPE_FRAME, KEYFRAME_SHAPE_BOTH) { + /* exterior - black frame */ + glColor3ub(0, 0, 0); + + glCallList(displist1); + } glDisable(GL_LINE_SMOOTH); @@ -345,7 +350,7 @@ static void draw_keylist(View2D *v2d, ListBase *keys, ListBase *blocks, float yp for (ak= keys->first; ak; ak= ak->next) { /* draw using OpenGL - uglier but faster */ // NOTE: a previous version of this didn't work nice for some intel cards - draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT)); + draw_keyframe_shape(ak->cfra, ypos, xscale, 5.0f, (ak->sel & SELECT), KEYFRAME_SHAPE_BOTH); #if 0 // OLD CODE //int sc_x, sc_y; diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h index 22ee7a42121..63adcf39c12 100644 --- a/source/blender/editors/include/ED_keyframes_draw.h +++ b/source/blender/editors/include/ED_keyframes_draw.h @@ -67,6 +67,22 @@ typedef struct ActKeyBlock { short totcurve; } ActKeyBlock; + +/* *********************** Keyframe Drawing ****************************** */ + +/* options for keyframe shape drawing */ +typedef enum eKeyframeShapeDrawOpts { + /* only the border */ + KEYFRAME_SHAPE_FRAME = 0, + /* only the inside filling */ + KEYFRAME_SHAPE_INSIDE, + /* the whole thing */ + KEYFRAME_SHAPE_BOTH +} eKeyframeShapeDrawOpts; + +/* draw simple diamond-shape keyframe (with OpenGL) */ +void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel, short mode); + /* ******************************* Methods ****************************** */ /* Channel Drawing */ diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c index 743cc1f128e..93d061e8bf3 100644 --- a/source/blender/editors/space_action/action_draw.c +++ b/source/blender/editors/space_action/action_draw.c @@ -1194,7 +1194,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar) glColor3f(0.0f, 0.0f, 0.0f); glBegin(GL_LINES); - glVertex2f(saction->timeslide, v2d->cur.ymin-EXTRA_SCROLL_PAD) + glVertex2f(saction->timeslide, v2d->cur.ymin-EXTRA_SCROLL_PAD); glVertex2f(saction->timeslide, v2d->cur.ymax); glEnd(); } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 3385906979a..6219acf6fae 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -91,66 +91,78 @@ extern void gl_round_box_shade(int mode, float minx, float miny, float maxx, flo /* *********************************************** */ /* Strips */ -/* Keyframe Ghosts ---------------------- */ +/* Action-Line ---------------------- */ -/* helper func - draw keyframe as a frame only */ -static void draw_nla_keyframe_ghost (float x, float y, float xscale, float hsize) +/* get colors for drawing Action-Line + * NOTE: color returned includes fine-tuned alpha! + */ +static void nla_action_get_color (AnimData *adt, bAction *act, float color[4]) { - static GLuint displist=0; - - /* initialise empty diamond shape */ - if (displist == 0) { - const float dist= 1.0f; - - displist= glGenLists(1); - glNewList(displist, GL_COMPILE); - - glBegin(GL_LINE_LOOP); - glVertex2f(0.0f, dist); - glVertex2f(dist, 0.0f); - glVertex2f(0.0f, -dist); - glVertex2f(-dist, 0.0f); - glEnd(); - - glEndList(); + // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) + if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { + // greenish color (same as tweaking strip) - hardcoded for now + color[0]= 0.30f; + color[1]= 0.95f; + color[2]= 0.10f; + color[3]= 0.30f; + } + else { + if (act) { + // reddish color - hardcoded for now + color[0]= 0.8f; + color[1]= 0.2f; + color[2]= 0.0f; + color[3]= 0.4f; + } + else { + // greyish-red color - hardcoded for now + color[0]= 0.6f; + color[1]= 0.5f; + color[2]= 0.5f; + color[3]= 0.3f; + } } - - /* adjust view transform before starting */ - glTranslatef(x, y, 0.0f); - glScalef(1.0f/xscale*hsize, hsize, 1.0f); - - /* anti-aliased lines for more consistent appearance */ - glEnable(GL_LINE_SMOOTH); - - /* draw! */ - glCallList(displist); - - glDisable(GL_LINE_SMOOTH); - - /* restore view transform */ - glScalef(xscale/hsize, 1.0f/hsize, 1.0); - glTranslatef(-x, -y, 0.0f); } /* draw the keyframes in the specified Action */ -static void nla_action_draw_keyframes (AnimData *adt, View2D *v2d, float y) +static void nla_action_draw_keyframes (AnimData *adt, bAction *act, View2D *v2d, float y, float ymin, float ymax) { ListBase keys = {NULL, NULL}; ActKeyColumn *ak; - float xscale; - - /* for now, color is hardcoded to be black */ - glColor3f(0.0f, 0.0f, 0.0f); + float xscale, f1, f2; + float color[4]; /* get a list of the keyframes with NLA-scaling applied */ - action_to_keylist(adt, adt->action, &keys, NULL); + action_to_keylist(adt, act, &keys, NULL); + + if ELEM(NULL, act, keys.first) + return; + + /* draw a darkened region behind the strips + * - get and reset the background color, this time without the alpha to stand out better + */ + nla_action_get_color(adt, act, color); + glColor3fv(color); + /* - draw a rect from the first to the last frame (no extra overlaps for now) + * that is slightly stumpier than the track background (hardcoded 2-units here) + */ + f1= ((ActKeyColumn *)keys.first)->cfra; + f2= ((ActKeyColumn *)keys.last)->cfra; + + glRectf(f1, ymin+2, f2, ymax-2); + /* get View2D scaling factor */ UI_view2d_getscale(v2d, &xscale, NULL); - /* just draw each keyframe as a simple dot (regardless of the selection status) */ + /* for now, color is hardcoded to be black */ + glColor3f(0.0f, 0.0f, 0.0f); + + /* just draw each keyframe as a simple dot (regardless of the selection status) + * - size is 3.0f which is smaller than the editable keyframes, so that there is a distinction + */ for (ak= keys.first; ak; ak= ak->next) - draw_nla_keyframe_ghost(ak->cfra, y, xscale, 3.0f); + draw_keyframe_shape(ak->cfra, y, xscale, 3.0f, 0, KEYFRAME_SHAPE_FRAME); /* free icons */ BLI_freelistN(&keys); @@ -158,6 +170,7 @@ static void nla_action_draw_keyframes (AnimData *adt, View2D *v2d, float y) /* Strips (Proper) ---------------------- */ +/* get colors for drawing NLA-Strips */ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float color[3]) { if (strip->type == NLASTRIP_TYPE_TRANSITION) { @@ -179,6 +192,7 @@ static void nla_strip_get_color_inside (AnimData *adt, NlaStrip *strip, float co } else if (strip->type == NLASTRIP_TYPE_META) { /* Meta Clip */ + // TODO: should temporary metas get different colours too? if (strip->flag & NLASTRIP_FLAG_SELECT) { /* selected - use a bold purple color */ // FIXME: hardcoded temp-hack colors @@ -535,6 +549,7 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) case ANIMTYPE_NLAACTION: { AnimData *adt= BKE_animdata_from_id(ale->id); + float color[4]; /* just draw a semi-shaded rect spanning the width of the viewable area if there's data, * and a second darker rect within which we draw keyframe indicator dots if there's data @@ -542,30 +557,17 @@ void draw_nla_main_data (bAnimContext *ac, SpaceNla *snla, ARegion *ar) glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_BLEND); - // TODO: if tweaking some action, use the same color as for the tweaked track (quick hack done for now) - if (adt && (adt->flag & ADT_NLA_EDIT_ON)) { - // greenish color (same as tweaking strip) - hardcoded for now - glColor4f(0.3f, 0.95f, 0.1f, 0.3f); - } - else { - if (ale->data) - glColor4f(0.8f, 0.2f, 0.0f, 0.4f); // reddish color - hardcoded for now - else - glColor4f(0.6f, 0.5f, 0.5f, 0.3f); // greyish-red color - hardcoded for now - } - + /* get colors for drawing */ + nla_action_get_color(adt, ale->data, color); + glColor4fv(color); + /* draw slightly shifted up for greater separation from standard channels, * but also slightly shorter for some more contrast when viewing the strips */ - glBegin(GL_QUADS); - glVertex2f(v2d->cur.xmin, yminc+NLACHANNEL_SKIP); - glVertex2f(v2d->cur.xmin, ymaxc-NLACHANNEL_SKIP); - glVertex2f(v2d->cur.xmax, ymaxc-NLACHANNEL_SKIP); - glVertex2f(v2d->cur.xmax, yminc+NLACHANNEL_SKIP); - glEnd(); + glRectf(v2d->cur.xmin, yminc+NLACHANNEL_SKIP, v2d->cur.xmax, ymaxc-NLACHANNEL_SKIP); /* draw keyframes in the action */ - nla_action_draw_keyframes(adt, v2d, y); + nla_action_draw_keyframes(adt, ale->data, v2d, y, yminc+NLACHANNEL_SKIP, ymaxc-NLACHANNEL_SKIP); /* draw 'embossed' lines above and below the strip for effect */ /* white base-lines */ diff --git a/source/blender/makesdna/DNA_anim_types.h b/source/blender/makesdna/DNA_anim_types.h index ac8d44a86e6..d71beb8785b 100644 --- a/source/blender/makesdna/DNA_anim_types.h +++ b/source/blender/makesdna/DNA_anim_types.h @@ -464,7 +464,7 @@ typedef struct NlaStrip { /* NLA Strip Blending Mode */ enum { - NLASTRIP_MODE_BLEND = 0, + NLASTRIP_MODE_REPLACE = 0, NLASTRIP_MODE_ADD, NLASTRIP_MODE_SUBTRACT, NLASTRIP_MODE_MULTIPLY, diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 219feaad09b..97f35af1db7 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -239,7 +239,7 @@ void rna_def_nlastrip(BlenderRNA *brna) {NLASTRIP_TYPE_META, "META", 0, "Meta", "NLA Strip acts as a container for adjacent strips."}, {0, NULL, 0, NULL, NULL}}; static EnumPropertyItem prop_mode_blend_items[] = { - {NLASTRIP_MODE_BLEND, "BLEND", 0, "Blend", "Results of strip and accumulated results are combined in ratio governed by influence."}, + {NLASTRIP_MODE_REPLACE, "REPLACE", 0, "Replace", "Result strip replaces the accumulated results by amount specified by influence."}, {NLASTRIP_MODE_ADD, "ADD", 0, "Add", "Weighted result of strip is added to the accumlated results."}, {NLASTRIP_MODE_SUBTRACT, "SUBTRACT", 0, "Subtract", "Weighted result of strip is removed from the accumlated results."}, {NLASTRIP_MODE_MULTIPLY, "MULITPLY", 0, "Multiply", "Weighted result of strip is multiplied with the accumlated results."}, |