From 00d9e77e7fba21d8150ad24759c32ffbd51c8620 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Tue, 31 Mar 2020 17:35:45 +0200 Subject: [PATCH] 3D viewer: fix a minor problem: to many rotations when typing Shift+z or Shift+y more than once. Fixes #4135 https://gitlab.com/kicad/code/kicad/issues/4135 --- 3d-viewer/3d_canvas/eda_3d_canvas.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/3d-viewer/3d_canvas/eda_3d_canvas.cpp b/3d-viewer/3d_canvas/eda_3d_canvas.cpp index ad1c9e7ffa..15e9534b56 100644 --- a/3d-viewer/3d_canvas/eda_3d_canvas.cpp +++ b/3d-viewer/3d_canvas/eda_3d_canvas.cpp @@ -912,8 +912,11 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_camera.SetT0_and_T1_current_T(); m_camera.Reset_T1(); - m_camera.RotateX_T1( glm::radians( -90.0f ) ); - m_camera.RotateZ_T1( glm::radians( -180.0f ) ); + m_camera.RotateX_T1( glm::radians( -90.0f ) ); + // The rotation angle should be 180. + // We use 179.999 (180 - epsilon) to avoid a full 360 deg rotation when + // using 180 deg if the previous rotated position was already 180 deg + m_camera.RotateZ_T1( glm::radians( 179.999f ) ); request_start_moving_camera(); return true; @@ -928,7 +931,7 @@ bool EDA_3D_CANVAS::SetView3D( int aKeycode ) m_camera.SetInterpolateMode( CAMERA_INTERPOLATION::BEZIER ); m_camera.SetT0_and_T1_current_T(); m_camera.Reset_T1(); - m_camera.RotateY_T1( glm::radians( 180.0f ) ); + m_camera.RotateY_T1( glm::radians( 179.999f ) ); // Rotation = 180 - epsilon request_start_moving_camera( glm::min( glm::max( m_camera.ZoomGet(), 0.5f ), 1.125f ) ); return true;