Browse Source

added handle_wrt_reparent

Darren Ranalli 18 years ago
parent
commit
114dd9bee9
2 changed files with 20 additions and 0 deletions
  1. 18 0
      direct/src/deadrec/smoothMover.cxx
  2. 2 0
      direct/src/deadrec/smoothMover.h

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

@@ -743,3 +743,21 @@ record_timestamp_delay(double timestamp) {
 
   _last_heard_from = now;
 }
+
+////////////////////////////////////////////////////////////////////
+//     Function: SmoothMover::handle_wrt_reparent
+//       Access: Private
+//  Description: Node is being wrtReparented, update recorded
+//               sample positions to reflect new parent
+////////////////////////////////////////////////////////////////////
+void SmoothMover::
+handle_wrt_reparent(NodePath &old_parent, NodePath &new_parent) {
+  Points::iterator pi;
+  CPT(TransformState) transform = old_parent.get_transform(new_parent);
+  const LPoint3f &old_to_new_pos = transform->get_pos();
+  const LVecBase3f &old_to_new_hpr = transform->get_hpr();
+  for (pi = _points.begin(); pi != _points.end(); pi++) {
+    (*pi)._pos += old_to_new_pos;
+    (*pi)._hpr += old_to_new_hpr;
+  }
+}

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

@@ -111,6 +111,8 @@ PUBLISHED:
   INLINE float get_smooth_rotational_velocity() const;
   INLINE const LVecBase3f &get_forward_axis() const;
 
+  void handle_wrt_reparent(NodePath &old_parent, NodePath &new_parent);
+
   enum SmoothMode {
     SM_off,
     SM_on,