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>2007-12-07 13:50:02 +0300
committerJoshua Leung <aligorith@gmail.com>2007-12-07 13:50:02 +0300
commitbe7192c0bd161a3b4a3ef28eca60fcc12730d986 (patch)
treee3653785205be9e124e527c56e4e32d22915ab27 /source/blender/src/editnla.c
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/blender/src/editnla.c')
-rw-r--r--source/blender/src/editnla.c60
1 files changed, 42 insertions, 18 deletions
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