Commit 47dd55fb authored by Frédéric Larue's avatar Frédéric Larue

Bug fixed in the rotation center computation during grabbing.

parent 3501a9e3
......@@ -1624,15 +1624,13 @@ void GLViewer::enterGrabbingMode( bool translation )
if( dof() != DisplayDoF::DISPLAY_DOF_3D )
return;
bool itemsAvailableForGrabbing = false;
m_GrabbingBoundingBox.SetNull();
for( auto &d : m_Displayables )
if( d.second.displayable->isSelected() && d.second.displayable->isGrabbable() )
{
itemsAvailableForGrabbing = true;
break;
}
for( auto c : d.second.boundingBox.Corners() )
m_GrabbingBoundingBox.Add( d.second.UserTransform().map(c) );
if( itemsAvailableForGrabbing )
if( !m_GrabbingBoundingBox.IsNull() )
{
m_IsGrabbingTranslationEnabled = translation;
m_IsGrabbingRotationEnabled = !translation;
......@@ -1695,18 +1693,12 @@ void GLViewer::onGrabbing( QMouseEvent *evt )
}
else //if( m_IsGrabbingRotationEnabled )
{
Box3f selectionBox;
for( auto &d : m_Displayables )
if( d.second.displayable->isSelected() && d.second.displayable->isGrabbable() )
for( auto c : d.second.boundingBox.Corners() )
selectionBox.Add( d.second.UserTransform().map(c) );
xf.translate( selectionBox.Center() );
xf.translate( m_GrabbingBoundingBox.Center() );
if( m_GrabbingAxisConstraint < 0 )
xf.rotate( 0.5*dx, frontAxis() );
else
xf.rotate( 0.5*dx, constraintAxis );
xf.translate( -selectionBox.Center() );
xf.translate( -m_GrabbingBoundingBox.Center() );
}
for( auto &d : m_Displayables )
......@@ -1779,18 +1771,12 @@ void GLViewer::onGrabbing( QMouseEvent *evt )
dx = 0.5*(evt->pos().x() - m_PrevMousePos.x());
}
Box3f selectionBox;
for( auto &d : m_Displayables )
if( d.second.displayable->isSelected() && d.second.displayable->isGrabbable() )
for( auto c : d.second.boundingBox.Corners() )
selectionBox.Add( d.second.UserTransform().map(c) );
xf.translate( selectionBox.Center() );
xf.translate( m_GrabbingBoundingBox.Center() );
if( m_GrabbingAxisConstraint < 0 )
xf.rotate( dx, frontAxis() );
else
xf.rotate( dx, constraintAxis );
xf.translate( -selectionBox.Center() );
xf.translate( -m_GrabbingBoundingBox.Center() );
}
for( auto &d : m_Displayables )
......
......@@ -223,6 +223,7 @@ protected:
bool m_IsCursorInside;
Box3f m_GrabbingBoundingBox;
bool m_IsGrabbingTranslationEnabled = false;
bool m_IsGrabbingRotationEnabled = false;
int m_GrabbingAxisConstraint = -1;
......
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