time_since_keyframe += t;
while(time_since_keyframe>iter->delta_t)
{
- KeyFrameList::const_iterator next = iter;
+ vector<TimedKeyFrame>::const_iterator next = iter;
++next;
if(next==animation->keyframes.end())
{
void prepare();
};
- typedef std::list<TimedKeyFrame> KeyFrameList;
-
struct UniformInfo
{
std::string name;
{
private:
const Animation *animation;
- KeyFrameList::const_iterator iter;
+ std::vector<TimedKeyFrame>::const_iterator iter;
Time::TimeDelta time_since_keyframe;
bool end;
private:
const Armature *armature;
- KeyFrameList keyframes;
+ std::vector<TimedKeyFrame> keyframes;
bool looping;
std::vector<UniformInfo> uniforms;
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<AnimationSlot>::iterator j=i->second.animations.begin(); j!=i->second.animations.end(); ++j)
+ if(j->animation==&anim)
{
i->second.animations.erase(j);
break;
anim.iterator += dt;
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; i<n_uniforms; ++i)
- set_object_uniform(slot.object, anim.animation.get_uniform_name(i), anim.iterator.get_uniform(i));
+ set_object_uniform(slot.object, anim.animation->get_uniform_name(i), anim.iterator.get_uniform(i));
if(slot.armature)
{
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<AnimationSlot>::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; j<n_uniforms; ++j)
- set_object_uniform(slot.object, i->animation.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);
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<AnimationSlot>::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<AnimationSlot>::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;
}
AnimationPlayer::AnimationSlot::AnimationSlot(const Animation &a):
- animation(a),
- iterator(animation)
+ animation(&a),
+ iterator(*animation)
{ }
} // namespace GL
private:
struct AnimationSlot
{
- const Animation &animation;
+ const Animation *animation;
Animation::Iterator iterator;
AnimationSlot(const Animation &);
};
- typedef std::list<AnimationSlot> AnimationList;
-
struct ObjectSlot
{
AnimatedObject &object;
Matrix base_matrix;
const Armature *armature;
- AnimationList animations;
+ std::vector<AnimationSlot> animations;
bool stacked;
ObjectSlot(AnimatedObject &);
const Armature::Link &Armature::get_link(unsigned index) const
{
- for(list<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
+ for(vector<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
if(i->get_index()==index)
return *i;
throw key_error(typeid(list<Link>));
const Armature::Link &Armature::get_link(const string &name) const
{
- for(list<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
+ for(vector<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
if(i->get_name()==name)
return *i;
throw key_error(typeid(list<Link>));
unsigned Armature::get_max_link_index() const
{
unsigned max_index = 0;
- for(list<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
+ for(vector<Link>::const_iterator i=links.begin(); i!=links.end(); ++i)
max_index = max(max_index, i->get_index());
return max_index;
}
};
private:
- std::list<Link> links;
+ std::vector<Link> links;
public:
Link &add_link();
#ifndef MSP_GL_PROGRAM_H_
#define MSP_GL_PROGRAM_H_
-#include <list>
#include <string>
+#include <vector>
#include <msp/datafile/objectloader.h>
#include "bindable.h"
#include "gl.h"
LayoutHash layout_hash;
};
- typedef std::list<Shader *> ShaderList;
+ typedef std::vector<Shader *> ShaderList;
typedef std::map<std::string, UniformInfo> UniformMap;
typedef std::map<std::string, UniformBlockInfo> UniformBlockMap;
void ProgramCompiler::append_module(ProgramSyntax::Module &mod)
{
- list<Import *> imports = apply<NodeGatherer<Import> >(mod.shared);
- for(list<Import *>::iterator i=imports.begin(); i!=imports.end(); ++i)
+ vector<Import *> imports = apply<NodeGatherer<Import> >(mod.shared);
+ for(vector<Import *>::iterator i=imports.begin(); i!=imports.end(); ++i)
import((*i)->module);
apply<NodeRemover>(mod.shared, set<Node *>(imports.begin(), imports.end()));
struct BlockModifier: Visitor
{
bool remove_node;
- std::list<RefPtr<ProgramSyntax::Node> > insert_nodes;
+ std::vector<RefPtr<ProgramSyntax::Node> > insert_nodes;
BlockModifier();
template<typename T>
struct NodeGatherer: Visitor
{
- typedef std::list<T *> ResultType;
+ typedef std::vector<T *> ResultType;
- std::list<T *> nodes;
+ std::vector<T *> nodes;
const ResultType &get_result() const { return nodes; }
using Visitor::visit;
Scene::~Scene()
{
- for(list<Renderable *>::iterator i=owned_data.begin(); i!=owned_data.end(); ++i)
+ for(vector<Renderable *>::iterator i=owned_data.begin(); i!=owned_data.end(); ++i)
delete *i;
}
#ifndef MSP_GL_SCENE_H_
#define MSP_GL_SCENE_H_
-#include <list>
+#include <vector>
#include <msp/datafile/objectloader.h>
#include "matrix.h"
#include "renderable.h"
};
protected:
- std::list<Renderable *> owned_data;
+ std::vector<Renderable *> owned_data;
mutable Matrix culling_matrix;
mutable Vector4 frustum_edges[6];