|
@@ -6,8 +6,14 @@
|
|
|
#include "correction.h"
|
|
#include "correction.h"
|
|
|
#include <clockObject.h>
|
|
#include <clockObject.h>
|
|
|
|
|
|
|
|
|
|
+#include <notifyCategoryProxy.h>
|
|
|
|
|
+NotifyCategoryDeclNoExport(correction);
|
|
|
|
|
+NotifyCategoryDef(correction, "");
|
|
|
|
|
+
|
|
|
Correction::Correction(LPoint3f& start, LVector3f& s_vel) : _curr_p(start),
|
|
Correction::Correction(LPoint3f& start, LVector3f& s_vel) : _curr_p(start),
|
|
|
_curr_v(s_vel) {
|
|
_curr_v(s_vel) {
|
|
|
|
|
+ correction_cat->debug() << "construction with:" << endl << "start = "
|
|
|
|
|
+ << start << endl << "vel = " << s_vel << endl;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
Correction::~Correction(void) {
|
|
Correction::~Correction(void) {
|
|
@@ -19,6 +25,9 @@ void Correction::step(void) {
|
|
|
void Correction::new_target(LPoint3f&, LVector3f&) {
|
|
void Correction::new_target(LPoint3f&, LVector3f&) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void Correction::force_target(LPoint3f&, LVector3f&) {
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
LPoint3f Correction::get_pos(void) const {
|
|
LPoint3f Correction::get_pos(void) const {
|
|
|
return _curr_p;
|
|
return _curr_p;
|
|
|
}
|
|
}
|
|
@@ -43,6 +52,10 @@ void PopCorrection::new_target(LPoint3f& target, LVector3f&) {
|
|
|
_curr_p = target;
|
|
_curr_p = target;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void PopCorrection::force_target(LPoint3f& target, LVector3f&) {
|
|
|
|
|
+ _curr_p = target;
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
LerpCorrection::LerpCorrection(LPoint3f& start, LVector3f& s_vel)
|
|
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) {
|
|
void LerpCorrection::set_duration(float d) {
|
|
|
dur = d;
|
|
dur = d;
|
|
|
}
|
|
}
|
|
@@ -104,13 +125,20 @@ void SplineCorrection::step(void) {
|
|
|
_curr_p = (tmp * tmp * tmp * A) + (tmp * tmp * B) + (tmp * C) + D;
|
|
_curr_p = (tmp * tmp * tmp * A) + (tmp * tmp * B) + (tmp * C) + D;
|
|
|
_curr_v = (3. * tmp * tmp * A) + (2. * tmp * B) + C;
|
|
_curr_v = (3. * tmp * tmp * A) + (2. * tmp * B) + C;
|
|
|
time += ClockObject::get_global_clock()->get_dt();
|
|
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) {
|
|
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;
|
|
return;
|
|
|
|
|
+ }
|
|
|
if (have_both) {
|
|
if (have_both) {
|
|
|
time = 0.;
|
|
time = 0.;
|
|
|
prev_p = _curr_p;
|
|
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;
|
|
B = (3. * (save_p - prev_p)) - (2. * prev_v) - save_v;
|
|
|
C = prev_v;
|
|
C = prev_v;
|
|
|
D = prev_p;
|
|
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 {
|
|
} else {
|
|
|
save_p = target;
|
|
save_p = target;
|
|
|
save_v = v_target;
|
|
save_v = v_target;
|
|
@@ -132,7 +167,25 @@ void SplineCorrection::new_target(LPoint3f& target, LVector3f& v_target) {
|
|
|
C = prev_v;
|
|
C = prev_v;
|
|
|
D = prev_p;
|
|
D = prev_p;
|
|
|
have_both = true;
|
|
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) {
|
|
void SplineCorrection::set_duration(float d) {
|