From df4a329a892f8a89134b9d9cd0be12b18bf55453 Mon Sep 17 00:00:00 2001 From: CarlOlson Date: Sun, 28 Aug 2022 14:10:01 +0900 Subject: [PATCH] make model rotation act like Blender and other 3D modelers --- application/sources/model_widget.cc | 3 ++- application/sources/model_widget.h | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/application/sources/model_widget.cc b/application/sources/model_widget.cc index bc19d57d..a44979db 100644 --- a/application/sources/model_widget.cc +++ b/application/sources/model_widget.cc @@ -320,6 +320,7 @@ bool ModelWidget::inputMousePressEventFromOtherWidget(QMouseEvent *event, bool n m_moveStartPos = mapToParent(convertInputPosFromOtherWidget(event)); m_moveStartGeometry = geometry(); m_moveStarted = true; + m_directionOnMoveStart = abs(m_xRot) > 180 * 8 ? -1 : 1; } return true; } @@ -389,7 +390,7 @@ bool ModelWidget::inputMouseMoveEventFromOtherWidget(QMouseEvent *event) } } else { setXRotation(m_xRot + 8 * dy); - setYRotation(m_yRot + 8 * dx); + setYRotation(m_yRot + 8 * dx * m_directionOnMoveStart); } } m_lastPos = pos; diff --git a/application/sources/model_widget.h b/application/sources/model_widget.h index c79477bf..f6c0c624 100644 --- a/application/sources/model_widget.h +++ b/application/sources/model_widget.h @@ -92,6 +92,7 @@ private: int m_xRot = m_defaultXRotation; int m_yRot = m_defaultYRotation; int m_zRot = m_defaultZRotation; + int m_directionOnMoveStart = 0; ModelShaderProgram *m_program = nullptr; bool m_moveStarted = false; bool m_moveEnabled = true;