Fix 2809.

This commit is contained in:
hiker 2017-03-15 12:46:20 +11:00
parent 9bee42ccb7
commit 71f247ecb7
2 changed files with 7 additions and 7 deletions

View File

@ -534,18 +534,18 @@ void Ipo::update(float time, Vec3 *xyz, Vec3 *hpr,Vec3 *scale)
* the time. * the time.
* \param t Time for which m_next_n needs to be updated. * \param t Time for which m_next_n needs to be updated.
*/ */
void Ipo::updateNextN(float time) const void Ipo::updateNextN(float *time) const
{ {
time = m_ipo_data->adjustTime(time); *time = m_ipo_data->adjustTime(*time);
// Time was reset since the last cached value for n, // Time was reset since the last cached value for n,
// reset n to start from the beginning again. // reset n to start from the beginning again.
if (time < m_ipo_data->m_points[m_next_n - 1].getW()) if (*time < m_ipo_data->m_points[m_next_n - 1].getW())
m_next_n = 1; m_next_n = 1;
// Search for the first point in the (sorted) array which is greater or equal // Search for the first point in the (sorted) array which is greater or equal
// to the current time. // to the current time.
while (m_next_n < m_ipo_data->m_points.size() - 1 && while (m_next_n < m_ipo_data->m_points.size() - 1 &&
time >= m_ipo_data->m_points[m_next_n].getW()) *time >= m_ipo_data->m_points[m_next_n].getW())
{ {
m_next_n++; m_next_n++;
} // while } // while
@ -564,7 +564,7 @@ float Ipo::get(float time, unsigned int index) const
if(m_next_n==0) if(m_next_n==0)
return m_ipo_data->m_points[0][index]; return m_ipo_data->m_points[0][index];
updateNextN(time); updateNextN(&time);
float rval = m_ipo_data->get(time, index, m_next_n-1); float rval = m_ipo_data->get(time, index, m_next_n-1);
assert(!std::isnan(rval)); assert(!std::isnan(rval));
@ -587,7 +587,7 @@ void Ipo::getDerivative(float time, Vec3 *xyz)
return; return;
} }
updateNextN(time); updateNextN(&time);
switch (m_ipo_data->m_channel) switch (m_ipo_data->m_channel)
{ {
case Ipo::IPO_LOCX: xyz->setX(m_ipo_data->getDerivative(time, m_next_n, 0)); break; case Ipo::IPO_LOCX: xyz->setX(m_ipo_data->getDerivative(time, m_next_n, 0)); break;

View File

@ -116,7 +116,7 @@ private:
* it is declared mutable). */ * it is declared mutable). */
mutable unsigned int m_next_n; mutable unsigned int m_next_n;
void updateNextN(float time) const; void updateNextN(float *time) const;
Ipo(const Ipo *ipo); Ipo(const Ipo *ipo);
public: public: