From cbe5818382a3f61fda8390c1fa0b0853a44b5907 Mon Sep 17 00:00:00 2001 From: "zhou.xu" Date: Tue, 25 Feb 2025 09:03:41 +0800 Subject: [PATCH] FIX:Fix some missing contours in height range cursor rendering delete init_from api in GLModel jira: none Change-Id: Icd2522ff1dc156f074369fadeb51b9568945a4fc (cherry picked from commit f1d27c1bf3419f449fdc6cb83dca1224ca7478be) --- src/slic3r/GUI/GLModel.cpp | 27 -------------------- src/slic3r/GUI/GLModel.hpp | 1 - src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp | 2 +- 3 files changed, 1 insertion(+), 29 deletions(-) diff --git a/src/slic3r/GUI/GLModel.cpp b/src/slic3r/GUI/GLModel.cpp index 33cc0e6c9..c19b88b42 100644 --- a/src/slic3r/GUI/GLModel.cpp +++ b/src/slic3r/GUI/GLModel.cpp @@ -588,33 +588,6 @@ void GLModel::init_from(const indexed_triangle_set& its) this->init_from(its, bounding_box(its)); } -void GLModel::init_from(const Polygons& polygons, float z) -{ - auto append_polygon = [](const Polygon& polygon, float z, GUI::GLModel::InitializationData& data) { - if (!polygon.empty()) { - GUI::GLModel::InitializationData::Entity entity; - entity.type = GUI::GLModel::PrimitiveType::LineLoop; - // contour - entity.positions.reserve(polygon.size() + 1); - entity.indices.reserve(polygon.size() + 1); - unsigned int id = 0; - for (const Point& p : polygon) { - Vec3f position = unscale(p.x(), p.y(), 0.0).cast(); - position.z() = z; - entity.positions.emplace_back(position); - entity.indices.emplace_back(id++); - } - data.entities.emplace_back(entity); - } - }; - - InitializationData init_data; - for (const Polygon& polygon : polygons) { - append_polygon(polygon, z, init_data); - } - init_from(init_data); -} - bool GLModel::init_from_file(const std::string& filename) { if (!boost::filesystem::exists(filename)) diff --git a/src/slic3r/GUI/GLModel.hpp b/src/slic3r/GUI/GLModel.hpp index 49a58479a..f78c45257 100644 --- a/src/slic3r/GUI/GLModel.hpp +++ b/src/slic3r/GUI/GLModel.hpp @@ -179,7 +179,6 @@ namespace GUI { void init_from(const InitializationData& data); void init_from(const indexed_triangle_set& its, const BoundingBoxf3& bbox); void init_from(const indexed_triangle_set& its); - void init_from(const Polygons& polygons, float z); bool init_from_file(const std::string& filename); void init_model_from_polygon(const Polygons &polygons, float z); bool init_model_from_poly(const std::vector &triangles, float z, bool generate_mesh = false); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index 4e534d813..2a5f8cc27 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -548,7 +548,7 @@ void GLGizmoPainterBase::update_contours(int i, const TriangleMesh &vol_mesh, fl } } } - m_cut_contours[i].contours.init_from(polys, static_cast(cursor_z)); + m_cut_contours[i].contours.init_model_from_polygon(polys, static_cast(cursor_z)); m_cut_contours[i].contours.set_color(-1, {1.0f, 1.0f, 1.0f, 1.0f}); } } else if (box.center() != m_cut_contours[i].position) {