OpenBarnyard
 
Loading...
Searching...
No Matches
TSkeletonSequenceBone Class Reference

#include <TSkeleton.h>

Public Member Functions

TFLOAT GetKeyPair (TINT a_iCurrentAnimProgress, TUINT16 &a_rCurrentKeyIndex, TUINT16 &a_rLerpFromIndex, TUINT16 &a_rLerpToIndex)
 Returns lerp progress coefficient that should be used for animating.
 
TFORCEINLINE uint16_t * GetKey (size_t a_iKeyIndex)
 
TFORCEINLINE TUINT16 GetKeyCount () const
 
TFORCEINLINE TBOOL IsTranslateAnimated () const
 
TFORCEINLINE TBOOL IsOverlayAnimated () const
 
TFORCEINLINE uint8_t GetFlags () const
 

Detailed Description

Definition at line 16 of file TSkeleton.h.

Member Function Documentation

◆ GetFlags()

TFORCEINLINE uint8_t TSkeletonSequenceBone::GetFlags ( ) const
inline

Definition at line 48 of file TSkeleton.h.

49 {
50 return m_eFlags;
51 }

◆ GetKey()

TFORCEINLINE uint16_t * TSkeletonSequenceBone::GetKey ( size_t a_iKeyIndex)
inline

Definition at line 28 of file TSkeleton.h.

29 {
30 return TREINTERPRETCAST( uint16_t*, a_iKeyIndex * m_iKeySize + TREINTERPRETCAST( uintptr_t, m_pData ) );
31 }
#define TREINTERPRETCAST(TYPE, VALUE)
Definition Defines.h:68

◆ GetKeyCount()

TFORCEINLINE TUINT16 TSkeletonSequenceBone::GetKeyCount ( ) const
inline

Definition at line 33 of file TSkeleton.h.

34 {
35 return m_iNumKeys;
36 }

◆ GetKeyPair()

TFLOAT TSkeletonSequenceBone::GetKeyPair ( TINT a_iCurrentAnimProgress,
TUINT16 & a_rCurrentKeyIndex,
TUINT16 & a_rLerpFromIndex,
TUINT16 & a_rLerpToIndex )

Returns lerp progress coefficient that should be used for animating.

Parameters
a_iCurrentAnimProgressThe current progress of animation from 0 to 65535
a_rCurrentKeyIndexThe index of current frame
a_rLerpFromIndexThe index of key that is being interpolated from
a_rLerpToIndexThe index of key to which previous is being interpolated to

Definition at line 556 of file TSkeleton.cpp.

557{
558 auto pFirstKeyTime = *GetKey( 0 );
559
560 if ( a_iCurrentAnimTime < pFirstKeyTime || a_iCurrentAnimTime == pFirstKeyTime )
561 {
562 // Animation haven't reached it's first frame
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 // Animation is over
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 // Current key is currently lerping
586 auto iNextIndex = a_rCurrentKeyIndex + 1;
587 auto iNextKeyTime = *GetKey( iNextIndex );
588
589 while ( iNextKeyTime <= a_iCurrentAnimTime )
590 {
591 // Skip keys that are already over
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 // Current time is right at the end of keys transition
604 a_rLerpFromIndex = a_rCurrentKeyIndex;
605 a_rLerpToIndex = a_rCurrentKeyIndex;
606 return 0.0f;
607 }
608
609 // The animation is playing backwards?
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)
Definition TSkeleton.h:28

◆ IsOverlayAnimated()

TFORCEINLINE TBOOL TSkeletonSequenceBone::IsOverlayAnimated ( ) const
inline

Definition at line 43 of file TSkeleton.h.

44 {
45 return m_eFlags & 2;
46 }

◆ IsTranslateAnimated()

TFORCEINLINE TBOOL TSkeletonSequenceBone::IsTranslateAnimated ( ) const
inline

Definition at line 38 of file TSkeleton.h.

39 {
40 return m_eFlags & 1;
41 }

The documentation for this class was generated from the following files: