Xonotic
expandnode.qc File Reference
+ Include dependency graph for expandnode.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

float pathlib_expandnode_box (entity node, vector start, vector goal)
 
float pathlib_expandnode_star (entity node, vector start, vector goal)
 

Function Documentation

◆ pathlib_expandnode_box()

float pathlib_expandnode_box ( entity  node,
vector  start,
vector  goal 
)

Definition at line 224 of file expandnode.qc.

References pathlib_gridsize, pathlib_makenode(), pathlib_movecost, pathlib_open_cnt, v, and vector().

Referenced by pathlib_astar(), and pathlib_makenode_adaptive().

225 {
226  vector v;
227 
228  for(v.z = node.origin.z - pathlib_gridsize; v.z <= node.origin.z + pathlib_gridsize; v.z += pathlib_gridsize)
229  for(v.y = node.origin.y - pathlib_gridsize; v.y <= node.origin.y + pathlib_gridsize; v.y += pathlib_gridsize)
230  for(v.x = node.origin.x - pathlib_gridsize; v.x <= node.origin.x + pathlib_gridsize; v.x += pathlib_gridsize)
231  {
232  //if(vlen(v - node.origin))
233  pathlib_makenode(node,start,v,goal,pathlib_movecost);
234  }
235 
236  return pathlib_open_cnt;
237 }
float pathlib_movecost
Definition: pathlib.qh:51
float pathlib_gridsize
Definition: pathlib.qh:50
float pathlib_open_cnt
Definition: pathlib.qh:42
var bool pathlib_makenode(entity parent, vector start, vector to, vector goal, float cost)
vector(float skel, float bonenum) _skel_get_boneabs_hidden
vector v
Definition: ent_cs.qc:116
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ pathlib_expandnode_star()

float pathlib_expandnode_star ( entity  node,
vector  start,
vector  goal 
)

Definition at line 96 of file expandnode.qc.

References LOG_TRACE, pathlib_gridsize, pathlib_makenode(), pathlib_movecost, pathlib_movecost_diag, pathlib_node_edgeflag_back, pathlib_node_edgeflag_backleft, pathlib_node_edgeflag_backright, pathlib_node_edgeflag_forward, pathlib_node_edgeflag_forwardleft, pathlib_node_edgeflag_forwardright, pathlib_node_edgeflag_left, pathlib_node_edgeflag_none, pathlib_node_edgeflag_right, pathlib_node_edgeflag_unknown, pathlib_open_cnt, PLIB_FORWARD, PLIB_RIGHT, tile_check_plus2(), vector(), and vtos().

Referenced by pathlib_astar(), and pathlib_makenode_adaptive().

97 {
98  vector point;
99 
100  vector where = node.origin;
101 
104 
105  if (node.pathlib_node_edgeflags == pathlib_node_edgeflag_unknown)
106  node.pathlib_node_edgeflags = tile_check_plus2(node, node.origin);
107 
108  if(node.pathlib_node_edgeflags == pathlib_node_edgeflag_none)
109  {
110  LOG_TRACE("Node at ", vtos(node.origin), " not expanable");
111  return pathlib_open_cnt;
112  }
113 
114  // Forward
115  if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forward)
116  {
117  point = where + f;
118  pathlib_makenode(node, start, point, goal, pathlib_movecost);
119  }
120 
121  // Back
122  if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_back)
123  {
124  point = where - f;
125  pathlib_makenode(node, start, point, goal, pathlib_movecost);
126  }
127 
128  // Right
129  if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_right)
130  {
131  point = where + r;
132  pathlib_makenode(node, start, point, goal, pathlib_movecost);
133  }
134 
135  // Left
136  if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_left)
137  {
138  point = where - r;
139  pathlib_makenode(node, start, point, goal, pathlib_movecost);
140 
141  }
142 
143  // Forward-right
144  if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardright)
145  {
146  point = where + f + r;
147  pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
148  }
149 
150  // Forward-left
151  if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardleft)
152  {
153  point = where + f - r;
154  pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
155 
156  }
157 
158  // Back-right
159  if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backright)
160  {
161  point = where - f + r;
162  pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
163  }
164 
165  // Back-left
166  if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backleft)
167  {
168  point = where - f - r;
169  pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
170  }
171 
172  return pathlib_open_cnt;
173 }
float tile_check_plus2(entity this, vector where)
Definition: utility.qc:112
const float pathlib_node_edgeflag_backright
Definition: pathlib.qh:36
const float pathlib_node_edgeflag_forwardleft
Definition: pathlib.qh:37
const vector PLIB_FORWARD
Definition: pathlib.qh:13
const float pathlib_node_edgeflag_left
Definition: pathlib.qh:31
float pathlib_movecost
Definition: pathlib.qh:51
float pathlib_gridsize
Definition: pathlib.qh:50
float pathlib_open_cnt
Definition: pathlib.qh:42
var bool pathlib_makenode(entity parent, vector start, vector to, vector goal, float cost)
const float pathlib_node_edgeflag_back
Definition: pathlib.qh:34
vector(float skel, float bonenum) _skel_get_boneabs_hidden
#define LOG_TRACE(...)
Definition: log.qh:81
const float pathlib_node_edgeflag_backleft
Definition: pathlib.qh:35
const float pathlib_node_edgeflag_none
Definition: pathlib.qh:39
const vector PLIB_RIGHT
Definition: pathlib.qh:15
float pathlib_movecost_diag
Definition: pathlib.qh:52
const float pathlib_node_edgeflag_forward
Definition: pathlib.qh:33
const float pathlib_node_edgeflag_right
Definition: pathlib.qh:32
const float pathlib_node_edgeflag_forwardright
Definition: pathlib.qh:38
const float pathlib_node_edgeflag_unknown
Definition: pathlib.qh:30
+ Here is the call graph for this function:
+ Here is the caller graph for this function: