gwnavruntime/channel/gatearraycomputer.h Source File

gatearraycomputer.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 #ifndef Navigation_GateArrayComputer_H
8 #define Navigation_GateArrayComputer_H
9 
20 
21 
22 namespace Kaim
23 {
24 
26 {
29 
30  GateArrayComputerResult_ComputingGateDefinitions,
31  GateArrayComputerResult_WidenChannel_FirstGate,
32  GateArrayComputerResult_WidenChannel_TurnGates,
33  GateArrayComputerResult_WidenChannel_LastGate,
34 
35  GateArrayComputerResult_Done_InputError,
36  GateArrayComputerResult_Done_Error,
37  GateArrayComputerResult_Done_GateDefinitionComputerError,
38  GateArrayComputerResult_Done_IntermediateGatesError,
39 
40  GateArrayComputerResult_Done
41 };
42 
43 class GateArrayComputer
44 {
45  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
46 public:
47  GateArrayComputer();
48 
49  void Initialize(Database* database, const StringPulledBubbleList& stringPulledBubbleList, Channel* channel);
50 
51  bool IsFinished() const { return m_result >= GateArrayComputerResult_Done_InputError; }
52  GateArrayComputerResult GetResult() const { return m_result; }
53 
54  void Clear();
55 
56  template<class TraverseLogic>
57  void Advance(WorkingMemory* workingMemory);
58 
59  template<class TraverseLogic>
60  KyResult Compute(WorkingMemory* workingMemory);
61 
62  ChannelComputerConfig& GetComputerConfig();
63 
64  KyFloat32 GetComputationDurationMks() const;
65  void* GetTraverseLogicUserData() const;
66 
67  Channel* GetChannel() { return m_channel; }
68 
69  void SetComputerConfig(const ChannelComputerConfig& computerConfig);
70  void SetTraverseLogicUserData(void* traverseLogicUserData);
71 
72 protected:
73  void Processing_Initialize();
74 
75  template<class TraverseLogic>
76  void Processing_ComputingGateDefinitions(WorkingMemory* workingMemory);
77 
78  template<class TraverseLogic>
79  void Processing_WidenChannel_FirstGate(WorkingMemory* workingMemory);
80 
81  template<class TraverseLogic>
82  void Processing_WidenChannel_TurnGates(WorkingMemory* workingMemory);
83 
84  template<class TraverseLogic>
85  void Processing_WidenChannel_LastGate(WorkingMemory* workingMemory);
86 
87  template<class TLogic>
88  void CreateStartGate(WorkingMemory* workingMemory);
89  template<class TLogic>
90  void CheckExtremityGateSize(WorkingMemory* workingMemory, Gate& gate);
91 
92  void MovePathPosInsideGates();
93 
94  void TreatCollapsedSections();
95 
96  bool IsGateCollapsed(const Gate& gate) const;
97  bool CollapseGateWhenNecessary(KyUInt32 gateIdx) const;
98 
99  KyResult ComputeCollapseIntermediaryGate(const Gate& extremityGate, const Vec3f collapsingPosition, Gate& intermediaryExtremityGate);
100 
101  KyUInt32 BacktrackCollapse(const Gate& prevGate, KyUInt32 gateIdx);
102 
103  void UpdateInternalParametersFromConfig();
104 
105  template<class TraverseLogic>
106  KyResult WidenChannelNotInTurn(WorkingMemory* workingMemory, const Vec2f& endGateDirOnLeft);
107 
108  template<class TraverseLogic>
109  KyResult WidenChannelInTurn(WorkingMemory* workingMemory, const Vec2f& endGateDirOnLeft);
110 
111  template<class TLogic>
112  KyResult ComputeCurrentGatePos(WorkingMemory* workingMemory);
113 
114  template<class TLogic>
115  KyResult TreatNextStringPulledBubble_TransitionToNextBubble(WorkingMemory* workingMemory);
116 
117  template<class TraverseLogic>
118  KyResult ComputeTurnGate(WorkingMemory* workingMemory, const Vec2f& gateLeftDirection);
119 
120 protected:
121  Ptr<Database> m_database;
122  ChannelComputerConfig m_computerConfig;
123  void* m_traverseLogicUserData;
124 
125  GateArrayComputerResult m_result;
126 
127  // stats
128  KyFloat32 m_computationDurationMks;
129 
130  const StringPulledBubbleList* m_stringPulledBubbleList;
131  Ptr<GateDefinitionArray> m_gateDefinitionArray;
132  Ptr<Channel> m_channel;
133 
134 public: // internal
135  Vec2f m_prevGateDirOnLeft;
136  Gate m_currentNewGate;
137  Vec3f m_channelCornerPos;
138 
139  // temp for intermediate gates computing and adjusting
140  GateDefinitionComputer m_gateDefinitionComputer;
141  ChannelSectionWidener m_channelSectionWidener;
142  KyUInt32 m_gateDefinitionCount;
143  KyUInt32 m_gateDefinitionIdx;
144  NavTrianglePtr m_previousGateNavTriangle;
145 
146 public:
147  bool m_advancedVisualDebuggingEnabled;
148 };
149 
150 } // namespace Kaim
151 
152 
154 
155 
156 #endif // Navigation_GateArrayComputer_H
GateArrayComputerResult
Definition: gatearraycomputer.h:25
KyInt32 KyResult
Defines a type that can be returned by methods or functions in the Gameware Navigation SDK to indicat...
Definition: types.h:254
Indicates the query has not yet been launched.
Definition: gatearraycomputer.h:28
Indicates the query has not yet been initialized.
Definition: gatearraycomputer.h:27
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
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43