From 4354c0180c9205569cc8a6a1e52019fde8eb32d2 Mon Sep 17 00:00:00 2001 From: Cedric Pinson Date: Wed, 9 Jun 2010 13:09:40 +0000 Subject: [PATCH] From Michael Platings, The attached file fixes 2 issues: 1) some time values were passed as floats, reducing accuracy. 2) comparisons done between doubles and floats gave different results so time < endtime evaluated to false the first time it was checked (with doubles), and true the second time it was checked (with time having been converted to a float). This consequently resulted in an array-out-of-bounds crash --- include/osgAnimation/Interpolator | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/osgAnimation/Interpolator b/include/osgAnimation/Interpolator index a5bda3b0e..aafbe2a50 100644 --- a/include/osgAnimation/Interpolator +++ b/include/osgAnimation/Interpolator @@ -38,7 +38,7 @@ namespace osgAnimation TemplateInterpolatorBase() : _lastKeyAccess(-1) {} void reset() { _lastKeyAccess = -1; } - int getKeyIndexFromTime(const TemplateKeyframeContainer& keys, float time) const + int getKeyIndexFromTime(const TemplateKeyframeContainer& keys, double time) const { // todo use a cache int key_size = keys.size(); @@ -49,8 +49,8 @@ namespace osgAnimation const TemplateKeyframe* keysVector = &keys.front(); for (int i = 0; i < key_size-1; i++) { - float time0 = keysVector[i].getTime(); - float time1 = keysVector[i+1].getTime(); + double time0 = keysVector[i].getTime(); + double time1 = keysVector[i+1].getTime(); if ( time >= time0 && time < time1 ) { @@ -70,7 +70,7 @@ namespace osgAnimation public: TemplateStepInterpolator() {} - void getValue(const TemplateKeyframeContainer& keyframes, float time, TYPE& result) const + void getValue(const TemplateKeyframeContainer& keyframes, double time, TYPE& result) const { if (time >= keyframes.back().getTime()) @@ -96,7 +96,7 @@ namespace osgAnimation public: TemplateLinearInterpolator() {} - void getValue(const TemplateKeyframeContainer& keyframes, float time, TYPE& result) const + void getValue(const TemplateKeyframeContainer& keyframes, double time, TYPE& result) const { if (time >= keyframes.back().getTime()) @@ -124,7 +124,7 @@ namespace osgAnimation { public: TemplateSphericalLinearInterpolator() {} - void getValue(const TemplateKeyframeContainer& keyframes, float time, TYPE& result) const + void getValue(const TemplateKeyframeContainer& keyframes, double time, TYPE& result) const { if (time >= keyframes.back().getTime()) { @@ -152,7 +152,7 @@ namespace osgAnimation public: TemplateLinearPackedInterpolator() {} - void getValue(const TemplateKeyframeContainer& keyframes, float time, TYPE& result) const + void getValue(const TemplateKeyframeContainer& keyframes, double time, TYPE& result) const { if (time >= keyframes.back().getTime()) { @@ -182,7 +182,7 @@ namespace osgAnimation public: TemplateCubicBezierInterpolator() {} - void getValue(const TemplateKeyframeContainer& keyframes, float time, TYPE& result) const + void getValue(const TemplateKeyframeContainer& keyframes, double time, TYPE& result) const { if (time >= keyframes.back().getTime())