void CHeadBobMgr::Update() { CMoveMgr* pMoveMgr = g_pGameClientShell->GetMoveMgr(); if (!pMoveMgr) return; // We check CanDoFootstep instead of on ground since CanDoFootstep // handles stairs much better... if (pMoveMgr->CanDoFootstep() && g_pGameClientShell->IsFirstPerson()) { UpdateHeadBob(); UpdateHeadCant(); } }
void CHeadBobMgr::Update() { // Don't allow head bobbing or canting to update when paused... if( g_pGameClientShell->IsGamePaused() ) return; CMoveMgr* pMoveMgr = g_pPlayerMgr->GetMoveMgr(); if (!pMoveMgr) return; // We check CanDoFootstep instead of on ground since CanDoFootstep // handles stairs much better... if ( (!g_pPlayerMgr->IsSpectatorMode() && g_pPlayerMgr->IsFirstPerson() && pMoveMgr->CanDoFootstep() && g_pPlayerMgr->IsPlayerMovementAllowed() && pMoveMgr->GetAllowMovement()) || pMoveMgr->GetVehicleMgr()->IsVehiclePhysics() ) { UpdateHeadBob(); UpdateHeadCant(); } }
void CHeadBobMgr::UpdateHeadCant() { CMoveMgr* pMoveMgr = g_pPlayerMgr->GetMoveMgr(); if (!pMoveMgr) return; CVehicleMgr* pVehicleMgr = pMoveMgr->GetVehicleMgr(); if (!pVehicleMgr) return; LTBOOL bVehicleTurning = pVehicleMgr->IsTurning(); int nVehicleTurnDir = pVehicleMgr->GetTurnDirection(); CantType eCantType = eCantNone; LTFLOAT fMaxCant = 0.0f, fCantRate = 0.0f; if (bVehicleTurning && pMoveMgr->CanDoFootstep()) { eCantType = nVehicleTurnDir > 0 ? eCantRight : eCantLeft; } fMaxCant = DEG2RAD(g_vtMaxVehicleHeadCant.GetFloat()); LTFLOAT fMinCant = fMaxCant * 0.25f; LTFLOAT fRoll = LimitToPosNegPi( g_pPlayerMgr->GetRoll() - pVehicleMgr->GetVehicleContourRoll() ); switch (eCantType) { case eCantRight : { if (fRoll > 0.0f) { fCantRate = g_vtVehicleHeadCantDownRate.GetFloat(); } else { fCantRate = g_vtVehicleHeadCantUpRate.GetFloat(); } } break; case eCantLeft : { if (fRoll < 0.0f) { fCantRate = g_vtVehicleHeadCantDownRate.GetFloat(); } else { fCantRate = g_vtVehicleHeadCantUpRate.GetFloat(); } } break; case eCantNone: { fCantRate = g_vtVehicleHeadCantDownRate.GetFloat(); } break; default : break; } if (fabs(fRoll) < fMinCant) { fCantRate *= 0.5f; } // This frame time is used since unlike ClientDE::GetFrameTime() the // max value is controlled by the game... LTFLOAT fFrameTime = g_pGameClientShell->GetFrameTime(); LTFLOAT fDelta = fCantRate * fFrameTime; switch (eCantType) { case eCantRight : { fRoll -= fDelta; if (fRoll < -fMaxCant) { fRoll = -fMaxCant; } } break; case eCantLeft : { fRoll += fDelta; if (fRoll > fMaxCant) { fRoll = fMaxCant; } } break; case eCantNone: default : { // We are not canting so move us toward zero... if (fRoll != 0.0f) { if (fRoll < 0.0f) { fRoll += fDelta; if (fRoll > 0.0f) { fRoll = 0.0f; } } else { fRoll -= fDelta; if (fRoll < 0.0f) { fRoll = 0.0f; } } } } break; } // Let the vehicle mgr adjust the value... pVehicleMgr->AdjustCameraRoll(fRoll); // Set the new value... g_pPlayerMgr->SetRoll(fRoll); }