gwnavruntime/queries/utils/bubblearrayqueries.h Source File

bubblearrayqueries.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: JUBA - secondary contact: NOBODY
9 #ifndef Navigation_BubbleArrayQueries_H
10 #define Navigation_BubbleArrayQueries_H
11 
14 
15 namespace Kaim
16 {
17 
18 class BubbleArray;
19 class DisplayList;
20 
21 
22 class BubbleArrayQueries
23 {
24 public:
25  BubbleArrayQueries() { m_bubbleArray = KY_NULL; }
26 
27  void Init(const BubbleArray* bubbleArray) { m_bubbleArray = bubbleArray; }
28 
29  struct RayCastFromCornerInputOutput
30  {
31  RayCastFromCornerInputOutput() : m_startCornerIdx(KyUInt32MAXVAL), m_dir2d(Vec2f::Zero()),
32  m_collisionSegmentStartCornerIdx(KyUInt32MAXVAL), m_collisionSegmentEndCornerIdx(KyUInt32MAXVAL), m_result(Error) {}
33 
34  // input
35  KyUInt32 m_startCornerIdx;
36  Vec2f m_dir2d;
37 
38  // output
39  KyUInt32 m_collisionSegmentStartCornerIdx;
40  KyUInt32 m_collisionSegmentEndCornerIdx;
41 
42  enum Result
43  {
44  Error,
45  RayGoesOutside,
46  Collision_SameSide,
47  Collision_OppositeSide,
48  Collision_StartCorner,
49  Collision_EndCorner
50  };
51  Result m_result;
52  };
53  void RayCastFromCorner(RayCastFromCornerInputOutput& rayCastFromCornerInputOuput);
54 
55  bool RayCanGoFromCorner(KyUInt32 cornerIdx, const Vec3f& dest);
56 
57  void CollectIntersectingBubbles(KyUInt32 startCornerIdx, const Vec2f& dir2d, RotationDirection rotDir, KyArrayPOD<KyUInt32>& intersectingBubbles, ScopedDisplayList* displayList);
58 
59 public: //internal
60  void CastRayInTheStripForward(RayCastFromCornerInputOutput& rayCastFromBubbleInputOuput,
61  KyUInt32 startCornerIdx, KyUInt32 leftCornerIdx, KyUInt32 rightCornerIdx);
62  void CastRayInTheStripBackward(RayCastFromCornerInputOutput& rayCastFromBubbleInputOuput,
63  KyUInt32 startCornerIdx, KyUInt32 leftCornerIdx, KyUInt32 rightCornerIdx);
64 
65  void ResolveWhenRayGoesOnOppositeBubble(RayCastFromCornerInputOutput& rayCastFromBubbleInputOuput,
66  KyUInt32 startCornerIdx, KyUInt32 bubbleIdxOnOppositeSide);
67 
68  bool IsStartOrEndBubble(KyUInt32 cornerIdx)
69  {
70  BubbleType bubbleType = m_bubbleArray->At(cornerIdx).GetType();
71  return bubbleType == StartBubble || bubbleType == EndBubble;
72  }
73 
74  KyUInt32 FindPrevCornerIdxAlongStripBorder(KyUInt32 startCornerIdx);
75  KyUInt32 FindNextCornerIdxAlongStripBorder(KyUInt32 startCornerIdx);
76  KyUInt32 FindOneDiagonalOppositeCornerIdx(KyUInt32 startCornerIdx);
77  KyUInt32 GetLastNonTerminalBubble(RotationDirection rotationDirection);
78  KyUInt32 GetFirstNonTerminalBubble(RotationDirection rotationDirection);
79 public:
80  const BubbleArray* m_bubbleArray;
81 };
82 
83 
84 }
85 
86 
87 #endif //Navigation_BubbleArrayQueries_H
88 
#define KY_NULL
Null value.
Definition: types.h:247
RotationDirection
Defines the 4 possible cases of possibly constrained rotation in the horizontal plane for a given ele...
Definition: rotation.h:20
BubbleType
Defines the type of a bubble accordingly to the place it has in a BubbleArray, a BubbleList, etc.
Definition: bubble.h:26
Definition: gamekitcrowddispersion.h:20
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
#define KyUInt32MAXVAL
The maximum value that can be stored in the KyUInt32 variable type.
Definition: types.h:226