|
|
|
@ -588,23 +588,27 @@ namespace MWRender
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RenderingManager::RayResult RenderingManager::castRay(const osg::Vec3f& origin, const osg::Vec3f& dest, bool ignorePlayer, bool ignoreActors)
|
|
|
|
|
osg::ref_ptr<osgUtil::IntersectionVisitor> createIntersectionVisitor(osgUtil::Intersector* intersector, bool ignorePlayer, bool ignoreActors)
|
|
|
|
|
{
|
|
|
|
|
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector (new osgUtil::LineSegmentIntersector(osgUtil::LineSegmentIntersector::MODEL,
|
|
|
|
|
origin, dest));
|
|
|
|
|
intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::LIMIT_NEAREST);
|
|
|
|
|
|
|
|
|
|
osgUtil::IntersectionVisitor intersectionVisitor(intersector);
|
|
|
|
|
int mask = intersectionVisitor.getTraversalMask();
|
|
|
|
|
mask &= ~(Mask_RenderToTexture|Mask_Sky|Mask_Debug|Mask_Effect|Mask_Water);
|
|
|
|
|
osg::ref_ptr<osgUtil::IntersectionVisitor> intersectionVisitor( new osgUtil::IntersectionVisitor(intersector));
|
|
|
|
|
int mask = intersectionVisitor->getTraversalMask();
|
|
|
|
|
mask &= ~(Mask_RenderToTexture|Mask_Sky|Mask_Debug|Mask_Effect|Mask_Water|Mask_SimpleWater);
|
|
|
|
|
if (ignorePlayer)
|
|
|
|
|
mask &= ~(Mask_Player);
|
|
|
|
|
if (ignoreActors)
|
|
|
|
|
mask &= ~(Mask_Actor|Mask_Player);
|
|
|
|
|
|
|
|
|
|
intersectionVisitor.setTraversalMask(mask);
|
|
|
|
|
intersectionVisitor->setTraversalMask(mask);
|
|
|
|
|
return intersectionVisitor;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RenderingManager::RayResult RenderingManager::castRay(const osg::Vec3f& origin, const osg::Vec3f& dest, bool ignorePlayer, bool ignoreActors)
|
|
|
|
|
{
|
|
|
|
|
osg::ref_ptr<osgUtil::LineSegmentIntersector> intersector (new osgUtil::LineSegmentIntersector(osgUtil::LineSegmentIntersector::MODEL,
|
|
|
|
|
origin, dest));
|
|
|
|
|
intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::LIMIT_NEAREST);
|
|
|
|
|
|
|
|
|
|
mRootNode->accept(intersectionVisitor);
|
|
|
|
|
mRootNode->accept(*createIntersectionVisitor(intersector, ignorePlayer, ignoreActors));
|
|
|
|
|
|
|
|
|
|
return getIntersectionResult(intersector);
|
|
|
|
|
}
|
|
|
|
@ -623,17 +627,7 @@ namespace MWRender
|
|
|
|
|
intersector->setEnd(end);
|
|
|
|
|
intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::LIMIT_NEAREST);
|
|
|
|
|
|
|
|
|
|
osgUtil::IntersectionVisitor intersectionVisitor(intersector);
|
|
|
|
|
int mask = intersectionVisitor.getTraversalMask();
|
|
|
|
|
mask &= ~(Mask_RenderToTexture|Mask_Sky|Mask_Debug|Mask_Effect|Mask_Water);
|
|
|
|
|
if (ignorePlayer)
|
|
|
|
|
mask &= ~(Mask_Player);
|
|
|
|
|
if (ignoreActors)
|
|
|
|
|
mask &= ~(Mask_Actor|Mask_Player);
|
|
|
|
|
|
|
|
|
|
intersectionVisitor.setTraversalMask(mask);
|
|
|
|
|
|
|
|
|
|
mViewer->getCamera()->accept(intersectionVisitor);
|
|
|
|
|
mViewer->getCamera()->accept(*createIntersectionVisitor(intersector, ignorePlayer, ignoreActors));
|
|
|
|
|
|
|
|
|
|
return getIntersectionResult(intersector);
|
|
|
|
|
}
|
|
|
|
|