From 44255995e34269c99a5cd47eb7e3146990d3ab23 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 28 Jun 2016 13:44:00 +0100 Subject: [PATCH] Cleaned up pointer checks --- src/osgPlugins/logo/ReaderWriterLOGO.cpp | 28 ++++++++++++++---------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/src/osgPlugins/logo/ReaderWriterLOGO.cpp b/src/osgPlugins/logo/ReaderWriterLOGO.cpp index 8c95a97c0..ac5a57e7e 100644 --- a/src/osgPlugins/logo/ReaderWriterLOGO.cpp +++ b/src/osgPlugins/logo/ReaderWriterLOGO.cpp @@ -37,28 +37,30 @@ class Logos: public osg::Drawable { virtual bool cull(osg::NodeVisitor *visitor, osg::Drawable* drawable, osg::State*) const { - Logos *logos = dynamic_cast (drawable); + Logos *logos = dynamic_cast(drawable); + if (!logos) return true; + + osgUtil::CullVisitor *cv = visitor->asCullVisitor(); if (!cv) return true; - unsigned int contextID = cv->getState()!=0 ? cv->getState()->getContextID() : 0; + osg::State* state = cv->getState(); + + unsigned int contextID = state!=0 ? state->getContextID() : 0; if(contextID != logos->getContextID()) { // logo not appropriate for window assigned to the cull visitor so cull it. return true; } - if( logos != NULL && cv != NULL ) + osg::Viewport *vp = cv->getViewport(); + if( vp != NULL ) { - osg::Viewport *vp = cv->getViewport(); - if( vp != NULL ) + if( vp->width() != logos->getViewport()->width() || + vp->height() != logos->getViewport()->height() ) { - if( vp->width() != logos->getViewport()->width() || - vp->height() != logos->getViewport()->height() ) - { - logos->getViewport()->setViewport( vp->x(), vp->y(), vp->width(), vp->height() ); - logos->dirtyDisplayList(); - } + logos->getViewport()->setViewport( vp->x(), vp->y(), vp->width(), vp->height() ); + logos->dirtyDisplayList(); } } return false; @@ -86,7 +88,9 @@ class Logos: public osg::Drawable _contextID = 0; } - Logos(const Logos& logo, const CopyOp& copyop=CopyOp::SHALLOW_COPY) :Drawable( logo, copyop ) {} + Logos(const Logos& logo, const CopyOp& copyop=CopyOp::SHALLOW_COPY) : + Drawable( logo, copyop ), + _contextID(0) {} virtual Object* cloneType() const { return new Logos(); } virtual Object* clone( const CopyOp& copyop) const { return new Logos(*this, copyop ); }