SW: Smooth out 180 degree turn landing and replace some fix16_min/max with fix16_clamp.

This commit is contained in:
Mitchell Richters 2020-04-12 07:34:14 +10:00 committed by Christoph Oelckers
parent 2d73466425
commit 0996e87f79
2 changed files with 6 additions and 11 deletions

View file

@ -1642,9 +1642,7 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, fix16_t
zvect = 0;
// new horiz to player
*tq16horiz = fix16_from_int(100 - (zvect/256));
*tq16horiz = fix16_max(*tq16horiz, fix16_from_int(PLAYER_HORIZ_MIN));
*tq16horiz = fix16_min(*tq16horiz, fix16_from_int(PLAYER_HORIZ_MAX));
*tq16horiz = fix16_clamp(fix16_from_int(100 - (zvect/256)), fix16_from_int(PLAYER_HORIZ_MIN), fix16_from_int(PLAYER_HORIZ_MAX));
//DSPRINTF(ds,"xvect %d,yvect %d,zvect %d,tq16horiz %d",xvect,yvect,zvect,*tq16horiz);
MONO_PRINT(ds);
@ -2104,10 +2102,8 @@ drawscreen(PLAYERp pp)
tz += camerapp->bob_z;
// recoil only when not in camera
//tq16horiz = tq16horiz + fix16_from_int(camerapp->recoil_horizoff);
tq16horiz = tq16horiz + fix16_from_int(pp->recoil_horizoff);
tq16horiz = fix16_max(tq16horiz, fix16_from_int(PLAYER_HORIZ_MIN));
tq16horiz = fix16_min(tq16horiz, fix16_from_int(PLAYER_HORIZ_MAX));
//tq16horiz = fix16_clamp(fix16_sadd(tq16horiz, fix16_from_int(camerapp->recoil_horizoff)), fix16_from_int(PLAYER_HORIZ_MIN), fix16_from_int(PLAYER_HORIZ_MAX));
tq16horiz = fix16_clamp(fix16_sadd(tq16horiz, fix16_from_int(pp->recoil_horizoff)), fix16_from_int(PLAYER_HORIZ_MIN), fix16_from_int(PLAYER_HORIZ_MAX));
}
if (r_usenewaspect)

View file

@ -3309,7 +3309,7 @@ void getinput(int const playerNum)
// the rest will follow
delta_q16ang = GetDeltaAngleQ16(pp->turn180_target, pp->q16ang);
pp->q16ang = fix16_sadd(pp->q16ang, fix16_max(fix16_one,fix16_from_float(scaleAdjustmentToInterval(fix16_to_int(fix16_sdiv(fix16_abs(delta_q16ang), fix16_from_int(TURN_SHIFT))))))) & 0x7FFFFFF;
pp->q16ang = fix16_sadd(pp->q16ang, fix16_max(fix16_one, fix16_from_float(scaleAdjustmentToInterval(fix16_to_int(fix16_sdiv(fix16_abs(delta_q16ang), fix16_from_int(TURN_SHIFT))))))) & 0x7FFFFFF;
SET(pp->Flags, PF_TURN_180);
}
@ -3337,7 +3337,7 @@ void getinput(int const playerNum)
// get new delta to see how close we are
delta_q16ang = GetDeltaAngleQ16(pp->turn180_target, pp->q16ang);
if (fix16_abs(delta_q16ang) < fix16_from_int(3 * TURN_SHIFT))
if (fix16_abs(delta_q16ang) < (fix16_one << 1))
{
pp->q16ang = pp->turn180_target;
RESET(pp->Flags, PF_TURN_180);
@ -3491,8 +3491,7 @@ void getinput(int const playerNum)
}
// bound the base
pp->q16horizbase = fix16_max(pp->q16horizbase, fix16_from_int(PLAYER_HORIZ_MIN));
pp->q16horizbase = fix16_min(pp->q16horizbase, fix16_from_int(PLAYER_HORIZ_MAX));
pp->q16horizbase = fix16_clamp(pp->q16horizbase, fix16_from_int(PLAYER_HORIZ_MIN), fix16_from_int(PLAYER_HORIZ_MAX));
// bound adjust q16horizoff
if (pp->q16horizbase + pp->q16horizoff < fix16_from_int(PLAYER_HORIZ_MIN))