Revision: 20748
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=20748
Author: aligorith
Date: 2009-06-09 13:26:45 +0200 (Tue, 09 Jun 2009)
Log Message:
-----------
NLA SoC: Transform tools for NLA
This commit restores transform support for NLA. Grab, scale, 'extend', and
tweak (i.e. grab by just click+dragging) are implemented.
Notes:
- As soon as one end of a strip touches another adjacent strip (within the same
track), that end stops moving. This has been done to avoid the situation where
overlapping strips within the same track (which is not allowed) might be caused
by transforms.
- Made some changes to the RNA setters for the strip extents so that the
validation above could take place (and other necessary changes on a per-strip
basis could also occur).
TODO's ?
- Strips cannot be transferred from track to track using transforms. I've yet
to decide whether this needs to be done, or whether a separate operator will
suffice.
- What happens to the range of Actions used when the strips change sizes
unexpectedly (i.e. the no-overlap condition above)? Currently range stays the
same, but this doesn't always seem desirable?
Modified Paths:
--------------
branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c
branches/soc-2009-aligorith/source/blender/editors/transform/transform.c
branches/soc-2009-aligorith/source/blender/editors/transform/transform.h
branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c
branches/soc-2009-aligorith/source/blender/editors/transform/transform_ops.c
branches/soc-2009-aligorith/source/blender/makesrna/intern/rna_nla.c
Modified: branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c
2009-06-09 10:30:16 UTC (rev 20747)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_ops.c
2009-06-09 11:26:45 UTC (rev 20748)
@@ -54,6 +54,8 @@
#include "ED_space_api.h"
#include "ED_screen.h"
+#include "BIF_transform.h"
+
#include "WM_api.h"
#include "WM_types.h"
@@ -191,7 +193,7 @@
WM_keymap_add_item(keymap, "NLAEDIT_OT_tweakmode_exit", TABKEY,
KM_PRESS, 0, 0);
/* transform system */
- //transform_keymap_for_space(wm, keymap, SPACE_NLA);
+ transform_keymap_for_space(wm, keymap, SPACE_NLA);
}
/* --------------- */
Modified:
branches/soc-2009-aligorith/source/blender/editors/transform/transform.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/transform/transform.c
2009-06-09 10:30:16 UTC (rev 20747)
+++ branches/soc-2009-aligorith/source/blender/editors/transform/transform.c
2009-06-09 11:26:45 UTC (rev 20748)
@@ -319,6 +319,9 @@
else
ED_area_tag_redraw(t->sa);
}
+ else if (t->spacetype == SPACE_NLA) {
+ ED_area_tag_redraw(t->sa); // XXX this should use a notifier
instead!
+ }
else if(t->spacetype == SPACE_NODE)
{
//ED_area_tag_redraw(t->sa);
Modified:
branches/soc-2009-aligorith/source/blender/editors/transform/transform.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/transform/transform.h
2009-06-09 10:30:16 UTC (rev 20747)
+++ branches/soc-2009-aligorith/source/blender/editors/transform/transform.h
2009-06-09 11:26:45 UTC (rev 20748)
@@ -161,6 +161,13 @@
} TransDataSeq;
+/* for NLA transform (stored in td->extra pointer) */
+typedef struct TransDataNla {
+ struct NlaStrip *strip; /* NLA-strip that handle belongs to */
+ float val; /* value for the handle
that the transform tools write to */
+ int handle; /* handle-index, 0 for
start, 1 for end */
+} TransDataNla;
+
typedef struct TransData {
float dist; /* Distance needed to affect element (for
Proportionnal Editing) */
float rdist; /* Distance to the nearest element (for
Proportionnal Editing) */
Modified:
branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
===================================================================
---
branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
2009-06-09 10:30:16 UTC (rev 20747)
+++
branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
2009-06-09 11:26:45 UTC (rev 20748)
@@ -2559,8 +2559,160 @@
return (clipx || clipy);
}
-/* ********************* ACTION/NLA EDITOR ****************** */
+/* ********************* ANIMATION EDITORS (GENERAL) *************************
*/
+/* This function tests if a point is on the "mouse" side of the
cursor/frame-marking */
+static short FrameOnMouseSide(char side, float frame, float cframe)
+{
+ /* both sides, so it doesn't matter */
+ if (side == 'B') return 1;
+
+ /* only on the named side */
+ if (side == 'R')
+ return (frame >= cframe) ? 1 : 0;
+ else
+ return (frame <= cframe) ? 1 : 0;
+}
+
+/* ********************* NLA EDITOR ************************* */
+
+static void createTransNlaData(bContext *C, TransInfo *t)
+{
+ Scene *scene= CTX_data_scene(C);
+ TransData *td = NULL;
+ TransDataNla *tdn = NULL;
+
+ bAnimContext ac;
+ ListBase anim_data = {NULL, NULL};
+ bAnimListElem *ale;
+ int filter;
+
+ int count=0;
+ char side;
+
+ /* determine what type of data we are operating on */
+ if (ANIM_animdata_get_context(C, &ac) == 0)
+ return;
+
+ /* filter data */
+ filter= (ANIMFILTER_VISIBLE | ANIMFILTER_FOREDIT);
+ ANIM_animdata_filter(&ac, &anim_data, filter, ac.data, ac.datatype);
+
+ /* which side of the current frame should be allowed */
+ if (t->mode == TFM_TIME_EXTEND) {
+ /* only side on which mouse is gets transformed */
+ float xmouse, ymouse;
+
+ UI_view2d_region_to_view(&ac.ar->v2d, t->imval[0], t->imval[1],
&xmouse, &ymouse);
+ side = (xmouse > CFRA) ? 'R' : 'L'; // XXX use t->frame_side
+ }
+ else {
+ /* normal transform - both sides of current frame are
considered */
+ side = 'B';
+ }
+
+ /* loop 1: count how many strips are selected (consider each strip as 2
points) */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ /* only if a real NLA-track */
+ if (ale->type == ANIMTYPE_NLATRACK) {
+ NlaTrack *nlt= (NlaTrack *)ale->data;
+ NlaStrip *strip;
+
+ /* only consider selected strips */
+ for (strip= nlt->strips.first; strip; strip=
strip->next) {
+ // TODO: we can make strips have handles later
on...
+ if (strip->flag & NLASTRIP_FLAG_SELECT) {
+ if (FrameOnMouseSide(side,
strip->start, (float)CFRA)) count++;
+ if (FrameOnMouseSide(side, strip->end,
(float)CFRA)) count++;
+ }
+ }
+ }
+ }
+
+ /* stop if trying to build list if nothing selected */
+ if (count == 0) {
+ /* cleanup temp list */
+ BLI_freelistN(&anim_data);
+ return;
+ }
+
+ /* allocate memory for data */
+ t->total= count;
+
+ t->data= MEM_callocN(t->total*sizeof(TransData), "TransData(NLA
Editor)");
+ td= t->data;
+ t->customData= MEM_callocN(t->total*sizeof(TransDataNla), "TransDataNla
(NLA Editor)");
+ tdn= t->customData;
+
+ /* loop 2: build transdata array */
+ for (ale= anim_data.first; ale; ale= ale->next) {
+ /* only if a real NLA-track */
+ if (ale->type == ANIMTYPE_NLATRACK) {
+ NlaTrack *nlt= (NlaTrack *)ale->data;
+ NlaStrip *strip;
+
+ /* only consider selected strips */
+ for (strip= nlt->strips.first; strip; strip=
strip->next) {
+ // TODO: we can make strips have handles later
on...
+ if (strip->flag & NLASTRIP_FLAG_SELECT) {
+ if (FrameOnMouseSide(side,
strip->start, (float)CFRA))
+ {
+ /* init the 'extra' data for
NLA strip handles first */
+ tdn->strip= strip;
+ tdn->val= strip->start;
+ tdn->handle= 0;
+
+ /* now, link the transform data
up to this data */
+ td->val= &tdn->val;
+ td->ival= tdn->val;
+ td->extra= tdn;
+ td++;
+ tdn++;
+ }
+ if (FrameOnMouseSide(side, strip->end,
(float)CFRA))
+ {
+ /* init the 'extra' data for
NLA strip handles first */
+ tdn->strip= strip;
+ tdn->val= strip->end;
+ tdn->handle= 1;
+
+ /* now, link the transform data
up to this data */
+ td->val= &tdn->val;
+ td->ival= tdn->val;
+ td->extra= tdn;
+ td++;
+ tdn++;
+ }
+ }
+ }
+ }
+ }
+
+ /* check if we're supposed to be setting minx/maxx for TimeSlide */
+ if (t->mode == TFM_TIME_SLIDE) {
+ float min=999999999.0f, max=-999999999.0f;
+ int i;
+
+ td= (t->data + 1);
+ for (i=1; i < count; i+=3, td+=3) {
+ if (min > *(td->val)) min= *(td->val);
+ if (max < *(td->val)) max= *(td->val);
+ }
+
+ /* minx/maxx values used by TimeSlide are stored as a
+ * calloced 2-float array in t->customData. This gets freed
+ * in postTrans (T_FREE_CUSTOMDATA).
+ */
+ *((float *)(t->customData)) = min;
+ *((float *)(t->customData) + 1) = max;
+ }
+
+ /* cleanup temp list */
+ BLI_freelistN(&anim_data);
+}
+
+/* ********************* ACTION EDITOR ****************** */
+
/* Called by special_aftertrans_update to make sure selected gp-frames replace
* any other gp-frames which may reside on that frame (that are not selected).
* It also makes sure gp-frames are still stored in chronological order after
@@ -2744,19 +2896,6 @@
/* ----------------------------- */
-/* This function tests if a point is on the "mouse" side of the
cursor/frame-marking */
-static short FrameOnMouseSide(char side, float frame, float cframe)
-{
- /* both sides, so it doesn't matter */
- if (side == 'B') return 1;
-
- /* only on the named side */
- if (side == 'R')
- return (frame >= cframe) ? 1 : 0;
- else
- return (frame <= cframe) ? 1 : 0;
-}
-
/* fully select selected beztriples, but only include if it's on the right
side of cfra */
static int count_fcurve_keys(FCurve *fcu, char side, float cfra)
{
@@ -3044,8 +3183,6 @@
/* ********************* GRAPH EDITOR ************************* */
-
-
/* Helper function for createTransGraphEditData, which is reponsible for
associating
* source data with transform data
*/
@@ -3502,7 +3639,6 @@
}
}
-
/* **************** IpoKey stuff, for Object TransData ********** */
/* while transforming */
@@ -4604,6 +4740,29 @@
/* make sure all F-Curves are set correctly */
ANIM_editkeyframes_refresh(&ac);
}
+ else if (t->spacetype == SPACE_NLA) {
+ SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
+ Scene *scene;
+ bAnimContext ac;
+
+ /* initialise relevant anim-context 'context' data from
TransInfo data */
+ /* NOTE: sync this with the code in ANIM_animdata_get_context()
*/
+ memset(&ac, 0, sizeof(bAnimContext));
+
+ scene= ac.scene= t->scene;
+ ob= ac.obact= OBACT;
+ ac.sa= t->sa;
+ ac.ar= t->ar;
+ ac.spacetype= (t->sa)? t->sa->spacetype : 0;
+ ac.regiontype= (t->ar)? t->ar->regiontype : 0;
+
+ if (ANIM_animdata_context_getdata(&ac) == 0)
+ return;
+
+ // XXX check on the calls below... we need some of these sanity
checks
+ //synchronize_action_strips();
+ //ANIM_editkeyframes_refresh(&ac);
+ }
else if (t->obedit) {
// TRANSFORM_FIX_ME
// if (t->mode==TFM_BONESIZE || t->mode==TFM_BONE_ENVELOPE)
@@ -4682,24 +4841,6 @@
}
}
-#if 0 // TRANSFORM_FIX_ME
- else if (t->spacetype == SPACE_NLA) {
- recalc_all_ipos(); // bad
- synchronize_action_strips();
-
- /* cleanup */
- for (base=t->scene->base.first; base; base=base->next)
- base->flag &= ~(BA_HAS_RECALC_OB|BA_HAS_RECALC_DATA);
-
- /* after transform, remove duplicate keyframes on a frame that
resulted from transform */
- if ( (G.snla->flag & SNLA_NOTRANSKEYCULL)==0 &&
- ((cancelled == 0) || (duplicate)) )
- {
- posttrans_nla_clean(t);
- }
- }
-#endif
-
clear_trans_object_base_flags(t);
#if 0 // TRANSFORM_FIX_ME
@@ -4932,8 +5073,7 @@
}
else if (t->spacetype == SPACE_NLA) {
t->flag |= T_POINTS|T_2D_EDIT;
- // TRANSFORM_FIX_ME
- //createTransNlaData(C, t);
+ createTransNlaData(C, t);
}
else if (t->spacetype == SPACE_SEQ) {
t->flag |= T_POINTS|T_2D_EDIT;
Modified:
branches/soc-2009-aligorith/source/blender/editors/transform/transform_generics.c
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs