Open PierrickKoch opened 6 years ago
You probably want to report that upstream...
of course :) I will when I find time to reproduce it with minimal example, I'll keep track of any update here
here is a workaround, I'll open PR soon
diff --git a/src/morse/blender/view_camera.py b/src/morse/blender/view_camera.py
index da36f619..1e7c43db 100644
--- a/src/morse/blender/view_camera.py
+++ b/src/morse/blender/view_camera.py
@@ -18,6 +18,7 @@ from morse.core import blenderapi
start_position = []
start_orientation = []
keyboard_ctrl_objects = []
+last_mouse_pose = None
robots = []
current_robot = 0
@@ -164,49 +165,36 @@ def rotate(contr):
# Hide the cursor while we control the camera
mouse_visible = False
if mouse.positive:
- # get width and height of game window
- width = blenderapi.render().getWindowWidth()
- height = blenderapi.render().getWindowHeight()
-
# get mouse movement from function
- move = mouse_move(camera, mouse, width, height)
-
+ move = mouse_move(mouse)
# set mouse sensitivity
sensitivity = camera['Sensitivity']
-
# Amount, direction and sensitivity
leftRight = move[0] * sensitivity
upDown = move[1] * sensitivity
-
# set the values
camera.applyRotation( [0.0, 0.0, leftRight], 0 )
camera.applyRotation( [upDown, 0.0, 0.0], 1 )
- # Center mouse in game window
- # Using the '//' operator (floor division) to produce an integer result
- blenderapi.render().setMousePosition(width//2, height//2)
-
# Set the cursor visibility
blenderapi.mousepointer(visible = mouse_visible)
+ if mouse_visible:
+ global last_mouse_pose
+ last_mouse_pose = None
-def mouse_move(camera, mouse, width, height):
- """ Get the movement of the mouse as an X, Y coordinate. """
- # distance moved from screen center
- # Using the '//' operator (floor division) to produce an integer result
- x = width//2 - mouse.position[0]
- y = height//2 - mouse.position[1]
-
- # intialize mouse so it doesn't jerk first time
- try:
- camera['mouseInit']
- except KeyError:
- x = 0
- y = 0
- # bug in Add Property
- # can't use True. Have to use 1
- camera['mouseInit'] = 1
+def mouse_move(mouse):
+ """ Get the movement of the mouse as an X, Y coordinate. """
+ global last_mouse_pose
+ if not last_mouse_pose:
+ # intialize mouse so it doesn't jerk first time
+ last_mouse_pose = mouse.position
+ return 0, 0
+
+ # distance moved from last pose
+ x = last_mouse_pose[0] - mouse.position[0]
+ y = last_mouse_pose[1] - mouse.position[1]
logger.debug("Read displacement: %s, %s" % (x, y))
-
+ last_mouse_pose = mouse.position
# return mouse movement
return x, y
Here is the ticket on d.b.o : https://developer.blender.org/T54238
in
src/morse/blender/view_camera.py
setMousePosition does not work on Wayland (Fedora 26)
Result in unusable FPS view (using left CTRL)