MF_NOCLIPHEIGHT: remove restrictions on first-person camera

Fixes spectator noclip camera being clamped to
floor/ceiling heights.
This commit is contained in:
James R 2023-04-02 05:21:01 -07:00
parent b1c3d1b2e7
commit 652fb5452e
2 changed files with 18 additions and 6 deletions

View file

@ -2839,8 +2839,9 @@ void P_PlayerZMovement(mobj_t *mo)
P_AdjustMobjFloorZ_PolyObjs(mo, mo->subsector);
// check for smooth step up
if ((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height > mo->ceilingz)
|| (!(mo->eflags & MFE_VERTICALFLIP) && mo->z < mo->floorz))
if (!(mo->flags & MF_NOCLIPHEIGHT)
&& ((mo->eflags & MFE_VERTICALFLIP && mo->z + mo->height > mo->ceilingz)
|| (!(mo->eflags & MFE_VERTICALFLIP) && mo->z < mo->floorz)))
{
if (mo->eflags & MFE_VERTICALFLIP)
mo->player->viewheight -= (mo->z+mo->height) - mo->ceilingz;

View file

@ -220,12 +220,20 @@ void P_CalcHeight(player_t *player)
if (mo->eflags & MFE_VERTICALFLIP)
{
player->viewz = mo->z + mo->height - player->viewheight;
if (mo->flags & MF_NOCLIPHEIGHT)
return;
if (player->viewz < mo->floorz + FixedMul(FRACUNIT, mo->scale))
player->viewz = mo->floorz + FixedMul(FRACUNIT, mo->scale);
}
else
{
player->viewz = mo->z + player->viewheight;
if (mo->flags & MF_NOCLIPHEIGHT)
return;
if (player->viewz > mo->ceilingz - FixedMul(FRACUNIT, mo->scale))
player->viewz = mo->ceilingz - FixedMul(FRACUNIT, mo->scale);
}
@ -2300,10 +2308,13 @@ static void P_SpectatorMovement(player_t *player)
else if (cmd->buttons & BT_BRAKE)
player->mo->z -= 32*mapobjectscale;
if (player->mo->z > player->mo->ceilingz - player->mo->height)
player->mo->z = player->mo->ceilingz - player->mo->height;
if (player->mo->z < player->mo->floorz)
player->mo->z = player->mo->floorz;
if (!(player->mo->flags & MF_NOCLIPHEIGHT))
{
if (player->mo->z > player->mo->ceilingz - player->mo->height)
player->mo->z = player->mo->ceilingz - player->mo->height;
if (player->mo->z < player->mo->floorz)
player->mo->z = player->mo->floorz;
}
player->mo->momx = player->mo->momy = player->mo->momz = 0;
if (cmd->forwardmove != 0)