+#include <msp/core/maputils.h>
#include "blend.h"
#include "camera.h"
#include "effect.h"
-#include "except.h"
#include "framebuffer.h"
#include "lighting.h"
#include "pipeline.h"
PipelinePass &Pipeline::add_pass(const Tag &tag)
{
- if(passes.count(tag))
- throw KeyError("Pass already exists");
-
- PipelinePass &pass = passes[tag];
+ PipelinePass &pass = insert_unique(passes, tag, PipelinePass())->second;
pass_order.push_back(tag);
return pass;
}
PipelinePass &Pipeline::get_pass(const Tag &tag)
{
- PassMap::iterator i = passes.find(tag);
- if(i==passes.end())
- throw KeyError("Unknown pass");
- return i->second;
+ return get_item(passes, tag);
}
const PipelinePass &Pipeline::get_pass(const Tag &tag) const
{
- PassMap::const_iterator i = passes.find(tag);
- if(i==passes.end())
- throw KeyError("Unknown pass");
- return i->second;
+ return get_item(passes, tag);
}
void Pipeline::add_renderable(const Renderable &r)
RenderPass &Technique::add_pass(const GL::Tag &tag)
{
- if(passes.count(tag))
- throw KeyError("Duplicate pass");
-
- return passes[tag];
+ return insert_unique(passes, tag, RenderPass())->second;
}
bool Technique::has_pass(const GL::Tag &tag) const
const RenderPass &Technique::get_pass(const GL::Tag &tag) const
{
- PassMap::const_iterator i = passes.find(tag);
- if(i==passes.end())
- throw KeyError("Unknown pass");
- return i->second;
+ return get_item(passes, tag);
}
void Technique::Loader::pass(const string &n)
{
- Tag tag(n);
- if(obj.passes.count(tag))
- throw KeyError("Duplicate pass name", n);
-
RenderPass p;
if(coll)
load_sub(p, get_collection());
else
load_sub(p);
- obj.passes.insert(PassMap::value_type(tag, p));
+
+ insert_unique(obj.passes, n, p);
}