Tech ENABLE_SEQUENTIAL_LIMITS -> Improved rendering of clearance regions

This commit is contained in:
enricoturri1966 2021-05-12 13:09:33 +02:00
parent 75677ba810
commit 0d37f66f61
2 changed files with 19 additions and 8 deletions

View file

@ -424,7 +424,10 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
} }
glsafe(::glEnable(GL_DEPTH_TEST)); glsafe(::glEnable(GL_DEPTH_TEST));
glsafe(::glDepthMask(GL_FALSE)); #if ENABLE_SEQUENTIAL_LIMITS
if (bottom)
#endif // ENABLE_SEQUENTIAL_LIMITS
glsafe(::glDepthMask(GL_FALSE));
glsafe(::glEnable(GL_BLEND)); glsafe(::glEnable(GL_BLEND));
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)); glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
@ -469,7 +472,10 @@ void Bed3D::render_texture(bool bottom, GLCanvas3D& canvas) const
glsafe(::glFrontFace(GL_CCW)); glsafe(::glFrontFace(GL_CCW));
glsafe(::glDisable(GL_BLEND)); glsafe(::glDisable(GL_BLEND));
glsafe(::glDepthMask(GL_TRUE)); #if ENABLE_SEQUENTIAL_LIMITS
if (bottom)
#endif // ENABLE_SEQUENTIAL_LIMITS
glsafe(::glDepthMask(GL_TRUE));
shader->stop_using(); shader->stop_using();
} }

View file

@ -1085,13 +1085,14 @@ void GLCanvas3D::SequentialPrintClearance::set(const Polygons& polygons)
GLModel::InitializationData data; GLModel::InitializationData data;
GLModel::InitializationData::Entity entity; GLModel::InitializationData::Entity entity;
entity.type = GLModel::PrimitiveType::Triangles; entity.type = GLModel::PrimitiveType::Triangles;
entity.color = { 0.3333f, 0.3333f, 0.3333f, 1.0f }; entity.color = { 0.3333f, 0.0f, 0.0f, 0.5f };
entity.positions.reserve(vertices_count); entity.positions.reserve(vertices_count);
entity.normals.reserve(vertices_count); entity.normals.reserve(vertices_count);
entity.indices.reserve(vertices_count); entity.indices.reserve(vertices_count);
for (const Polygon& poly : polygons) { ExPolygons polygons_union = union_ex(polygons);
std::vector<Vec3d> triangulation = triangulate_expolygon_3d(ExPolygon(poly), false); for (const ExPolygon& poly : polygons_union) {
std::vector<Vec3d> triangulation = triangulate_expolygon_3d(poly, false);
for (const Vec3d& v : triangulation) { for (const Vec3d& v : triangulation) {
entity.positions.emplace_back(v.cast<float>()); entity.positions.emplace_back(v.cast<float>());
entity.normals.emplace_back(Vec3f::UnitZ()); entity.normals.emplace_back(Vec3f::UnitZ());
@ -1109,7 +1110,7 @@ void GLCanvas3D::SequentialPrintClearance::set(const Polygons& polygons)
for (const Polygon& poly : polygons) { for (const Polygon& poly : polygons) {
GLModel::InitializationData::Entity ent; GLModel::InitializationData::Entity ent;
ent.type = GLModel::PrimitiveType::LineLoop; ent.type = GLModel::PrimitiveType::LineLoop;
ent.color = { 1.0f, 1.0f, 0.0f, 1.0f }; ent.color = { 1.0f, 0.0f, 0.0f, 1.0f };
ent.positions.reserve(poly.points.size()); ent.positions.reserve(poly.points.size());
ent.indices.reserve(poly.points.size()); ent.indices.reserve(poly.points.size());
unsigned int id_count = 0; unsigned int id_count = 0;
@ -1133,11 +1134,16 @@ void GLCanvas3D::SequentialPrintClearance::render() const
shader->start_using(); shader->start_using();
glsafe(::glEnable(GL_DEPTH_TEST));
glsafe(::glDisable(GL_CULL_FACE)); glsafe(::glDisable(GL_CULL_FACE));
glsafe(::glEnable(GL_BLEND));
glsafe(::glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA));
m_model.render(); m_model.render();
glsafe(::glDisable(GL_BLEND));
glsafe(::glEnable(GL_CULL_FACE)); glsafe(::glEnable(GL_CULL_FACE));
glsafe(::glDisable(GL_DEPTH_TEST));
shader->stop_using(); shader->stop_using();
} }
@ -1743,11 +1749,10 @@ void GLCanvas3D::render()
_render_gcode(); _render_gcode();
_render_sla_slices(); _render_sla_slices();
_render_selection(); _render_selection();
_render_bed(!camera.is_looking_downward(), true);
#if ENABLE_SEQUENTIAL_LIMITS #if ENABLE_SEQUENTIAL_LIMITS
_render_sequential_clearance(); _render_sequential_clearance();
#endif // ENABLE_SEQUENTIAL_LIMITS #endif // ENABLE_SEQUENTIAL_LIMITS
_render_bed(!camera.is_looking_downward(), true);
#if ENABLE_RENDER_SELECTION_CENTER #if ENABLE_RENDER_SELECTION_CENTER
_render_selection_center(); _render_selection_center();
#endif // ENABLE_RENDER_SELECTION_CENTER #endif // ENABLE_RENDER_SELECTION_CENTER