Returns lerp progress coefficient that should be used for animating.
557{
558 auto pFirstKeyTime = *
GetKey( 0 );
559
560 if ( a_iCurrentAnimTime < pFirstKeyTime || a_iCurrentAnimTime == pFirstKeyTime )
561 {
562
563 a_rCurrentKeyIndex = 0;
564 a_rLerpFromIndex = 0;
565 a_rLerpToIndex = 0;
566 return 0.0f;
567 }
568
569 auto iLastKeyIndex = m_iNumKeys - 1;
570 auto pLastKeyTime = *
GetKey( iLastKeyIndex );
571
572 if ( pLastKeyTime <= a_iCurrentAnimTime )
573 {
574
575 a_rCurrentKeyIndex = iLastKeyIndex;
576 a_rLerpFromIndex = iLastKeyIndex;
577 a_rLerpToIndex = iLastKeyIndex;
578 return 0.0f;
579 }
580
581 auto pCurrentKeyTime = *
GetKey( a_rCurrentKeyIndex );
582
583 if ( pCurrentKeyTime < a_iCurrentAnimTime )
584 {
585
586 auto iNextIndex = a_rCurrentKeyIndex + 1;
587 auto iNextKeyTime = *
GetKey( iNextIndex );
588
589 while ( iNextKeyTime <= a_iCurrentAnimTime )
590 {
591
592 a_rCurrentKeyIndex = iNextIndex++;
593 iNextKeyTime = *
GetKey( iNextIndex );
594 }
595
596 a_rLerpFromIndex = a_rCurrentKeyIndex;
597 a_rLerpToIndex = iNextIndex;
598 }
599 else
600 {
601 if ( pCurrentKeyTime == a_iCurrentAnimTime )
602 {
603
604 a_rLerpFromIndex = a_rCurrentKeyIndex;
605 a_rLerpToIndex = a_rCurrentKeyIndex;
606 return 0.0f;
607 }
608
609
610 auto iPrevIndex = a_rCurrentKeyIndex - 1;
611 auto iPrevKeyTime = *
GetKey( iPrevIndex );
612
613 while ( a_iCurrentAnimTime < iPrevKeyTime || a_iCurrentAnimTime == iPrevKeyTime )
614 {
615 a_rCurrentKeyIndex = iPrevIndex--;
616 iPrevKeyTime = *
GetKey( iPrevIndex );
617 }
618
619 a_rLerpFromIndex = iPrevIndex;
620 a_rLerpToIndex = a_rCurrentKeyIndex;
621 }
622
623 auto iLerpFromTime = *
GetKey( a_rLerpFromIndex );
624 auto iLerpToTime = *
GetKey( a_rLerpToIndex );
625
626 return ( ( a_iCurrentAnimTime - iLerpFromTime ) * ( 1.0f / 65535 ) ) / ( ( iLerpToTime - iLerpFromTime ) * ( 1.0f / 65535 ) );
627}
TFORCEINLINE uint16_t * GetKey(size_t a_iKeyIndex)