mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 04:50:42 +00:00
- consolidation of pitch code for aim mode 0.
This commit is contained in:
parent
7ba4e4de97
commit
dc9c8a0e60
6 changed files with 41 additions and 64 deletions
|
@ -231,5 +231,6 @@ void setlocalplayerinput(player_struct *pp);
|
|||
void PlayerColorChanged(void);
|
||||
void nonsharedkeys(void);
|
||||
void apply_seasick(player_struct* p, double scalefactor);
|
||||
void calcviewpitch(player_struct* p, int psectlotag, double factor);
|
||||
|
||||
END_DUKE_NS
|
||||
|
|
|
@ -82,6 +82,40 @@ void setlocalplayerinput(player_struct* pp)
|
|||
pp->weaponswitch = cl_weaponswitch;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
// calculates automatic view pitch for playing without a mouse
|
||||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void calcviewpitch(player_struct *p, int psectlotag, double factor)
|
||||
{
|
||||
int psect = p->cursectnum;
|
||||
if (p->aim_mode == 0 && p->on_ground && psectlotag != ST_2_UNDERWATER && (sector[psect].floorstat & 2))
|
||||
{
|
||||
int x = p->posx + (sintable[(p->getang() + 512) & 2047] >> 5);
|
||||
int y = p->posy + (sintable[p->getang() & 2047] >> 5);
|
||||
short tempsect = psect;
|
||||
updatesector(x, y, &tempsect);
|
||||
|
||||
if (tempsect >= 0)
|
||||
{
|
||||
int k = getflorzofslope(psect, x, y);
|
||||
if (psect == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))
|
||||
p->addhorizoff(factor * mulscale16(p->truefz - k, 160));
|
||||
}
|
||||
}
|
||||
if (p->q16horizoff > 0)
|
||||
{
|
||||
p->addhorizoff(-factor * fix16_to_dbl((p->q16horizoff >> 3) + FRACUNIT));
|
||||
if (p->q16horizoff < 0) p->q16horizoff = 0;
|
||||
}
|
||||
else if (p->q16horizoff < 0)
|
||||
{
|
||||
p->addhorizoff(-factor * fix16_to_dbl((p->q16horizoff >> 3) + FRACUNIT));
|
||||
if (p->q16horizoff > 0) p->q16horizoff = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
//
|
||||
|
|
|
@ -2645,23 +2645,7 @@ void processinput_d(int snum)
|
|||
{
|
||||
p->oq16horiz = p->q16horiz;
|
||||
p->oq16horizoff = p->q16horizoff;
|
||||
|
||||
if (p->aim_mode == 0 && p->on_ground && psectlotag != ST_2_UNDERWATER && (sector[psect].floorstat & 2))
|
||||
{
|
||||
int x = p->posx + (sintable[(p->getang() + 512) & 2047] >> 5);
|
||||
int y = p->posy + (sintable[p->getang() & 2047] >> 5);
|
||||
short tempsect = psect;
|
||||
updatesector(x, y, &tempsect);
|
||||
|
||||
if (tempsect >= 0)
|
||||
{
|
||||
k = getflorzofslope(psect, x, y);
|
||||
if (psect == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))
|
||||
p->addhorizoff(mulscale16(j - k, 160));
|
||||
}
|
||||
}
|
||||
if (p->q16horizoff > 0) p->q16horizoff -= ((p->q16horizoff >> 3) + FRACUNIT);
|
||||
else if (p->q16horizoff < 0) p->q16horizoff += (((-p->q16horizoff) >> 3) + FRACUNIT);
|
||||
calcviewpitch(p, psectlotag, 1);
|
||||
}
|
||||
|
||||
if (hz >= 0 && (hz & 49152) == 49152)
|
||||
|
|
|
@ -3504,23 +3504,7 @@ void processinput_r(int snum)
|
|||
{
|
||||
p->oq16horiz = p->q16horiz;
|
||||
p->oq16horizoff = p->q16horizoff;
|
||||
|
||||
if (p->aim_mode == 0 && p->on_ground && psectlotag != ST_2_UNDERWATER && (sector[psect].floorstat & 2))
|
||||
{
|
||||
int x = p->posx + (sintable[(p->getang() + 512) & 2047] >> 5);
|
||||
int y = p->posy + (sintable[p->getang() & 2047] >> 5);
|
||||
short tempsect = psect;
|
||||
updatesector(x, y, &tempsect);
|
||||
|
||||
if (tempsect >= 0)
|
||||
{
|
||||
k = getflorzofslope(psect, x, y);
|
||||
if (psect == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))
|
||||
p->addhorizoff(mulscale16(j - k, 160));
|
||||
}
|
||||
}
|
||||
if (p->q16horizoff > 0) p->q16horizoff -= ((p->q16horizoff >> 3) + FRACUNIT);
|
||||
else if (p->q16horizoff < 0) p->q16horizoff += (((-p->q16horizoff) >> 3) + FRACUNIT);
|
||||
calcviewpitch(p, psectlotag, 1);
|
||||
}
|
||||
|
||||
if (hz >= 0 && (hz & 49152) == 49152)
|
||||
|
|
|
@ -207,6 +207,7 @@ struct player_struct
|
|||
void setoang(int v) { oq16ang = v << FRACBITS; }
|
||||
void addhoriz(int v) { q16horiz += (v << FRACBITS); }
|
||||
void addhorizoff(int v) { q16horiz += (v << FRACBITS); }
|
||||
void addhorizoff(double v) { q16horiz += int(v * 65536.); }
|
||||
void sethoriz(int v) { q16horiz = (v << FRACBITS); }
|
||||
void sethorizoff(int v) { q16horizoff = (v << FRACBITS); }
|
||||
int gethoriz() { return q16horiz >> FRACBITS; }
|
||||
|
|
|
@ -359,36 +359,9 @@ void P_GetInput(int const playerNum)
|
|||
if (pPlayer->q16horizoff >= F16(-1) && pPlayer->q16horizoff <= F16(1))
|
||||
pPlayer->q16horizoff = 0;
|
||||
}
|
||||
|
||||
// calculates automatic view angle for playing without a mouse
|
||||
if (!pPlayer->aim_mode && pPlayer->on_ground && sectorLotag != ST_2_UNDERWATER && (sector[pPlayer->cursectnum].floorstat & 2))
|
||||
{
|
||||
// this is some kind of horse shit approximation of where the player is looking, I guess?
|
||||
vec2_t const adjustedPosition = { pPlayer->posx + (sintable[(fix16_to_int(pPlayer->q16ang) + 512) & 2047] >> 5),
|
||||
pPlayer->posy + (sintable[fix16_to_int(pPlayer->q16ang) & 2047] >> 5) };
|
||||
int16_t currentSector = pPlayer->cursectnum;
|
||||
|
||||
updatesector(adjustedPosition.x, adjustedPosition.y, ¤tSector);
|
||||
|
||||
if (currentSector >= 0)
|
||||
{
|
||||
int const slopeZ = getflorzofslope(pPlayer->cursectnum, adjustedPosition.x, adjustedPosition.y);
|
||||
if ((pPlayer->cursectnum == currentSector) || (klabs(getflorzofslope(currentSector, adjustedPosition.x, adjustedPosition.y) - slopeZ) <= ZOFFSET6))
|
||||
pPlayer->q16horizoff = fix16_sadd(pPlayer->q16horizoff, fix16_from_dbl(scaleAdjustmentToInterval(mulscale16(pPlayer->truefz - slopeZ, 160))));
|
||||
}
|
||||
}
|
||||
|
||||
if (pPlayer->q16horizoff > 0)
|
||||
{
|
||||
pPlayer->q16horizoff = fix16_ssub(pPlayer->q16horizoff, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl((pPlayer->q16horizoff >> 3) + fix16_one))));
|
||||
pPlayer->q16horizoff = fix16_max(pPlayer->q16horizoff, 0);
|
||||
}
|
||||
else if (pPlayer->q16horizoff < 0)
|
||||
{
|
||||
pPlayer->q16horizoff = fix16_sadd(pPlayer->q16horizoff, fix16_from_dbl(scaleAdjustmentToInterval(fix16_to_dbl((-pPlayer->q16horizoff >> 3) + fix16_one))));
|
||||
pPlayer->q16horizoff = fix16_min(pPlayer->q16horizoff, 0);
|
||||
}
|
||||
|
||||
|
||||
calcviewpitch(pPlayer, sectorLotag, scaleAdjust);
|
||||
|
||||
if (thisPlayer.horizSkew)
|
||||
pPlayer->q16horiz = fix16_sadd(pPlayer->q16horiz, fix16_from_dbl(scaleAdjustmentToInterval(thisPlayer.horizSkew)));
|
||||
|
||||
|
|
Loading…
Reference in a new issue