gwnavruntime/channel/channelarraycomputer.h Source File

channelarraycomputer.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: LAPA - secondary contact: NOBODY
9 
10 #ifndef Navigation_ChannelArrayComputer_H
11 #define Navigation_ChannelArrayComputer_H
12 
21 
23 
24 
25 namespace Kaim
26 {
27 
29 {
32 
33  ChannelArrayResult_StartNewPathSection,
34  ChannelArrayResult_ComputingChannel_DiagonalStrip_Init,
35  ChannelArrayResult_ComputingChannel_DiagonalStrip,
36  ChannelArrayResult_ComputingChannel_StringPull_Init,
37  ChannelArrayResult_ComputingChannel_StringPull,
38  ChannelArrayResult_ComputingChannel_GateArray_Init,
39  ChannelArrayResult_ComputingChannel_GateArray,
40  ChannelArrayResult_ComputingChannel_PreChannelPolyline,
41  ChannelArrayResult_ComputingChannel_PostChannelPolyline,
42  ChannelArrayResult_ComputingAggregatedPath,
43  ChannelArrayResult_ComputingChannelWidth,
44 
45  ChannelArrayResult_Error_InvalidRawPath,
46  ChannelArrayResult_Error_ChannelComputation_DiagonalStrip,
47  ChannelArrayResult_Error_ChannelComputation_StringPull,
48  ChannelArrayResult_Error_ChannelComputation_GateArray,
49  ChannelArrayResult_Error_ChannelComputation_PreChannelPolyline,
50  ChannelArrayResult_Error_ChannelComputation_PostChannelPolyline,
51  ChannelArrayResult_Error_PathAggregation,
52  ChannelArrayResult_Error_ChannelWidthComputation,
53 
54  ChannelArrayResult_Done
55 };
56 
57 class ChannelArrayComputer
58 {
59  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_QueryWorkingMem)
60 
61 public:
62  ChannelArrayComputer();
63  ~ChannelArrayComputer();
64 
65  void SetChannelComputerConfig(const ChannelComputerConfig& channelComputerConfig) { m_channelComputerConfig = channelComputerConfig; }
66 
67  void* GetTraverseLogicUserData() const { return m_traverseLogicUserData; }
68  void SetTraverseLogicUserData(void* traverseLogicUserData) { m_traverseLogicUserData = traverseLogicUserData; }
69 
70 
71  void Init(Path* rawPath, PathClamperFlagMask pathClamperFlagMask);
72  void Clear();
73 
74  template<class TraverseLogic>
75  void Advance(WorkingMemory* workingMemory);
76  bool IsFinished() const { return m_result >= ChannelArrayResult_Error_InvalidRawPath; }
77  ChannelArrayComputerResult GetResult() const { return m_result; }
78 
79  template<class TraverseLogic>
80  KyResult FullCompute(WorkingMemory* workingMemory, Path* rawPath, PathClamperFlagMask pathClamperFlagMask, Ptr<Path>& pathWithChannels);
81 
82 private:
83  template<class TLogic>
84  KyResult ComputePreChannelPolyline(WorkingMemory* workingMemory, Channel* channel);
85  template<class TLogic>
86  KyResult ComputePostChannelPolyline(WorkingMemory* workingMemory, Channel* channel);
87  template<class TLogic>
88  KyResult ComputeChannelPolylineSection(Database* database, WorkingMemory* workingMemory,
89  const Vec3f& gatePathPos, const Vec3f& gateStartPos, const Vec3f& gateEndPos, KyArray<Vec2f>& polyline);
90 
91  template<class TLogic>
92  KyResult CreateAggregatedPath(WorkingMemory* workingMemory);
93 
94  template<class TLogic>
95  KyResult CreateChannelPath(Database* database, WorkingMemory* workingMemory, const Channel& channel, Ptr<Path>& channelPath);
96 
97  void UpdateChannelSectionFromPath(const Path* channelPath, KyUInt32 channelIdx, Ptr<Channel>& channel);
98 
99  KyResult FillAggregatedPathWithChannelPath(const Path* ChannelPath, KyUInt32& currentAggregatedPathEdgeIndex,
100  KyInt32 clearanceDistanceInt, KyInt32 cellSizeInCoord);
101 
102  KyResult FillAggregatedPathWithRawPathSection(KyUInt32 firstEdgeIndex, KyUInt32 lastEdgeIndex, KyUInt32& currentAggregatedPathEdgeIndex);
103  void EnlargeCellBoxFromPolyline(const KyArray<Vec2f>& polyline, CellBox& cellBox);
104 
105  KyResult SplitChannelOnCollapsedSections(const Channel* originalChannel, KyUInt32 originalChannelStartPathNodeIdx, ChannelArray* finalChannelArray);
106 
107  bool GetNextEdgeOnNavMesh(const KyUInt32 currentEdgeIdx, KyUInt32& nextOnNavMeshEdgeIdx);
108  bool GetNextEdgeNotOnNavMesh(const KyUInt32 currentEdgeIdx, KyUInt32& nextOnNavMeshEdgeIdx);
109 
110  void FindEndNodeIdxOfNavMeshSection();
111  void FindEndNodeIdxOfNonNavMeshSection();
112 
113  void SetPathNodeToPathWithChannels(const Path* path, KyUInt32 pathNodeIndex, KyUInt32 aggregatedPathNodeIndex);
114  void SetPathEdgeToPathWithChannels(const Path* path, KyUInt32 pathEdgeIndex, KyUInt32 aggregatedPathEdgeIndex);
115 
116 
117 public:
118  ChannelComputerConfig m_channelComputerConfig;
119  void* m_traverseLogicUserData;
120  PathClamperFlagMask m_pathClamperFlagMask;
121 
122  KyArray<KyUInt32> m_navGraphSectionBoundaryIndices;
123  KyUInt32 m_currentSectionStartNodeIdx;
124  KyUInt32 m_currentSectionEndNodeIdx;
125 
126  Ptr<Path> m_rawPath;
127  Ptr<ChannelArray> m_channelArray;
128  Ptr<Path> m_pathWithChannels;
129 
131 
132  Ptr<Channel> m_channelUnderConstruction;
133 
134  DiagonalStrip m_diagonalStrip;
135  BubbleArray m_bubbleArray;
136  StringPulledBubbleList m_stringPulledBubbleList;
137 
138  DiagonalStripComputer m_diagonalStripComputer;
139  StringPuller m_stringPuller;
140  GateArrayComputer m_gateArrayComputer;
141 
142  bool m_advancedVisualDebuggingEnabled;
143  ChannelArrayComputerStats m_stats;
144 
145 };
146 
147 } // namespace Kaim
148 
149 
151 
152 
153 #endif // Navigation_ChannelArrayComputer_H
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:34
Indicates the query has not yet been launched.
Definition: channelarraycomputer.h:31
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
Definition: gamekitcrowddispersion.h:20
Indicates that the query has not yet been initialized.
Definition: iquery.h:346
#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
Indicates that the query has not yet been launched.
Definition: iquery.h:347
ChannelArrayComputerResult
Definition: channelarraycomputer.h:28
Indicates the query has not yet been initialized.
Definition: channelarraycomputer.h:30