diff --git a/AUTHORS b/AUTHORS index 3d1fe8662..02934ced7 100644 --- a/AUTHORS +++ b/AUTHORS @@ -80,6 +80,9 @@ Henry Maddocks Paul Fredrikson - new Matrix implementation. +Sasa Bistrivic + - option for detailed calculation of the near clipping plane during cull traversal. + Indirect Contributors --------------------- diff --git a/include/osgUtil/Optimizer b/include/osgUtil/Optimizer index 863a13889..bb191bfb9 100644 --- a/include/osgUtil/Optimizer +++ b/include/osgUtil/Optimizer @@ -49,12 +49,16 @@ class OSGUTIL_EXPORT Optimizer public: typedef std::vector MatrixStack; - MatrixStack _matrixStack; typedef std::set TransformList; - TransformList _transformList; + + MatrixStack _matrixStack; + TransformList _transformList; + bool _ignoreDynamicTransforms; - FlattenStaticTransformsVisitor():osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN) {} + FlattenStaticTransformsVisitor(bool ignoreDynamicTransforms=true): + osg::NodeVisitor(osg::NodeVisitor::TRAVERSE_ALL_CHILDREN), + _ignoreDynamicTransforms(ignoreDynamicTransforms) {} virtual void apply(osg::Geode& geode); virtual void apply(osg::Billboard& billboard); diff --git a/src/osgPlugins/osg/Transform.cpp b/src/osgPlugins/osg/Transform.cpp index 7b7c2d1e6..749fe4935 100644 --- a/src/osgPlugins/osg/Transform.cpp +++ b/src/osgPlugins/osg/Transform.cpp @@ -77,8 +77,8 @@ bool Transform_writeLocalData(const Object& obj, Output& fw) switch(transform.getType()) { - case(osg::Transform::STATIC): fw.indent() << "Type STATIC" << std::endl; - default: fw.indent() << "Type DYNAMIC" << std::endl; + case(osg::Transform::STATIC): fw.indent() << "Type STATIC" << std::endl;break; + default: fw.indent() << "Type DYNAMIC" << std::endl;break; } fw.writeObject(transform.getMatrix()); diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index 12376a46c..bcfc7b5e3 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -353,25 +353,32 @@ void Optimizer::FlattenStaticTransformsVisitor::apply(osg::LOD& lod) void Optimizer::FlattenStaticTransformsVisitor::apply(osg::Transform& transform) { - if (_matrixStack.empty()) + if (_ignoreDynamicTransforms && transform.getType()==osg::Transform::DYNAMIC) { - _matrixStack.push_back(transform.getMatrix()); + // simple traverse the children as if this Transform didn't exist. + traverse(transform); } else - { - _matrixStack.push_back(transform.getMatrix()*_matrixStack.back()); + { + if (_matrixStack.empty()) + { + _matrixStack.push_back(transform.getMatrix()); + } + else + { + _matrixStack.push_back(transform.getMatrix()*_matrixStack.back()); + } + + _transformList.insert(&transform); + + // simple traverse the children as if this Transform didn't exist. + traverse(transform); + + // reset the matrix to identity. + transform.setMatrix(osg::Matrix::identity()); + + _matrixStack.pop_back(); } - - traverse(transform); - - _transformList.insert(&transform); - - // reset the matrix to identity. - transform.setMatrix(osg::Matrix::identity()); - - transform.dirtyBound(); - - _matrixStack.pop_back(); } void Optimizer::FlattenStaticTransformsVisitor::removeTransforms()