mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-21 05:37:52 -06:00
Fixed cracks in MMU painting gizmo. All triangles, even not painted triangles, are now rendered inside MMU painting gizmo.
The cracks were caused by using glPolygonOffset to resolve Z-fighting. All triangles of the object were firstly rendered entirely with a base color. And then paint triangles were drawn over these already rendered triangles.
This commit is contained in:
parent
de9ed9ee3e
commit
7377fc34ac
4 changed files with 22 additions and 25 deletions
|
@ -1168,10 +1168,11 @@ void GLCanvas3D::toggle_model_objects_visibility(bool visible, const ModelObject
|
||||||
const GLGizmosManager& gm = get_gizmos_manager();
|
const GLGizmosManager& gm = get_gizmos_manager();
|
||||||
auto gizmo_type = gm.get_current_type();
|
auto gizmo_type = gm.get_current_type();
|
||||||
if ( (gizmo_type == GLGizmosManager::FdmSupports
|
if ( (gizmo_type == GLGizmosManager::FdmSupports
|
||||||
|| gizmo_type == GLGizmosManager::Seam
|
|| gizmo_type == GLGizmosManager::Seam)
|
||||||
|| gizmo_type == GLGizmosManager::MmuSegmentation)
|
|
||||||
&& ! vol->is_modifier)
|
&& ! vol->is_modifier)
|
||||||
vol->force_neutral_color = true;
|
vol->force_neutral_color = true;
|
||||||
|
else if (gizmo_type == GLGizmosManager::MmuSegmentation)
|
||||||
|
vol->is_active = false;
|
||||||
else
|
else
|
||||||
vol->force_native_color = true;
|
vol->force_native_color = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ void GLGizmoMmuSegmentation::render_painter_gizmo() const
|
||||||
glsafe(::glEnable(GL_BLEND));
|
glsafe(::glEnable(GL_BLEND));
|
||||||
glsafe(::glEnable(GL_DEPTH_TEST));
|
glsafe(::glEnable(GL_DEPTH_TEST));
|
||||||
|
|
||||||
render_triangles(selection);
|
render_triangles(selection, false);
|
||||||
|
|
||||||
m_c->object_clipper()->render_cut();
|
m_c->object_clipper()->render_cut();
|
||||||
render_cursor();
|
render_cursor();
|
||||||
|
|
|
@ -13,8 +13,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r::GUI {
|
||||||
namespace GUI {
|
|
||||||
|
|
||||||
|
|
||||||
GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
|
||||||
|
@ -110,13 +109,15 @@ void GLGizmoPainterBase::set_painter_gizmo_data(const Selection& selection)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void GLGizmoPainterBase::render_triangles(const Selection& selection) const
|
void GLGizmoPainterBase::render_triangles(const Selection& selection, const bool use_polygon_offset_fill) const
|
||||||
{
|
{
|
||||||
const ModelObject* mo = m_c->selection_info()->model_object();
|
const ModelObject* mo = m_c->selection_info()->model_object();
|
||||||
|
|
||||||
|
if (use_polygon_offset_fill) {
|
||||||
glsafe(::glEnable(GL_POLYGON_OFFSET_FILL));
|
glsafe(::glEnable(GL_POLYGON_OFFSET_FILL));
|
||||||
ScopeGuard offset_fill_guard([]() { glsafe(::glDisable(GL_POLYGON_OFFSET_FILL)); });
|
ScopeGuard offset_fill_guard([]() { glsafe(::glDisable(GL_POLYGON_OFFSET_FILL)); });
|
||||||
glsafe(::glPolygonOffset(-5.0, -5.0));
|
glsafe(::glPolygonOffset(-5.0, -5.0));
|
||||||
|
}
|
||||||
|
|
||||||
// Take care of the clipping plane. The normal of the clipping plane is
|
// Take care of the clipping plane. The normal of the clipping plane is
|
||||||
// saved with opposite sign than we need to pass to OpenGL (FIXME)
|
// saved with opposite sign than we need to pass to OpenGL (FIXME)
|
||||||
|
@ -590,12 +591,8 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
||||||
if (!tr.valid() || tr.is_split() || tr.get_state() == EnforcerBlockerType::NONE || tr.is_selected_by_seed_fill())
|
if (!tr.valid() || tr.is_split() || tr.get_state() == EnforcerBlockerType::NONE || tr.is_selected_by_seed_fill())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
GLIndexedVertexArray& va = tr.get_state() == EnforcerBlockerType::ENFORCER
|
GLIndexedVertexArray &va = tr.get_state() == EnforcerBlockerType::ENFORCER ? m_iva_enforcers : m_iva_blockers;
|
||||||
? m_iva_enforcers
|
int &cnt = tr.get_state() == EnforcerBlockerType::ENFORCER ? enf_cnt : blc_cnt;
|
||||||
: m_iva_blockers;
|
|
||||||
int& cnt = tr.get_state() == EnforcerBlockerType::ENFORCER
|
|
||||||
? enf_cnt
|
|
||||||
: blc_cnt;
|
|
||||||
|
|
||||||
for (int i=0; i<3; ++i)
|
for (int i=0; i<3; ++i)
|
||||||
va.push_geometry(m_vertices[tr.verts_idxs[i]].v, m_mesh->stl.facet_start[tr.source_triangle].normal);
|
va.push_geometry(m_vertices[tr.verts_idxs[i]].v, m_mesh->stl.facet_start[tr.source_triangle].normal);
|
||||||
|
@ -746,5 +743,4 @@ void TriangleSelectorGUI::render_debug(ImGuiWrapper* imgui)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // namespace GUI
|
} // namespace Slic3r::GUI
|
||||||
} // namespace Slic3r
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ public:
|
||||||
virtual void render_painter_gizmo() const = 0;
|
virtual void render_painter_gizmo() const = 0;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void render_triangles(const Selection& selection) const;
|
void render_triangles(const Selection& selection, const bool use_polygon_offset_fill = true) const;
|
||||||
void render_cursor() const;
|
void render_cursor() const;
|
||||||
void render_cursor_circle() const;
|
void render_cursor_circle() const;
|
||||||
void render_cursor_sphere(const Transform3d& trafo) const;
|
void render_cursor_sphere(const Transform3d& trafo) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue