Account for conveyor belts with no-accelerate movement

use R_PointToDist2 instead of P_AproxDistance for player->speed, more accurate and probably won't cause too much performance trouble
This commit is contained in:
Sryder 2017-03-10 22:54:54 +00:00
parent 81fca118fe
commit 8934cf69c7
2 changed files with 4 additions and 5 deletions

View file

@ -1009,7 +1009,6 @@ static void K_PlayTauntSound(mobj_t *source)
void K_MomentumToFacing(player_t *player) void K_MomentumToFacing(player_t *player)
{ {
angle_t dangle = player->mo->angle - R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); angle_t dangle = player->mo->angle - R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy);
fixed_t speed = R_PointToDist2(0, 0, player->rmomx, player->rmomy);
if (dangle > ANGLE_180) if (dangle > ANGLE_180)
dangle = InvAngle(dangle); dangle = InvAngle(dangle);
@ -1018,9 +1017,9 @@ void K_MomentumToFacing(player_t *player)
if (!P_IsObjectOnGround(player->mo) || dangle > ANGLE_90) if (!P_IsObjectOnGround(player->mo) || dangle > ANGLE_90)
return; return;
P_Thrust(player->mo, player->mo->angle, speed - FixedMul(speed, player->mo->friction)); P_Thrust(player->mo, player->mo->angle, player->speed - FixedMul(player->speed, player->mo->friction));
player->mo->momx = FixedMul(player->mo->momx, player->mo->friction); player->mo->momx = FixedMul(player->mo->momx - player->cmomx, player->mo->friction) + player->cmomx;
player->mo->momy = FixedMul(player->mo->momy, player->mo->friction); player->mo->momy = FixedMul(player->mo->momy - player->cmomy, player->mo->friction) + player->cmomy;
} }
// if speed is true it gets the speed boost power, otherwise it gets the acceleration // if speed is true it gets the speed boost power, otherwise it gets the acceleration

View file

@ -4616,7 +4616,7 @@ static void P_3dMovement(player_t *player)
player->rmomy = player->mo->momy - player->cmomy; player->rmomy = player->mo->momy - player->cmomy;
// Calculates player's speed based on distance-of-a-line formula // Calculates player's speed based on distance-of-a-line formula
player->speed = P_AproxDistance(player->rmomx, player->rmomy); player->speed = R_PointToDist2(0, 0, player->rmomx, player->rmomy);
// Monster Iestyn - 04-11-13 // Monster Iestyn - 04-11-13
// Quadrants are stupid, excessive and broken, let's do this a much simpler way! // Quadrants are stupid, excessive and broken, let's do this a much simpler way!