Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int CBaseEntity::BaseInterpolatePart1( float ¤tTime, Vector &oldOrigin, QAngle &oldAngles, int &bNoMoreChanges )
- {
- // Don't mess with the world!!!
- bNoMoreChanges = 1;
- // These get moved to the parent position automatically
- if ( IsFollowingEntity() || !IsInterpolationEnabled() )
- {
- // Assume current origin ( no interpolation )
- MoveToLastReceivedPosition();
- return INTERPOLATE_STOP;
- }
- if ( GetPredictable() || IsClientCreated() )
- {
- C_BasePlayer *localplayer = C_BasePlayer::GetLocalPlayer();
- if ( localplayer && currentTime == gpGlobals->curtime )
- {
- currentTime = localplayer->GetFinalPredictedTime();
- currentTime -= TICK_INTERVAL;
- currentTime += ( gpGlobals->interpolation_amount * TICK_INTERVAL );
- }
- }
- oldOrigin = m_vecOrigin;
- oldAngles = m_angRotation;
- bNoMoreChanges = Interp_Interpolate( GetVarMapping(), currentTime );
- if ( cl_interp_all.GetInt() || (m_EntClientFlags & ENTCLIENTFLAG_ALWAYS_INTERPOLATE) )
- bNoMoreChanges = 0;
- return INTERPOLATE_CONTINUE;
- }
- void C_BaseEntity::BaseInterpolatePart2( Vector &oldOrigin, QAngle &oldAngles, int nChangeFlags )
- {
- if ( m_vecOrigin != oldOrigin )
- {
- nChangeFlags |= POSITION_CHANGED;
- }
- if( m_angRotation != oldAngles )
- {
- nChangeFlags |= ANGLES_CHANGED;
- }
- if ( nChangeFlags != 0 )
- {
- InvalidatePhysicsRecursive( nChangeFlags );
- }
- #if 0
- if ( IsPlayer() &&
- cl_watchplayer.GetInt() == entindex() &&
- C_BasePlayer::GetLocalPlayer() &&
- GetTeam() == C_BasePlayer::GetLocalPlayer()->GetTeam() )
- {
- // SpewInterpolatedVar( &m_iv_vecOrigin, gpGlobals->curtime, GetInterpolationAmount( LATCH_SIMULATION_VAR ), false );
- Vector vel;
- EstimateAbsVelocity( vel );
- float spd = vel.Length();
- Msg( "estimated %f\n", spd );
- }
- #endif
- }
- inline int C_BaseEntity::Interp_Interpolate( VarMapping_t *map, float currentTime )
- {
- int bNoMoreChanges = 1;
- if ( currentTime < map->m_lastInterpolationTime )
- {
- for ( int i = 0; i < map->m_nInterpolatedEntries; i++ )
- {
- VarMapEntry_t *e = &map->m_Entries[ i ];
- e->m_bNeedsToInterpolate = true;
- }
- }
- map->m_lastInterpolationTime = currentTime;
- for ( int i = 0; i < map->m_nInterpolatedEntries; i++ )
- {
- VarMapEntry_t *e = &map->m_Entries[ i ];
- if ( !e->m_bNeedsToInterpolate )
- continue;
- IInterpolatedVar *watcher = e->watcher;
- Assert( !( watcher->GetType() & EXCLUDE_AUTO_INTERPOLATE ) );
- if ( watcher->Interpolate( currentTime ) )
- e->m_bNeedsToInterpolate = false;
- else
- bNoMoreChanges = 0;
- }
- return bNoMoreChanges;
- }
Advertisement
Add Comment
Please, Sign In to add comment