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_graph
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_graph')
-rw-r--r--source/blender/editors/space_graph/graph_draw.c10
-rw-r--r--source/blender/editors/space_graph/graph_edit.c51
-rw-r--r--source/blender/editors/space_graph/graph_select.c46
3 files changed, 68 insertions, 39 deletions
diff --git a/source/blender/editors/space_graph/graph_draw.c b/source/blender/editors/space_graph/graph_draw.c
index acf712d0147..d9e12afc947 100644
--- a/source/blender/editors/space_graph/graph_draw.c
+++ b/source/blender/editors/space_graph/graph_draw.c
@@ -836,11 +836,11 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri
for (ale=anim_data.first; ale; ale=ale->next) {
FCurve *fcu= (FCurve *)ale->key_data;
FModifier *fcm= fcurve_find_active_modifier(fcu);
- //Object *nob= ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* map keyframes for drawing if scaled F-Curve */
- //if (nob)
- // ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 0, 0);
+ if (adt)
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 0);
/* draw curve:
* - curve line may be result of one or more destructive modifiers or just the raw data,
@@ -918,8 +918,8 @@ void graph_draw_curves (bAnimContext *ac, SpaceIpo *sipo, ARegion *ar, View2DGri
}
/* undo mapping of keyframes for drawing if scaled F-Curve */
- //if (nob)
- // ANIM_nla_mapping_apply_fcurve(nob, ale->key_data, 1, 0);
+ if (adt)
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 0);
}
/* free list of curves */
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index 8903d95b288..a1888e252d2 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_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"
@@ -114,16 +115,16 @@ static void get_graph_keyframe_extents (bAnimContext *ac, float *xmin, float *xm
if (anim_data.first) {
/* go through channels, finding max extents */
for (ale= anim_data.first; ale; ale= ale->next) {
- Object *nob= NULL; //ANIM_nla_mapping_get(ac, ale);
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
FCurve *fcu= (FCurve *)ale->key_data;
float txmin, txmax, tymin, tymax;
/* get range and apply necessary scaling before */
calc_fcurve_bounds(fcu, &txmin, &txmax, &tymin, &tymax);
- if (nob) {
- txmin= get_action_frame_inv(nob, txmin);
- txmax= get_action_frame_inv(nob, txmax);
+ if (adt) {
+ txmin= BKE_nla_tweakedit_remap(adt, txmin, 1);
+ txmax= BKE_nla_tweakedit_remap(adt, txmax, 1);
}
/* try to set cur using these values, if they're more extreme than previously set values */
@@ -271,6 +272,7 @@ static void create_ghost_curves (bAnimContext *ac, int start, int end)
for (ale= anim_data.first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->key_data;
FCurve *gcu= MEM_callocN(sizeof(FCurve), "Ghost FCurve");
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
ChannelDriver *driver= fcu->driver;
FPoint *fpt;
int cfra;
@@ -286,8 +288,10 @@ static void create_ghost_curves (bAnimContext *ac, int start, int end)
/* use the sampling callback at 1-frame intervals from start to end frames */
for (cfra= start; cfra <= end; cfra++, fpt++) {
- fpt->vec[0]= (float)cfra;
- fpt->vec[1]= fcurve_samplingcb_evalcurve(fcu, NULL, (float)cfra);
+ float cfrae= BKE_nla_tweakedit_remap(adt, cfra, 1);
+
+ fpt->vec[0]= cfrae;
+ fpt->vec[1]= fcurve_samplingcb_evalcurve(fcu, NULL, cfrae);
}
/* set color of ghost curve
@@ -403,6 +407,7 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op)
{
bAnimContext ac;
bAnimListElem *ale;
+ AnimData *adt;
float frame, val;
/* get animation context */
@@ -420,6 +425,10 @@ static int graphkeys_click_insert_exec (bContext *C, wmOperator *op)
frame= RNA_float_get(op->ptr, "frame");
val= RNA_float_get(op->ptr, "value");
+ /* apply inverse NLA-mapping to frame to get correct time in un-scaled action */
+ adt= ANIM_nla_mapping_get(&ac, ale);
+ frame= BKE_nla_tweakedit_remap(adt, frame, 1);
+
/* insert keyframe on the specified frame + value */
insert_vert_fcurve((FCurve *)ale->data, frame, val, 0);
@@ -1336,8 +1345,18 @@ static int graphkeys_framejump_exec(bContext *C, wmOperator *op)
filter= (ANIMFILTER_VISIBLE | ANIMFILTER_CURVEVISIBLE| 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);
@@ -1405,12 +1424,12 @@ static void snap_graph_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
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
@@ -1516,12 +1535,12 @@ static void mirror_graph_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
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, NULL, edit_cb, calchandles_fcurve);
diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c
index 632ce30863d..4451cfae227 100644
--- a/source/blender/editors/space_graph/graph_select.c
+++ b/source/blender/editors/space_graph/graph_select.c
@@ -63,6 +63,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"
@@ -231,14 +232,14 @@ static void borderselect_graphkeys (bAnimContext *ac, rcti rect, short mode, sho
/* 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);
/* set horizontal range (if applicable) */
if (mode != BEZT_OK_VALUERANGE) {
/* 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;
@@ -379,12 +380,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);
@@ -450,15 +451,15 @@ static void columnselect_graph_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 (ale)
+ bed.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, 0);
else
bed.f1= ce->cfra;
@@ -566,11 +567,16 @@ static short findnearest_fcurve_vert (bAnimContext *ac, int mval[2], FCurve **fc
for (ale= anim_data.first; ale; ale= ale->next) {
FCurve *fcu= (FCurve *)ale->key_data;
+ AnimData *adt= ANIM_nla_mapping_get(ac, ale);
/* try to progressively get closer to the right point... */
if (fcu->bezt) {
BezTriple *bezt1=fcu->bezt, *prevbezt=NULL;
+ /* apply NLA mapping to all the keyframes */
+ if (adt)
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 0, 1);
+
for (i=0; i < fcu->totvert; i++, prevbezt=bezt1, bezt1++) {
/* convert beztriple points to screen-space */
UI_view2d_to_region_no_clip(v2d, bezt1->vec[0][0], bezt1->vec[0][1], &sco[0][0], &sco[0][1]);
@@ -624,6 +630,10 @@ static short findnearest_fcurve_vert (bAnimContext *ac, int mval[2], FCurve **fc
}
}
}
+
+ /* un-apply NLA mapping from all the keyframes */
+ if (adt)
+ ANIM_nla_mapping_apply_fcurve(adt, ale->key_data, 1, 1);
}
}
@@ -767,12 +777,12 @@ static void graphkeys_mselect_leftright (bAnimContext *ac, short leftright, shor
/* 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
ANIM_fcurve_keys_bezier_loop(&bed, ale->key_data, ok_cb, select_cb, NULL);
@@ -827,11 +837,11 @@ static void graphkeys_mselect_column (bAnimContext *ac, int mval[2], short selec
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;