Text archives Help
- From: "Thiago Ize" <
>
- To:
- Subject: [Manta] r2295 - trunk/Model/MiscObjects
- Date: Thu, 26 Jun 2008 15:58:19 -0600 (MDT)
Author: thiago
Date: Thu Jun 26 15:58:18 2008
New Revision: 2295
Modified:
trunk/Model/MiscObjects/KeyFrameAnimation.cc
trunk/Model/MiscObjects/KeyFrameAnimation.h
Log:
Modified lockedFrames so that it also works for linear interpolation
timesteps. In the processs I cleaned up the code a little bit by
removing an unneeded class data member.
Modified: trunk/Model/MiscObjects/KeyFrameAnimation.cc
==============================================================================
--- trunk/Model/MiscObjects/KeyFrameAnimation.cc (original)
+++ trunk/Model/MiscObjects/KeyFrameAnimation.cc Thu Jun 26 15:58:18
2008
@@ -14,7 +14,7 @@
as(NULL), interpolation(interpolation), spareGroup(NULL),
currGroup(NULL), currTime(-1), updateToCurrTime(false),
paused(false), barrier("keyframe animation barrier"), duration(1),
- lockedFrames(false), lastFrame(0), startFrame(0), endFrame(0),
framesClipped(false),
+ lockedFrames(false), startFrame(0), endFrame(0), framesClipped(false),
loop(true), repeatLastFrame(0.0), repeating(false), forceUpdate(false)
{
}
@@ -115,9 +115,32 @@
differentFrame = false;
}
else {
- float newTime = wrapTime(context.time - startTime);
- differentFrame = isDifferentFrame(newTime);
- currTime = newTime;
+ if (lockedFrames) {
+ if (interpolation == linear) {
+ const int fps = 30;
+ float oldTime = currTime;
+ currTime = wrapTime(currTime + numFrames/(duration*fps));
+ differentFrame = isDifferentFrame(oldTime);
+ if (currTime < oldTime)
+ exit(1);
+ }
+ else if (interpolation == truncate) {
+ //it's possible that direclty adding in the extra time
+ //will result in a time that is just epsilon shy of the
+ //next keyframe. To avoid that, we have to figure out at
+ //what time the next frame would have occured and then
+ //work backwards.
+ float nextFrame = currTime/duration*numFrames+1;
+ currTime = nextFrame/numFrames*duration;
+ differentFrame = numFrames > 1;
+ currTime = wrapTime(currTime);
+ }
+ }
+ else {
+ float newTime = wrapTime(context.time - startTime);
+ differentFrame = isDifferentFrame(newTime);
+ currTime = newTime;
+ }
}
if (!loop && (context.time - startTime) >=duration) {
pauseAnimation();
@@ -133,11 +156,7 @@
if (differentFrame) {
float frame = currTime/duration * numFrames;
- if (lockedFrames && lastFrame!=frame && (lastFrame+1)%(numFrames) !=
frame)
- {
- frame = (lastFrame+1)%(numFrames);
- }
- lastFrame = static_cast<int>(frame);
+ float lastFrame = static_cast<int>(frame);
if (interpolation == linear) {
//do interpolation in parallel
Modified: trunk/Model/MiscObjects/KeyFrameAnimation.h
==============================================================================
--- trunk/Model/MiscObjects/KeyFrameAnimation.h (original)
+++ trunk/Model/MiscObjects/KeyFrameAnimation.h Thu Jun 26 15:58:18 2008
@@ -95,7 +95,6 @@
float duration; //how many seconds long
bool lockedFrames; // make sure that no frames are skipped when setting
time, each frame will be shown at least once
- int lastFrame;
int startFrame;
int endFrame;
int numFrames;
@@ -103,7 +102,7 @@
bool loop;
float repeatLastFrame; //this will repeat the last frame for the given
number of seconds (on top of the duration)
bool repeating;
- bool forceUpdate;
+ bool forceUpdate;
};
}
#endif
- [Manta] r2295 - trunk/Model/MiscObjects, Thiago Ize, 06/26/2008
Archive powered by MHonArc 2.6.16.