1 #include "expandnode.qh"
3 #include <server/pathlib/pathlib.qh>
4 #include <server/pathlib/utility.qh>
7 vector plib_points2[8];
11 float pathlib_expandnode_starf(entity node, vector start, vector goal)
15 vector where = node.origin;
17 vector f = PLIB_FORWARD * pathlib_gridsize;
18 vector r = PLIB_RIGHT * pathlib_gridsize;
21 plib_points[0] = where + f;
24 plib_points[1] = where - f;
27 plib_points[2] = where + r;
30 plib_points[3] = where - r;
33 plib_points[4] = where + f + r;
36 plib_points[5] = where + f - r;
39 plib_points[6] = where - f + r;
42 plib_points[7] = where - f - r;
44 for(int i=0;i < 8; ++i)
46 vector t = plib_points[i];
47 fc = pathlib_heuristic(t,goal) + pathlib_cost(node, t, pathlib_gridsize);
53 plib_points2[0] = plib_points[0];
57 for(int i = 0; i < 8; ++i)
60 entity nap = pathlib_nodeatpoint(plib_points[i]);
63 if(nap.owner == openlist)
70 if(plib_fvals[i] < fc)
74 plib_points2[fc2] = plib_points[i];
78 //nap = pathlib_nodeatpoint(plib_points[i]);
80 //if not nap.owner == closedlist)
85 pathlib_makenode(node, start, bp, goal, pathlib_gridsize);
87 for(int i = 0; i < 3; ++i)
89 pathlib_makenode(node, start, plib_points2[i], goal, pathlib_gridsize);
92 return pathlib_open_cnt;
96 float pathlib_expandnode_star(entity node, vector start, vector goal)
100 vector where = node.origin;
102 vector f = PLIB_FORWARD * pathlib_gridsize;
103 vector r = PLIB_RIGHT * pathlib_gridsize;
105 if (node.pathlib_node_edgeflags == pathlib_node_edgeflag_unknown)
106 node.pathlib_node_edgeflags = tile_check_plus2(node, node.origin);
108 if(node.pathlib_node_edgeflags == pathlib_node_edgeflag_none)
110 LOG_TRACE("Node at ", vtos(node.origin), " not expanable");
111 return pathlib_open_cnt;
115 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forward)
118 pathlib_makenode(node, start, point, goal, pathlib_movecost);
122 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_back)
125 pathlib_makenode(node, start, point, goal, pathlib_movecost);
129 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_right)
132 pathlib_makenode(node, start, point, goal, pathlib_movecost);
136 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_left)
139 pathlib_makenode(node, start, point, goal, pathlib_movecost);
144 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardright)
146 point = where + f + r;
147 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
151 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardleft)
153 point = where + f - r;
154 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
159 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backright)
161 point = where - f + r;
162 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
166 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backleft)
168 point = where - f - r;
169 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
172 return pathlib_open_cnt;
176 float pathlib_expandnode_octagon(entity node, vector start, vector goal)
180 vector where = node.origin;
182 vector f = PLIB_FORWARD * pathlib_gridsize;
183 vector r = PLIB_RIGHT * pathlib_gridsize;
187 pathlib_makenode(node, start, point, goal, pathlib_movecost);
191 pathlib_makenode(node, start, point, goal, pathlib_movecost);
195 pathlib_makenode(node, start, point, goal, pathlib_movecost);
199 pathlib_makenode(node, start, point, goal, pathlib_movecost);
201 f = PLIB_FORWARD * pathlib_gridsize * 0.5;
202 r = PLIB_RIGHT * pathlib_gridsize * 0.5;
205 point = where + f + r;
206 pathlib_makenode(node, start, point, goal, pathlib_movecost);
209 point = where + f - r;
210 pathlib_makenode(node, start, point, goal, pathlib_movecost);
213 point = where - f + r;
214 pathlib_makenode(node, start, point, goal, pathlib_movecost);
217 point = where - f - r;
218 pathlib_makenode(node, start, point, goal, pathlib_movecost);
220 return pathlib_open_cnt;
224 float pathlib_expandnode_box(entity node, vector start, vector goal)
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)
232 //if(vlen(v - node.origin))
233 pathlib_makenode(node,start,v,goal,pathlib_movecost);
236 return pathlib_open_cnt;