Skip to content

Commit

Permalink
Foot clipping: Interpolated, fixed for client
Browse files Browse the repository at this point in the history
Foot clipping is now applied to the view offset, which also
handles view bobbing. This means it gets interpolated,
giving a smoother "sinking" into liquids.

On the client, the clmobj's invalid floorclip value was
occasionally overwriting the valid local floorclip, causing
viewheight glitches.
  • Loading branch information
skyjake committed Aug 28, 2011
1 parent 8c48979 commit 1ef61f9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
8 changes: 7 additions & 1 deletion doomsday/engine/portable/src/cl_mobj.c
Expand Up @@ -330,7 +330,13 @@ void Cl_UpdateRealPlayerMobj(mobj_t *localMobj, mobj_t *remoteClientMobj, int fl
localMobj->flags = (localMobj->flags & ~0x1c000000) |
(remoteClientMobj->flags & 0x1c000000); // color translation flags (MF_TRANSLATION)
localMobj->height = remoteClientMobj->height;
localMobj->floorClip = remoteClientMobj->floorClip;
/*#ifdef _DEBUG
if(localMobj->floorClip != remoteClientMobj->floorClip)
{
Con_Message("Cl_UpdateRealPlayerMobj: Floorclip=%f\n", remoteClientMobj->floorClip);
}
#endif
localMobj->floorClip = remoteClientMobj->floorClip;*/
localMobj->selector &= ~DDMOBJ_SELECTOR_MASK;
localMobj->selector |= remoteClientMobj->selector & DDMOBJ_SELECTOR_MASK;
localMobj->visAngle = remoteClientMobj->angle >> 16;
Expand Down
40 changes: 20 additions & 20 deletions doomsday/plugins/common/src/p_view.c
Expand Up @@ -128,6 +128,25 @@ void P_CalcHeight(player_t* plr)
else
step = 4.0f;

// Foot clipping (interpolated).
if(!( Get(DD_PLAYBACK) || P_MobjIsCamera(pmo) || (ddplr->flags & DDPF_CHASECAM) ))
{
if(morphed)
{ // Chicken or pig.
target /*plr->viewZ*/ -= 20;
}

// Foot clipping is done for living players.
if(plr->playerState != PST_DEAD)
{
if(pmo->floorClip && pmo->pos[VZ] <= pmo->floorZ)
{
target /*plr->viewZ*/ -= pmo->floorClip;
}
}
}

// viewOffset is used for bobbing the view (applied to plr->viewZ).
if(plr->viewOffset[VZ] > target)
{
if(plr->viewOffset[VZ] - target > step)
Expand Down Expand Up @@ -169,6 +188,7 @@ void P_CalcHeight(player_t* plr)
plr->viewHeightDelta = 1;
}

/// @todo What is the purpose of this? -skyjake
if(plr->viewHeightDelta)
{
plr->viewHeightDelta += 0.25f;
Expand All @@ -180,24 +200,4 @@ void P_CalcHeight(player_t* plr)

// Set the plr's eye-level Z coordinate.
plr->viewZ = pmo->pos[VZ] + (P_MobjIsCamera(pmo)? 0 : plr->viewHeight);

// During demo playback (or camera mode) the viewz will not be modified
// any further.
if(!(Get(DD_PLAYBACK) || P_MobjIsCamera(pmo) ||
(ddplr->flags & DDPF_CHASECAM)))
{
if(morphed)
{ // Chicken or pig.
plr->viewZ -= 20;
}

// Foot clipping is done for living players.
if(plr->playerState != PST_DEAD)
{
if(pmo->floorClip && pmo->pos[VZ] <= pmo->floorZ)
{
plr->viewZ -= pmo->floorClip;
}
}
}
}

0 comments on commit 1ef61f9

Please sign in to comment.