mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-11 07:11:39 +00:00
Improve vertical mouse aim
This improves vertical mouse aim in two ways: the Y axis is normalized to match the sensitivity of the X axis, and horiz adjustment has been corrected so that the player's pitch is operated on as an angle instead of as the tangent of said angle. Based on a patch from Fox. git-svn-id: https://svn.eduke32.com/eduke32@7342 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
eef6667fbc
commit
a3f49b4584
1 changed files with 13 additions and 6 deletions
|
@ -2944,7 +2944,7 @@ void P_GetInput(int const playerNum)
|
|||
else
|
||||
input.q16avel = fix16_div(fix16_from_int(info.dyaw), F16(32));
|
||||
|
||||
input.q16horz = fix16_div(fix16_from_int(info.dpitch), F16(256));
|
||||
input.q16horz = fix16_div(fix16_from_int(info.dpitch), F16(128));
|
||||
|
||||
if (ud.mouseflip) input.q16horz = -input.q16horz;
|
||||
|
||||
|
@ -5362,12 +5362,17 @@ HORIZONLY:;
|
|||
if (VM_OnEvent(EVENT_RETURNTOCENTER,pPlayer->i,playerNum) == 0)
|
||||
pPlayer->return_to_center = 9;
|
||||
|
||||
// A horiz diff of 128 equal 45 degrees,
|
||||
// so we convert horiz to 1024 angle units
|
||||
|
||||
float horizAngle = atan2f(pPlayer->q16horiz - F16(100), F16(128)) * (512.f / PI) + fix16_to_float(g_player[playerNum].inputBits->q16horz);
|
||||
|
||||
if (TEST_SYNC_KEY(playerBits, SK_LOOK_UP))
|
||||
{
|
||||
if (VM_OnEvent(EVENT_LOOKUP,pPlayer->i,playerNum) == 0)
|
||||
{
|
||||
pPlayer->return_to_center = 9;
|
||||
pPlayer->q16horiz += fix16_from_int(12<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||
horizAngle += float(12<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||
centerHoriz++;
|
||||
}
|
||||
}
|
||||
|
@ -5377,7 +5382,7 @@ HORIZONLY:;
|
|||
if (VM_OnEvent(EVENT_LOOKDOWN,pPlayer->i,playerNum) == 0)
|
||||
{
|
||||
pPlayer->return_to_center = 9;
|
||||
pPlayer->q16horiz -= fix16_from_int(12<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||
horizAngle -= float(12<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||
centerHoriz++;
|
||||
}
|
||||
}
|
||||
|
@ -5386,7 +5391,7 @@ HORIZONLY:;
|
|||
{
|
||||
if (VM_OnEvent(EVENT_AIMUP,pPlayer->i,playerNum) == 0)
|
||||
{
|
||||
pPlayer->q16horiz += fix16_from_int(6<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||
horizAngle += float(6<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||
centerHoriz++;
|
||||
}
|
||||
}
|
||||
|
@ -5395,11 +5400,13 @@ HORIZONLY:;
|
|||
{
|
||||
if (VM_OnEvent(EVENT_AIMDOWN,pPlayer->i,playerNum) == 0)
|
||||
{
|
||||
pPlayer->q16horiz -= fix16_from_int(6<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||
horizAngle -= float(6<<(int)(TEST_SYNC_KEY(playerBits, SK_RUN)));
|
||||
centerHoriz++;
|
||||
}
|
||||
}
|
||||
|
||||
pPlayer->q16horiz = F16(100) + F16(128) * tanf(horizAngle * (PI / 512.f));
|
||||
|
||||
if (pPlayer->return_to_center > 0 && !TEST_SYNC_KEY(playerBits, SK_LOOK_UP) && !TEST_SYNC_KEY(playerBits, SK_LOOK_DOWN))
|
||||
{
|
||||
pPlayer->return_to_center--;
|
||||
|
@ -5419,7 +5426,7 @@ HORIZONLY:;
|
|||
if (pPlayer->q16horizoff > F16(-5) && pPlayer->q16horizoff < F16(5)) pPlayer->q16horizoff = 0;
|
||||
}
|
||||
|
||||
pPlayer->q16horiz = fix16_clamp(pPlayer->q16horiz + g_player[playerNum].inputBits->q16horz, F16(HORIZ_MIN), F16(HORIZ_MAX));
|
||||
pPlayer->q16horiz = fix16_clamp(pPlayer->q16horiz, F16(HORIZ_MIN), F16(HORIZ_MAX));
|
||||
|
||||
//Shooting code/changes
|
||||
|
||||
|
|
Loading…
Reference in a new issue