]> git.tdb.fi Git - libs/gl.git/blobdiff - source/scene.cpp
Keep track of which components have been set in Transform
[libs/gl.git] / source / scene.cpp
index 9d301fbfb0801ab3d1ea95b5104d88f81b94d902..e6c62e802f8c9672fafce477d3eae50c9f2efaac 100644 (file)
@@ -11,7 +11,7 @@ namespace GL {
 
 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;
 }
 
@@ -40,7 +40,7 @@ bool Scene::setup_frustum(const Renderer &renderer) const
                frustum_edges[0] = Vector4(0, 1/s, y/s, 0);
                frustum_edges[1] = Vector4(0, -1/s, y/s, 0);
 
-               float x = y*camera->get_aspect();
+               float x = y*camera->get_aspect_ratio();
                s = sqrt(x*x+1);
                frustum_edges[2] = Vector4(1/s, 0, x/s, 0);
                frustum_edges[3] = Vector4(-1/s, 0, x/s, 0);
@@ -75,16 +75,37 @@ bool Scene::frustum_cull(const Renderable &renderable) const
 
 
 Scene::Loader::Loader(Scene &s, Collection &c):
-       DataFile::CollectionObjectLoader<Scene>(s, &c)
+       DataFile::CollectionObjectLoader<Scene>(s, &c),
+       content(0)
+{
+       init();
+}
+
+Scene::Loader::Loader(Scene &s, Collection &c, ContentMap &m):
+       DataFile::CollectionObjectLoader<Scene>(s, &c),
+       content(&m)
+{
+       init();
+}
+
+void Scene::Loader::init()
 {
        add("object", &Loader::object);
+       add("object", &Loader::object_tagged);
 }
 
 void Scene::Loader::object(const string &n)
+{
+       object_tagged(n, string());
+}
+
+void Scene::Loader::object_tagged(const string &n, const string &t)
 {
        RefPtr<AnimatedObject> anob = new AnimatedObject(get_collection().get<GL::Object>(n));
        load_sub(*anob);
        obj.add(*anob);
+       if(content && !t.empty())
+               (*content)[t] = anob.get();
        obj.owned_data.push_back(anob.release());
 }