Skip to content

Commit

Permalink
Tech ENABLE_GLBEGIN_GLEND_REMOVAL - Fix in GLGizmoRotate::render_angl…
Browse files Browse the repository at this point in the history
…e_arc():

Tech ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL - Fix in GLModel::render()
  • Loading branch information
enricoturri1966 committed Feb 28, 2022
1 parent 1e9951d commit 2379588
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/slic3r/GUI/GLModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -998,7 +998,7 @@ void GLModel::render(const std::pair<size_t, size_t>& range)
shader->set_uniform("uniform_color", data.color);

glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_render_data.ibo_id));
glsafe(::glDrawElements(mode, range.second - range.first + 1, index_type, (const void*)(range.first * Geometry::index_stride_bytes(data.format))));
glsafe(::glDrawElements(mode, range.second - range.first, index_type, (const void*)(range.first * Geometry::index_stride_bytes(data.format))));
glsafe(::glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0));

if (tex_coord)
Expand Down
30 changes: 17 additions & 13 deletions src/slic3r/GUI/Gizmos/GLGizmoRotate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,22 +461,26 @@ void GLGizmoRotate::render_angle() const
const float ex_radius = m_radius * (1.0f + GrabberOffset);

#if ENABLE_GLBEGIN_GLEND_REMOVAL
if (!m_angle_arc.is_initialized() || radius_changed) {
m_angle_arc.reset();
const bool angle_changed = std::abs(m_old_angle - m_angle) > EPSILON;
m_old_angle = m_angle;

GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::LineStrip, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.reserve_vertices(1 + AngleResolution);
init_data.reserve_indices(1 + AngleResolution);
if (!m_angle_arc.is_initialized() || radius_changed || angle_changed) {
m_angle_arc.reset();
if (m_angle > 0.0f) {
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::LineStrip, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.reserve_vertices(1 + AngleResolution);
init_data.reserve_indices(1 + AngleResolution);

// vertices + indices
for (unsigned short i = 0; i <= AngleResolution; ++i) {
const float angle = float(i) * step_angle;
init_data.add_vertex(Vec3f(::cos(angle) * ex_radius, ::sin(angle) * ex_radius, 0.0f));
init_data.add_ushort_index(i);
}

// vertices + indices
for (unsigned short i = 0; i <= AngleResolution; ++i) {
const float angle = float(i) * step_angle;
init_data.add_vertex(Vec3f(::cos(angle) * ex_radius, ::sin(angle) * ex_radius, 0.0f));
init_data.add_ushort_index(i);
m_angle_arc.init_from(std::move(init_data));
}

m_angle_arc.init_from(std::move(init_data));
}

m_angle_arc.set_color(color);
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/Gizmos/GLGizmoRotate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class GLGizmoRotate : public GLGizmoBase
GrabberConnection m_grabber_connection;
float m_old_radius{ 0.0f };
float m_old_hover_radius{ 0.0f };
float m_old_angle{ 0.0f };
#endif // ENABLE_GLBEGIN_GLEND_REMOVAL

ColorRGBA m_drag_color;
Expand Down

0 comments on commit 2379588

Please sign in to comment.