X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Frender%2Fscene.h;h=8083239390fed6d765e546ae08ea2aadde14f2ce;hp=fcf5d33e8eb9645caccdbc9bff5f7d34a3427f27;hb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14;hpb=3ac3a51c623271da815c8ee60c484445871753bf diff --git a/source/render/scene.h b/source/render/scene.h index fcf5d33e..80832393 100644 --- a/source/render/scene.h +++ b/source/render/scene.h @@ -1,12 +1,11 @@ #ifndef MSP_GL_SCENE_H_ #define MSP_GL_SCENE_H_ -#include -#include +#include +#include #include #include "matrix.h" #include "renderable.h" -#include "vector.h" namespace Msp { namespace GL { @@ -29,10 +28,10 @@ protected: unsigned inst_counter; public: - Loader(Scene &, Collection &); - Loader(Scene &, Collection &, ContentMap &); + Loader(Scene &s, Collection &c): Loader(s, c, 0) { } + Loader(Scene &s, Collection &c, ContentMap &m) : Loader(s, c, &m) { } private: - void init(); + Loader(Scene &, Collection &, ContentMap *); void object(const std::string &); void object_tagged(const std::string &, const std::string &); @@ -40,47 +39,27 @@ protected: }; public: - class GenericLoader: public DataFile::Loader + class GenericLoader: public DataFile::DynamicObjectLoader { - private: - template - struct CreateScene - { - void operator()(const std::string &, GenericLoader &) const; - }; - - DataFile::Collection &coll; - Scene *scene; - Loader *scene_loader; - - static ActionMap shared_actions; + friend class Scene; public: - GenericLoader(DataFile::Collection &); - ~GenericLoader(); + GenericLoader(DataFile::Collection &c): DynamicObjectLoader(&c) { } - Scene *get_scene() { Scene *s = scene; scene = 0; return s; } - private: - virtual void init_actions(); - - void type(const DataFile::Symbol &); - - friend class Scene; + protected: + virtual const TypeRegistry &get_type_registry() const { return get_scene_registry(); } }; -private: - typedef TypeRegistry SceneRegistry; - protected: mutable Matrix culling_matrix; mutable Vector4 frustum_edges[6]; - Scene() { } + Scene() = default; private: Scene(const Scene &); Scene &operator=(const Scene &); public: - virtual ~Scene() { } + virtual ~Scene() = default; virtual void add(Renderable &) = 0; virtual void remove(Renderable &) = 0; @@ -93,7 +72,7 @@ public: template static void register_type(const std::string &); private: - static SceneRegistry &get_scene_registry(); + static GenericLoader::TypeRegistry &get_scene_registry(); }; template @@ -102,18 +81,6 @@ void Scene::register_type(const std::string &kw) get_scene_registry().register_type(kw); } -template -void Scene::GenericLoader::CreateScene::operator()(const std::string &, GenericLoader &ldr) const -{ - if(ldr.scene) - throw std::logic_error("Scene type was already specified"); - - T *scene = new T; - ldr.scene = scene; - ldr.scene_loader = new typename T::Loader(*scene, ldr.coll); - ldr.add_auxiliary_loader(*ldr.scene_loader); -} - } // namespace GL } // namespace Msp