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
path: root/source
diff options
context:
space:
mode:
authorJoshua Leung <aligorith@gmail.com>2007-12-07 13:50:02 +0300
committerJoshua Leung <aligorith@gmail.com>2007-12-07 13:50:02 +0300
commitbe7192c0bd161a3b4a3ef28eca60fcc12730d986 (patch)
treee3653785205be9e124e527c56e4e32d22915ab27 /source
parent9723e3ef39d0a0c8b7a47f145c52982481109f2f (diff)
== NLA - Scale Related Fixes ==
* Old files now get initialised with the correct scale. The wrong calculation was being used * Added a new tool to Alt-S menu: "Apply Scale" This tool causes all the keyframes in the active strip to be moved to their NLA-scaled times, the scale to be set to 1.0, and the frame ranges recalculated accordingly (to remove any nasty weird errors) * Scale field now draws red when the action-range is < 1, and the tooltip in this case instructs the user how to fix this (by using "Apply Scale").
Diffstat (limited to 'source')
-rw-r--r--source/blender/blenkernel/intern/action.c1
-rw-r--r--source/blender/blenloader/intern/readfile.c3
-rw-r--r--source/blender/src/drawnla.c8
-rw-r--r--source/blender/src/editnla.c60
-rw-r--r--source/blender/src/header_nla.c10
5 files changed, 57 insertions, 25 deletions
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 7731eea3694..162ee582d74 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -443,7 +443,6 @@ static float get_actionstrip_frame(bActionStrip *strip, float cframe, int invert
length = repeat * scale * actlength;
/* invert = convert action-strip time to global time */
- // FIXME?
if (invert)
return length*(cframe - strip->actstart)/(repeat*actlength) + strip->start;
else
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index f6b0c4cb4dc..68bf1d1815c 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -7211,8 +7211,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
if (length == 0.0f) length= 1.0f;
actlength = strip->actend-strip->actstart;
- // right calculation?
- strip->scale = actlength / (length * repeat);
+ strip->scale = length / (repeat * actlength);
if (strip->scale == 0.0f) strip->scale= 1.0f;
}
}
diff --git a/source/blender/src/drawnla.c b/source/blender/src/drawnla.c
index c1a45ff42f3..ea49c05b322 100644
--- a/source/blender/src/drawnla.c
+++ b/source/blender/src/drawnla.c
@@ -639,7 +639,13 @@ static void nla_panel_properties(short cntrl) // NLA_HANDLER_PROPERTIES
uiBlockBeginAlign(block);
// FIXME: repeat and scale are too cramped!
uiDefButF(block, NUM, B_NLA_SCALE, "Repeat:", 160,100,75,19, &strip->repeat, 0.001, 1000.0f, 100, 0, "Number of times the action should repeat");
- uiDefButF(block, NUM, B_NLA_SCALE, "Scale:", 235,100,75,19, &strip->scale, 0.001, 10000.0f, 100, 0, "Amount the action should be scaled by");
+ if ((strip->actend - strip->actstart) < 1.0f) {
+ uiBlockSetCol(block, TH_REDALERT);
+ uiDefButF(block, NUM, B_NLA_SCALE, "Scale:", 235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Please run Alt-S to fix up this error");
+ uiBlockSetCol(block, TH_AUTO);
+ }
+ else
+ uiDefButF(block, NUM, B_NLA_SCALE, "Scale:", 235,100,75,19, &strip->scale, 0.001, 1000.0f, 100, 0, "Amount the action should be scaled by");
but= uiDefButC(block, TEX, B_NLA_PANEL, "OffsBone:", 160,80,150,19, strip->offs_bone, 0, 31.0f, 0, 0, "Name of Bone that defines offset for repeat");
uiButSetCompleteFunc(but, autocomplete_bone, (void *)ob);
uiDefButBitS(block, TOG, ACTSTRIP_HOLDLASTFRAME, B_NLA_PANEL, "Hold", 160,60,75,19, &strip->flag, 0, 0, 0, 0, "Toggles whether to continue displaying the last frame past the end of the strip");
diff --git a/source/blender/src/editnla.c b/source/blender/src/editnla.c
index 34b60e3e820..d871ef371c8 100644
--- a/source/blender/src/editnla.c
+++ b/source/blender/src/editnla.c
@@ -199,11 +199,11 @@ void synchronize_action_strips(void)
calc_action_range(strip->act, &actstart, &actend, 1);
if ((strip->actstart!=actstart) || (strip->actend!=actend)) {
- float offset;
+ float offset = strip->scale * (actstart - strip->actstart);
+ float actlen = actend - actstart;
- offset= strip->scale * (actstart - strip->actstart);
strip->start += offset;
- strip->end = strip->scale * strip->repeat * (actend-actstart) + strip->start;
+ strip->end = (strip->scale * strip->repeat * actlen) + strip->start;
strip->actstart= actstart;
strip->actend= actend;
@@ -372,15 +372,41 @@ void reset_action_strips(int val)
for (strip = base->object->nlastrips.last; strip; strip=strip->prev) {
if (strip->flag & ACTSTRIP_SELECT) {
- if(val==2) {
- calc_action_range(strip->act, &strip->actstart, &strip->actend, 1);
- }
- else if(val==1) {
- float mapping= (strip->actend - strip->actstart)/(strip->end - strip->start);
-
- strip->end= strip->start + mapping*(strip->end - strip->start);
+ switch (val) {
+ case 1:
+ {
+ /* clear scaling - reset to 1.0 without touching keys */
+ float actlen= (strip->actend - strip->actstart);
+
+ strip->scale= 1.0f;
+ strip->end= (strip->repeat * actlen) + strip->start;
+ }
+ break;
+ case 2:
+ {
+ /* reset action-range */
+ calc_action_range(strip->act, &strip->actstart, &strip->actend, 1);
+ }
+ break;
+ case 3:
+ {
+ /* apply scale to keys - scale is reset to 1.0f, but keys stay at the same times */
+ bActionChannel *achan;
+
+ if (strip->act) {
+ for (achan= strip->act->chanbase.first; achan; achan= achan->next) {
+ actstrip_map_ipo_keys(base->object, achan->ipo, 0, 0);
+ }
+
+ /* now we can reset scale */
+ calc_action_range(strip->act, &strip->actstart, &strip->actend, 1);
+ strip->scale= 1.0f;
+ strip->end = (strip->repeat * (strip->actend - strip->actstart)) + strip->start;
+ }
+ }
+ break;
}
- base->object->ctime= -1234567.0f; // eveil!
+ base->object->ctime= -1234567.0f; // evil!
DAG_object_flush_update(G.scene, base->object, OB_RECALC_OB|OB_RECALC_DATA);
}
}
@@ -1850,14 +1876,12 @@ void winqreadnlaspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
break;
case SKEY:
- if(G.qual==LR_ALTKEY) {
- val= pupmenu("Action Strip Scale%t|Clear Strip Scale%x1|Remap Start/End%x2");
- if(val==1)
- reset_action_strips(1);
- else if(val==2)
- reset_action_strips(2);
+ if (G.qual==LR_ALTKEY) {
+ val= pupmenu("Action Strip Scale%t|Reset Strip Scale%x1|Remap Action Start/End%x2|Apply Scale%x3");
+ if (val > 0)
+ reset_action_strips(val);
}
- else if(G.qual & LR_SHIFTKEY) {
+ else if (G.qual & LR_SHIFTKEY) {
if (snla->flag & SNLA_DRAWTIME)
val= pupmenu("Snap To%t|Nearest Second%x3|Current Time%x2");
else
diff --git a/source/blender/src/header_nla.c b/source/blender/src/header_nla.c
index 96ea6c3d792..3b614ebfb7c 100644
--- a/source/blender/src/header_nla.c
+++ b/source/blender/src/header_nla.c
@@ -331,7 +331,7 @@ static void do_nla_stripmenu(void *arg, int event)
case 7: /* Move Down */
shift_nlastrips_down();
break;
- case 8: /* size */
+ case 8: /* reset scale */
reset_action_strips(1);
break;
case 9: /* reset start/end of action */
@@ -340,6 +340,9 @@ static void do_nla_stripmenu(void *arg, int event)
case 10: /* add new action as new action strip */
add_empty_nlablock();
break;
+ case 11: /* apply scale */
+ reset_action_strips(3);
+ break;
}
}
@@ -353,10 +356,11 @@ static uiBlock *nla_stripmenu(void *arg_unused)
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Strip Properties...|N", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBlockBut(block, nla_strip_transformmenu, NULL, ICON_RIGHTARROW_THIN, "Transform", 0, yco-=20, 120, 20, "");
- uiDefIconTextBlockBut(block, nla_strip_snapmenu, NULL, ICON_RIGHTARROW_THIN, "Snap To Frame", 0, yco-=20, 120, 20, "");
+ uiDefIconTextBlockBut(block, nla_strip_snapmenu, NULL, ICON_RIGHTARROW_THIN, "Snap", 0, yco-=20, 120, 20, "");
- uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Strip Size|Alt S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Strip Scale|Alt S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 8, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Reset Action Start/End|Alt S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Apply Strip Scaling|Alt S", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 11, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");