diff options
author | Joshua Leung <aligorith@gmail.com> | 2008-01-27 06:21:24 +0300 |
---|---|---|
committer | Joshua Leung <aligorith@gmail.com> | 2008-01-27 06:21:24 +0300 |
commit | 8c59520060009d08d50b79e2a37734e77fd6aebe (patch) | |
tree | e4989001053626ef8d267c0cc063b112b4147a78 /source/blender/src/drawaction.c | |
parent | 4213dac345f053cb5674143d719276e742bc69da (diff) |
== Action Editor Drawing - Optimisations (Part 2 out of ?) ==
Keyframes are now checked for whether they are visible or not before they are prepared for drawing. This should provide some improvements for large data-sets...
In general there don't appear to be any major issues, although in a few situations, long-keyframes may end up appearing/disappearing.
Diffstat (limited to 'source/blender/src/drawaction.c')
-rw-r--r-- | source/blender/src/drawaction.c | 70 |
1 files changed, 48 insertions, 22 deletions
diff --git a/source/blender/src/drawaction.c b/source/blender/src/drawaction.c index 3339385d565..87c9d886a6e 100644 --- a/source/blender/src/drawaction.c +++ b/source/blender/src/drawaction.c @@ -816,8 +816,7 @@ static void draw_channel_strips(void) /* Draw keyframes * 1) Only channels that are visible in the Action Editor get drawn/evaluated. * This is to try to optimise this for heavier data sets - * 2) Keyframes which are out of view horizontally could be disregarded (probably as - * option - 'drop-frames' or so). Todo... + * 2) Keyframes which are out of view horizontally are disregarded */ y = 0.0; for (ale= act_data.first; ale; ale= ale->next) { @@ -1241,12 +1240,15 @@ static void draw_keylist(gla2DDrawInfo *di, ListBase *keys, ListBase *blocks, fl glDisable(GL_BLEND); } +#define INIT_AKI_DATA {((G.saction && NLA_ACTION_SCALED)? OBACT : NULL), G.v2d->cur.xmin - 10, G.v2d->cur.xmax + 10} + void draw_object_channel(gla2DDrawInfo *di, Object *ob, float ypos) { ListBase keys = {0, 0}; ListBase blocks = {0, 0}; + ActKeysInc aki = INIT_AKI_DATA; - ob_to_keylist(ob, &keys, &blocks); + ob_to_keylist(ob, &keys, &blocks, &aki); draw_keylist(di, &keys, &blocks, ypos); BLI_freelistN(&keys); @@ -1257,8 +1259,9 @@ void draw_ipo_channel(gla2DDrawInfo *di, Ipo *ipo, float ypos) { ListBase keys = {0, 0}; ListBase blocks = {0, 0}; + ActKeysInc aki = INIT_AKI_DATA; - ipo_to_keylist(ipo, &keys, &blocks); + ipo_to_keylist(ipo, &keys, &blocks, &aki); draw_keylist(di, &keys, &blocks, ypos); BLI_freelistN(&keys); @@ -1269,8 +1272,9 @@ void draw_icu_channel(gla2DDrawInfo *di, IpoCurve *icu, float ypos) { ListBase keys = {0, 0}; ListBase blocks = {0, 0}; + ActKeysInc aki = INIT_AKI_DATA; - icu_to_keylist(icu, &keys, &blocks); + icu_to_keylist(icu, &keys, &blocks, &aki); draw_keylist(di, &keys, &blocks, ypos); BLI_freelistN(&keys); @@ -1281,8 +1285,9 @@ void draw_agroup_channel(gla2DDrawInfo *di, bActionGroup *agrp, float ypos) { ListBase keys = {0, 0}; ListBase blocks = {0, 0}; + ActKeysInc aki = INIT_AKI_DATA; - agroup_to_keylist(agrp, &keys, &blocks); + agroup_to_keylist(agrp, &keys, &blocks, &aki); draw_keylist(di, &keys, &blocks, ypos); BLI_freelistN(&keys); BLI_freelistN(&blocks); @@ -1291,27 +1296,28 @@ void draw_agroup_channel(gla2DDrawInfo *di, bActionGroup *agrp, float ypos) void draw_action_channel(gla2DDrawInfo *di, bAction *act, float ypos) { ListBase keys = {0, 0}; + ActKeysInc aki = INIT_AKI_DATA; - action_to_keylist(act, &keys, NULL); + action_to_keylist(act, &keys, NULL, &aki); draw_keylist(di, &keys, NULL, ypos); BLI_freelistN(&keys); } /* --------------- Conversion: data -> keyframe list ------------------ */ -void ob_to_keylist(Object *ob, ListBase *keys, ListBase *blocks) +void ob_to_keylist(Object *ob, ListBase *keys, ListBase *blocks, ActKeysInc *aki) { bConstraintChannel *conchan; if (ob) { /* Add object keyframes */ if (ob->ipo) - ipo_to_keylist(ob->ipo, keys, blocks); + ipo_to_keylist(ob->ipo, keys, blocks, aki); /* Add constraint keyframes */ - for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next){ + for (conchan=ob->constraintChannels.first; conchan; conchan=conchan->next) { if(conchan->ipo) - ipo_to_keylist(conchan->ipo, keys, blocks); + ipo_to_keylist(conchan->ipo, keys, blocks, aki); } /* Add object data keyframes */ @@ -1319,7 +1325,24 @@ void ob_to_keylist(Object *ob, ListBase *keys, ListBase *blocks) } } -void icu_to_keylist(IpoCurve *icu, ListBase *keys, ListBase *blocks) +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 nla-scaling is in effect, apply appropriate scaling adjustments */ + 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); + } +} + +void icu_to_keylist(IpoCurve *icu, ListBase *keys, ListBase *blocks, ActKeysInc *aki) { BezTriple *bezt; ActKeyColumn *ak; @@ -1331,8 +1354,11 @@ void icu_to_keylist(IpoCurve *icu, ListBase *keys, ListBase *blocks) bezt= icu->bezt; for (v=0; v<icu->totvert; v++, bezt++) { - add_bezt_to_keycolumnslist(keys, bezt); - if (blocks) add_bezt_to_keyblockslist(blocks, icu, v); + /* 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, icu, v); + } } /* update the number of curves that elements have appeared in */ @@ -1355,17 +1381,17 @@ void icu_to_keylist(IpoCurve *icu, ListBase *keys, ListBase *blocks) } } -void ipo_to_keylist(Ipo *ipo, ListBase *keys, ListBase *blocks) +void ipo_to_keylist(Ipo *ipo, ListBase *keys, ListBase *blocks, ActKeysInc *aki) { IpoCurve *icu; if (ipo) { for (icu= ipo->curve.first; icu; icu= icu->next) - icu_to_keylist(icu, keys, blocks); + icu_to_keylist(icu, keys, blocks, aki); } } -void agroup_to_keylist(bActionGroup *agrp, ListBase *keys, ListBase *blocks) +void agroup_to_keylist(bActionGroup *agrp, ListBase *keys, ListBase *blocks, ActKeysInc *aki) { bActionChannel *achan; bConstraintChannel *conchan; @@ -1375,18 +1401,18 @@ void agroup_to_keylist(bActionGroup *agrp, ListBase *keys, ListBase *blocks) for (achan= agrp->channels.first; achan && achan!=agrp->channels.last; achan= achan->next) { /* firstly, add keys from action channel's ipo block */ if (achan->ipo) - ipo_to_keylist(achan->ipo, keys, blocks); + ipo_to_keylist(achan->ipo, keys, blocks, aki); /* then, add keys from constraint channels */ for (conchan= achan->constraintChannels.first; conchan; conchan= conchan->next) { if (conchan->ipo) - ipo_to_keylist(conchan->ipo, keys, blocks); + ipo_to_keylist(conchan->ipo, keys, blocks, aki); } } } } -void action_to_keylist(bAction *act, ListBase *keys, ListBase *blocks) +void action_to_keylist(bAction *act, ListBase *keys, ListBase *blocks, ActKeysInc *aki) { bActionChannel *achan; bConstraintChannel *conchan; @@ -1396,12 +1422,12 @@ void action_to_keylist(bAction *act, ListBase *keys, ListBase *blocks) for (achan= act->chanbase.first; achan; achan= achan->next) { /* firstly, add keys from action channel's ipo block */ if (achan->ipo) - ipo_to_keylist(achan->ipo, keys, blocks); + ipo_to_keylist(achan->ipo, keys, blocks, aki); /* then, add keys from constraint channels */ for (conchan= achan->constraintChannels.first; conchan; conchan= conchan->next) { if (conchan->ipo) - ipo_to_keylist(conchan->ipo, keys, blocks); + ipo_to_keylist(conchan->ipo, keys, blocks, aki); } } } |