diff --git a/PickingVisitor.cpp b/PickingVisitor.cpp index 874f874..9612138 100644 --- a/PickingVisitor.cpp +++ b/PickingVisitor.cpp @@ -132,6 +132,5 @@ void PickingVisitor::visit(LineCircle &n) void PickingVisitor::visit(Scene &n) { - // TODO : maybe pick only foreground ? n.root()->accept(*this); } diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index 4808620..72827ef 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -374,11 +374,11 @@ void UserInterface::handleMouse() // ask the view what was picked picked = Mixer::manager().currentView()->pick(point); - if (picked.first == nullptr){ + if ( picked.first == nullptr ) { // nothing picked, unset current Mixer::manager().unsetCurrentSource(); navigator.hidePannel(); - } else { + } else { Mixer::manager().setCurrentSource( picked.first ); if (navigator.pannelVisible()) navigator.showPannelSource( Mixer::manager().indexCurrentSource() ); diff --git a/View.cpp b/View.cpp index 64d311f..daa9906 100644 --- a/View.cpp +++ b/View.cpp @@ -314,20 +314,21 @@ std::pair GeometryView::pick(glm::vec3 point) scene.accept(pv); // picking visitor found nodes? - if ( !pv.picked().empty()) { + if ( pv.picked().size() > 0) { Source *s = Mixer::manager().currentSource(); if (s != nullptr) { + // find if the current source was picked - auto itp = pv.picked().begin(); - for (; itp != pv.picked().end(); itp++){ + auto itp = pv.picked().rbegin(); + for (; itp != pv.picked().rend(); itp++){ if ( s->contains( (*itp).first ) ){ pick = *itp; break; } } // not found: the current source was not clicked - if (itp == pv.picked().end()) + if (itp == pv.picked().rend()) s = nullptr; } // maybe the source changed