9front - general discussion about 9front
 help / color / mirror / Atom feed
* doom: fix glitchy mouse movement
@ 2016-06-30 18:07 qwx
  0 siblings, 0 replies; only message in thread
From: qwx @ 2016-06-30 18:07 UTC (permalink / raw)
  To: 9front

doom: fix glitchy mouse movement

mousex and mousey in g_game.c are mouse x and y deltas during a single tic.
G_Responder can be called multiple times per tics with new mouse deltas from
mouseproc. these must then be added rather than overwritten.
in mouseproc, remove multiplication by 10 for no reason (carried over x11
differences?).

these errors make the camera abruptly jump to the final angle rather than
turn smoothly. the effect is worse on terminals with fast terminals with fast
draw speeds (where the game draws very smoothly).

to easily test:
- try to increase ingame frames per second as much as possible: use a terminal
  with a good drawing speed, disable sound (unmount '#A' or /dev/audio for
  mixfs), etc.
- increase doom's mouse acceleration setting
then, while ingame, move the camera continuously and smoothly along the
horizontal axis. without the patch, the camera jumps around, especially on
wider motions. (trackpoints: beware of negative inertia)

diff -r 0a3cf47fce65 sys/src/games/doom/g_game.c
--- a/sys/src/games/doom/g_game.c	Mon Jun 27 00:36:54 2016 +0200
+++ b/sys/src/games/doom/g_game.c	Thu Jun 30 16:56:34 2016 +0300
@@ -566,8 +566,8 @@
 	mousebuttons[0] = ev->data1 & 1; 
 	mousebuttons[1] = ev->data1 & 2; 
 	mousebuttons[2] = ev->data1 & 4; 
-	mousex = ev->data2*(mouseSensitivity+5)/10; 
-	mousey = ev->data3*(mouseSensitivity+5)/10; 
+	mousex += ev->data2*(mouseSensitivity+5)/10;
+	mousey += ev->data3*(mouseSensitivity+5)/10;
 	return true;    // eat events 
  
       case ev_joystick: 
diff -r 0a3cf47fce65 sys/src/games/doom/i_video.c
--- a/sys/src/games/doom/i_video.c	Mon Jun 27 00:36:54 2016 +0200
+++ b/sys/src/games/doom/i_video.c	Thu Jun 30 16:56:34 2016 +0300
@@ -360,8 +360,8 @@
 			
 			e.type = ev_mouse;
 			e.data1 = m.buttons;
-			e.data2 = 10*(m.xy.x - om.xy.x);
-			e.data3 = 10*(om.xy.y - m.xy.y);
+			e.data2 = m.xy.x - om.xy.x;
+			e.data3 = om.xy.y - m.xy.y;
 			D_PostEvent(&e);
 			om = m;
 


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-06-30 15:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-30 18:07 doom: fix glitchy mouse movement qwx

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).