Added collateReferencesToDependentCameras() and clearReferencesToDependentCameras() methods into RenderStage and SceneView, and use
of these methods in src/osgViewer/Renderer.cpp to make sure that the draw thread keeps references to all in scene graph Cameras that are being used by the drawing threads, to keep the Camera's alive even when the main thread removes these Cameras from the scene graph.
This commit is contained in:
@@ -224,20 +224,29 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
|
||||
GLenum _imageReadPixelFormat;
|
||||
GLenum _imageReadPixelDataType;
|
||||
};
|
||||
|
||||
|
||||
void attach(osg::Camera::BufferComponent buffer, osg::Image* image);
|
||||
|
||||
|
||||
/** search through any pre and post RenderStage that reference a Camera, and take a reference to each of these cameras to prevent them being deleted while they are still be used by the drawing thread.*/
|
||||
void collateReferencesToDependentCameras();
|
||||
|
||||
/** clear the refence to any any dependent cameras.*/
|
||||
void clearReferencesToDependentCameras();
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
virtual ~RenderStage();
|
||||
|
||||
typedef std::pair< int , osg::ref_ptr<RenderStage> > RenderStageOrderPair;
|
||||
typedef std::list< RenderStageOrderPair > RenderStageList;
|
||||
typedef std::vector< osg::ref_ptr<osg::Camera> > Cameras;
|
||||
|
||||
bool _stageDrawnThisFrame;
|
||||
RenderStageList _preRenderList;
|
||||
RenderStageList _postRenderList;
|
||||
|
||||
Cameras _dependentCameras;
|
||||
|
||||
// viewport x,y,width,height.
|
||||
osg::ref_ptr<osg::Viewport> _viewport;
|
||||
|
||||
@@ -271,8 +280,7 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
|
||||
mutable osg::Matrix _inheritedPositionalStateContainerMatrix;
|
||||
mutable osg::ref_ptr<PositionalStateContainer> _inheritedPositionalStateContainer;
|
||||
mutable osg::ref_ptr<PositionalStateContainer> _renderStageLighting;
|
||||
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -311,6 +311,12 @@ class OSGUTIL_EXPORT SceneView : public osg::Object, public osg::CullSettings
|
||||
osgUtil::RenderStage* getRenderStageRight() { return _renderStageRight.get(); }
|
||||
const osgUtil::RenderStage* getRenderStageRight() const { return _renderStageRight.get(); }
|
||||
|
||||
/** search through any pre and post RenderStage that reference a Camera, and take a reference to each of these cameras to prevent them being deleted while they are still be used by the drawing thread.*/
|
||||
void collateReferencesToDependentCameras();
|
||||
|
||||
/** clear the refence to any any dependent cameras.*/
|
||||
void clearReferencesToDependentCameras();
|
||||
|
||||
|
||||
/** Set the draw buffer value used at the start of each frame draw. Note, overridden in quad buffer stereo mode */
|
||||
void setDrawBufferValue( GLenum drawBufferValue ) { _camera->setDrawBuffer(drawBufferValue); }
|
||||
|
||||
Reference in New Issue
Block a user