gwnavgeneration/generator/generatornavdatafilter.h Source File

generatornavdatafilter.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 
8 #pragma once
9 
10 
17 
18 
19 namespace Kaim
20 {
21 
22 class GeneratorNavDataElement;
23 class NavMeshElementManager;
24 class NavMeshElement;
25 class Database;
26 class DynamicNavFloor;
27 class NavFloor;
28 // GeneratorNavDataFilter is where we detect connected components and we discard parts of the NavMesh (aka NavDataElement) if...
29 // - part is not reachable from a seedpoint with PerformFilteringFromSeed()
30 // - part surface is less than a threshold with PerformFilteringFromSurfaces()
31 class GeneratorNavDataFilter
32 {
33  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
34 
35 public:
36  GeneratorNavDataFilter(GeneratorNavDataElement& navDataElement);
37 
38  KyResult PerformFilteringFromSeed(KyArray<Vec3f>& seedpoints);
39 
40  KyResult PerformFilteringFromSurfaces(const KyFloat32 minSurfaceOfConnectedComponent);
41 
42 private:
43  friend class GeneratorConnectComponentTraversal;
44  friend class NavCellCleaner_BlobBuilder;
45 
46  enum ConnectedComponentStatus
47  {
48  ConnectedComponentStatus_NOSEED,
49  ConnectedComponentStatus_SEED
50  };
51 
52  struct ConnectedComponentData
53  {
54  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
55  public:
56  ConnectedComponentData() : m_status(ConnectedComponentStatus_NOSEED), m_surface(0.0f) {}
57  explicit ConnectedComponentData(KyFloat32 surfaceInit) : m_status(ConnectedComponentStatus_NOSEED), m_surface(surfaceInit) {}
58 
59  ConnectedComponentStatus m_status;
60  KyFloat32 m_surface;
61  };
62 
63  KyUInt32 ComputeConnectedComponent(NavMeshElement& navMeshElement);
64 
65  void FilterConnectedComponentFromSeedPoints(const KyArray<Vec3f>& seedpoints);
66 
67  void FilterConnectedComponentFromOtherNavMeshInvolvedInOverlap(NavMeshElement& navMeshElement);
68  void AddAllInvolvedNavMeshInOverlapToNavMeshElementManager(KyArrayPOD<NavMeshElement*>& addedNavMeshs);
69  void RemoveAllInvolvedNavMeshInOverlapFromNavMeshElementManager(KyArrayPOD<NavMeshElement*>& addedNavMeshs);
70 
71  void ComputeConnectedComponentSurface(NavMeshElement& navMeshElement);
72 
73  KyResult CleanNavMeshElement(NavMeshElement& navMeshElement);
74  void BuildNewNavCell(NavMeshElement& navMeshElement, KyUInt32 navCellIdx, KyArray<BitField>& connexFilterStatus);
75  void BuildNewFloor(DynamicNavFloor& floor, NavFloor* navFloor, BitField& connexStatus);
76 
77  void ResizeConnectedComponentDataTableWithDefaultValue(KyUInt32 size, KyFloat32 defaultValue);
78 
79 public:
80  GeneratorNavDataElement* m_navDataElement;
81  Ptr<World> m_world;
82  Database* m_database;
83  NavMeshElementManager* m_navMeshElementManager;
84  KyArray<ConnectedComponentData> m_connectedComponents;
85 };
86 
87 
88 }
89 
90 
91 
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
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
float KyFloat32
float
Definition: types.h:32