diff --git a/src/osg/AnimationPath.cpp b/src/osg/AnimationPath.cpp index 382e6e222..1c333fe3a 100644 --- a/src/osg/AnimationPath.cpp +++ b/src/osg/AnimationPath.cpp @@ -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; } diff --git a/src/osgUtil/Optimizer.cpp b/src/osgUtil/Optimizer.cpp index 5422fd113..bf0144c1f 100644 --- a/src/osgUtil/Optimizer.cpp +++ b/src/osgUtil/Optimizer.cpp @@ -41,7 +41,9 @@ void Optimizer::optimize(osg::Node* node, unsigned int options) if (options & SHARE_DUPLICATE_STATE) { - #if !defined(WIN32) || defined(_STLPORT_VERSION) + #if (defined(_MSC_VER) && _MSC_VER<13 && !defined(_STLPORT_VERSION)) + osg::notify(osg::INFO)<<"Warning: VisualStudio 6.0 build, unable to run state optimizer"<accept(osv); osv.optimize();