Note: compatibility-breaking change. Major version bump in next release.
{
}
-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();
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);
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)
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.
*/
template<typename Iter>
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)
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;
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);
const Object &get_object() const { return object; }
- virtual bool has_pass(const Tag &tag) const;
-
virtual void render(const Tag &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);
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 &);
public:
virtual ~Renderable() { }
- virtual bool has_pass(const Tag &tag) const =0;
virtual void render(const Tag &tag=Tag()) const =0;
};
void Scene::render(const Tag &tag) const
{
for(map<const Object *, set<const ObjectInstance *> >::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 Renderable *>::const_iterator i=renderables.begin(); i!=renderables.end(); ++i)
- if((*i)->has_pass(tag))
- (*i)->render(tag);
+ (*i)->render(tag);
}
} // namespace GL
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;
};