mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 08:47:52 -06:00
ENABLE_3DCONNEXION_DEVICES -> Update 3D scene only when mouse 3D device send update messages
This commit is contained in:
parent
5a94ac9499
commit
0ba9fbaf0c
2 changed files with 18 additions and 4 deletions
|
@ -2323,8 +2323,7 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
|
||||||
m_dirty |= m_undoredo_toolbar.update_items_state();
|
m_dirty |= m_undoredo_toolbar.update_items_state();
|
||||||
m_dirty |= m_view_toolbar.update_items_state();
|
m_dirty |= m_view_toolbar.update_items_state();
|
||||||
#if ENABLE_3DCONNEXION_DEVICES
|
#if ENABLE_3DCONNEXION_DEVICES
|
||||||
bool mouse3d_controller_applied = wxGetApp().plater()->get_mouse3d_controller().apply(m_camera);
|
m_dirty |= wxGetApp().plater()->get_mouse3d_controller().apply(m_camera);
|
||||||
m_dirty |= mouse3d_controller_applied;
|
|
||||||
#endif // ENABLE_3DCONNEXION_DEVICES
|
#endif // ENABLE_3DCONNEXION_DEVICES
|
||||||
|
|
||||||
if (!m_dirty)
|
if (!m_dirty)
|
||||||
|
@ -2333,7 +2332,7 @@ void GLCanvas3D::on_idle(wxIdleEvent& evt)
|
||||||
_refresh_if_shown_on_screen();
|
_refresh_if_shown_on_screen();
|
||||||
|
|
||||||
#if ENABLE_3DCONNEXION_DEVICES
|
#if ENABLE_3DCONNEXION_DEVICES
|
||||||
if (m_keep_dirty || wxGetApp().plater()->get_mouse3d_controller().is_device_connected())
|
if (m_keep_dirty)
|
||||||
{
|
{
|
||||||
m_dirty = true;
|
m_dirty = true;
|
||||||
evt.RequestMore();
|
evt.RequestMore();
|
||||||
|
|
|
@ -349,6 +349,8 @@ void Mouse3DController::collect_input()
|
||||||
|
|
||||||
if (res > 0)
|
if (res > 0)
|
||||||
{
|
{
|
||||||
|
bool updated = false;
|
||||||
|
|
||||||
switch (retrieved_data[0])
|
switch (retrieved_data[0])
|
||||||
{
|
{
|
||||||
case Translation:
|
case Translation:
|
||||||
|
@ -356,8 +358,11 @@ void Mouse3DController::collect_input()
|
||||||
Vec3d translation(-convert_input(retrieved_data[1], retrieved_data[2]),
|
Vec3d translation(-convert_input(retrieved_data[1], retrieved_data[2]),
|
||||||
convert_input(retrieved_data[3], retrieved_data[4]),
|
convert_input(retrieved_data[3], retrieved_data[4]),
|
||||||
convert_input(retrieved_data[5], retrieved_data[6]));
|
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);
|
m_state.set_translation(translation);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -367,7 +372,10 @@ void Mouse3DController::collect_input()
|
||||||
(float)convert_input(retrieved_data[3], retrieved_data[4]),
|
(float)convert_input(retrieved_data[3], retrieved_data[4]),
|
||||||
-(float)convert_input(retrieved_data[5], retrieved_data[6]));
|
-(float)convert_input(retrieved_data[5], retrieved_data[6]));
|
||||||
if (!rotation.isApprox(Vec3f::Zero()))
|
if (!rotation.isApprox(Vec3f::Zero()))
|
||||||
|
{
|
||||||
|
updated = true;
|
||||||
m_state.set_rotation(rotation);
|
m_state.set_rotation(rotation);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -383,7 +391,10 @@ void Mouse3DController::collect_input()
|
||||||
for (unsigned int i = 0; i < 8; ++i)
|
for (unsigned int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
if (retrieved_data[1] & (0x1 << i))
|
if (retrieved_data[1] & (0x1 << i))
|
||||||
|
{
|
||||||
|
updated = true;
|
||||||
m_state.set_button(i);
|
m_state.set_button(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// // On the other hand, other libraries, as in https://github.com/koenieee/CrossplatformSpacemouseDriver/blob/master/SpaceMouseDriver/driver/SpaceMouseController.cpp
|
// // 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:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (updated)
|
||||||
|
// ask for an idle event to update 3D scene
|
||||||
|
wxWakeUpIdle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue