Added getInverse implementation to AnimationPath, and added #if guard

to Optimizer.cpp to all compilation on state optimizer when using VS7.
This commit is contained in:
Robert Osfield
2002-03-01 09:29:56 +00:00
parent 084ca39841
commit b13f7fecf6
2 changed files with 36 additions and 1 deletions

View File

@@ -46,4 +46,37 @@ bool AnimationPath::getMatrix(double time,Matrix& matrix)
bool AnimationPath::getInverse(double time,Matrix& matrix)
{
if (_timeKeyMap.empty()) return false;
TimeKeyMap::iterator second = _timeKeyMap.lower_bound(time);
if (second==_timeKeyMap.begin())
{
second->second.getInverse(matrix);
}
else if (second!=_timeKeyMap.end())
{
TimeKeyMap::iterator first = second;
--first;
// we have both a lower bound and the next item.
// deta_time = second.time - first.time
double delta_time = second->first - first->first;
if (delta_time==0.0)
first->second.getInverse(matrix);
else
{
Key key;
key.interpolate((time - first->first)/delta_time,
first->second,
second->second);
key.getInverse(matrix);
}
}
else // (second==_timeKeyMap.end())
{
_timeKeyMap.rbegin().base()->second.getInverse(matrix);
}
return true;
}