gwnavruntime/abstractgraph/blobs/abstractgraphdatagenerator.h Source File

abstractgraphdatagenerator.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 
19 
20 
21 
22 namespace Kaim
23 {
24 
25 class FileOpenerBase;
26 
34 {
35  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_NavDataGen)
36 public:
37  static const char* GetFileExtension() { return "AbstractData"; }
38 public:
40  : m_boxExtentInCellSize(10)
41  , m_navMeshBlob(nullptr)
42  , m_abstractGraphCount(0)
43  , m_result(KY_SUCCESS)
44  {
45  m_tmpCellFilter = *KY_NEW CellFilter;
46  }
47 
48  void SetOutputDirectory(const char* absoluteOutputBaseDir, const char* relativeOutputDir);
49  KyResult InitFromFilename(Ptr<Database> database, const char* navDataFileName, FileOpenerBase* fileOpener = nullptr);
50  KyResult InitFromFile(Ptr<Database> database, File* navDataFile);
51  KyResult InitFromMemory(Ptr<Database> database, void* memory);
52  KyResult InitFromNavData(Ptr<NavData> navData);
53 
54  void SetExtentInNumberOfCells(KyInt32 abstractGraphBoxExtentInCellSize) { m_boxExtentInCellSize = abstractGraphBoxExtentInCellSize; }
55 
56  KyResult Generate();
57 
58  KyResult SaveAbstractGraphData(const char* sectorName, FileOpenerBase* fileOpener = nullptr, Endianness::Type endianness = Endianness::LittleEndian);
59 
60  void ClearAndRelease()
61  {
62  m_abstractGraphBlobHandlers.ClearAndRelease();
63  m_tmpAbstractGraphBorderAsCellPos.ClearAndRelease();
64  m_tmpBoundaryFlagsPerCellOnBorder.ClearAndRelease();
65  m_abstractGraphCount = 0;
66  m_abstractGraphGenerator.ClearAndRelease();
67  }
68 
69 public: // internal
70 
71  // Fulfill m_tmpAbstractGraphBorderAsCellPos with CellPos defining the border of the AbstractGraph (different from the boundary of the cellBox)
72  // Fulfill m_tmpBoundaryFlagsPerCellOnBorder with a mask of Kaim::CardinalDir defining the border on the cell
73  // Load the cell from NavData that are in the given cellBox
74  // Call DoGenerateAbstractGraph
75  KyResult GenerateOneAbstractGraphFromCellBox(const CellBox& cellBox);
76  KyResult DoGenerateAbstractGraph();
77 
78 public:
79  // ---------------- Input ------------------
80 
81  Ptr<Database> m_database;
82  Ptr<NavData> m_navData;
83 
84  String m_absoluteOutputBaseDir;
85  String m_relativeOutputDir;
86 
87  KyInt32 m_boxExtentInCellSize;
88 
89  // ---------------- Used over several calls to DoGenerateAbstractGraph ------------------
90 
91  NavMeshElementBlob* m_navMeshBlob; //< from m_navdata
92  CellBox m_navDataCellBox; //< from m_navdata
93 
94  AbstractGraphGenerator m_abstractGraphGenerator;
95  KyUInt32 m_abstractGraphCount;
96  KyArray< Ptr< BlobHandler<AbstractGraphBlob> > > m_abstractGraphBlobHandlers;
97 
98  AbstractGraphGenerationReport m_report;
99 
100  // ---------------- Used into DoGenerateAbstractGraph, setup by calling functions ------------------
101  // m_tmpAbstractGraphBorderAsCellPos and m_tmpBoundaryFlagsPerCellOnBorder are expected to contain the same number of AbstractGraph
102 
103  Ptr<CellFilter> m_tmpCellFilter;
104  KyArrayPOD<CellPos> m_tmpAbstractGraphBorderAsCellPos; //< defines the CellPos of the border of the AbstractGraph, hence the CellPos expected to be used to create nodes of the AbstractGraph
105  KyArrayPOD<KyUInt8> m_tmpBoundaryFlagsPerCellOnBorder; //< defines the boundaries to test for the cell at CellPos given (same index in m_tmpAbstractGraphBorderAsCellPos)
106 
107  // ---------------- Output result ------------------
108  KyResult m_result;
109 };
110 
111 }
112 
General purpose array for movable objects that DOES NOT require construction/destruction.
Definition: kyarray.h:194
Base interface for a class that opens a file on disk.
Definition: fileopener.h:30
2d axis aligned box of 32bits integers. Very Important: CountX() returns m_max.x - m_min...
Definition: box2i.h:17
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
General purpose array for movable objects that require explicit construction/destruction.
Definition: kyarray.h:162
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Usage: AbstractGraphDataGenerator gen; gen.InitFromXxxx() gen.Generate() gen.SaveAbstractGraphData() ...
Definition: abstractgraphdatagenerator.h:33
Little-endian format (used, for example, for Windows, Linux).
Definition: endianness.h:22
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
The NavMeshElementBlob contains the NavMesh static data (a set of NavCellBlob) for an element (a Guid...
Definition: navmeshelementblob.h:46
std::int32_t KyInt32
int32_t
Definition: types.h:24
Type
Enumerates possible endianness types.
Definition: endianness.h:20