Skip to content
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

[WIP] Introduce fast mouse polling for lower lag interpolation #1194

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

mikeday0
Copy link
Collaborator

@mikeday0 mikeday0 commented Apr 2, 2024

This is my humble attempt to port to Crispy the fine work that @ceski-1 did for Woof. It's not ready yet but I thought it might be prudent to go ahead and get it out there for early review and testing.

mikeday0 and others added 2 commits April 2, 2024 14:47
Co-authored-by: ceski <56656010+ceski-1@users.noreply.github.com>
Co-authored-by: ceski <56656010+ceski-1@users.noreply.github.com>
@ceski-1
Copy link
Collaborator

ceski-1 commented Apr 3, 2024

Nice starting point, I tested it briefly. Some issues I noticed:

  • Mouselook and mousevert feel off (compare capped and uncapped).
  • Combining keyboard turning and mouse turning at the same time has visual glitches (occasional "pops").
  • The "mouse threshold" concept in Chocolate/Crispy/Woof assumes each update is a tic in duration (1/35th of a second). So it doesn't work correctly with fast polling and the mouse will feel "slow" at higher fps. I sidestep the issue in Woof by ignoring threshold under certain conditions.
  • If you follow the mouse input calculations from start to finish, you'll notice that Crispy has rounding error in several stages. First there's AccelerateMouse() in I_ReadMouse(), then there's *(mouseSensitivity+5)/10 in G_Responder() or G_FastResponder(). By the time the error accumulator runs ("carrying" the error), it's too late and ineffective. I prevent this in Woof by doing the calculations as a single step and using doubles as working variables (see CalcMouseAngle() for example). The rounding only occurs once, in the carry function.

I'll try to give more feedback later, I know it's WIP right now.

@mikeday0
Copy link
Collaborator Author

mikeday0 commented Apr 3, 2024

  • Combining keyboard turning and mouse turning at the same time has visual glitches (occasional "pops").

I can repeat this. It appears to be fixed on my end by moving the fractionaltic update back to the end of I_FinishUpdate().

Diff
diff --git a/src/i_video.c b/src/i_video.c
index ab3c7bc9..b5f9f6f1 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -544,9 +544,6 @@ void I_StartDisplay(void) // [crispy]
 {
     SDL_PumpEvents();
 
-    // [AM] Figure out how far into the current tic we're in as a fixed_t.
-    fractionaltic = I_GetFracRealTime();
-
     if (usemouse && !nomouse && window_focused)
     {
         I_ReadMouseUncapped();
@@ -941,6 +938,9 @@ void I_FinishUpdate (void)
                 }
             }
         }
+        // [AM] Figure out how far into the current tic we're in as a fixed_t.
+        fractionaltic = I_GetFracRealTime();
+
     }
 
     // Restore background and undo the disk indicator, if it was drawn.

Does this fix the "pops" for you?

@ceski-1
Copy link
Collaborator

ceski-1 commented Apr 4, 2024

Does this fix the "pops" for you?

That seems to work fine, or like Woof:

Diff (Alt)
diff --git a/src/i_video.c b/src/i_video.c
index ab3c7bc9..328e6b1e 100644
--- a/src/i_video.c
+++ b/src/i_video.c
@@ -542,11 +542,11 @@ void I_StartTic (void)
 
 void I_StartDisplay(void) // [crispy]
 {
-    SDL_PumpEvents();
-
     // [AM] Figure out how far into the current tic we're in as a fixed_t.
     fractionaltic = I_GetFracRealTime();
 
+    SDL_PumpEvents();
+
     if (usemouse && !nomouse && window_focused)
     {
         I_ReadMouseUncapped();

mikeday0 and others added 9 commits April 13, 2024 09:01
Fixes random "pops" when turning using keyboard.

Co-authored-by: ceski <56656010+ceski-1@users.noreply.github.com>
When running uncapped, track last gametic's worth (28 ms) of mouse
movement to determine if acceleration should be applied.
* Apply mouse acceleration in g_game.
* Expand carry_t to include side and vertical movement.

Co-authored-by: ceski <56656010+ceski-1@users.noreply.github.com>
Co-authored-by: ceski <56656010+ceski-1@users.noreply.github.com>
Co-authored-by: ceski <56656010+ceski-1@users.noreply.github.com>
Co-authored-by: ceski <56656010+ceski-1@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants