Removed GLU calls from all the gizmos

This commit is contained in:
Lukas Matena 2021-03-12 10:29:17 +01:00
parent 0c7095d807
commit 97b7ef7dc0
12 changed files with 129 additions and 200 deletions

View File

@ -1014,6 +1014,33 @@ TriangleMesh make_cylinder(double r, double h, double fa)
return mesh;
}
TriangleMesh make_cone(double r, double h, double fa)
{
Pointf3s vertices;
std::vector<Vec3i> facets;
vertices.reserve(3+size_t(2*PI/fa));
vertices.reserve(3+2*size_t(2*PI/fa));
vertices = { Vec3d::Zero(), Vec3d(0., 0., h) }; // base center and top vertex
size_t i = 0;
for (double angle=0; angle<2*PI; angle+=fa) {
vertices.emplace_back(r*std::cos(angle), r*std::sin(angle), 0.);
if (angle > 0.) {
facets.emplace_back(0, i+2, i+1);
facets.emplace_back(1, i+1, i+2);
}
++i;
}
facets.emplace_back(0, 2, i+1); // close the shape
facets.emplace_back(1, i+1, 2);
TriangleMesh mesh(std::move(vertices), std::move(facets));
mesh.repair();
return mesh;
}
// Generates mesh for a sphere centered about the origin, using the generated angle
// to determine the granularity.
// Default angle is 1 degree.

View File

@ -122,10 +122,8 @@ Polygon its_convex_hull_2d_above(const indexed_triangle_set &its, const Matrix3f
Polygon its_convex_hull_2d_above(const indexed_triangle_set &its, const Transform3f &t, const float z);
TriangleMesh make_cube(double x, double y, double z);
// Generate a TriangleMesh of a cylinder
TriangleMesh make_cylinder(double r, double h, double fa=(2*PI/360));
TriangleMesh make_cone(double r, double h, double fa=(2*PI/360));
TriangleMesh make_sphere(double rho, double fa=(2*PI/360));
}

View File

@ -13,6 +13,10 @@ namespace GUI {
const float GLGizmoBase::Grabber::SizeFactor = 0.05f;
const float GLGizmoBase::Grabber::MinHalfSize = 1.5f;
const float GLGizmoBase::Grabber::DraggingScaleFactor = 1.25f;
GLModel GLGizmoBase::Grabber::VBOCube;
GLModel GLGizmoBase::VBOCone;
GLModel GLGizmoBase::VBOCylinder;
GLModel GLGizmoBase::VBOSphere;
GLGizmoBase::Grabber::Grabber()
: center(Vec3d::Zero())
@ -24,6 +28,9 @@ GLGizmoBase::Grabber::Grabber()
color[1] = 1.0f;
color[2] = 1.0f;
color[3] = 1.0f;
TriangleMesh cube = make_cube(1., 1., 1.);
cube.translate(Vec3f(-0.5, -0.5, -0.5));
VBOCube.init_from(cube);
}
void GLGizmoBase::Grabber::render(bool hover, float size) const
@ -54,7 +61,7 @@ float GLGizmoBase::Grabber::get_dragging_half_size(float size) const
void GLGizmoBase::Grabber::render(float size, const float* render_color, bool use_lighting) const
{
float half_size = dragging ? get_dragging_half_size(size) : get_half_size(size);
float fullsize = 2 * (dragging ? get_dragging_half_size(size) : get_half_size(size));
if (use_lighting)
glsafe(::glEnable(GL_LIGHTING));
@ -63,71 +70,17 @@ void GLGizmoBase::Grabber::render(float size, const float* render_color, bool us
glsafe(::glPushMatrix());
glsafe(::glTranslated(center(0), center(1), center(2)));
glsafe(::glRotated(Geometry::rad2deg(angles(2)), 0.0, 0.0, 1.0));
glsafe(::glRotated(Geometry::rad2deg(angles(1)), 0.0, 1.0, 0.0));
glsafe(::glRotated(Geometry::rad2deg(angles(0)), 1.0, 0.0, 0.0));
// face min x
glsafe(::glPushMatrix());
glsafe(::glTranslatef(-(GLfloat)half_size, 0.0f, 0.0f));
glsafe(::glRotatef(-90.0f, 0.0f, 1.0f, 0.0f));
render_face(half_size);
glsafe(::glPopMatrix());
// face max x
glsafe(::glPushMatrix());
glsafe(::glTranslatef((GLfloat)half_size, 0.0f, 0.0f));
glsafe(::glRotatef(90.0f, 0.0f, 1.0f, 0.0f));
render_face(half_size);
glsafe(::glPopMatrix());
// face min y
glsafe(::glPushMatrix());
glsafe(::glTranslatef(0.0f, -(GLfloat)half_size, 0.0f));
glsafe(::glRotatef(90.0f, 1.0f, 0.0f, 0.0f));
render_face(half_size);
glsafe(::glPopMatrix());
// face max y
glsafe(::glPushMatrix());
glsafe(::glTranslatef(0.0f, (GLfloat)half_size, 0.0f));
glsafe(::glRotatef(-90.0f, 1.0f, 0.0f, 0.0f));
render_face(half_size);
glsafe(::glPopMatrix());
// face min z
glsafe(::glPushMatrix());
glsafe(::glTranslatef(0.0f, 0.0f, -(GLfloat)half_size));
glsafe(::glRotatef(180.0f, 1.0f, 0.0f, 0.0f));
render_face(half_size);
glsafe(::glPopMatrix());
// face max z
glsafe(::glPushMatrix());
glsafe(::glTranslatef(0.0f, 0.0f, (GLfloat)half_size));
render_face(half_size);
glsafe(::glPopMatrix());
glsafe(::glScaled(fullsize, fullsize, fullsize));
VBOCube.render();
glsafe(::glPopMatrix());
if (use_lighting)
glsafe(::glDisable(GL_LIGHTING));
}
void GLGizmoBase::Grabber::render_face(float half_size) const
{
::glBegin(GL_TRIANGLES);
::glNormal3f(0.0f, 0.0f, 1.0f);
::glVertex3f(-(GLfloat)half_size, -(GLfloat)half_size, 0.0f);
::glVertex3f((GLfloat)half_size, -(GLfloat)half_size, 0.0f);
::glVertex3f((GLfloat)half_size, (GLfloat)half_size, 0.0f);
::glVertex3f((GLfloat)half_size, (GLfloat)half_size, 0.0f);
::glVertex3f(-(GLfloat)half_size, (GLfloat)half_size, 0.0f);
::glVertex3f(-(GLfloat)half_size, -(GLfloat)half_size, 0.0f);
glsafe(::glEnd());
}
GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
: m_parent(parent)
@ -144,6 +97,9 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent, const std::string& icon_filename, u
::memcpy((void*)m_base_color, (const void*)DEFAULT_BASE_COLOR, 4 * sizeof(float));
::memcpy((void*)m_drag_color, (const void*)DEFAULT_DRAG_COLOR, 4 * sizeof(float));
::memcpy((void*)m_highlight_color, (const void*)DEFAULT_HIGHLIGHT_COLOR, 4 * sizeof(float));
VBOCone.init_from(make_cone(1., 1., 2*PI/24));
VBOSphere.init_from(make_sphere(1., (2*M_PI)/24.));
VBOCylinder.init_from(make_cylinder(1., 1., 2*PI/24.));
}
void GLGizmoBase::set_hover_id(int id)

View File

@ -4,6 +4,7 @@
#include "libslic3r/Point.hpp"
#include "slic3r/GUI/I18N.hpp"
#include "slic3r/GUI/GLModel.hpp"
#include <cereal/archives/binary.hpp>
@ -47,6 +48,8 @@ protected:
static const float SizeFactor;
static const float MinHalfSize;
static const float DraggingScaleFactor;
static GLModel VBOCube;
static GLModel VBOCone;
Vec3d center;
Vec3d angles;
@ -64,7 +67,6 @@ protected:
private:
void render(float size, const float* render_color, bool use_lighting) const;
void render_face(float half_size) const;
};
public:
@ -103,6 +105,9 @@ protected:
bool m_first_input_window_render;
mutable std::string m_tooltip;
CommonGizmosDataPool* m_c;
static GLModel VBOCone;
static GLModel VBOCylinder;
static GLModel VBOSphere;
public:
GLGizmoBase(GLCanvas3D& parent,

View File

@ -19,20 +19,10 @@ namespace GUI {
GLGizmoHollow::GLGizmoHollow(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
: GLGizmoBase(parent, icon_filename, sprite_id)
, m_quadric(nullptr)
{
m_quadric = ::gluNewQuadric();
if (m_quadric != nullptr)
// using GLU_FILL does not work when the instance's transformation
// contains mirroring (normals are reverted)
::gluQuadricDrawStyle(m_quadric, GLU_FILL);
m_vbo_cylinder.init_from(make_cylinder(1., 1.));
}
GLGizmoHollow::~GLGizmoHollow()
{
if (m_quadric != nullptr)
::gluDeleteQuadric(m_quadric);
}
bool GLGizmoHollow::on_init()
{
@ -87,7 +77,7 @@ void GLGizmoHollow::on_render() const
glsafe(::glEnable(GL_BLEND));
glsafe(::glEnable(GL_DEPTH_TEST));
if (m_quadric != nullptr && selection.is_from_single_instance())
if (selection.is_from_single_instance())
render_points(selection, false);
m_selection_rectangle.render(m_parent);
@ -111,8 +101,10 @@ void GLGizmoHollow::on_render_for_picking() const
void GLGizmoHollow::render_points(const Selection& selection, bool picking) const
{
if (!picking)
glsafe(::glEnable(GL_LIGHTING));
GLShaderProgram* shader = picking ? nullptr : wxGetApp().get_shader("gouraud_light");
if (shader)
shader->start_using();
ScopeGuard guard([shader]() { if (shader) shader->stop_using(); });
const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin());
const Transform3d& instance_scaling_matrix_inverse = vol->get_instance_transformation().get_matrix(true, true, false, true).inverse();
@ -150,16 +142,17 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons
}
else { // neigher hover nor picking
render_color[0] = point_selected ? 1.0f : 0.7f;
render_color[1] = point_selected ? 0.3f : 0.7f;
render_color[2] = point_selected ? 0.3f : 0.7f;
render_color[0] = point_selected ? 1.0f : 1.f;
render_color[1] = point_selected ? 0.3f : 1.f;
render_color[2] = point_selected ? 0.3f : 1.f;
render_color[3] = 0.5f;
}
}
glsafe(::glColor4fv(render_color.data()));
float render_color_emissive[4] = { 0.5f * render_color[0], 0.5f * render_color[1], 0.5f * render_color[2], 1.f};
glsafe(::glMaterialfv(GL_FRONT, GL_EMISSION, render_color_emissive));
if (shader && ! picking)
shader->set_uniform("uniform_color", render_color);
else // picking
glsafe(::glColor4fv(render_color.data()));
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
glsafe(::glPushMatrix());
@ -176,12 +169,8 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons
glsafe(::glRotated(aa.angle() * (180. / M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2)));
glsafe(::glPushMatrix());
glsafe(::glTranslated(0., 0., -drain_hole.height));
::gluCylinder(m_quadric, drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength, 24, 1);
glsafe(::glTranslated(0., 0., drain_hole.height + sla::HoleStickOutLength));
::gluDisk(m_quadric, 0.0, drain_hole.radius, 24, 1);
glsafe(::glTranslated(0., 0., -drain_hole.height - sla::HoleStickOutLength));
glsafe(::glRotatef(180.f, 1.f, 0.f, 0.f));
::gluDisk(m_quadric, 0.0, drain_hole.radius, 24, 1);
glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength));
m_vbo_cylinder.render();
glsafe(::glPopMatrix());
if (vol->is_left_handed())
@ -189,14 +178,8 @@ void GLGizmoHollow::render_points(const Selection& selection, bool picking) cons
glsafe(::glPopMatrix());
}
{
// Reset emissive component to zero (the default value)
float render_color_emissive[4] = { 0.f, 0.f, 0.f, 1.f };
glsafe(::glMaterialfv(GL_FRONT, GL_EMISSION, render_color_emissive));
}
if (!picking)
glsafe(::glDisable(GL_LIGHTING));
//if (!picking)
// glsafe(::glDisable(GL_LIGHTING));
glsafe(::glPopMatrix());
}

View File

@ -25,12 +25,10 @@ class GLGizmoHollow : public GLGizmoBase
private:
bool unproject_on_mesh(const Vec2d& mouse_pos, std::pair<Vec3f, Vec3f>& pos_and_normal);
GLUquadricObj* m_quadric;
public:
GLGizmoHollow(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
~GLGizmoHollow() override;
virtual ~GLGizmoHollow() = default;
void set_sla_support_data(ModelObject* model_object, const Selection& selection);
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
void delete_selected_points();
@ -50,7 +48,7 @@ private:
ObjectID m_old_mo_id = -1;
// bool m_show_supports = true;
GLModel m_vbo_cylinder;
float m_new_hole_radius = 2.f; // Size of a new hole.
float m_new_hole_height = 6.f;
mutable std::vector<bool> m_selected; // which holes are currently selected

View File

@ -18,17 +18,8 @@ GLGizmoMove3D::GLGizmoMove3D(GLCanvas3D& parent, const std::string& icon_filenam
, m_starting_drag_position(Vec3d::Zero())
, m_starting_box_center(Vec3d::Zero())
, m_starting_box_bottom_center(Vec3d::Zero())
, m_quadric(nullptr)
{
m_quadric = ::gluNewQuadric();
if (m_quadric != nullptr)
::gluQuadricDrawStyle(m_quadric, GLU_FILL);
}
GLGizmoMove3D::~GLGizmoMove3D()
{
if (m_quadric != nullptr)
::gluDeleteQuadric(m_quadric);
m_vbo_cone.init_from(make_cone(1., 1., 2*PI/36));
}
std::string GLGizmoMove3D::get_tooltip() const
@ -200,9 +191,6 @@ double GLGizmoMove3D::calc_projection(const UpdateData& data) const
void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box, bool picking) const
{
if (m_quadric == nullptr)
return;
float mean_size = (float)((box.size()(0) + box.size()(1) + box.size()(2)) / 3.0);
double size = m_dragging ? (double)m_grabbers[axis].get_dragging_half_size(mean_size) : (double)m_grabbers[axis].get_half_size(mean_size);
@ -228,10 +216,8 @@ void GLGizmoMove3D::render_grabber_extension(Axis axis, const BoundingBoxf3& box
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
::gluQuadricOrientation(m_quadric, GLU_OUTSIDE);
::gluCylinder(m_quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1);
::gluQuadricOrientation(m_quadric, GLU_INSIDE);
::gluDisk(m_quadric, 0.0, 0.75 * size, 36, 1);
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
m_vbo_cone.render();
glsafe(::glPopMatrix());
if (!picking)

View File

@ -19,11 +19,11 @@ class GLGizmoMove3D : public GLGizmoBase
Vec3d m_starting_box_center;
Vec3d m_starting_box_bottom_center;
GLUquadricObj* m_quadric;
GLModel m_vbo_cone;
public:
GLGizmoMove3D(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
virtual ~GLGizmoMove3D();
virtual ~GLGizmoMove3D() = default;
double get_snap_step(double step) const { return m_snap_step; }
void set_snap_step(double step) { m_snap_step = step; }

View File

@ -38,9 +38,6 @@ GLGizmoRotate::GLGizmoRotate(GLCanvas3D& parent, GLGizmoRotate::Axis axis)
, m_snap_fine_in_radius(0.0f)
, m_snap_fine_out_radius(0.0f)
{
m_quadric = ::gluNewQuadric();
if (m_quadric != nullptr)
::gluQuadricDrawStyle(m_quadric, GLU_FILL);
}
GLGizmoRotate::GLGizmoRotate(const GLGizmoRotate& other)
@ -60,11 +57,6 @@ GLGizmoRotate::GLGizmoRotate(const GLGizmoRotate& other)
::gluQuadricDrawStyle(m_quadric, GLU_FILL);
}
GLGizmoRotate::~GLGizmoRotate()
{
if (m_quadric != nullptr)
::gluDeleteQuadric(m_quadric);
}
void GLGizmoRotate::set_angle(double angle)
{
@ -361,20 +353,16 @@ void GLGizmoRotate::render_grabber_extension(const BoundingBoxf3& box, bool pick
glsafe(::glRotated(Geometry::rad2deg(m_angle), 0.0, 0.0, 1.0));
glsafe(::glRotated(90.0, 1.0, 0.0, 0.0));
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
::gluQuadricOrientation(m_quadric, GLU_OUTSIDE);
::gluCylinder(m_quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1);
::gluQuadricOrientation(m_quadric, GLU_INSIDE);
::gluDisk(m_quadric, 0.0, 0.75 * size, 36, 1);
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
VBOCone.render();
glsafe(::glPopMatrix());
glsafe(::glPushMatrix());
glsafe(::glTranslated(m_grabbers[0].center(0), m_grabbers[0].center(1), m_grabbers[0].center(2)));
glsafe(::glRotated(Geometry::rad2deg(m_angle), 0.0, 0.0, 1.0));
glsafe(::glRotated(-90.0, 1.0, 0.0, 0.0));
glsafe(::glTranslated(0.0, 0.0, 2.0 * size));
::gluQuadricOrientation(m_quadric, GLU_OUTSIDE);
::gluCylinder(m_quadric, 0.75 * size, 0.0, 3.0 * size, 36, 1);
::gluQuadricOrientation(m_quadric, GLU_INSIDE);
::gluDisk(m_quadric, 0.0, 0.75 * size, 36, 1);
glsafe(::glScaled(0.75 * size, 0.75 * size, 3.0 * size));
VBOCone.render();
glsafe(::glPopMatrix());
if (!picking)

View File

@ -32,8 +32,6 @@ private:
Axis m_axis;
double m_angle;
GLUquadricObj* m_quadric;
mutable Vec3d m_center;
mutable float m_radius;
@ -45,7 +43,7 @@ private:
public:
GLGizmoRotate(GLCanvas3D& parent, Axis axis);
GLGizmoRotate(const GLGizmoRotate& other);
virtual ~GLGizmoRotate();
virtual ~GLGizmoRotate() = default;
double get_angle() const { return m_angle; }
void set_angle(double angle);

View File

@ -26,20 +26,9 @@ namespace GUI {
GLGizmoSlaSupports::GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id)
: GLGizmoBase(parent, icon_filename, sprite_id)
, m_quadric(nullptr)
{
m_quadric = ::gluNewQuadric();
if (m_quadric != nullptr)
// using GLU_FILL does not work when the instance's transformation
// contains mirroring (normals are reverted)
::gluQuadricDrawStyle(m_quadric, GLU_FILL);
{
}
GLGizmoSlaSupports::~GLGizmoSlaSupports()
{
if (m_quadric != nullptr)
::gluDeleteQuadric(m_quadric);
}
bool GLGizmoSlaSupports::on_init()
{
@ -100,7 +89,7 @@ void GLGizmoSlaSupports::on_render() const
glsafe(::glEnable(GL_BLEND));
glsafe(::glEnable(GL_DEPTH_TEST));
if (m_quadric != nullptr && selection.is_from_single_instance())
if (selection.is_from_single_instance())
render_points(selection, false);
m_selection_rectangle.render(m_parent);
@ -114,14 +103,25 @@ void GLGizmoSlaSupports::on_render() const
void GLGizmoSlaSupports::on_render_for_picking() const
{
const Selection& selection = m_parent.get_selection();
glsafe(::glEnable(GL_DEPTH_TEST));
//glsafe(::glEnable(GL_DEPTH_TEST));
render_points(selection, true);
}
void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking) const
{
if (!picking)
glsafe(::glEnable(GL_LIGHTING));
size_t cache_size = m_editing_mode ? m_editing_cache.size() : m_normal_cache.size();
bool has_points = (cache_size != 0);
bool has_holes = (! m_c->hollowed_mesh()->get_hollowed_mesh()
&& ! m_c->selection_info()->model_object()->sla_drain_holes.empty());
if (! has_points && ! has_holes)
return;
GLShaderProgram* shader = picking ? nullptr : wxGetApp().get_shader("gouraud_light");
if (shader)
shader->start_using();
ScopeGuard guard([shader]() { if (shader) shader->stop_using(); });
const GLVolume* vol = selection.get_volume(*selection.get_volume_idxs().begin());
const Transform3d& instance_scaling_matrix_inverse = vol->get_instance_transformation().get_matrix(true, true, false, true).inverse();
@ -132,8 +132,7 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
glsafe(::glTranslated(0.0, 0.0, z_shift));
glsafe(::glMultMatrixd(instance_matrix.data()));
float render_color[4];
size_t cache_size = m_editing_mode ? m_editing_cache.size() : m_normal_cache.size();
std::array<float, 4> render_color;
for (size_t i = 0; i < cache_size; ++i)
{
const sla::SupportPoint& support_point = m_editing_mode ? m_editing_cache[i].support_point : m_normal_cache[i];
@ -143,34 +142,31 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
continue;
// First decide about the color of the point.
if (picking) {
std::array<float, 4> color = picking_color_component(i);
render_color[0] = color[0];
render_color[1] = color[1];
render_color[2] = color[2];
render_color[3] = color[3];
}
if (picking)
render_color = picking_color_component(i);
else {
render_color[3] = 1.f;
if ((size_t(m_hover_id) == i && m_editing_mode)) { // ignore hover state unless editing mode is active
render_color[0] = 0.f;
render_color[1] = 1.0f;
render_color[2] = 1.0f;
}
if ((size_t(m_hover_id) == i && m_editing_mode)) // ignore hover state unless editing mode is active
render_color = { 0.f, 1.f, 1.f, 1.f };
else { // neigher hover nor picking
bool supports_new_island = m_lock_unique_islands && support_point.is_new_island;
if (m_editing_mode) {
render_color[0] = point_selected ? 1.0f : (supports_new_island ? 0.3f : 0.7f);
render_color[1] = point_selected ? 0.3f : (supports_new_island ? 0.3f : 0.7f);
render_color[2] = point_selected ? 0.3f : (supports_new_island ? 1.0f : 0.7f);
if (point_selected)
render_color = { 1.f, 0.3f, 0.3f, 1.f};
else
if (supports_new_island)
render_color = { 0.3f, 0.3f, 1.f, 1.f };
else
render_color = { 0.7f, 0.7f, 0.7f, 1.f };
}
else
for (unsigned char i=0; i<3; ++i) render_color[i] = 0.5f;
render_color = { 0.5f, 0.5f, 0.5f, 1.f };
}
}
glsafe(::glColor4fv(render_color));
float render_color_emissive[4] = { 0.5f * render_color[0], 0.5f * render_color[1], 0.5f * render_color[2], 1.f};
glsafe(::glMaterialfv(GL_FRONT, GL_EMISSION, render_color_emissive));
if (shader && ! picking)
shader->set_uniform("uniform_color", render_color);
else // picking
glsafe(::glColor4fv(render_color.data()));
// Inverse matrix of the instance scaling is applied so that the mark does not scale with the object.
glsafe(::glPushMatrix());
@ -195,33 +191,36 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
const double cone_radius = 0.25; // mm
const double cone_height = 0.75;
glsafe(::glPushMatrix());
glsafe(::glTranslatef(0.f, 0.f, support_point.head_front_radius * RenderPointScale));
::gluCylinder(m_quadric, 0., cone_radius, cone_height, 24, 1);
glsafe(::glTranslatef(0.f, 0.f, cone_height + support_point.head_front_radius * RenderPointScale));
glsafe(::glPushMatrix());
glsafe(::glRotated(180., 1., 0., 0.));
glsafe(::glScaled(cone_radius, cone_radius, cone_height));
VBOCone.render();
glsafe(::glPopMatrix());
glsafe(::glTranslatef(0.f, 0.f, cone_height));
::gluDisk(m_quadric, 0.0, cone_radius, 24, 1);
glsafe(::glPopMatrix());
}
::gluSphere(m_quadric, (double)support_point.head_front_radius * RenderPointScale, 24, 12);
glsafe(::glPushMatrix());
double radius = (double)support_point.head_front_radius * RenderPointScale;
glsafe(::glScaled(radius, radius, radius));
VBOSphere.render();
glsafe(::glPopMatrix());
if (vol->is_left_handed())
glFrontFace(GL_CCW);
glsafe(::glPopMatrix());
}
{
// Reset emissive component to zero (the default value)
float render_color_emissive[4] = { 0.f, 0.f, 0.f, 1.f };
glsafe(::glMaterialfv(GL_FRONT, GL_EMISSION, render_color_emissive));
}
// Now render the drain holes:
//if (! m_c->has_drilled_mesh()) {
if (! m_c->hollowed_mesh()->get_hollowed_mesh()) {
if (has_holes && ! picking) {
render_color[0] = 0.7f;
render_color[1] = 0.7f;
render_color[2] = 0.7f;
render_color[3] = 0.7f;
glsafe(::glColor4fv(render_color));
if (shader)
shader->set_uniform("uniform_color", render_color);
for (const sla::DrainHole& drain_hole : m_c->selection_info()->model_object()->sla_drain_holes) {
if (is_mesh_point_clipped(drain_hole.pos.cast<double>()))
continue;
@ -242,12 +241,8 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
glsafe(::glRotated(aa.angle() * (180. / M_PI), aa.axis()(0), aa.axis()(1), aa.axis()(2)));
glsafe(::glPushMatrix());
glsafe(::glTranslated(0., 0., -drain_hole.height));
::gluCylinder(m_quadric, drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength, 24, 1);
glsafe(::glTranslated(0., 0., drain_hole.height + sla::HoleStickOutLength));
::gluDisk(m_quadric, 0.0, drain_hole.radius, 24, 1);
glsafe(::glTranslated(0., 0., -drain_hole.height - sla::HoleStickOutLength));
glsafe(::glRotatef(180.f, 1.f, 0.f, 0.f));
::gluDisk(m_quadric, 0.0, drain_hole.radius, 24, 1);
glsafe(::glScaled(drain_hole.radius, drain_hole.radius, drain_hole.height + sla::HoleStickOutLength));
VBOCylinder.render();
glsafe(::glPopMatrix());
if (vol->is_left_handed())
@ -256,9 +251,6 @@ void GLGizmoSlaSupports::render_points(const Selection& selection, bool picking)
}
}
if (!picking)
glsafe(::glDisable(GL_LIGHTING));
glsafe(::glPopMatrix());
}

View File

@ -27,8 +27,6 @@ private:
const float RenderPointScale = 1.f;
GLUquadricObj* m_quadric;
class CacheEntry {
public:
CacheEntry() :
@ -58,7 +56,7 @@ private:
public:
GLGizmoSlaSupports(GLCanvas3D& parent, const std::string& icon_filename, unsigned int sprite_id);
~GLGizmoSlaSupports() override;
virtual ~GLGizmoSlaSupports() = default;
void set_sla_support_data(ModelObject* model_object, const Selection& selection);
bool gizmo_event(SLAGizmoEventType action, const Vec2d& mouse_position, bool shift_down, bool alt_down, bool control_down);
void delete_selected_points(bool force = false);