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

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEnrico Turri <enricoturri@seznam.cz>2019-06-14 16:37:29 +0300
committerEnrico Turri <enricoturri@seznam.cz>2019-06-14 16:37:29 +0300
commitac8de0bcaff04b6dc038128c1544ed182f5b3f14 (patch)
treee966b1d8b2c34aef5a078c764a40ba764d5b50f9 /src
parent541f58c65617eb1f341fe47105fc57c57ab2b710 (diff)
Follow-up of 1a91add2e60f3a4d22cdd6c8a10e57dc8095e0a2 -> Improvements to tighter camera frustrum to reduce z-fighting
Diffstat (limited to 'src')
-rw-r--r--src/slic3r/GUI/3DBed.cpp20
-rw-r--r--src/slic3r/GUI/3DBed.hpp1
-rw-r--r--src/slic3r/GUI/3DScene.hpp1
-rw-r--r--src/slic3r/GUI/Camera.cpp9
-rw-r--r--src/slic3r/GUI/GLCanvas3D.cpp4
5 files changed, 17 insertions, 18 deletions
diff --git a/src/slic3r/GUI/3DBed.cpp b/src/slic3r/GUI/3DBed.cpp
index c82b34f49..404fb4774 100644
--- a/src/slic3r/GUI/3DBed.cpp
+++ b/src/slic3r/GUI/3DBed.cpp
@@ -211,7 +211,7 @@ const double Bed3D::Axes::ArrowLength = 5.0;
Bed3D::Axes::Axes()
: origin(Vec3d::Zero())
-, length(Vec3d::Zero())
+, length(25.0 * Vec3d::Ones())
{
m_quadric = ::gluNewQuadric();
if (m_quadric != nullptr)
@@ -273,7 +273,6 @@ void Bed3D::Axes::render_axis(double length) const
Bed3D::Bed3D()
: m_type(Custom)
- , m_extended_bounding_box_dirty(true)
#if ENABLE_TEXTURES_FROM_SVG
, m_vbo_id(0)
#endif // ENABLE_TEXTURES_FROM_SVG
@@ -314,8 +313,6 @@ bool Bed3D::set_shape(const Pointfs& shape)
m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z);
m_axes.length = 0.1 * m_bounding_box.max_size() * Vec3d::Ones();
- m_extended_bounding_box_dirty = true;
-
// Let the calee to update the UI.
return true;
}
@@ -413,17 +410,12 @@ void Bed3D::calc_bounding_boxes() const
m_extended_bounding_box = m_bounding_box;
- if (m_extended_bounding_box_dirty)
- {
- // extend to contain Z axis
- m_extended_bounding_box.merge(0.1 * m_bounding_box.max_size() * Vec3d::UnitZ());
+ // extend to contain axes
+ m_extended_bounding_box.merge(m_axes.length + Axes::ArrowLength * Vec3d::Ones());
- if (!m_model.get_filename().empty())
- // extend to contain model
- m_extended_bounding_box.merge(m_model.get_bounding_box());
-
- m_extended_bounding_box_dirty = false;
- }
+ // extend to contain model, if any
+ if (!m_model.get_filename().empty())
+ m_extended_bounding_box.merge(m_model.get_transformed_bounding_box());
}
void Bed3D::calc_triangles(const ExPolygon& poly)
diff --git a/src/slic3r/GUI/3DBed.hpp b/src/slic3r/GUI/3DBed.hpp
index 79e96fdf0..98da03542 100644
--- a/src/slic3r/GUI/3DBed.hpp
+++ b/src/slic3r/GUI/3DBed.hpp
@@ -87,7 +87,6 @@ private:
Pointfs m_shape;
mutable BoundingBoxf3 m_bounding_box;
mutable BoundingBoxf3 m_extended_bounding_box;
- mutable bool m_extended_bounding_box_dirty;
Polygon m_polygon;
GeometryBuffer m_triangles;
GeometryBuffer m_gridlines;
diff --git a/src/slic3r/GUI/3DScene.hpp b/src/slic3r/GUI/3DScene.hpp
index 2ca11073b..c0613badd 100644
--- a/src/slic3r/GUI/3DScene.hpp
+++ b/src/slic3r/GUI/3DScene.hpp
@@ -555,6 +555,7 @@ public:
const std::string& get_filename() const { return m_filename; }
const BoundingBoxf3& get_bounding_box() const { return m_volume.bounding_box; }
+ const BoundingBoxf3& get_transformed_bounding_box() const { return m_volume.transformed_bounding_box(); }
void reset();
diff --git a/src/slic3r/GUI/Camera.cpp b/src/slic3r/GUI/Camera.cpp
index 1fc2f6be3..f6cefc801 100644
--- a/src/slic3r/GUI/Camera.cpp
+++ b/src/slic3r/GUI/Camera.cpp
@@ -169,6 +169,7 @@ void Camera::debug_render() const
Vec3f up = get_dir_up().cast<float>();
float nearZ = (float)m_frustrum_zs.first;
float farZ = (float)m_frustrum_zs.second;
+ float deltaZ = farZ - nearZ;
ImGui::InputText("Type", const_cast<char*>(type.data()), type.length(), ImGuiInputTextFlags_ReadOnly);
ImGui::Separator();
@@ -181,6 +182,7 @@ void Camera::debug_render() const
ImGui::Separator();
ImGui::InputFloat("Near Z", &nearZ, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags_ReadOnly);
ImGui::InputFloat("Far Z", &farZ, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags_ReadOnly);
+ ImGui::InputFloat("Delta Z", &deltaZ, 0.0f, 0.0f, "%.6f", ImGuiInputTextFlags_ReadOnly);
imgui.end();
}
#endif // ENABLE_CAMERA_STATISTICS
@@ -230,7 +232,12 @@ std::pair<double, double> Camera::calc_tight_frustrum_zs_around(const BoundingBo
// ensure min size
if (ret.second - ret.first < FrustrumMinZSize)
- ret.second = ret.first + FrustrumMinZSize;
+ {
+ double mid_z = 0.5 * (ret.first + ret.second);
+ double half_size = 0.5 * FrustrumMinZSize;
+ ret.first = mid_z - half_size;
+ ret.second = mid_z + half_size;
+ }
assert(ret.first > 0.0);
diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp
index faee2727d..fd77b4609 100644
--- a/src/slic3r/GUI/GLCanvas3D.cpp
+++ b/src/slic3r/GUI/GLCanvas3D.cpp
@@ -1590,8 +1590,8 @@ void GLCanvas3D::render()
if (m_camera.requires_zoom_to_bed)
{
zoom_to_bed();
- const Size& cnv_size = get_canvas_size();
- _resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
+// const Size& cnv_size = get_canvas_size();
+// _resize((unsigned int)cnv_size.get_width(), (unsigned int)cnv_size.get_height());
m_camera.requires_zoom_to_bed = false;
}