Tech ENABLE_GLBEGIN_GLEND_REMOVAL - Removed Slic3r::GUI::GLPaintContour from GLGizmoPainterBase.hpp/.cpp and replaced with GLModel
This commit is contained in:
parent
81e9582761
commit
df3d670357
@ -589,6 +589,9 @@ void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
|
|||||||
m_gizmo_scene.render(color_idx);
|
m_gizmo_scene.render(color_idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
render_paint_contour();
|
||||||
|
#else
|
||||||
if (m_paint_contour.has_VBO()) {
|
if (m_paint_contour.has_VBO()) {
|
||||||
ScopeGuard guard_mm_gouraud([shader]() { shader->start_using(); });
|
ScopeGuard guard_mm_gouraud([shader]() { shader->start_using(); });
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
@ -602,6 +605,7 @@ void TriangleSelectorMmGui::render(ImGuiWrapper *imgui)
|
|||||||
|
|
||||||
contour_shader->stop_using();
|
contour_shader->stop_using();
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
m_update_render_data = false;
|
m_update_render_data = false;
|
||||||
}
|
}
|
||||||
@ -636,6 +640,9 @@ void TriangleSelectorMmGui::update_render_data()
|
|||||||
|
|
||||||
m_gizmo_scene.finalize_triangle_indices();
|
m_gizmo_scene.finalize_triangle_indices();
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
update_paint_contour();
|
||||||
|
#else
|
||||||
m_paint_contour.release_geometry();
|
m_paint_contour.release_geometry();
|
||||||
std::vector<Vec2i> contour_edges = this->get_seed_fill_contour();
|
std::vector<Vec2i> contour_edges = this->get_seed_fill_contour();
|
||||||
m_paint_contour.contour_vertices.reserve(contour_edges.size() * 6);
|
m_paint_contour.contour_vertices.reserve(contour_edges.size() * 6);
|
||||||
@ -654,6 +661,7 @@ void TriangleSelectorMmGui::update_render_data()
|
|||||||
m_paint_contour.contour_indices_size = m_paint_contour.contour_indices.size();
|
m_paint_contour.contour_indices_size = m_paint_contour.contour_indices.size();
|
||||||
|
|
||||||
m_paint_contour.finalize_geometry();
|
m_paint_contour.finalize_geometry();
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString GLGizmoMmuSegmentation::handle_snapshot_action_name(bool shift_down, GLGizmoPainterBase::Button button_down) const
|
wxString GLGizmoMmuSegmentation::handle_snapshot_action_name(bool shift_down, GLGizmoPainterBase::Button button_down) const
|
||||||
|
@ -249,7 +249,7 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const
|
|||||||
glsafe(::glPushMatrix());
|
glsafe(::glPushMatrix());
|
||||||
glsafe(::glMultMatrixd(trafo.data()));
|
glsafe(::glMultMatrixd(trafo.data()));
|
||||||
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
|
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
|
||||||
glsafe(::glTranslatef(m_rr.hit(0), m_rr.hit(1), m_rr.hit(2)));
|
glsafe(::glTranslatef(m_rr.hit.x(), m_rr.hit.y(), m_rr.hit.z()));
|
||||||
glsafe(::glMultMatrixd(complete_scaling_matrix_inverse.data()));
|
glsafe(::glMultMatrixd(complete_scaling_matrix_inverse.data()));
|
||||||
glsafe(::glScaled(m_cursor_radius, m_cursor_radius, m_cursor_radius));
|
glsafe(::glScaled(m_cursor_radius, m_cursor_radius, m_cursor_radius));
|
||||||
|
|
||||||
@ -824,6 +824,9 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
|||||||
}
|
}
|
||||||
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
render_paint_contour();
|
||||||
|
#else
|
||||||
if (m_paint_contour.has_VBO()) {
|
if (m_paint_contour.has_VBO()) {
|
||||||
ScopeGuard guard_gouraud([shader]() { shader->start_using(); });
|
ScopeGuard guard_gouraud([shader]() { shader->start_using(); });
|
||||||
shader->stop_using();
|
shader->stop_using();
|
||||||
@ -837,6 +840,7 @@ void TriangleSelectorGUI::render(ImGuiWrapper* imgui)
|
|||||||
|
|
||||||
contour_shader->stop_using();
|
contour_shader->stop_using();
|
||||||
}
|
}
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
||||||
if (imgui)
|
if (imgui)
|
||||||
@ -930,6 +934,9 @@ void TriangleSelectorGUI::update_render_data()
|
|||||||
iva.finalize_geometry(true);
|
iva.finalize_geometry(true);
|
||||||
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
update_paint_contour();
|
||||||
|
#else
|
||||||
m_paint_contour.release_geometry();
|
m_paint_contour.release_geometry();
|
||||||
std::vector<Vec2i> contour_edges = this->get_seed_fill_contour();
|
std::vector<Vec2i> contour_edges = this->get_seed_fill_contour();
|
||||||
m_paint_contour.contour_vertices.reserve(contour_edges.size() * 6);
|
m_paint_contour.contour_vertices.reserve(contour_edges.size() * 6);
|
||||||
@ -948,8 +955,10 @@ void TriangleSelectorGUI::update_render_data()
|
|||||||
m_paint_contour.contour_indices_size = m_paint_contour.contour_indices.size();
|
m_paint_contour.contour_indices_size = m_paint_contour.contour_indices.size();
|
||||||
|
|
||||||
m_paint_contour.finalize_geometry();
|
m_paint_contour.finalize_geometry();
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
void GLPaintContour::render() const
|
void GLPaintContour::render() const
|
||||||
{
|
{
|
||||||
assert(this->m_contour_VBO_id != 0);
|
assert(this->m_contour_VBO_id != 0);
|
||||||
@ -1007,6 +1016,7 @@ void GLPaintContour::release_geometry()
|
|||||||
}
|
}
|
||||||
this->clear();
|
this->clear();
|
||||||
}
|
}
|
||||||
|
#endif // !ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
||||||
void TriangleSelectorGUI::render_debug(ImGuiWrapper* imgui)
|
void TriangleSelectorGUI::render_debug(ImGuiWrapper* imgui)
|
||||||
@ -1172,4 +1182,53 @@ void TriangleSelectorGUI::render_debug(ImGuiWrapper* imgui)
|
|||||||
}
|
}
|
||||||
#endif // PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
#endif // PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
||||||
|
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
void TriangleSelectorGUI::update_paint_contour()
|
||||||
|
{
|
||||||
|
m_paint_contour.reset();
|
||||||
|
|
||||||
|
GLModel::Geometry init_data;
|
||||||
|
const std::vector<Vec2i> contour_edges = this->get_seed_fill_contour();
|
||||||
|
const GLModel::Geometry::EIndexType index_type = (2 * contour_edges.size() < 65536) ? GLModel::Geometry::EIndexType::USHORT : GLModel::Geometry::EIndexType::UINT;
|
||||||
|
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, index_type };
|
||||||
|
init_data.reserve_vertices(2 * contour_edges.size());
|
||||||
|
init_data.reserve_indices(2 * contour_edges.size());
|
||||||
|
// vertices + indices
|
||||||
|
unsigned int vertices_count = 0;
|
||||||
|
for (const Vec2i& edge : contour_edges) {
|
||||||
|
init_data.add_vertex(m_vertices[edge(0)].v);
|
||||||
|
init_data.add_vertex(m_vertices[edge(1)].v);
|
||||||
|
vertices_count += 2;
|
||||||
|
if (index_type == GLModel::Geometry::EIndexType::USHORT)
|
||||||
|
init_data.add_ushort_line((unsigned short)vertices_count - 2, (unsigned short)vertices_count - 1);
|
||||||
|
else
|
||||||
|
init_data.add_uint_line(vertices_count - 2, vertices_count - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!init_data.is_empty())
|
||||||
|
m_paint_contour.init_from(std::move(init_data));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TriangleSelectorGUI::render_paint_contour()
|
||||||
|
{
|
||||||
|
auto* curr_shader = wxGetApp().get_current_shader();
|
||||||
|
if (curr_shader != nullptr)
|
||||||
|
curr_shader->stop_using();
|
||||||
|
|
||||||
|
auto* contour_shader = wxGetApp().get_shader("mm_contour");
|
||||||
|
if (contour_shader != nullptr) {
|
||||||
|
contour_shader->start_using();
|
||||||
|
|
||||||
|
glsafe(::glDepthFunc(GL_LEQUAL));
|
||||||
|
m_paint_contour.render();
|
||||||
|
glsafe(::glDepthFunc(GL_LESS));
|
||||||
|
|
||||||
|
contour_shader->stop_using();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (curr_shader != nullptr)
|
||||||
|
curr_shader->start_using();
|
||||||
|
}
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
} // namespace Slic3r::GUI
|
} // namespace Slic3r::GUI
|
||||||
|
@ -32,6 +32,7 @@ enum class PainterGizmoType {
|
|||||||
MMU_SEGMENTATION
|
MMU_SEGMENTATION
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if !ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
class GLPaintContour
|
class GLPaintContour
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -67,6 +68,7 @@ public:
|
|||||||
GLuint m_contour_VBO_id{0};
|
GLuint m_contour_VBO_id{0};
|
||||||
GLuint m_contour_EBO_id{0};
|
GLuint m_contour_EBO_id{0};
|
||||||
};
|
};
|
||||||
|
#endif // !ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
|
||||||
class TriangleSelectorGUI : public TriangleSelector {
|
class TriangleSelectorGUI : public TriangleSelector {
|
||||||
public:
|
public:
|
||||||
@ -79,7 +81,7 @@ public:
|
|||||||
virtual void render(ImGuiWrapper *imgui);
|
virtual void render(ImGuiWrapper *imgui);
|
||||||
void render() { this->render(nullptr); }
|
void render() { this->render(nullptr); }
|
||||||
|
|
||||||
void request_update_render_data() { m_update_render_data = true; };
|
void request_update_render_data() { m_update_render_data = true; }
|
||||||
|
|
||||||
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
#ifdef PRUSASLICER_TRIANGLE_SELECTOR_DEBUG
|
||||||
void render_debug(ImGuiWrapper* imgui);
|
void render_debug(ImGuiWrapper* imgui);
|
||||||
@ -110,7 +112,14 @@ private:
|
|||||||
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
#endif // ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
#if ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
|
GLModel m_paint_contour;
|
||||||
|
|
||||||
|
void update_paint_contour();
|
||||||
|
void render_paint_contour();
|
||||||
|
#else
|
||||||
GLPaintContour m_paint_contour;
|
GLPaintContour m_paint_contour;
|
||||||
|
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user