From: John Tsiombikas Date: Thu, 18 Jan 2018 06:43:22 +0000 (+0200) Subject: exhibit drawing is now handled by the Renderer X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=laserbrain_demo;a=commitdiff_plain;h=37b68f014b46922b885c6344d6b069cba3c9c3c5 exhibit drawing is now handled by the Renderer --- diff --git a/src/blob_exhibit.cc b/src/blob_exhibit.cc index 35552e4..cd29e96 100644 --- a/src/blob_exhibit.cc +++ b/src/blob_exhibit.cc @@ -140,6 +140,12 @@ void BlobExhibit::draw() const glEnable(GL_TEXTURE_GEN_S); glEnable(GL_TEXTURE_GEN_T); + if(node) { + glMatrixMode(GL_MODELVIEW); + glPushMatrix(); + glMultMatrixf(node->get_matrix()[0]); + } + glMatrixMode(GL_TEXTURE); glLoadIdentity(); glScalef(1, -1, 1); @@ -183,6 +189,9 @@ void BlobExhibit::draw() const glLoadIdentity(); glMatrixMode(GL_MODELVIEW); + if(node) { + glPopMatrix(); + } glPopAttrib(); } diff --git a/src/exhibit.cc b/src/exhibit.cc index 8403550..2e81854 100644 --- a/src/exhibit.cc +++ b/src/exhibit.cc @@ -1,8 +1,6 @@ #include "exhibit.h" #include "snode.h" #include "scene.h" -#include "geomdraw.h" -#include "app.h" ExSelection ExSelection::null; @@ -70,33 +68,6 @@ void Exhibit::update(float dt) { } -void Exhibit::pre_draw() const -{ - if(node) { - glMatrixMode(GL_MODELVIEW); - glPushMatrix(); - glMultMatrixf(node->get_matrix()[0]); - } -} - -void Exhibit::draw() const -{ -} - -void Exhibit::post_draw() const -{ - if(node) { - glMatrixMode(GL_MODELVIEW); - glPopMatrix(); - - if(exsel_hover.ex == this) { - const AABox &bvol = get_aabox(); - draw_geom_object(&bvol); - } - } -} - - const AABox &Exhibit::get_aabox() const { aabb = node->get_bounds(); diff --git a/src/exhibit.h b/src/exhibit.h index fd1d77b..9b5c753 100644 --- a/src/exhibit.h +++ b/src/exhibit.h @@ -77,10 +77,6 @@ public: virtual void update(float dt = 0.0f) override; - virtual void pre_draw() const; - virtual void draw() const override; - virtual void post_draw() const; - virtual const AABox &get_aabox() const override; }; diff --git a/src/exman.cc b/src/exman.cc index d6cac9c..31ee1ae 100644 --- a/src/exman.cc +++ b/src/exman.cc @@ -4,6 +4,8 @@ #include "exhibit.h" #include "blob_exhibit.h" #include "treestore.h" +#include "app.h" +#include "geomdraw.h" static Exhibit *create_exhibit(const char *type); @@ -114,13 +116,10 @@ ExhibitManager::~ExhibitManager() void ExhibitManager::clear() { - int num = (int)items.size(); - for(int i=0; i::iterator it = std::find(items.begin(), items.end(), ex); if(it == items.end()) { items.push_back(ex); + own_scn->add_object(ex); + if(ex->node) own_scn->add_node(ex->node); } } @@ -142,6 +143,8 @@ bool ExhibitManager::remove(Exhibit *ex) std::vector::iterator it = std::find(items.begin(), items.end(), ex); if(it != items.end()) { items.erase(it); + own_scn->remove_object(ex); + if(ex->node) own_scn->remove_node(ex->node); return true; } return false; @@ -156,8 +159,10 @@ bool ExhibitManager::load(MetaScene *mscn, const char *fname) return false; } - // create our own scene to manage all exhibits not already in an existing scene - // and add it to the metascene + /* create our own scene to manage all exhibits not already in an existing scene + * and add it to the metascene. + * Also exhibit drawing happens due to the renderer drawing the metascene + */ if(!own_scn) { own_scn = new Scene; own_scn->name = "ad-hoc exhibits"; @@ -192,13 +197,15 @@ bool ExhibitManager::load(MetaScene *mscn, const char *fname) } } + // add everything to our data structures + // equivalent to add_exhibit(ex), but without all the searching + own_scn->add_object(ex); if(!snode) { snode = new SceneNode; snode->set_name(ex->get_name()); own_scn->add_node(snode); } ex->set_node(snode); - items.push_back(ex); float *apos = ts_get_attr_vec(node, "pos"); @@ -336,9 +343,10 @@ void ExhibitManager::draw() const { int num = items.size(); for(int i=0; ipre_draw(); - items[i]->draw(); - items[i]->post_draw(); + if(exsel_hover.ex == items[i]) { + const AABox &bvol = items[i]->get_aabox(); + draw_geom_object(&bvol); + } } }