SpectralVectors / RightMouseNavigation

Game Engine-style Right Mouse Viewport Navigation
GNU General Public License v3.0
221 stars 18 forks source link

Mouse doesn't center on screen after navigation #14

Closed NathanC closed 2 years ago

NathanC commented 2 years ago

First off, great plugin, I was considering creating a similar one! I had bound navigation to the center button, but it was toggle not click, and you had to press left mouse button to exit.

Anyhow, after navigating and releasing the right mouse button, the cursor seems to snap back to where it was when right mouse button was initally clicked. This is jarring, and difficult to use, since Unity and the default Blender fly navigation exits with the mouse at the center of the screen (where the navigation cross-hair is).

Is there any way to change this behavior?

NathanC commented 2 years ago

I looked through the code, and see where it reset the cursor (viewport cursor and windows cursor). I commented out both lines, and imported the forked plugin. It works like a charm, mouse is now centered!

# Reset blender window cursor to previous position
# context.window.cursor_warp(self.view_x, self.view_y)
# Reset Windows OS cursor to previous position
# ctypes.windll.user32.SetCursorPos(self.mouse_x, self.mouse_y)

Since you explicitly added those calls to reset the cursor, I presume you like that behavior. How would you feel about me opening a PR for a config option for changing that behavior, so the user can choose?

I'd argue that centering after navigation should be the default behavior, but the default behavior could stay the same if you'd prefer.

SpectralVectors commented 2 years ago

Yes, what you describe is the original behavior which was changed for the same reason you are suggesting, because users found it jarring to have their cursor snapped to the center of the screen after each move operation.

If you want to add a setting (BoolProperty) to the addon preferences I'll merge it in, that way everybody's happy.

Thanks!