Browse Source

*** empty log message ***

David Rose 24 years ago
parent
commit
73dfaaf6ca

+ 54 - 0
direct/src/deadrec/smoothMover.I

@@ -17,6 +17,20 @@
 ////////////////////////////////////////////////////////////////////
 
 
+////////////////////////////////////////////////////////////////////
+//     Function: SmoothMover::set_scale
+//       Access: Published
+//  Description: Specifies the current scale that should be applied to
+//               the transform.  This is not smoothed along with pos
+//               and hpr, but rather takes effect immediately; it is
+//               only here at all so we can return a complete matrix
+//               in get_smooth_mat().
+////////////////////////////////////////////////////////////////////
+INLINE bool SmoothMover::
+set_scale(const LVecBase3f &scale) {
+  return set_sx(scale[0]) | set_sy(scale[1]) | set_sz(scale[2]);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: SmoothMover::set_scale
 //       Access: Published
@@ -70,6 +84,26 @@ set_sz(float sz) {
   return result;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: SmoothMover::set_pos
+//       Access: Published
+//  Description: Specifies the position of the SmoothMover at a
+//               particular time in the past.  When mark_position() is
+//               called, this will be recorded (along with hpr and
+//               timestamp) in a position report, which will then be
+//               used along with all other position reports to
+//               determine the smooth position at any particular
+//               instant.
+//
+//               The return value is true if any parameter has changed
+//               since the last call to set_pos(), or false if they
+//               are the same.
+////////////////////////////////////////////////////////////////////
+INLINE bool SmoothMover::
+set_pos(const LVecBase3f &pos) {
+  return set_x(pos[0]) | set_y(pos[1]) | set_z(pos[2]);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: SmoothMover::set_pos
 //       Access: Published
@@ -126,6 +160,26 @@ set_z(float z) {
   return result;
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: SmoothMover::set_hpr
+//       Access: Published
+//  Description: Specifies the orientation of the SmoothMover at a
+//               particular time in the past.  When mark_position() is
+//               called, this will be recorded (along with hpr and
+//               timestamp) in a position report, which will then be
+//               used along with all other position reports to
+//               determine the smooth position at any particular
+//               instant.
+//
+//               The return value is true if any parameter has changed
+//               since the last call to set_hpr(), or false if they
+//               are the same.
+////////////////////////////////////////////////////////////////////
+INLINE bool SmoothMover::
+set_hpr(const LVecBase3f &hpr) {
+  return set_h(hpr[0]) | set_p(hpr[1]) | set_r(hpr[2]);
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: SmoothMover::set_hpr
 //       Access: Published

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

@@ -62,6 +62,23 @@ SmoothMover::
 ~SmoothMover() {
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: SmoothMover::set_mat
+//       Access: Published
+//  Description: Specifies the scale, hpr, and pos for the SmoothMover
+//               at some particular point, based on the matrix.
+////////////////////////////////////////////////////////////////////
+bool SmoothMover::
+set_mat(const LMatrix4f &mat) {
+  bool result = false;
+
+  LVecBase3f scale, hpr, pos;
+  if (decompose_matrix(mat, scale, hpr, pos)) {
+    result = set_scale(scale) | set_hpr(hpr) | set_pos(pos);
+  }
+  return result;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: SmoothMover::mark_position
 //       Access: Published
@@ -247,6 +264,31 @@ compute_smooth_position(double timestamp) {
   }
 }
 
+////////////////////////////////////////////////////////////////////
+//     Function: SmoothMover::get_latest_position
+//       Access: Published
+//  Description: Updates the smooth_pos (and smooth_hpr, etc.) members
+//               to reflect the absolute latest position known for
+//               this avatar.  This may result in a pop to the most
+//               recent position.
+//
+//               Returns true if the latest position is known, false
+//               otherwise.
+////////////////////////////////////////////////////////////////////
+bool SmoothMover::
+get_latest_position() {
+  if (_points.empty()) {
+    // Nothing to do if there are no points.
+    return false;
+  }
+
+  const SamplePoint &point = _points.back();
+  set_smooth_pos(point._pos, point._hpr, point._timestamp);
+  _smooth_forward_velocity = 0.0;
+  _smooth_rotational_velocity = 0.0;
+  return true;
+}
+
 ////////////////////////////////////////////////////////////////////
 //     Function: SmoothMover::output
 //       Access: Published

+ 6 - 0
direct/src/deadrec/smoothMover.h

@@ -52,6 +52,7 @@ PUBLISHED:
   // This method is just used to specify a scale which is only used
   // when composing the matrix for return by get_smooth_mat().  It
   // might change from time to time, but it is not smoothed.
+  INLINE bool set_scale(const LVecBase3f &scale);
   INLINE bool set_scale(float sx, float sy, float sz);
   INLINE bool set_sx(float sx);
   INLINE bool set_sy(float sy);
@@ -62,16 +63,20 @@ PUBLISHED:
   // mark_position().  The return value of each function is true if
   // the parameter value has changed, or false if it remains the same
   // as last time.
+  INLINE bool set_pos(const LVecBase3f &pos);
   INLINE bool set_pos(float x, float y, float z);
   INLINE bool set_x(float x);
   INLINE bool set_y(float y);
   INLINE bool set_z(float z);
 
+  INLINE bool set_hpr(const LVecBase3f &hpr);
   INLINE bool set_hpr(float h, float p, float r);
   INLINE bool set_h(float h);
   INLINE bool set_p(float p);
   INLINE bool set_r(float r);
 
+  bool set_mat(const LMatrix4f &mat);
+
   INLINE void set_timestamp();
   INLINE void set_timestamp(double timestamp);
 
@@ -80,6 +85,7 @@ PUBLISHED:
 
   INLINE void compute_smooth_position();
   void compute_smooth_position(double timestamp);
+  bool get_latest_position();
 
   INLINE const LPoint3f &get_smooth_pos() const;
   INLINE const LVecBase3f &get_smooth_hpr() const;