mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 10:22:52 +01:00
Fix animation test case
This commit is contained in:
parent
1fb8162a7c
commit
330fa56b77
@ -72,7 +72,7 @@ void Animator::tick(float dt)
|
||||
|
||||
for( auto& b : boneInstances )
|
||||
{
|
||||
auto kf = b.first->getInterpolatedKeyframe(getAnimationTime());
|
||||
auto kf = b.first->getInterpolatedKeyframe(getAnimationTime(1.f));
|
||||
|
||||
auto& data = skeleton->getData(b.second.frameIdx);
|
||||
ModelFrame* frame = model->frames[b.second.frameIdx];
|
||||
@ -148,10 +148,16 @@ bool Animator::isCompleted() const
|
||||
|
||||
float Animator::getAnimationTime(float alpha) const
|
||||
{
|
||||
float td = serverTime - lastServerTime;
|
||||
if(repeat) {
|
||||
return fmod(serverTime + alpha, getAnimation()->duration);
|
||||
float t = serverTime + td * alpha;
|
||||
while( t > getAnimation()->duration )
|
||||
{
|
||||
t -= getAnimation()->duration;
|
||||
}
|
||||
return serverTime + alpha;
|
||||
return t;
|
||||
}
|
||||
return serverTime + td * alpha;
|
||||
}
|
||||
|
||||
void Animator::setAnimationTime(float time)
|
||||
|
@ -180,7 +180,7 @@ void CharacterObject::updateCharacter(float dt)
|
||||
glm::vec3 walkDir;
|
||||
glm::vec3 animTranslate;
|
||||
|
||||
if( isAnimationFixed() ) {
|
||||
if( isAnimationFixed() && animator->getAnimation() != nullptr ) {
|
||||
auto d = animator->getRootTranslation() / animator->getAnimation()->duration;
|
||||
animTranslate = d * dt;
|
||||
}
|
||||
|
@ -26,10 +26,10 @@ BOOST_AUTO_TEST_CASE(test_matrix)
|
||||
AnimationBone::RT0,
|
||||
{
|
||||
{
|
||||
glm::quat(), glm::vec3(0.f, 0.f, 0.f), glm::vec3(), 0.f,
|
||||
glm::quat(), glm::vec3(0.f, 0.f, 0.f), glm::vec3(), 0.f, 0
|
||||
},
|
||||
{
|
||||
glm::quat(), glm::vec3(0.f, 1.f, 0.f), glm::vec3(), 1.0f,
|
||||
glm::quat(), glm::vec3(0.f, 1.f, 0.f), glm::vec3(), 1.0f, 1
|
||||
},
|
||||
}
|
||||
};
|
||||
@ -45,7 +45,6 @@ BOOST_AUTO_TEST_CASE(test_matrix)
|
||||
|
||||
BOOST_CHECK( skeleton.getData(0).a.translation == glm::vec3(0.f, 1.f, 0.f) );
|
||||
BOOST_CHECK( skeleton.getData(0).b.translation == glm::vec3(0.f, 0.f, 0.f) );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user