osgEarth::IntersectionPicker issue with WGS-84 map type

classic Classic list List threaded Threaded
3 messages Options
Blanky Blanky
Reply | Threaded
Open this post in threaded view
|

osgEarth::IntersectionPicker issue with WGS-84 map type

Hey,

I was making a tooltip handler and attaching it to my widget to handle hovering over scene objects. I interface through a QOpenGlWidget and that stuff is working just fine. However, I have both a projected spherical-mercator map and a WGS-84 map. The projected map works just fine since nothing can be "occluded" by the earth, however when I spin the globe around to the other side and hover my mouse on a coordinate that an infinite picker plane can intersect with, it will collide with stuff that is culled by the HorizonCullCallback that I've installed on just about every single node.

I have to allow the picker to have no limit because things can be overlapping. Here is my code for reference on what we attempted to do to circumvent the issue:

void TooltipHandler::traverse(){
    osgEarth::IntersectionPicker picker(m_va, m_msg->getMapNode());
    picker.setLimit(osgEarth::IntersectionPicker::Limit::NO_LIMIT);


    osgEarth::PrimitiveIntersector::Intersections intersections;
    picker.pick(m_x, m_y, intersections);

    if(!m_msg->getMapNode()->getMapSRS()->isProjected()){
        osgEarth::IntersectionPicker picker2(m_va, m_msg->getMapNode());
        picker2.setLimit(osgEarth::IntersectionPicker::Limit::LIMIT_NEAREST);

        osgEarth::PrimitiveIntersector::Intersections intersections2;
        picker2.pick(m_x, m_y, intersections2);

        if(!intersections2.empty() && picker2.getNode<osgEarth::MapNode>(*intersections2.begin())) return;
    }

    for(auto iterator = intersections.begin(); iterator != intersections.end(); ++iterator){
        CMS::Node::SymbolNode* chld = picker.getNode<CMS::Node::SymbolNode>(*iterator);

        //Skips invalid children
        if(!chld){
            continue;
        }

        QString text = chld->getHandle()->getToolTip();
        bool isCulled = false;
        chld->getUserValue(m_va->getCamera()->getName(), isCulled);

        if(!isCulled){
            QToolTip::showText(QPoint(QCursor::pos().x() + 20, QCursor::pos().y() + 20), text, m_glWidget, m_glWidget->rect(), -1);
        }

        return;
    }
    QToolTip::hideText();
    return;
}


So what we tried to do was for the WGS-84 map type, we created a second picker and attempted to pick the nearest object, if it was the osgEarth::MapNode, return. Well... even when we rotated the earth around to show stuff and everything was visible, it still thinks with the osgEarth::IntersectionPicker::Limit::LIMIT_NEAREST flag that the begin() of the Intersections is still the osgEarth::MapNode. Is there a way that we don't allow the intersector to pick up things that are culled by the HorizonCullCallback? We have set a user value for stuff we've explicitly culled and that works just fine, but we're still having difficulty understanding what the LIMIT_NEAREST is doing... Thanks for any clarification or steering us in the right direction.

I'm also assuming that the begin() of any intersection will almost always be the chosen subgraph for the picker argument if it is found. Is there a way to reorder the intersections based on distance from the camera? That may help solve our issue. I just don't want there to be gross overhead for something that should be relatively light weight.

- Blanky
krzysief krzysief
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth::IntersectionPicker issue with WGS-84 map type

Hello,
try:
osg::ref_ptr< osgEarth::Util::AutoClipPlaneCullCallback > culler = new
      osgEarth::Util::AutoClipPlaneCullCallback(map_node);
viewer->getCamera()->addCullCallback(culler);    
Blanky Blanky
Reply | Threaded
Open this post in threaded view
|

Re: osgEarth::IntersectionPicker issue with WGS-84 map type

Thanks! That worked perfectly it seems.

- Blanky