gwnavruntime/world/worldstatistics.h Source File

worldstatistics.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 #pragma once
9 
15 
16 namespace Kaim
17 {
18 
19 class World;
20 class VisualDebugAttributeGroup;
21 class VisualDebugServer;
22 
23 
24 enum WorldUpdateStep
25 {
26  WorldUpdateStep_WorldUpdate = 0,
27  WorldUpdateStep_WorldUpdateAllButVisualDebug ,
28  WorldUpdateStep_SendVisualDebugData ,
29  WorldUpdateStep_ProcessQueuesInWorldUpdate ,
30  WorldUpdateStep_FlushQueries ,
31  WorldUpdateStep_UpdateDatabases ,
32  WorldUpdateStep_UpdateDynamicNavMesh ,
33  WorldUpdateStep_UpdateSpatializations ,
34  WorldUpdateStep_UpdateBotsPathFollowing ,
35  WorldUpdateStep_QueryQueueProcess ,
36 
37  WorldUpdateStepIndex_Count
38 };
39 
40 enum WorldSummaryAttributes
41 {
42  WorldSummaryAttributes_worldUpdateStat,
43  WorldSummaryAttributes_visualDebugTime,
44  WorldSummaryAttributes_queriesTime,
45  WorldSummaryAttributes_navdata_count,
46  WorldSummaryAttributes_bot_count,
47  WorldSummaryAttributes_obstacle_count,
48  WorldSummaryAttributes_tagvolume_count,
49  WorldSummaryAttributes_database_count,
50  WorldSummaryAttributes_memory_footprint
51 };
52 
53 enum CountersAttributes
54 {
55  CountersAttributes_NotEmptyDatabaseCount ,
56  CountersAttributes_MaxDatabasesCount ,
57  CountersAttributes_DatabaseUpdateStatus ,
58  CountersAttributes_DatabaseUpdateWaitingDynamicNavMeshQueryCount,
59  CountersAttributes_DatabaseUpdateWaitingNavMeshStitchQueryCount,
60  CountersAttributes_NavDataCount ,
61  CountersAttributes_NavDataToBeAddedCount ,
62  CountersAttributes_NavDataBeingAddedCount ,
63  CountersAttributes_NavDataToBeRemovedCount ,
64  CountersAttributes_NavDataBeingRemovedCount ,
65  CountersAttributes_BotCount ,
66  CountersAttributes_ObstaclesTotalCount ,
67  CountersAttributes_BoxObstaclesCount ,
68  CountersAttributes_CylinderObstaclesCount ,
69  CountersAttributes_TagVolumeTotalCount ,
70  CountersAttributes_TagVolumeToBeIntegratedCount,
71  CountersAttributes_TagVolumeIntegratedCount ,
72  CountersAttributes_TagVolumeToBeRemovedCount ,
73  CountersAttributes_PointOfInterestCount
74 };
75 
76 enum MemoryAttributes
77 {
78  MemoryAttributes_TotalFootprint,
79  MemoryAttributes_TotalUsedSpace
80 };
81 
82 enum SettingsAttributes
83 {
84  SettingsAttributes_NbFramesForShortcutTrajectoryPeriodicUpdate,
85 };
86 
87 // This class is not instantiated in the world when KY_CONFIG_RELEASE is defined
88 class WorldStatistics
89 {
90  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
91 
92 public:
93  WorldStatistics()
94  : m_world(nullptr)
95  , m_navdataCount(0)
96  , m_botsCount(0)
97  , m_boxObstaclesCount(0)
98  , m_cylinderObstaclesCount(0)
99  , m_pointsOfInterestCount(0)
100  , m_tagVolumesToBeIntegratedCount(0)
101  , m_tagVolumesIntegratedCount(0)
102  , m_tagVolumesToBeRemovedCount(0)
103  , m_databasesCount(0)
104  , m_notEmptyDatabaseCount(0)
105  , m_summaryAttributesGroup(nullptr)
106  , m_profilingAttributesGroup(nullptr)
107  , m_countersAttributesGroup(nullptr)
108  , m_settingsAttributesGroup(nullptr)
109  {}
110 
111  void Initialize(World* world);
112 
113  const FloatStat& GetWorldUpdateStepStat(WorldUpdateStep worldStat) const { return m_worldUpdateStepStats[worldStat]; }
114 
115  void Update();
116  void UpdateVisualDebug();
117  void ResetStatValues();
118 
119  KyFloat32* GetWorldUpdateStepTimeToUpdate(WorldUpdateStep worldStat);
120 
121  void CreateSummaryAttributes();
122  void UpdateSummaryAttributes();
123  void CreateProfilingStatsAttributeGroup();
124  void UpdateProfilingStatsAttributeGroup();
125  void CreateCountersAttributeGroup();
126  void UpdateCountersAttributeGroup();
127  void CreateSettingsAttributeGroup();
128  void UpdateSettingsAttributeGroup();
129 
130  void Report(StringBuffer* report) const;
131 
132 public:
133  World* m_world;
134 
135  KyArray<FloatStat> m_worldUpdateStepStats;
136 
137  // total in all databases
138  KyUInt32 m_navdataCount;
139  KyUInt32 m_navdataToBeAddedCount;
140  KyUInt32 m_navdataBeingAddedCount;
141  KyUInt32 m_navdataToBeRemovedCount;
142  KyUInt32 m_navdataBeingRemovedCount;
143  KyUInt32 m_botsCount;
144 
145  KyUInt32 m_boxObstaclesCount;
146  KyUInt32 m_cylinderObstaclesCount;
147  KyUInt32 m_pointsOfInterestCount;
148  KyUInt32 m_tagVolumesToBeIntegratedCount;
149  KyUInt32 m_tagVolumesIntegratedCount;
150  KyUInt32 m_tagVolumesToBeRemovedCount;
151  KyUInt32 m_databasesCount;
152  KyUInt32 m_notEmptyDatabaseCount;
153 
154  VisualDebugAttributeGroup* m_summaryAttributesGroup;
155  VisualDebugAttributeGroup* m_profilingAttributesGroup;
156  VisualDebugAttributeGroup* m_countersAttributesGroup;
157  VisualDebugAttributeGroup* m_settingsAttributesGroup;
158 };
159 
160 #if defined(KY_CONFIG_DEBUG_OR_DEV)
161 // to use only in World::Update() "sub functions"
162 // we may divide the number of Timer calls in WorldUpdate by 2
163 #define KY_PROFILE_WORLD_UPDATE_STEP(x) \
164 ScopedProfilerMs scopedProfilerMs(this->m_statistics->GetWorldUpdateStepTimeToUpdate(WorldUpdateStep_##x)); \
165 KY_SCOPED_PERF_MARKER("World::" #x);
166 #else
167 #define KY_PROFILE_WORLD_UPDATE_STEP(x)
168 #endif
169 
170 } // namespace Kaim
171 
172 
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
float KyFloat32
float
Definition: types.h:32