like that

This commit is contained in:
Cary Sandvig 2001-04-12 17:55:06 +00:00
parent 1facd208fd
commit 08315e791d
3 changed files with 67 additions and 2 deletions

View File

@ -41,12 +41,11 @@ private:
template <class value>
class SimpleLerpFunctor : public LerpFunctor {
private:
protected:
value _start;
value _end;
value _diff_cache;
protected:
value interpolate(float);
SimpleLerpFunctor(value start, value end) : LerpFunctor(), _start(start),
_end(end), _diff_cache(end-start)

View File

@ -37,6 +37,26 @@ void PosLerpFunctor::operator()(float t) {
HprLerpFunctor::HprLerpFunctor(const HprLerpFunctor& c)
: LVecBase3fLerpFunctor(c), _node_path(c._node_path) {}
void HprLerpFunctor::take_shortest(void) {
// so long as these are actually degrees
for (int i=0; i!=3; ++i)
if (this->_diff_cache[i] < -180.)
_start[i] -= 360.;
else if (this->_diff_cache[i] > 180.)
_start[i] += 360.;
this->_diff_cache = this->_end - this->_start;
}
void HprLerpFunctor::take_longest(void) {
// so long as these are actually degrees
for (int i=0; i!=3; ++i)
if ((this->_diff_cache[i] < 0.) && (this->_diff_cache[i] > -180.))
_start[i] -= 360.;
else if ((this->_diff_cache[i] >= 0.) && (this->_diff_cache[i] < 180))
_start[i] += 360.;
this->_diff_cache = this->_end - this->_start;
}
HprLerpFunctor::~HprLerpFunctor(void)
{
}
@ -95,6 +115,26 @@ void ColorLerpFunctor::operator()(float t) {
PosHprLerpFunctor::PosHprLerpFunctor(const PosHprLerpFunctor& c)
: LerpFunctor(c), _node_path(c._node_path) {}
void PosHprLerpFunctor::take_shortest(void) {
// so long as these are actually degrees
for (int i=0; i!=3; ++i)
if (this->_hdiff_cache[i] < -180.)
_hstart[i] -= 360.;
else if (this->_hdiff_cache[i] > 180.)
_hstart[i] += 360.;
this->_hdiff_cache = this->_hend - this->_hstart;
}
void PosHprLerpFunctor::take_longest(void) {
// so long as these are actually degrees
for (int i=0; i!=3; ++i)
if ((this->_hdiff_cache[i] < 0.) && (this->_hdiff_cache[i] > -180.))
_hstart[i] -= 360.;
else if ((this->_hdiff_cache[i] >= 0.) && (this->_hdiff_cache[i] < 180))
_hstart[i] += 360.;
this->_hdiff_cache = this->_hend - this->_hstart;
}
PosHprLerpFunctor::~PosHprLerpFunctor(void)
{
}
@ -123,6 +163,26 @@ void PosHprLerpFunctor::operator()(float t) {
PosHprScaleLerpFunctor::PosHprScaleLerpFunctor(const PosHprScaleLerpFunctor& c)
: LerpFunctor(c), _node_path(c._node_path) {}
void PosHprScaleLerpFunctor::take_shortest(void) {
// so long as these are actually degrees
for (int i=0; i!=3; ++i)
if (this->_hdiff_cache[i] < -180.)
_hstart[i] -= 360.;
else if (this->_hdiff_cache[i] > 180.)
_hstart[i] += 360.;
this->_hdiff_cache = this->_hend - this->_hstart;
}
void PosHprScaleLerpFunctor::take_longest(void) {
// so long as these are actually degrees
for (int i=0; i!=3; ++i)
if ((this->_hdiff_cache[i] < 0.) && (this->_hdiff_cache[i] > -180.))
_hstart[i] -= 360.;
else if ((this->_hdiff_cache[i] >= 0.) && (this->_hdiff_cache[i] < 180))
_hstart[i] += 360.;
this->_hdiff_cache = this->_hend - this->_hstart;
}
PosHprScaleLerpFunctor::~PosHprScaleLerpFunctor(void)
{
}

View File

@ -87,6 +87,8 @@ PUBLISHED:
float ez, NodePath wrt)
: LVecBase3fLerpFunctor(LVecBase3f(sx, sy, sz), LVecBase3f(ex, ey, ez)),
_node_path(np), _is_wrt(true), _wrt_path(wrt) {}
void take_shortest(void);
void take_longest(void);
public:
HprLerpFunctor(const HprLerpFunctor&);
@ -260,6 +262,8 @@ PUBLISHED:
_pend(pex, pey, pez), _pdiff_cache(_pend-_pstart),
_hstart(hsx, hsy, hsz), _hend(hex, hey, hez),
_hdiff_cache(_hend - _hstart), _is_wrt(true), _wrt_path(wrt) {}
void take_shortest(void);
void take_longest(void);
public:
PosHprLerpFunctor(const PosHprLerpFunctor&);
@ -343,6 +347,8 @@ PUBLISHED:
_hdiff_cache(_hend-_hstart), _sstart(ssx, ssy, ssz),
_send(sex, sey, sez), _sdiff_cache(_send-_sstart), _is_wrt(true),
_wrt_path(wrt) {}
void take_shortest(void);
void take_longest(void);
public:
PosHprScaleLerpFunctor(const PosHprScaleLerpFunctor&);