Fix draw cut line

This commit is contained in:
Noisyfox 2023-10-27 23:07:00 +08:00
parent fe78e40cb4
commit 5ce3ec716e
2 changed files with 36 additions and 9 deletions

View file

@ -1054,15 +1054,41 @@ void GLGizmoAdvancedCut::render_cut_line()
if (!cut_line_processing() || m_cut_line_end == Vec3d::Zero()) if (!cut_line_processing() || m_cut_line_end == Vec3d::Zero())
return; return;
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glDisable(GL_DEPTH_TEST));
glsafe(::glClear(GL_DEPTH_BUFFER_BIT));
glsafe(::glColor3f(0.0, 1.0, 0.0)); GLShaderProgram *shader = wxGetApp().get_shader("flat");
glEnable(GL_LINE_STIPPLE); if (shader != nullptr) {
::glBegin(GL_LINES); shader->start_using();
::glVertex3dv(m_cut_line_begin.data());
::glVertex3dv(m_cut_line_end.data()); {
glsafe(::glEnd()); m_cut_line.reset();
glDisable(GL_LINE_STIPPLE);
GLModel::Geometry init_data;
init_data.format = {GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3};
init_data.color = ColorRGBA::GREEN();
init_data.reserve_vertices(2);
init_data.reserve_vertices(2);
// vertices
init_data.add_vertex((Vec3f) m_cut_line_begin.cast<float>());
init_data.add_vertex((Vec3f) m_cut_line_end.cast<float>());
// indices
init_data.add_line(0, 1);
m_cut_line.init_from(std::move(init_data));
}
const Camera &camera = wxGetApp().plater()->get_camera();
shader->set_uniform("view_model_matrix", camera.get_view_matrix());
shader->set_uniform("projection_matrix", camera.get_projection_matrix());
glEnable(GL_LINE_STIPPLE);
glLineStipple(1, 0x0FFF);
m_cut_line.render();
glDisable(GL_LINE_STIPPLE);
shader->stop_using();
}
} }
void GLGizmoAdvancedCut::render_connector_model(GLModel &model, const ColorRGBA &color, Transform3d view_model_matrix, bool for_picking) void GLGizmoAdvancedCut::render_connector_model(GLModel &model, const ColorRGBA &color, Transform3d view_model_matrix, bool for_picking)

View file

@ -55,6 +55,7 @@ private:
bool m_rotate_lower{false}; bool m_rotate_lower{false};
GLModel m_plane; GLModel m_plane;
GLModel m_grabber_connection; GLModel m_grabber_connection;
GLModel m_cut_line;
bool m_do_segment; bool m_do_segment;
double m_segment_smoothing_alpha; double m_segment_smoothing_alpha;