Skip to content

Commit

Permalink
Fix view clipping through floor while crouching
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlaux committed Dec 11, 2023
1 parent 16a9888 commit 07400d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
- **Teleporter Zoom and BFG "explosion" shake affecting all players in multiplayer**
- **Explosion shake being stopped by the menu during demo playback and netgames**
- **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
- **_View Height_ increments not being applied immediately**
- **Tweaked dark menu background and Automap overlay algorithm** (fixes very low values)
19 changes: 15 additions & 4 deletions src/p_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ void P_CalcHeight (player_t* player)

player->viewheight += breathing_val;
}

if (player->viewheight > view)
{
player->viewheight = view;
Expand All @@ -201,9 +201,20 @@ void P_CalcHeight (player_t* player)
}
}

// [Nugget] Account for crouching
player->viewz = player->mo->z + player->viewheight + bob - player->crouchoffset;

player->viewz = player->mo->z + player->viewheight + bob;

// [Nugget] Account for crouching, but don't clip view through the floor
if (player->crouchoffset)
{
fixed_t crouchoffset = player->crouchoffset;

if ((player->viewz - crouchoffset) < (player->mo->floorz + FRACUNIT))
{ crouchoffset = player->viewz - (player->mo->floorz + FRACUNIT); }

// Do clip view through the floor if not because of crouching
player->viewz -= MAX(0, crouchoffset);
}

if (player->viewz > player->mo->ceilingz-4*FRACUNIT)
player->viewz = player->mo->ceilingz-4*FRACUNIT;
}
Expand Down

0 comments on commit 07400d6

Please sign in to comment.