Panda3D
aiNode.cxx
1 // Filename: aiNode.cxx
2 // Created by: Deepak, John, Navin (19Nov2009)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "aiNode.h"
16 
17 AINode::AINode(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) {
18  for (int i = 0; i < 8; ++i) {
19  _neighbours[i] = NULL;
20  }
21 
22  _position = pos;
23  _width = w;
24  _length = l;
25  _height = h;
26  _grid_x = grid_x;
27  _grid_y = grid_y;
28  _status = ST_neutral;
29  _type = true;
30  _score = 0;
31  _cost = 0;
32  _heuristic = 0;
33  _next = NULL;
34  _prv_node = NULL;
35 }
36 
37 AINode::~AINode() {
38 }
39 
40 ////////////////////////////////////////////////////////////////////
41 // Function: contains
42 // Description: This is a handy function which returns true if the
43 // passed position is within the node's dimensions.
44 ////////////////////////////////////////////////////////////////////
45 bool AINode::contains(float x, float y) {
46  if (_position.get_x() - _width / 2 <= x && _position.get_x() + _width / 2 >= x &&
47  _position.get_y() - _length / 2 <= y && _position.get_y() + _length / 2 >= y) {
48  return true;
49  }
50  else {
51  return false;
52  }
53 }
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
bool contains(float x, float y)
This is a handy function which returns true if the passed position is within the node&#39;s dimensions...
Definition: aiNode.cxx:45