mirror of
https://github.com/lubosz/overte.git
synced 2025-04-10 04:28:59 +02:00
fixing up animation loop issues
This commit is contained in:
parent
ba79f40007
commit
dd22683672
3 changed files with 21 additions and 5 deletions
|
@ -73,10 +73,12 @@ void AnimationLoop::simulate(float deltaTime) {
|
|||
_frameIndex = startFrameIndex + glm::mod(_frameIndex - startFrameIndex, endFrameIndex - startFrameIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
qDebug() << "AnimationLoop::simulate()";
|
||||
qDebug() << " deltaTime:" << deltaTime;
|
||||
qDebug() << " _frameIndex:" << _frameIndex;
|
||||
*/
|
||||
}
|
||||
|
||||
void AnimationLoop::setStartAutomatically(bool startAutomatically) {
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
void setRunning(bool running);
|
||||
bool isRunning() const { return _running; }
|
||||
|
||||
void setFrameIndex(float frameIndex) { _frameIndex = glm::clamp(_frameIndex, _firstFrame, _lastFrame); }
|
||||
void setFrameIndex(float frameIndex) { _frameIndex = glm::clamp(frameIndex, _firstFrame, _lastFrame); }
|
||||
float getFrameIndex() const { return _frameIndex; }
|
||||
|
||||
void start() { setRunning(true); }
|
||||
|
|
|
@ -101,9 +101,23 @@ int ModelEntityItem::readEntitySubclassDataFromBuffer(const unsigned char* data,
|
|||
READ_ENTITY_PROPERTY_COLOR(PROP_COLOR, _color);
|
||||
READ_ENTITY_PROPERTY_STRING(PROP_MODEL_URL, setModelURL);
|
||||
READ_ENTITY_PROPERTY_STRING(PROP_ANIMATION_URL, setAnimationURL);
|
||||
READ_ENTITY_PROPERTY_SETTER(PROP_ANIMATION_FPS, float, setAnimationFPS);
|
||||
READ_ENTITY_PROPERTY_SETTER(PROP_ANIMATION_FRAME_INDEX, float, setAnimationFrameIndex);
|
||||
READ_ENTITY_PROPERTY_SETTER(PROP_ANIMATION_PLAYING, bool, setAnimationIsPlaying);
|
||||
|
||||
// Because we're using AnimationLoop which will reset the frame index if you change it's running state
|
||||
// we want to read these values in the order they appear in the buffer, but call our setters in an
|
||||
// order that allows AnimationLoop to preserve the correct frame rate.
|
||||
float animationFPS = getAnimationFPS();
|
||||
float animationFrameIndex = getAnimationFrameIndex();
|
||||
bool animationIsPlaying = getAnimationIsPlaying();
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FPS, float, animationFPS);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_FRAME_INDEX, float, animationFrameIndex);
|
||||
READ_ENTITY_PROPERTY(PROP_ANIMATION_PLAYING, bool, animationIsPlaying);
|
||||
|
||||
setAnimationIsPlaying(animationIsPlaying);
|
||||
setAnimationFPS(animationFPS);
|
||||
setAnimationFrameIndex(animationFrameIndex);
|
||||
|
||||
qDebug() << "just read PROP_ANIMATION_FRAME_INDEX, getAnimationFrameIndex():" << getAnimationFrameIndex();
|
||||
|
||||
READ_ENTITY_PROPERTY_STRING(PROP_TEXTURES, setTextures);
|
||||
|
||||
return bytesRead;
|
||||
|
|
Loading…
Reference in a new issue