Commit 5d63870f authored by Robin Eschbach's avatar Robin Eschbach
Browse files

[FIX #553] DVR boundingbox

parent bf5c465a
......@@ -39,6 +39,7 @@ WGEZoomTrackballNodeVisitor::WGEZoomTrackballNodeVisitor( TraversalMode traversa
void WGEZoomTrackballNodeVisitor::reset()
{
m_matrixStack.clear();
m_bb.init();
}
......@@ -69,17 +70,37 @@ void WGEZoomTrackballNodeVisitor::apply( osg::Drawable& node ) // NOLINT
osg::BoundingBox bb = node.getBoundingBox();
if( bb.valid() )
{
m_bb.expandBy( bb );
if( m_matrixStack.empty() )
{
m_bb.expandBy( bb );
}
else
{
osg::Matrix matrix = m_matrixStack.back();
m_bb.expandBy( bb.corner( 0 ) * matrix );
m_bb.expandBy( bb.corner( 1 ) * matrix );
m_bb.expandBy( bb.corner( 2 ) * matrix );
m_bb.expandBy( bb.corner( 3 ) * matrix );
m_bb.expandBy( bb.corner( 4 ) * matrix );
m_bb.expandBy( bb.corner( 5 ) * matrix );
m_bb.expandBy( bb.corner( 6 ) * matrix );
m_bb.expandBy( bb.corner( 7 ) * matrix );
}
}
}
void WGEZoomTrackballNodeVisitor::apply( osg::MatrixTransform& node ) // NOLINT
{
// Ignore grids.
if( !dynamic_cast< WGEGridNode* >( &node ) )
osg::Matrix matrix;
if( !m_matrixStack.empty() )
{
traverse( node );
matrix = m_matrixStack.back();
}
node.computeLocalToWorldMatrix( matrix, this );
m_matrixStack.push_back( matrix );
traverse( node );
m_matrixStack.pop_back();
}
osg::BoundingBox& WGEZoomTrackballNodeVisitor::getBoundingBox()
......
......@@ -26,9 +26,10 @@
#define WGEZOOMTRACKBALLNODEVISITOR_H
#include <limits>
#include <vector>
#include <osg/NodeVisitor>
#include <osg/BoundingBox>
#include <osg/NodeVisitor>
/**
* A visitor that ignores specific nodes that are irrelevant for the trackball.
......@@ -79,6 +80,7 @@ public:
private:
osg::BoundingBox m_bb; //!< The bounding box that is generated.
std::vector< osg::Matrix > m_matrixStack; //!< The stack for the matrices.
};
#endif // WGEZOOMTRACKBALLNODEVISITOR_H
  • Works well for me. I am looking forward to our meeting where you can explain your changes. I do not understand 100% ... more like 80%

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment