fix: Restore camera rotation and stabilize UI element scaling
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -87,17 +87,7 @@ void Camera::wheelEvent(QWheelEvent* event, const QVector3D& worldPos)
|
||||
QMatrix4x4 Camera::modelViewMatrix() const
|
||||
{
|
||||
QMatrix4x4 model;
|
||||
float effectiveZoom = m_zoom;
|
||||
|
||||
if (m_isRotating) {
|
||||
QMatrix4x4 rotation;
|
||||
rotation.rotate(m_xRot / 16.0f, 1, 0, 0);
|
||||
rotation.rotate(m_yRot / 16.0f, 0, 1, 0);
|
||||
QVector3D p_rotated = rotation.map(m_rotationPivot);
|
||||
effectiveZoom += (p_rotated - m_rotationPivot).z();
|
||||
}
|
||||
|
||||
model.translate(m_panX, m_panY, effectiveZoom);
|
||||
model.translate(m_panX, m_panY, m_zoom);
|
||||
|
||||
if (m_isRotating) {
|
||||
model.translate(m_rotationPivot);
|
||||
@@ -237,6 +227,7 @@ void Camera::animateToPlaneView(int plane)
|
||||
void Camera::startRotation(const QVector3D& pivot)
|
||||
{
|
||||
m_rotationPivot = pivot;
|
||||
m_stableZoom = m_zoom;
|
||||
|
||||
QMatrix4x4 rotation;
|
||||
rotation.rotate(m_xRot / 16.0f, 1, 0, 0);
|
||||
@@ -247,6 +238,7 @@ void Camera::startRotation(const QVector3D& pivot)
|
||||
|
||||
setPanX(m_panX + p_diff.x());
|
||||
setPanY(m_panY + p_diff.y());
|
||||
setZoom(m_zoom + p_diff.z());
|
||||
|
||||
m_isRotating = true;
|
||||
}
|
||||
@@ -266,6 +258,7 @@ void Camera::stopRotation()
|
||||
|
||||
setPanX(m_panX - p_diff.x());
|
||||
setPanY(m_panY - p_diff.y());
|
||||
setZoom(m_zoom - p_diff.z());
|
||||
|
||||
m_isRotating = false;
|
||||
}
|
||||
@@ -313,3 +306,11 @@ void Camera::animateRestoreState()
|
||||
|
||||
animGroup->start(QAbstractAnimation::DeleteWhenStopped);
|
||||
}
|
||||
|
||||
float Camera::uiCameraDistance() const
|
||||
{
|
||||
if (m_isRotating) {
|
||||
return m_stableZoom;
|
||||
}
|
||||
return m_zoom;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user