float CSDKPlayerAnimState::CalcMovementPlaybackRate( bool *bIsMoving ) { // Get the player's current velocity and speed. Vector vecVelocity; GetOuterAbsVelocity( vecVelocity ); float flSpeed = vecVelocity.Length2D(); // Determine if the player is considered moving or not. bool bMoving = ( flSpeed > MOVING_MINIMUM_SPEED ); // Initialize the return data. *bIsMoving = false; float flReturn = 1.0f; // If we are moving. if ( bMoving ) { // float flGroundSpeed = GetInterpolatedGroundSpeed(); float flGroundSpeed = GetCurrentMaxGroundSpeed(); if ( flGroundSpeed < 0.001f ) { flReturn = 0.01; } else { // Note this gets set back to 1.0 if sequence changes due to ResetSequenceInfo below flReturn = flSpeed / flGroundSpeed; flReturn = clamp( flReturn, 0.01f, 10.0f ); } *bIsMoving = true; } return flReturn; }
void CBasePlayerAnimState::UpdateInterpolators() { VPROF( "CBasePlayerAnimState::UpdateInterpolators" ); // First, figure out their current MAX speed based on their current activity. float flCurMaxSpeed = GetCurrentMaxGroundSpeed(); m_flMaxGroundSpeed = flCurMaxSpeed; }
void CSDKPlayerAnimState::ResetGroundSpeed( void ) { #ifdef CLIENT_DLL m_flMaxGroundSpeed = GetCurrentMaxGroundSpeed(); m_iv_flMaxGroundSpeed.Reset(); m_iv_flMaxGroundSpeed.NoteChanged( gpGlobals->curtime, 0, false ); #endif }
void CSDKPlayerAnimState::UpdateInterpolators() { VPROF( "CBasePlayerAnimState::UpdateInterpolators" ); // First, figure out their current max speed based on their current activity. float flCurMaxSpeed = GetCurrentMaxGroundSpeed(); #ifdef CLIENT_DLL float flGroundSpeedInterval = 0.1; // Only update this 10x/sec so it has an interval to interpolate over. if ( gpGlobals->curtime - m_flLastGroundSpeedUpdateTime >= flGroundSpeedInterval ) { m_flLastGroundSpeedUpdateTime = gpGlobals->curtime; m_flMaxGroundSpeed = flCurMaxSpeed; m_iv_flMaxGroundSpeed.NoteChanged( gpGlobals->curtime, flGroundSpeedInterval, false ); } m_iv_flMaxGroundSpeed.Interpolate( gpGlobals->curtime, flGroundSpeedInterval ); #else m_flMaxGroundSpeed = flCurMaxSpeed; #endif }
void CBasePlayerAnimState::ResetGroundSpeed( void ) { m_flMaxGroundSpeed = GetCurrentMaxGroundSpeed(); }