diff --git a/src/slic3r/GUI/GLModel.cpp b/src/slic3r/GUI/GLModel.cpp index 2da64f662e..1bebabb32f 100644 --- a/src/slic3r/GUI/GLModel.cpp +++ b/src/slic3r/GUI/GLModel.cpp @@ -416,6 +416,11 @@ void GLModel::init_from(const Geometry& data) } #if ENABLE_GLBEGIN_GLEND_REMOVAL +void GLModel::init_from(const TriangleMesh& mesh) +{ + init_from(mesh.its); +} + void GLModel::init_from(const indexed_triangle_set& its) #else void GLModel::init_from(const indexed_triangle_set& its, const BoundingBoxf3 &bbox) @@ -488,7 +493,7 @@ void GLModel::init_from(const indexed_triangle_set& its, const BoundingBoxf3 &bb #if !ENABLE_GLBEGIN_GLEND_REMOVAL void GLModel::init_from(const indexed_triangle_set& its) { - this->init_from(its, bounding_box(its)); + init_from(its, bounding_box(its)); } #endif // !ENABLE_GLBEGIN_GLEND_REMOVAL @@ -574,11 +579,10 @@ bool GLModel::init_from_file(const std::string& filename) return false; } - const TriangleMesh mesh = model.mesh(); #if ENABLE_GLBEGIN_GLEND_REMOVAL - init_from(mesh.its); + init_from(model.mesh()); #else - init_from(mesh.its, mesh.bounding_box()); + init_from(model.mesh().its, mesh.bounding_box()); #endif // ENABLE_GLBEGIN_GLEND_REMOVAL m_filename = filename; diff --git a/src/slic3r/GUI/GLModel.hpp b/src/slic3r/GUI/GLModel.hpp index e81231aea5..2e073dee2a 100644 --- a/src/slic3r/GUI/GLModel.hpp +++ b/src/slic3r/GUI/GLModel.hpp @@ -188,6 +188,7 @@ namespace GUI { size_t indices_size_bytes() const { return indices_count() * Geometry::index_stride_bytes(m_render_data.geometry.format); } void init_from(Geometry&& data); + void init_from(const TriangleMesh& mesh); #else void init_from(const Geometry& data); void init_from(const indexed_triangle_set& its, const BoundingBoxf3& bbox); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp index 67c17cd015..e0e018a13c 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoBase.cpp @@ -39,7 +39,7 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo #if ENABLE_GLBEGIN_GLEND_REMOVAL m_cube.init_from(its); #else - const_cast(m_cube).init_from(its, BoundingBoxf3{ { -0.5, -0.5, -0.5 }, { 0.5, 0.5, 0.5 } }); + m_cube.init_from(its, BoundingBoxf3{ { -0.5, -0.5, -0.5 }, { 0.5, 0.5, 0.5 } }); #endif // ENABLE_GLBEGIN_GLEND_REMOVAL } @@ -48,7 +48,7 @@ void GLGizmoBase::Grabber::render(float size, const ColorRGBA& render_color, boo #if ENABLE_GLBEGIN_GLEND_REMOVAL m_cube.set_color(render_color); #else - const_cast(&m_cube)->set_color(-1, render_color); + m_cube.set_color(-1, render_color); #endif // ENABLE_GLBEGIN_GLEND_REMOVAL glsafe(::glPushMatrix()); diff --git a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp index 2126e41a2d..1b4c751d4e 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoSimplify.cpp @@ -651,17 +651,23 @@ void GLGizmoSimplify::init_model() } assert(volume != nullptr); +#if ENABLE_GLBEGIN_GLEND_REMOVAL + // set actual triangle count + m_triangle_count += volume->mesh().its.indices.size(); +#else const indexed_triangle_set &its = volume->mesh().its; // set actual triangle count m_triangle_count += its.indices.size(); +#endif // ENABLE_GLBEGIN_GLEND_REMOVAL assert(m_glmodels.find(id) == m_glmodels.end()); GLModel &glmodel = m_glmodels[id]; // create new glmodel - glmodel.init_from(its); #if ENABLE_GLBEGIN_GLEND_REMOVAL + glmodel.init_from(volume->mesh()); glmodel.set_color(selected_volume->color); #else + glmodel.init_from(its); glmodel.set_color(-1,selected_volume->color); #endif // ENABLE_GLBEGIN_GLEND_REMOVAL