Move democam.reset_aiming to camera_t, let spectator camera even out aiming

This commit is contained in:
James R 2023-08-17 17:39:41 -07:00
parent 414d6f3647
commit 7a1e61d722
2 changed files with 11 additions and 7 deletions

View file

@ -126,6 +126,9 @@ struct camera_t
// SRB2Kart: camera pitches on slopes // SRB2Kart: camera pitches on slopes
angle_t pitch; angle_t pitch;
// Freecam: aiming needs to be reset after switching from chasecam
boolean reset_aiming;
// Interpolation data // Interpolation data
fixed_t old_x, old_y, old_z; fixed_t old_x, old_y, old_z;
angle_t old_angle, old_aiming; angle_t old_angle, old_aiming;
@ -135,7 +138,6 @@ struct camera_t
struct demofreecam_s { struct demofreecam_s {
UINT8 button_a_held; // A button was held since entering from menu, so don't move camera UINT8 button_a_held; // A button was held since entering from menu, so don't move camera
boolean reset_aiming; // camera aiming needs to be reset from chase camera
}; };
extern struct demofreecam_s democam; extern struct demofreecam_s democam;

View file

@ -2956,7 +2956,7 @@ void P_DemoCameraMovement(camera_t *cam)
{ {
cam->aiming += cmd->aiming << TICCMD_REDUCE; cam->aiming += cmd->aiming << TICCMD_REDUCE;
democam.reset_aiming = false; cam->reset_aiming = false;
} }
cam->angle += cmd->turning << TICCMD_REDUCE; cam->angle += cmd->turning << TICCMD_REDUCE;
@ -2988,7 +2988,7 @@ void P_DemoCameraMovement(camera_t *cam)
cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y); cam->angle = R_PointToAngle2(cam->x, cam->y, lastp->mo->x, lastp->mo->y);
cam->aiming = R_PointToAngle2(0, cam->z, R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y), lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads. cam->aiming = R_PointToAngle2(0, cam->z, R_PointToDist2(cam->x, cam->y, lastp->mo->x, lastp->mo->y), lastp->mo->z + lastp->mo->scale*128*P_MobjFlip(lastp->mo)); // This is still unholy. Aim a bit above their heads.
democam.reset_aiming = false; cam->reset_aiming = false;
} }
if (cmd->forwardmove != 0) if (cmd->forwardmove != 0)
@ -3002,7 +3002,7 @@ void P_DemoCameraMovement(camera_t *cam)
// forward/back will have a slope. So, as long as democam // forward/back will have a slope. So, as long as democam
// controls haven't been used to alter the vertical angle, // controls haven't been used to alter the vertical angle,
// slowly reset it to flat. // slowly reset it to flat.
if ((democam.reset_aiming && moving) || ((cmd->buttons & BT_DRIFT) && !democam.button_a_held)) if ((cam->reset_aiming && moving) || ((cmd->buttons & BT_DRIFT) && !democam.button_a_held))
{ {
INT32 aiming = cam->aiming; INT32 aiming = cam->aiming;
INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming)); INT32 smooth = FixedMul(ANGLE_11hh / 4, FCOS(cam->aiming));
@ -3014,7 +3014,7 @@ void P_DemoCameraMovement(camera_t *cam)
else else
{ {
cam->aiming = 0; cam->aiming = 0;
democam.reset_aiming = false; // completely smoothed out cam->reset_aiming = false; // completely smoothed out
} }
} }
@ -3029,7 +3029,7 @@ void P_DemoCameraMovement(camera_t *cam)
cam->x += FixedMul(cmd->forwardmove*mapobjectscale, FINECOSINE(thrustangle)); cam->x += FixedMul(cmd->forwardmove*mapobjectscale, FINECOSINE(thrustangle));
cam->y += FixedMul(cmd->forwardmove*mapobjectscale, FINESINE(thrustangle)); cam->y += FixedMul(cmd->forwardmove*mapobjectscale, FINESINE(thrustangle));
if (!democam.reset_aiming) if (!cam->reset_aiming)
{ {
cam->z += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(cam->aiming)); cam->z += FixedMul(cmd->forwardmove*mapobjectscale, AIMINGTOSLOPE(cam->aiming));
} }
@ -3049,7 +3049,7 @@ void P_ToggleDemoCamera(void)
{ {
demo.freecam = true; demo.freecam = true;
democam.button_a_held = 2; democam.button_a_held = 2;
democam.reset_aiming = true; camera[0].reset_aiming = true;
} }
else // toggle off else // toggle off
{ {
@ -3093,6 +3093,8 @@ void P_ResetCamera(player_t *player, camera_t *thiscam)
thiscam->radius = 20*FRACUNIT; thiscam->radius = 20*FRACUNIT;
thiscam->height = 16*FRACUNIT; thiscam->height = 16*FRACUNIT;
thiscam->reset_aiming = true;
while (!P_MoveChaseCamera(player,thiscam,true) && ++tries < 2*TICRATE); while (!P_MoveChaseCamera(player,thiscam,true) && ++tries < 2*TICRATE);
} }