gwnavruntime/channel/gatearraycomputer.h Source File

gatearraycomputer.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 
21 
22 
23 namespace Kaim
24 {
25 
27 {
30 
31  GateArrayComputerResult_ComputingGateDefinitions,
32  GateArrayComputerResult_WidenChannel_FirstGate,
33  GateArrayComputerResult_WidenChannel_TurnGates,
34  GateArrayComputerResult_WidenChannel_LastGate,
35 
36  GateArrayComputerResult_Done_InputError,
37  GateArrayComputerResult_Done_Error,
38  GateArrayComputerResult_Done_GateDefinitionComputerError,
39  GateArrayComputerResult_Done_IntermediateGatesError,
40 
41  GateArrayComputerResult_Done
42 };
43 
44 class GateArrayComputer
45 {
46  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
47 public:
48  GateArrayComputer() { Clear(); }
49 
50  void Initialize(Database* database, const ChannelComputerConfig& config, const StringPulledBubbleList& stringPulledBubbleList, Channel* channel, const FullDebug& fullDebug);
51  void SetTraverseLogicUserData(void* traverseLogicUserData);
52 
53  bool IsFinished() const { return m_result >= GateArrayComputerResult_Done_InputError; }
54  GateArrayComputerResult GetResult() const { return m_result; }
55 
56  void Clear();
57 
58  template<class TLogic> void Advance(WorkingMemory* workingMemory);
59  template<class TLogic> KyResult Compute(WorkingMemory* workingMemory);
60 
61  ChannelComputerConfig& GetComputerConfig();
62 
63  //KyFloat32 GetComputationDurationMks() const;
64  void* GetTraverseLogicUserData() const { return m_traverseLogicUserData; }
65 
66  Channel* GetChannel() { return m_channel; }
67 
68 protected:
69  void Processing_Initialize();
70 
71  template<class TLogic> void Processing_ComputingGateDefinitions(WorkingMemory* workingMemory);
72  template<class TLogic> void Processing_WidenChannel_FirstGate(WorkingMemory* workingMemory);
73  template<class TLogic> void Processing_WidenChannel_TurnGates(WorkingMemory* workingMemory);
74  template<class TLogic> void Processing_WidenChannel_LastGate(WorkingMemory* workingMemory);
75 
76  template<class TLogic> void CreateStartGate(WorkingMemory* workingMemory);
77  template<class TLogic> void CheckExtremityGateSize(WorkingMemory* workingMemory, Gate& gate);
78 
79  void MovePathPosInsideGates();
80 
81  void TreatCollapsedSections();
82 
83  bool CollapseGateWhenNecessary(KyUInt32 gateIdx) const;
84 
85  KyResult ComputeCollapseIntermediaryGate(const Gate& extremityGate, const Vec3f collapsingPosition, Gate& intermediaryExtremityGate);
86 
87  KyUInt32 BacktrackCollapse(const Gate& prevGate, KyUInt32 gateIdx);
88 
89  template<class TLogic> KyResult WidenSection_NotInTurn(WorkingMemory* workingMemory, const Vec2f& endGateDirOnLeft);
90  template<class TLogic> KyResult WidenSection_InTurn(WorkingMemory* workingMemory, const Vec2f& endGateDirOnLeft);
91 
92  DisplayListManager* GetDisplayListManager();
93 
94 protected:
95  Ptr<Database> m_database; // TODO use Database* instead of Ptr<Database>
96  ChannelComputerConfig m_channelConfig;
97  void* m_traverseLogicUserData;
98 
99  GateArrayComputerResult m_result;
100  KyFloat32 m_computationDurationMks; // stats
101 
102  const StringPulledBubbleList* m_stringPulledBubbleList;
103  Ptr<GateDefinitionArray> m_gateDefinitionArray;
104  Ptr<Channel> m_channel;
105 
106 public: // internal
107  Vec2f m_prevGateDirOnLeft;
108  Gate m_currentNewGate;
109  Vec3f m_channelCornerPos;
110 
111  // temp for intermediate gates computing and adjusting
112  GateDefinitionComputer m_gateDefinitionComputer;
113  ChannelSectionWidener m_channelSectionWidener;
114  KyUInt32 m_gateDefinitionCount;
115  KyUInt32 m_gateDefinitionIdx;
116  NavTrianglePtr m_previousGateNavTriangle;
117 
118  FullDebug m_fullDebug;
119 };
120 
121 } // namespace Kaim
122 
GateArrayComputerResult
Definition: gatearraycomputer.h:26
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
Indicates the query has not yet been launched.
Definition: gatearraycomputer.h:29
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
Indicates the query has not yet been initialized.
Definition: gatearraycomputer.h:28
Navigation return code class.
Definition: types.h:108
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Indicates that the query has not yet been initialized.
Definition: iquery.h:295
Indicates that the query has not yet been launched.
Definition: iquery.h:296
float KyFloat32
float
Definition: types.h:32