diff --git a/src/slic3r/GUI/Camera.hpp b/src/slic3r/GUI/Camera.hpp index 4b9144519..b784e7b96 100644 --- a/src/slic3r/GUI/Camera.hpp +++ b/src/slic3r/GUI/Camera.hpp @@ -122,6 +122,13 @@ public: // returns true if the camera z axis (forward) is pointing in the negative direction of the world z axis bool is_looking_downward() const { return get_dir_forward().dot(Vec3d::UnitZ()) < 0.0; } + // forces camera right vector to be parallel to XY plane + void recover_from_free_camera() + { + if (std::abs(get_dir_right()(2)) > EPSILON) + look_at(get_position(), m_target, Vec3d::UnitZ()); + } + void look_at(const Vec3d& position, const Vec3d& target, const Vec3d& up); double max_zoom() const { return 100.0; } diff --git a/src/slic3r/GUI/Mouse3DController.cpp b/src/slic3r/GUI/Mouse3DController.cpp index 0cd39b092..5ff817c59 100644 --- a/src/slic3r/GUI/Mouse3DController.cpp +++ b/src/slic3r/GUI/Mouse3DController.cpp @@ -388,6 +388,9 @@ void Mouse3DController::disconnected() m_params_by_device[m_device_str] = m_params_ui; m_device_str.clear(); m_connected = false; + wxGetApp().plater()->get_camera().recover_from_free_camera(); + wxGetApp().plater()->set_current_canvas_as_dirty(); + wxWakeUpIdle(); } } @@ -773,7 +776,10 @@ void Mouse3DController::disconnect_device() } m_device_str.clear(); m_connected = false; - } + wxGetApp().plater()->get_camera().recover_from_free_camera(); + wxGetApp().plater()->set_current_canvas_as_dirty(); + wxWakeUpIdle(); + } } void Mouse3DController::collect_input() diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index d7d6f419d..0beddc358 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -2277,11 +2277,7 @@ void Plater::priv::update_ui_from_settings() camera.set_type(wxGetApp().app_config->get("use_perspective_camera")); if (wxGetApp().app_config->get("use_free_camera") != "1") - { - // forces camera right vector to be parallel to XY plane - if (std::abs(camera.get_dir_right()(2)) > EPSILON) - camera.look_at(camera.get_position(), camera.get_target(), Vec3d::UnitZ()); - } + camera.recover_from_free_camera(); view3D->get_canvas3d()->update_ui_from_settings(); preview->get_canvas3d()->update_ui_from_settings(); @@ -5661,6 +5657,11 @@ const Camera& Plater::get_camera() const return p->camera; } +Camera& Plater::get_camera() +{ + return p->camera; +} + const Mouse3DController& Plater::get_mouse3d_controller() const { return p->mouse3d_controller; diff --git a/src/slic3r/GUI/Plater.hpp b/src/slic3r/GUI/Plater.hpp index dbf706988..89603f703 100644 --- a/src/slic3r/GUI/Plater.hpp +++ b/src/slic3r/GUI/Plater.hpp @@ -280,6 +280,7 @@ public: bool init_view_toolbar(); const Camera& get_camera() const; + Camera& get_camera(); const Mouse3DController& get_mouse3d_controller() const; Mouse3DController& get_mouse3d_controller();