gwnavruntime/world/worldstatistics.h Source File

worldstatistics.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 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 // primary contact: GUAL - secondary contact: NOBODY
9 
10 #ifndef Navigation_WorldStatistics_H
11 #define Navigation_WorldStatistics_H
12 
18 
19 namespace Kaim
20 {
21 
22 class World;
23 class VisualDebugAttributeGroup;
24 class VisualDebugServer;
25 
26 
27 enum WorldUpdateStep
28 {
29  WorldUpdateStep_WorldUpdate = 0,
30  WorldUpdateStep_WorldUpdateAllButVisualDebug ,
31  WorldUpdateStep_SendVisualDebugData ,
32  WorldUpdateStep_ProcessQueuesInWorldUpdate ,
33  WorldUpdateStep_FlushQueries ,
34  WorldUpdateStep_UpdateDatabases ,
35  WorldUpdateStep_UpdateDynamicNavMesh ,
36  WorldUpdateStep_UpdateSpatializations ,
37  WorldUpdateStep_UpdateBotsPathFollowing ,
38  WorldUpdateStep_QueryQueueProcess ,
39 
40  WorldUpdateStepIndex_Count
41 };
42 
43 enum WorldSummaryAttributes
44 {
45  WorldSummaryAttributes_worldUpdateStat,
46  WorldSummaryAttributes_visualDebugTime,
47  WorldSummaryAttributes_queriesTime,
48  WorldSummaryAttributes_navdata_count,
49  WorldSummaryAttributes_bot_count,
50  WorldSummaryAttributes_obstacle_count,
51  WorldSummaryAttributes_tagvolume_count,
52  WorldSummaryAttributes_database_count,
53  WorldSummaryAttributes_memory_footprint
54 };
55 
56 enum CountersAttributes
57 {
58  CountersAttributes_NavDataCount ,
59  CountersAttributes_NotEmptyDatabaseCount ,
60  CountersAttributes_MaxDatabasesCount ,
61  CountersAttributes_BotCount ,
62  CountersAttributes_ObstaclesTotalCount ,
63  CountersAttributes_BoxObstaclesCount ,
64  CountersAttributes_CylinderObstaclesCount ,
65  CountersAttributes_TagVolumeTotalCount ,
66  CountersAttributes_TagVolumeToBeIntegratedCount,
67  CountersAttributes_TagVolumeIntegratedCount ,
68  CountersAttributes_TagVolumeToBeRemovedCount ,
69  CountersAttributes_PointOfInterestCount
70 };
71 
72 enum MemoryAttributes
73 {
74  MemoryAttributes_TotalFootprint,
75  MemoryAttributes_TotalUsedSpace
76 };
77 
78 enum SettingsAttributes
79 {
80  SettingsAttributes_NbFramesForShortcutTrajectoryPeriodicUpdate,
81 };
82 
83 // This class is not instantiated in the world when KY_BUILD_SHIPPING is defined
84 class WorldStatistics
85 {
86  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_WorldFwk)
87 
88 public:
89  WorldStatistics()
90  : m_world(KY_NULL)
91  , m_navdataCount(0)
92  , m_botsCount(0)
93  , m_boxObstaclesCount(0)
94  , m_cylinderObstaclesCount(0)
95  , m_pointsOfInterestCount(0)
96  , m_tagVolumesToBeIntegratedCount(0)
97  , m_tagVolumesIntegratedCount(0)
98  , m_tagVolumesToBeRemovedCount(0)
99  , m_databasesCount(0)
100  , m_notEmptyDatabaseCount(0)
101  , m_summaryAttributesGroup(KY_NULL)
102  , m_profilingAttributesGroup(KY_NULL)
103  , m_countersAttributesGroup(KY_NULL)
104  , m_settingsAttributesGroup(KY_NULL)
105  {}
106 
107  void Initialize(World* world);
108 
109  const FloatStat& GetWorldUpdateStepStat(WorldUpdateStep worldStat) const { return m_worldUpdateStepStats[worldStat]; }
110 
111  void Update();
112  void UpdateVisualDebug();
113  void ResetStatValues();
114 
115  KyFloat32* GetWorldUpdateStepTimeToUpdate(WorldUpdateStep worldStat);
116 
117  void CreateSummaryAttributes();
118  void UpdateSummaryAttributes();
119  void CreateProfilingStatsAttributeGroup();
120  void UpdateProfilingStatsAttributeGroup();
121  void CreateCountersAttributeGroup();
122  void UpdateCountersAttributeGroup();
123  void CreateSettingsAttributeGroup();
124  void UpdateSettingsAttributeGroup();
125 
126  void Report(StringBuffer* report) const;
127 
128 public:
129  World* m_world;
130 
131  KyArray<FloatStat> m_worldUpdateStepStats;
132 
133  KyUInt32 m_navdataCount; // total in all databases
134  KyUInt32 m_botsCount;
135  KyUInt32 m_boxObstaclesCount;
136  KyUInt32 m_cylinderObstaclesCount;
137  KyUInt32 m_pointsOfInterestCount;
138  KyUInt32 m_tagVolumesToBeIntegratedCount;
139  KyUInt32 m_tagVolumesIntegratedCount;
140  KyUInt32 m_tagVolumesToBeRemovedCount;
141  KyUInt32 m_databasesCount;
142  KyUInt32 m_notEmptyDatabaseCount;
143 
144  VisualDebugAttributeGroup* m_summaryAttributesGroup;
145  VisualDebugAttributeGroup* m_profilingAttributesGroup;
146  VisualDebugAttributeGroup* m_countersAttributesGroup;
147  VisualDebugAttributeGroup* m_settingsAttributesGroup;
148 };
149 
150 #ifndef KY_BUILD_SHIPPING
151 // to use only in World::Update() "sub functions"
152 // we may divide the number of Timer calls in WorldUpdate by 2
153 #define KY_PROFILE_WORLD_UPDATE_STEP(x) \
154 ScopedProfilerMs scopedProfilerMs(this->m_statistics->GetWorldUpdateStepTimeToUpdate(WorldUpdateStep_##x)); \
155 KY_SCOPED_PERF_MARKER("World::" #x);
156 #else
157 #define KY_PROFILE_WORLD_UPDATE_STEP(x)
158 #endif
159 
160 } // namespace Kaim
161 
162 #endif
163 
#define KY_NULL
Null value.
Definition: types.h:247
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43