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-06-23 17:25:31 +0400
committerJoshua Leung <aligorith@gmail.com>2009-06-23 17:25:31 +0400
commitb4acd77526f32faab0c3d86436eef56096985c3d (patch)
tree9b0212ceb39f1299b5e49508ed40bffb1bbf5318 /source/blender/editors/space_action
parentaa267976b86f90423204e11a30eec4e0def0f296 (diff)
NLA SoC: Big Commit - Restored NLA-Mapping Corrections
In TweakMode, the keyframes of the Active Action are now shown (and can be edited) in NLA-mapped time, with appropriate corrections applied when editing. This works in the DopeSheet and Graph Editors :) To do this, got rid of the old wrappers/API-methods, replacing them with new-style ones. A few methods previously (in this branch) used only for evaluation are now used for this purpose too. As the same code is used for editing + evaluation, this should now be much better to work with. I've only done a few brief tests now, but I think I might've muddled the invert-flags on one or two cases which I'll need to check out tomorrow. So, beware that there may be some weird and critical bugs for the next few days here... Also, added proper license headers to new NLA files. TODO: - testing + bugfixing due to this commit - show range of keyframes in NLA Editor active-action line
Diffstat (limited to 'source/blender/editors/space_action')
-rw-r--r--source/blender/editors/space_action/action_draw.c24
-rw-r--r--source/blender/editors/space_action/action_edit.c48
-rw-r--r--source/blender/editors/space_action/action_select.c45
3 files changed, 64 insertions, 53 deletions
diff --git a/source/blender/editors/space_action/action_draw.c b/source/blender/editors/space_action/action_draw.c
index 6eae581aa40..61048598644 100644
--- a/source/blender/editors/space_action/action_draw.c
+++ b/source/blender/editors/space_action/action_draw.c
@@ -964,7 +964,7 @@ ActKeysInc *init_aki_data(bAnimContext *ac, bAnimListElem *ale)
return NULL;
/* if strip is mapped, store settings */
- aki.ob= ANIM_nla_mapping_get(ac, ale);
+ aki.adt= ANIM_nla_mapping_get(ac, ale);
if (ac->datatype == ANIMCONT_DOPESHEET)
aki.ads= (bDopeSheet *)ac->data;
@@ -985,7 +985,7 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
int filter;
View2D *v2d= &ar->v2d;
- Object *nob= NULL;
+ AnimData *adt= NULL;
gla2DDrawInfo *di;
rcti scr_rct;
@@ -1016,18 +1016,18 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
/* if in NLA there's a strip active, map the view */
if (ac->datatype == ANIMCONT_ACTION) {
- nob= ANIM_nla_mapping_get(ac, NULL);
+ adt= ANIM_nla_mapping_get(ac, NULL);
- if (nob)
- ANIM_nla_mapping_draw(di, nob, 0);
+ 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 (nob)
- ANIM_nla_mapping_draw(di, nob, 1);
+ if (adt)
+ ANIM_nla_mapping_draw(di, adt, 1);
}
/* build list of channels to draw */
@@ -1191,10 +1191,10 @@ 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);
- nob= ANIM_nla_mapping_get(ac, ale);
+ adt= ANIM_nla_mapping_get(ac, ale);
- if (nob)
- ANIM_nla_mapping_draw(di, nob, 0);
+ if (adt)
+ ANIM_nla_mapping_draw(di, adt, 0);
/* draw 'keyframes' for each specific datatype */
switch (ale->datatype) {
@@ -1218,8 +1218,8 @@ void draw_channel_strips(bAnimContext *ac, SpaceAction *saction, ARegion *ar)
break;
}
- if (nob)
- ANIM_nla_mapping_draw(di, nob, 1);
+ if (adt)
+ ANIM_nla_mapping_draw(di, adt, 1);
}
}
diff --git a/source/blender/editors/space_action/action_edit.c b/source/blender/editors/space_action/action_edit.c
index deaa6597bd2..272ef3222ce 100644
--- a/source/blender/editors/space_action/action_edit.c
+++ b/source/blender/editors/space_action/action_edit.c
@@ -67,6 +67,7 @@
#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_material.h"
+#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_context.h"
#include "BKE_report.h"
@@ -112,16 +113,16 @@ static void get_keyframe_extents (bAnimContext *ac, float *min, float *max)
if (anim_data.first) {
/* go through channels, finding max extents */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
float tmin, tmax;
/* get range and apply necessary scaling before */
calc_fcurve_range(fcu, &tmin, &tmax);
- if (nob) {
- tmin= get_action_frame_inv(nob, tmin);
- tmax= get_action_frame_inv(nob, tmax);
+ if (adt) {
+ tmin= BKE_nla_tweakedit_remap(adt, tmin, 1);
+ tmax= BKE_nla_tweakedit_remap(adt, tmax, 1);
}
/* try to set cur using these values, if they're more extreme than previously set values */
@@ -400,14 +401,14 @@ static void insert_action_keys(bAnimContext *ac, short mode)
/* insert keyframes */
for (ale= anim_data.first; ale; ale= ale->next) {
- //Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
/* adjust current frame for NLA-scaling */
- //if (nob)
- // cfra= get_action_frame(nob, CFRA);
- //else
- // cfra= (float)CFRA;
+ if (adt)
+ cfra= BKE_nla_tweakedit_remap(adt, (float)CFRA, 1);
+ else
+ cfra= (float)CFRA;
/* if there's an id */
if (ale->id)
@@ -1054,8 +1055,17 @@ static int actkeys_framejump_exec(bContext *C, wmOperator *op)
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVESONLY);
ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
- for (ale= anim_data.first; ale; ale= ale->next)
- ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL);
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ AnimData *adt= ANIM_nla_mapping_get(&ac, ale);
+
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
+ ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
+ }
+ else
+ ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, bezt_calc_average, NULL);
+ }
BLI_freelistN(&anim_data);
@@ -1125,12 +1135,12 @@ static void snap_action_keys(bAnimContext *ac, short mode)
/* snap keyframes */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
//else if (ale->type == ACTTYPE_GPLAYER)
// snap_gplayer_frames(ale->data, mode);
@@ -1241,12 +1251,12 @@ static void mirror_action_keys(bAnimContext *ac, short mode)
/* mirror keyframes */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
//else if (ale->type == ACTTYPE_GPLAYER)
// snap_gplayer_frames(ale->data, mode);
diff --git a/source/blender/editors/space_action/action_select.c b/source/blender/editors/space_action/action_select.c
index 4cb39712f84..3583d16fd8c 100644
--- a/source/blender/editors/space_action/action_select.c
+++ b/source/blender/editors/space_action/action_select.c
@@ -64,6 +64,7 @@
#include "BKE_fcurve.h"
#include "BKE_key.h"
#include "BKE_material.h"
+#include "BKE_nla.h"
#include "BKE_object.h"
#include "BKE_context.h"
#include "BKE_utildefines.h"
@@ -245,7 +246,7 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short
/* loop over data, doing border select */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* get new vertical minimum extent of channel */
ymin= ymax - ACHANNEL_STEP;
@@ -253,9 +254,9 @@ static void borderselect_action (bAnimContext *ac, rcti rect, short mode, short
/* set horizontal range (if applicable) */
if (ELEM(mode, ACTKEYS_BORDERSEL_FRAMERANGE, ACTKEYS_BORDERSEL_ALLKEYS)) {
/* if channel is mapped in NLA, apply correction */
- if (nob) {
- bed.f1= get_action_frame(nob, rectf.xmin);
- bed.f2= get_action_frame(nob, rectf.xmax);
+ if (adt) {
+ bed.f1= BKE_nla_tweakedit_remap(adt, rectf.xmin, 0);
+ bed.f2= BKE_nla_tweakedit_remap(adt, rectf.xmax, 0);
}
else {
bed.f1= rectf.xmin;
@@ -413,12 +414,12 @@ static void markers_selectkeys_between (bAnimContext *ac)
/* select keys in-between */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
else {
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
@@ -495,15 +496,15 @@ static void columnselect_action_keys (bAnimContext *ac, short mode)
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* loop over cfraelems (stored in the BeztEditData->list)
* - we need to do this here, as we can apply fewer NLA-mapping conversions
*/
for (ce= bed.list.first; ce; ce= ce->next) {
/* set frame for validation callback to refer to */
- if (nob)
- bed.f1= get_action_frame(nob, ce->cfra);
+ if (adt)
+ bed.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, 0);
else
bed.f1= ce->cfra;
@@ -658,12 +659,12 @@ static void actkeys_mselect_leftright (bAnimContext *ac, short leftright, short
/* select keys on the side where most data occurs */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
- if (nob) {
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 1);
+ if (adt) {
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
- ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 1);
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
//else if (ale->type == ANIMTYPE_GPLAYER)
// borderselect_gplayer_frames(ale->data, min, max, SELECT_ADD);
@@ -702,11 +703,11 @@ static void actkeys_mselect_column(bAnimContext *ac, short select_mode, float se
ANIM_animdata_filter(ac, &anim_data, filter, ac->data, ac->datatype);
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* set frame for validation callback to refer to */
- if (nob)
- bed.f1= get_action_frame(nob, selx);
+ if (adt)
+ bed.f1= BKE_nla_tweakedit_remap(adt, selx, 0);
else
bed.f1= selx;
@@ -771,15 +772,15 @@ static void mouse_action_keys (bAnimContext *ac, int mval[2], short select_mode,
}
else {
/* found match - must return here... */
- Object *nob= ANIM_nla_mapping_get(ac, ale);
+ 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 (nob) {
- xmin= get_action_frame(nob, rectf.xmin);
- xmax= get_action_frame(nob, rectf.xmax);
+ if (adt) {
+ xmin= BKE_nla_tweakedit_remap(adt, rectf.xmin, 0);
+ xmax= BKE_nla_tweakedit_remap(adt, rectf.xmax, 0);
}
else {
xmin= rectf.xmin;