From 6cbabebe65575a55e120acd6294da305765d5bbb Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Wed, 14 Apr 2021 18:26:39 +0300 Subject: [PATCH] Allow renderables to be specified in SequenceTemplate passes --- source/builders/sequencebuilder.cpp | 2 +- source/builders/sequencetemplate.cpp | 25 ++++++++++++++++++++----- source/builders/sequencetemplate.h | 10 ++++++---- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/source/builders/sequencebuilder.cpp b/source/builders/sequencebuilder.cpp index 3abfca81..658ded0b 100644 --- a/source/builders/sequencebuilder.cpp +++ b/source/builders/sequencebuilder.cpp @@ -16,7 +16,7 @@ SequenceBuilder::SequenceBuilder(const SequenceTemplate &t): { const vector &steps = tmpl.get_steps(); for(vector::const_iterator i=steps.begin(); i!=steps.end(); ++i) - renderables[i->slot_name] = 0; + renderables[i->slot_name] = i->default_renderable; const vector &postprocs = tmpl.get_postprocessors(); for(SequenceTemplate::PostProcessorArray::const_iterator i=postprocs.begin(); i!=postprocs.end(); ++i) if(!i->slot_name.empty()) diff --git a/source/builders/sequencetemplate.cpp b/source/builders/sequencetemplate.cpp index 46ffec70..f158c630 100644 --- a/source/builders/sequencetemplate.cpp +++ b/source/builders/sequencetemplate.cpp @@ -5,7 +5,9 @@ #include "bloom.h" #include "colorcurve.h" #include "lighting.h" +#include "object.h" #include "resources.h" +#include "scene.h" #include "sequencetemplate.h" #include "tests.h" @@ -75,9 +77,10 @@ SequenceTemplate::Loader::Loader(SequenceTemplate &t, Collection &c): add("multisample", &Loader::multisample_range); add("postprocessor", &Loader::postprocessor); add("step", &Loader::step); + add("step", &Loader::step_with_slot); // Deprecated - add("pass", &Loader::step); + add("pass", &Loader::step_with_slot); obj.resources = &c; } @@ -109,7 +112,12 @@ void SequenceTemplate::Loader::postprocessor(const string &slot) obj.postprocessors.push_back(pp); } -void SequenceTemplate::Loader::step(const string &tag, const string &rend) +void SequenceTemplate::Loader::step(const string &tag) +{ + step_with_slot(tag, string()); +} + +void SequenceTemplate::Loader::step_with_slot(const string &tag, const string &rend) { Step stp; stp.tag = tag; @@ -143,6 +151,8 @@ void SequenceTemplate::Step::Loader::init() add("depth_test", &Loader::depth_test_predefined); add("lighting", &Loader::lighting); add("lighting", &Loader::lighting_inline); + add("object", &Loader::object); + add("scene", &Loader::scene); } void SequenceTemplate::Step::Loader::blend_predefined(const string &name) @@ -196,10 +206,15 @@ void SequenceTemplate::Step::Loader::lighting(const string &name) obj.lighting.keep(); } -/*void SequenceTemplate::Step::Loader::scene(const string &name) +void SequenceTemplate::Step::Loader::object(const string &name) { - obj.default_renderable = get_collection().get(name); -}*/ + obj.default_renderable = &get_collection().get(name); +} + +void SequenceTemplate::Step::Loader::scene(const string &name) +{ + obj.default_renderable = &get_collection().get(name); +} } // namespace GL } // namespace Msp diff --git a/source/builders/sequencetemplate.h b/source/builders/sequencetemplate.h index 12ccd91d..596def50 100644 --- a/source/builders/sequencetemplate.h +++ b/source/builders/sequencetemplate.h @@ -14,6 +14,7 @@ namespace GL { class DepthTest; class Lighting; +class Renderable; class SequenceTemplate { @@ -55,7 +56,8 @@ public: void multisample(unsigned); void multisample_range(unsigned, unsigned); void postprocessor(const std::string &); - void step(const std::string &, const std::string &); + void step(const std::string &); + void step_with_slot(const std::string &, const std::string &); }; struct Step @@ -74,8 +76,8 @@ public: void depth_test_predefined(const std::string &); void lighting(const std::string &); void lighting_inline(); - // TODO requires support for scenes in Resources - //void scene(const std::string &); + void object(const std::string &); + void scene(const std::string &); }; std::string tag; @@ -83,7 +85,7 @@ public: RefPtr depth_test; RefPtr blend; std::string slot_name; - //Renderable *default_renderable; + Renderable *default_renderable; ~Step(); }; -- 2.45.2