Revision: 21395
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=21395
Author: aligorith
Date: 2009-07-07 07:41:59 +0200 (Tue, 07 Jul 2009)
Log Message:
-----------
NLA SoC: Transform Code for NLA-Strips recoded (still buggy)
Recoded the Transform code for NLA-Strips so that they can now be moved between
strips and will not get truncated when they get moved into other non-moving
strips.
Todos:
* The current code for moving strips between tracks is buggy (only goes up, and
has a tendency to move up without being told to)
* Auto-snapping doesn't work yet...
Modified Paths:
--------------
branches/soc-2009-aligorith/source/blender/editors/include/ED_anim_api.h
branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c
branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
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
Modified:
branches/soc-2009-aligorith/source/blender/editors/include/ED_anim_api.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/include/ED_anim_api.h
2009-07-07 02:12:50 UTC (rev 21394)
+++ branches/soc-2009-aligorith/source/blender/editors/include/ED_anim_api.h
2009-07-07 05:41:59 UTC (rev 21395)
@@ -228,6 +228,22 @@
/* channel toggle-buttons */
#define ACHANNEL_BUTTON_WIDTH 16
+
+/* -------------- NLA Channel Defines -------------- */
+
+/* NLA channel heights */
+#define NLACHANNEL_FIRST -16
+#define NLACHANNEL_HEIGHT 24
+#define NLACHANNEL_HEIGHT_HALF 12
+#define NLACHANNEL_SKIP 2
+#define NLACHANNEL_STEP (NLACHANNEL_HEIGHT +
NLACHANNEL_SKIP)
+
+/* channel widths */
+#define NLACHANNEL_NAMEWIDTH 200
+
+/* channel toggle-buttons */
+#define NLACHANNEL_BUTTON_WIDTH 16
+
/* ---------------- API -------------------- */
/* Obtain list of filtered Animation channels to operate on.
Modified:
branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c
2009-07-07 02:12:50 UTC (rev 21394)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_header.c
2009-07-07 05:41:59 UTC (rev 21395)
@@ -139,7 +139,7 @@
static void nla_edit_transformmenu(bContext *C, uiLayout *layout, void
*arg_unused)
{
// XXX these operators may change for NLA...
- uiItemEnumO(layout, "Grab/Move", 0, "TFM_OT_transform", "mode",
TFM_TIME_TRANSLATE);
+ uiItemEnumO(layout, "Grab/Move", 0, "TFM_OT_transform", "mode",
TFM_TRANSLATION);
uiItemEnumO(layout, "Extend", 0, "TFM_OT_transform", "mode",
TFM_TIME_EXTEND);
uiItemEnumO(layout, "Scale", 0, "TFM_OT_transform", "mode",
TFM_TIME_SCALE);
}
Modified:
branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
2009-07-07 02:12:50 UTC (rev 21394)
+++ branches/soc-2009-aligorith/source/blender/editors/space_nla/nla_intern.h
2009-07-07 05:41:59 UTC (rev 21395)
@@ -33,21 +33,6 @@
/* **************************************** */
/* Macros, etc. only used by NLA */
-/* -------------- NLA Channel Defines -------------- */
-
-/* NLA channel heights */
-#define NLACHANNEL_FIRST -16
-#define NLACHANNEL_HEIGHT 24
-#define NLACHANNEL_HEIGHT_HALF 12
-#define NLACHANNEL_SKIP 2
-#define NLACHANNEL_STEP (NLACHANNEL_HEIGHT +
NLACHANNEL_SKIP)
-
-/* channel widths */
-#define NLACHANNEL_NAMEWIDTH 200
-
-/* channel toggle-buttons */
-#define NLACHANNEL_BUTTON_WIDTH 16
-
/* **************************************** */
/* space_nla.c / nla_buttons.c */
Modified:
branches/soc-2009-aligorith/source/blender/editors/transform/transform.c
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/transform/transform.c
2009-07-07 02:12:50 UTC (rev 21394)
+++ branches/soc-2009-aligorith/source/blender/editors/transform/transform.c
2009-07-07 05:41:59 UTC (rev 21395)
@@ -162,7 +162,7 @@
vec[1]= aspy*(v2d->cur.ymax-v2d->cur.ymin)*(dy)/divy;
vec[2]= 0.0f;
}
- else if(t->spacetype==SPACE_IPO) {
+ else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
View2D *v2d = t->view;
float divx, divy;
@@ -212,7 +212,7 @@
UI_view2d_to_region_no_clip(t->view, v[0], v[1], adr, adr+1);
}
- else if(t->spacetype==SPACE_IPO) {
+ else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
int out[2] = {0, 0};
UI_view2d_view_to_region((View2D *)t->view, vec[0], vec[1],
out, out+1);
@@ -241,7 +241,7 @@
adr[0]= a[0];
adr[1]= a[1];
}
- else if(t->spacetype==SPACE_IPO) {
+ else if(ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)) {
int a[2];
projectIntView(t, vec, a);
@@ -1324,10 +1324,10 @@
case TFM_TIME_EXTEND:
/* now that transdata has been made, do like for
TFM_TIME_TRANSLATE (for most Animation
* Editors because they have only 1D transforms for time
values) or TFM_TRANSLATION
- * (for Graph Editor only since it uses 'standard' transforms
to get 2D movement)
+ * (for Graph/NLA Editors only since they uses 'standard'
transforms to get 2D movement)
* depending on which editor this was called from
*/
- if (t->spacetype == SPACE_IPO)
+ if ELEM(t->spacetype, SPACE_IPO, SPACE_NLA)
initTranslation(t);
else
initTimeTranslate(t);
Modified:
branches/soc-2009-aligorith/source/blender/editors/transform/transform.h
===================================================================
--- branches/soc-2009-aligorith/source/blender/editors/transform/transform.h
2009-07-07 02:12:50 UTC (rev 21394)
+++ branches/soc-2009-aligorith/source/blender/editors/transform/transform.h
2009-07-07 05:41:59 UTC (rev 21395)
@@ -163,9 +163,17 @@
/* 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 */
+ struct NlaTrack *oldTrack; /* Original NLA-Track that the strip
belongs to */
+ struct NlaTrack *nlt; /* Current NLA-Track that the strip
belongs to */
+
+ struct NlaStrip *strip; /* NLA-strip this data represents */
+
+ /* dummy values for transform to write in - must have 3 elements... */
+ float h1[3]; /* start handle */
+ float h2[3]; /* end handle */
+
+ int trackIndex; /* index of track that strip is
currently in */
+ int handle; /* handle-index: 0 for
dummy entry, -1 for start, 1 for end, 2 for both ends */
} TransDataNla;
typedef struct TransData {
Modified:
branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
===================================================================
---
branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
2009-07-07 02:12:50 UTC (rev 21394)
+++
branches/soc-2009-aligorith/source/blender/editors/transform/transform_conversions.c
2009-07-07 05:41:59 UTC (rev 21395)
@@ -2661,34 +2661,104 @@
/* transition strips can't get directly
transformed */
if (strip->type != NLASTRIP_TYPE_TRANSITION) {
if (strip->flag & NLASTRIP_FLAG_SELECT)
{
+ /* our transform data is
constructed as follows:
+ * - only the handles on
the right side of the current-frame get included
+ * - td structs are
transform-elements operated on by the transform system
+ * and represent a
single handle. The storage/pointer used (val or loc) depends on
+ * whether we're scaling
or transforming. Ultimately though, the handles
+ * the td writes to will
simply be a dummy in tdn
+ * - for each strip being
transformed, a single tdn struct is used, so in some
+ * cases, there will
need to be 1 of these tdn elements in the array skipped...
+ */
+ float center[3], yval;
+
+ /* firstly, init tdn settings */
+ tdn->oldTrack= tdn->nlt= nlt;
+ tdn->strip= strip;
+ tdn->trackIndex=
BLI_findindex(&nlt->strips, strip);
+
+ yval= (float)(tdn->trackIndex *
NLACHANNEL_SKIP);
+
+ tdn->h1[0]= strip->start;
+ tdn->h1[1]= yval;
+ tdn->h2[0]= strip->end;
+ tdn->h2[1]= yval;
+
+ center[0]= (float)CFRA;
+ center[1]= yval;
+ center[2]= 0.0f;
+
+ /* set td's based on which
handles are applicable */
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;
+ /* just set tdn to
assume that it only has one handle for now */
+ tdn->handle= -1;
/* now, link the
transform data up to this data */
- td->val= &tdn->val;
- td->ival= tdn->val;
+ if (t->mode ==
TFM_TRANSLATION) {
+ td->loc=
tdn->h1;
+
VECCOPY(td->iloc, tdn->h1);
+
+ /* store all
the other gunk that is required by transform */
+
VECCOPY(td->center, center);
+
memset(td->axismtx, 0, sizeof(td->axismtx));
+
td->axismtx[2][2] = 1.0f;
+
+ td->ext= NULL;
td->tdi= NULL; td->val= NULL;
+
+ td->flag |=
TD_SELECTED;
+ td->dist= 0.0f;
+
+
Mat3One(td->mtx);
+
Mat3One(td->smtx);
+ }
+ else {
+ td->val=
&tdn->h1[0];
+ td->ival=
tdn->h1[0];
+ }
+
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;
+ /* if tdn is already
holding the start handle, then we're doing both, otherwise, only end */
+ tdn->handle=
(tdn->handle) ? 2 : 1;
/* now, link the
transform data up to this data */
- td->val= &tdn->val;
- td->ival= tdn->val;
+ if (t->mode ==
TFM_TRANSLATION) {
+ td->loc=
tdn->h2;
+
VECCOPY(td->iloc, tdn->h2);
+
+ /* store all
the other gunk that is required by transform */
+
VECCOPY(td->center, center);
+
memset(td->axismtx, 0, sizeof(td->axismtx));
+
td->axismtx[2][2] = 1.0f;
+
+ td->ext= NULL;
td->tdi= NULL; td->val= NULL;
+
+ td->flag |=
TD_SELECTED;
+ td->dist= 0.0f;
+
+
Mat3One(td->mtx);
+
Mat3One(td->smtx);
+ }
+ else {
+ td->val=
&tdn->h2[0];
+ td->ival=
tdn->h2[0];
+ }
+
td->extra= tdn;
td++;
+ }
+
+ /* if both handles were used,
skip the next tdn (i.e. leave it blank) since the counting code is dumb...
+ * otherwise, just advance to
the next one...
+ */
+ if (tdn->handle == 2)
+ tdn += 2;
+ else
tdn++;
- }
}
}
}
@@ -4739,7 +4809,6 @@
ANIM_editkeyframes_refresh(&ac);
}
else if (t->spacetype == SPACE_NLA) {
- SpaceNla *snla= (SpaceNla *)t->sa->spacedata.first;
Scene *scene;
bAnimContext ac;
@@ -4769,6 +4838,10 @@
for (ale= anim_data.first; ale; ale= ale->next) {
NlaTrack *nlt= (NlaTrack *)ale->data;
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs