fixed smooth motion warping problem

This commit is contained in:
Darren Ranalli 2007-08-13 23:27:24 +00:00
parent 7c76269c9e
commit 0caaf136cd

View File

@ -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); NodePath np = old_parent.attach_new_node("smoothMoverWrtReparent");
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++) { for (pi = _points.begin(); pi != _points.end(); pi++) {
(*pi)._pos += old_to_new_pos; np.set_pos_hpr((*pi)._pos, (*pi)._hpr);
(*pi)._hpr += old_to_new_hpr; (*pi)._pos = np.get_pos(new_parent);
(*pi)._hpr = np.get_hpr(new_parent);
} }
np.detach_node();
} }