gwnavruntime/world/botmoveonnavmesh.h Source File

botmoveonnavmesh.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: MUBI
9 #ifndef Navigation_BotMoveOnNavMesh_H
10 #define Navigation_BotMoveOnNavMesh_H
11 
13 
14 namespace Kaim
15 {
16 
19 {
20 public:
21  template<class TraverseLogic>
22  static Vec3f ComputeMoveOnNavMesh(const BotMoveOnNavMesh& input)
23  {
24  if(input.m_simulationTimeInSeconds == 0.0f)
25  return input.m_currentPosition;
26 
27  // compute new position
28  Kaim::Vec3f move = input.m_velocity * input.m_simulationTimeInSeconds;
29 
30  // query the navMesh to ensure that we are moving to a valid location
31  Kaim::Vec2f move2d;
32  KyFloat32 dist = move.GetNormalized2d(move2d);
33 
34  if(dist == 0.0f)
35  return input.m_currentPosition;
36 
38  query.BindToDatabase (input.m_database);
39  query.SetTraverseLogicUserData(input.m_traverseLogicUserData);
40  query.Initialize (input.m_currentPosition, move2d, dist);
41  query.SetStartTrianglePtr (input.m_navTrianglePtr); // initialize the StartTrianglePtr with the triangle the current position is upon
42  query.PerformQuery();
43 
44  switch (query.GetResult())
45  {
48  return input.m_currentPosition;
49 
55  return input.m_currentPosition + move;
56 
60  return query.GetArrivalPos();
61 
62  default:
63  break;
64  }
65 
66  return input.m_currentPosition;
67  }
68 
69 public:
70  Vec3f m_currentPosition;
71  Vec3f m_velocity;
72  KyFloat32 m_simulationTimeInSeconds;
73  Database* m_database;
74  void* m_traverseLogicUserData;
75  NavTrianglePtr m_navTrianglePtr;
76 };
77 
78 } // namespace Kaim
79 
80 #endif //Navigation_BotMoveOnNavMesh_H
81 
Indicates that the start position is near an edge but should not be linked to it. This is usualy due ...
Definition: basemoveonnavmeshquery.h:29
Indicates that a NavMesh triangle could not be found for the starting point.
Definition: basemoveonnavmeshquery.h:27
void Initialize(const Vec3f &startPos, const Vec2f &normalizedDir2d, KyFloat32 maxDist)
Sets an instance of this class with minimum input requirements.
Definition: moveonnavmeshquery.inl:25
Indicates that the query has not yet been launched.
Definition: basemoveonnavmeshquery.h:25
Indicates that a NavMesh triangle has been found for the starting point, but its NavTag is not consid...
Definition: basemoveonnavmeshquery.h:28
Indicates an arrival point was successfully calculated without a collision with the NavMesh border...
Definition: basemoveonnavmeshquery.h:33
Indicates that an unknown error occurred during the query processing.
Definition: basemoveonnavmeshquery.h:31
This class is a runtime container for all NavData that represents the world from the point of view of...
Definition: database.h:64
Indicates a collision point was found, and a final arrival position was successfully calculated...
Definition: basemoveonnavmeshquery.h:34
This class defines a two-dimensional vector whose coordinates are stored using floating-point numbers...
Definition: vec2f.h:24
void BindToDatabase(Database *database)
Binds the query with the specified Database, clears all the inputs and outputs and sets all other par...
Definition: moveonnavmeshquery.inl:19
This class is used to get move bots on the NavMesh without physics engine.
Definition: botmoveonnavmesh.h:18
Definition: gamekitcrowddispersion.h:20
Indicates that insufficient memory was available to store crossed triangles or sub-sections, and the query failed as a result.
Definition: basemoveonnavmeshquery.h:30
void PerformQuery(WorkingMemory *workingMemory=0)
Performs the query.
Definition: moveonnavmeshquery.inl:328
Indicates a collision point was found, an intermediary position has be found but progression has been...
Definition: basemoveonnavmeshquery.h:35
Each instance of this class uniquely identifies a single NavTriangle in a NavFloor.
Definition: navtriangleptr.h:22
This class is used to get move bots on the NavMesh without physics engine.
Definition: moveonnavmeshquery.h:30
Indicates that the query has not yet been initialized.
Definition: basemoveonnavmeshquery.h:24
KyFloat32 GetNormalized2d(Vec2f &normalized) const
Normalizes the (X,Y) coordinates of the vector, making it one unit in length without changing its ori...
Definition: vec3f.h:369
void SetStartTrianglePtr(const NavTrianglePtr &startTrianglePtr)
Set the NavMesh triangle that corresponds to #m_startPos3f.
Definition: moveonnavmeshquery.inl:31
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43
This class defines a three-dimensional vector whose coordinates are stored using floating-point numbe...
Definition: vec3f.h:23
void SetTraverseLogicUserData(void *traverseLogicUserData)
Should be set for queries templated by a traverse logic, useless otherwise.
Definition: iquery.h:384