MCPcopy Create free account
hub / github.com/carbonengine/trinity / GetAnimationRemainingTime

Method GetAnimationRemainingTime

trinity/Tr2GrannyAnimationLayer.cpp:801–864  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

799}
800
801float Tr2GrannyAnimationLayer::GetAnimationRemainingTime()
802{
803 if( IsUsingCMF() )
804 {
805 if( !m_sequencer )
806 {
807 return 0.f;
808 }
809
810 float maxRemaining = 0.0f;
811 m_sequencer->EnumerateAnimations( [&]( const std::shared_ptr<cmf::AnimationPlayer>& player ) {
812 int loopCount = max( 0, player->GetLoopIndex( GetLayerAnimationTime() ) );
813 int newLoopCount = loopCount + 1;
814 int loopsTotal = player->GetLoopCount();
815
816 player->SetLoopCount( newLoopCount );
817 float remaining = player->GetDurationLeft( GetLayerAnimationTime() );
818 player->SetLoopCount( loopsTotal );
819 if( remaining > maxRemaining )
820 {
821 maxRemaining = remaining;
822 }
823 } );
824
825 return maxRemaining;
826 }
827#if WITH_GRANNY
828 else
829 {
830 if( !m_modelInstance )
831 {
832 return 0.f;
833 }
834
835 float maxRemaining = 0.0f;
836 for( granny_model_control_binding* binding = GrannyModelControlsBegin( m_modelInstance );
837 binding != GrannyModelControlsEnd( m_modelInstance );
838 binding = GrannyModelControlsNext( binding ) )
839 {
840 granny_control* control = GrannyGetControlFromBinding( binding );
841
842 // Force control to stop at the end of its current loop iteration
843 int loopCount = max( 0, GrannyGetControlLoopIndex( control ) );
844 int newLoopCount = loopCount + 1;
845 int loopsTotal = GrannyGetControlLoopCount( control );
846
847 GrannySetControlLoopCount( control, newLoopCount );
848 float remaining = GrannyGetControlDurationLeft( control );
849 GrannySetControlLoopCount( control, loopsTotal );
850 if( remaining > maxRemaining )
851 {
852 maxRemaining = remaining;
853 }
854 }
855
856 return maxRemaining;
857 }
858#else

Callers 2

IsAnimationPlayingFunction · 0.80
CanTransitionMethod · 0.80

Calls 2

IsUsingCMFFunction · 0.85
ifFunction · 0.50

Tested by

no test coverage detected