X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frender%2Fscene.cpp;h=0f7737227e8da37c4ba69e0260d99f4e893b87c0;hp=87d8c423852ac749ec29a45e9af7331c5f214031;hb=77a534371433054384d213922a2e8c55f8a69ad6;hpb=5bb193f930fb8738d099d630c4d625d82c1215b5 diff --git a/source/render/scene.cpp b/source/render/scene.cpp index 87d8c423..0f773722 100644 --- a/source/render/scene.cpp +++ b/source/render/scene.cpp @@ -73,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) { @@ -89,27 +89,16 @@ 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) + content(m) { - init(); -} - -void Scene::Loader::init() -{ - inst_counter = 0; - add("object", &Loader::object); add("object", &Loader::object_tagged); add("scene", &Loader::scene); + add("scene", &Loader::scene_inline); } void Scene::Loader::object(const string &n) @@ -121,7 +110,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()); @@ -132,31 +121,12 @@ 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) +void Scene::Loader::scene_inline() { - get_scene_registry().invoke(sym.name, *this); + GenericLoader ldr(get_collection()); + load_sub_with(ldr); + Scene *scene = ldr.store_object(get_collection(), format("_scene_%d.scene", ++inline_counter)); + obj.add(*scene); } } // namespace GL