make model rotation act like Blender and other 3D modelers

master
CarlOlson 2022-08-28 14:10:01 +09:00 committed by Jeremy HU
parent 914b6955f9
commit df4a329a89
2 changed files with 3 additions and 1 deletions

View File

@ -320,6 +320,7 @@ bool ModelWidget::inputMousePressEventFromOtherWidget(QMouseEvent *event, bool n
m_moveStartPos = mapToParent(convertInputPosFromOtherWidget(event)); m_moveStartPos = mapToParent(convertInputPosFromOtherWidget(event));
m_moveStartGeometry = geometry(); m_moveStartGeometry = geometry();
m_moveStarted = true; m_moveStarted = true;
m_directionOnMoveStart = abs(m_xRot) > 180 * 8 ? -1 : 1;
} }
return true; return true;
} }
@ -389,7 +390,7 @@ bool ModelWidget::inputMouseMoveEventFromOtherWidget(QMouseEvent *event)
} }
} else { } else {
setXRotation(m_xRot + 8 * dy); setXRotation(m_xRot + 8 * dy);
setYRotation(m_yRot + 8 * dx); setYRotation(m_yRot + 8 * dx * m_directionOnMoveStart);
} }
} }
m_lastPos = pos; m_lastPos = pos;

View File

@ -92,6 +92,7 @@ private:
int m_xRot = m_defaultXRotation; int m_xRot = m_defaultXRotation;
int m_yRot = m_defaultYRotation; int m_yRot = m_defaultYRotation;
int m_zRot = m_defaultZRotation; int m_zRot = m_defaultZRotation;
int m_directionOnMoveStart = 0;
ModelShaderProgram *m_program = nullptr; ModelShaderProgram *m_program = nullptr;
bool m_moveStarted = false; bool m_moveStarted = false;
bool m_moveEnabled = true; bool m_moveEnabled = true;