mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Bugfix Views
This commit is contained in:
@@ -119,6 +119,8 @@ Mixer::Mixer() : session_(nullptr), back_session_(nullptr), current_view_(nullpt
|
||||
{
|
||||
// unsused initial empty session
|
||||
session_ = new Session;
|
||||
current_source_ = session_->end();
|
||||
current_source_index_ = -1;
|
||||
|
||||
// auto load if Settings ask to
|
||||
if ( Settings::application.recentSessions.load_at_start &&
|
||||
@@ -163,7 +165,7 @@ void Mixer::update()
|
||||
layer_.update(dt);
|
||||
|
||||
// optimize the reordering in depth for views
|
||||
View::need_reordering_ = false;
|
||||
View::need_deep_update_ = false;
|
||||
}
|
||||
|
||||
void Mixer::draw()
|
||||
@@ -437,7 +439,7 @@ void Mixer::swap()
|
||||
session_->setResolution( session_->config(View::RENDERING)->scale_ );
|
||||
|
||||
// request reordering in depth for views
|
||||
View::need_reordering_ = true;
|
||||
View::need_deep_update_ = true;
|
||||
|
||||
// no current source
|
||||
current_source_ = session_->end();
|
||||
|
||||
60
View.cpp
60
View.cpp
@@ -22,7 +22,7 @@
|
||||
#define CIRCLE_PIXELS 64
|
||||
#define CIRCLE_PIXEL_RADIUS 1024.0
|
||||
|
||||
bool View::need_reordering_ = true;
|
||||
bool View::need_deep_update_ = true;
|
||||
|
||||
View::View(Mode m) : mode_(m)
|
||||
{
|
||||
@@ -40,15 +40,23 @@ void View::saveSettings()
|
||||
Settings::application.views[mode_].default_translation = scene.root()->translation_;
|
||||
}
|
||||
|
||||
void View::draw()
|
||||
{
|
||||
// draw scene of this view
|
||||
scene.root()->draw(glm::identity<glm::mat4>(), Rendering::manager().Projection());
|
||||
}
|
||||
|
||||
void View::update(float dt)
|
||||
{
|
||||
// recursive update from root of scene
|
||||
scene.update( dt );
|
||||
|
||||
// reorder depth if needed
|
||||
if (View::need_reordering_)
|
||||
// a more complete update is requested
|
||||
if (View::need_deep_update_) {
|
||||
// reorder sources
|
||||
scene.fg()->sort();
|
||||
}
|
||||
}
|
||||
|
||||
void View::drag (glm::vec2 from, glm::vec2 to)
|
||||
{
|
||||
@@ -89,16 +97,6 @@ MixingView::MixingView() : View(MIXING)
|
||||
scene.bg()->attach(circle);
|
||||
}
|
||||
|
||||
MixingView::~MixingView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MixingView::draw()
|
||||
{
|
||||
// draw scene of this view
|
||||
scene.root()->draw(glm::identity<glm::mat4>(), Rendering::manager().Projection());
|
||||
}
|
||||
|
||||
void MixingView::zoom( float factor )
|
||||
{
|
||||
@@ -236,13 +234,13 @@ GeometryView::GeometryView() : View(GEOMETRY)
|
||||
|
||||
}
|
||||
|
||||
GeometryView::~GeometryView()
|
||||
void GeometryView::update(float dt)
|
||||
{
|
||||
View::update(dt);
|
||||
|
||||
}
|
||||
// reorder depth if needed
|
||||
if (View::need_deep_update_) {
|
||||
|
||||
void GeometryView::draw()
|
||||
{
|
||||
// update rendering of render frame
|
||||
FrameBuffer *output = Mixer::manager().session()->frame();
|
||||
if (output){
|
||||
@@ -250,9 +248,7 @@ void GeometryView::draw()
|
||||
(*node)->scale_.x = output->aspectRatio();
|
||||
}
|
||||
}
|
||||
|
||||
// draw scene of this view
|
||||
scene.root()->draw(glm::identity<glm::mat4>(), Rendering::manager().Projection());
|
||||
}
|
||||
}
|
||||
|
||||
void GeometryView::zoom( float factor )
|
||||
@@ -366,25 +362,25 @@ LayerView::LayerView() : View(LAYER), aspect_ratio(1.f)
|
||||
scene.bg()->attach(border);
|
||||
}
|
||||
|
||||
LayerView::~LayerView()
|
||||
void LayerView::update(float dt)
|
||||
{
|
||||
View::update(dt);
|
||||
|
||||
}
|
||||
// reorder depth if needed
|
||||
if (View::need_deep_update_) {
|
||||
|
||||
void LayerView::draw ()
|
||||
{
|
||||
// update rendering of render frame
|
||||
FrameBuffer *output = Mixer::manager().session()->frame();
|
||||
if (output)
|
||||
if (output){
|
||||
aspect_ratio = output->aspectRatio();
|
||||
|
||||
for (NodeSet::iterator node = scene.bg()->begin(); node != scene.bg()->end(); node++) {
|
||||
(*node)->scale_.x = aspect_ratio;
|
||||
}
|
||||
|
||||
// draw scene of this view
|
||||
scene.root()->draw(glm::identity<glm::mat4>(), Rendering::manager().Projection());
|
||||
|
||||
for (NodeSet::iterator node = scene.fg()->begin(); node != scene.fg()->end(); node++) {
|
||||
(*node)->translation_.y = (*node)->translation_.x / aspect_ratio;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LayerView::zoom (float factor)
|
||||
@@ -426,7 +422,7 @@ void LayerView::setDepth (Source *s, float d)
|
||||
s->touch();
|
||||
|
||||
// request reordering
|
||||
View::need_reordering_ = true;
|
||||
View::need_deep_update_ = true;
|
||||
}
|
||||
|
||||
void LayerView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick)
|
||||
@@ -450,6 +446,6 @@ void LayerView::grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *,
|
||||
glm::vec3 dest_translation = start_translation + gl_Position_to - gl_Position_from;
|
||||
|
||||
// apply change
|
||||
setDepth( s, -dest_translation.x );
|
||||
setDepth( s, MAX( -dest_translation.x, 0.f) );
|
||||
}
|
||||
|
||||
|
||||
16
View.h
16
View.h
@@ -14,10 +14,12 @@ public:
|
||||
typedef enum {RENDERING = 0, MIXING=1, GEOMETRY=2, LAYER=3, INVALID=4 } Mode;
|
||||
|
||||
View(Mode m);
|
||||
virtual ~View() {}
|
||||
|
||||
inline Mode mode() const { return mode_; }
|
||||
|
||||
virtual void update (float dt);
|
||||
virtual void draw () = 0;
|
||||
virtual void draw ();
|
||||
virtual void zoom (float) {}
|
||||
virtual void drag (glm::vec2, glm::vec2);
|
||||
virtual void grab (glm::vec2, glm::vec2, Source*, std::pair<Node *, glm::vec2>) {}
|
||||
@@ -28,7 +30,7 @@ public:
|
||||
Scene scene;
|
||||
|
||||
// hack to avoid reordering scene of view if not necessary
|
||||
static bool need_reordering_;
|
||||
static bool need_deep_update_;
|
||||
|
||||
protected:
|
||||
Mode mode_;
|
||||
@@ -39,9 +41,7 @@ class MixingView : public View
|
||||
{
|
||||
public:
|
||||
MixingView();
|
||||
~MixingView();
|
||||
|
||||
void draw () override;
|
||||
void zoom (float factor) override;
|
||||
void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2>) override;
|
||||
|
||||
@@ -69,23 +69,19 @@ class GeometryView : public View
|
||||
{
|
||||
public:
|
||||
GeometryView();
|
||||
~GeometryView();
|
||||
|
||||
void draw () override;
|
||||
void update (float dt) override;
|
||||
void zoom (float factor) override;
|
||||
void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick) override;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
class LayerView : public View
|
||||
{
|
||||
public:
|
||||
LayerView();
|
||||
~LayerView();
|
||||
|
||||
void draw () override;
|
||||
void update (float dt) override;
|
||||
void zoom (float factor) override;
|
||||
void grab (glm::vec2 from, glm::vec2 to, Source *s, std::pair<Node *, glm::vec2> pick) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user