Merge remote-tracking branch 'origin/master' into ys_cut

This commit is contained in:
YuSanka 2022-03-11 15:58:14 +01:00
commit e5b10ae289
85 changed files with 5320 additions and 1851 deletions

View file

@ -351,14 +351,31 @@ void GLGizmoCut3D::render_cut_plane()
glsafe(::glEnable(GL_BLEND));
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
#if ENABLE_GLBEGIN_GLEND_REMOVAL
#if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_GL_SHADERS_ATTRIBUTES
GLShaderProgram* shader = wxGetApp().get_shader("flat_attr");
#else
GLShaderProgram* shader = wxGetApp().get_shader("flat");
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (shader == nullptr)
return;
shader->start_using();
/* const Vec3d diff = plane_center - m_old_center;
// Z changed when move with cut plane
// X and Y changed when move with cutted object
bool is_changed = std::abs(diff.x()) > EPSILON ||
std::abs(diff.y()) > EPSILON ||
std::abs(diff.z()) > EPSILON;
m_old_center = plane_center;
*/
const Vec3d& angles = m_rotation_gizmo.get_rotation();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3 };
init_data.color = { 0.8f, 0.8f, 0.8f, 0.5f };
init_data.reserve_vertices(4);
init_data.reserve_indices(6);
glsafe(::glPushMatrix());
glsafe(::glTranslated(m_plane_center.x(), m_plane_center.y(), m_plane_center.z()));
glsafe(::glRotated(Geometry::rad2deg(angles.z()), 0.0, 0.0, 1.0));
@ -368,11 +385,9 @@ void GLGizmoCut3D::render_cut_plane()
if (!m_plane.is_initialized()) {
m_plane.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.color = { 0.8f, 0.8f, 0.8f, 0.5f };
init_data.reserve_vertices(4);
init_data.reserve_indices(6);
// indices
init_data.add_triangle(0, 1, 2);
init_data.add_triangle(2, 3, 0);
// vertices
init_data.add_vertex(Vec3f(min_x, min_y, 0.0));
@ -380,12 +395,11 @@ void GLGizmoCut3D::render_cut_plane()
init_data.add_vertex(Vec3f(max_x, max_y, 0.0));
init_data.add_vertex(Vec3f(min_x, max_y, 0.0));
// indices
init_data.add_ushort_triangle(0, 1, 2);
init_data.add_ushort_triangle(2, 3, 0);
m_plane.init_from(std::move(init_data));
}
#if ENABLE_GL_SHADERS_ATTRIBUTES
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());
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
m_plane.render();
glsafe(::glPopMatrix());
@ -398,7 +412,7 @@ void GLGizmoCut3D::render_cut_plane()
::glVertex3f(max_x, max_y, plane_center.z());
::glVertex3f(min_x, max_y, plane_center.z());
glsafe(::glEnd());
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
glsafe(::glEnable(GL_CULL_FACE));
glsafe(::glDisable(GL_BLEND));
@ -431,7 +445,7 @@ void GLGizmoCut3D::render_cut_center_graber()
m_grabber_connection.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.color = ColorRGBA::YELLOW();
init_data.reserve_vertices(2);
init_data.reserve_indices(2);
@ -441,7 +455,7 @@ void GLGizmoCut3D::render_cut_center_graber()
init_data.add_vertex((Vec3f)m_grabbers[0].center.cast<float>());
// indices
init_data.add_ushort_line(0, 1);
init_data.add_line(0, 1);
m_grabber_connection.init_from(std::move(init_data));
}
@ -450,7 +464,20 @@ void GLGizmoCut3D::render_cut_center_graber()
shader->stop_using();
}
#if ENABLE_GL_SHADERS_ATTRIBUTES
shader = wxGetApp().get_shader("gouraud_light_attr");
#else
shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
#else
glsafe(::glColor3f(1.0, 1.0, 0.0));
::glBegin(GL_LINES);
::glVertex3dv(plane_center.data());
::glVertex3dv(m_grabbers[0].center.data());
glsafe(::glEnd());
GLShaderProgram* shader = wxGetApp().get_shader("gouraud_light");
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
if (shader != nullptr) {
shader->start_using();
shader->set_uniform("emission_factor", 0.1f);
@ -538,6 +565,7 @@ void GLGizmoCut3D::on_dragging(const UpdateData& data)
for (auto& connector : connectors)
connector.pos += shift;
}
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
else if (m_hover_id > m_group_id)
{
std::pair<Vec3f, Vec3f> pos_and_normal;
@ -665,7 +693,7 @@ void GLGizmoCut3D::on_render_input_window(float x, float y, float bottom_limit)
revert_rotation = render_revert_button("rotation");
for (Axis axis : {X, Y, Z})
render_rotation_input(axis);
m_imgui->text(_L("°"));
m_imgui->text(_L("°"));
}
else {
ImGui::AlignTextToFramePadding();