From 0ba9fbaf0c568f5f377bac6579ae693f856cfa7a Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Mon, 7 Oct 2019 09:31:23 +0200 Subject: [PATCH] ENABLE_3DCONNEXION_DEVICES -> Update 3D scene only when mouse 3D device send update messages --- src/slic3r/GUI/GLCanvas3D.cpp | 5 ++--- src/slic3r/GUI/Mouse3DController.cpp | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 6f94647ac..7b2b5f6d4 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -2323,8 +2323,7 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt) m_dirty |= m_undoredo_toolbar.update_items_state(); m_dirty |= m_view_toolbar.update_items_state(); #if ENABLE_3DCONNEXION_DEVICES - bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(m_camera); - m_dirty |= mouse3d_controller_applied; + m_dirty |= wxGetApp().plater()->get_mouse3d_controller().apply(m_camera); #endif // ENABLE_3DCONNEXION_DEVICES if (!m_dirty) @@ -2333,7 +2332,7 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt) _refresh_if_shown_on_screen(); #if ENABLE_3DCONNEXION_DEVICES - if (m_keep_dirty || wxGetApp().plater()->get_mouse3d_controller().is_device_connected()) + if (m_keep_dirty) { m_dirty = true; evt.RequestMore(); diff --git a/src/slic3r/GUI/Mouse3DController.cpp b/src/slic3r/GUI/Mouse3DController.cpp index d7e9bda4a..f32f54b2d 100644 --- a/src/slic3r/GUI/Mouse3DController.cpp +++ b/src/slic3r/GUI/Mouse3DController.cpp @@ -349,6 +349,8 @@ void Mouse3DController::collect_input() if (res > 0) { + bool updated = false; + switch (retrieved_data[0]) { case Translation: @@ -356,8 +358,11 @@ void Mouse3DController::collect_input() Vec3d translation(-convert_input(retrieved_data[1], retrieved_data[2]), convert_input(retrieved_data[3], retrieved_data[4]), convert_input(retrieved_data[5], retrieved_data[6])); - if (!translation.isApprox(Vec3d::Zero())) + if (!translation.isApprox(Vec3d::Zero())) + { + updated = true; m_state.set_translation(translation); + } break; } @@ -367,7 +372,10 @@ void Mouse3DController::collect_input() (float)convert_input(retrieved_data[3], retrieved_data[4]), -(float)convert_input(retrieved_data[5], retrieved_data[6])); if (!rotation.isApprox(Vec3f::Zero())) + { + updated = true; m_state.set_rotation(rotation); + } break; } @@ -383,7 +391,10 @@ void Mouse3DController::collect_input() for (unsigned int i = 0; i < 8; ++i) { if (retrieved_data[1] & (0x1 << i)) + { + updated = true; m_state.set_button(i); + } } // // On the other hand, other libraries, as in https://github.com/koenieee/CrossplatformSpacemouseDriver/blob/master/SpaceMouseDriver/driver/SpaceMouseController.cpp @@ -396,6 +407,10 @@ void Mouse3DController::collect_input() default: break; } + + if (updated) + // ask for an idle event to update 3D scene + wxWakeUpIdle(); } }