소스 검색

added has_most_recent_timestamp, avoids invalid timestamps after reset

Darren Ranalli 18 년 전
부모
커밋
0680a3d796
3개의 변경된 파일18개의 추가작업 그리고 15개의 파일을 삭제
  1. 12 13
      direct/src/deadrec/smoothMover.I
  2. 3 0
      direct/src/deadrec/smoothMover.cxx
  3. 3 2
      direct/src/deadrec/smoothMover.h

+ 12 - 13
direct/src/deadrec/smoothMover.I

@@ -306,6 +306,7 @@ INLINE void SmoothMover::
 set_phony_timestamp() {
   double now = ClockObject::get_global_clock()->get_frame_time();
   _sample._timestamp = now;
+  _has_most_recent_timestamp = true;
   _most_recent_timestamp = now;
 }
 
@@ -324,31 +325,29 @@ set_timestamp(double timestamp) {
   }
   */
   _sample._timestamp = timestamp;
+  _has_most_recent_timestamp = true;
   _most_recent_timestamp = timestamp;
   record_timestamp_delay(timestamp);
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: SmoothMover::get_most_recent_timestamp
+//     Function: SmoothMover::has_most_recent_timestamp
 //       Access: Published
-//  Description: Returns most recently recorded timestamp
+//  Description: Returns true if we have most recently recorded timestamp
 ////////////////////////////////////////////////////////////////////
-INLINE double SmoothMover::
-get_most_recent_timestamp() {
-  return _most_recent_timestamp;
+INLINE bool SmoothMover::
+has_most_recent_timestamp() const {
+  return _has_most_recent_timestamp;
 }
 
 ////////////////////////////////////////////////////////////////////
-//     Function: SmoothMover::set_most_recent_timestamp
+//     Function: SmoothMover::get_most_recent_timestamp
 //       Access: Published
-//  Description: Specifies the time that the current position report
-//               applies.  This should be called after a call to
-//               mark_position().
+//  Description: Returns most recently recorded timestamp
 ////////////////////////////////////////////////////////////////////
-INLINE void SmoothMover::
-set_most_recent_timestamp(double timestamp) {
-  _points.back()._timestamp = timestamp;
-  _most_recent_timestamp = timestamp;
+INLINE double SmoothMover::
+get_most_recent_timestamp() const {
+  return _most_recent_timestamp;
 }
 
 ////////////////////////////////////////////////////////////////////

+ 3 - 0
direct/src/deadrec/smoothMover.cxx

@@ -46,6 +46,8 @@ SmoothMover() {
   _smooth_lateral_velocity = 0.0;
   _smooth_rotational_velocity = 0.0;
 
+  _has_most_recent_timestamp = false;
+
   _last_point_before = -1;
   _last_point_after = -1;
 
@@ -207,6 +209,7 @@ clear_positions(bool reset_velocity) {
   _last_point_before = -1;
   _last_point_after = -1;
   _smooth_position_known = false;
+  _has_most_recent_timestamp = false;
 
   if (reset_velocity) {
     _smooth_forward_velocity = 0.0;

+ 3 - 2
direct/src/deadrec/smoothMover.h

@@ -87,8 +87,8 @@ PUBLISHED:
   INLINE void set_phony_timestamp();
   INLINE void set_timestamp(double timestamp);
   
-  INLINE double get_most_recent_timestamp();
-  void set_most_recent_timestamp(double timestamp);
+  INLINE bool has_most_recent_timestamp() const;
+  INLINE double get_most_recent_timestamp() const;
 
   void mark_position();
   void clear_positions(bool reset_velocity);
@@ -201,6 +201,7 @@ private:
   double _smooth_lateral_velocity;
   double _smooth_rotational_velocity;
 
+  bool _has_most_recent_timestamp;
   double _most_recent_timestamp;
 
   //  typedef CircBuffer<SamplePoint, max_position_reports> Points;