mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-11 16:57:53 -06:00
Tighter camera frustrum to reduce z-fighting
This commit is contained in:
parent
a99466ef1d
commit
1a91add2e6
9 changed files with 123 additions and 71 deletions
|
@ -273,6 +273,7 @@ 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
|
||||
|
@ -290,7 +291,7 @@ bool Bed3D::set_shape(const Pointfs& shape)
|
|||
m_shape = shape;
|
||||
m_type = new_type;
|
||||
|
||||
calc_bounding_box();
|
||||
calc_bounding_boxes();
|
||||
|
||||
ExPolygon poly;
|
||||
for (const Vec2d& p : m_shape)
|
||||
|
@ -311,7 +312,9 @@ bool Bed3D::set_shape(const Pointfs& shape)
|
|||
|
||||
// Set the origin and size for painting of the coordinate system axes.
|
||||
m_axes.origin = Vec3d(0.0, 0.0, (double)GROUND_Z);
|
||||
m_axes.length = 0.1 * get_bounding_box().max_size() * Vec3d::Ones();
|
||||
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;
|
||||
|
@ -400,13 +403,27 @@ void Bed3D::render_axes() const
|
|||
m_axes.render();
|
||||
}
|
||||
|
||||
void Bed3D::calc_bounding_box()
|
||||
void Bed3D::calc_bounding_boxes() const
|
||||
{
|
||||
m_bounding_box = BoundingBoxf3();
|
||||
for (const Vec2d& p : m_shape)
|
||||
{
|
||||
m_bounding_box.merge(Vec3d(p(0), p(1), 0.0));
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void Bed3D::calc_triangles(const ExPolygon& poly)
|
||||
|
@ -539,6 +556,9 @@ void Bed3D::render_prusa(const std::string &key, bool bottom) const
|
|||
offset += Vec3d(0.0, 0.0, -0.03);
|
||||
|
||||
m_model.center_around(offset);
|
||||
|
||||
// update extended bounding box
|
||||
calc_bounding_boxes();
|
||||
}
|
||||
|
||||
if (!m_model.get_filename().empty())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue