Bladeren bron

fixed smooth motion warping problem

Darren Ranalli 18 jaren geleden
bovenliggende
commit
0caaf136cd
1 gewijzigde bestanden met toevoegingen van 7 en 5 verwijderingen
  1. 7 5
      direct/src/deadrec/smoothMover.cxx

+ 7 - 5
direct/src/deadrec/smoothMover.cxx

@@ -109,9 +109,11 @@ set_mat(const LMatrix4f &mat) {
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
 void SmoothMover::
 void SmoothMover::
 mark_position() {
 mark_position() {
+  /*
   if (deadrec_cat.is_debug()) {
   if (deadrec_cat.is_debug()) {
     deadrec_cat.debug() << "mark_position\n";
     deadrec_cat.debug() << "mark_position\n";
   }
   }
+  */
   if (_smooth_mode == SM_off) {
   if (_smooth_mode == SM_off) {
     // With smoothing disabled, mark_position() simply stores its
     // With smoothing disabled, mark_position() simply stores its
     // current position in the smooth_position members.
     // current position in the smooth_position members.
@@ -781,11 +783,11 @@ record_timestamp_delay(double timestamp) {
 void SmoothMover::
 void SmoothMover::
 handle_wrt_reparent(NodePath &old_parent, NodePath &new_parent) {
 handle_wrt_reparent(NodePath &old_parent, NodePath &new_parent) {
   Points::iterator pi;
   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();
+  NodePath np = old_parent.attach_new_node("smoothMoverWrtReparent");
   for (pi = _points.begin(); pi != _points.end(); pi++) {
   for (pi = _points.begin(); pi != _points.end(); pi++) {
-    (*pi)._pos += old_to_new_pos;
-    (*pi)._hpr += old_to_new_hpr;
+    np.set_pos_hpr((*pi)._pos, (*pi)._hpr);
+    (*pi)._pos = np.get_pos(new_parent);
+    (*pi)._hpr = np.get_hpr(new_parent);
   }
   }
+  np.detach_node();
 }
 }