#4987 - Fixed camera switches back to non-Perspective camera after slice

This commit is contained in:
enricoturri1966 2020-10-27 14:01:42 +01:00
parent 30fb77b8d4
commit c8d875bee1
3 changed files with 18 additions and 22 deletions

View file

@ -32,15 +32,6 @@ double Camera::MaxFovDeg = 60.0;
Camera::Camera()
: requires_zoom_to_bed(false)
, m_type(Perspective)
, m_target(Vec3d::Zero())
, m_zenit(45.0f)
, m_zoom(1.0)
, m_distance(DefaultDistance)
, m_gui_scale(1.0)
, m_view_matrix(Transform3d::Identity())
, m_view_rotation(1., 0., 0., 0.)
, m_projection_matrix(Transform3d::Identity())
{
set_default_orientation();
}
@ -58,11 +49,12 @@ std::string Camera::get_type_as_string() const
void Camera::set_type(EType type)
{
if (m_type != type)
{
if (m_type != type) {
m_type = type;
wxGetApp().app_config->set("use_perspective_camera", (m_type == Perspective) ? "1" : "0");
wxGetApp().app_config->save();
if (m_update_config_on_type_change_enabled) {
wxGetApp().app_config->set("use_perspective_camera", (m_type == Perspective) ? "1" : "0");
wxGetApp().app_config->save();
}
}
}

View file

@ -29,19 +29,20 @@ struct Camera
bool requires_zoom_to_bed;
private:
EType m_type;
Vec3d m_target;
float m_zenit;
double m_zoom;
EType m_type{ Perspective };
bool m_update_config_on_type_change_enabled{ false };
Vec3d m_target{ Vec3d::Zero() };
float m_zenit{ 45.0f };
double m_zoom{ 1.0 };
// Distance between camera position and camera target measured along the camera Z axis
mutable double m_distance;
mutable double m_gui_scale;
mutable double m_distance{ DefaultDistance };
mutable double m_gui_scale{ 1.0 };
mutable std::array<int, 4> m_viewport;
mutable Transform3d m_view_matrix;
mutable Transform3d m_view_matrix{ Transform3d::Identity() };
// We are calculating the rotation part of the m_view_matrix from m_view_rotation.
mutable Eigen::Quaterniond m_view_rotation;
mutable Transform3d m_projection_matrix;
mutable Eigen::Quaterniond m_view_rotation{ 1.0, 0.0, 0.0, 0.0 };
mutable Transform3d m_projection_matrix{ Transform3d::Identity() };
mutable std::pair<double, double> m_frustrum_zs;
BoundingBoxf3 m_scene_box;
@ -56,6 +57,8 @@ public:
void set_type(const std::string& type);
void select_next_type();
void enable_update_config_on_type_change(bool enable) { m_update_config_on_type_change_enabled = enable; }
const Vec3d& get_target() const { return m_target; }
void set_target(const Vec3d& target);

View file

@ -2003,6 +2003,7 @@ Plater::priv::priv(Plater *q, MainFrame *main_frame)
#endif // ENABLE_GCODE_VIEWER
// updates camera type from .ini file
camera.enable_update_config_on_type_change(true);
camera.set_type(get_config("use_perspective_camera"));
// Load the 3DConnexion device database.