// Don't check collision with root element (2nd element in _target_path)
// do event listeners attached to the canvas itself (its root group)
// always get called even if no element has been hit.
- if( _target_path.size() > 2 && !el.hitBound(local_pos) )
+ if( _target_path.size() > 2 && !el.hitBound(pos, local_pos) )
return false;
const osg::Vec2f& delta = _target_path.back().local_delta;
}
//----------------------------------------------------------------------------
- bool Element::hitBound(const osg::Vec2f& pos) const
+ bool Element::hitBound( const osg::Vec2f& pos,
+ const osg::Vec2f& local_pos ) const
{
const osg::Vec3f pos3(pos, 0);
// Drawables have a bounding box...
if( _drawable )
{
- if( !_drawable->getBound().contains(pos3) )
+ if( !_drawable->getBound().contains(osg::Vec3f(local_pos, 0)) )
return false;
}
// ... for other elements, i.e. groups only a bounding sphere is available
- else if( !_transform->getBound().contains(pos3) )
- return false;
+ else if( !_transform->getBound().contains(osg::Vec3f(pos, 0)) )
+ return false;
return true;
}
void callListeners(const canvas::EventPtr& event);
- virtual bool hitBound(const osg::Vec2f& pos) const;
+ virtual bool hitBound( const osg::Vec2f& pos,
+ const osg::Vec2f& local_pos ) const;
osg::ref_ptr<osg::MatrixTransform> getMatrixTransform();