gwnavruntime/world/botmoveonnavmesh.h Source File

botmoveonnavmesh.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 
8 #pragma once
9 
11 
12 namespace Kaim
13 {
14 
17 {
18 public:
19  template<class TraverseLogic>
20  static Vec3f ComputeMoveOnNavMesh(const BotMoveOnNavMesh& input)
21  {
22  if(input.m_simulationTimeInSeconds == 0.0f)
23  return input.m_currentPosition;
24 
25  // compute new position
26  Kaim::Vec3f move = input.m_velocity * input.m_simulationTimeInSeconds;
27 
28  // query the navMesh to ensure that we are moving to a valid location
29  Kaim::Vec2f move2d;
30  KyFloat32 dist = move.GetNormalized2d(move2d);
31 
32  if(dist == 0.0f)
33  return input.m_currentPosition;
34 
36  query.BindToDatabase (input.m_database);
37  query.SetTraverseLogicUserData(input.m_traverseLogicUserData);
38  query.Initialize (input.m_currentPosition, move2d, dist);
39  query.SetStartTrianglePtr (input.m_navTrianglePtr); // initialize the StartTrianglePtr with the triangle the current position is upon
40  query.PerformQuery();
41 
42  switch (query.GetResult())
43  {
46  return input.m_currentPosition;
47 
53  return input.m_currentPosition + move;
54 
58  return query.GetArrivalPos();
59 
60  default:
61  break;
62  }
63 
64  return input.m_currentPosition;
65  }
66 
67 public:
68  Vec3f m_currentPosition;
69  Vec3f m_velocity;
70  KyFloat32 m_simulationTimeInSeconds;
71  Database* m_database;
72  void* m_traverseLogicUserData;
73  NavTrianglePtr m_navTrianglePtr;
74 };
75 
76 } // namespace Kaim
77 
78 
Indicates that the start position is near an edge but should not be linked to it. ...
Definition: basemoveonnavmeshquery.h:24
Indicates that a NavMesh triangle could not be found for the starting point.
Definition: basemoveonnavmeshquery.h:22
Indicates that the query has not yet been launched.
Definition: basemoveonnavmeshquery.h:20
Indicates that a NavMesh triangle has been found for the starting point, but its NavTag is not consid...
Definition: basemoveonnavmeshquery.h:23
Indicates an arrival point was successfully calculated without a collision with the NavMesh border...
Definition: basemoveonnavmeshquery.h:29
Indicates that an unknown error occurred during the query processing.
Definition: basemoveonnavmeshquery.h:27
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:57
Indicates a collision point was found, and a final arrival position was successfully calculated...
Definition: basemoveonnavmeshquery.h:30
2d vector using KyFloat32.
Definition: vec2f.h:18
This class is used to get move bots on the NavMesh without physics engine.
Definition: botmoveonnavmesh.h:16
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
Indicates that insufficient memory was available to store crossed triangles or sub-sections, and the query failed as a result.
Definition: basemoveonnavmeshquery.h:26
Indicates a collision point was found, an intermediary position has be found but progression has been...
Definition: basemoveonnavmeshquery.h:31
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:17
This class is used to get move bots on the NavMesh without physics engine.
Definition: moveonnavmeshquery.h:26
Indicates that the query has not yet been initialized.
Definition: basemoveonnavmeshquery.h:19
void PerformQuery(WorkingMemory *workingMemory=nullptr)
If workingMemory param is nullptr, m_database.GetWorkingMemory() will be used.
Definition: moveonnavmeshquery.inl:267
KyFloat32 GetNormalized2d(Vec2f &normalized) const
as Get2d().GetNormalized()
Definition: vec3f.h:224
float KyFloat32
float
Definition: types.h:32
3d vector using 32bits floating points.
Definition: vec3f.h:16
void SetTraverseLogicUserData(void *traverseLogicUserData)
Sets m_traverseLogicUserData for queries that have a custom TraverseLogic, useless otherwise...
Definition: iquery.h:167