mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-11-10 14:52:01 +00:00
- Duke/SW: Move each game's check of cl_slopetilting
into calcviewpitch()
backend function.
This commit is contained in:
parent
6d12159006
commit
8003753989
3 changed files with 42 additions and 46 deletions
|
@ -378,51 +378,54 @@ void applylook(PlayerAngle* angle, float const avel, ESyncBits* actions, double
|
||||||
|
|
||||||
void calcviewpitch(vec2_t const pos, fixedhoriz* horizoff, binangle const ang, bool const aimmode, bool const canslopetilt, int const cursectnum, double const scaleAdjust, bool const climbing)
|
void calcviewpitch(vec2_t const pos, fixedhoriz* horizoff, binangle const ang, bool const aimmode, bool const canslopetilt, int const cursectnum, double const scaleAdjust, bool const climbing)
|
||||||
{
|
{
|
||||||
if (aimmode && canslopetilt) // If the floor is sloped
|
if (cl_slopetilting)
|
||||||
{
|
{
|
||||||
// Get a point, 512 units ahead of player's position
|
if (aimmode && canslopetilt) // If the floor is sloped
|
||||||
int x = pos.x + ang.bcos(-5);
|
|
||||||
int y = pos.y + ang.bsin(-5);
|
|
||||||
int16_t tempsect = cursectnum;
|
|
||||||
updatesector(x, y, &tempsect);
|
|
||||||
|
|
||||||
if (tempsect >= 0) // If the new point is inside a valid sector...
|
|
||||||
{
|
{
|
||||||
// Get the floorz as if the new (x,y) point was still in
|
// Get a point, 512 units ahead of player's position
|
||||||
// your sector
|
int x = pos.x + ang.bcos(-5);
|
||||||
int j = getflorzofslope(cursectnum, pos.x, pos.y);
|
int y = pos.y + ang.bsin(-5);
|
||||||
int k = getflorzofslope(cursectnum, x, y);
|
int16_t tempsect = cursectnum;
|
||||||
|
updatesector(x, y, &tempsect);
|
||||||
|
|
||||||
// If extended point is in same sector as you or the slopes
|
if (tempsect >= 0) // If the new point is inside a valid sector...
|
||||||
// of the sector of the extended point and your sector match
|
|
||||||
// closely (to avoid accidently looking straight out when
|
|
||||||
// you're at the edge of a sector line) then adjust horizon
|
|
||||||
// accordingly
|
|
||||||
if (cursectnum == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))
|
|
||||||
{
|
{
|
||||||
*horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * 160)));
|
// Get the floorz as if the new (x,y) point was still in
|
||||||
|
// your sector
|
||||||
|
int j = getflorzofslope(cursectnum, pos.x, pos.y);
|
||||||
|
int k = getflorzofslope(cursectnum, x, y);
|
||||||
|
|
||||||
|
// If extended point is in same sector as you or the slopes
|
||||||
|
// of the sector of the extended point and your sector match
|
||||||
|
// closely (to avoid accidently looking straight out when
|
||||||
|
// you're at the edge of a sector line) then adjust horizon
|
||||||
|
// accordingly
|
||||||
|
if (cursectnum == tempsect || abs(getflorzofslope(tempsect, x, y) - k) <= (4 << 8))
|
||||||
|
{
|
||||||
|
*horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * ((j - k) * 160)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (climbing)
|
if (climbing)
|
||||||
{
|
|
||||||
// tilt when climbing but you can't even really tell it.
|
|
||||||
if (horizoff->asq16() < IntToFixed(100))
|
|
||||||
*horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * (((IntToFixed(100) - horizoff->asq16()) >> 3) + FRACUNIT)));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
|
|
||||||
if (horizoff->asq16() > 0)
|
|
||||||
{
|
{
|
||||||
*horizoff += q16horiz(xs_CRoundToInt(-scaleAdjust * ((horizoff->asq16() >> 3) + FRACUNIT)));
|
// tilt when climbing but you can't even really tell it.
|
||||||
if (horizoff->asq16() < 0) *horizoff = q16horiz(0);
|
if (horizoff->asq16() < IntToFixed(100))
|
||||||
|
*horizoff += q16horiz(xs_CRoundToInt(scaleAdjust * (((IntToFixed(100) - horizoff->asq16()) >> 3) + FRACUNIT)));
|
||||||
}
|
}
|
||||||
if (horizoff->asq16() < 0)
|
else
|
||||||
{
|
{
|
||||||
*horizoff += q16horiz(xs_CRoundToInt(-scaleAdjust * ((horizoff->asq16() >> 3) + FRACUNIT)));
|
// Make horizoff grow towards 0 since horizoff is not modified when you're not on a slope.
|
||||||
if (horizoff->asq16() > 0) *horizoff = q16horiz(0);
|
if (horizoff->asq16() > 0)
|
||||||
|
{
|
||||||
|
*horizoff += q16horiz(xs_CRoundToInt(-scaleAdjust * ((horizoff->asq16() >> 3) + FRACUNIT)));
|
||||||
|
if (horizoff->asq16() < 0) *horizoff = q16horiz(0);
|
||||||
|
}
|
||||||
|
if (horizoff->asq16() < 0)
|
||||||
|
{
|
||||||
|
*horizoff += q16horiz(xs_CRoundToInt(-scaleAdjust * ((horizoff->asq16() >> 3) + FRACUNIT)));
|
||||||
|
if (horizoff->asq16() > 0) *horizoff = q16horiz(0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -195,11 +195,8 @@ inline double get16thOfHoriz(int const snum, bool const interpolate, double cons
|
||||||
|
|
||||||
inline void doslopetilting(player_struct* p, double const scaleAdjust)
|
inline void doslopetilting(player_struct* p, double const scaleAdjust)
|
||||||
{
|
{
|
||||||
if (cl_slopetilting)
|
bool const canslopetilt = p->on_ground && sector[p->cursectnum].lotag != ST_2_UNDERWATER && (sector[p->cursectnum].floorstat & 2);
|
||||||
{
|
calcviewpitch(p->pos.vec2, &p->horizon.horizoff, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursectnum, scaleAdjust);
|
||||||
bool const canslopetilt = p->on_ground && sector[p->cursectnum].lotag != ST_2_UNDERWATER && (sector[p->cursectnum].floorstat & 2);
|
|
||||||
calcviewpitch(p->pos.vec2, &p->horizon.horizoff, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursectnum, scaleAdjust);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1667,12 +1667,8 @@ void SlipSlope(PLAYERp pp)
|
||||||
void
|
void
|
||||||
DoPlayerHorizon(PLAYERp pp, float const horz, double const scaleAdjust)
|
DoPlayerHorizon(PLAYERp pp, float const horz, double const scaleAdjust)
|
||||||
{
|
{
|
||||||
if (cl_slopetilting)
|
bool const canslopetilt = !TEST(pp->Flags, PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING) && TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE);
|
||||||
{
|
calcviewpitch(pp->pos.vec2, &pp->horizon.horizoff, pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursectnum, scaleAdjust, TEST(pp->Flags, PF_CLIMBING));
|
||||||
bool const canslopetilt = !TEST(pp->Flags, PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING) && TEST(sector[pp->cursectnum].floorstat, FLOOR_STAT_SLOPE);
|
|
||||||
calcviewpitch(pp->pos.vec2, &pp->horizon.horizoff, pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursectnum, scaleAdjust, TEST(pp->Flags, PF_CLIMBING));
|
|
||||||
}
|
|
||||||
|
|
||||||
sethorizon(&pp->horizon.horiz, horz, &pp->input.actions, scaleAdjust);
|
sethorizon(&pp->horizon.horiz, horz, &pp->input.actions, scaleAdjust);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue