diff --git a/direct/src/deadrec/correction.cxx b/direct/src/deadrec/correction.cxx index fa1468f7fc..c45c0e0377 100644 --- a/direct/src/deadrec/correction.cxx +++ b/direct/src/deadrec/correction.cxx @@ -6,8 +6,14 @@ #include "correction.h" #include +#include +NotifyCategoryDeclNoExport(correction); +NotifyCategoryDef(correction, ""); + Correction::Correction(LPoint3f& start, LVector3f& s_vel) : _curr_p(start), _curr_v(s_vel) { + correction_cat->debug() << "construction with:" << endl << "start = " + << start << endl << "vel = " << s_vel << endl; } Correction::~Correction(void) { @@ -19,6 +25,9 @@ void Correction::step(void) { void Correction::new_target(LPoint3f&, LVector3f&) { } +void Correction::force_target(LPoint3f&, LVector3f&) { +} + LPoint3f Correction::get_pos(void) const { return _curr_p; } @@ -43,6 +52,10 @@ void PopCorrection::new_target(LPoint3f& target, LVector3f&) { _curr_p = target; } +void PopCorrection::force_target(LPoint3f& target, LVector3f&) { + _curr_p = target; +} + ///////////////////////////////////////////////////////////////////// LerpCorrection::LerpCorrection(LPoint3f& start, LVector3f& s_vel) @@ -79,6 +92,14 @@ void LerpCorrection::new_target(LPoint3f& target, LVector3f&) { } } +void LerpCorrection::force_target(LPoint3f& target, LVector3f&) { + if (target == save_p) + return; + _curr_p = prev_p = save_p = target; + have_both = false; + time = 0.; +} + void LerpCorrection::set_duration(float d) { dur = d; } @@ -104,13 +125,20 @@ void SplineCorrection::step(void) { _curr_p = (tmp * tmp * tmp * A) + (tmp * tmp * B) + (tmp * C) + D; _curr_v = (3. * tmp * tmp * A) + (2. * tmp * B) + C; time += ClockObject::get_global_clock()->get_dt(); - } - } + correction_cat->spam() << "new possition = " << _curr_p << endl; + correction_cat->spam() << "new vel = " << _curr_v << endl; + } else + correction_cat->spam() << "time >= dur, holding at current pos" << endl; + } else + correction_cat->spam() << "have_both is false, no point calculated" + << endl; } void SplineCorrection::new_target(LPoint3f& target, LVector3f& v_target) { - if (target == save_p) + if (target == save_p) { + correction_cat->spam() << "new target: same point, no action" << endl; return; + } if (have_both) { time = 0.; prev_p = _curr_p; @@ -121,6 +149,13 @@ void SplineCorrection::new_target(LPoint3f& target, LVector3f& v_target) { B = (3. * (save_p - prev_p)) - (2. * prev_v) - save_v; C = prev_v; D = prev_p; + correction_cat->debug() << "new target: already had 'both'." << endl; + correction_cat->debug() << "target = " << target << endl; + correction_cat->debug() << "vel = " << v_target << endl; + correction_cat->debug() << "A = " << A << endl; + correction_cat->debug() << "B = " << B << endl; + correction_cat->debug() << "C = " << C << endl; + correction_cat->debug() << "D = " << D << endl; } else { save_p = target; save_v = v_target; @@ -132,9 +167,27 @@ void SplineCorrection::new_target(LPoint3f& target, LVector3f& v_target) { C = prev_v; D = prev_p; have_both = true; + correction_cat->debug() << "new target: now have 'both'." << endl; + correction_cat->debug() << "target = " << target << endl; + correction_cat->debug() << "vel = " << v_target << endl; + correction_cat->debug() << "A = " << A << endl; + correction_cat->debug() << "B = " << B << endl; + correction_cat->debug() << "C = " << C << endl; + correction_cat->debug() << "D = " << D << endl; } } +void SplineCorrection::force_target(LPoint3f& target, LVector3f& v_target) { + if (target == save_p) { + correction_cat->debug() << "force target: same point, no action" << endl; + return; + } + _curr_p = prev_p = save_p = target; + _curr_v = prev_v = save_v = v_target; + have_both = false; + time = 0.; +} + void SplineCorrection::set_duration(float d) { dur = d; } diff --git a/direct/src/deadrec/correction.h b/direct/src/deadrec/correction.h index cbe10c7177..e5f4dc70ff 100644 --- a/direct/src/deadrec/correction.h +++ b/direct/src/deadrec/correction.h @@ -19,6 +19,7 @@ PUBLISHED: virtual void step(void); virtual void new_target(LPoint3f&, LVector3f&); + virtual void force_target(LPoint3f&, LVector3f&); LPoint3f get_pos(void) const; LVector3f get_vel(void) const; @@ -31,6 +32,7 @@ PUBLISHED: virtual void step(void); virtual void new_target(LPoint3f&, LVector3f&); + virtual void force_target(LPoint3f&, LVector3f&); }; class LerpCorrection : public Correction { @@ -45,6 +47,7 @@ PUBLISHED: virtual void step(void); virtual void new_target(LPoint3f&, LVector3f&); + virtual void force_target(LPoint3f&, LVector3f&); void set_duration(float); float get_duration(void) const; @@ -64,6 +67,7 @@ PUBLISHED: virtual void step(void); virtual void new_target(LPoint3f&, LVector3f&); + virtual void force_target(LPoint3f&, LVector3f&); void set_duration(float); float get_duration(void) const;