Added Camera::isRenderToTextureCamera() method, and improved support in PickVisitor
and IntersectVisitor for CameraNode, including the ignoring of render to texture cameras, such that HUD's etc are still intersected against.
This commit is contained in:
@@ -92,7 +92,6 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
|
||||
void setTransformOrder(TransformOrder order) { _transformOrder = order; }
|
||||
TransformOrder getTransformOrder() const { return _transformOrder; }
|
||||
|
||||
|
||||
|
||||
/** Set the projection matrix. Can be thought of as setting the lens of a camera. */
|
||||
inline void setProjectionMatrix(const osg::Matrixf& matrix) { _projectionMatrix.set(matrix); }
|
||||
@@ -184,6 +183,9 @@ class OSG_EXPORT CameraNode : public Transform, public CullSettings
|
||||
/** Get the rendering order of this camera's subgraph relative to any camera that this subgraph is nested within.*/
|
||||
RenderOrder getRenderOrder() const { return _renderOrder; }
|
||||
|
||||
/** Return true if this Camera is set up as a render to texture camera, i.e. it has textures assigned to it.*/
|
||||
bool isRenderToTextureCamera() const;
|
||||
|
||||
enum RenderTargetImplementation
|
||||
{
|
||||
FRAME_BUFFER_OBJECT,
|
||||
|
||||
@@ -53,6 +53,11 @@ CameraNode::~CameraNode()
|
||||
{
|
||||
}
|
||||
|
||||
bool CameraNode::isRenderToTextureCamera() const
|
||||
{
|
||||
return (!_bufferAttachmentMap.empty());
|
||||
}
|
||||
|
||||
void CameraNode::setRenderTargetImplementation(RenderTargetImplementation impl)
|
||||
{
|
||||
_renderTargetImplementation = impl;
|
||||
|
||||
@@ -764,13 +764,10 @@ bool Viewer::computeIntersections(float x,float y,unsigned int cameraNum,osg::No
|
||||
view = osg::Matrixd(camera->getViewMatrix());
|
||||
}
|
||||
|
||||
node = node->getParent(0);
|
||||
|
||||
osgUtil::PickVisitor pick(viewport, proj, view, pixel_x, pixel_y);
|
||||
pick.setTraversalMask(traversalMask);
|
||||
node->accept(pick);
|
||||
|
||||
|
||||
// copy all the hits across to the external hits list
|
||||
for(osgUtil::PickVisitor::LineSegmentHitListMap::iterator itr = pick.getSegHitList().begin();
|
||||
itr != pick.getSegHitList().end();
|
||||
|
||||
@@ -113,20 +113,17 @@ bool IntersectVisitor::IntersectState::isCulled(const BoundingSphere& bs,LineSeg
|
||||
LineSegmentMask mask = 0x00000001;
|
||||
segMaskOut = 0x00000000;
|
||||
LineSegmentMask segMaskIn = _segmentMaskStack.back();
|
||||
// notify(INFO) << << "IntersectState::isCulled() mask in "<<segMaskIn<<" ";
|
||||
for(IntersectState::LineSegmentList::iterator sitr=_segList.begin();
|
||||
sitr!=_segList.end();
|
||||
++sitr)
|
||||
{
|
||||
if ((segMaskIn & mask) && (sitr->second)->intersect(bs))
|
||||
{
|
||||
// notify(INFO) << << "Hit ";
|
||||
segMaskOut = segMaskOut| mask;
|
||||
hit = true;
|
||||
}
|
||||
mask = mask << 1;
|
||||
}
|
||||
// notify(INFO) << << "mask = "<<segMaskOut<< std::endl;
|
||||
return !hit;
|
||||
}
|
||||
|
||||
@@ -303,7 +300,7 @@ void IntersectVisitor::popMatrix()
|
||||
bool IntersectVisitor::enterNode(Node& node)
|
||||
{
|
||||
const BoundingSphere& bs = node.getBound();
|
||||
if (bs.valid())
|
||||
if (bs.valid() && node.isCullingActive())
|
||||
{
|
||||
IntersectState* cis = _intersectStateStack.back().get();
|
||||
IntersectState::LineSegmentMask sm=0xffffffff;
|
||||
@@ -313,7 +310,13 @@ bool IntersectVisitor::enterNode(Node& node)
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
IntersectState* cis = _intersectStateStack.back().get();
|
||||
if (!cis->_segmentMaskStack.empty())
|
||||
cis->_segmentMaskStack.push_back(cis->_segmentMaskStack.back());
|
||||
else
|
||||
cis->_segmentMaskStack.push_back(0xffffffff);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -721,9 +724,12 @@ void PickVisitor::apply(osg::Projection& projection)
|
||||
|
||||
void PickVisitor::apply(osg::CameraNode& camera)
|
||||
{
|
||||
runNestedPickVisitor( camera,
|
||||
camera.getViewport() ? camera.getViewport() : _lastViewport.get(),
|
||||
camera.getProjectionMatrix(),
|
||||
camera.getViewMatrix(),
|
||||
_mx, _my );
|
||||
if (!camera.isRenderToTextureCamera())
|
||||
{
|
||||
runNestedPickVisitor( camera,
|
||||
camera.getViewport() ? camera.getViewport() : _lastViewport.get(),
|
||||
camera.getProjectionMatrix(),
|
||||
camera.getViewMatrix(),
|
||||
_mx, _my );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,7 @@ BEGIN_OBJECT_REFLECTOR(osg::CameraNode)
|
||||
I_Method0(osg::Matrixd, getInverseViewMatrix);
|
||||
I_Method1(void, setRenderOrder, IN, osg::CameraNode::RenderOrder, order);
|
||||
I_Method0(osg::CameraNode::RenderOrder, getRenderOrder);
|
||||
I_Method0(bool, isRenderToTextureCamera);
|
||||
I_Method1(void, setRenderTargetImplementation, IN, osg::CameraNode::RenderTargetImplementation, impl);
|
||||
I_Method2(void, setRenderTargetImplementation, IN, osg::CameraNode::RenderTargetImplementation, impl, IN, osg::CameraNode::RenderTargetImplementation, fallback);
|
||||
I_Method0(osg::CameraNode::RenderTargetImplementation, getRenderTargetImplementation);
|
||||
|
||||
Reference in New Issue
Block a user