Skip to content

Commit

Permalink
Fix choppy Chasecam speed effect with pitch != 0
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlaux committed Dec 11, 2023
1 parent 07400d6 commit ea556e5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
- **Blazing door sound fix not applying to Boom doors**
- **Teleporter Zoom and BFG "explosion" shake affecting all players in multiplayer**
- **Explosion shake being stopped by the menu during demo playback and netgames**
- **Choppy Chasecam speed effect when looking up or down**
- **View snapping when teleporting to Automap pointer while crouching**
- **View clipping through floor when landing while crouching**
- **Fixed a demo desync** caused by a failed weapon autoswitch when picking up ammo
Expand Down
4 changes: 2 additions & 2 deletions src/p_map.c
Original file line number Diff line number Diff line change
Expand Up @@ -1931,8 +1931,8 @@ void P_PositionChasecam(fixed_t z, fixed_t dist, fixed_t slope)
const boolean intercepts_overflow_enabled = overflow[emu_intercepts].enabled;

dist += FRACUNIT;
x2 = viewx + (dist >> FRACBITS) * finecosine[angle];
y2 = viewy + (dist >> FRACBITS) * finesine[angle];
x2 = viewx + FixedMul(dist, finecosine[angle]);
y2 = viewy + FixedMul(dist, finesine[angle]);
shootz = z;
attackrange = dist;
aimslope = slope;
Expand Down
12 changes: 7 additions & 5 deletions src/r_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,8 @@ void R_SetupFrame (player_t *player)
const fixed_t z = MIN(playerz + ((player->mo->health <= 0 && player->playerstate == PST_DEAD) ? 6*FRACUNIT : chasecamheight),
player->mo->ceilingz - (2*FRACUNIT));
fixed_t slope;
fixed_t dist = chasecam_distance*FRACUNIT;
const fixed_t oldviewx = viewx, oldviewy = viewy;
fixed_t dist = chasecam_distance * FRACUNIT;
const fixed_t oldviewx = viewx, oldviewy = viewy;
const angle_t oldviewangle = viewangle;

if (chasecam_mode == CHASECAMMODE_FRONT)
Expand Down Expand Up @@ -961,15 +961,17 @@ void R_SetupFrame (player_t *player)
viewz = chasecam.z;
}
else {
const fixed_t dx = FixedMul(dist, finecosine[viewangle >> ANGLETOFINESHIFT]);
const fixed_t dy = FixedMul(dist, finesine[viewangle >> ANGLETOFINESHIFT]);
const fixed_t dx = FixedMul(dist, finecosine[viewangle >> ANGLETOFINESHIFT]),
dy = FixedMul(dist, finesine[viewangle >> ANGLETOFINESHIFT]);

const sector_t *const sec = R_PointInSubsector(viewx-dx, viewy-dy)->sector;

viewz = z + (slope * (dist / FRACUNIT));
viewz = z + FixedMul(slope, dist);

if (viewz < sec->floorheight+FRACUNIT || sec->ceilingheight-FRACUNIT < viewz)
{
fixed_t frac;

viewz = BETWEEN(sec->floorheight+FRACUNIT, sec->ceilingheight-FRACUNIT, viewz);
frac = FixedDiv(viewz - z, FixedMul(slope, dist));
viewx -= FixedMul(dx, frac);
Expand Down

0 comments on commit ea556e5

Please sign in to comment.