Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions code/playerman/playercontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,15 @@ void do_view_track_target()
chase_slew_angles.h = forward_angles.h - view_angles.h;
chase_slew_angles.p = -(forward_angles.p - view_angles.p);

// Do over-the-top correction.
// Headings are extracted with atan2, so each one lies in (-PI, PI] and their difference can be
// nearly a full circle in either direction. Without wrapping it back into (-PI, PI], a target just
// past the left shoulder reads as being almost all the way around to the right instead.
if (chase_slew_angles.h > PI)
chase_slew_angles.h -= PI2;
else if (chase_slew_angles.h < -PI)
chase_slew_angles.h += PI2;

// the gimbal limits of the player's virtual neck.
// These nested ifs prevent the player from looking up and
// down beyond 90 degree angles.
Expand Down
Loading