diff options
Diffstat (limited to 'src/slic3r/GUI/Camera.hpp')
-rw-r--r-- | src/slic3r/GUI/Camera.hpp | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/src/slic3r/GUI/Camera.hpp b/src/slic3r/GUI/Camera.hpp index b784e7b96..91f4661b4 100644 --- a/src/slic3r/GUI/Camera.hpp +++ b/src/slic3r/GUI/Camera.hpp @@ -2,9 +2,7 @@ #define slic3r_Camera_hpp_ #include "libslic3r/BoundingBox.hpp" -#if ENABLE_THUMBNAIL_GENERATOR #include "3DScene.hpp" -#endif // ENABLE_THUMBNAIL_GENERATOR #include <array> namespace Slic3r { @@ -13,10 +11,8 @@ namespace GUI { struct Camera { static const double DefaultDistance; -#if ENABLE_THUMBNAIL_GENERATOR static const double DefaultZoomToBoxMarginFactor; static const double DefaultZoomToVolumesMarginFactor; -#endif // ENABLE_THUMBNAIL_GENERATOR static double FrustrumMinZRange; static double FrustrumMinNearZ; static double FrustrumZMargin; @@ -33,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; @@ -60,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); @@ -88,6 +87,7 @@ public: double get_near_z() const { return m_frustrum_zs.first; } double get_far_z() const { return m_frustrum_zs.second; } + const std::pair<double, double>& get_z_range() const { return m_frustrum_zs; } double get_fov() const; @@ -97,12 +97,8 @@ public: // If larger z span is needed, pass the desired values of near and far z (negative values are ignored) void apply_projection(const BoundingBoxf3& box, double near_z = -1.0, double far_z = -1.0) const; -#if ENABLE_THUMBNAIL_GENERATOR void zoom_to_box(const BoundingBoxf3& box, double margin_factor = DefaultZoomToBoxMarginFactor); void zoom_to_volumes(const GLVolumePtrs& volumes, double margin_factor = DefaultZoomToVolumesMarginFactor); -#else - void zoom_to_box(const BoundingBoxf3& box, int canvas_w, int canvas_h); -#endif // ENABLE_THUMBNAIL_GENERATOR #if ENABLE_CAMERA_STATISTICS void debug_render() const; @@ -131,19 +127,15 @@ public: void look_at(const Vec3d& position, const Vec3d& target, const Vec3d& up); - double max_zoom() const { return 100.0; } + double max_zoom() const { return 250.0; } double min_zoom() const; private: // returns tight values for nearZ and farZ plane around the given bounding box // the camera MUST be outside of the bounding box in eye coordinate of the given box std::pair<double, double> calc_tight_frustrum_zs_around(const BoundingBoxf3& box) const; -#if ENABLE_THUMBNAIL_GENERATOR double calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, double margin_factor = DefaultZoomToBoxMarginFactor) const; double calc_zoom_to_volumes_factor(const GLVolumePtrs& volumes, Vec3d& center, double margin_factor = DefaultZoomToVolumesMarginFactor) const; -#else - double calc_zoom_to_bounding_box_factor(const BoundingBoxf3& box, int canvas_w, int canvas_h) const; -#endif // ENABLE_THUMBNAIL_GENERATOR void set_distance(double distance) const; void set_default_orientation(); |