gwnavruntime/queries/blobs/insideposfromoutsideposquerydisplaylistbuilder.h Source File

insideposfromoutsideposquerydisplaylistbuilder.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 InsidePosFromOutsidePosQueryDisplayListBuilder : public IDisplayListBuilder
18 {
19 private:
20  void DrawSearchBox(const InsidePosFromOutsidePosQueryBlob* 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 InsidePosFromOutsidePosQueryBlob* query = (InsidePosFromOutsidePosQueryBlob*)blob;
40  InsidePosFromOutsidePosQueryOutputBlob* output = query->m_queryOutput.Ptr();
41  if (output == nullptr)
42  return;
43 
44  const KyFloat32 radius = 0.1f;
45  const bool useCast = (query->m_castDirection != Vec2f(KyFloat32MAXVAL, KyFloat32MAXVAL));
46  Vec3f useCastPos;
47  if (useCast)
48  useCastPos = query->m_inputPos3f + Vec3f(query->m_castDirection * 2.f * query->m_horizontalTolerance);
49 
50  switch ((InsidePosFromOutsidePosQueryResult)output->m_result)
51  {
53  break;
55  {
56  DrawSearchBox(query, Color::Orange, displayList);
57  displayList->PushPoint(query->m_inputPos3f, radius, Color::White);
58  }
59  break;
62  {
63  DrawSearchBox(query, Color::Red, displayList);
64  displayList->PushPoint(query->m_inputPos3f, radius, Color::Red);
65  if (useCast)
66  displayList->PushLine(query->m_inputPos3f, useCastPos, Color::Red);
67  }
68  break;
70  {
71  DrawSearchBox(query, Color::LightGreen, displayList);
72  displayList->PushText(output->m_insidePos3f.OffsetZ(1.0f), Color::Green, "Inside pos");
73  displayList->PushDisk(output->m_insidePos3f, query->m_distFromObstacle, Color::Green);
74  displayList->PushPoint(query->m_inputPos3f, radius, Color::Green);
75  displayList->PushArrowPyramid(query->m_inputPos3f, output->m_insidePos3f, Color::Green);
76  if (useCast)
77  displayList->PushLine(query->m_inputPos3f, useCastPos, Color::LightGreen);
78  }
79  break;
80  }
81  }
82 };
83 
84 }
85 
InsidePosFromOutsidePosQueryResult
Enumerates the possible results of an InsidePosFromOutsidePosQuery.
Definition: baseinsideposfromoutsideposquery.h:20
Indicates that the query was completed successfully, and a valid position on the NavMesh was found wi...
Definition: baseinsideposfromoutsideposquery.h:28
#define KyFloat32MAXVAL
KyFloat32 max value
Definition: types.h:71
Indicates the query has not yet been initialized.
Definition: baseinsideposfromoutsideposquery.h:22
Indicates that insufficient working memory caused the query to stop.
Definition: baseinsideposfromoutsideposquery.h:25
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Indicates the query has not yet been launched.
Definition: baseinsideposfromoutsideposquery.h:23
Indicates that a valid position was not found within the query's bounding box.
Definition: baseinsideposfromoutsideposquery.h:27
float KyFloat32
float
Definition: types.h:32