Smoothen rotation in 3D viewer when crossing the 0-2pi line
Rotating to 0 when above pi would result in the board spinning back
through pi to get there. This led to jarring motion.
Also fix an issue added in b6f64815
where the board would rotate
2pi when crossing over the 0-2pi boundary.
This commit is contained in:
parent
6cb32fe9ef
commit
4fc9b4e5ab
|
@ -106,6 +106,20 @@ void CCAMERA::Reset_T1()
|
|||
m_zoom_t1 = 1.0f;
|
||||
m_rotate_aux_t1 = SFVEC3F( 0.0f );
|
||||
m_lookat_pos_t1 = m_board_lookat_pos_init;
|
||||
|
||||
|
||||
// Since 0 = 2pi, we want to reset the angle to be the closest
|
||||
// one to where we currently are. That ensures that we rotate
|
||||
// the board around the smallest distance getting there.
|
||||
if( m_rotate_aux_t0.x > M_PI )
|
||||
m_rotate_aux_t1.x = 2*M_PI;
|
||||
|
||||
if( m_rotate_aux_t0.y > M_PI )
|
||||
m_rotate_aux_t1.y = 2*M_PI;
|
||||
|
||||
if( m_rotate_aux_t0.z > M_PI )
|
||||
m_rotate_aux_t1.z = 2*M_PI;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -119,20 +133,20 @@ void CCAMERA::updateViewMatrix()
|
|||
|
||||
void CCAMERA::updateRotationMatrix()
|
||||
{
|
||||
normalise2PI( m_rotate_aux.x );
|
||||
m_rotationMatrixAux = glm::rotate( glm::mat4( 1.0f ),
|
||||
m_rotate_aux.x,
|
||||
SFVEC3F( 1.0f, 0.0f, 0.0f ) );
|
||||
normalise2PI( m_rotate_aux.x );
|
||||
|
||||
normalise2PI( m_rotate_aux.y );
|
||||
m_rotationMatrixAux = glm::rotate( m_rotationMatrixAux,
|
||||
m_rotate_aux.y,
|
||||
SFVEC3F( 0.0f, 1.0f, 0.0f ) );
|
||||
normalise2PI( m_rotate_aux.y );
|
||||
|
||||
normalise2PI( m_rotate_aux.z );
|
||||
m_rotationMatrixAux = glm::rotate( m_rotationMatrixAux,
|
||||
m_rotate_aux.z,
|
||||
SFVEC3F( 0.0f, 0.0f, 1.0f ) );
|
||||
normalise2PI( m_rotate_aux.z );
|
||||
|
||||
m_parametersChanged = true;
|
||||
|
||||
|
@ -533,21 +547,18 @@ void CCAMERA::RotateZ( float aAngleInRadians )
|
|||
void CCAMERA::RotateX_T1( float aAngleInRadians )
|
||||
{
|
||||
m_rotate_aux_t1.x += aAngleInRadians;
|
||||
normalise2PI( m_rotate_aux_t1.x );
|
||||
}
|
||||
|
||||
|
||||
void CCAMERA::RotateY_T1( float aAngleInRadians )
|
||||
{
|
||||
m_rotate_aux_t1.y += aAngleInRadians;
|
||||
normalise2PI( m_rotate_aux_t1.y );
|
||||
}
|
||||
|
||||
|
||||
void CCAMERA::RotateZ_T1( float aAngleInRadians )
|
||||
{
|
||||
m_rotate_aux_t1.z += aAngleInRadians;
|
||||
normalise2PI( m_rotate_aux_t1.z );
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue