Tech ENABLE_LEGACY_OPENGL_REMOVAL - Refactoring of GLModel to automatically detect the data type to use into the index buffer in dependence of vertices count

This commit is contained in:
enricoturri1966 2022-03-09 11:51:02 +01:00
parent 46283cfde3
commit f8ce187262
16 changed files with 416 additions and 591 deletions

View File

@ -366,7 +366,7 @@ void Bed3D::init_triangles()
return;
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3T2, GLModel::Geometry::index_type(triangles.size()) };
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3T2 };
init_data.reserve_vertices(triangles.size());
init_data.reserve_indices(triangles.size() / 3);
@ -390,12 +390,8 @@ void Bed3D::init_triangles()
const Vec3f p = { v.x(), v.y(), GROUND_Z };
init_data.add_vertex(p, (Vec2f)(v - min).cwiseProduct(inv_size).eval());
++vertices_counter;
if (vertices_counter % 3 == 0) {
if (init_data.format.index_type == GLModel::Geometry::EIndexType::USHORT)
init_data.add_ushort_triangle((unsigned short)vertices_counter - 3, (unsigned short)vertices_counter - 2, (unsigned short)vertices_counter - 1);
else
init_data.add_uint_triangle(vertices_counter - 3, vertices_counter - 2, vertices_counter - 1);
}
if (vertices_counter % 3 == 0)
init_data.add_triangle(vertices_counter - 3, vertices_counter - 2, vertices_counter - 1);
}
m_triangles.init_from(std::move(init_data));
@ -434,7 +430,7 @@ void Bed3D::init_gridlines()
std::copy(contour_lines.begin(), contour_lines.end(), std::back_inserter(gridlines));
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::index_type(2 * gridlines.size()) };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(2 * gridlines.size());
init_data.reserve_indices(2 * gridlines.size());
@ -442,10 +438,7 @@ void Bed3D::init_gridlines()
init_data.add_vertex(Vec3f(unscale<float>(l.a.x()), unscale<float>(l.a.y()), GROUND_Z));
init_data.add_vertex(Vec3f(unscale<float>(l.b.x()), unscale<float>(l.b.y()), GROUND_Z));
const unsigned int vertices_counter = (unsigned int)init_data.vertices_count();
if (init_data.format.index_type == GLModel::Geometry::EIndexType::USHORT)
init_data.add_ushort_line((unsigned short)vertices_counter - 2, (unsigned short)vertices_counter - 1);
else
init_data.add_uint_line(vertices_counter - 2, vertices_counter - 1);
init_data.add_line(vertices_counter - 2, vertices_counter - 1);
}
m_gridlines.init_from(std::move(init_data));

View File

@ -335,7 +335,7 @@ void GLVolume::SinkingContours::update()
m_model.reset();
GUI::GLModel::Geometry init_data;
#if ENABLE_LEGACY_OPENGL_REMOVAL
init_data.format = { GUI::GLModel::Geometry::EPrimitiveType::Triangles, GUI::GLModel::Geometry::EVertexLayout::P3, GUI::GLModel::Geometry::EIndexType::UINT };
init_data.format = { GUI::GLModel::Geometry::EPrimitiveType::Triangles, GUI::GLModel::Geometry::EVertexLayout::P3 };
init_data.color = ColorRGBA::WHITE();
unsigned int vertices_counter = 0;
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
@ -351,7 +351,7 @@ void GLVolume::SinkingContours::update()
init_data.add_vertex((Vec3f)(v.cast<float>() + 0.015f * Vec3f::UnitZ())); // add a small positive z to avoid z-fighting
++vertices_counter;
if (vertices_counter % 3 == 0)
init_data.add_uint_triangle(vertices_counter - 3, vertices_counter - 2, vertices_counter - 1);
init_data.add_triangle(vertices_counter - 3, vertices_counter - 2, vertices_counter - 1);
}
}
m_model.init_from(std::move(init_data));
@ -431,7 +431,7 @@ void GLVolume::NonManifoldEdges::update()
if (!edges.empty()) {
GUI::GLModel::Geometry init_data;
#if ENABLE_LEGACY_OPENGL_REMOVAL
init_data.format = { GUI::GLModel::Geometry::EPrimitiveType::Lines, GUI::GLModel::Geometry::EVertexLayout::P3, GUI::GLModel::Geometry::index_type(2 * edges.size()) };
init_data.format = { GUI::GLModel::Geometry::EPrimitiveType::Lines, GUI::GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(2 * edges.size());
init_data.reserve_indices(2 * edges.size());
@ -441,10 +441,7 @@ void GLVolume::NonManifoldEdges::update()
init_data.add_vertex((Vec3f)mesh.its.vertices[edge.first].cast<float>());
init_data.add_vertex((Vec3f)mesh.its.vertices[edge.second].cast<float>());
vertices_count += 2;
if (init_data.format.index_type == GUI::GLModel::Geometry::EIndexType::USHORT)
init_data.add_ushort_line((unsigned short)vertices_count - 2, (unsigned short)vertices_count - 1);
else
init_data.add_uint_line(vertices_count - 2, vertices_count - 1);
init_data.add_line(vertices_count - 2, vertices_count - 1);
}
m_model.init_from(std::move(init_data));
#else
@ -1480,8 +1477,8 @@ static void thick_lines_to_geometry(
if (!is_first && bottom_z_different) {
// Found a change of the layer thickness -> Add a cap at the end of the previous segment.
geometry.add_uint_triangle(idx_b[Bottom], idx_b[Left], idx_b[Top]);
geometry.add_uint_triangle(idx_b[Bottom], idx_b[Top], idx_b[Right]);
geometry.add_triangle(idx_b[Bottom], idx_b[Left], idx_b[Top]);
geometry.add_triangle(idx_b[Bottom], idx_b[Top], idx_b[Right]);
}
// Share top / bottom vertices if possible.
@ -1531,13 +1528,13 @@ static void thick_lines_to_geometry(
geometry.add_vertex(Vec3f(a2.x(), a2.y(), middle_z), Vec3f(-xy_right_normal.x(), -xy_right_normal.y(), 0.0f));
if (cross2(v_prev, v) > 0.0) {
// Right turn. Fill in the right turn wedge.
geometry.add_uint_triangle(idx_prev[Right], idx_a[Right], idx_prev[Top]);
geometry.add_uint_triangle(idx_prev[Right], idx_prev[Bottom], idx_a[Right]);
geometry.add_triangle(idx_prev[Right], idx_a[Right], idx_prev[Top]);
geometry.add_triangle(idx_prev[Right], idx_prev[Bottom], idx_a[Right]);
}
else {
// Left turn. Fill in the left turn wedge.
geometry.add_uint_triangle(idx_prev[Left], idx_prev[Top], idx_a[Left]);
geometry.add_uint_triangle(idx_prev[Left], idx_a[Left], idx_prev[Bottom]);
geometry.add_triangle(idx_prev[Left], idx_prev[Top], idx_a[Left]);
geometry.add_triangle(idx_prev[Left], idx_a[Left], idx_prev[Bottom]);
}
}
}
@ -1559,11 +1556,11 @@ static void thick_lines_to_geometry(
// Replace the left / right vertex indices to point to the start of the loop.
const size_t indices_count = geometry.indices_count();
for (size_t u = indices_count - 24; u < indices_count; ++u) {
const unsigned int id = geometry.extract_uint_index(u);
const unsigned int id = geometry.extract_index(u);
if (id == (unsigned int)idx_prev[Left])
geometry.set_uint_index(u, (unsigned int)idx_initial[Left]);
geometry.set_index(u, (unsigned int)idx_initial[Left]);
else if (id == (unsigned int)idx_prev[Right])
geometry.set_uint_index(u, (unsigned int)idx_initial[Right]);
geometry.set_index(u, (unsigned int)idx_initial[Right]);
}
}
}
@ -1600,36 +1597,36 @@ static void thick_lines_to_geometry(
if (bottom_z_different && (closed || (!is_first && !is_last))) {
// Found a change of the layer thickness -> Add a cap at the beginning of this segment.
geometry.add_uint_triangle(idx_a[Bottom], idx_a[Right], idx_a[Top]);
geometry.add_uint_triangle(idx_a[Bottom], idx_a[Top], idx_a[Left]);
geometry.add_triangle(idx_a[Bottom], idx_a[Right], idx_a[Top]);
geometry.add_triangle(idx_a[Bottom], idx_a[Top], idx_a[Left]);
}
if (!closed) {
// Terminate open paths with caps.
if (is_first) {
geometry.add_uint_triangle(idx_a[Bottom], idx_a[Right], idx_a[Top]);
geometry.add_uint_triangle(idx_a[Bottom], idx_a[Top], idx_a[Left]);
geometry.add_triangle(idx_a[Bottom], idx_a[Right], idx_a[Top]);
geometry.add_triangle(idx_a[Bottom], idx_a[Top], idx_a[Left]);
}
// We don't use 'else' because both cases are true if we have only one line.
if (is_last) {
geometry.add_uint_triangle(idx_b[Bottom], idx_b[Left], idx_b[Top]);
geometry.add_uint_triangle(idx_b[Bottom], idx_b[Top], idx_b[Right]);
geometry.add_triangle(idx_b[Bottom], idx_b[Left], idx_b[Top]);
geometry.add_triangle(idx_b[Bottom], idx_b[Top], idx_b[Right]);
}
}
// Add quads for a straight hollow tube-like segment.
// bottom-right face
geometry.add_uint_triangle(idx_a[Bottom], idx_b[Bottom], idx_b[Right]);
geometry.add_uint_triangle(idx_a[Bottom], idx_b[Right], idx_a[Right]);
geometry.add_triangle(idx_a[Bottom], idx_b[Bottom], idx_b[Right]);
geometry.add_triangle(idx_a[Bottom], idx_b[Right], idx_a[Right]);
// top-right face
geometry.add_uint_triangle(idx_a[Right], idx_b[Right], idx_b[Top]);
geometry.add_uint_triangle(idx_a[Right], idx_b[Top], idx_a[Top]);
geometry.add_triangle(idx_a[Right], idx_b[Right], idx_b[Top]);
geometry.add_triangle(idx_a[Right], idx_b[Top], idx_a[Top]);
// top-left face
geometry.add_uint_triangle(idx_a[Top], idx_b[Top], idx_b[Left]);
geometry.add_uint_triangle(idx_a[Top], idx_b[Left], idx_a[Left]);
geometry.add_triangle(idx_a[Top], idx_b[Top], idx_b[Left]);
geometry.add_triangle(idx_a[Top], idx_b[Left], idx_a[Left]);
// bottom-left face
geometry.add_uint_triangle(idx_a[Left], idx_b[Left], idx_b[Bottom]);
geometry.add_uint_triangle(idx_a[Left], idx_b[Bottom], idx_a[Bottom]);
geometry.add_triangle(idx_a[Left], idx_b[Left], idx_b[Bottom]);
geometry.add_triangle(idx_a[Left], idx_b[Bottom], idx_a[Bottom]);
}
}
@ -1769,13 +1766,13 @@ static void thick_lines_to_geometry(
if (is_right_turn) {
// Right turn. Fill in the right turn wedge.
geometry.add_uint_triangle(idx_prev[Right], idx_a[Right], idx_prev[Top]);
geometry.add_uint_triangle(idx_prev[Right], idx_prev[Bottom], idx_a[Right]);
geometry.add_triangle(idx_prev[Right], idx_a[Right], idx_prev[Top]);
geometry.add_triangle(idx_prev[Right], idx_prev[Bottom], idx_a[Right]);
}
else {
// Left turn. Fill in the left turn wedge.
geometry.add_uint_triangle(idx_prev[Left], idx_prev[Top], idx_a[Left]);
geometry.add_uint_triangle(idx_prev[Left], idx_a[Left], idx_prev[Bottom]);
geometry.add_triangle(idx_prev[Left], idx_prev[Top], idx_a[Left]);
geometry.add_triangle(idx_prev[Left], idx_a[Left], idx_prev[Bottom]);
}
}
else {
@ -1794,11 +1791,11 @@ static void thick_lines_to_geometry(
// Replace the left / right vertex indices to point to the start of the loop.
const size_t indices_count = geometry.indices_count();
for (size_t u = indices_count - 24; u < indices_count; ++u) {
const unsigned int id = geometry.extract_uint_index(u);
const unsigned int id = geometry.extract_index(u);
if (id == (unsigned int)idx_prev[Left])
geometry.set_uint_index(u, (unsigned int)idx_initial[Left]);
geometry.set_index(u, (unsigned int)idx_initial[Left]);
else if (id == (unsigned int)idx_prev[Right])
geometry.set_uint_index(u, (unsigned int)idx_initial[Right]);
geometry.set_index(u, (unsigned int)idx_initial[Right]);
}
}
@ -1837,30 +1834,30 @@ static void thick_lines_to_geometry(
if (!closed) {
// Terminate open paths with caps.
if (i == 0) {
geometry.add_uint_triangle(idx_a[Bottom], idx_a[Right], idx_a[Top]);
geometry.add_uint_triangle(idx_a[Bottom], idx_a[Top], idx_a[Left]);
geometry.add_triangle(idx_a[Bottom], idx_a[Right], idx_a[Top]);
geometry.add_triangle(idx_a[Bottom], idx_a[Top], idx_a[Left]);
}
// We don't use 'else' because both cases are true if we have only one line.
if (i + 1 == lines.size()) {
geometry.add_uint_triangle(idx_b[Bottom], idx_b[Left], idx_b[Top]);
geometry.add_uint_triangle(idx_b[Bottom], idx_b[Top], idx_b[Right]);
geometry.add_triangle(idx_b[Bottom], idx_b[Left], idx_b[Top]);
geometry.add_triangle(idx_b[Bottom], idx_b[Top], idx_b[Right]);
}
}
// Add quads for a straight hollow tube-like segment.
// bottom-right face
geometry.add_uint_triangle(idx_a[Bottom], idx_b[Bottom], idx_b[Right]);
geometry.add_uint_triangle(idx_a[Bottom], idx_b[Right], idx_a[Right]);
geometry.add_triangle(idx_a[Bottom], idx_b[Bottom], idx_b[Right]);
geometry.add_triangle(idx_a[Bottom], idx_b[Right], idx_a[Right]);
// top-right face
geometry.add_uint_triangle(idx_a[Right], idx_b[Right], idx_b[Top]);
geometry.add_uint_triangle(idx_a[Right], idx_b[Top], idx_a[Top]);
geometry.add_triangle(idx_a[Right], idx_b[Right], idx_b[Top]);
geometry.add_triangle(idx_a[Right], idx_b[Top], idx_a[Top]);
// top-left face
geometry.add_uint_triangle(idx_a[Top], idx_b[Top], idx_b[Left]);
geometry.add_uint_triangle(idx_a[Top], idx_b[Left], idx_a[Left]);
geometry.add_triangle(idx_a[Top], idx_b[Top], idx_b[Left]);
geometry.add_triangle(idx_a[Top], idx_b[Left], idx_a[Left]);
// bottom-left face
geometry.add_uint_triangle(idx_a[Left], idx_b[Left], idx_b[Bottom]);
geometry.add_uint_triangle(idx_a[Left], idx_b[Bottom], idx_a[Bottom]);
geometry.add_triangle(idx_a[Left], idx_b[Left], idx_b[Bottom]);
geometry.add_triangle(idx_a[Left], idx_b[Bottom], idx_a[Bottom]);
}
}
#else

View File

@ -1675,7 +1675,7 @@ void GCodeViewer::load_toolpaths(const GCodeProcessorResult& gcode_result)
#if ENABLE_LEGACY_OPENGL_REMOVAL
const size_t indices_count = data.indices_count();
for (size_t i = 0; i < indices_count; ++i) {
indices.push_back(static_cast<IBufferType>(data.extract_ushort_index(i) + base_index));
indices.push_back(static_cast<IBufferType>(data.extract_index(i) + base_index));
}
#else
for (const auto& entity : data.entities) {

View File

@ -161,7 +161,11 @@ void GLCanvas3D::LayersEditing::select_object(const Model &model, int object_id)
bool GLCanvas3D::LayersEditing::is_allowed() const
{
#if ENABLE_GL_SHADERS_ATTRIBUTES
return wxGetApp().get_shader("variable_layer_height_attr") != nullptr && m_z_texture_id > 0;
#else
return wxGetApp().get_shader("variable_layer_height") != nullptr && m_z_texture_id > 0;
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
}
bool GLCanvas3D::LayersEditing::is_enabled() const
@ -324,7 +328,11 @@ Rect GLCanvas3D::LayersEditing::get_bar_rect_viewport(const GLCanvas3D& canvas)
bool GLCanvas3D::LayersEditing::is_initialized() const
{
#if ENABLE_GL_SHADERS_ATTRIBUTES
return wxGetApp().get_shader("variable_layer_height_attr") != nullptr;
#else
return wxGetApp().get_shader("variable_layer_height") != nullptr;
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
}
std::string GLCanvas3D::LayersEditing::get_tooltip(const GLCanvas3D& canvas) const
@ -402,7 +410,7 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
m_profile.background.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P2T2, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P2T2 };
init_data.reserve_vertices(4);
init_data.reserve_indices(6);
@ -424,8 +432,8 @@ void GLCanvas3D::LayersEditing::render_active_object_annotations(const GLCanvas3
init_data.add_vertex(Vec2f(l, t), Vec2f(0.0f, 1.0f));
// indices
init_data.add_ushort_triangle(0, 1, 2);
init_data.add_ushort_triangle(2, 3, 0);
init_data.add_triangle(0, 1, 2);
init_data.add_triangle(2, 3, 0);
m_profile.background.init_from(std::move(init_data));
}
@ -491,7 +499,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
m_profile.baseline.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P2, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P2 };
init_data.color = ColorRGBA::BLACK();
init_data.reserve_vertices(2);
init_data.reserve_indices(2);
@ -508,7 +516,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
// indices
init_data.add_ushort_line(0, 1);
init_data.add_line(0, 1);
m_profile.baseline.init_from(std::move(init_data));
}
@ -522,7 +530,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
m_profile.profile.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::LineStrip, GLModel::Geometry::EVertexLayout::P2, GLModel::Geometry::index_type(m_layer_height_profile.size() / 2) };
init_data.format = { GLModel::Geometry::EPrimitiveType::LineStrip, GLModel::Geometry::EVertexLayout::P2 };
init_data.color = ColorRGBA::BLUE();
init_data.reserve_vertices(m_layer_height_profile.size() / 2);
init_data.reserve_indices(m_layer_height_profile.size() / 2);
@ -536,10 +544,7 @@ void GLCanvas3D::LayersEditing::render_profile(const Rect& bar_rect)
init_data.add_vertex(Vec2f(bar_rect.get_left() + float(m_layer_height_profile[i + 1]) * scale_x,
bar_rect.get_bottom() + float(m_layer_height_profile[i]) * scale_y));
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
if (init_data.format.index_type == GLModel::Geometry::EIndexType::USHORT)
init_data.add_ushort_index((unsigned short)i / 2);
else
init_data.add_uint_index(i / 2);
init_data.add_index(i / 2);
}
m_profile.profile.init_from(std::move(init_data));
@ -994,7 +999,7 @@ void GLCanvas3D::SequentialPrintClearance::set_polygons(const Polygons& polygons
if (m_render_fill) {
GLModel::Geometry fill_data;
#if ENABLE_LEGACY_OPENGL_REMOVAL
fill_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::UINT };
fill_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3 };
fill_data.color = { 0.3333f, 0.0f, 0.0f, 0.5f };
// vertices + indices
@ -1008,7 +1013,7 @@ void GLCanvas3D::SequentialPrintClearance::set_polygons(const Polygons& polygons
fill_data.add_vertex((Vec3f)(v.cast<float>() + 0.0125f * Vec3f::UnitZ())); // add a small positive z to avoid z-fighting
++vertices_counter;
if (vertices_counter % 3 == 0)
fill_data.add_uint_triangle(vertices_counter - 3, vertices_counter - 2, vertices_counter - 1);
fill_data.add_triangle(vertices_counter - 3, vertices_counter - 2, vertices_counter - 1);
}
}
@ -5439,7 +5444,7 @@ void GLCanvas3D::_render_background()
m_background.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P2T2, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P2T2 };
init_data.reserve_vertices(4);
init_data.reserve_indices(6);
@ -5450,8 +5455,8 @@ void GLCanvas3D::_render_background()
init_data.add_vertex(Vec2f(-1.0f, 1.0f), Vec2f(0.0f, 1.0f));
// indices
init_data.add_ushort_triangle(0, 1, 2);
init_data.add_ushort_triangle(2, 3, 0);
init_data.add_triangle(0, 1, 2);
init_data.add_triangle(2, 3, 0);
m_background.init_from(std::move(init_data));
}
@ -6142,7 +6147,7 @@ void GLCanvas3D::_render_sla_slices()
#if ENABLE_LEGACY_OPENGL_REMOVAL
auto init_model = [](GLModel& model, const Pointf3s& triangles, const ColorRGBA& color) {
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::index_type(triangles.size()) };
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(triangles.size());
init_data.reserve_indices(triangles.size() / 3);
init_data.color = color;
@ -6151,12 +6156,8 @@ void GLCanvas3D::_render_sla_slices()
for (const Vec3d& v : triangles) {
init_data.add_vertex((Vec3f)v.cast<float>());
++vertices_count;
if (vertices_count % 3 == 0) {
if (init_data.format.index_type == GLModel::Geometry::EIndexType::USHORT)
init_data.add_ushort_triangle((unsigned short)vertices_count - 3, (unsigned short)vertices_count - 2, (unsigned short)vertices_count - 1);
else
init_data.add_uint_triangle(vertices_count - 3, vertices_count - 2, vertices_count - 1);
}
if (vertices_count % 3 == 0)
init_data.add_triangle(vertices_count - 3, vertices_count - 2, vertices_count - 1);
}
if (!init_data.is_empty())
@ -6485,7 +6486,7 @@ void GLCanvas3D::_load_print_toolpaths(const BuildVolume &build_volume)
#if ENABLE_LEGACY_OPENGL_REMOVAL
GLVolume* volume = m_volumes.new_toolpath_volume(color);
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3, GLModel::Geometry::EIndexType::UINT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3 };
#else
GLVolume *volume = m_volumes.new_toolpath_volume(color, VERTEX_BUFFER_RESERVE_SIZE);
#endif // ENABLE_LEGACY_OPENGL_REMOVAL
@ -6750,7 +6751,7 @@ void GLCanvas3D::_load_print_object_toolpaths(const PrintObject& print_object, c
#if ENABLE_LEGACY_OPENGL_REMOVAL
assert(vols.size() == geometries.size());
for (GLModel::Geometry& g : geometries) {
g.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3, GLModel::Geometry::EIndexType::UINT };
g.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3 };
}
#else
for (GLVolume *vol : vols)
@ -7006,7 +7007,7 @@ void GLCanvas3D::_load_wipe_tower_toolpaths(const BuildVolume& build_volume, con
#if ENABLE_LEGACY_OPENGL_REMOVAL
assert(vols.size() == geometries.size());
for (GLModel::Geometry& g : geometries) {
g.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3, GLModel::Geometry::EIndexType::UINT };
g.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3 };
}
#else
for (GLVolume *volume : vols)

File diff suppressed because it is too large Load Diff

View File

@ -68,23 +68,25 @@ namespace GUI {
enum class EIndexType : unsigned char
{
UINT, // unsigned int
USHORT // unsigned short
USHORT, // unsigned short
UBYTE // unsigned byte
};
struct Format
{
EPrimitiveType type{ EPrimitiveType::Triangles };
EVertexLayout vertex_layout{ EVertexLayout::P3N3 };
EIndexType index_type{ EIndexType::UINT };
};
Format format;
std::vector<float> vertices;
std::vector<unsigned char> indices;
std::vector<unsigned int> indices;
EIndexType index_type{ EIndexType::UINT };
ColorRGBA color{ ColorRGBA::BLACK() };
void reserve_vertices(size_t vertices_count);
void reserve_indices(size_t indices_count);
void reserve_vertices(size_t vertices_count) { vertices.reserve(vertices_count * vertex_stride_floats(format)); }
void reserve_indices(size_t indices_count) { indices.reserve(indices_count * index_stride_bytes(*this)); }
void add_vertex(const Vec2f& position); // EVertexLayout::P2
void add_vertex(const Vec2f& position, const Vec2f& tex_coord); // EVertexLayout::P2T2
@ -94,36 +96,29 @@ namespace GUI {
void set_vertex(size_t id, const Vec3f& position, const Vec3f& normal); // EVertexLayout::P3N3
void set_ushort_index(size_t id, unsigned short index);
void set_uint_index(size_t id, unsigned int index);
void set_index(size_t id, unsigned int index);
void add_ushort_index(unsigned short id);
void add_uint_index(unsigned int id);
void add_ushort_line(unsigned short id1, unsigned short id2);
void add_uint_line(unsigned int id1, unsigned int id2);
void add_ushort_triangle(unsigned short id1, unsigned short id2, unsigned short id3);
void add_uint_triangle(unsigned int id1, unsigned int id2, unsigned int id3);
void add_index(unsigned int id);
void add_line(unsigned int id1, unsigned int id2);
void add_triangle(unsigned int id1, unsigned int id2, unsigned int id3);
Vec2f extract_position_2(size_t id) const;
Vec3f extract_position_3(size_t id) const;
Vec3f extract_normal_3(size_t id) const;
Vec2f extract_tex_coord_2(size_t id) const;
unsigned int extract_uint_index(size_t id) const;
unsigned short extract_ushort_index(size_t id) const;
unsigned int extract_index(size_t id) const;
void remove_vertex(size_t id);
bool is_empty() const { return vertices_count() == 0 || indices_count() == 0; }
size_t vertices_count() const { return vertices.size() / vertex_stride_floats(format); }
size_t indices_count() const { return indices.size() / index_stride_bytes(format); }
size_t indices_count() const { return indices.size(); }
size_t vertices_size_floats() const { return vertices.size(); }
size_t vertices_size_bytes() const { return vertices_size_floats() * sizeof(float); }
size_t indices_size_bytes() const { return indices.size(); }
size_t indices_size_bytes() const { return indices.size() * index_stride_bytes(*this); }
static size_t vertex_stride_floats(const Format& format);
static size_t vertex_stride_bytes(const Format& format) { return vertex_stride_floats(format) * sizeof(float); }
@ -143,9 +138,7 @@ namespace GUI {
static size_t tex_coord_offset_floats(const Format& format);
static size_t tex_coord_offset_bytes(const Format& format) { return tex_coord_offset_floats(format) * sizeof(float); }
static size_t index_stride_bytes(const Format& format);
static EIndexType index_type(size_t vertices_count);
static size_t index_stride_bytes(const Geometry& data);
static bool has_position(const Format& format);
static bool has_normal(const Format& format);
@ -213,7 +206,7 @@ namespace GUI {
size_t vertices_size_floats() const { return vertices_count() * Geometry::vertex_stride_floats(m_render_data.geometry.format); }
size_t vertices_size_bytes() const { return vertices_size_floats() * sizeof(float); }
size_t indices_size_bytes() const { return indices_count() * Geometry::index_stride_bytes(m_render_data.geometry.format); }
size_t indices_size_bytes() const { return indices_count() * Geometry::index_stride_bytes(m_render_data.geometry); }
const Geometry& get_geometry() const { return m_render_data.geometry; }
@ -297,13 +290,13 @@ namespace GUI {
// the origin of the arrow is in the center of the stem cap
// the arrow has its axis of symmetry along the Z axis and is pointing upward
// used to render bed axes and sequential marker
GLModel::Geometry stilized_arrow(unsigned short resolution, float tip_radius, float tip_height, float stem_radius, float stem_height);
GLModel::Geometry stilized_arrow(unsigned int resolution, float tip_radius, float tip_height, float stem_radius, float stem_height);
// create an arrow whose stem is a quarter of circle, with the given dimensions and resolution
// the origin of the arrow is in the center of the circle
// the arrow is contained in the 1st quadrant of the XY plane and is pointing counterclockwise
// used to render sidebar hints for rotations
GLModel::Geometry circular_arrow(unsigned short resolution, float radius, float tip_height, float tip_width, float stem_width, float thickness);
GLModel::Geometry circular_arrow(unsigned int resolution, float radius, float tip_height, float tip_width, float stem_width, float thickness);
// create an arrow with the given dimensions
// the origin of the arrow is in the center of the stem cap
@ -314,13 +307,13 @@ namespace GUI {
// create a diamond with the given resolution
// the origin of the diamond is in its center
// the diamond is contained into a box with size [1, 1, 1]
GLModel::Geometry diamond(unsigned short resolution);
GLModel::Geometry diamond(unsigned int resolution);
#if ENABLE_LEGACY_OPENGL_REMOVAL
#if ENABLE_SHOW_TOOLPATHS_COG
// create a sphere with the given resolution and smooth normals
// the origin of the sphere is in its center
GLModel::Geometry smooth_sphere(unsigned short resolution, float radius);
GLModel::Geometry smooth_sphere(unsigned int resolution, float radius);
#endif // ENABLE_SHOW_TOOLPATHS_COG
#endif // ENABLE_LEGACY_OPENGL_REMOVAL

View File

@ -145,7 +145,7 @@ namespace GUI {
m_rectangle.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P2, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P2 };
init_data.reserve_vertices(4);
init_data.reserve_indices(4);
@ -156,10 +156,10 @@ namespace GUI {
init_data.add_vertex(Vec2f(left, top));
// indices
init_data.add_ushort_index(0);
init_data.add_ushort_index(1);
init_data.add_ushort_index(2);
init_data.add_ushort_index(3);
init_data.add_index(0);
init_data.add_index(1);
init_data.add_index(2);
init_data.add_index(3);
m_rectangle.init_from(std::move(init_data));
}

View File

@ -341,7 +341,7 @@ void GLTexture::render_sub_texture(unsigned int tex_id, float left, float right,
#if ENABLE_LEGACY_OPENGL_REMOVAL
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P2T2, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P2T2 };
init_data.reserve_vertices(4);
init_data.reserve_indices(6);
@ -352,8 +352,8 @@ void GLTexture::render_sub_texture(unsigned int tex_id, float left, float right,
init_data.add_vertex(Vec2f(left, top), Vec2f(uvs.left_top.u, uvs.left_top.v));
// indices
init_data.add_ushort_triangle(0, 1, 2);
init_data.add_ushort_triangle(2, 3, 0);
init_data.add_triangle(0, 1, 2);
init_data.add_triangle(2, 3, 0);
GLModel model;
model.init_from(std::move(init_data));

View File

@ -126,7 +126,7 @@ void GLGizmoCut::on_render()
m_plane.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3 };
init_data.color = { 0.8f, 0.8f, 0.8f, 0.5f };
init_data.reserve_vertices(4);
init_data.reserve_indices(6);
@ -138,8 +138,8 @@ void GLGizmoCut::on_render()
init_data.add_vertex(Vec3f(min_x, max_y, plane_center.z()));
// indices
init_data.add_ushort_triangle(0, 1, 2);
init_data.add_ushort_triangle(2, 3, 0);
init_data.add_triangle(0, 1, 2);
init_data.add_triangle(2, 3, 0);
m_plane.init_from(std::move(init_data));
}
@ -177,7 +177,7 @@ void GLGizmoCut::on_render()
m_grabber_connection.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.color = ColorRGBA::YELLOW();
init_data.reserve_vertices(2);
init_data.reserve_indices(2);
@ -187,7 +187,7 @@ void GLGizmoCut::on_render()
init_data.add_vertex((Vec3f)m_grabbers[0].center.cast<float>());
// indices
init_data.add_ushort_line(0, 1);
init_data.add_line(0, 1);
m_grabber_connection.init_from(std::move(init_data));
}

View File

@ -429,16 +429,13 @@ void GLGizmoFlatten::update_planes()
for (auto& plane : m_planes) {
#if ENABLE_LEGACY_OPENGL_REMOVAL
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::TriangleFan, GLModel::Geometry::EVertexLayout::P3N3, GLModel::Geometry::index_type(plane.vertices.size()) };
init_data.format = { GLModel::Geometry::EPrimitiveType::TriangleFan, GLModel::Geometry::EVertexLayout::P3N3 };
init_data.reserve_vertices(plane.vertices.size());
init_data.reserve_indices(plane.vertices.size());
// vertices + indices
for (size_t i = 0; i < plane.vertices.size(); ++i) {
init_data.add_vertex((Vec3f)plane.vertices[i].cast<float>(), (Vec3f)plane.normal.cast<float>());
if (init_data.format.index_type == GLModel::Geometry::EIndexType::USHORT)
init_data.add_ushort_index((unsigned short)i);
else
init_data.add_uint_index((unsigned int)i);
init_data.add_index((unsigned int)i);
}
plane.vbo.init_from(std::move(init_data));
#else

View File

@ -132,7 +132,7 @@ void GLGizmoMove3D::on_render()
m_grabber_connections[id].model.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.color = AXES_COLOR[id];
init_data.reserve_vertices(2);
init_data.reserve_indices(2);
@ -142,7 +142,7 @@ void GLGizmoMove3D::on_render()
init_data.add_vertex((Vec3f)m_grabbers[id].center.cast<float>());
// indices
init_data.add_ushort_line(0, 1);
init_data.add_line(0, 1);
m_grabber_connections[id].model.init_from(std::move(init_data));
}

View File

@ -230,21 +230,21 @@ void GLGizmoPainterBase::render_cursor_circle()
GLModel::Geometry init_data;
static const unsigned int StepsCount = 32;
static const float StepSize = 2.0f * float(PI) / float(StepsCount);
init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P2, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P2 };
init_data.color = { 0.0f, 1.0f, 0.3f, 1.0f };
init_data.reserve_vertices(StepsCount);
init_data.reserve_indices(StepsCount);
// vertices + indices
for (unsigned short i = 0; i < StepsCount; ++i) {
const float angle = float(i * StepSize);
for (unsigned int i = 0; i < StepsCount; ++i) {
const float angle = float(i) * StepSize;
#if ENABLE_GL_SHADERS_ATTRIBUTES
init_data.add_vertex(Vec2f(2.0f * ((center.x() + ::cos(angle) * radius) * cnv_inv_width - 0.5f),
-2.0f * ((center.y() + ::sin(angle) * radius) * cnv_inv_height - 0.5f)));
#else
init_data.add_vertex(Vec2f(center.x() + ::cos(angle) * m_cursor_radius, center.y() + ::sin(angle) * m_cursor_radius));
#endif // ENABLE_GL_SHADERS_ATTRIBUTES
init_data.add_ushort_index(i);
init_data.add_index(i);
}
m_circle.init_from(std::move(init_data));
@ -1014,12 +1014,12 @@ void TriangleSelectorGUI::update_render_data()
}
GLModel::Geometry iva_enforcers_data;
iva_enforcers_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3, GLModel::Geometry::EIndexType::UINT };
iva_enforcers_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3 };
GLModel::Geometry iva_blockers_data;
iva_blockers_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3, GLModel::Geometry::EIndexType::UINT };
iva_blockers_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3 };
std::array<GLModel::Geometry, 3> iva_seed_fills_data;
for (auto& data : iva_seed_fills_data)
data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3, GLModel::Geometry::EIndexType::UINT };
data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3 };
#else
for (auto *iva : {&m_iva_enforcers, &m_iva_blockers})
iva->release_geometry();
@ -1055,7 +1055,7 @@ void TriangleSelectorGUI::update_render_data()
iva.add_vertex(v0, n);
iva.add_vertex(v1, n);
iva.add_vertex(v2, n);
iva.add_uint_triangle((unsigned int)cnt, (unsigned int)cnt + 1, (unsigned int)cnt + 2);
iva.add_triangle((unsigned int)cnt, (unsigned int)cnt + 1, (unsigned int)cnt + 2);
#else
iva.push_geometry(v0, n);
iva.push_geometry(v1, n);
@ -1345,7 +1345,7 @@ void TriangleSelectorGUI::update_paint_contour()
GLModel::Geometry init_data;
const std::vector<Vec2i> contour_edges = this->get_seed_fill_contour();
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::index_type(2 * contour_edges.size()) };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(2 * contour_edges.size());
init_data.reserve_indices(2 * contour_edges.size());
#if ENABLE_GL_SHADERS_ATTRIBUTES
@ -1358,10 +1358,7 @@ void TriangleSelectorGUI::update_paint_contour()
init_data.add_vertex(m_vertices[edge(0)].v);
init_data.add_vertex(m_vertices[edge(1)].v);
vertices_count += 2;
if (init_data.format.index_type == GLModel::Geometry::EIndexType::USHORT)
init_data.add_ushort_line((unsigned short)vertices_count - 2, (unsigned short)vertices_count - 1);
else
init_data.add_uint_line(vertices_count - 2, vertices_count - 1);
init_data.add_line(vertices_count - 2, vertices_count - 1);
}
if (!init_data.is_empty())

View File

@ -297,15 +297,15 @@ void GLGizmoRotate::render_circle() const
m_circle.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::LineLoop, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(ScaleStepsCount);
init_data.reserve_indices(ScaleStepsCount);
// vertices + indices
for (unsigned short i = 0; i < ScaleStepsCount; ++i) {
for (unsigned int i = 0; i < ScaleStepsCount; ++i) {
const float angle = float(i * ScaleStepRad);
init_data.add_vertex(Vec3f(::cos(angle) * m_radius, ::sin(angle) * m_radius, 0.0f));
init_data.add_ushort_index(i);
init_data.add_index(i);
}
m_circle.init_from(std::move(init_data));
@ -340,12 +340,12 @@ void GLGizmoRotate::render_scale() const
m_scale.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(2 * ScaleStepsCount);
init_data.reserve_indices(2 * ScaleStepsCount);
// vertices + indices
for (unsigned short i = 0; i < ScaleStepsCount; ++i) {
for (unsigned int i = 0; i < ScaleStepsCount; ++i) {
const float angle = float(i * ScaleStepRad);
const float cosa = ::cos(angle);
const float sina = ::sin(angle);
@ -354,10 +354,12 @@ void GLGizmoRotate::render_scale() const
const float out_x = (i % ScaleLongEvery == 0) ? cosa * out_radius_long : cosa * out_radius_short;
const float out_y = (i % ScaleLongEvery == 0) ? sina * out_radius_long : sina * out_radius_short;
// vertices
init_data.add_vertex(Vec3f(in_x, in_y, 0.0f));
init_data.add_vertex(Vec3f(out_x, out_y, 0.0f));
init_data.add_ushort_index(i * 2);
init_data.add_ushort_index(i * 2 + 1);
// indices
init_data.add_line(i * 2, i * 2 + 1);
}
m_scale.init_from(std::move(init_data));
@ -399,12 +401,12 @@ void GLGizmoRotate::render_snap_radii() const
m_snap_radii.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(2 * ScaleStepsCount);
init_data.reserve_indices(2 * ScaleStepsCount);
// vertices + indices
for (unsigned short i = 0; i < ScaleStepsCount; ++i) {
for (unsigned int i = 0; i < ScaleStepsCount; ++i) {
const float angle = float(i * step);
const float cosa = ::cos(angle);
const float sina = ::sin(angle);
@ -413,10 +415,12 @@ void GLGizmoRotate::render_snap_radii() const
const float out_x = cosa * out_radius;
const float out_y = sina * out_radius;
// vertices
init_data.add_vertex(Vec3f(in_x, in_y, 0.0f));
init_data.add_vertex(Vec3f(out_x, out_y, 0.0f));
init_data.add_ushort_index(i * 2);
init_data.add_ushort_index(i * 2 + 1);
// indices
init_data.add_line(i * 2, i * 2 + 1);
}
m_snap_radii.init_from(std::move(init_data));
@ -450,7 +454,7 @@ void GLGizmoRotate::render_reference_radius(const ColorRGBA& color, bool radius_
m_reference_radius.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(2);
init_data.reserve_indices(2);
@ -459,7 +463,7 @@ void GLGizmoRotate::render_reference_radius(const ColorRGBA& color, bool radius_
init_data.add_vertex(Vec3f(m_radius * (1.0f + GrabberOffset), 0.0f, 0.0f));
// indices
init_data.add_ushort_line(0, 1);
init_data.add_line(0, 1);
m_reference_radius.init_from(std::move(init_data));
}
@ -494,15 +498,15 @@ void GLGizmoRotate::render_angle() const
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.format = { GLModel::Geometry::EPrimitiveType::LineStrip, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(1 + AngleResolution);
init_data.reserve_indices(1 + AngleResolution);
// vertices + indices
for (unsigned short i = 0; i <= AngleResolution; ++i) {
for (unsigned int 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);
init_data.add_index(i);
}
m_angle_arc.init_from(std::move(init_data));
@ -532,7 +536,7 @@ void GLGizmoRotate::render_grabber_connection(const ColorRGBA& color, bool radiu
m_grabber_connection.old_center = m_grabbers.front().center;
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(2);
init_data.reserve_indices(2);
@ -541,7 +545,7 @@ void GLGizmoRotate::render_grabber_connection(const ColorRGBA& color, bool radiu
init_data.add_vertex((Vec3f)m_grabbers.front().center.cast<float>());
// indices
init_data.add_ushort_line(0, 1);
init_data.add_line(0, 1);
m_grabber_connection.model.init_from(std::move(init_data));
}

View File

@ -515,7 +515,7 @@ void GLGizmoScale3D::render_grabbers_connection(unsigned int id_1, unsigned int
m_grabber_connections[id].model.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(2);
init_data.reserve_indices(2);
@ -524,7 +524,7 @@ void GLGizmoScale3D::render_grabbers_connection(unsigned int id_1, unsigned int
init_data.add_vertex((Vec3f)m_grabbers[id_2].center.cast<float>());
// indices
init_data.add_ushort_line(0, 1);
init_data.add_line(0, 1);
m_grabber_connections[id].model.init_from(std::move(init_data));
}

View File

@ -202,7 +202,7 @@ void MeshClipper::recalculate_triangles()
m_model.reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3, GLModel::Geometry::index_type(m_triangles2d.size()) };
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3N3 };
init_data.reserve_vertices(m_triangles2d.size());
init_data.reserve_indices(m_triangles2d.size());
@ -212,10 +212,7 @@ void MeshClipper::recalculate_triangles()
init_data.add_vertex((Vec3f)(tr * Vec3d((*(it + 1)).x(), (*(it + 1)).y(), height_mesh)).cast<float>(), (Vec3f)up.cast<float>());
init_data.add_vertex((Vec3f)(tr * Vec3d((*(it + 2)).x(), (*(it + 2)).y(), height_mesh)).cast<float>(), (Vec3f)up.cast<float>());
const size_t idx = it - m_triangles2d.cbegin();
if (init_data.format.index_type == GLModel::Geometry::EIndexType::USHORT)
init_data.add_ushort_triangle((unsigned short)idx, (unsigned short)idx + 1, (unsigned short)idx + 2);
else
init_data.add_uint_triangle((unsigned int)idx, (unsigned int)idx + 1, (unsigned int)idx + 2);
init_data.add_triangle((unsigned int)idx, (unsigned int)idx + 1, (unsigned int)idx + 2);
}
if (!init_data.is_empty())

View File

@ -1947,7 +1947,7 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con
const Vec3f size = 0.2f * box.size().cast<float>();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Lines, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(48);
init_data.reserve_indices(48);
@ -2009,8 +2009,8 @@ void Selection::render_bounding_box(const BoundingBoxf3 & box, float* color) con
init_data.add_vertex(Vec3f(b_min.x(), b_max.y(), b_max.z() - size.z()));
// indices
for (unsigned short i = 0; i < 48; ++i) {
init_data.add_ushort_index(i);
for (unsigned int i = 0; i < 48; ++i) {
init_data.add_index(i);
}
m_box.init_from(std::move(init_data));
@ -2371,7 +2371,7 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field)
m_planes.models[0].reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(4);
init_data.reserve_indices(6);
@ -2382,8 +2382,8 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field)
init_data.add_vertex(Vec3f(p1.x(), p2.y(), z1));
// indices
init_data.add_ushort_triangle(0, 1, 2);
init_data.add_ushort_triangle(2, 3, 0);
init_data.add_triangle(0, 1, 2);
init_data.add_triangle(2, 3, 0);
m_planes.models[0].init_from(std::move(init_data));
}
@ -2393,7 +2393,7 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field)
m_planes.models[1].reset();
GLModel::Geometry init_data;
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3, GLModel::Geometry::EIndexType::USHORT };
init_data.format = { GLModel::Geometry::EPrimitiveType::Triangles, GLModel::Geometry::EVertexLayout::P3 };
init_data.reserve_vertices(4);
init_data.reserve_indices(6);
@ -2404,8 +2404,8 @@ void Selection::render_sidebar_layers_hints(const std::string& sidebar_field)
init_data.add_vertex(Vec3f(p1.x(), p2.y(), z2));
// indices
init_data.add_ushort_triangle(0, 1, 2);
init_data.add_ushort_triangle(2, 3, 0);
init_data.add_triangle(0, 1, 2);
init_data.add_triangle(2, 3, 0);
m_planes.models[1].init_from(std::move(init_data));
}