Skip to content

Commit

Permalink
Merge pull request #1739 from zenustech/revert-1734-revert-1729-camer…
Browse files Browse the repository at this point in the history
…a-move

camera-move
  • Loading branch information
teachmain authored Jan 22, 2024
2 parents d52e957 + 4ae9ead commit dc6e93d
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion ui/zenoedit/viewport/cameracontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,24 @@ void CameraControl::fakeMouseMoveEvent(QMouseEvent *event)
}
}

if (!bTransform && (event->buttons() & (rotateButton | moveButton))) {
if (!bTransform && ctrl_pressed && (event->buttons() & Qt::MiddleButton)) {
float ratio = QApplication::desktop()->devicePixelRatio();
float dx = xpos - m_lastMidButtonPos.x(), dy = ypos - m_lastMidButtonPos.y();
dx *= ratio / m_res[0];
dy *= ratio / m_res[1];
float cos_t = cos(getTheta());
float sin_t = sin(getTheta());
float cos_p = cos(getPhi());
float sin_p = sin(getPhi());
QVector3D back(cos_t * sin_p, sin_t, -cos_t * cos_p);
QVector3D delta = -back * dy;
auto c = getCenter();
QVector3D center = {c[0], c[1], c[2]};
center += delta * getRadius();
setCenter({float(center.x()), float(center.y()), float(center.z())});
m_lastMidButtonPos = QPointF(xpos, ypos);
}
else if (!bTransform && (event->buttons() & (rotateButton | moveButton))) {
float ratio = QApplication::desktop()->devicePixelRatio();
float dx = xpos - m_lastMidButtonPos.x(), dy = ypos - m_lastMidButtonPos.y();
dx *= ratio / m_res[0];
Expand Down

0 comments on commit dc6e93d

Please sign in to comment.