diff --git a/src/slic3r/GUI/GLModel.cpp b/src/slic3r/GUI/GLModel.cpp index 4c98b05172..bb8d0b338d 100644 --- a/src/slic3r/GUI/GLModel.cpp +++ b/src/slic3r/GUI/GLModel.cpp @@ -2254,7 +2254,7 @@ GLModel::Geometry smooth_sphere(unsigned int resolution, float radius) return data; } -GLModel::Geometry smooth_cylinder(Axis axis, unsigned int resolution, float radius, float height) +GLModel::Geometry smooth_cylinder(unsigned int resolution, float radius, float height) { resolution = std::max(4, resolution); @@ -2266,39 +2266,19 @@ GLModel::Geometry smooth_cylinder(Axis axis, unsigned int resolution, float radi data.reserve_vertices(sectorCount * 4 + 2); data.reserve_indices(sectorCount * 4 * 3); - auto generate_vertices_on_circle = [sectorCount, sectorStep](Axis axis, float radius) { + auto generate_vertices_on_circle = [sectorCount, sectorStep](float radius) { std::vector ret; ret.reserve(sectorCount); for (unsigned int i = 0; i < sectorCount; ++i) { // from 0 to 2pi const float sectorAngle = (i != sectorCount) ? sectorStep * i : 0.0f; - const float x1 = radius * std::cos(sectorAngle); - const float x2 = radius * std::sin(sectorAngle); - - Vec3f v; - switch (axis) - { - case X: { v = Vec3f(0.0f, x1, x2); break; } - case Y: { v = Vec3f(-x1, 0.0f, x2); break; } - case Z: { v = Vec3f(x1, x2, 0.0f); break; } - default: { assert(false); break; } - } - - ret.emplace_back(v); + ret.emplace_back(radius * std::cos(sectorAngle), radius * std::sin(sectorAngle), 0.0f); } return ret; }; - const std::vector base_vertices = generate_vertices_on_circle(axis, radius); - - Vec3f h; - switch (axis) - { - case X: { h = height * Vec3f::UnitX(); break; } - case Y: { h = height * Vec3f::UnitY(); break; } - case Z: { h = height * Vec3f::UnitZ(); break; } - default: { assert(false); break; } - } + const std::vector base_vertices = generate_vertices_on_circle(radius); + const Vec3f h = height * Vec3f::UnitZ(); // stem vertices for (unsigned int i = 0; i < sectorCount; ++i) { @@ -2321,14 +2301,7 @@ GLModel::Geometry smooth_cylinder(Axis axis, unsigned int resolution, float radi // bottom cap vertices Vec3f cap_center = Vec3f::Zero(); unsigned int cap_center_id = data.vertices_count(); - Vec3f normal; - switch (axis) - { - case X: { normal = -Vec3f::UnitX(); break; } - case Y: { normal = -Vec3f::UnitY(); break; } - case Z: { normal = -Vec3f::UnitZ(); break; } - default: { assert(false); break; } - } + Vec3f normal = -Vec3f::UnitZ(); data.add_vertex(cap_center, normal); for (unsigned int i = 0; i < sectorCount; ++i) { diff --git a/src/slic3r/GUI/GLModel.hpp b/src/slic3r/GUI/GLModel.hpp index 393e545ab9..8fe821a3da 100644 --- a/src/slic3r/GUI/GLModel.hpp +++ b/src/slic3r/GUI/GLModel.hpp @@ -374,16 +374,13 @@ namespace GUI { GLModel::Geometry diamond(unsigned int resolution); #if ENABLE_LEGACY_OPENGL_REMOVAL - // create a sphere with the given resolution and smooth normals + // create a sphere with smooth normals // the origin of the sphere is in its center - // the radius of the sphere is the given value GLModel::Geometry smooth_sphere(unsigned int resolution, float radius); - // create a cylinder with the given resolution and smooth normals - // the axis of the cylinder is the given value - // the radius of the cylinder is the given value - // the height of the cylinder is the given value - // the origin of the cylinder is in the center of the cap face having axis == 0 - GLModel::Geometry smooth_cylinder(Axis axis, unsigned int resolution, float radius, float height); + // create a cylinder with smooth normals + // the axis of the cylinder is the Z axis + // the origin of the cylinder is the center of its bottom cap face + GLModel::Geometry smooth_cylinder(unsigned int resolution, float radius, float height); #endif // ENABLE_LEGACY_OPENGL_REMOVAL } // namespace GUI diff --git a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp index 5b6baa0153..327a60a046 100644 --- a/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp +++ b/src/slic3r/GUI/Gizmos/GLGizmoMeasure.cpp @@ -23,7 +23,7 @@ GLGizmoMeasure::GLGizmoMeasure(GLCanvas3D& parent, const std::string& icon_filen : GLGizmoBase(parent, icon_filename, sprite_id) { m_vbo_sphere.init_from(smooth_sphere(16, 7.5f)); - m_vbo_cylinder.init_from(smooth_cylinder(Z, 16, 5.0f, 1.0f)); + m_vbo_cylinder.init_from(smooth_cylinder(16, 5.0f, 1.0f)); } bool GLGizmoMeasure::on_mouse(const wxMouseEvent &mouse_event)