Commit b1786d39 authored by Shuyao Guo's avatar Shuyao Guo

Fixed Manipulator Node

parent 13d4d19a
......@@ -326,14 +326,14 @@ ManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
case QEvent::MouseMove:
{
// IF sphere clicked rotate or change direction
if(sphere_clicked_)
{
{
bool hit0 = mapToSphere(_state, newPoint2D, newPoint3D);
bool hit1 = mapToSphere(_state, oldPoint2D_, oldPoint3D);
if (hit0 && hit1)
if ( (newPoint2D != oldPoint2D_) && hit0 && hit1)
{
// change direction
if(_event->modifiers() & Qt::ShiftModifier)
......@@ -350,8 +350,10 @@ ManipulatorNode::mouseEvent(GLState& _state, QMouseEvent* _event)
// rotate
else
{
Vec3d axis = oldPoint3D % newPoint3D;
double cos_angle = ( oldPoint3D | newPoint3D );
double cos_angle = ( oldPoint3D | newPoint3D );
if (fabs(cos_angle) < 1.0)
rotate(acos(cos_angle)*180.0/M_PI, axis);
......@@ -589,7 +591,8 @@ void ManipulatorNode::pick(GLState& _state, PickTarget _target) {
void
ManipulatorNode::set_direction(Vec3d& _v)
{
direction_ = inverse_rotation().transform_vector(_v.normalize());
direction_ = inverse_rotation().transform_vector(_v.normalize());
}
//----------------------------------------------------------------------------
......@@ -597,7 +600,8 @@ ManipulatorNode::set_direction(Vec3d& _v)
Vec3d
ManipulatorNode::direction() const
{
return rotation().transform_vector(direction_);
return rotation().transform_vector(direction_);
}
......
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