BVB Source Codes

CRYENGINE Show StatsManager.cpp Source code

Return Download CRYENGINE: download StatsManager.cpp Source code - Download CRYENGINE Source code - Type:.cpp
  1. // Copyright 2001-2016 Crytek GmbH / Crytek Group. All rights reserved.
  2.  
  3. // -------------------------------------------------------------------------
  4. //  File name:   StatsManager.cpp
  5. //  Created:     15/09/2008 by Matthew
  6. //  Description: Stores global AI statistics and provides display/output methods
  7. // -------------------------------------------------------------------------
  8. //  History:
  9. //
  10. ////////////////////////////////////////////////////////////////////////////
  11.  
  12. #include "StdAfx.h"
  13. #include "StatsManager.h"
  14. #include "DebugDrawContext.h"
  15.  
  16. #pragma warning (disable: 6313)
  17.  
  18. // Useful formatting strings
  19. // 30 characters total are allowed for this in the standard view!
  20. // 20 (max) of those are usually used for the short description
  21. const static char* sFmtDefault = "%s: %3.1f";
  22.  
  23. void CStatsManager::InitDescriptions()
  24. {
  25.         // The list of statistics metadata
  26.         static const SStatMetadata sMetadata[] = {
  27.                 { "Enabled AI Actors",   eSF_FrameReset | eSF_Integer, 0 },
  28.                 { "AI full updates",     eSF_FrameReset,               0 },
  29.                 { "TPS queries (sync)",  eSF_FrameReset,               0 },
  30.                 { "TPS queries (async)", eSF_FrameReset,               0 },
  31.         };
  32.  
  33.         // Make sure that the number of descriptions never varies from the size of the enum
  34.         // That should be enough to avoid descriptions and enums from getting out of step
  35.         PREFAST_SUPPRESS_WARNING(6326) static_assert(CRY_ARRAY_COUNT(sMetadata) == eStat_Last, "Unexpected array size!");
  36.  
  37.         m_sMetadata = sMetadata;
  38. }
  39.  
  40. CStatsManager::CStatsManager(void)
  41. {
  42.         m_fValues = new float[eStat_Last];
  43.  
  44.         InitDescriptions();
  45.  
  46.         Reset(eStatReset_All);
  47. }
  48.  
  49. CStatsManager::~CStatsManager(void)
  50. {
  51.         delete[] m_fValues;
  52. }
  53.  
  54. void CStatsManager::Reset(EStatsReset eReset)
  55. {
  56.         // Reset some or all of the stats values
  57.         for (uint32 i = 0; i < eStat_Last; i++)
  58.         {
  59.                 switch (eReset)
  60.                 {
  61.                 case eStatReset_Frame:
  62.                         if (!(m_sMetadata[i].flags & eSF_FrameReset))
  63.                                 break;
  64.                 // Otherwise, fall-through
  65.                 case eStatReset_All:
  66.                         m_fValues[i] = 0.0f;
  67.                 }
  68.         }
  69. }
  70.  
  71. void CStatsManager::Render()
  72. {
  73.         CDebugDrawContext dc;
  74.  
  75.         static float xPos = 78.0f;
  76.         static float yPos = 45.0f;
  77.         static float yStep = 2.0;
  78.  
  79.         if (gAIEnv.CVars.StatsDisplayMode == 0)
  80.                 return;
  81.  
  82.         float yOffset = 0.0f;
  83.  
  84.         const char sTitle[30] = "------- AI Statistics -------";
  85.         dc->TextToScreen(xPos, yPos, sTitle);
  86.         yOffset += yStep;
  87.  
  88.         for (uint32 i = 0; i < eStat_Last; i++, yOffset += yStep)
  89.         {
  90.                 const SStatMetadata& metadata = m_sMetadata[i];
  91.                 const char* sFormSpec = metadata.format ? metadata.format : sFmtDefault;
  92.                 dc->TextToScreen(xPos, yPos + yOffset, sFormSpec, metadata.description, m_fValues[i]);
  93.         }
  94. }
  95.  
downloadStatsManager.cpp Source code - Download CRYENGINE Source code
Related Source Codes/Software:
postal - 2017-06-11
reactide - Reactide is the first dedicated IDE for React web ... 2017-06-11
rkt - rkt is a pod-native container engine for Linux. It... 2017-06-11
uWebSockets - Tiny WebSockets https://for... 2017-06-11
realworld - TodoMVC for the RealWorld - Exemplary fullstack Me... 2017-06-11
CRYENGINE - CRYENGINE is a powerful real-time game development... 2017-06-11
goreplay - GoReplay is an open-source tool for capturing and ... 2017-06-10
pyenv - Simple Python version management 2017-06-10
redux-saga - An alternative side effect model for Redux apps ... 2017-06-10
angular-starter - 2017-06-10

 Back to top