From: Mikko Rasa Date: Sat, 30 Oct 2021 19:59:09 +0000 (+0300) Subject: Rename "renderable" to "content" in Effects and Scenes X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=bdcae47bf2f4e49d2d9e4ba15e6f17171ce5fa0c;p=libs%2Fgl.git Rename "renderable" to "content" in Effects and Scenes This name better describes the relationship. --- diff --git a/source/effects/effect.cpp b/source/effects/effect.cpp index e59aeed8..878e23fb 100644 --- a/source/effects/effect.cpp +++ b/source/effects/effect.cpp @@ -4,8 +4,8 @@ namespace Msp { namespace GL { -Effect::Effect(Renderable &r): - renderable(r) +Effect::Effect(Renderable &c): + content(c) { enable_for_method(Tag()); } diff --git a/source/effects/effect.h b/source/effects/effect.h index ac458361..e77b4cf5 100644 --- a/source/effects/effect.h +++ b/source/effects/effect.h @@ -44,7 +44,7 @@ public: }; protected: - Renderable &renderable; + Renderable &content; std::vector enabled_methods; protected: @@ -56,11 +56,11 @@ public: void disable_for_method(Tag); bool is_enabled_for_method(Tag) const; - virtual const Matrix *get_matrix() const { return renderable.get_matrix(); } - virtual const Geometry::BoundingSphere *get_bounding_sphere() const { return renderable.get_bounding_sphere(); } + virtual const Matrix *get_matrix() const { return content.get_matrix(); } + virtual const Geometry::BoundingSphere *get_bounding_sphere() const { return content.get_bounding_sphere(); } - virtual void setup_frame(Renderer &r) { renderable.setup_frame(r); } - virtual void finish_frame() { renderable.finish_frame(); } + virtual void setup_frame(Renderer &r) { content.setup_frame(r); } + virtual void finish_frame() { content.finish_frame(); } virtual void set_debug_name(const std::string &) = 0; }; diff --git a/source/effects/environmentmap.cpp b/source/effects/environmentmap.cpp index b1a50ecc..614b1252 100644 --- a/source/effects/environmentmap.cpp +++ b/source/effects/environmentmap.cpp @@ -13,12 +13,12 @@ using namespace std; namespace Msp { namespace GL { -EnvironmentMap::EnvironmentMap(unsigned s, PixelFormat f, Renderable &r, Renderable &e): - EnvironmentMap(s, f, 1, r, e) +EnvironmentMap::EnvironmentMap(unsigned s, PixelFormat f, Renderable &c, Renderable &e): + EnvironmentMap(s, f, 1, c, e) { } -EnvironmentMap::EnvironmentMap(unsigned s, PixelFormat f, unsigned l, Renderable &r, Renderable &e): - Effect(r), +EnvironmentMap::EnvironmentMap(unsigned s, PixelFormat f, unsigned l, Renderable &c, Renderable &e): + Effect(c), size(s), environment(e), irradiance_shprog(Resources::get_global().get("_envmap_irradiance.glsl.shader")), @@ -106,7 +106,7 @@ void EnvironmentMap::setup_frame(Renderer &renderer) return; rendered = true; - renderable.setup_frame(renderer); + content.setup_frame(renderer); if(update_delay) { @@ -124,7 +124,7 @@ void EnvironmentMap::setup_frame(Renderer &renderer) center = fixed_position; else { - const Matrix *matrix = renderable.get_matrix(); + const Matrix *matrix = content.get_matrix(); if(!matrix) return; @@ -160,7 +160,7 @@ void EnvironmentMap::finish_frame() if(rendered) { rendered = false; - renderable.finish_frame(); + content.finish_frame(); environment.finish_frame(); } } @@ -170,14 +170,14 @@ void EnvironmentMap::render(Renderer &renderer, Tag tag) const if(in_setup_frame) return; if(!is_enabled_for_method(tag)) - return renderable.render(renderer, tag); + return content.render(renderer, tag); Renderer::Push _push_rend(renderer); renderer.set_texture("environment_map", &env_tex, &mip_sampler); renderer.set_texture("irradiance_map", &irradiance, &sampler); renderer.add_shader_data(shdata); - renderable.render(renderer, tag); + content.render(renderer, tag); } void EnvironmentMap::set_debug_name(const string &name) diff --git a/source/effects/shadowmap.cpp b/source/effects/shadowmap.cpp index 6b926dd8..ddb78aeb 100644 --- a/source/effects/shadowmap.cpp +++ b/source/effects/shadowmap.cpp @@ -12,8 +12,8 @@ using namespace std; namespace Msp { namespace GL { -ShadowMap::ShadowMap(unsigned w, unsigned h, Renderable &r, const Lighting *l): - Effect(r), +ShadowMap::ShadowMap(unsigned w, unsigned h, Renderable &c, const Lighting *l): + Effect(c), width(w), height(h), lighting(l), @@ -38,10 +38,10 @@ ShadowMap::ShadowMap(unsigned w, unsigned h, Renderable &r, const Lighting *l): shdata.uniform_array("shd_world_matrix", 1, &dummy_matrix); } -ShadowMap::ShadowMap(unsigned s, Renderable &r, const DirectionalLight &l, Renderable &c): - ShadowMap(s, s, r, 0) +ShadowMap::ShadowMap(unsigned s, Renderable &c, const DirectionalLight &l, Renderable &sc): + ShadowMap(s, s, c, 0) { - add_light(l, s, c); + add_light(l, s, sc); } ShadowMap::ShadowMap(unsigned w, unsigned h, Renderable &r, const Lighting &l): @@ -183,7 +183,7 @@ void ShadowMap::setup_frame(Renderer &renderer) return; rendered = true; - renderable.setup_frame(renderer); + content.setup_frame(renderer); for(const ShadowedLight &l: lights) l.shadow_caster->setup_frame(renderer); @@ -244,20 +244,20 @@ void ShadowMap::finish_frame() if(rendered) { rendered = false; - renderable.finish_frame(); + content.finish_frame(); } } void ShadowMap::render(Renderer &renderer, Tag tag) const { if(!is_enabled_for_method(tag)) - return renderable.render(renderer, tag); + return content.render(renderer, tag); Renderer::Push _push_rend(renderer); renderer.set_texture("shadow_map", &depth_buf, &sampler); renderer.add_shader_data(shdata); - renderable.render(renderer, tag); + content.render(renderer, tag); } void ShadowMap::set_debug_name(const string &name) diff --git a/source/effects/sky.cpp b/source/effects/sky.cpp index 0744e7b9..2e5a6e18 100644 --- a/source/effects/sky.cpp +++ b/source/effects/sky.cpp @@ -13,8 +13,8 @@ using namespace std; namespace Msp { namespace GL { -Sky::Sky(Renderable &r, DirectionalLight &s): - Effect(r), +Sky::Sky(Renderable &c, DirectionalLight &s): + Effect(c), sun(s), transmittance_lookup(128, 64, (COLOR_ATTACHMENT,RGB16F)), transmittance_shprog(Resources::get_global().get("_sky_transmittance.glsl.shader")), @@ -116,7 +116,7 @@ void Sky::setup_frame(Renderer &renderer) renderer.set_texture("transmittance_lookup", &transmittance_lookup.get_target_texture(0), &sampler); fullscreen_mesh.draw(renderer); - renderable.setup_frame(renderer); + content.setup_frame(renderer); } void Sky::finish_frame() @@ -124,13 +124,13 @@ void Sky::finish_frame() if(rendered) { rendered = false; - renderable.finish_frame(); + content.finish_frame(); } } void Sky::render(Renderer &renderer, Tag tag) const { - renderable.render(renderer, tag); + content.render(renderer, tag); if(!is_enabled_for_method(tag)) return; diff --git a/source/render/occludedscene.cpp b/source/render/occludedscene.cpp index bfe17349..0d8a5b85 100644 --- a/source/render/occludedscene.cpp +++ b/source/render/occludedscene.cpp @@ -21,20 +21,20 @@ OccludedScene::OccludedScene(): void OccludedScene::add(Renderable &r) { - auto i = lower_bound(renderables, &r); - if(i==renderables.end() || *i!=&r) + auto i = lower_bound(content, &r); + if(i==content.end() || *i!=&r) { - renderables.insert(i, &r); + content.insert(i, &r); cache_dirty = true; } } void OccludedScene::remove(Renderable &r) { - auto i = lower_bound(renderables, &r); - if(i!=renderables.end() && *i==&r) + auto i = lower_bound(content, &r); + if(i!=content.end() && *i==&r) { - renderables.erase(i); + content.erase(i); cache_dirty = true; } } @@ -44,13 +44,13 @@ void OccludedScene::populate_cache() const if(!cache_dirty) return; - if(queries.get_size()renderable = r; for(; j!=occluded_cache.end(); ++j) { @@ -76,7 +76,7 @@ void OccludedScene::finish_frame() void OccludedScene::render(Renderer &renderer, Tag tag) const { - if(renderables.empty()) + if(content.empty()) return; populate_cache(); @@ -119,7 +119,7 @@ void OccludedScene::render(Renderer &renderer, Tag tag) const } // Move all objects within the frustum to the beginning of the array - for(auto i=occluded_cache.begin(), j=i+renderables.size()-1; i!=j; ) + for(auto i=occluded_cache.begin(), j=i+content.size()-1; i!=j; ) { if(i->in_frustum) ++i; diff --git a/source/render/occludedscene.h b/source/render/occludedscene.h index 2e24db5e..1f447c39 100644 --- a/source/render/occludedscene.h +++ b/source/render/occludedscene.h @@ -39,7 +39,7 @@ private: const Program &bounding_shader; Blend no_color_write; DepthTest no_depth_write = { LEQUAL, false }; - std::vector renderables; + std::vector content; float occluder_min_size = 0.25f; mutable QueryPool queries; mutable std::vector occluded_cache; diff --git a/source/render/orderedscene.cpp b/source/render/orderedscene.cpp index 2d018c70..48ad7d64 100644 --- a/source/render/orderedscene.cpp +++ b/source/render/orderedscene.cpp @@ -7,42 +7,42 @@ namespace GL { void OrderedScene::add(Renderable &r) { - renderables.push_back(&r); + content.push_back(&r); } void OrderedScene::remove(Renderable &r) { - auto end = std::remove(renderables.begin(), renderables.end(), &r); - renderables.erase(end, renderables.end()); + auto end = std::remove(content.begin(), content.end(), &r); + content.erase(end, content.end()); } void OrderedScene::prepend(Renderable &r) { - renderables.insert(renderables.begin(), &r); + content.insert(content.begin(), &r); } void OrderedScene::insert(unsigned index, Renderable &r) { - auto i = renderables.begin(); - for(; (i!=renderables.end() && index); ++i, --index) ; - renderables.insert(i, &r); + auto i = content.begin(); + for(; (i!=content.end() && index); ++i, --index) ; + content.insert(i, &r); } void OrderedScene::insert_after(Renderable &after, Renderable &r) { - auto i = find(renderables, &after); - renderables.insert(i, &r); + auto i = find(content, &after); + content.insert(i, &r); } void OrderedScene::setup_frame(Renderer &renderer) { - for(Renderable *r: renderables) + for(Renderable *r: content) r->setup_frame(renderer); } void OrderedScene::finish_frame() { - for(Renderable *r: renderables) + for(Renderable *r: content) r->finish_frame(); } @@ -50,13 +50,13 @@ void OrderedScene::render(Renderer &renderer, Tag tag) const { if(setup_frustum(renderer)) { - for(Renderable *r: renderables) + for(Renderable *r: content) if(!frustum_cull(*r)) r->render(renderer, tag); } else { - for(Renderable *r: renderables) + for(Renderable *r: content) r->render(renderer, tag); } } diff --git a/source/render/orderedscene.h b/source/render/orderedscene.h index a4e5631b..b7fa8c6c 100644 --- a/source/render/orderedscene.h +++ b/source/render/orderedscene.h @@ -16,7 +16,7 @@ public: using Scene::Loader; private: - std::vector renderables; + std::vector content; public: virtual void add(Renderable &); diff --git a/source/render/simplescene.cpp b/source/render/simplescene.cpp index fbdb004f..68db812b 100644 --- a/source/render/simplescene.cpp +++ b/source/render/simplescene.cpp @@ -7,27 +7,27 @@ namespace GL { void SimpleScene::add(Renderable &r) { - auto i = lower_bound(renderables, &r); - if(i==renderables.end() || *i!=&r) - renderables.insert(i, &r); + auto i = lower_bound(content, &r); + if(i==content.end() || *i!=&r) + content.insert(i, &r); } void SimpleScene::remove(Renderable &r) { - auto i = find(renderables, &r); - if(i!=renderables.end()) - renderables.erase(i); + auto i = find(content, &r); + if(i!=content.end()) + content.erase(i); } void SimpleScene::setup_frame(Renderer &renderer) { - for(Renderable *r: renderables) + for(Renderable *r: content) r->setup_frame(renderer); } void SimpleScene::finish_frame() { - for(Renderable *r: renderables) + for(Renderable *r: content) r->finish_frame(); } @@ -35,13 +35,13 @@ void SimpleScene::render(Renderer &renderer, Tag tag) const { if(setup_frustum(renderer)) { - for(Renderable *r: renderables) + for(Renderable *r: content) if(!frustum_cull(*r)) r->render(renderer, tag); } else { - for(Renderable *r: renderables) + for(Renderable *r: content) r->render(renderer, tag); } } diff --git a/source/render/simplescene.h b/source/render/simplescene.h index ce2a1546..174a9e2e 100644 --- a/source/render/simplescene.h +++ b/source/render/simplescene.h @@ -16,7 +16,7 @@ public: using Scene::Loader; private: - std::vector renderables; + std::vector content; public: virtual void add(Renderable &); diff --git a/source/render/slot.cpp b/source/render/slot.cpp index adbf535e..eb2a2e3e 100644 --- a/source/render/slot.cpp +++ b/source/render/slot.cpp @@ -4,37 +4,37 @@ namespace Msp { namespace GL { -void Slot::set(Renderable *r) +void Slot::set(Renderable *c) { - renderable = r; + content = c; } const Matrix *Slot::get_matrix() const { - return renderable ? renderable->get_matrix() : 0; + return content ? content->get_matrix() : 0; } const Geometry::BoundingSphere *Slot::get_bounding_sphere() const { - return renderable ? renderable->get_bounding_sphere() : 0; + return content ? content->get_bounding_sphere() : 0; } void Slot::setup_frame(Renderer &renderer) { - if(renderable) - renderable->setup_frame(renderer); + if(content) + content->setup_frame(renderer); } void Slot::finish_frame() { - if(renderable) - renderable->finish_frame(); + if(content) + content->finish_frame(); } void Slot::render(Renderer &renderer, Tag tag) const { - if(renderable) - renderable->render(renderer, tag); + if(content) + content->render(renderer, tag); } } // namespace GL diff --git a/source/render/slot.h b/source/render/slot.h index 40dfd758..a675c64f 100644 --- a/source/render/slot.h +++ b/source/render/slot.h @@ -13,11 +13,11 @@ needs to be switched without affecting the rest. class Slot: public Renderable { private: - Renderable *renderable = 0; + Renderable *content = 0; public: void set(Renderable *); - Renderable *get() const { return renderable; } + Renderable *get() const { return content; } virtual const Matrix *get_matrix() const; virtual const Geometry::BoundingSphere *get_bounding_sphere() const; diff --git a/source/render/zsortedscene.cpp b/source/render/zsortedscene.cpp index af3c5b86..25255dc6 100644 --- a/source/render/zsortedscene.cpp +++ b/source/render/zsortedscene.cpp @@ -10,10 +10,10 @@ namespace GL { void ZSortedScene::add(Renderable &r) { - auto i = lower_bound(renderables, &r); - if(i==renderables.end() || *i!=&r) + auto i = lower_bound(content, &r); + if(i==content.end() || *i!=&r) { - renderables.insert(i, &r); + content.insert(i, &r); if(!sorted_cache.empty()) sorted_cache.push_back(&r); } @@ -21,10 +21,10 @@ void ZSortedScene::add(Renderable &r) void ZSortedScene::remove(Renderable &r) { - auto i = lower_bound(renderables, &r); - if(i!=renderables.end() && *i==&r) + auto i = lower_bound(content, &r); + if(i!=content.end() && *i==&r) { - renderables.erase(i); + content.erase(i); sorted_cache.clear(); } } @@ -41,10 +41,10 @@ void ZSortedScene::set_reference(DepthReference r) void ZSortedScene::populate_cache() const { - if(sorted_cache.empty() && !renderables.empty()) + if(sorted_cache.empty() && !content.empty()) { - sorted_cache.reserve(renderables.size()); - sorted_cache.insert(sorted_cache.end(), renderables.begin(), renderables.end()); + sorted_cache.reserve(content.size()); + sorted_cache.insert(sorted_cache.end(), content.begin(), content.end()); } } @@ -63,7 +63,7 @@ void ZSortedScene::finish_frame() void ZSortedScene::render(Renderer &renderer, Tag tag) const { - if(renderables.empty()) + if(content.empty()) return; populate_cache(); diff --git a/source/render/zsortedscene.h b/source/render/zsortedscene.h index 277d62cf..778b097e 100644 --- a/source/render/zsortedscene.h +++ b/source/render/zsortedscene.h @@ -45,7 +45,7 @@ private: bool operator<(const SortedRenderable &o) const { return depth renderables; + std::vector content; SortOrder order = BACK_TO_FRONT; DepthReference reference = FURTHEST; mutable std::vector sorted_cache;