Show
Ignore:
Timestamp:
06/09/10 15:09:40 (4 years ago)
Author:
cedricpinson
Message:

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

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/trunk/include/osgAnimation/Interpolator

    r11009 r11594  
    3939 
    4040        void reset() { _lastKeyAccess = -1; } 
    41         int getKeyIndexFromTime(const TemplateKeyframeContainer<KEY>& keys, float time) const  
     41        int getKeyIndexFromTime(const TemplateKeyframeContainer<KEY>& keys, double time) const  
    4242        { 
    4343            // todo use a cache 
     
    5050            for (int i = 0; i < key_size-1; i++) 
    5151            { 
    52                 float time0 = keysVector[i].getTime(); 
    53                 float time1 = keysVector[i+1].getTime(); 
     52                double time0 = keysVector[i].getTime(); 
     53                double time1 = keysVector[i+1].getTime(); 
    5454 
    5555                if ( time >= time0 && time < time1 )  
     
    7171 
    7272        TemplateStepInterpolator() {} 
    73         void getValue(const TemplateKeyframeContainer<KEY>& keyframes, float time, TYPE& result) const  
     73        void getValue(const TemplateKeyframeContainer<KEY>& keyframes, double time, TYPE& result) const  
    7474        { 
    7575       
     
    9797 
    9898        TemplateLinearInterpolator() {} 
    99         void getValue(const TemplateKeyframeContainer<KEY>& keyframes, float time, TYPE& result) const  
     99        void getValue(const TemplateKeyframeContainer<KEY>& keyframes, double time, TYPE& result) const  
    100100        { 
    101101       
     
    125125    public: 
    126126        TemplateSphericalLinearInterpolator() {} 
    127         void getValue(const TemplateKeyframeContainer<KEY>& keyframes, float time, TYPE& result) const  
     127        void getValue(const TemplateKeyframeContainer<KEY>& keyframes, double time, TYPE& result) const  
    128128        { 
    129129            if (time >= keyframes.back().getTime())  
     
    153153 
    154154        TemplateLinearPackedInterpolator() {} 
    155         void getValue(const TemplateKeyframeContainer<KEY>& keyframes, float time, TYPE& result) const  
     155        void getValue(const TemplateKeyframeContainer<KEY>& keyframes, double time, TYPE& result) const  
    156156        { 
    157157            if (time >= keyframes.back().getTime())  
     
    183183 
    184184        TemplateCubicBezierInterpolator() {} 
    185         void getValue(const TemplateKeyframeContainer<KEY>& keyframes, float time, TYPE& result) const  
     185        void getValue(const TemplateKeyframeContainer<KEY>& keyframes, double time, TYPE& result) const  
    186186        { 
    187187