diff --git a/Mixer.cpp b/Mixer.cpp index 11f4188..6072a1e 100644 --- a/Mixer.cpp +++ b/Mixer.cpp @@ -125,7 +125,6 @@ Mixer::Mixer() : session_(nullptr), back_session_(nullptr), current_view_(nullpt setCurrentView( (View::Mode) Settings::application.current_view ); } - void Mixer::update() { // change session when threaded loading is finished @@ -140,6 +139,7 @@ void Mixer::update() Settings::application.recentSessions.push(sessionFilename_); } } + // confirm when threaded saving is finished if (sessionSaveFinished_) { sessionSaveFinished_ = false; @@ -155,16 +155,17 @@ void Mixer::update() float dt = static_cast( GST_TIME_AS_MSECONDS(current_time - update_time_) ) * 0.001f; update_time_ = current_time; - // update session and associted sources + // update session and associated sources session_->update(dt); // update views mixing_.update(dt); geometry_.update(dt); layer_.update(dt); - // TODO other views - + // TODO other views? + // optimize the reordering in depth for views + View::need_reordering_ = false; } void Mixer::draw() @@ -199,10 +200,8 @@ void Mixer::insertSource(Source *s) mixing_.scene.fg()->attach(s->group(View::MIXING)); geometry_.scene.fg()->attach(s->group(View::GEOMETRY)); layer_.scene.fg()->attach(s->group(View::LAYER)); - } - void Mixer::deleteCurrentSource() { deleteSource( currentSource() ); @@ -366,7 +365,6 @@ void Mixer::saveas(const std::string& filename) // launch a thread to save the session std::thread (saveSession, filename, session_).detach(); - } void Mixer::open(const std::string& filename) @@ -382,10 +380,8 @@ void Mixer::open(const std::string& filename) // launch a thread to load the session into back_session std::thread (loadSession, filename, back_session_).detach(); - } - void Mixer::swap() { if (!back_session_) @@ -434,7 +430,6 @@ void Mixer::swap() back_session_ = nullptr; } - void Mixer::newSession() { // delete previous back session if needed diff --git a/Scene.cpp b/Scene.cpp index eb9ac17..4a1e749 100644 --- a/Scene.cpp +++ b/Scene.cpp @@ -52,7 +52,6 @@ void Node::update( float ) { // update transform matrix from attributes transform_ = GlmToolkit::transform(translation_, rotation_, scale_); - } void Node::accept(Visitor& v) diff --git a/View.cpp b/View.cpp index 37816ff..76d3822 100644 --- a/View.cpp +++ b/View.cpp @@ -22,6 +22,8 @@ #define CIRCLE_PIXELS 64 #define CIRCLE_PIXEL_RADIUS 1024.0 +bool View::need_reordering_ = true; + View::View(Mode m) : mode_(m) { } @@ -43,8 +45,9 @@ void View::update(float dt) // recursive update from root of scene scene.update( dt ); - // reorder depth - scene.fg()->sort(); + // reorder depth if needed + if (View::need_reordering_) + scene.fg()->sort(); } void View::drag (glm::vec2 from, glm::vec2 to) @@ -84,7 +87,6 @@ MixingView::MixingView() : View(MIXING) Mesh *circle = new Mesh("mesh/circle.ply"); circle->shader()->color = pink; scene.bg()->attach(circle); - } MixingView::~MixingView() @@ -106,7 +108,6 @@ void MixingView::zoom( float factor ) scene.root()->scale_.y = z; } - void MixingView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair) { if (!s) @@ -133,7 +134,6 @@ void MixingView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pairtouch(); } - uint MixingView::textureMixingQuadratic() { static GLuint texid = 0; @@ -194,7 +194,6 @@ RenderView::~RenderView() delete frame_buffer_; } - void RenderView::setResolution(glm::vec3 resolution) { if (resolution.x < 128.f || resolution.y < 128.f) @@ -355,7 +354,6 @@ LayerView::LayerView() : View(LAYER), aspect_ratio(1.f) Frame *border = new Frame(Frame::ROUND_SHADOW); border->color = glm::vec4( 0.8f, 0.f, 0.8f, 0.7f ); scene.bg()->attach(border); - } LayerView::~LayerView() @@ -365,7 +363,6 @@ LayerView::~LayerView() void LayerView::draw () { - // update rendering of render frame FrameBuffer *output = Mixer::manager().session()->frame(); if (output) @@ -420,5 +417,8 @@ void LayerView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pairtouch(); + + // request reordering + View::need_reordering_ = true; } diff --git a/View.h b/View.h index e03f98d..042988a 100644 --- a/View.h +++ b/View.h @@ -27,6 +27,9 @@ public: Scene scene; + // hack to avoid reordering scene of view if not necessary + static bool need_reordering_; + protected: Mode mode_; }; @@ -60,7 +63,6 @@ public: glm::vec3 resolution() const { return frame_buffer_->resolution(); } inline FrameBuffer *frameBuffer () const { return frame_buffer_; } - }; class GeometryView : public View