X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fanimationplayer.cpp;h=95b45dfd0ef5fc5869be3f62755f46888d04d27d;hp=0c00105276309f711569a0ae65a29347c0879b2a;hb=573ea4e5602c4321cc1d75daf9ed0beed5cde280;hpb=d093b45975eb03b07680711ce982ad634a50fba3 diff --git a/source/animationplayer.cpp b/source/animationplayer.cpp index 0c001052..95b45dfd 100644 --- a/source/animationplayer.cpp +++ b/source/animationplayer.cpp @@ -55,8 +55,8 @@ void AnimationPlayer::stop(AnimatedObject &obj, const Animation &anim) if(i==objects.end()) return; - for(AnimationList::iterator j=i->second.animations.begin(); j!=i->second.animations.end(); ++j) - if(&j->animation==&anim) + for(vector::iterator j=i->second.animations.begin(); j!=i->second.animations.end(); ++j) + if(j->animation==&anim) { i->second.animations.erase(j); break; @@ -85,20 +85,19 @@ void AnimationPlayer::tick(const Time::TimeDelta &dt) bool AnimationPlayer::tick_single(ObjectSlot &slot, const Time::TimeDelta &dt) { - AnimatedObject &obj = slot.object; AnimationSlot &anim = slot.animations.front(); anim.iterator += dt; - obj.set_matrix(anim.iterator.get_matrix()); + slot.object.set_matrix(anim.iterator.get_matrix()); - unsigned n_uniforms = anim.animation.get_n_uniforms(); + unsigned n_uniforms = anim.animation->get_n_uniforms(); for(unsigned i=0; iget_uniform_name(i), anim.iterator.get_uniform(i)); if(slot.armature) { unsigned max_index = slot.armature->get_max_link_index(); for(unsigned i=0; i<=max_index; ++i) - obj.set_pose_matrix(i, anim.iterator.get_pose_matrix(i)); + slot.object.set_pose_matrix(i, anim.iterator.get_pose_matrix(i)); } return !anim.iterator.is_end(); @@ -107,14 +106,14 @@ bool AnimationPlayer::tick_single(ObjectSlot &slot, const Time::TimeDelta &dt) bool AnimationPlayer::tick_stacked(ObjectSlot &slot, const Time::TimeDelta &dt) { Matrix matrix = slot.base_matrix; - for(AnimationList::iterator i=slot.animations.begin(); i!=slot.animations.end(); ++i) + for(vector::iterator i=slot.animations.begin(); i!=slot.animations.end(); ++i) { i->iterator += dt; matrix *= i->iterator.get_matrix(); - unsigned n_uniforms = i->animation.get_n_uniforms(); + unsigned n_uniforms = i->animation->get_n_uniforms(); for(unsigned j=0; janimation.get_uniform_name(j), i->iterator.get_uniform(j)); + set_object_uniform(slot.object, i->animation->get_uniform_name(j), i->iterator.get_uniform(j)); } slot.object.set_matrix(matrix); @@ -126,17 +125,17 @@ bool AnimationPlayer::tick_stacked(ObjectSlot &slot, const Time::TimeDelta &dt) matrix = Matrix(); /* XXX This is in all likelihood incorrect. The stacking should be performed on local matrices. */ - for(AnimationList::iterator j=slot.animations.begin(); j!=slot.animations.end(); ++j) - if(j->animation.get_armature()) + for(vector::iterator j=slot.animations.begin(); j!=slot.animations.end(); ++j) + if(j->animation->get_armature()) matrix *= j->iterator.get_pose_matrix(i); slot.object.set_pose_matrix(i, matrix); } } - for(AnimationList::iterator i=slot.animations.begin(); i!=slot.animations.end(); ) + for(vector::iterator i=slot.animations.begin(); i!=slot.animations.end(); ) { if(i->iterator.is_end()) - slot.animations.erase(i++); + i = slot.animations.erase(i); else ++i; } @@ -167,8 +166,8 @@ AnimationPlayer::ObjectSlot::ObjectSlot(AnimatedObject &o): AnimationPlayer::AnimationSlot::AnimationSlot(const Animation &a): - animation(a), - iterator(animation) + animation(&a), + iterator(*animation) { } } // namespace GL