From e759062876ee7fc81d1c2f40818d5bf97898d53d Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Thu, 4 Feb 2010 07:59:12 +0000 Subject: [PATCH] Drop Renderable::has_pass; renderables are now expected to ignore unknown passes Note: compatibility-breaking change. Major version bump in next release. --- source/object.cpp | 22 ++++++++++++++-------- source/object.h | 6 ++++-- source/objectinstance.cpp | 5 ----- source/objectinstance.h | 2 -- source/pipeline.cpp | 5 ----- source/pipeline.h | 1 - source/renderable.h | 1 - source/scene.cpp | 6 ++---- source/scene.h | 1 - 9 files changed, 20 insertions(+), 29 deletions(-) diff --git a/source/object.cpp b/source/object.cpp index a23aa433..d5d5231b 100644 --- a/source/object.cpp +++ b/source/object.cpp @@ -34,16 +34,11 @@ Object::~Object() { } -bool Object::has_pass(const Tag &tag) const -{ - if(technique) - return technique->has_pass(tag); - else - return tag.id==0; -} - void Object::render(const Tag &tag) const { + if(!can_render(tag)) + return; + const ObjectPass *pass=get_pass(tag); setup_render(pass); meshes[0]->draw(); @@ -52,6 +47,9 @@ void Object::render(const Tag &tag) const void Object::render(const ObjectInstance &inst, const Tag &tag) const { + if(!can_render(tag)) + return; + const ObjectPass *pass=get_pass(tag); setup_render(pass); render_instance(inst, tag); @@ -59,6 +57,14 @@ void Object::render(const ObjectInstance &inst, const Tag &tag) const finish_render(pass); } +bool Object::can_render(const Tag &tag) const +{ + if(technique) + return technique->has_pass(tag); + else + return tag.id==0; +} + const ObjectPass *Object::get_pass(const Tag &tag) const { if(technique) diff --git a/source/object.h b/source/object.h index 9c1ea7f7..fff1e4cf 100644 --- a/source/object.h +++ b/source/object.h @@ -70,8 +70,6 @@ public: const Technique *get_technique() const { return technique; } - virtual bool has_pass(const Tag &) const; - /** Renders the object. A tag can be provided to render a non-default pass. */ @@ -93,6 +91,9 @@ public: template void render(Iter begin, Iter end, const Tag &tag=Tag()) const { + if(!can_render(tag)) + return; + const ObjectPass *pass=get_pass(tag); setup_render(pass); for(Iter i=begin; i!=end; ++i) @@ -100,6 +101,7 @@ public: finish_render(pass); } private: + bool can_render(const Tag &) const; const ObjectPass *get_pass(const Tag &) const; void setup_render(const ObjectPass *) const; void finish_render(const ObjectPass *) const; diff --git a/source/objectinstance.cpp b/source/objectinstance.cpp index 7552cc93..666d9005 100644 --- a/source/objectinstance.cpp +++ b/source/objectinstance.cpp @@ -18,11 +18,6 @@ ObjectInstance::ObjectInstance(const Object &obj): object(obj) { } -bool ObjectInstance::has_pass(const Tag &tag) const -{ - return object.has_pass(tag); -} - void ObjectInstance::render(const Tag &tag) const { object.render(*this, tag); diff --git a/source/objectinstance.h b/source/objectinstance.h index dbb8c627..602cbc24 100644 --- a/source/objectinstance.h +++ b/source/objectinstance.h @@ -35,8 +35,6 @@ public: const Object &get_object() const { return object; } - virtual bool has_pass(const Tag &tag) const; - virtual void render(const Tag &tag=Tag()) const; /** diff --git a/source/pipeline.cpp b/source/pipeline.cpp index ea8b56a3..5969246b 100644 --- a/source/pipeline.cpp +++ b/source/pipeline.cpp @@ -61,11 +61,6 @@ const PipelinePass &Pipeline::get_pass(const Tag &tag) const return i->second; } -bool Pipeline::has_pass(const Tag &tag) const -{ - return passes.count(tag.id); -} - void Pipeline::add_renderable(const Renderable &r) { renderables.push_back(&r); diff --git a/source/pipeline.h b/source/pipeline.h index 19bea10a..afa9ed5e 100644 --- a/source/pipeline.h +++ b/source/pipeline.h @@ -43,7 +43,6 @@ public: PipelinePass &add_pass(const Tag &tag); PipelinePass &get_pass(const Tag &tag); const PipelinePass &get_pass(const Tag &tag) const; - virtual bool has_pass(const Tag &tag) const; void add_renderable(const Renderable &); void add_effect(Effect &); diff --git a/source/renderable.h b/source/renderable.h index b83fdb0d..6e433d3e 100644 --- a/source/renderable.h +++ b/source/renderable.h @@ -21,7 +21,6 @@ protected: public: virtual ~Renderable() { } - virtual bool has_pass(const Tag &tag) const =0; virtual void render(const Tag &tag=Tag()) const =0; }; diff --git a/source/scene.cpp b/source/scene.cpp index 59f30411..c28192d4 100644 --- a/source/scene.cpp +++ b/source/scene.cpp @@ -41,12 +41,10 @@ void Scene::remove(const Renderable &r) void Scene::render(const Tag &tag) const { for(map >::const_iterator i=objects.begin(); i!=objects.end(); ++i) - if(i->first->has_pass(tag)) - i->first->render(i->second.begin(), i->second.end(), tag); + i->first->render(i->second.begin(), i->second.end(), tag); for(set::const_iterator i=renderables.begin(); i!=renderables.end(); ++i) - if((*i)->has_pass(tag)) - (*i)->render(tag); + (*i)->render(tag); } } // namespace GL diff --git a/source/scene.h b/source/scene.h index e6de1c23..05c5b678 100644 --- a/source/scene.h +++ b/source/scene.h @@ -28,7 +28,6 @@ public: void add(const Renderable &); void remove(const Renderable &); - virtual bool has_pass(const Tag &) const { return true; } virtual void render(const Tag &tag=Tag()) const; }; -- 2.45.2