Add player_t.cameraOffset, offset chasecam Z position

This commit is contained in:
James R 2023-08-17 18:09:03 -07:00 committed by NepDisk
parent 5290e3fcd8
commit 410419c852
3 changed files with 14 additions and 2 deletions

View file

@ -319,6 +319,7 @@ typedef struct player_s
fixed_t deltaviewheight;
// bounded/scaled total momentum.
fixed_t bob;
fixed_t cameraOffset;
angle_t viewrollangle;
// camera tilt

View file

@ -6536,6 +6536,15 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
{
const boolean onground = P_IsObjectOnGround(player->mo);
/* reset sprite offsets :) */
player->mo->sprxoff = 0;
player->mo->spryoff = 0;
player->mo->sprzoff = 0;
player->mo->spritexoffset = 0;
player->mo->spriteyoffset = 0;
player->cameraOffset = 0;
K_UpdateOffroad(player);
K_UpdateEngineSounds(player); // Thanks, VAda!

View file

@ -3599,6 +3599,8 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
thiscam->z = thiscam->floorz;
#endif // NOCLIPCAM
z += player->cameraOffset;
// point viewed by the camera
// this point is just 64 unit forward the player
dist = 64*mapobjectscale;
@ -3651,13 +3653,13 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall
if (mo->eflags & MFE_VERTICALFLIP)
{
angle = R_PointToAngle2(0, thiscam->z + thiscam->height, dist, mo->z + mo->height - player->mo->height);
angle = R_PointToAngle2(0, thiscam->z + thiscam->height, dist, mo->z + mo->height - player->mo->height + player->cameraOffset);
if (thiscam->pitch < ANGLE_180 && thiscam->pitch > angle)
angle += (thiscam->pitch - angle)/2;
}
else
{
angle = R_PointToAngle2(0, thiscam->z, dist, mo->z + player->mo->height);
angle = R_PointToAngle2(0, thiscam->z, dist, mo->z + player->mo->height + player->cameraOffset);
if (thiscam->pitch >= ANGLE_180 && thiscam->pitch < angle)
angle -= (angle - thiscam->pitch)/2;
}