From 745b3030d7fa32c1f6be29548f978af640eb4021 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 23 Feb 2010 14:42:09 +0000 Subject: [PATCH] Support collectionless loading of Technique and RenderPass --- source/object.cpp | 9 ++++++--- source/renderpass.cpp | 11 +++++++++++ source/renderpass.h | 2 ++ source/technique.cpp | 16 +++++++++++++++- source/technique.h | 2 ++ 5 files changed, 36 insertions(+), 4 deletions(-) diff --git a/source/object.cpp b/source/object.cpp index 0a03b7a8..2423fcda 100644 --- a/source/object.cpp +++ b/source/object.cpp @@ -125,9 +125,12 @@ void Object::Loader::mesh(const std::string &n) void Object::Loader::technique() { - RefPtr tch=new Technique; - load_sub(*tch, get_collection()); - obj.technique=tch.release(); + RefPtr tech=new Technique; + if(coll) + load_sub(*tech, get_collection()); + else + load_sub(*tech); + obj.technique=tech.release(); obj.own_technique=true; } diff --git a/source/renderpass.cpp b/source/renderpass.cpp index 9e5b71d9..06726086 100644 --- a/source/renderpass.cpp +++ b/source/renderpass.cpp @@ -111,8 +111,19 @@ void RenderPass::unbind() } +RenderPass::Loader::Loader(RenderPass &p): + DataFile::CollectionObjectLoader(p, 0) +{ + init(); +} + RenderPass::Loader::Loader(RenderPass &p, Collection &c): DataFile::CollectionObjectLoader(p, &c) +{ + init(); +} + +void RenderPass::Loader::init() { allow_pointer_reload=false; diff --git a/source/renderpass.h b/source/renderpass.h index 223f57dc..94c6bc02 100644 --- a/source/renderpass.h +++ b/source/renderpass.h @@ -28,9 +28,11 @@ public: class Loader: public DataFile::CollectionObjectLoader { public: + Loader(RenderPass &); Loader(RenderPass &, Collection &); private: + void init(); virtual void finish(); void material(); void shader(const std::string &); diff --git a/source/technique.cpp b/source/technique.cpp index 78060e01..d913f4d1 100644 --- a/source/technique.cpp +++ b/source/technique.cpp @@ -34,8 +34,19 @@ const RenderPass &Technique::get_pass(const GL::Tag &tag) const } +Technique::Loader::Loader(Technique &t): + DataFile::CollectionObjectLoader(t, 0) +{ + init(); +} + Technique::Loader::Loader(Technique &t, Collection &c): DataFile::CollectionObjectLoader(t, &c) +{ + init(); +} + +void Technique::Loader::init() { add("inherit", &Loader::inherit); add("pass", &Loader::pass); @@ -55,7 +66,10 @@ void Technique::Loader::pass(const string &n) throw KeyError("Duplicate pass name", n); RenderPass p; - load_sub(p, *coll); + if(coll) + load_sub(p, get_collection()); + else + load_sub(p); obj.passes.insert(PassMap::value_type(tag, p)); } diff --git a/source/technique.h b/source/technique.h index ce12b4f4..6633ad7d 100644 --- a/source/technique.h +++ b/source/technique.h @@ -25,9 +25,11 @@ public: class Loader: public Msp::DataFile::CollectionObjectLoader { public: + Loader(Technique &); Loader(Technique &, Collection &); private: + void init(); void inherit(const std::string &); void pass(const std::string &); }; -- 2.45.2