From f47be656b41ef44d292ae6243986cfff9ad8cbc9 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 24 Jun 2016 10:02:18 +0100 Subject: [PATCH] Cleaned up pointer usage --- src/osgUtil/Optimizer.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index b6c942c6b..5904d780d 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -809,7 +809,7 @@ class CollectLowestTransformsVisitor : public BaseOptimizerVisitor inline bool isOperationPermissibleForObject(const osg::Drawable* drawable) const { // disable if cannot apply transform functor. - if (drawable && !drawable->supports(_transformFunctor)) return false; + if (!drawable->supports(_transformFunctor)) return false; return BaseOptimizerVisitor::isOperationPermissibleForObject(drawable); } @@ -4507,17 +4507,16 @@ void Optimizer::FlattenStaticTransformsDuplicatingSharedSubgraphsVisitor::apply( if(!_matrixStack.empty() && group.getNumParents() > 1 && nodepathsize > 1) { // copy this Group - osg::ref_ptr new_obj = group.clone(osg::CopyOp::DEEP_COPY_NODES | osg::CopyOp::DEEP_COPY_DRAWABLES | osg::CopyOp::DEEP_COPY_ARRAYS); - osg::Group* new_group = dynamic_cast(new_obj.get()); + osg::ref_ptr new_group = osg::clone(&group, osg::CopyOp(osg::CopyOp::DEEP_COPY_NODES | osg::CopyOp::DEEP_COPY_DRAWABLES | osg::CopyOp::DEEP_COPY_ARRAYS)); // New Group should only be added to parent through which this Group // was traversed, not to all parents of this Group. osg::Group* parent_group = dynamic_cast(_nodePath[nodepathsize-2]); - if(parent_group) + if(new_group && parent_group) { - parent_group->replaceChild(&group, new_group); + parent_group->replaceChild(&group, new_group.get()); // also replace the node in the nodepath - _nodePath[nodepathsize-1] = new_group; + _nodePath[nodepathsize-1] = new_group.get(); // traverse the new Group traverse(*(new_group)); }