Added rendering of smart fill and contour around selected areas for the FDM supports painting gizmo.
This commit is contained in:
parent
2b59a16dc7
commit
542ba1bb9a
@ -569,6 +569,29 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &iva : m_iva_seed_fills)
|
||||
if (iva.has_VBOs()) {
|
||||
size_t color_idx = &iva - &m_iva_seed_fills.front();
|
||||
const std::array<float, 4> &color = TriangleSelectorGUI::get_seed_fill_color(color_idx == 1 ? enforcers_color :
|
||||
color_idx == 2 ? blockers_color :
|
||||
GLVolume::NEUTRAL_COLOR);
|
||||
shader->set_uniform("uniform_color", color);
|
||||
iva.render();
|
||||
}
|
||||
|
||||
if (m_paint_contour.has_VBO()) {
|
||||
ScopeGuard guard_gouraud([shader]() { shader->start_using(); });
|
||||
shader->stop_using();
|
||||
|
||||
auto *contour_shader = wxGetApp().get_shader("mm_contour");
|
||||
contour_shader->start_using();
|
||||
|
||||
glsafe(::glDepthFunc(GL_GEQUAL));
|
||||
m_paint_contour.render();
|
||||
glsafe(::glDepthFunc(GL_LESS));
|
||||
|
||||
contour_shader->stop_using();
|
||||
}
|
||||
|
||||
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
||||
if (imgui)
|
||||
@ -582,16 +605,25 @@ void TriangleSelectorGUI::update_render_data()
|
||||
{
|
||||
int enf_cnt = 0;
|
||||
int blc_cnt = 0;
|
||||
std::vector<int> seed_fill_cnt(m_iva_seed_fills.size(), 0);
|
||||
|
||||
for (auto *iva : {&m_iva_enforcers, &m_iva_blockers})
|
||||
iva->release_geometry();
|
||||
|
||||
for (auto &iva : m_iva_seed_fills)
|
||||
iva.release_geometry();
|
||||
|
||||
for (const Triangle &tr : m_triangles) {
|
||||
if (!tr.valid() || tr.is_split() || tr.get_state() == EnforcerBlockerType::NONE)
|
||||
if (!tr.valid() || tr.is_split() || (tr.get_state() == EnforcerBlockerType::NONE && !tr.is_selected_by_seed_fill()))
|
||||
continue;
|
||||
|
||||
GLIndexedVertexArray &iva = tr.get_state() == EnforcerBlockerType::ENFORCER ? m_iva_enforcers : m_iva_blockers;
|
||||
int & cnt = tr.get_state() == EnforcerBlockerType::ENFORCER ? enf_cnt : blc_cnt;
|
||||
int tr_state = int(tr.get_state());
|
||||
GLIndexedVertexArray &iva = tr.is_selected_by_seed_fill() ? m_iva_seed_fills[tr_state] :
|
||||
tr.get_state() == EnforcerBlockerType::ENFORCER ? m_iva_enforcers :
|
||||
m_iva_blockers;
|
||||
int &cnt = tr.is_selected_by_seed_fill() ? seed_fill_cnt[tr_state] :
|
||||
tr.get_state() == EnforcerBlockerType::ENFORCER ? enf_cnt :
|
||||
blc_cnt;
|
||||
const Vec3f &v0 = m_vertices[tr.verts_idxs[0]].v;
|
||||
const Vec3f &v1 = m_vertices[tr.verts_idxs[1]].v;
|
||||
const Vec3f &v2 = m_vertices[tr.verts_idxs[2]].v;
|
||||
@ -607,6 +639,28 @@ void TriangleSelectorGUI::update_render_data()
|
||||
|
||||
for (auto *iva : {&m_iva_enforcers, &m_iva_blockers})
|
||||
iva->finalize_geometry(true);
|
||||
|
||||
for (auto &iva : m_iva_seed_fills)
|
||||
iva.finalize_geometry(true);
|
||||
|
||||
m_paint_contour.release_geometry();
|
||||
std::vector<Vec2i> contour_edges = this->get_seed_fill_contour();
|
||||
m_paint_contour.contour_vertices.reserve(contour_edges.size() * 6);
|
||||
for (const Vec2i &edge : contour_edges) {
|
||||
m_paint_contour.contour_vertices.emplace_back(m_vertices[edge(0)].v.x());
|
||||
m_paint_contour.contour_vertices.emplace_back(m_vertices[edge(0)].v.y());
|
||||
m_paint_contour.contour_vertices.emplace_back(m_vertices[edge(0)].v.z());
|
||||
|
||||
m_paint_contour.contour_vertices.emplace_back(m_vertices[edge(1)].v.x());
|
||||
m_paint_contour.contour_vertices.emplace_back(m_vertices[edge(1)].v.y());
|
||||
m_paint_contour.contour_vertices.emplace_back(m_vertices[edge(1)].v.z());
|
||||
}
|
||||
|
||||
m_paint_contour.contour_indices.assign(m_paint_contour.contour_vertices.size() / 3, 0);
|
||||
std::iota(m_paint_contour.contour_indices.begin(), m_paint_contour.contour_indices.end(), 0);
|
||||
m_paint_contour.contour_indices_size = m_paint_contour.contour_indices.size();
|
||||
|
||||
m_paint_contour.finalize_geometry();
|
||||
}
|
||||
|
||||
void GLPaintContour::render() const
|
||||
|
@ -92,6 +92,7 @@ private:
|
||||
|
||||
GLIndexedVertexArray m_iva_enforcers;
|
||||
GLIndexedVertexArray m_iva_blockers;
|
||||
std::array<GLIndexedVertexArray, 3> m_iva_seed_fills;
|
||||
std::array<GLIndexedVertexArray, 3> m_varrays;
|
||||
|
||||
protected:
|
||||
|
@ -548,7 +548,7 @@ bool GLGizmosManager::on_mouse(wxMouseEvent& evt)
|
||||
// mouse anywhere
|
||||
if (evt.Moving()) {
|
||||
m_tooltip = update_hover_state(mouse_pos);
|
||||
if (m_current == MmuSegmentation)
|
||||
if (m_current == MmuSegmentation || m_current == FdmSupports)
|
||||
gizmo_event(SLAGizmoEventType::Moving, mouse_pos, evt.ShiftDown(), evt.AltDown());
|
||||
} else if (evt.LeftUp()) {
|
||||
if (m_mouse_capture.left) {
|
||||
|
Loading…
Reference in New Issue
Block a user