mirror of
https://github.com/ZDoom/Raze.git
synced 2025-03-26 10:44:17 +00:00
- PlayerHorizon::calcviewpitch()
: Provide commentary on how numeric literals used in function came to be and place into an enum for clarity.
This commit is contained in:
parent
1df2ba80ed
commit
0eb4ff4ad2
1 changed files with 14 additions and 2 deletions
|
@ -450,6 +450,18 @@ void PlayerAngle::applyinput(float const avel, ESyncBits* actions, double const
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
enum
|
||||
{
|
||||
// Values used by Duke/SW, where this function originated from.
|
||||
DEFSINSHIFT = 5,
|
||||
DEFVIEWPITCH = 160,
|
||||
|
||||
// Values used by Blood since it calculates differently to Duke/SW.
|
||||
BLOODSINSHIFT = 8,
|
||||
SINSHIFTDELTA = BLOODSINSHIFT - DEFSINSHIFT,
|
||||
BLOODVIEWPITCH = (0x4000 >> SINSHIFTDELTA) - (DEFVIEWPITCH << (SINSHIFTDELTA - 1)), // 1408.
|
||||
};
|
||||
|
||||
void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool const aimmode, bool const canslopetilt, int const cursectnum, double const scaleAdjust, bool const climbing)
|
||||
{
|
||||
if (cl_slopetilting)
|
||||
|
@ -457,7 +469,7 @@ void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool con
|
|||
if (aimmode && canslopetilt) // If the floor is sloped
|
||||
{
|
||||
// Get a point, 512 (64 for Blood) units ahead of player's position
|
||||
int const shift = -(isBlood() ? 8 : 5);
|
||||
int const shift = -(isBlood() ? BLOODSINSHIFT : DEFSINSHIFT);
|
||||
int const x = pos.x + ang.bcos(shift);
|
||||
int const y = pos.y + ang.bsin(shift);
|
||||
int16_t tempsect = cursectnum;
|
||||
|
@ -477,7 +489,7 @@ void PlayerHorizon::calcviewpitch(vec2_t const pos, binangle const ang, bool con
|
|||
// accordingly
|
||||
if (cursectnum == tempsect || (!isBlood() && abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8)))
|
||||
{
|
||||
horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * (!isBlood() ? 160 : 1408))));
|
||||
horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * (!isBlood() ? DEFVIEWPITCH : BLOODVIEWPITCH))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue