gwnavruntime/queries/utils/bubblearrayqueries.h Source File

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