Flip X mouse deltas if bed is upside down (when camera up vector has negative Z)

This commit is contained in:
Enrico Turri 2019-04-30 15:09:25 +02:00
parent 646986348a
commit 3a5485a179
3 changed files with 7 additions and 1 deletions

View File

@ -25,6 +25,7 @@ Camera::Camera()
, phi(45.0f)
// , distance(0.0f)
, requires_zoom_to_bed(false)
, inverted_phi(false)
, m_theta(45.0f)
, m_target(Vec3d::Zero())
{

View File

@ -22,6 +22,7 @@ struct Camera
float phi;
// float distance;
bool requires_zoom_to_bed;
bool inverted_phi;
private:
Vec3d m_target;

View File

@ -2729,7 +2729,8 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
if ((m_hover_volume_id == -1) && m_mouse.is_start_position_3D_defined())
{
const Vec3d& orig = m_mouse.drag.start_position_3D;
m_camera.phi += (((float)pos(0) - (float)orig(0)) * TRACKBALLSIZE);
float sign = m_camera.inverted_phi ? -1.0f : 1.0f;
m_camera.phi += sign * ((float)pos(0) - (float)orig(0)) * TRACKBALLSIZE;
m_camera.set_theta(m_camera.get_theta() - ((float)pos(1) - (float)orig(1)) * TRACKBALLSIZE, wxGetApp().preset_bundle->printers.get_edited_preset().printer_technology() != ptSLA);
m_dirty = true;
}
@ -2781,6 +2782,9 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
post_event(SimpleEvent(EVT_GLCANVAS_OBJECT_SELECT));
}
}
else if (evt.LeftUp() && m_mouse.dragging)
// Flips X mouse deltas if bed is upside down
m_camera.inverted_phi = (m_camera.get_dir_up()(2) < 0.0);
else if (evt.RightUp())
{
m_mouse.position = pos.cast<double>();