gwnavruntime/world/worldelement.h Source File

worldelement.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 // Authors: GUAL, JUBA
9 #ifndef Navigation_WorldElement_H
10 #define Navigation_WorldElement_H
11 
12 
17 
18 namespace Kaim
19 {
20 
21 class World;
22 class VisualDebugServer;
23 
24 
27 {
28  VisualDebugLOD_None = 0,
29  VisualDebugLOD_Default,
30  VisualDebugLOD_Maximal,
31  VisualDebugLOD_Undefined = KyUInt32MAXVAL
32 };
33 
34 
35 enum VisualDebugSendChangeEvent
36 {
37  VisualDebugSendChangeEvent_NoChange = 0, // Happens most of the time and means you can send your data only when they have changed
38  VisualDebugSendChangeEvent_OnLODChanged, // Happens when the level of detail has changed and means you must send or remove (send a VisualDebugDataRemovalBlob) all data according to the LOD change
39  VisualDebugSendChangeEvent_ForceSendAll // Happens on connection with a visual debug client (eg: NavigationLab) or when WorldElement::ForceSendAllvisualDebug is called. Means you must send all data describing your element for current LOD.
40 };
41 
42 
45 class WorldElement : public RefCountBase<WorldElement, Stat_Default_Mem>
46 {
47 public:
48  // ---------------------------------- Main API Functions ----------------------------------
49 
50  WorldElement(World* world = KY_NULL)
51  : m_currentVisualDebugLOD(VisualDebugLOD_Undefined)
52  , m_previousVisualDebugLOD(VisualDebugLOD_Undefined)
53  { MakeZeroWorldElement(); m_world = world; }
54 
55  virtual ~WorldElement() {}
56 
57  virtual WorldElementType GetType() const = 0;
58  virtual const char* GetTypeName() const = 0;
59 
60  bool IsAddedToWorld() const { return m_indexInCollection != KyUInt32MAXVAL; }
61  World* GetWorld() const { return m_world; }
62  KyUInt32 GetVisualDebugId() const { return m_visualDebugId; }
63  void* GetUserData() const { return m_userData; }
64 
65  void SetUserData(void* userData) { m_userData = userData; }
66 
67 
68  // ---------------------------------- Visual Debug ----------------------------------
69 
76 
77  VisualDebugLOD GetCurrentVisualDebugLOD() const { return m_currentVisualDebugLOD; }
78  VisualDebugLOD GetPreviousVisualDebugLod() const { return m_previousVisualDebugLOD; }
79  void SendVisualDebug(VisualDebugServer& server);
80 
85 
86 
87 public: // internal
88 
89  // Called at each update on all registered WorldElement. Consider the event
90  // to decide what to send.
91  virtual void DoSendVisualDebug(VisualDebugServer&, VisualDebugSendChangeEvent) {}
92  void SendForMaxLevelOfDetail(VisualDebugServer& server, const Vec3f& shapePosition);
93 
94  // visual debug registry
95  void RegisterToVisualDebug();
96  void UnRegisterFromVisualDebug();
97 
98  // for O(1) remove from world collections
99  KyUInt32 GetIndexInCollection() const { return m_indexInCollection; }
100  void SetIndexInCollection(KyUInt32 indexInCollection) { m_indexInCollection = indexInCollection; }
101 
102 protected:
103  void MakeZeroWorldElement();
104 
105 protected:
106  World* m_world;
107  KyUInt32 m_indexInCollection; // for O(1) remove from world collections
108  KyUInt32 m_visualDebugId; // TODO: 30 bits is enough merge it into 1 UINT32
109  VisualDebugLOD m_currentVisualDebugLOD; // TODO: 4 bits are enough merge it into 1 UINT32
110  VisualDebugLOD m_previousVisualDebugLOD; // TODO: 4 bits are enough merge it into 1 UINT32
111  bool m_forceSendAllVisualDebugData;
112  void* m_userData;
113 
114 friend class VisualDebugRegistry;
115 };
116 
117 
118 #ifndef KY_BUILD_SHIPPING
119 KY_INLINE void WorldElement::SetCurrentVisualDebugLOD(VisualDebugLOD lod) { m_currentVisualDebugLOD = lod; }
120 
121 #else // VisualDebug is disabled in Shipping mode
122 
124 
125 KY_INLINE void WorldElement::RegisterToVisualDebug() {}
126 KY_INLINE void WorldElement::UnRegisterFromVisualDebug() {}
127 KY_INLINE void WorldElement::ForceSendAllVisualDebug() {}
128 KY_INLINE void WorldElement::SendVisualDebug(VisualDebugServer&) {}
129 KY_INLINE void WorldElement::SendForMaxLevelOfDetail(VisualDebugServer&, const Vec3f&) {}
130 #endif
131 
132 
133 }
135 #endif
void SetCurrentVisualDebugLOD(VisualDebugLOD lod)
Set the visual debug level of details to use for this WorldElement instance.
Definition: worldelement.h:134
void ForceSendAllVisualDebug()
Call this when something impacts all your visual debug data.
#define KY_NULL
Null value.
Definition: types.h:247
This class is a runtime container for Gameware Navigation WorldElements such as NavData, Bots, BoxObstacles, TagVolumes...
Definition: world.h:54
WorldElementType
Enumerates the WorldElement types.
Definition: worldelementtype.h:15
Base internal class used to represent elements that can be added to a World, such as instances of Dat...
Definition: worldelement.h:45
Definition: gamekitcrowddispersion.h:20
The VisualDebugServer manages the sending of data to clients.
Definition: visualdebugserver.h:254
VisualDebugLOD
Enumerates the visual debug levels of details.
Definition: worldelement.h:26
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23