Fix some character preview raycasting issues (Bug #2769)

openmw-38
scrawl 9 years ago
parent 8fb328ef4f
commit 0655abcd8b

@ -30,6 +30,7 @@ namespace MWRender
public: public:
DrawOnceCallback () DrawOnceCallback ()
: mRendered(false) : mRendered(false)
, mLastRenderedFrame(0)
{ {
} }
@ -38,13 +39,14 @@ namespace MWRender
if (!mRendered) if (!mRendered)
{ {
mRendered = true; mRendered = true;
mLastRenderedFrame = nv->getTraversalNumber();
traverse(node, nv);
} }
else else
{ {
node->setNodeMask(0); node->setNodeMask(0);
} }
traverse(node, nv);
} }
void redrawNextFrame() void redrawNextFrame()
@ -52,8 +54,14 @@ namespace MWRender
mRendered = false; mRendered = false;
} }
unsigned int getLastRenderedFrame() const
{
return mLastRenderedFrame;
}
private: private:
bool mRendered; bool mRendered;
unsigned int mLastRenderedFrame;
}; };
CharacterPreview::CharacterPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem, CharacterPreview::CharacterPreview(osgViewer::Viewer* viewer, Resource::ResourceSystem* resourceSystem,
@ -262,8 +270,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)); osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector (new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, posX, posY));
intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::LIMIT_ONE); intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::LIMIT_NEAREST);
osgUtil::IntersectionVisitor visitor(intersector); osgUtil::IntersectionVisitor visitor(intersector);
visitor.setTraversalMode(osg::NodeVisitor::TRAVERSE_ACTIVE_CHILDREN);
// Set the traversal number from the last draw, so that the frame switch used for RigGeometry double buffering works correctly
visitor.setTraversalNumber(mDrawOnceCallback->getLastRenderedFrame());
osg::Node::NodeMask nodeMask = mCamera->getNodeMask(); osg::Node::NodeMask nodeMask = mCamera->getNodeMask();
mCamera->setNodeMask(~0); mCamera->setNodeMask(~0);

Loading…
Cancel
Save