gwnavgamekit/gamekitcrowddispersion.h Source File

gamekitcrowddispersion.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 
9 #ifndef Navigation_GameKitCrowdDispersion_H
10 #define Navigation_GameKitCrowdDispersion_H
11 
13 
18 
19 
20 namespace Kaim
21 {
22 
23 class NavGraphBlob;
24 class NavGraphEdgeRawPtr;
25 class TagVolume;
26 class GameKitNavTag;
27 class NavData;
28 class ScopedDisplayList;
29 
30 
31 class GameKitCrowdDispersionInput
32 {
33 public:
34  GameKitCrowdDispersionInput() : m_speed(-1.f) {}
35 
36  GameKitCrowdDispersionInput(const Vec3f& position, KyFloat32 speed)
37  : m_position(position), m_speed(speed) {}
38 
39 public:
40  Vec3f m_position;
41  KyFloat32 m_speed;
42 };
43 
44 class GameKitCrowdDispersionNavTag : public RefCountBase<GameKitCrowdDispersionNavTag, MemStat_GameKit>
45 {
46  KY_CLASS_WITHOUT_COPY(GameKitCrowdDispersionNavTag)
47 public:
48  GameKitCrowdDispersionNavTag(const Vec3f& refPos = Vec3f(), KyFloat32 length = 1.f, KyUInt32 expectedMaxCountPerSlot = 1, KyFloat32 intervalTimePerSlot = 0.5f);
49 
50 
51  KyUInt32 GetTimeIntervaldxFromInputExisting(const GameKitCrowdDispersionInput& input);
52 
53  KyFloat32 GetAdditionalCostMultiplier(const GameKitCrowdDispersionInput& input);
54 
55  void Register(const GameKitCrowdDispersionInput& input);
56 
57  void Unregister(const GameKitCrowdDispersionInput& input);
58 
59  KyUInt32 GetTimeIntervalSize() { return m_count.GetCount(); }
60 
61  KyFloat32 GetFirstArrivalTime() { return m_firstArrivalTime; }
62  KyUInt32 GetCountAtTimeInterval(KyUInt32 timeIntervalIdx) { return m_count[timeIntervalIdx]; }
63  KyUInt32 GetThresholdCountPerInterval() { return m_thresholdCountPerInterval; }
64 
65  void SendVisualDebug(ScopedDisplayList& displayList, const GameKitCrowdDispersionInput& input);
66 
67 private:
68  KyUInt32 m_thresholdCountPerInterval;
69  Vec3f m_referencePosition;
70  KyFloat32 m_length;
71  KyFloat32 m_intervalTimePerSlot;
72 
73  KyFloat32 m_firstArrivalTime; // gives the arrival time of the first interval (factor of intervalTimePerSlot)
74  CircularArray<KyUInt32> m_count; // count of registrations per time interval
75 
76 };
77 
78 
81 {
82 public:
84 
85  bool operator == (const GameKitCrowdDispersionNavTagId& other) const { return m_layerIndex == other.m_layerIndex && m_smartObjectID == other.m_smartObjectID;}
86  bool operator != (const GameKitCrowdDispersionNavTagId& other) const { return (*this == other) == false;}
87 
88  bool IsValid() const { return *this != GameKitCrowdDispersionNavTagId(); }
89 
90 public:
91  KyUInt32 m_layerIndex;
92  KyUInt32 m_smartObjectID;
93 };
94 
96 class GameKitCrowdDispersionNavTagHashMap : public RefCountBase<GameKitCrowdDispersionNavTagHashMap, MemStat_GameKit>
97 {
98  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_GameKit)
99 
100 public:
101  const Ptr<GameKitCrowdDispersionNavTag> Get(const GameKitCrowdDispersionNavTagId& navTagId) const;
102  Ptr<GameKitCrowdDispersionNavTag> Get(const GameKitCrowdDispersionNavTagId& navTagId);
103  bool Get(const GameKitCrowdDispersionNavTagId& navTagId, Ptr<GameKitCrowdDispersionNavTag>* crowdDispersionNavTag) const;
104 
106  KyResult Add(const TagVolume* tagVolume, Vec3f expectedTraversedPoints[2], KyUInt32 expectedMaxCountPerSlot = 1, KyFloat32 intervalTimePerSlot = 0.5f);
108  KyResult Add(const TagVolume* tagVolume, KyFloat32 length, KyUInt32 expectedMaxCountPerSlot = 1, KyFloat32 intervalTimePerSlot = 0.5f);
109 
113  KyResult Add(const NavGraphEdgeRawPtr& graphEdge, KyUInt32 expectedMaxCountPerSlot = 1, KyFloat32 intervalTimePerSlot = 0.5f);
114 
116  void Add(const NavData* navGraphOnlyNavData, KyUInt32 expectedMaxCountPerSlot = 1, KyFloat32 intervalTimePerSlot = 0.5f);
117 
118  KyResult Add(const GameKitCrowdDispersionNavTagId& navTagId, Ptr<GameKitCrowdDispersionNavTag> navTagCrowdDispersion);
119  void Remove(const GameKitCrowdDispersionNavTagId& navTagId);
120 
121  void Clear();
122 
123 public: // internal
124  void Add(const NavGraphBlob* navGraphBlob, KyUInt32 expectedMaxCountPerSlot = 1, KyFloat32 intervalTimePerSlot = 0.5f);
125 
126  typedef Hash<GameKitCrowdDispersionNavTagId, Ptr<GameKitCrowdDispersionNavTag> >::ConstIterator ConstIterator;
127  ConstIterator Begin() const;
128  ConstIterator End() const;
129 
130 private:
131  Hash<GameKitCrowdDispersionNavTagId, Ptr<GameKitCrowdDispersionNavTag> > m_hash;
132 };
133 
134 }
135 
136 #endif
The NavGraphBlob contains the static data of a NavGraph.
Definition: navgraphblob.h:21
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
Used to uniquely identify GameKitNavTag, c.f. GameKitNavTag for more information. ...
Definition: gamekitcrowddispersion.h:84
Each instance of this class uniquely identifies a single NavGraphEdge in a NavGraph.
Definition: navgraphedgerawptr.h:33
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
This class represents runtime-defined volumes with customized NavTag.
Definition: tagvolume.h:108
KyResult Add(const TagVolume *tagVolume, Vec3f expectedTraversedPoints[2], KyUInt32 expectedMaxCountPerSlot=1, KyFloat32 intervalTimePerSlot=0.5f)
Extract id from TagVolume.
The NavData class is the object containing navigation data that will be added to one Database...
Definition: navdata.h:44
Define an interpretation of NavTag specific to GameKit.
Definition: gamekitnavtag.h:24
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137
ScopedDisplayList is used to push text, lines or shapes for rendering in the NavigationLab e...
Definition: displaylist.h:136
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
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23