forked from teamnwah/openmw-tes3coop
Prefer Intersector::PROJECTION over Intersector::WINDOW
This commit is contained in:
parent
14b143231c
commit
576d5111a5
1 changed files with 5 additions and 1 deletions
|
@ -269,7 +269,11 @@ namespace MWRender
|
||||||
|
|
||||||
int InventoryPreview::getSlotSelected (int posX, int posY)
|
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);
|
intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::LIMIT_NEAREST);
|
||||||
osgUtil::IntersectionVisitor visitor(intersector);
|
osgUtil::IntersectionVisitor visitor(intersector);
|
||||||
visitor.setTraversalMode(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN);
|
visitor.setTraversalMode(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN);
|
||||||
|
|
Loading…
Reference in a new issue