Skip to content

Commit

Permalink
Prefer Intersector::PROJECTION over Intersector::WINDOW
Browse files Browse the repository at this point in the history
  • Loading branch information
scrawl committed Nov 30, 2015
1 parent 14b1432 commit 576d511
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion apps/openmw/mwrender/characterpreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,11 @@ namespace MWRender

int InventoryPreview::getSlotSelected (int posX, int posY)
{
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector (new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, posX, posY));
float projX = (posX / mCamera->getViewport()->width()) * 2 - 1.f;
float projY = (posY / mCamera->getViewport()->height()) * 2 - 1.f;
// With Intersector::WINDOW, the intersection ratios are slightly inaccurate. TODO: investigate
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector (new osgUtil::LineSegmentIntersector(osgUtil::Intersector::PROJECTION, projX, projY));

intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::LIMIT_NEAREST);
osgUtil::IntersectionVisitor visitor(intersector);
visitor.setTraversalMode(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN);
Expand Down

0 comments on commit 576d511

Please sign in to comment.