gwnavruntime/channel/channelarraycomputer.h Source File

channelarraycomputer.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 
20 
21 namespace Kaim
22 {
23 
24 class ChannelArrayComputer
25 {
26  KY_DEFINE_NEW_DELETE_OPERATORS(MemStat_QueryWorkingMem)
27 
28 public:
29  ChannelArrayComputer() { Clear(); }
30  ~ChannelArrayComputer() { Clear(); }
31 
32  void SetChannelComputerConfig(const ChannelComputerConfig& channelConfig) { m_channelConfig = channelConfig; }
33 
34  void* GetTraverseLogicUserData() const { return m_traverseLogicUserData; }
35  void SetTraverseLogicUserData(void* traverseLogicUserData) { m_traverseLogicUserData = traverseLogicUserData; }
36 
37  void Init(Path* rawPath, PathClamperFlagMask pathClamperFlagMask);
38  void Clear();
39 
40  template<class TLogic> void Advance(WorkingMemory* workingMemory);
41 
42  bool IsFinished() const { return m_result >= ChannelArrayResult_Error_NoRawPath; }
43  ChannelArrayComputerResult GetResult() const { return m_result; }
44 
45  template<class TLogic> KyResult FullCompute(WorkingMemory* workingMemory, Path* rawPath, PathClamperFlagMask pathClamperFlagMask, Ptr<Path>& pathWithChannels);
46 
47 private:
48  template <class TLogic> KyResult ComputePreChannelPolyline(WorkingMemory* workingMemory, Channel* channel);
49  template <class TLogic> KyResult ComputePostChannelPolyline(WorkingMemory* workingMemory, Channel* channel);
50  template <class TLogic> KyResult ComputePreOrPostPolylineSection(Database* database, WorkingMemory* workingMemory, const Vec3f& gatePathPos, const Vec3f& gateStartPos, const Vec3f& gateEndPos,
51  KyArray<Vec2f>& polyline);
52 
53  template<class TLogic> KyResult CreateAggregatedPath(WorkingMemory* workingMemory);
54  template<class TLogic> KyResult CreateChannelPath(Database* database, WorkingMemory* workingMemory, const Channel& channel, Ptr<Path>& channelPath);
55 
56  void UpdateChannelSectionFromPath(const Path* channelPath, KyUInt32 channelIdx, Ptr<Channel>& channel);
57 
58  KyResult FillAggregatedPathWithChannelPath(const Path* ChannelPath, KyUInt32& currentAggregatedPathEdgeIndex, KyInt32 clearanceDistanceInt, KyInt32 cellSizeInCoord);
59 
60  KyResult FillAggregatedPathWithRawPathSection(KyUInt32 firstEdgeIndex, KyUInt32 lastEdgeIndex, KyUInt32& currentAggregatedPathEdgeIndex);
61  void EnlargeCellBoxFromPolyline(const KyArray<Vec2f>& polyline, CellBox& cellBox);
62 
63  KyResult SplitChannelOnCollapsedSections(const Channel* originalChannel, KyUInt32 originalChannelStartPathNodeIdx, ChannelArray* finalChannelArray);
64 
65  // commented because not implemented
66  //bool GetNextEdgeOnNavMesh(const KyUInt32 currentEdgeIdx, KyUInt32& nextOnNavMeshEdgeIdx);
67  //bool GetNextEdgeNotOnNavMesh(const KyUInt32 currentEdgeIdx, KyUInt32& nextOnNavMeshEdgeIdx);
68 
69  void FindEndNodeIdxOfNavMeshSection();
70  void FindEndNodeIdxOfNonNavMeshSection();
71 
72  void SetPathNodeToPathWithChannels(const Path* path, KyUInt32 pathNodeIndex, KyUInt32 aggregatedPathNodeIndex);
73  void SetPathEdgeToPathWithChannels(const Path* path, KyUInt32 pathEdgeIndex, KyUInt32 aggregatedPathEdgeIndex);
74 
75  DisplayListManager* GetDisplayListManager();
76 
77 public:
78  ChannelComputerConfig m_channelConfig;
79  void* m_traverseLogicUserData;
80  PathClamperFlagMask m_pathClamperFlagMask;
81 
82  KyArray<KyUInt32> m_navGraphSectionBoundaryIndices;
83  KyUInt32 m_currentSectionStartNodeIdx;
84  KyUInt32 m_currentSectionEndNodeIdx;
85 
86  Ptr<Path> m_rawPath;
87  Ptr<ChannelArray> m_channelArray;
88  Ptr<Path> m_pathWithChannels;
89 
91 
92  Ptr<Channel> m_channelUnderConstruction;
93 
94  DiagonalStrip m_diagonalStrip;
95  BubbleArray m_bubbleArray;
96  StringPulledBubbleList m_stringPulledBubbleList;
97 
98  DiagonalStripComputer m_diagonalStripComputer;
99  StringPuller m_stringPuller;
100  GateArrayComputer m_gateArrayComputer;
101 
102  FullDebug m_fullDebug;
103  ChannelArrayComputerStats m_stats;
104 
105  // the multi frame display list ids that will be removed when the ChannelComputer is done
106  DiagonalStripDisplayListIds m_diagonalStripDisplayListIds;
107 };
108 
109 } // namespace Kaim
110 
111 
113 
114 
Box2i CellBox
A type that represents a bounding box around cells in a 2D grid.
Definition: navmeshtypes.h:31
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
std::int32_t KyInt32
int32_t
Definition: types.h:24
ChannelArrayComputerResult
ChannelArrayComputerResult.
Definition: channelarraycomputerresult.h:13