ENABLE_3DCONNEXION_DEVICES -> Update 3D scene only when mouse 3D device send update messages
This commit is contained in:
parent
5a94ac9499
commit
0ba9fbaf0c
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user