Panda3D
aiNode.cxx
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 aiNode.cxx
10  * @author Deepak, John, Navin
11  * @date 2009-11-19
12  */
13 
14 #include "aiNode.h"
15 
16 AINode::AINode(int grid_x, int grid_y, LVecBase3 pos, float w, float l, float h) {
17  for (int i = 0; i < 8; ++i) {
18  _neighbours[i] = nullptr;
19  }
20 
21  _position = pos;
22  _width = w;
23  _length = l;
24  _height = h;
25  _grid_x = grid_x;
26  _grid_y = grid_y;
27  _status = ST_neutral;
28  _type = true;
29  _score = 0;
30  _cost = 0;
31  _heuristic = 0;
32  _next = nullptr;
33  _prv_node = nullptr;
34 }
35 
36 AINode::~AINode() {
37 }
38 
39 /**
40  * This is a handy function which returns true if the passed position is
41  * within the node's dimensions.
42  */
43 bool AINode::contains(float x, float y) {
44  if (_position.get_x() - _width / 2 <= x && _position.get_x() + _width / 2 >= x &&
45  _position.get_y() - _length / 2 <= y && _position.get_y() + _length / 2 >= y) {
46  return true;
47  }
48  else {
49  return false;
50  }
51 }
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
bool contains(float x, float y)
This is a handy function which returns true if the passed position is within the node's dimensions.
Definition: aiNode.cxx:43