mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-07 23:17:35 -06:00
Gizmos refactoring - Removed GLModels defined into GLGizmoBase, and mostly unused, to avoid wasting GPU memory. Use a shared GLModel for Gizmos inheriting from GLGizmoPainterBase. Initialization of GLModels moved from constructor to render methods
(cherry picked from commit prusa3d/PrusaSlicer@e3d5cd445c)
This commit is contained in:
parent
874f39aac1
commit
b7989e3b2f
5 changed files with 21 additions and 28 deletions
|
@ -18,17 +18,21 @@
|
|||
|
||||
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);
|
||||
m_vertical_only = false;
|
||||
m_horizontal_only = false;
|
||||
}
|
||||
|
||||
GLGizmoPainterBase::~GLGizmoPainterBase()
|
||||
{
|
||||
if (s_sphere != nullptr && s_sphere->has_VBOs())
|
||||
s_sphere->release_geometry();
|
||||
}
|
||||
|
||||
void GLGizmoPainterBase::set_painter_gizmo_data(const Selection& selection)
|
||||
{
|
||||
if (m_state != On)
|
||||
|
@ -236,6 +240,12 @@ void GLGizmoPainterBase::render_cursor_circle()
|
|||
|
||||
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();
|
||||
|
||||
|
@ -257,7 +267,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue