// That is they get sorted by distance and by scenegraph depth.
// The nearest one is the first one and the deepest
// (the most specialized one in the scenegraph) is the first.
- SGSceneryPicks pickList;
- if (!globals->get_renderer()->pick(pickList, windowPos)) {
+ SGSceneryPicks pickList = globals->get_renderer()->pick(windowPos);
+ if (pickList.empty()) {
return;
}
bool didPick = false;
SGPickCallback::Priority priority = SGPickCallback::PriorityScenery;
- SGSceneryPicks pickList;
- globals->get_renderer()->pick(pickList, windowPos);
+ SGSceneryPicks pickList = globals->get_renderer()->pick(windowPos);
SGSceneryPicks::const_iterator i;
for( i = pickList.begin(); i != pickList.end(); ++i )
osg::Vec2d windowPos;
flightgear::eventToWindowCoords(ea, windowPos.x(), windowPos.y());
- SGSceneryPicks pickList;
- if( !globals->get_renderer()->pick(pickList, windowPos) )
+ SGSceneryPicks pickList = globals->get_renderer()->pick(windowPos);
+ if(pickList.empty())
return;
for( ActivePickCallbacks::iterator mi = activePickCallbacks.begin();
osg::Vec2d windowPos;
flightgear::eventToWindowCoords(ea, windowPos.x(), windowPos.y());
- SGSceneryPicks pickList;
- globals->get_renderer()->pick(pickList, windowPos);
+ SGSceneryPicks pickList = globals->get_renderer()->pick(windowPos);
if( updown != MOUSE_BUTTON_DOWN )
{
return toSG( osg::Vec2d(tc1 * r1 + tc2 * r2 + tc3 * r3) );
}
-bool
-FGRenderer::pick(std::vector<SGSceneryPick>& pickList, const osg::Vec2& windowPos)
+PickList FGRenderer::pick(const osg::Vec2& windowPos)
{
- // wipe out the return ...
- pickList.clear();
+ PickList result;
+
typedef osgUtil::LineSegmentIntersector::Intersections Intersections;
Intersections intersections;
if (!computeIntersections(CameraGroup::getDefault(), windowPos, intersections))
- return false;
+ return result;
for (Intersections::iterator hit = intersections.begin(),
e = intersections.end();
hit != e;
sceneryPick.info.uv = uvFromIntersection(*hit);
sceneryPick.callback = pickCallback;
- pickList.push_back(sceneryPick);
+ result.push_back(sceneryPick);
} // of installed pick callbacks iteration
} // of reverse node path walk
}
- return !pickList.empty();
+ return result;
}
void
class SGSky;
class SGUpdateVisitor;
+typedef std::vector<SGSceneryPick> PickList;
+
class FGRenderer {
public:
/** Just pick into the scene and return the pick callbacks on the way ...
*/
- bool pick( std::vector<SGSceneryPick>& pickList, const osg::Vec2& windowPos);
+ PickList pick(const osg::Vec2& windowPos);
/** Get and set the OSG Viewer object, if any.
*/