From a468078df3d4f82d22c2f542de9c7e2999cec4c0 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Thu, 15 Nov 2018 10:16:51 +0100 Subject: [PATCH] Fixed length of grabbers for rotate 3D gizmo --- src/slic3r/GUI/GLGizmo.cpp | 16 ++++++++++++---- src/slic3r/GUI/GLGizmo.hpp | 3 +++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/slic3r/GUI/GLGizmo.cpp b/src/slic3r/GUI/GLGizmo.cpp index c2e373452..c2e124b43 100644 --- a/src/slic3r/GUI/GLGizmo.cpp +++ b/src/slic3r/GUI/GLGizmo.cpp @@ -56,10 +56,19 @@ void GLGizmoBase::Grabber::render(bool hover, float size) const render(size, render_color, true); } +float GLGizmoBase::Grabber::get_half_size(float size) const +{ + return std::max(size * SizeFactor, MinHalfSize); +} + +float GLGizmoBase::Grabber::get_dragging_half_size(float size) const +{ + return std::max(size * SizeFactor * DraggingScaleFactor, MinHalfSize); +} + void GLGizmoBase::Grabber::render(float size, const float* render_color, bool use_lighting) const { - float half_size = dragging ? size * SizeFactor * DraggingScaleFactor : size * SizeFactor; - half_size = std::max(half_size, MinHalfSize); + float half_size = dragging ? get_dragging_half_size(size) : get_half_size(size); if (use_lighting) ::glEnable(GL_LIGHTING); @@ -73,7 +82,6 @@ void GLGizmoBase::Grabber::render(float size, const float* render_color, bool us ::glRotated(Geometry::rad2deg(angles(1)), 0.0, 1.0, 0.0); ::glRotated(Geometry::rad2deg(angles(0)), 1.0, 0.0, 0.0); - // face min x ::glPushMatrix(); ::glTranslatef(-(GLfloat)half_size, 0.0f, 0.0f); @@ -494,7 +502,7 @@ void GLGizmoRotate::render_angle() const void GLGizmoRotate::render_grabber(const BoundingBoxf3& box) const { - double grabber_radius = (double)m_radius * (1.0 + (double)GrabberOffset) + 2.0 * (double)m_axis * box.max_size() * (double)Grabber::SizeFactor; + double grabber_radius = (double)m_radius * (1.0 + (double)GrabberOffset) + 2.0 * (double)m_axis * (double)m_grabbers[0].get_half_size((float)box.max_size()); m_grabbers[0].center = Vec3d(::cos(m_angle) * grabber_radius, ::sin(m_angle) * grabber_radius, 0.0); m_grabbers[0].angles(2) = m_angle; diff --git a/src/slic3r/GUI/GLGizmo.hpp b/src/slic3r/GUI/GLGizmo.hpp index 7156c0b02..f62cdf283 100644 --- a/src/slic3r/GUI/GLGizmo.hpp +++ b/src/slic3r/GUI/GLGizmo.hpp @@ -38,6 +38,9 @@ protected: void render(bool hover, float size) const; void render_for_picking(float size) const { render(size, color, false); } + float get_half_size(float size) const; + float get_dragging_half_size(float size) const; + private: void render(float size, const float* render_color, bool use_lighting) const; void render_face(float half_size) const;