Panda3D
aiPathFinder.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file aiPathFinder.h
10  * @author Deepak, John, Navin
11  * @date 2009-11-10
12  */
13 
14 #ifndef _PATHFINDER_H
15 #define _PATHFINDER_H
16 
17 #include "meshNode.h"
18 #include "cmath.h"
19 #include "lineSegs.h"
20 
21 typedef std::vector<Node *> NodeArray;
22 typedef std::vector<NodeArray> NavMesh;
23 
24 Node* find_in_mesh(NavMesh nav_mesh, LVecBase3 pos, int grid_size);
25 
26 /**
27  * This class implements pathfinding using A* algorithm. It also uses a
28  * Binary Heap search to search the open list. The heuristics are calculated
29  * using the manhattan method.
30  */
31 class EXPCL_PANDAAI PathFinder {
32 public:
33  Node *_src_node;
34  Node *_dest_node;
35  std::vector<Node*> _open_list;
36  std::vector<Node*> _closed_list;
37 
38  NavMesh _grid;
39 
40  void identify_neighbors(Node *nd);
41  int calc_cost_frm_src(Node *nd);
42  int calc_heuristic(Node *nd);
43  void calc_node_score(Node *nd);
44  bool is_diagonal_node(Node *nd);
45 
46  void add_to_olist(Node *nd);
47  void remove_from_olist();
48 
49  void add_to_clist(Node *nd);
50  void remove_from_clist(int r, int c);
51 
52  void generate_path();
53  void find_path(Node *src_node, Node *dest_node);
54  PathFinder(NavMesh nav_mesh);
55  ~PathFinder();
56 };
57 
58 #endif
This class is used to assign the nodes on the mesh.
Definition: meshNode.h:16
This class implements pathfinding using A* algorithm.
Definition: aiPathFinder.h:31
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Node * find_in_mesh(NavMesh nav_mesh, LVecBase3 pos, int grid_size)
This function allows the user to pass a position and it returns the corresponding node on the navigat...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.