1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-04 03:40:14 +00:00

Prefer Intersector::PROJECTION over Intersector::WINDOW

This commit is contained in:
scrawl 2015-11-30 17:04:45 +01:00
parent 14b143231c
commit 576d5111a5

View File

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