From Pjotr Svetachov, introduced use of osg::observer_ptr<osg::Camera> in place of osg::Camera*

This commit is contained in:
Robert Osfield 2013-06-21 13:59:18 +00:00
parent da134aa8ed
commit 9d9543ca0a
2 changed files with 10 additions and 10 deletions

View File

@ -137,8 +137,8 @@ class OSGUTIL_EXPORT RenderStage : public RenderBin
void setCamera(osg::Camera* camera) { if (_camera!=camera) { _camera = camera; _cameraRequiresSetUp = true; } } void setCamera(osg::Camera* camera) { if (_camera!=camera) { _camera = camera; _cameraRequiresSetUp = true; } }
osg::Camera* getCamera() { return _camera; } osg::Camera* getCamera() { return _camera.get(); }
const osg::Camera* getCamera() const { return _camera; } const osg::Camera* getCamera() const { return _camera.get(); }
void setCameraRequiresSetUp(bool flag) { _cameraRequiresSetUp = flag; } void setCameraRequiresSetUp(bool flag) { _cameraRequiresSetUp = flag; }
bool getCameraRequiresSetUp() const { return _cameraRequiresSetUp; } bool getCameraRequiresSetUp() const { return _cameraRequiresSetUp; }
@ -288,7 +288,7 @@ protected:
int _clearStencil; int _clearStencil;
bool _cameraRequiresSetUp; bool _cameraRequiresSetUp;
osg::Camera* _camera; osg::observer_ptr<osg::Camera> _camera;
osg::ref_ptr<osg::Texture> _texture; osg::ref_ptr<osg::Texture> _texture;
unsigned int _level; unsigned int _level;

View File

@ -1090,7 +1090,7 @@ void RenderStage::drawInner(osg::RenderInfo& renderInfo,RenderLeaf*& previous, b
doCopyTexture = true; doCopyTexture = true;
} }
if (fbo_supported && _camera) if (fbo_supported && _camera.valid())
{ {
// now generate mipmaps if they are required. // now generate mipmaps if they are required.
const osg::Camera::BufferAttachmentMap& bufferAttachments = _camera->getBufferAttachmentMap(); const osg::Camera::BufferAttachmentMap& bufferAttachments = _camera->getBufferAttachmentMap();
@ -1142,11 +1142,11 @@ void RenderStage::draw(osg::RenderInfo& renderInfo,RenderLeaf*& previous)
if(_initialViewMatrix.valid()) renderInfo.getState()->setInitialViewMatrix(_initialViewMatrix.get()); if(_initialViewMatrix.valid()) renderInfo.getState()->setInitialViewMatrix(_initialViewMatrix.get());
// push the stages camera so that drawing code can query it // push the stages camera so that drawing code can query it
if (_camera) renderInfo.pushCamera(_camera); if (_camera.valid()) renderInfo.pushCamera(_camera.get());
_stageDrawnThisFrame = true; _stageDrawnThisFrame = true;
if (_camera && _camera->getInitialDrawCallback()) if (_camera.valid() && _camera->getInitialDrawCallback())
{ {
// if we have a camera with a intial draw callback invoke it. // if we have a camera with a intial draw callback invoke it.
(*(_camera->getInitialDrawCallback()))(renderInfo); (*(_camera->getInitialDrawCallback()))(renderInfo);
@ -1202,7 +1202,7 @@ void RenderStage::draw(osg::RenderInfo& renderInfo,RenderLeaf*& previous)
unsigned int originalStackSize = useState->getStateSetStackSize(); unsigned int originalStackSize = useState->getStateSetStackSize();
if (_camera && _camera->getPreDrawCallback()) if (_camera.valid() && _camera->getPreDrawCallback())
{ {
// if we have a camera with a pre draw callback invoke it. // if we have a camera with a pre draw callback invoke it.
(*(_camera->getPreDrawCallback()))(renderInfo); (*(_camera->getPreDrawCallback()))(renderInfo);
@ -1263,7 +1263,7 @@ void RenderStage::draw(osg::RenderInfo& renderInfo,RenderLeaf*& previous)
copyTexture(renderInfo); copyTexture(renderInfo);
} }
if (_camera && _camera->getPostDrawCallback()) if (_camera.valid() && _camera->getPostDrawCallback())
{ {
// if we have a camera with a post draw callback invoke it. // if we have a camera with a post draw callback invoke it.
(*(_camera->getPostDrawCallback()))(renderInfo); (*(_camera->getPostDrawCallback()))(renderInfo);
@ -1301,14 +1301,14 @@ void RenderStage::draw(osg::RenderInfo& renderInfo,RenderLeaf*& previous)
// render all the post draw callbacks // render all the post draw callbacks
drawPostRenderStages(renderInfo,previous); drawPostRenderStages(renderInfo,previous);
if (_camera && _camera->getFinalDrawCallback()) if (_camera.valid() && _camera->getFinalDrawCallback())
{ {
// if we have a camera with a final callback invoke it. // if we have a camera with a final callback invoke it.
(*(_camera->getFinalDrawCallback()))(renderInfo); (*(_camera->getFinalDrawCallback()))(renderInfo);
} }
// pop the render stages camera. // pop the render stages camera.
if (_camera) renderInfo.popCamera(); if (_camera.valid()) renderInfo.popCamera();
} }
void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& previous) void RenderStage::drawImplementation(osg::RenderInfo& renderInfo,RenderLeaf*& previous)