Fixed picking in geometry view.

This commit is contained in:
brunoherbelin
2020-06-03 20:31:58 +02:00
parent 5e51deef7f
commit 87fe169d73
3 changed files with 7 additions and 7 deletions

View File

@@ -132,6 +132,5 @@ void PickingVisitor::visit(LineCircle &n)
void PickingVisitor::visit(Scene &n)
{
// TODO : maybe pick only foreground ?
n.root()->accept(*this);
}

View File

@@ -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() );

View File

@@ -314,20 +314,21 @@ std::pair<Node *, glm::vec2> 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