Merge branch 'natural-camera-outrun' into 'master'

Add distance easing to the camera, so it doesn't jitter around too much when you're stuck.

See merge request KartKrew/Kart!310
This commit is contained in:
Sal 2021-01-06 22:27:09 -05:00
commit 57e69603a4

View file

@ -3181,17 +3181,40 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
}
// sets ideal cam pos
dist = camdist;
{
const fixed_t speedthreshold = 48*mapobjectscale;
const fixed_t olddist = P_AproxDistance(mo->x - thiscam->x, mo->y - thiscam->y);
/* player->speed subtracts conveyors, janks up the camera */
speed = R_PointToDist2(0, 0, player->mo->momx, player->mo->momy);
fixed_t lag, distoffset;
if (speed > K_GetKartSpeed(player, false))
dist += 4*(speed - K_GetKartSpeed(player, false));
dist += abs(thiscam->momz)/4;
dist = camdist;
if (player->karthud[khud_boostcam])
dist -= FixedMul(11*dist/16, player->karthud[khud_boostcam]);
if (player->karthud[khud_boostcam])
{
dist -= FixedMul(11*dist/16, player->karthud[khud_boostcam]);
}
speed = P_AproxDistance(P_AproxDistance(mo->momx, mo->momy), mo->momz / 16);
lag = FRACUNIT - ((FixedDiv(speed, speedthreshold) - FRACUNIT) * 2);
if (lag > FRACUNIT)
{
lag = FRACUNIT;
}
if (lag < camspeed)
{
lag = camspeed;
}
distoffset = dist - olddist;
dist = olddist + FixedMul(distoffset, lag);
if (dist < 0)
{
dist = 0;
}
}
if (mo->standingslope)
{
@ -3480,7 +3503,9 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
thiscam->momz = 0;
}
else if (player->exiting || timeover == 2)
{
thiscam->momx = thiscam->momy = thiscam->momz = 0;
}
else if (leveltime < introtime)
{
thiscam->momx = FixedMul(x - thiscam->x, camspeed);