Canvas: Only use cull callback if it's still valid
This commit is contained in:
parent
26664aaff0
commit
7463ebad1d
3 changed files with 9 additions and 6 deletions
|
@ -73,7 +73,7 @@ Canvas::CullCallback::CullCallback(CameraCullCallback* camera_cull):
|
|||
void Canvas::CullCallback::operator()( osg::Node* node,
|
||||
osg::NodeVisitor* nv )
|
||||
{
|
||||
if( nv->getTraversalMask() & simgear::MODEL_BIT )
|
||||
if( (nv->getTraversalMask() & simgear::MODEL_BIT) && _camera_cull.valid() )
|
||||
_camera_cull->enableRendering();
|
||||
|
||||
traverse(node, nv);
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <simgear/props/propertyObject.hxx>
|
||||
#include <osg/NodeCallback>
|
||||
#include <osg/observer_ptr>
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
@ -66,6 +67,7 @@ class Canvas:
|
|||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
|
||||
};
|
||||
typedef osg::ref_ptr<CameraCullCallback> CameraCullCallbackPtr;
|
||||
typedef osg::observer_ptr<CameraCullCallback> CameraCullCallbackWeakPtr;
|
||||
|
||||
/**
|
||||
* This callback is installed on every placement of the canvas in the
|
||||
|
@ -78,7 +80,7 @@ class Canvas:
|
|||
CullCallback(CameraCullCallback* camera_cull);
|
||||
|
||||
private:
|
||||
CameraCullCallback *_camera_cull;
|
||||
CameraCullCallbackWeakPtr _camera_cull;
|
||||
|
||||
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
|
||||
};
|
||||
|
@ -91,10 +93,10 @@ class Canvas:
|
|||
|
||||
int getSizeX() const
|
||||
{ return _size_x; }
|
||||
|
||||
|
||||
int getSizeY() const
|
||||
{ return _size_y; }
|
||||
|
||||
|
||||
void setSizeX(int sx);
|
||||
void setSizeY(int sy);
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ class CullCallback:
|
|||
CullCallback(Canvas::CameraCullCallback* camera_cull);
|
||||
|
||||
private:
|
||||
Canvas::CameraCullCallback *_camera_cull;
|
||||
Canvas::CameraCullCallbackWeakPtr _camera_cull;
|
||||
|
||||
virtual bool cull( osg::NodeVisitor* nv,
|
||||
osg::Drawable* drawable,
|
||||
|
@ -62,7 +62,8 @@ bool CullCallback::cull( osg::NodeVisitor* nv,
|
|||
osg::Drawable* drawable,
|
||||
osg::RenderInfo* renderInfo ) const
|
||||
{
|
||||
_camera_cull->enableRendering();
|
||||
if( _camera_cull.valid() )
|
||||
_camera_cull->enableRendering();
|
||||
|
||||
// TODO check if window/image should be culled
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue