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:
-rw-r--r--source/blender/editors/animation/keyframes_draw.c288
-rw-r--r--source/blender/editors/armature/poselib.c2
-rw-r--r--source/blender/editors/include/ED_keyframes_draw.h38
-rw-r--r--source/blender/editors/space_action/action_draw.c96
-rw-r--r--source/blender/editors/space_action/action_select.c66
-rw-r--r--source/blender/editors/space_nla/nla_draw.c2
-rw-r--r--source/blender/editors/space_view3d/drawarmature.c9
7 files changed, 197 insertions, 304 deletions
diff --git a/source/blender/editors/animation/keyframes_draw.c b/source/blender/editors/animation/keyframes_draw.c
index 56b1c63db74..f122e045776 100644
--- a/source/blender/editors/animation/keyframes_draw.c
+++ b/source/blender/editors/animation/keyframes_draw.c
@@ -51,7 +51,6 @@
#include "DNA_armature_types.h"
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
-#include "DNA_ipo_types.h"
#include "DNA_object_types.h"
#include "DNA_screen_types.h"
#include "DNA_scene_types.h"
@@ -64,6 +63,7 @@
#include "DNA_gpencil_types.h"
#include "DNA_windowmanager_types.h"
#include "DNA_world_types.h"
+#include "DNA_view2d_types.h"
#include "BKE_action.h"
#include "BKE_depsgraph.h"
@@ -234,45 +234,82 @@ static ActKeyColumn *cfra_find_actkeycolumn (ListBase *keys, float cframe)
return NULL;
}
-#if 0 // disabled, as some intel cards have problems with this
-/* Draw a simple diamond shape with a filled in center (in screen space) */
-static void draw_key_but(int x, int y, short w, short h, int sel)
+/* coordinates for diamond shape */
+static const float _unit_diamond_shape[4][2] = {
+ {0.0f, 1.0f}, /* top vert */
+ {1.0f, 0.0f}, /* mid-right */
+ {0.0f, -1.0f}, /* bottom vert */
+ {-1.0f, 0.0f} /* mid-left */
+};
+
+/* draw a simple diamond shape with OpenGL */
+static void draw_keyframe_shape (float x, float y, float xscale, float hsize, short sel)
{
- int xmin= x, ymin= y;
- int xmax= x+w-1, ymax= y+h-1;
- int xc= (xmin+xmax)/2, yc= (ymin+ymax)/2;
+ static GLuint displist1=0;
+ static GLuint displist2=0;
- /* interior - hardcoded colors (for selected and unselected only) */
- if (sel) glColor3ub(0xF1, 0xCA, 0x13);
- else glColor3ub(0xE9, 0xE9, 0xE9);
+ /* initialise 2 display lists for diamond shape - one empty, one filled */
+ if (displist1 == 0) {
+ displist1= glGenLists(1);
+ glNewList(displist1, GL_COMPILE);
+
+ glBegin(GL_LINE_LOOP);
+ glVertex2fv(_unit_diamond_shape[0]);
+ glVertex2fv(_unit_diamond_shape[1]);
+ glVertex2fv(_unit_diamond_shape[2]);
+ glVertex2fv(_unit_diamond_shape[3]);
+ glEnd();
+ glEndList();
+ }
+ if (displist2 == 0) {
+ displist2= glGenLists(1);
+ glNewList(displist2, GL_COMPILE);
+
+ glBegin(GL_QUADS);
+ glVertex2fv(_unit_diamond_shape[0]);
+ glVertex2fv(_unit_diamond_shape[1]);
+ glVertex2fv(_unit_diamond_shape[2]);
+ glVertex2fv(_unit_diamond_shape[3]);
+ glEnd();
+ glEndList();
+ }
+
+ /* 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);
- glBegin(GL_QUADS);
- glVertex2i(xc, ymin);
- glVertex2i(xmax, yc);
- glVertex2i(xc, ymax);
- glVertex2i(xmin, yc);
- glEnd();
+ /* 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);
- /* outline */
+ /* exterior - black frame */
glColor3ub(0, 0, 0);
+ glCallList(displist1);
+
+ glDisable(GL_LINE_SMOOTH);
- glBegin(GL_LINE_LOOP);
- glVertex2i(xc, ymin);
- glVertex2i(xmax, yc);
- glVertex2i(xc, ymax);
- glVertex2i(xmin, yc);
- glEnd();
+ /* restore view transform */
+ glScalef(xscale/hsize, 1.0f/hsize, 1.0);
+ glTranslatef(-x, -y, 0.0f);
}
-#endif
-static void draw_keylist(gla2DDrawInfo *di, ListBase *keys, ListBase *blocks, float ypos)
+static void draw_keylist(View2D *v2d, ListBase *keys, ListBase *blocks, float ypos)
{
ActKeyColumn *ak;
ActKeyBlock *ab;
+ float xscale;
glEnable(GL_BLEND);
+ /* get View2D scaling factor */
+ UI_view2d_getscale(v2d, &xscale, NULL);
+
/* draw keyblocks */
if (blocks) {
for (ab= blocks->first; ab; ab= ab->next) {
@@ -292,18 +329,13 @@ static void draw_keylist(gla2DDrawInfo *di, ListBase *keys, ListBase *blocks, fl
totCurves = (startCurves>endCurves)? endCurves: startCurves;
if (ab->totcurve >= totCurves) {
- int sc_xa, sc_xb, sc_ya, sc_yb;
-
- /* get co-ordinates of block */
- gla2DDrawTranslatePt(di, ab->start, ypos, &sc_xa, &sc_ya);
- gla2DDrawTranslatePt(di, ab->end, ypos, &sc_xb, &sc_yb);
-
/* draw block */
if (ab->sel)
UI_ThemeColor4(TH_STRIP_SELECT);
else
UI_ThemeColor4(TH_STRIP);
- glRectf((float)sc_xa, (float)sc_ya-3, (float)sc_xb, (float)sc_yb+5);
+
+ glRectf(ab->start, ypos-5, ab->end, ypos+5);
}
}
}
@@ -311,18 +343,28 @@ static void draw_keylist(gla2DDrawInfo *di, ListBase *keys, ListBase *blocks, fl
/* draw keys */
if (keys) {
for (ak= keys->first; ak; ak= ak->next) {
- int sc_x, sc_y;
+ /* 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));
+
+#if 0 // OLD CODE
+ //int sc_x, sc_y;
/* get co-ordinate to draw at */
- gla2DDrawTranslatePt(di, ak->cfra, ypos, &sc_x, &sc_y);
+ //gla2DDrawTranslatePt(di, ak->cfra, ypos, &sc_x, &sc_y);
/* draw using icons - old way which is slower but more proven */
- if (ak->sel & SELECT) UI_icon_draw_aspect((float)sc_x-7, (float)sc_y-6, ICON_SPACE2, 1.0f);
- else UI_icon_draw_aspect((float)sc_x-7, (float)sc_y-6, ICON_SPACE3, 1.0f);
+ //if (ak->sel & SELECT) UI_icon_draw_aspect((float)sc_x-7, (float)sc_y-6, ICON_SPACE2, 1.0f);
+ //else UI_icon_draw_aspect((float)sc_x-7, (float)sc_y-6, ICON_SPACE3, 1.0f);
+#endif // OLD CODE
+#if 0 // NEW NON-WORKING CODE
+ /* draw icon */
+ // FIXME: this draws slightly wrong, as we need to apply some offset for icon, but that depends on scaling
+ // so for now disabled
+ //int icon = (ak->sel & SELECT) ? ICON_SPACE2 : ICON_SPACE3;
+ //UI_icon_draw_aspect(ak->cfra, ypos-6, icon, 1.0f);
+#endif // NEW NON-WORKING CODE
- /* draw using OpenGL - slightly uglier but faster */
- // NOTE: disabled for now, as some intel cards seem to have problems with this
- //draw_key_but(sc_x-5, sc_y-4, 11, 11, (ak->sel & SELECT));
}
}
@@ -331,81 +373,80 @@ static void draw_keylist(gla2DDrawInfo *di, ListBase *keys, ListBase *blocks, fl
/* *************************** Channel Drawing Funcs *************************** */
-void draw_scene_channel(gla2DDrawInfo *di, ActKeysInc *aki, Scene *sce, float ypos)
+void draw_scene_channel(View2D *v2d, bDopeSheet *ads, Scene *sce, float ypos)
{
ListBase keys = {0, 0};
ListBase blocks = {0, 0};
- scene_to_keylist(sce, &keys, &blocks, aki);
- draw_keylist(di, &keys, &blocks, ypos);
+ scene_to_keylist(ads, sce, &keys, &blocks);
+ draw_keylist(v2d, &keys, &blocks, ypos);
BLI_freelistN(&keys);
BLI_freelistN(&blocks);
}
-void draw_object_channel(gla2DDrawInfo *di, ActKeysInc *aki, Object *ob, float ypos)
+void draw_object_channel(View2D *v2d, bDopeSheet *ads, Object *ob, float ypos)
{
ListBase keys = {0, 0};
ListBase blocks = {0, 0};
- ob_to_keylist(ob, &keys, &blocks, aki);
- draw_keylist(di, &keys, &blocks, ypos);
+ ob_to_keylist(ads, ob, &keys, &blocks);
+ draw_keylist(v2d, &keys, &blocks, ypos);
BLI_freelistN(&keys);
BLI_freelistN(&blocks);
}
-void draw_fcurve_channel(gla2DDrawInfo *di, ActKeysInc *aki, FCurve *fcu, float ypos)
+void draw_fcurve_channel(View2D *v2d, AnimData *adt, FCurve *fcu, float ypos)
{
ListBase keys = {0, 0};
ListBase blocks = {0, 0};
- fcurve_to_keylist(fcu, &keys, &blocks, aki);
- draw_keylist(di, &keys, &blocks, ypos);
+ fcurve_to_keylist(adt, fcu, &keys, &blocks);
+ draw_keylist(v2d, &keys, &blocks, ypos);
BLI_freelistN(&keys);
BLI_freelistN(&blocks);
}
-void draw_agroup_channel(gla2DDrawInfo *di, ActKeysInc *aki, bActionGroup *agrp, float ypos)
+void draw_agroup_channel(View2D *v2d, AnimData *adt, bActionGroup *agrp, float ypos)
{
ListBase keys = {0, 0};
ListBase blocks = {0, 0};
- agroup_to_keylist(agrp, &keys, &blocks, aki);
- draw_keylist(di, &keys, &blocks, ypos);
+ agroup_to_keylist(adt, agrp, &keys, &blocks);
+ draw_keylist(v2d, &keys, &blocks, ypos);
BLI_freelistN(&keys);
BLI_freelistN(&blocks);
}
-void draw_action_channel(gla2DDrawInfo *di, ActKeysInc *aki, bAction *act, float ypos)
+void draw_action_channel(View2D *v2d, AnimData *adt, bAction *act, float ypos)
{
ListBase keys = {0, 0};
ListBase blocks = {0, 0};
- action_to_keylist(act, &keys, &blocks, aki);
- draw_keylist(di, &keys, &blocks, ypos);
+ action_to_keylist(adt, act, &keys, &blocks);
+ draw_keylist(v2d, &keys, &blocks, ypos);
BLI_freelistN(&keys);
BLI_freelistN(&blocks);
}
-void draw_gpl_channel(gla2DDrawInfo *di, ActKeysInc *aki, bGPDlayer *gpl, float ypos)
+void draw_gpl_channel(View2D *v2d, bDopeSheet *ads, bGPDlayer *gpl, float ypos)
{
ListBase keys = {0, 0};
- gpl_to_keylist(gpl, &keys, NULL, aki);
- draw_keylist(di, &keys, NULL, ypos);
+ gpl_to_keylist(ads, gpl, &keys, NULL);
+ draw_keylist(v2d, &keys, NULL, ypos);
BLI_freelistN(&keys);
}
/* *************************** Keyframe List Conversions *************************** */
-void scene_to_keylist(Scene *sce, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
+void scene_to_keylist(bDopeSheet *ads, Scene *sce, ListBase *keys, ListBase *blocks)
{
if (sce) {
- bDopeSheet *ads= (aki)? (aki->ads) : NULL;
AnimData *adt;
int filterflag;
@@ -421,7 +462,7 @@ void scene_to_keylist(Scene *sce, ListBase *keys, ListBase *blocks, ActKeysInc *
// TODO: when we adapt NLA system, this needs to be the NLA-scaled version
if (adt->action)
- action_to_keylist(adt->action, keys, blocks, aki);
+ action_to_keylist(adt, adt->action, keys, blocks);
}
/* world animdata */
@@ -430,17 +471,16 @@ void scene_to_keylist(Scene *sce, ListBase *keys, ListBase *blocks, ActKeysInc *
// TODO: when we adapt NLA system, this needs to be the NLA-scaled version
if (adt->action)
- action_to_keylist(adt->action, keys, blocks, aki);
+ action_to_keylist(adt, adt->action, keys, blocks);
}
}
}
-void ob_to_keylist(Object *ob, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
+void ob_to_keylist(bDopeSheet *ads, Object *ob, ListBase *keys, ListBase *blocks)
{
Key *key= ob_get_key(ob);
if (ob) {
- bDopeSheet *ads= (aki)? (aki->ads) : NULL;
int filterflag;
/* get filterflag */
@@ -451,79 +491,18 @@ void ob_to_keylist(Object *ob, ListBase *keys, ListBase *blocks, ActKeysInc *aki
/* Add action keyframes */
if (ob->adt && ob->adt->action)
- action_nlascaled_to_keylist(ob->adt, ob->adt->action, keys, blocks, aki);
+ action_to_keylist(ob->adt, ob->adt->action, keys, blocks);
/* Add shapekey keyframes (only if dopesheet allows, if it is available) */
- // TODO: when we adapt NLA system, this needs to be the NLA-scaled version
if ((key && key->adt && key->adt->action) && !(filterflag & ADS_FILTER_NOSHAPEKEYS))
- action_to_keylist(key->adt->action, keys, blocks, aki);
+ action_to_keylist(key->adt, key->adt->action, keys, blocks);
-#if 0 // XXX old animation system
- /* Add material keyframes (only if dopesheet allows, if it is available) */
- if ((ob->totcol) && !(filterflag & ADS_FILTER_NOMAT)) {
- short a;
-
- for (a=0; a<ob->totcol; a++) {
- Material *ma= give_current_material(ob, a);
-
- if (ELEM(NULL, ma, ma->ipo) == 0)
- ipo_to_keylist(ma->ipo, keys, blocks, aki);
- }
- }
-
- /* Add object data keyframes */
- switch (ob->type) {
- case OB_CAMERA: /* ------- Camera ------------ */
- {
- Camera *ca= (Camera *)ob->data;
- if ((ca->ipo) && !(filterflag & ADS_FILTER_NOCAM))
- ipo_to_keylist(ca->ipo, keys, blocks, aki);
- }
- break;
- case OB_LAMP: /* ---------- Lamp ----------- */
- {
- Lamp *la= (Lamp *)ob->data;
- if ((la->ipo) && !(filterflag & ADS_FILTER_NOLAM))
- ipo_to_keylist(la->ipo, keys, blocks, aki);
- }
- break;
- case OB_CURVE: /* ------- Curve ---------- */
- {
- Curve *cu= (Curve *)ob->data;
- if ((cu->ipo) && !(filterflag & ADS_FILTER_NOCUR))
- ipo_to_keylist(cu->ipo, keys, blocks, aki);
- }
- break;
- }
-#endif // XXX old animation system
+ // TODO: restore materials, and object data, etc.
}
}
-static short bezt_in_aki_range (ActKeysInc *aki, BezTriple *bezt)
-{
- /* when aki == NULL, we don't care about range */
- if (aki == NULL)
- return 1;
-
- /* if start and end are both 0, then don't care about range */
- if (IS_EQ(aki->start, 0) && IS_EQ(aki->end, 0))
- return 1;
-
- /* if nla-scaling is in effect, apply appropriate scaling adjustments */
-#if 0 // XXX this was from some buggy code... do not port for now
- if (aki->ob) {
- float frame= get_action_frame_inv(aki->ob, bezt->vec[1][0]);
- return IN_RANGE(frame, aki->start, aki->end);
- }
- else {
- /* check if in range */
- return IN_RANGE(bezt->vec[1][0], aki->start, aki->end);
- }
-#endif // XXX this was from some buggy code... do not port for now
- return 1;
-}
-void fcurve_to_keylist(FCurve *fcu, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
+void fcurve_to_keylist(AnimData *adt, FCurve *fcu, ListBase *keys, ListBase *blocks)
{
BezTriple *bezt;
ActKeyColumn *ak, *ak2;
@@ -531,15 +510,17 @@ void fcurve_to_keylist(FCurve *fcu, ListBase *keys, ListBase *blocks, ActKeysInc
int v;
if (fcu && fcu->totvert && fcu->bezt) {
+ /* apply NLA-mapping (if applicable) */
+ if (adt)
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
+
/* loop through beztriples, making ActKeys and ActKeyBlocks */
bezt= fcu->bezt;
for (v=0; v < fcu->totvert; v++, bezt++) {
/* only if keyframe is in range (optimisation) */
- if (bezt_in_aki_range(aki, bezt)) {
- add_bezt_to_keycolumnslist(keys, bezt);
- if (blocks) add_bezt_to_keyblockslist(blocks, fcu, v);
- }
+ add_bezt_to_keycolumnslist(keys, bezt);
+ if (blocks) add_bezt_to_keyblockslist(blocks, fcu, v);
}
/* update the number of curves that elements have appeared in */
@@ -575,65 +556,38 @@ void fcurve_to_keylist(FCurve *fcu, ListBase *keys, ListBase *blocks, ActKeysInc
}
}
}
+
+ /* unapply NLA-mapping if applicable */
+ ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
}
}
-void agroup_to_keylist(bActionGroup *agrp, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
+void agroup_to_keylist(AnimData *adt, bActionGroup *agrp, ListBase *keys, ListBase *blocks)
{
FCurve *fcu;
if (agrp) {
/* loop through F-Curves */
for (fcu= agrp->channels.first; fcu && fcu->grp==agrp; fcu= fcu->next) {
- fcurve_to_keylist(fcu, keys, blocks, aki);
+ fcurve_to_keylist(adt, fcu, keys, blocks);
}
}
}
-void action_to_keylist(bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
+void action_to_keylist(AnimData *adt, bAction *act, ListBase *keys, ListBase *blocks)
{
FCurve *fcu;
if (act) {
/* loop through F-Curves */
for (fcu= act->curves.first; fcu; fcu= fcu->next) {
- fcurve_to_keylist(fcu, keys, blocks, aki);
+ fcurve_to_keylist(adt, fcu, keys, blocks);
}
}
}
-void action_nlascaled_to_keylist(AnimData *adt, bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
-{
- FCurve *fcu;
- AnimData *oldadt= NULL;
-
- /* although apply and clearing NLA-mapping pre-post creating keylist does impact on performance,
- * the effects should be fairly minimal, as we're already going through the keyframes multiple times
- * already for blocks too...
- */
- if (act) {
- /* if 'aki' is provided, store it's current ob to restore later as it might not be the same */
- if (aki) {
- oldadt= aki->adt;
- aki->adt= adt;
- }
-
- /* loop through F-Curves
- * - scaling correction only does times for center-points, so should be faster
- */
- for (fcu= act->curves.first; fcu; fcu= fcu->next) {
- ANIM_nla_mapping_apply_fcurve(adt, fcu, 0, 1);
- fcurve_to_keylist(fcu, keys, blocks, aki);
- ANIM_nla_mapping_apply_fcurve(adt, fcu, 1, 1);
- }
-
- /* if 'aki' is provided, restore ob */
- if (aki)
- aki->adt= oldadt;
- }
-}
-void gpl_to_keylist(bGPDlayer *gpl, ListBase *keys, ListBase *blocks, ActKeysInc *aki)
+void gpl_to_keylist(bDopeSheet *ads, bGPDlayer *gpl, ListBase *keys, ListBase *blocks)
{
bGPDframe *gpf;
ActKeyColumn *ak;
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index 8cbfebebff6..fcc1e8f9644 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -227,7 +227,7 @@ void poselib_validate_act (bAction *act)
}
/* determine which frames have keys */
- action_to_keylist(act, &keys, NULL, NULL);
+ action_to_keylist(NULL, act, &keys, NULL);
/* for each key, make sure there is a correspnding pose */
for (ak= keys.first; ak; ak= ak->next) {
diff --git a/source/blender/editors/include/ED_keyframes_draw.h b/source/blender/editors/include/ED_keyframes_draw.h
index d2269300d24..22ee7a42121 100644
--- a/source/blender/editors/include/ED_keyframes_draw.h
+++ b/source/blender/editors/include/ED_keyframes_draw.h
@@ -33,13 +33,14 @@
struct AnimData;
struct BezTriple;
struct FCurve;
-struct gla2DDrawInfo;
+struct bDopeSheet;
struct bAction;
struct bActionGroup;
struct Object;
struct ListBase;
struct bGPDlayer;
struct Scene;
+struct View2D;
/* ****************************** Base Structs ****************************** */
@@ -66,34 +67,23 @@ typedef struct ActKeyBlock {
short totcurve;
} ActKeyBlock;
-
-/* Inclusion-Range Limiting Struct (optional) */
-typedef struct ActKeysInc {
- struct bDopeSheet *ads; /* dopesheet data (for dopesheet mode) */
- struct AnimData *adt; /* owner for NLA-mapping info */
- short actmode; /* mode of the Action Editor (-1 is for NLA) */
-
- float start, end; /* frames (global-time) to only consider keys between */ // XXX not used anymore!
-} ActKeysInc;
-
/* ******************************* Methods ****************************** */
/* Channel Drawing */
-void draw_fcurve_channel(struct gla2DDrawInfo *di, ActKeysInc *aki, struct FCurve *fcu, float ypos);
-void draw_agroup_channel(struct gla2DDrawInfo *di, ActKeysInc *aki, struct bActionGroup *agrp, float ypos);
-void draw_action_channel(struct gla2DDrawInfo *di, ActKeysInc *aki, struct bAction *act, float ypos);
-void draw_object_channel(struct gla2DDrawInfo *di, ActKeysInc *aki, struct Object *ob, float ypos);
-void draw_scene_channel(struct gla2DDrawInfo *di, ActKeysInc *aki, struct Scene *sce, float ypos);
-void draw_gpl_channel(struct gla2DDrawInfo *di, ActKeysInc *aki, struct bGPDlayer *gpl, float ypos);
+void draw_fcurve_channel(struct View2D *v2d, struct AnimData *adt, struct FCurve *fcu, float ypos);
+void draw_agroup_channel(struct View2D *v2d, struct AnimData *adt, struct bActionGroup *agrp, float ypos);
+void draw_action_channel(struct View2D *v2d, struct AnimData *adt, struct bAction *act, float ypos);
+void draw_object_channel(struct View2D *v2d, struct bDopeSheet *ads, struct Object *ob, float ypos);
+void draw_scene_channel(struct View2D *v2d, struct bDopeSheet *ads, struct Scene *sce, float ypos);
+void draw_gpl_channel(struct View2D *v2d, struct bDopeSheet *ads, struct bGPDlayer *gpl, float ypos);
/* Keydata Generation */
-void fcurve_to_keylist(struct FCurve *fcu, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
-void agroup_to_keylist(struct bActionGroup *agrp, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
-void action_to_keylist(struct bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
-void action_nlascaled_to_keylist(struct AnimData *adt, struct bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
-void ob_to_keylist(struct Object *ob, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
-void scene_to_keylist(struct Scene *sce, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
-void gpl_to_keylist(struct bGPDlayer *gpl, ListBase *keys, ListBase *blocks, ActKeysInc *aki);
+void fcurve_to_keylist(struct AnimData *adt, struct FCurve *fcu, ListBase *keys, ListBase *blocks);
+void agroup_to_keylist(struct AnimData *adt, struct bActionGroup *agrp, ListBase *keys, ListBase *blocks);
+void action_to_keylist(struct AnimData *adt, struct bAction *act, ListBase *keys, ListBase *blocks);
+void ob_to_keylist(struct bDopeSheet *ads, struct Object *ob, ListBase *keys, ListBase *blocks);
+void scene_to_keylist(struct bDopeSheet *ads, struct Scene *sce, ListBase *keys, ListBase *blocks);
+void gpl_to_keylist(struct bDopeSheet *ads, struct bGPDlayer *gpl, ListBase *keys, ListBase *blocks);
#endif /* ED_KEYFRAMES_DRAW_H */
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 910b9733bc8..743cc1f128e 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -960,27 +960,8 @@ void draw_channel_names(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* ************************************************************************* */
/* Keyframes */
-ActKeysInc *init_aki_data(bAnimContext *ac, bAnimListElem *ale)
-{
- static ActKeysInc aki;
-
- /* no need to set settings if wrong context */
- if ((ac->data == NULL) || ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)==0)
- return NULL;
-
- /* if strip is mapped, store settings */
- aki.adt= ANIM_nla_mapping_get(ac, ale);
-
- if (ac->datatype == ANIMCONT_DOPESHEET)
- aki.ads= (bDopeSheet *)ac->data;
- else
- aki.ads= NULL;
- aki.actmode= ac->datatype;
-
- /* always return pointer... */
- return &aki;
-}
-
+/* extra padding for lengths (to go under scrollers) */
+#define EXTRA_SCROLL_PAD 100.0f
/* draw keyframes in each channel */
void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
@@ -990,13 +971,11 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
int filter;
View2D *v2d= &ar->v2d;
+ bDopeSheet *ads= &saction->ads;
AnimData *adt= NULL;
- gla2DDrawInfo *di;
- rcti scr_rct;
- int act_start, act_end, dummy;
+ float act_start, act_end, y;
int height, items;
- float y, sta, end;
char col1[3], col2[3];
char col1a[3], col2a[3];
@@ -1006,6 +985,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* get theme colors */
UI_GetThemeColor3ubv(TH_BACK, col2);
UI_GetThemeColor3ubv(TH_HILITE, col1);
+
UI_GetThemeColor3ubv(TH_GROUP, col2a);
UI_GetThemeColor3ubv(TH_GROUP_ACTIVE, col1a);
@@ -1013,26 +993,14 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
UI_GetThemeColor3ubv(TH_DOPESHEET_CHANNELSUBOB, col2b);
/* set view-mapping rect (only used for x-axis), for NLA-scaling mapping with less calculation */
- scr_rct.xmin= ar->winrct.xmin + ar->v2d.mask.xmin;
- scr_rct.ymin= ar->winrct.ymin + ar->v2d.mask.ymin;
- scr_rct.xmax= ar->winrct.xmin + ar->v2d.hor.xmax;
- scr_rct.ymax= ar->winrct.ymin + ar->v2d.mask.ymax;
- di= glaBegin2DDraw(&scr_rct, &v2d->cur);
/* if in NLA there's a strip active, map the view */
if (ac->datatype == ANIMCONT_ACTION) {
adt= ANIM_nla_mapping_get(ac, NULL);
- if (adt)
- ANIM_nla_mapping_draw(di, adt, 0);
-
/* start and end of action itself */
- calc_action_range(ac->data, &sta, &end, 0);
- gla2DDrawTranslatePt(di, sta, 0.0f, &act_start, &dummy);
- gla2DDrawTranslatePt(di, end, 0.0f, &act_end, &dummy);
-
- if (adt)
- ANIM_nla_mapping_draw(di, adt, 1);
+ // TODO: this has not had scaling applied
+ calc_action_range(ac->data, &act_start, &act_end, 0);
}
/* build list of channels to draw */
@@ -1063,7 +1031,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
if ( IN_RANGE(yminc, v2d->cur.ymin, v2d->cur.ymax) ||
IN_RANGE(ymaxc, v2d->cur.ymin, v2d->cur.ymax) )
{
- int frame1_x, channel_y, sel=0;
+ int sel=0;
/* determine if any need to draw channel */
if (ale->datatype != ALE_NONE) {
@@ -1102,8 +1070,6 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
}
if (ELEM(ac->datatype, ANIMCONT_ACTION, ANIMCONT_DOPESHEET)) {
- gla2DDrawTranslatePt(di, v2d->cur.xmin, y, &frame1_x, &channel_y);
-
switch (ale->type) {
case ANIMTYPE_SCENE:
case ANIMTYPE_OBJECT:
@@ -1139,36 +1105,32 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
}
/* draw region twice: firstly backdrop, then the current range */
- glRectf((float)frame1_x, (float)channel_y-ACHANNEL_HEIGHT_HALF, (float)v2d->hor.xmax, (float)channel_y+ACHANNEL_HEIGHT_HALF);
+ glRectf(v2d->cur.xmin, (float)y-ACHANNEL_HEIGHT_HALF, v2d->cur.xmax+EXTRA_SCROLL_PAD, (float)y+ACHANNEL_HEIGHT_HALF);
if (ac->datatype == ANIMCONT_ACTION)
- glRectf((float)act_start, (float)channel_y-ACHANNEL_HEIGHT_HALF, (float)act_end, (float)channel_y+ACHANNEL_HEIGHT_HALF);
+ glRectf(act_start, (float)y-ACHANNEL_HEIGHT_HALF, act_end, (float)y+ACHANNEL_HEIGHT_HALF);
}
else if (ac->datatype == ANIMCONT_SHAPEKEY) {
- gla2DDrawTranslatePt(di, 1, y, &frame1_x, &channel_y);
-
/* all frames that have a frame number less than one
* get a desaturated orange background
*/
glColor4ub(col2[0], col2[1], col2[2], 0x22);
- glRectf(0.0f, (float)channel_y-ACHANNEL_HEIGHT_HALF, (float)frame1_x, (float)channel_y+ACHANNEL_HEIGHT_HALF);
+ glRectf(0.0f, (float)y-ACHANNEL_HEIGHT_HALF, 1.0f, (float)y+ACHANNEL_HEIGHT_HALF);
/* frames one and higher get a saturated orange background */
glColor4ub(col2[0], col2[1], col2[2], 0x44);
- glRectf((float)frame1_x, (float)channel_y-ACHANNEL_HEIGHT_HALF, (float)v2d->hor.xmax, (float)channel_y+ACHANNEL_HEIGHT_HALF);
+ glRectf(1.0f, (float)y-ACHANNEL_HEIGHT_HALF, v2d->cur.xmax+EXTRA_SCROLL_PAD, (float)y+ACHANNEL_HEIGHT_HALF);
}
else if (ac->datatype == ANIMCONT_GPENCIL) {
- gla2DDrawTranslatePt(di, v2d->cur.xmin, y, &frame1_x, &channel_y);
-
/* frames less than one get less saturated background */
if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x22);
else glColor4ub(col2[0], col2[1], col2[2], 0x22);
- glRectf(0.0f, (float)channel_y-ACHANNEL_HEIGHT_HALF, (float)frame1_x, (float)channel_y+ACHANNEL_HEIGHT_HALF);
+ glRectf(0.0f, (float)y-ACHANNEL_HEIGHT_HALF, v2d->cur.xmin, (float)y+ACHANNEL_HEIGHT_HALF);
/* frames one and higher get a saturated background */
if (sel) glColor4ub(col1[0], col1[1], col1[2], 0x44);
else glColor4ub(col2[0], col2[1], col2[2], 0x44);
- glRectf((float)frame1_x, (float)channel_y-ACHANNEL_HEIGHT_HALF, (float)v2d->hor.xmax, (float)channel_y+ACHANNEL_HEIGHT_HALF);
+ glRectf(v2d->cur.xmin, (float)y-ACHANNEL_HEIGHT_HALF, v2d->cur.xmax+EXTRA_SCROLL_PAD, (float)y+ACHANNEL_HEIGHT_HALF);
}
}
}
@@ -1195,36 +1157,29 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
{
/* check if anything to show for this channel */
if (ale->datatype != ALE_NONE) {
- ActKeysInc *aki= init_aki_data(ac, ale);
adt= ANIM_nla_mapping_get(ac, ale);
- if (adt)
- ANIM_nla_mapping_draw(di, adt, 0);
-
/* draw 'keyframes' for each specific datatype */
switch (ale->datatype) {
case ALE_SCE:
- draw_scene_channel(di, aki, ale->key_data, y);
+ draw_scene_channel(v2d, ads, ale->key_data, y);
break;
case ALE_OB:
- draw_object_channel(di, aki, ale->key_data, y);
+ draw_object_channel(v2d, ads, ale->key_data, y);
break;
case ALE_ACT:
- draw_action_channel(di, aki, ale->key_data, y);
+ draw_action_channel(v2d, adt, ale->key_data, y);
break;
case ALE_GROUP:
- draw_agroup_channel(di, aki, ale->data, y);
+ draw_agroup_channel(v2d, adt, ale->data, y);
break;
case ALE_FCURVE:
- draw_fcurve_channel(di, aki, ale->key_data, y);
+ draw_fcurve_channel(v2d, adt, ale->key_data, y);
break;
case ALE_GPFRAME:
- draw_gpl_channel(di, aki, ale->data, y);
+ draw_gpl_channel(v2d, ads, ale->data, y);
break;
}
-
- if (adt)
- ANIM_nla_mapping_draw(di, adt, 1);
}
}
@@ -1236,16 +1191,11 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* black line marking 'current frame' for Time-Slide transform mode */
if (saction->flag & SACTION_MOVING) {
- int frame1_x;
-
- gla2DDrawTranslatePt(di, saction->timeslide, 0, &frame1_x, &dummy);
- cpack(0x0);
+ glColor3f(0.0f, 0.0f, 0.0f);
glBegin(GL_LINES);
- glVertex2f((float)frame1_x, (float)v2d->mask.ymin - 100);
- glVertex2f((float)frame1_x, (float)v2d->mask.ymax);
+ glVertex2f(saction->timeslide, v2d->cur.ymin-EXTRA_SCROLL_PAD)
+ glVertex2f(saction->timeslide, v2d->cur.ymax);
glEnd();
}
-
- glaEnd2DDraw(di);
}
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 5b87c04b311..8f95f5ea52d 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -223,7 +223,8 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short
BeztEditFunc ok_cb, select_cb;
View2D *v2d= &ac->ar->v2d;
rctf rectf;
- float ymin=0, ymax=(float)(-ACHANNEL_HEIGHT);
+ //float ymin=0, ymax=(float)(-ACHANNEL_HEIGHT);
+ float ymin=0, ymax=(float)(-ACHANNEL_HEIGHT_HALF);
/* convert mouse coordinates to frame ranges and channel coordinates corrected for view pan/zoom */
UI_view2d_region_to_view(v2d, rect.xmin, rect.ymin+2, &rectf.xmin, &rectf.ymin);
@@ -743,12 +744,16 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode,
int filter;
View2D *v2d= &ac->ar->v2d;
+ bDopeSheet *ads = NULL;
int channel_index;
short found = 0;
float selx = 0.0f;
float x, y;
rctf rectf;
+ /* get dopesheet info */
+ if (ac->datatype == ANIMCONT_DOPESHEET)
+ ads= ac->data;
/* use View2D to determine the index of the channel (i.e a row in the list) where keyframe was */
UI_view2d_region_to_view(v2d, mval[0], mval[1], &x, &y);
@@ -773,46 +778,35 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode,
else {
/* found match - must return here... */
AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- ActKeysInc *aki= init_aki_data(ac, ale);
ActKeyColumn *ak;
- float xmin, xmax;
-
- /* apply NLA-scaling correction? */
- if (adt) {
- xmin= BKE_nla_tweakedit_remap(adt, rectf.xmin, NLATIME_CONVERT_UNMAP);
- xmax= BKE_nla_tweakedit_remap(adt, rectf.xmax, NLATIME_CONVERT_UNMAP);
- }
- else {
- xmin= rectf.xmin;
- xmax= rectf.xmax;
- }
/* make list of keyframes */
+ // TODO: it would be great if we didn't have to apply this to all the keyframes to do this...
if (ale->key_data) {
switch (ale->datatype) {
case ALE_OB:
{
Object *ob= (Object *)ale->key_data;
- ob_to_keylist(ob, &anim_keys, NULL, aki);
+ ob_to_keylist(ads, ob, &anim_keys, NULL);
}
break;
case ALE_ACT:
{
bAction *act= (bAction *)ale->key_data;
- action_to_keylist(act, &anim_keys, NULL, aki);
+ action_to_keylist(adt, act, &anim_keys, NULL);
}
break;
case ALE_FCURVE:
{
FCurve *fcu= (FCurve *)ale->key_data;
- fcurve_to_keylist(fcu, &anim_keys, NULL, aki);
+ fcurve_to_keylist(adt, fcu, &anim_keys, NULL);
}
break;
}
}
else if (ale->type == ANIMTYPE_GROUP) {
bActionGroup *agrp= (bActionGroup *)ale->data;
- agroup_to_keylist(agrp, &anim_keys, NULL, aki);
+ agroup_to_keylist(adt, agrp, &anim_keys, NULL);
}
else if (ale->type == ANIMTYPE_GPDATABLOCK) {
/* cleanup */
@@ -822,13 +816,17 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode,
}
else if (ale->type == ANIMTYPE_GPLAYER) {
bGPDlayer *gpl= (bGPDlayer *)ale->data;
- gpl_to_keylist(gpl, &anim_keys, NULL, aki);
+ gpl_to_keylist(ads, gpl, &anim_keys, NULL);
}
/* loop through keyframes, finding one that was clicked on */
for (ak= anim_keys.first; ak; ak= ak->next) {
- if (IN_RANGE(ak->cfra, xmin, xmax)) {
- selx= ak->cfra;
+ if (IN_RANGE(ak->cfra, rectf.xmin, rectf.xmax)) {
+ /* set the frame to use, and apply inverse-correction for NLA-mapping
+ * so that the frame will get selected by the selection functiosn without
+ * requiring to map each frame once again...
+ */
+ selx= BKE_nla_tweakedit_remap(adt, ak->cfra, NLATIME_CONVERT_UNMAP);
found= 1;
break;
}
@@ -884,19 +882,21 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode,
}
/* only select keyframes if we clicked on a valid channel and hit something */
- if (ale && found) {
- /* apply selection to keyframes */
- if (/*gpl*/0) {
- /* grease pencil */
- //select_gpencil_frame(gpl, (int)selx, selectmode);
- }
- else if (column) {
- /* select all keyframes in the same frame as the one we hit on the active channel */
- actkeys_mselect_column(ac, select_mode, selx);
- }
- else {
- /* select the nominated keyframe on the given frame */
- actkeys_mselect_single(ac, ale, select_mode, selx);
+ if (ale) {
+ if (found) {
+ /* apply selection to keyframes */
+ if (/*gpl*/0) {
+ /* grease pencil */
+ //select_gpencil_frame(gpl, (int)selx, selectmode);
+ }
+ else if (column) {
+ /* select all keyframes in the same frame as the one we hit on the active channel */
+ actkeys_mselect_column(ac, select_mode, selx);
+ }
+ else {
+ /* select the nominated keyframe on the given frame */
+ actkeys_mselect_single(ac, ale, select_mode, selx);
+ }
}
/* free this channel */
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 7b2b19c19f6..3385906979a 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -143,7 +143,7 @@ static void nla_action_draw_keyframes (AnimData *adt, View2D *v2d, float y)
glColor3f(0.0f, 0.0f, 0.0f);
/* get a list of the keyframes with NLA-scaling applied */
- action_nlascaled_to_keylist(adt, adt->action, &keys, NULL, NULL);
+ action_to_keylist(adt, adt->action, &keys, NULL);
/* get View2D scaling factor */
UI_view2d_getscale(v2d, &xscale, NULL);
diff --git a/source/blender/editors/space_view3d/drawarmature.c b/source/blender/editors/space_view3d/drawarmature.c
index 0827bcaa9ae..c0f71ae6124 100644
--- a/source/blender/editors/space_view3d/drawarmature.c
+++ b/source/blender/editors/space_view3d/drawarmature.c
@@ -2173,7 +2173,7 @@ static void draw_pose_paths(Scene *scene, View3D *v3d, RegionView3D *rv3d, Objec
if (adt) {
bActionGroup *agrp= action_groups_find_named(adt->action, pchan->name);
if (agrp)
- agroup_to_keylist(agrp, &keys, NULL, NULL);
+ agroup_to_keylist(adt, agrp, &keys, NULL);
}
/* Draw slightly-larger yellow dots at each keyframe */
@@ -2320,18 +2320,17 @@ static void draw_ghost_poses_keys(Scene *scene, View3D *v3d, RegionView3D *rv3d,
bArmature *arm= ob->data;
bPose *posen, *poseo;
ListBase keys= {NULL, NULL};
- ActKeysInc aki = {0, 0, 0};
ActKeyColumn *ak, *akn;
float start, end, range, colfac, i;
int cfrao, flago;
- aki.start= start = (float)arm->ghostsf;
- aki.end= end = (float)arm->ghostef;
+ start = (float)arm->ghostsf;
+ end = (float)arm->ghostef;
if (end <= start)
return;
/* get keyframes - then clip to only within range */
- action_to_keylist(act, &keys, NULL, &aki);
+ action_to_keylist(adt, act, &keys, NULL);
range= 0;
for (ak= keys.first; ak; ak= akn) {
akn= ak->next;