//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFBaseRocket::PostDataUpdate( DataUpdateType_t type ) { // Pass through to the base class. BaseClass::PostDataUpdate( type ); if ( type == DATA_UPDATE_CREATED ) { // Now stick our initial velocity and angles into the interpolation history. CInterpolatedVar<Vector> &interpolator = GetOriginInterpolator(); interpolator.ClearHistory(); CInterpolatedVar<QAngle> &rotInterpolator = GetRotationInterpolator(); rotInterpolator.ClearHistory(); float flChangeTime = GetLastChangeTime( LATCH_SIMULATION_VAR ); // Add a sample 1 second back. Vector vCurOrigin = GetLocalOrigin() - m_vInitialVelocity; interpolator.AddToHead( flChangeTime - 1.0f, &vCurOrigin, false ); QAngle vCurAngles = GetLocalAngles(); rotInterpolator.AddToHead( flChangeTime - 1.0f, &vCurAngles, false ); // Add the current sample. vCurOrigin = GetLocalOrigin(); interpolator.AddToHead( flChangeTime, &vCurOrigin, false ); rotInterpolator.AddToHead( flChangeTime - 1.0, &vCurAngles, false ); } }
void C_DODBaseRocket::PostDataUpdate( DataUpdateType_t type ) { BaseClass::PostDataUpdate( type ); if ( type == DATA_UPDATE_CREATED ) { // Now stick our initial velocity into the interpolation history CInterpolatedVar< Vector > &interpolator = GetOriginInterpolator(); interpolator.ClearHistory(); float changeTime = GetLastChangeTime( LATCH_SIMULATION_VAR ); // Add a sample 1 second back. Vector vCurOrigin = GetLocalOrigin() - m_vInitialVelocity; interpolator.AddToHead( changeTime - 1.0, &vCurOrigin, false ); // Add the current sample. vCurOrigin = GetLocalOrigin(); interpolator.AddToHead( changeTime, &vCurOrigin, false ); // do the same for angles CInterpolatedVar< QAngle > &rotInterpolator = GetRotationInterpolator(); rotInterpolator.ClearHistory(); // Add a rotation sample 1 second back QAngle vCurAngles = GetLocalAngles(); rotInterpolator.AddToHead( changeTime - 1.0, &vCurAngles, false ); // Add the current rotation rotInterpolator.AddToHead( changeTime - 1.0, &vCurAngles, false ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_BaseObject::Simulate( void ) { if ( IsPlacing() && !MustBeBuiltOnAttachmentPoint() ) { int iValidPlacement = ( IsPlacementPosValid() && ServerValidPlacement() ) ? 1 : 0; if ( m_iLastPlacementPosValid != iValidPlacement ) { m_iLastPlacementPosValid = iValidPlacement; OnPlacementStateChanged( m_iLastPlacementPosValid > 0 ); } // We figure out our own placement pos, but we still leave it to the server to // do collision with other entities and nobuild triggers, so that sets the // placement animation SetLocalOrigin( m_vecBuildOrigin ); InvalidateBoneCache(); // Clear out our origin and rotation interpolation history // so we don't pop when we teleport in the actual position from the server CInterpolatedVar< Vector > &interpolator = GetOriginInterpolator(); interpolator.ClearHistory(); CInterpolatedVar<QAngle> &rotInterpolator = GetRotationInterpolator(); rotInterpolator.ClearHistory(); } BaseClass::Simulate(); }
void CBaseGrenadeProjectile::PostDataUpdate( DataUpdateType_t type ) { BaseClass::PostDataUpdate( type ); if ( type == DATA_UPDATE_CREATED ) { // Now stick our initial velocity into the interpolation history CInterpolatedVar< Vector > &interpolator = GetOriginInterpolator(); interpolator.ClearHistory(); float changeTime = GetLastChangeTime( LATCH_SIMULATION_VAR ); // Add a sample 1 second back. Vector vCurOrigin = GetLocalOrigin() - m_vInitialVelocity; interpolator.AddToHead( changeTime - 1.0, &vCurOrigin, false ); // Add the current sample. vCurOrigin = GetLocalOrigin(); interpolator.AddToHead( changeTime, &vCurOrigin, false ); } }
void CWeaponDODBase::OnDataChanged( DataUpdateType_t type ) { if ( m_iState == WEAPON_NOT_CARRIED && m_iOldState != WEAPON_NOT_CARRIED ) { // we are being notified of the weapon being dropped // add an interpolation history so the movement is smoother // Now stick our initial velocity into the interpolation history CInterpolatedVar< Vector > &interpolator = GetOriginInterpolator(); interpolator.ClearHistory(); float changeTime = GetLastChangeTime( LATCH_SIMULATION_VAR ); // Add a sample 1 second back. Vector vCurOrigin = GetLocalOrigin() - m_vInitialDropVelocity; interpolator.AddToHead( changeTime - 1.0, &vCurOrigin, false ); // Add the current sample. vCurOrigin = GetLocalOrigin(); interpolator.AddToHead( changeTime, &vCurOrigin, false ); Vector estVel; EstimateAbsVelocity( estVel ); /*Msg( "estimated velocity ( %.1f %.1f %.1f ) initial velocity ( %.1f %.1f %.1f )\n", estVel.x, estVel.y, estVel.z, m_vInitialDropVelocity.m_Value.x, m_vInitialDropVelocity.m_Value.y, m_vInitialDropVelocity.m_Value.z );*/ OnWeaponDropped(); } BaseClass::OnDataChanged( type ); if ( GetPredictable() && !ShouldPredict() ) ShutdownPredictable(); }