forked from mirror/openmw-tes3mp
Fix character preview item selection
This commit is contained in:
parent
c9f8a220dc
commit
5c11266a46
2 changed files with 9 additions and 3 deletions
|
@ -256,7 +256,8 @@ namespace MWRender
|
|||
|
||||
// NB Camera::setViewport has threading issues
|
||||
osg::ref_ptr<osg::StateSet> stateset = new osg::StateSet;
|
||||
stateset->setAttributeAndModes(new osg::Viewport(0, mSizeY-sizeY, std::min(mSizeX, sizeX), std::min(mSizeY, sizeY)));
|
||||
mViewport = new osg::Viewport(0, mSizeY-sizeY, std::min(mSizeX, sizeX), std::min(mSizeY, sizeY));
|
||||
stateset->setAttributeAndModes(mViewport);
|
||||
mCamera->setStateSet(stateset);
|
||||
|
||||
redraw();
|
||||
|
@ -334,8 +335,10 @@ namespace MWRender
|
|||
|
||||
int InventoryPreview::getSlotSelected (int posX, int posY)
|
||||
{
|
||||
float projX = (posX / mCamera->getViewport()->width()) * 2 - 1.f;
|
||||
float projY = (posY / mCamera->getViewport()->height()) * 2 - 1.f;
|
||||
if (!mViewport)
|
||||
return -1;
|
||||
float projX = (posX / mViewport->width()) * 2 - 1.f;
|
||||
float projY = (posY / mViewport->height()) * 2 - 1.f;
|
||||
// With Intersector::WINDOW, the intersection ratios are slightly inaccurate. Seems to be a
|
||||
// precision issue - compiling with OSG_USE_FLOAT_MATRIX=0, Intersector::WINDOW works ok.
|
||||
// Using Intersector::PROJECTION results in better precision because the start/end points and the model matrices
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace osg
|
|||
class Texture2D;
|
||||
class Camera;
|
||||
class Group;
|
||||
class Viewport;
|
||||
}
|
||||
|
||||
namespace MWRender
|
||||
|
@ -83,6 +84,8 @@ namespace MWRender
|
|||
int getSlotSelected(int posX, int posY);
|
||||
|
||||
protected:
|
||||
osg::ref_ptr<osg::Viewport> mViewport;
|
||||
|
||||
virtual void onSetup();
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue