gwnavruntime/visualsystem/idisplaylistbuilder.h Source File

idisplaylistbuilder.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 #pragma once
8 
12 
13 namespace Kaim
14 {
15 
16 class DisplayList;
17 
18 enum DisplayListBuilderParamType
19 {
20  DisplayListBuilderParamType_Int,
21  DisplayListBuilderParamType_Float,
22  DisplayListBuilderParamType_Bool
23 };
24 
25 class DisplayListBuilderParam
26 {
27 public:
28  DisplayListBuilderParam()
29  : m_name("Unset")
30  , m_groupName("Unset")
31  , m_type(DisplayListBuilderParamType_Bool)
32  , m_intValue(0)
33  , m_floatValue(0.0f)
34  {}
35 
36 public:
37  String m_name;
38  String m_groupName;
39  DisplayListBuilderParamType m_type;
40  KyInt32 m_intValue; // Stores the integer and boolean value depending on the param type
41  KyFloat32 m_floatValue;
42 };
43 
44 // Key, type, value configuration
45 // NOTE:
46 // Create an enum to allow direct access to each value.
47 // In Add***Param, for each value, pass the corresponding enum to paramEnum.
48 // e.g.:
49 // - Write param => AddIntParam("Nearest bot index", 0, NEAREST_BOT_INDEX);
50 // - Read param => KyInt32 myParam = config.GetIntParam(NEAREST_BOT_INDEX);
51 //
52 class DisplayListBuilderConfig
53 {
54 public:
55  void Init(KyUInt32 paramNumbers);
56  //void AddIntParam (const char* name, KyInt32 defaultValue , KyUInt32 paramEnum, const char* groupName = "");
57  //void AddFloatParam(const char* name, KyFloat32 defaultValue, KyUInt32 paramEnum, const char* groupName = "");
58  void AddBoolParam (const char* name, bool defaultValue , KyUInt32 paramEnum, const char* groupName = "");
59 
60  //KyInt32 GetIntParam (KyUInt32 paramEnum);
61  //KyFloat32 GetFloatParam(KyUInt32 paramEnum);
62  bool GetBoolParam (KyUInt32 paramEnum);
63 
64  //void SetIntParam (KyUInt32 paramEnum, KyInt32 value);
65  //void SetFloatParam(KyUInt32 paramEnum, KyFloat32 value);
66  void SetBoolParam (KyUInt32 paramEnum, bool value);
67 
68 public:
69  KyArray<DisplayListBuilderParam> m_params;
70 };
71 
72 
73 // Interface that fills a displayList from a blob.
74 // Used in practice to take QueryBlobs
75 class IDisplayListBuilder
76 {
77  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_VisualSystem)
78 public:
79  IDisplayListBuilder() : m_doBuild(true) {}
80  virtual ~IDisplayListBuilder() {}
81 
82 public:
83  void Build(DisplayList* displayList, char* blob, KyUInt32)
84  {
85  if (m_doBuild)
86  DoBuild(displayList, blob);
87  }
88 
89 private:
90  // 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!
91  // Recommendation is to associate the instance of IDisplayListBuilder to the blob type thanks to UserBlobRegistry!
92  // You can setup a configuration in the Init function, and use it during DoBuild in order to allow the user to setup
93  // the way the display list is built.
94  virtual void DoBuild(DisplayList* displayList, char* blob) = 0;
95 
96 public:
97  bool m_doBuild;
98  //DisplayListBuilderConfig m_config;
99 
100 protected:
101  static bool IsVisualDebugSupported(DisplayList* displayList); // helper
102 };
103 
104 
105 // Registry that associates Blobs to IDisplayListBuilder
106 // This is called in the game to send visual debug display lists for Queries run in the Game
107 // This is called in the Lab to create visual debug display lists for Queries run in the Lab
108 void RegisterDisplayListBuilders(UserBlobRegistry<IDisplayListBuilder>& registry);
109 
110 }
111 
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
std::int32_t KyInt32
int32_t
Definition: types.h:24
float KyFloat32
float
Definition: types.h:32