From de06db7989d2753ae8bdc0539a434e1f9482b238 Mon Sep 17 00:00:00 2001 From: Enrico Turri Date: Wed, 6 Mar 2019 12:09:20 +0100 Subject: [PATCH] Allow dragging of objects also along world Z axis in side views --- src/slic3r/GUI/GLCanvas3D.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 19aff8469..9a8b6c469 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5354,11 +5354,14 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt) GLfloat matrix[16]; ::glGetFloatv(GL_MODELVIEW_MATRIX, matrix); Vec3d camera_right((double)matrix[0], (double)matrix[4], (double)matrix[8]); + Vec3d camera_up((double)matrix[1], (double)matrix[5], (double)matrix[9]); - // finds projection of the vector along the camera right axis - double projection = inters_vec.dot(camera_right); + // finds projection of the vector along the camera axes + double projection_x = inters_vec.dot(camera_right); + double projection_z = inters_vec.dot(camera_up); - cur_pos = m_mouse.drag.start_position_3D + projection * camera_right; + // apply offset + cur_pos = m_mouse.drag.start_position_3D + projection_x * camera_right + projection_z * camera_up; } else {