make model rotation act like Blender and other 3D modelers
parent
914b6955f9
commit
df4a329a89
|
@ -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;
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue