Navigation Menu

Skip to content

Commit

Permalink
Refactor|libgui|ModelDrawable: Calculating animation time
Browse files Browse the repository at this point in the history
The model animator may use more advanced logic to determine the
current time of the animation, so allow overriding the default time.
  • Loading branch information
skyjake committed Aug 5, 2014
1 parent db143ac commit 4409d6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 9 additions & 0 deletions doomsday/libgui/include/de/graphics/modeldrawable.h
Expand Up @@ -124,6 +124,15 @@ class LIBGUI_PUBLIC ModelDrawable : public AssetGroup
*/
virtual void advanceTime(TimeDelta const &elapsed);

/**
* Returns the time to be used when drawing the model.
*
* @param index Animation index.
*
* @return Time in the model's animation sequence.
*/
virtual ddouble currentTime(int index) const;

private:
DENG2_PRIVATE(d)
};
Expand Down
7 changes: 6 additions & 1 deletion doomsday/libgui/src/graphics/modeldrawable.cpp
Expand Up @@ -776,7 +776,7 @@ DENG2_PIMPL(ModelDrawable)
DENG2_ASSERT(duint(anim.animId) < scene->mNumAnimations);
DENG2_ASSERT(nodeNameToPtr.contains(anim.node));

accumulateAnimationTransforms(anim.time,
accumulateAnimationTransforms(animation->currentTime(i),
*scene->mAnimations[anim.animId],
*nodeNameToPtr[anim.node]);
}
Expand Down Expand Up @@ -1057,4 +1057,9 @@ void ModelDrawable::Animator::advanceTime(TimeDelta const &)
// overridden
}

ddouble ModelDrawable::Animator::currentTime(int index) const
{
return at(index).time;
}

} // namespace de

0 comments on commit 4409d6d

Please sign in to comment.