-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix initial GetMouseDelta on GLFW #4663
Conversation
This fixes #4654 |
cada094
to
958952f
Compare
The initial mouse delta is often very large, depending on where the cursor was before the window opened. This is because the first mouse delta is the x/y coordinates your cursor entered the screen from. This can (and often does) cause the free camera to make a sudden jump when its moved for the first time. The solution to this is to initialize the previousPosition and the currentPosition to the same value on the first mouse input, essentially ignoring the first mouse delta.
@asdqwe Mouse start position OUTSIDE the area where window will be created:
Mouse start position INSIDE the area where window will be created:
This is with me positioning my cursor, running your code, and moving my cursor slightly. Then I strip off the excess zero deltas. I'm assuming that's how you're running it as well. |
Am I supposed to see that delta on the second frame without any mouse input? The first two frames always have a delta of I.E.
If you need any info on platform differences let me know and I'll try and provide any info I can. Currently I'm building your test code by adding it to the
|
Here's what I'm seeing: https://www.youtube.com/watch?v=rXTMOdLJj6A |
@@ -1873,6 +1873,13 @@ static void MouseCursorPosCallback(GLFWwindow *window, double x, double y) | |||
CORE.Input.Mouse.currentPosition.y = (float)y; | |||
CORE.Input.Touch.position[0] = CORE.Input.Mouse.currentPosition; | |||
|
|||
static bool firstMouseInput = true; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the most horrible things I've seen in some time. I'm afraid I'm not adding this dirty hack to raylib... just for macOS!!! 😱
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for clarification, does it happen with other platforms?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As said in the other thread, this issue is not limited to macOS. I'm seeing the same issue on Linux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for clarification, still thinking it should be addressed at GLFW level.
If the issue is related to GLFW, it should be addressed by GLFW, not hacked in raylib. |
The initial mouse delta is often very large, depending on where the cursor was before the window opened. This is because the first mouse delta is the x/y coordinates your cursor entered the screen from. This can (and often does) cause the free camera to make a sudden jump when its moved for the first time.
The solution to this is to initialize the previousPosition and the currentPosition to the same value on the first mouse input, essentially ignoring the first mouse delta.