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

Method OnTick

trinity/TriDevice.cpp:697–846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

695static const float ANIMATION_TIME_MAX = 3600.0f; // One hour
696
697void TriDevice::OnTick( Be::Time realTime, Be::Time simTime, void* cookie )
698{
699 CCP_STATS_SCOPED_TIME( deviceOnTick );
700
701 // Start with statistics on frame time
702 static BeTimer s_frameTimer;
703 static const int s_fpsValuesCount = 64;
704 static double s_frameTimeValues[s_fpsValuesCount] = { 0.0 };
705 static double s_generatedFrames[s_fpsValuesCount] = { 0 };
706
707 static double s_frameTimeSum = 0.0;
708 static int s_currentFpsValue = 0;
709 static double s_generatedFpsSum = 0;
710
711 double frameTime = s_frameTimer.GetSeconds();
712#if CCP_STATS_ENABLED
713 //CCP_STATS_SET
714 g_ccpStatistics_activeFrameTime.Set( frameTime - g_ccpStatistics_presentTime.GetValue() - g_ccpStatistics_throttleTime.GetValue() );
715 g_ccpStatistics_frameTime.Set( frameTime );
716 if( g_ccpStatistics_frameTimeMin.GetValue() > 0 )
717 {
718 g_ccpStatistics_frameTimeMin.Set( std::min( frameTime, g_ccpStatistics_frameTimeMin.GetValue() ) );
719 }
720 else
721 {
722 g_ccpStatistics_frameTimeMin.Set( frameTime );
723 }
724 g_ccpStatistics_frameTimeMax.Set( std::max( frameTime, g_ccpStatistics_frameTimeMax.GetValue() ) );
725#endif
726
727 if( frameTime > 0.5f )
728 {
729 CCP_STATS_INC( frameTimeAbove500ms );
730 }
731 else if( frameTime > 0.4f )
732 {
733 CCP_STATS_INC( frameTimeAbove400ms );
734 }
735 else if( frameTime > 0.3f )
736 {
737 CCP_STATS_INC( frameTimeAbove300ms );
738 }
739 else if( frameTime > 0.2f )
740 {
741 CCP_STATS_INC( frameTimeAbove200ms );
742 }
743 else if( frameTime > 0.1f )
744 {
745 CCP_STATS_INC( frameTimeAbove100ms );
746 }
747
748 double fps = 0.0;
749 if( frameTime > 0.0 )
750 {
751 fps = 1.0 / frameTime;
752 }
753
754 CCP_STATS_SET( fpsRaw, fps );

Callers

nothing calls this directly

Calls 5

to_stringFunction · 0.85
ExecuteMainThreadActionsFunction · 0.85
SetMethod · 0.45
GetValueMethod · 0.45
ResetMethod · 0.45

Tested by

no test coverage detected