Tech ENABLE_GLBEGIN_GLEND_REMOVAL - Fix in GLGizmoRotate::render_angle_arc():

Tech ENABLE_GLINDEXEDVERTEXARRAY_REMOVAL - Fix in GLModel::render()

(cherry picked from commit prusa3d/PrusaSlicer@2379588196)
This commit is contained in:
enricoturri1966 2023-10-23 17:12:30 +08:00 committed by Noisyfox
parent d09dc36ff1
commit 1fedcb61b7
3 changed files with 18 additions and 13 deletions

View file

@ -680,7 +680,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)

View file

@ -334,22 +334,26 @@ void GLGizmoRotate::render_angle_arc(const ColorRGBA& color, bool radius_changed
const float step_angle = float(m_angle) / float(AngleResolution);
const float ex_radius = m_radius * (1.0f + GrabberOffset);
if (!m_angle_arc.is_initialized() || radius_changed) {
const bool angle_changed = std::abs(m_old_angle - m_angle) > EPSILON;
m_old_angle = m_angle;
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);
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);

View file

@ -54,6 +54,7 @@ private:
GrabberConnection m_grabber_connection;
float m_old_radius{ 0.0f };
float m_old_hover_radius{ 0.0f };
float m_old_angle{ 0.0f };
public:
GLGizmoRotate(GLCanvas3D& parent, Axis axis);