gwnavruntime/queries/makenavfloorstitchquery.h Source File

makenavfloorstitchquery.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: LASI - secondary contact: NOBODY
9 #ifndef Navigation_MakeNavFloorStitchQuery_H
10 #define Navigation_MakeNavFloorStitchQuery_H
11 
16 
17 namespace Kaim
18 {
19 class NavCell;
20 class NavFloorBlob;
21 class DynamicTriangulation;
22 class DynamicNavFloor;
23 class NavFloorStitcherData;
24 
27 {
30 
31  RUNTIMESTITCH_PROCESSING,
32 
35 
37 };
38 
39 class MakeNavFloorStitchQuery : public ITimeSlicedQuery
40 {
41 
42 public:
43  static QueryType GetStaticType() { return TypeMakeNavFloorStitchQuery; }
44  virtual QueryType GetType() const { return TypeMakeNavFloorStitchQuery; }
45 
46  MakeNavFloorStitchQuery();
47  virtual ~MakeNavFloorStitchQuery();
48 
52  void BindToDatabase(Database* database);
53  void Initialize(NavCell* navCell);
54 
55  virtual void Advance(WorkingMemory* workingMemory);
56  virtual void ReleaseWorkingMemoryOnCancelDuringProcess(WorkingMemory* workingMemory = KY_NULL);
58  MakeNavFloorStitchQueryResult GetResult() const { return m_result; };
59 
60  // ---------------------------------- Accessors ----------------------------------
61  void SetResult(MakeNavFloorStitchQueryResult result) { m_result = result; };
62  static void FillEdgeExtremities(const NavFloorBlob* navFloorBlob, NavHalfEdgeIdx halfEdgeIdx, Vec2i& start, Vec2i& end);
63 
64 private:
65  void ProcessNavFloor();
66 
67  class NewCutAlongStaticEdge
68  {
69  public:
70  NewCutAlongStaticEdge() {}
71  NewCutAlongStaticEdge(const Vec2i& pos, KyFloat32 alt) : m_pos(pos), m_altitude(alt) {}
72  bool operator==(const NewCutAlongStaticEdge& other) const { return m_pos == other.m_pos; }
73  bool operator!=(const NewCutAlongStaticEdge& other) const { return m_pos != other.m_pos; }
74 
75  public:
76  Vec2i m_pos;
77  KyFloat32 m_altitude;
78  };
79 
80  class RunTimeStitchCutSorter
81  {
82  public:
83  RunTimeStitchCutSorter(const Vec2i& stitch1To1EndVertex, KyInt32 currentEdgeDir) :
84  m_stitch1To1EndVertex(stitch1To1EndVertex), m_coordIdx(currentEdgeDir) {}
85 
86  bool operator() (const NewCutAlongStaticEdge& cut1, const NewCutAlongStaticEdge& cut2) const
87  {
88  KY_ASSERT(cut1.m_pos[m_coordIdx] != m_stitch1To1EndVertex[m_coordIdx]);
89  KY_ASSERT(cut2.m_pos[m_coordIdx] != m_stitch1To1EndVertex[m_coordIdx]);
90  const KyInt32 diff1 = cut1.m_pos[m_coordIdx] - m_stitch1To1EndVertex[m_coordIdx];
91  const KyInt32 diff2 = cut2.m_pos[m_coordIdx] - m_stitch1To1EndVertex[m_coordIdx];
92  const KyInt32 squareDist1 = diff1*diff1;
93  const KyInt32 squareDist2 = diff2*diff2;
94  return squareDist1 < squareDist2;
95  }
96 
97  Vec2i m_stitch1To1EndVertex;
98  KyInt32 m_coordIdx;
99  };
100 
101 
102  void ComputeAndInsertAllCuts(NavFloorStitcherData& currentData, KyUInt32 stitch1To1EdgeIdx, const Vec2i& stitch1To1EndVertex,
103  NavFloorStitcherData& neighborData, KyUInt32 neighborStitch1To1EdgeIdx, KyArray<NewCutAlongStaticEdge>& newCuts, DynamicTriangulation& dynTri);
104  void InsertexVertexInTriangulationOnEdge(DynamicTriangulation& dynTri, KyUInt32 halfEdgeIdx, NewCutAlongStaticEdge& newCut);
105  void BuildDynamicTriangulationFromStaticNavFloorBlob(const NavFloorBlob* floorBlob, DynamicTriangulation& dynTri);
106  void BuildDynamicNavFloorFromDynamicTriangulation(const NavFloorBlob* floorBlob, const NavFloor1To1StitchDataBlob& floor1To1StitchDataBlob,
107  const DynamicTriangulation& dynTri, DynamicNavFloor& dynaFloor);
108 
109  void SetFinish(WorkingMemory* workingMemory);
110  void ReleaseWorkingMemory() {}
111 
112 
113 public:
115  NavCell* m_navCell;
116  KyArray<Ptr<BlobHandler<NavFloorBlob> > > m_resultNavfloorHandlers;
118  KyInt32 m_coordIdx; // 0 for x, 1 for y
119  NavFloorIdx m_currentFloorIdx;
120  KyArray<KyUInt16> m_navHalfEdgeToTriangulationEdge;
121  bool m_dynamicTriangulationFromFloorIsBuilt;
122 };
123 
124 KY_INLINE void MakeNavFloorStitchQuery::SetFinish(WorkingMemory* /*workingMemory*/)
125 {
126  m_processStatus = QueryDone; // TODO - CHANGE THIS!
127  ReleaseWorkingMemory();
128 }
129 
130 
131 
132 }
133 
134 
135 
136 
137 
138 #endif //Navigation_MakeNavFloorStitchQuery_H
139 
Indicates that insufficient working memory caused the query to stop.
Definition: makenavfloorstitchquery.h:33
KyUInt32 NavHalfEdgeIdx
An index that uniquely identifies a single edge of a triangle within the set of edges owned by a NavF...
Definition: navmeshtypes.h:87
Indicates the query was successfully processed.
Definition: makenavfloorstitchquery.h:36
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
#define KY_NULL
Null value.
Definition: types.h:247
Indicates the query has not yet been initialized.
Definition: makenavfloorstitchquery.h:28
MakeNavFloorStitchQueryResult
Enumerates the possible results of a MakeNavFloorStitchQuery.
Definition: makenavfloorstitchquery.h:26
QueryType
Enumerates all the type of query.
Definition: iquery.h:29
Indicates an unknown error occurred during the query processing.
Definition: makenavfloorstitchquery.h:34
KyUInt32 NavFloorIdx
An index that uniquely identifies a single NavFloor within the set of NavFloors owned by a NavCell...
Definition: navmeshtypes.h:115
Definition: gamekitcrowddispersion.h:20
Indicates that the query has not yet been initialized.
Definition: iquery.h:346
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
Indicates the query has not yet been launched.
Definition: makenavfloorstitchquery.h:29
Indicates that the query has not yet been launched.
Definition: iquery.h:347
void Initialize()
Should be called by the derived class before trying to perform the query or to push it in a QueryQueu...
Definition: iquery.h:404
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43