Skip to content

Commit 69ea5b8

Browse files
fabien servantcbentejac
authored andcommitted
[qt6][Viewer3D] Fix mouse camera controller
1 parent 65a014d commit 69ea5b8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

meshroom/ui/qml/Viewer3D/DefaultCameraController.qml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@ Entity {
1414
property real translateSpeed: 75.0
1515
property real tiltSpeed: 500.0
1616
property real panSpeed: 500.0
17-
readonly property bool moving: actionLMB.active
18-
readonly property bool panning: (keyboardHandler._pressed && actionLMB.active && actionShift.active) || actionMMB.active
19-
readonly property bool zooming: keyboardHandler._pressed && actionRMB.active && actionAlt.active
2017
property alias focus: keyboardHandler.focus
2118
readonly property bool pickingActive: actionControl.active && keyboardHandler._pressed
2219
property alias rotationSpeed: trackball.rotationSpeed
@@ -25,6 +22,10 @@ Entity {
2522

2623
property bool loseMouseFocus: false // Must be changed by other entities when they want to take mouse focus
2724

25+
property bool moving: false
26+
property bool panning: false
27+
property bool zooming: false
28+
2829
readonly property alias pressed: mouseHandler._pressed
2930
signal mousePressed(var mouse)
3031
signal mouseReleased(var mouse, var moved)
@@ -68,15 +69,20 @@ Entity {
6869
const dt = 0.02
6970
var d
7071

71-
if (panning) { // Translate
72+
root.moving = mouse.buttons & Qt.LeftButton
73+
root.panning = (mouse.buttons & Qt.MiddleButton)
74+
var panningAlt = actionShift.active && (mouse.buttons & Qt.LeftButton)
75+
root.zooming = actionAlt.active && (mouse.buttons & Qt.RightButton)
76+
77+
if (panning || panningAlt) { // Translate
7278
d = (root.camera.viewCenter.minus(root.camera.position)).length() * 0.03
7379
var tx = axisMX.value * root.translateSpeed * d
7480
var ty = axisMY.value * root.translateSpeed * d
7581
mouseHandler.hasMoved = true
7682
root.camera.translate(Qt.vector3d(-tx, -ty, 0).times(dt))
7783
return
7884
}
79-
if (moving){ // Trackball rotation
85+
if (moving) { // Trackball rotation
8086
trackball.rotate(mouseHandler.lastPosition, mouseHandler.currentPosition, dt)
8187
mouseHandler.lastPosition = mouseHandler.currentPosition
8288
mouseHandler.hasMoved = true

0 commit comments

Comments
 (0)