X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Frender%2Fscene.cpp;h=4b7aee1a8574499b59c169b976fd34cf7dc22feb;hb=29f0d4ada51ff65c424398546e01e2884dba6ef3;hp=3c101b8a172cdba1fc421eecc5a182946bb3f308;hpb=f8bf444f26ce0bb392b96317ef3665be0af110aa;p=libs%2Fgl.git diff --git a/source/render/scene.cpp b/source/render/scene.cpp index 3c101b8a..4b7aee1a 100644 --- a/source/render/scene.cpp +++ b/source/render/scene.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "camera.h" #include "objectinstance.h" #include "occludedscene.h" @@ -72,9 +73,9 @@ bool Scene::frustum_cull(const Renderable &renderable) const return false; } -Scene::SceneRegistry &Scene::get_scene_registry() +Scene::GenericLoader::TypeRegistry &Scene::get_scene_registry() { - static SceneRegistry registry; + static Scene::GenericLoader::TypeRegistry registry; static bool initialized = false; if(!initialized) { @@ -88,24 +89,12 @@ Scene::SceneRegistry &Scene::get_scene_registry() } -Scene::Loader::Loader(Scene &s, Collection &c): - DataFile::CollectionObjectLoader(s, &c), - content(0) -{ - init(); -} +unsigned Scene::Loader::inline_counter = 0; -Scene::Loader::Loader(Scene &s, Collection &c, ContentMap &m): +Scene::Loader::Loader(Scene &s, Collection &c, ContentMap *m): DataFile::CollectionObjectLoader(s, &c), - content(&m) -{ - init(); -} - -void Scene::Loader::init() + content(m) { - inst_counter = 0; - add("object", &Loader::object); add("object", &Loader::object_tagged); add("scene", &Loader::scene); @@ -120,7 +109,7 @@ void Scene::Loader::object_tagged(const string &n, const string &t) { RefPtr inst = new ObjectInstance(get_collection().get(n)); load_sub(*inst); - get_collection().add(format("%s/%d.inst", FS::basename(get_source()), inst_counter++), inst.get()); + get_collection().add(format("_scene_object_%d.inst", ++inline_counter), inst.get()); if(content && !t.empty()) (*content)[t] = inst.get(); obj.add(*inst.release()); @@ -131,32 +120,5 @@ void Scene::Loader::scene(const string &n) obj.add(get_collection().get(n)); } - -DataFile::Loader::ActionMap Scene::GenericLoader::shared_actions; - -Scene::GenericLoader::GenericLoader(DataFile::Collection &c): - coll(c), - scene(0), - scene_loader(0) -{ - set_actions(shared_actions); -} - -Scene::GenericLoader::~GenericLoader() -{ - delete scene; - delete scene_loader; -} - -void Scene::GenericLoader::init_actions() -{ - add("type", &GenericLoader::type); -} - -void Scene::GenericLoader::type(const DataFile::Symbol &sym) -{ - get_scene_registry().invoke(sym.name, *this); -} - } // namespace GL } // namespace Msp