mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
proper modulus of animation frame
This commit is contained in:
parent
559cb33563
commit
bad2c1df76
2 changed files with 8 additions and 11 deletions
|
@ -993,16 +993,15 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) {
|
|||
}
|
||||
|
||||
{
|
||||
// the current frame is set on the server in update() in ModelEntityItem.cpp
|
||||
int animationCurrentFrame = (int)(glm::floor(entity->getAnimationCurrentFrame()));
|
||||
if (animationCurrentFrame < 0 || animationCurrentFrame >= frameCount) {
|
||||
animationCurrentFrame = 0;
|
||||
float currentFrame = fmod(entity->getAnimationCurrentFrame(), (float)(frameCount));
|
||||
if (currentFrame < 0.0f) {
|
||||
currentFrame += (float)frameCount;
|
||||
}
|
||||
|
||||
if (animationCurrentFrame == _lastKnownCurrentFrame) {
|
||||
int currentIntegerFrame = (int)(glm::floor(currentFrame));
|
||||
if (currentIntegerFrame == _lastKnownCurrentFrame) {
|
||||
return;
|
||||
}
|
||||
_lastKnownCurrentFrame = animationCurrentFrame;
|
||||
_lastKnownCurrentFrame = currentIntegerFrame;
|
||||
}
|
||||
|
||||
if (_jointMapping.size() != _model->getJointStateCount()) {
|
||||
|
|
|
@ -245,7 +245,7 @@ void ModelEntityItem::updateFrameCount() {
|
|||
if (_currentFrame < 0.0f) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (!_lastAnimated) {
|
||||
_lastAnimated = usecTimestampNow();
|
||||
return;
|
||||
|
@ -263,7 +263,7 @@ void ModelEntityItem::updateFrameCount() {
|
|||
}
|
||||
|
||||
int updatedFrameCount = getAnimationLastFrame() - getAnimationFirstFrame() + 1;
|
||||
|
||||
|
||||
if (!getAnimationHold() && getAnimationIsPlaying()) {
|
||||
float deltaTime = (float)interval / (float)USECS_PER_SECOND;
|
||||
_currentFrame += (deltaTime * getAnimationFPS());
|
||||
|
@ -283,8 +283,6 @@ void ModelEntityItem::updateFrameCount() {
|
|||
// qCDebug(entities) << "in update frame " << _currentFrame;
|
||||
setAnimationCurrentFrame(_currentFrame);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ModelEntityItem::debugDump() const {
|
||||
|
|
Loading…
Reference in a new issue