1 #include "expandnode.qh"
6 vector plib_points2[8];
10 float pathlib_expandnode_starf(entity node, vector start, vector goal)
14 vector where = node.origin;
16 vector f = PLIB_FORWARD * pathlib_gridsize;
17 vector r = PLIB_RIGHT * pathlib_gridsize;
20 plib_points[0] = where + f;
23 plib_points[1] = where - f;
26 plib_points[2] = where + r;
29 plib_points[3] = where - r;
32 plib_points[4] = where + f + r;
35 plib_points[5] = where + f - r;
38 plib_points[6] = where - f + r;
41 plib_points[7] = where - f - r;
43 for(int i=0;i < 8; ++i)
45 vector t = plib_points[i];
46 fc = pathlib_heuristic(t,goal) + pathlib_cost(node, t, pathlib_gridsize);
52 plib_points2[0] = plib_points[0];
56 for(int i = 0; i < 8; ++i)
59 entity nap = pathlib_nodeatpoint(plib_points[i]);
62 if(nap.owner == openlist)
69 if(plib_fvals[i] < fc)
73 plib_points2[fc2] = plib_points[i];
77 //nap = pathlib_nodeatpoint(plib_points[i]);
79 //if not nap.owner == closedlist)
84 pathlib_makenode(node, start, bp, goal, pathlib_gridsize);
86 for(int i = 0; i < 3; ++i)
88 pathlib_makenode(node, start, plib_points2[i], goal, pathlib_gridsize);
91 return pathlib_open_cnt;
95 float pathlib_expandnode_star(entity node, vector start, vector goal)
99 vector where = node.origin;
101 vector f = PLIB_FORWARD * pathlib_gridsize;
102 vector r = PLIB_RIGHT * pathlib_gridsize;
104 if (node.pathlib_node_edgeflags == pathlib_node_edgeflag_unknown)
105 node.pathlib_node_edgeflags = tile_check_plus2(node, node.origin);
107 if(node.pathlib_node_edgeflags == pathlib_node_edgeflag_none)
109 LOG_TRACE("Node at ", vtos(node.origin), " not expanable");
110 return pathlib_open_cnt;
114 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forward)
117 pathlib_makenode(node, start, point, goal, pathlib_movecost);
121 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_back)
124 pathlib_makenode(node, start, point, goal, pathlib_movecost);
128 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_right)
131 pathlib_makenode(node, start, point, goal, pathlib_movecost);
135 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_left)
138 pathlib_makenode(node, start, point, goal, pathlib_movecost);
143 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardright)
145 point = where + f + r;
146 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
150 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardleft)
152 point = where + f - r;
153 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
158 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backright)
160 point = where - f + r;
161 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
165 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backleft)
167 point = where - f - r;
168 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
171 return pathlib_open_cnt;
175 float pathlib_expandnode_octagon(entity node, vector start, vector goal)
179 vector where = node.origin;
181 vector f = PLIB_FORWARD * pathlib_gridsize;
182 vector r = PLIB_RIGHT * pathlib_gridsize;
186 pathlib_makenode(node, start, point, goal, pathlib_movecost);
190 pathlib_makenode(node, start, point, goal, pathlib_movecost);
194 pathlib_makenode(node, start, point, goal, pathlib_movecost);
198 pathlib_makenode(node, start, point, goal, pathlib_movecost);
200 f = PLIB_FORWARD * pathlib_gridsize * 0.5;
201 r = PLIB_RIGHT * pathlib_gridsize * 0.5;
204 point = where + f + r;
205 pathlib_makenode(node, start, point, goal, pathlib_movecost);
208 point = where + f - r;
209 pathlib_makenode(node, start, point, goal, pathlib_movecost);
212 point = where - f + r;
213 pathlib_makenode(node, start, point, goal, pathlib_movecost);
216 point = where - f - r;
217 pathlib_makenode(node, start, point, goal, pathlib_movecost);
219 return pathlib_open_cnt;
223 float pathlib_expandnode_box(entity node, vector start, vector goal)
227 for(v.z = node.origin.z - pathlib_gridsize; v.z <= node.origin.z + pathlib_gridsize; v.z += pathlib_gridsize)
228 for(v.y = node.origin.y - pathlib_gridsize; v.y <= node.origin.y + pathlib_gridsize; v.y += pathlib_gridsize)
229 for(v.x = node.origin.x - pathlib_gridsize; v.x <= node.origin.x + pathlib_gridsize; v.x += pathlib_gridsize)
231 //if(vlen(v - node.origin))
232 pathlib_makenode(node,start,v,goal,pathlib_movecost);
235 return pathlib_open_cnt;