Gems/EMotionFX/Code/EMotionFX/Source/MotionData/MotionData.cpp
void MotionData::CalculateInterpolationIndicesUniform(float sampleTime, float sampleSpacing, float duration, size_t numSamples, size_t& indexA, size_t& indexB, float& t)
    {
        if (sampleTime < 0.0f)
        {
            indexA = 0;
            indexB = 0;
            t = 0.0f;
            return;
        }

        if (sampleTime >= duration)
        {
            indexA = numSamples - 1;
            indexB = indexA;
            t = 0.0f;
            return;
        }

        indexA = static_cast<size_t>(floor(sampleTime / sampleSpacing));
        indexB = indexA + 1;

        if (indexB > numSamples - 1)
        {
            indexB = indexA;
            t = 0.0f;
            return;
        }

        t = (sampleTime - (indexA * sampleSpacing)) / sampleSpacing;
    }
// Based on a given time value, find the two keyframes to interpolate between, and calculate the t value, which is the interpolation weight between 0 and 1.
Based on a given time value, find the two keyframes to interpolate between, and calculate the t value, which is the interpolation weight between 0 and 1.
Based on a given time value find the two keyframes to interpolate between and calculate the t value which is the interpolation weight between 0 and 1 .
void MotionData::CalculateInterpolationIndicesUniform(float sampleTime, float sampleSpacing, float duration, size_t numSamples, size_t& indexA, size_t& indexB, float& t)
    {
        if (sampleTime < 0.0f)
        {
            indexA = 0;
            indexB = 0;
            t = 0.0f;
            return;
        }
        if (sampleTime >= duration)
        {
            indexA = numSamples - 1;
            indexB = indexA;
            t = 0.0f;
            return;
        }
        indexA = static_cast<size_t>(floor(sampleTime / sampleSpacing));
        indexB = indexA + 1;
        if (indexB > numSamples - 1)
        {
            indexB = indexA;
            t = 0.0f;
            return;
        }
        t = (sampleTime - (indexA * sampleSpacing)) / sampleSpacing;
    }
void MotionData :: CalculateInterpolationIndicesUniform ( float sampleTime , float sampleSpacing , float duration , size_t numSamples , size_t & indexA , size_t & indexB , float & t ) { if ( sampleTime < 0.0f ) { indexA = 0 ; indexB = 0 ; t = 0.0f ; return ; } if ( sampleTime >= duration ) { indexA = numSamples - 1 ; indexB = indexA ; t = 0.0f ; return ; } indexA = static_cast < size_t > ( floor ( sampleTime / sampleSpacing ) ) ; indexB = indexA + 1 ; if ( indexB > numSamples - 1 ) { indexB = indexA ; t = 0.0f ; return ; } t = ( sampleTime - ( indexA * sampleSpacing ) ) / sampleSpacing ; }
Based on a given time value, find the two keyframes to interpolate between, and calculate the t value, which is the interpolation weight between 0 and 1.
Based on a given time value find the two keyframes to interpolate between and calculate the t value which is the interpolation weight between 0 and 1 .