gwnavruntime/queries/blobs/nearestborderhalfedgefromposquerydisplaylistbuilder.h Source File

nearestborderhalfedgefromposquerydisplaylistbuilder.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 
13 
14 namespace Kaim
15 {
16 
17 class NearestBorderHalfEdgeFromPosQueryDisplayListBuilder : public IDisplayListBuilder
18 {
19 private:
20  void DrawSearchBox(const NearestBorderHalfEdgeFromPosQueryBlob* queryBlob, const Color& color, DisplayList* displayList)
21  {
22  Vec3f boxMax(queryBlob->m_inputPos3f);
23  Vec3f boxMin(queryBlob->m_inputPos3f);
24  boxMin.x -= queryBlob->m_horizontalTolerance;
25  boxMin.y -= queryBlob->m_horizontalTolerance;
26  boxMin.z -= queryBlob->m_positionSpatializationRange.m_rangeBelowPosition;
27 
28  boxMax.x += queryBlob->m_horizontalTolerance;
29  boxMax.y += queryBlob->m_horizontalTolerance;
30  boxMax.z += queryBlob->m_positionSpatializationRange.m_rangeAbovePosition;
31 
32  ShapeColor shapeColor;
33  shapeColor.m_lineColor = color;
34  displayList->PushBox(Box3f(boxMin, boxMax), shapeColor);
35  }
36 
37  virtual void DoBuild(DisplayList* displayList, char* blob)
38  {
39  const NearestBorderHalfEdgeFromPosQueryBlob* query = (NearestBorderHalfEdgeFromPosQueryBlob*) blob;
40  NearestBorderHalfEdgeFromPosQueryOutputBlob* output = query->m_queryOutput.Ptr();
41  if (output == nullptr)
42  return;
43 
44  const KyFloat32 flagRadius = 0.3f;
45 
46  switch ((NearestBorderHalfEdgeFromPosQueryResult)output->m_result)
47  {
50  {
51  displayList->PushPoint(query->m_inputPos3f, flagRadius, Color::Orange);
52  DrawSearchBox(query, Color::Orange, displayList);
53  }
54  break;
56  {
57  DrawSearchBox(query, Color::Red, displayList);
58  }
59  break;
61  {
62  displayList->PushText(query->m_inputPos3f.OffsetZ(1.0f), Color::Red, "Lack of memory");
63  DrawSearchBox(query, Color::Red, displayList);
64  }
65  break;
67  {
68  DrawSearchBox(query, Color::LightGreen, displayList);
69 
70  Color nearest_color = Color::Green;
71  Color side_color = Color::Orange;
72 
73  const Vec3f& start = output->m_nearestHalfEdgeOnBorder.m_startPos3f;
74  const Vec3f& end = output->m_nearestHalfEdgeOnBorder.m_endPos3f;
75 
76  const Vec3f& prev_start = output->m_prevHalfEdgeOnBorder.m_startPos3f;
77  const Vec3f& prev_end = output->m_prevHalfEdgeOnBorder.m_endPos3f;
78  const Vec3f& prev_middle = (prev_start + prev_end) * 0.5f;
79 
80  const Vec3f& next_start = output->m_nextHalfEdgeOnBorder.m_startPos3f;
81  const Vec3f& next_end = output->m_nextHalfEdgeOnBorder.m_endPos3f;
82  const Vec3f& next_middle = (next_start + next_end) * 0.5f;
83 
84  // nearest
85  displayList->PushPoint(output->m_nearestPosOnHalfEdge, flagRadius, nearest_color);
86 
87  displayList->PushArrow2d5(query->m_inputPos3f, output->m_nearestPosOnHalfEdge, nearest_color);
88  displayList->PushText(output->m_nearestPosOnHalfEdge.OffsetZ(1.0f), nearest_color, "Nearest half edge");
89  displayList->PushLine(start, end, nearest_color);
90 
91  // side
92  displayList->PushLine(prev_start, prev_end, side_color);
93  displayList->PushArrow2d5(query->m_inputPos3f, prev_middle, side_color);
94  displayList->PushText(prev_middle.OffsetZ(1.0f), side_color, "Prev");
95 
96  displayList->PushLine(next_start, next_end, side_color);
97  displayList->PushArrow2d5(query->m_inputPos3f, next_middle, side_color);
98  displayList->PushText(next_middle.OffsetZ(1.0f), side_color, "Next");
99  }
100  break;
101  }
102  }
103 };
104 
105 }
106 
Indicates that the query was completed successfully, and a NavMesh border was found.
Definition: basenearestborderhalfedgefromposquery.h:28
Indicates that a NavMesh border was not found within the query's bounding box.
Definition: basenearestborderhalfedgefromposquery.h:25
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Indicates that insufficient working memory caused the query to stop.
Definition: basenearestborderhalfedgefromposquery.h:26
NearestBorderHalfEdgeFromPosQueryResult
Enumerates the possible results of a NearestBorderHalfEdgeFromPosQuery.
Definition: basenearestborderhalfedgefromposquery.h:20
Indicates the query has not yet been initialized.
Definition: basenearestborderhalfedgefromposquery.h:22
Indicates the query has not yet been launched.
Definition: basenearestborderhalfedgefromposquery.h:23
float KyFloat32
float
Definition: types.h:32