Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/supermerill/SuperSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2019-06-14 11:38:09 +0300
committerEnrico Turri <enricoturri@seznam.cz>2019-06-14 11:38:09 +0300
commit1a91add2e60f3a4d22cdd6c8a10e57dc8095e0a2 (patch)
tree711eca9fdaeb3e304ba91667f00eaad21bab61a3 /src/slic3r/GUI/Camera.hpp
parenta99466ef1df99d52277a5f78a4fbb5481d2dd584 (diff)
Tighter camera frustrum to reduce z-fighting
Diffstat (limited to 'src/slic3r/GUI/Camera.hpp')
-rw-r--r--src/slic3r/GUI/Camera.hpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/slic3r/GUI/Camera.hpp b/src/slic3r/GUI/Camera.hpp
index 83dbb0f6d..18dec6083 100644
--- a/src/slic3r/GUI/Camera.hpp
+++ b/src/slic3r/GUI/Camera.hpp
@@ -10,6 +10,8 @@ namespace GUI {
struct Camera
{
static const float DefaultDistance;
+ static double FrustrumMinZSize;
+ static double FrustrumZMargin;
enum EType : unsigned char
{
@@ -34,6 +36,7 @@ private:
mutable std::array<int, 4> m_viewport;
mutable Transform3d m_view_matrix;
mutable Transform3d m_projection_matrix;
+ mutable std::pair<double, double> m_frustrum_zs;
BoundingBoxf3 m_scene_box;
@@ -63,6 +66,9 @@ public:
Vec3d get_position() const { return m_view_matrix.matrix().inverse().block(0, 3, 3, 1); }
+ double get_near_z() const { return m_frustrum_zs.first; }
+ double get_far_z() const { return m_frustrum_zs.second; }
+
void apply_viewport(int x, int y, unsigned int w, unsigned int h) const;
void apply_view_matrix() const;
void apply_projection(const BoundingBoxf3& box) const;
@@ -73,6 +79,9 @@ public:
private:
void apply_ortho_projection(double x_min, double x_max, double y_min, double y_max, double z_min, double z_max) const;
+ // 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;
};
} // GUI