Commit c82929f7 authored by Robin Eschbach's avatar Robin Eschbach
Browse files

[FIX #474] rotation bounding box and centre calculation with node masks

parent 05d1a866
......@@ -161,6 +161,18 @@ bool WGEZoomTrackballManipulator::handle( const osgGA::GUIEventAdapter& ea, osgG
}
}
void WGEZoomTrackballManipulator::computeHomePosition( const osg::Camera *camera, bool )
{
TrackballManipulator::computeHomePosition( camera, true );
osg::Vec3d homeEye;
osg::Vec3d homeCenter;
osg::Vec3d homeUp;
TrackballManipulator::getHomePosition( homeEye, homeCenter, homeUp );
TrackballManipulator::setCenter( homeCenter );
}
void WGEZoomTrackballManipulator::setPaintMode( int mode )
{
m_paintMode = mode;
......
......@@ -83,6 +83,13 @@ public:
*/
virtual bool handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us );
/**
* Overloading the function to always use the bounding box and not the bounding spehere.
* \param camera The camera of the viewer.
* \param useBoundingBox This one is irrelevant as its value is ignored.
*/
virtual void computeHomePosition( const osg::Camera *camera = NULL, bool useBoundingBox = true );
/**
* Get zoom factor.
*
......
......@@ -47,6 +47,10 @@ void WGENodeMaskCallback::activate()
if( m_flag->get() ) // only handle activation here
{
m_reactivateSignal();
// Update the home position
WGEViewer::SPtr viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewer();
viewer->getCameraManipulator()->computeHomePosition( viewer->getCamera() );
}
}
......@@ -60,6 +64,10 @@ void WGENodeMaskCallback::operator()( osg::Node* node, osg::NodeVisitor* nv )
// NOTE: this also deactivates the callback. So reactivating the node is done in a separate method
// connect the flag's callback to the signal, only this way, we can ensure the reactivation of a node without saving a pointer to it.
m_reactivateConnection = m_reactivateSignal.connect( boost::bind( &osg::Node::setNodeMask, node, 0xFFFFFFFF ) );
// Update the home position
WGEViewer::SPtr viewer = WKernel::getRunningKernel()->getGraphicsEngine()->getViewer();
viewer->getCameraManipulator()->computeHomePosition( viewer->getCamera() );
}
traverse( node, nv );
......
......@@ -31,7 +31,8 @@
#include <osg/Camera>
#include <osg/Node>
#include "../../common/WFlag.h"
#include "core/common/WFlag.h"
#include "core/kernel/WKernel.h"
/**
* This callback is useful to en-/disable nodes using the node mask based on properties. In contrast to WGEManagedGroupNode, this callback can be
......
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