Public Member Functions | |
nClientLag () | |
REAL | SmoothLag () |
void | ReportLag (REAL lag, REAL weight) |
void | Timestep (REAL dt) |
Private Attributes | |
REAL | lagLast_ |
the last time a serious lag report came in | |
REAL | lagSlow_ |
most accurate estimate of lag | |
REAL | lagFast_ |
faster adapting, but less accurate estimate of lag | |
REAL | smoothLag_ |
smoothed estimate of lag |
Definition at line 54 of file eLagCompensation.cpp.
nClientLag::nClientLag | ( | ) | [inline] |
Definition at line 56 of file eLagCompensation.cpp.
00056 :lagLast_(0), lagSlow_(0), lagFast_(0), smoothLag_(0) {}
REAL nClientLag::SmoothLag | ( | ) | [inline] |
Definition at line 58 of file eLagCompensation.cpp.
References smoothLag_.
Referenced by eLag::Current().
00058 { return smoothLag_; }
Definition at line 60 of file eLagCompensation.cpp.
References con, lagFast_, lagLast_, lagSlow_, REAL, se_lagFastWeight, se_lagSlowWeight, smoothLag_, and tSysTimeFloat().
Referenced by se_receiveLagMessage().
00061 { 00062 #ifdef DEBUG 00063 con << "Received message of " << lag << " seconds of lag, weight " << weight << "\n"; 00064 #endif 00065 00066 // memorize the time of serious reports 00067 if ( weight > 1 ) 00068 lagLast_ = tSysTimeFloat(); 00069 00070 REAL slowWeight = weight * se_lagSlowWeight; 00071 slowWeight = slowWeight > 1 ? 1 : slowWeight; 00072 REAL fastWeight = weight * se_lagFastWeight; 00073 fastWeight = fastWeight > 1 ? 1 : fastWeight; 00074 00075 lagFast_ = smoothLag_ + lag * fastWeight; 00076 lagSlow_ = ( smoothLag_ > lagSlow_ ? lagSlow_ : smoothLag_ ) + lag * slowWeight; 00077 }
void nClientLag::Timestep | ( | REAL | dt | ) | [inline] |
Definition at line 79 of file eLagCompensation.cpp.
References lagFast_, lagLast_, lagSlow_, REAL, se_lagFastDecayTime, se_lagSlowDecayTime, se_maxLagSpeedup, smoothLag_, and tSysTimeFloat().
Referenced by eLag::Timestep().
00080 { 00081 if ( dt > .5 ) 00082 dt = .5; 00083 00084 // increase smooth lag 00085 REAL speedup = se_maxLagSpeedup * dt; 00086 smoothLag_ += speedup; 00087 00088 // clamp fast lag with slow lag 00089 if ( lagFast_ < lagSlow_ ) 00090 lagFast_ = lagSlow_; 00091 00092 // clam smooth lag with fast lag 00093 if ( smoothLag_ > lagFast_ ) 00094 smoothLag_ = lagFast_; 00095 00096 // the last serious lag report came from this many seconds ago 00097 REAL lastLag = tSysTimeFloat() - lagLast_; 00098 00099 // let regular lag decay 00100 if ( lastLag > se_lagSlowDecayTime ) 00101 lagSlow_ *= se_lagSlowDecayTime/( se_lagSlowDecayTime + dt ); 00102 if ( lastLag > se_lagFastDecayTime ) 00103 lagFast_ *= se_lagFastDecayTime/( se_lagFastDecayTime + dt ); 00104 }
REAL nClientLag::lagLast_ [private] |
the last time a serious lag report came in
Definition at line 106 of file eLagCompensation.cpp.
Referenced by ReportLag(), and Timestep().
REAL nClientLag::lagSlow_ [private] |
most accurate estimate of lag
Definition at line 107 of file eLagCompensation.cpp.
Referenced by ReportLag(), and Timestep().
REAL nClientLag::lagFast_ [private] |
faster adapting, but less accurate estimate of lag
Definition at line 108 of file eLagCompensation.cpp.
Referenced by ReportLag(), and Timestep().
REAL nClientLag::smoothLag_ [private] |
smoothed estimate of lag
Definition at line 109 of file eLagCompensation.cpp.
Referenced by ReportLag(), SmoothLag(), and Timestep().