mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:00:41 +02:00
Merge pull request #12008 from AndrewMeadows/fix-animation-crash
fix interface crash for bad QVector index in animation loop
This commit is contained in:
commit
5f5bf94f2a
2 changed files with 8 additions and 14 deletions
|
@ -993,19 +993,15 @@ void ModelEntityRenderer::animate(const TypedEntityPointer& entity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
// the current frame is set on the server in update() in ModelEntityItem.cpp
|
float currentFrame = fmod(entity->getAnimationCurrentFrame(), (float)(frameCount));
|
||||||
int animationCurrentFrame = (int)(glm::floor(entity->getAnimationCurrentFrame()));
|
if (currentFrame < 0.0f) {
|
||||||
|
currentFrame += (float)frameCount;
|
||||||
// in the case where the last frame is greater than the framecount then clamp
|
|
||||||
// it to the end of the animation until it loops around.
|
|
||||||
if (animationCurrentFrame < 0 || animationCurrentFrame > frameCount) {
|
|
||||||
animationCurrentFrame = 0;
|
|
||||||
}
|
}
|
||||||
|
int currentIntegerFrame = (int)(glm::floor(currentFrame));
|
||||||
if (animationCurrentFrame == _lastKnownCurrentFrame) {
|
if (currentIntegerFrame == _lastKnownCurrentFrame) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_lastKnownCurrentFrame = animationCurrentFrame;
|
_lastKnownCurrentFrame = currentIntegerFrame;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_jointMapping.size() != _model->getJointStateCount()) {
|
if (_jointMapping.size() != _model->getJointStateCount()) {
|
||||||
|
|
|
@ -245,7 +245,7 @@ void ModelEntityItem::updateFrameCount() {
|
||||||
if (_currentFrame < 0.0f) {
|
if (_currentFrame < 0.0f) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_lastAnimated) {
|
if (!_lastAnimated) {
|
||||||
_lastAnimated = usecTimestampNow();
|
_lastAnimated = usecTimestampNow();
|
||||||
return;
|
return;
|
||||||
|
@ -263,7 +263,7 @@ void ModelEntityItem::updateFrameCount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
int updatedFrameCount = getAnimationLastFrame() - getAnimationFirstFrame() + 1;
|
int updatedFrameCount = getAnimationLastFrame() - getAnimationFirstFrame() + 1;
|
||||||
|
|
||||||
if (!getAnimationHold() && getAnimationIsPlaying()) {
|
if (!getAnimationHold() && getAnimationIsPlaying()) {
|
||||||
float deltaTime = (float)interval / (float)USECS_PER_SECOND;
|
float deltaTime = (float)interval / (float)USECS_PER_SECOND;
|
||||||
_currentFrame += (deltaTime * getAnimationFPS());
|
_currentFrame += (deltaTime * getAnimationFPS());
|
||||||
|
@ -283,8 +283,6 @@ void ModelEntityItem::updateFrameCount() {
|
||||||
// qCDebug(entities) << "in update frame " << _currentFrame;
|
// qCDebug(entities) << "in update frame " << _currentFrame;
|
||||||
setAnimationCurrentFrame(_currentFrame);
|
setAnimationCurrentFrame(_currentFrame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModelEntityItem::debugDump() const {
|
void ModelEntityItem::debugDump() const {
|
||||||
|
|
Loading…
Reference in a new issue