diff options
Diffstat (limited to 'src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp')
-rw-r--r-- | src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp index 8b866c7c9..fa59d7646 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoPainterBase.cpp @@ -18,13 +18,17 @@ namespace Slic3r::GUI { + std::shared_ptr<GLIndexedVertexArray> GLGizmoPainterBase::s_sphere = nullptr; GLGizmoPainterBase::GLGizmoPainterBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id) : GLGizmoBase(parent, icon_filename, sprite_id) { - // Make sphere and save it into a vertex buffer. - m_vbo_sphere.load_its_flat_shading(its_make_sphere(1., (2*M_PI)/24.)); - m_vbo_sphere.finalize_geometry(true); +} + +GLGizmoPainterBase::~GLGizmoPainterBase() +{ + if (s_sphere != nullptr && s_sphere->has_VBOs()) + s_sphere->release_geometry(); } void GLGizmoPainterBase::set_painter_gizmo_data(const Selection& selection) @@ -184,6 +188,12 @@ void GLGizmoPainterBase::render_cursor_circle() const void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const { + if (s_sphere == nullptr) { + s_sphere = std::make_shared<GLIndexedVertexArray>(); + s_sphere->load_its_flat_shading(its_make_sphere(1.0, double(PI) / 12.0)); + s_sphere->finalize_geometry(true); + } + const Transform3d complete_scaling_matrix_inverse = Geometry::Transformation(trafo).get_matrix(true, true, false, true).inverse(); const bool is_left_handed = Geometry::Transformation(trafo).is_left_handed(); @@ -204,7 +214,8 @@ void GLGizmoPainterBase::render_cursor_sphere(const Transform3d& trafo) const render_color = this->get_cursor_sphere_right_button_color(); glsafe(::glColor4fv(render_color.data())); - m_vbo_sphere.render(); + assert(s_sphere != nullptr); + s_sphere->render(); if (is_left_handed) glFrontFace(GL_CCW); @@ -245,7 +256,7 @@ std::vector<std::vector<GLGizmoPainterBase::ProjectedMousePosition>> GLGizmoPain const Camera &camera = wxGetApp().plater()->get_camera(); std::vector<ProjectedMousePosition> mesh_hit_points; - mesh_hit_points.reserve(mouse_position.size()); + mesh_hit_points.reserve(mouse_positions.size()); // In mesh_hit_points only the last item could have mesh_id == -1, any other items mustn't. for (const Vec2d &mp : mouse_positions) { |