gwnavruntime/visualsystem/idisplaylistbuilder.h Source File

idisplaylistbuilder.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: MAMU - secondary contact: BRGR
9 #ifndef Navigation_IDisplayListBuilder_H
10 #define Navigation_IDisplayListBuilder_H
11 
15 
16 namespace Kaim
17 {
18 
19 class ScopedDisplayList;
20 
21 enum DisplayListBuilderParamType
22 {
23  DisplayListBuilderParamType_Int,
24  DisplayListBuilderParamType_Float,
25  DisplayListBuilderParamType_Bool
26 };
27 
28 class DisplayListBuilderParam
29 {
30 public:
31  DisplayListBuilderParam()
32  : m_name("Unset")
33  , m_groupName("Unset")
34  , m_type(DisplayListBuilderParamType_Bool)
35  , m_intValue(0)
36  , m_floatValue(0.0f)
37  {}
38 
39 public:
40  String m_name;
41  String m_groupName;
42  DisplayListBuilderParamType m_type;
43  KyInt32 m_intValue; // Stores the integer and boolean value depending on the param type
44  KyFloat32 m_floatValue;
45 };
46 
47 // Key, type, value configuration
48 // NOTE:
49 // Create an enum to allow direct access to each value.
50 // In Add***Param, for each value, pass the corresponding enum to paramEnum.
51 // e.g.:
52 // - Write param => AddIntParam("Nearest bot index", 0, NEAREST_BOT_INDEX);
53 // - Read param => KyInt32 myParam = config.GetIntParam(NEAREST_BOT_INDEX);
54 //
55 class DisplayListBuilderConfig
56 {
57 public:
58  void Init(KyUInt32 paramNumbers);
59  void AddIntParam (const char* name, KyInt32 defaultValue , KyUInt32 paramEnum, const char* groupName = "");
60  void AddFloatParam(const char* name, KyFloat32 defaultValue, KyUInt32 paramEnum, const char* groupName = "");
61  void AddBoolParam (const char* name, bool defaultValue , KyUInt32 paramEnum, const char* groupName = "");
62 
63  KyInt32 GetIntParam (KyUInt32 paramEnum);
64  KyFloat32 GetFloatParam(KyUInt32 paramEnum);
65  bool GetBoolParam (KyUInt32 paramEnum);
66 
67  void SetIntParam (KyUInt32 paramEnum, KyInt32 value);
68  void SetFloatParam(KyUInt32 paramEnum, KyFloat32 value);
69  void SetBoolParam (KyUInt32 paramEnum, bool value);
70 
71 public:
72  KyArray<DisplayListBuilderParam> m_params;
73 };
74 
75 
76 // Interface to help to fulfill a displayList from a blob
77 class IDisplayListBuilder
78 {
79  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_VisualSystem)
80 public:
81  IDisplayListBuilder() : m_doBuild(true) {}
82  virtual ~IDisplayListBuilder() {}
83 
84 public:
85  void Build(ScopedDisplayList* displayList, char* blob, KyUInt32 deepBlobSize)
86  {
87  if (m_doBuild)
88  DoBuild(displayList, blob, deepBlobSize);
89  }
90 
91 private:
92  // It is the caller's responsability to ensure that the given void* is really pointing to a blob of the blob type expected by the implementation!
93  // Recommendation is to associate the instance of IDisplayListBuilder to the blob type thanks to UserBlobRegistry!
94  // You can setup a configuration in the Init function, and use it during DoBuild in order to allow the user to setup
95  // the way the display list is built.
96  virtual void DoBuild(ScopedDisplayList* displayList, char* blob, KyUInt32 deepBlobSize = 0) = 0;
97 
98 public:
99  bool m_doBuild;
100  DisplayListBuilderConfig m_config;
101 
102 protected:
103  static bool IsVisualDebugSupported(ScopedDisplayList* displayList); // helper
104 };
105 
106 
107 // Registry that associates blobs to IDisplayListBuilder
108 // Intended to be used to fulfill the displayList client-side (typically this is done by the NavigationLab)
109 void RegisterDisplayListBuilders(UserBlobRegistry<IDisplayListBuilder>& registry);
110 
111 }
112 
113 #endif // Navigation_DisplayList_H
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
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