1 vector plib_points2[8];
5 float pathlib_expandnode_starf(entity node, vector start, vector goal)
13 f = PLIB_FORWARD * pathlib_gridsize;
14 r = PLIB_RIGHT * pathlib_gridsize;
17 plib_points[0] = where + f;
20 plib_points[1] = where - f;
23 plib_points[2] = where + r;
26 plib_points[3] = where - r;
29 plib_points[4] = where + f + r;
32 plib_points[5] = where + f - r;
35 plib_points[6] = where - f + r;
38 plib_points[7] = where - f - r;
43 fc = pathlib_heuristic(t,goal) + pathlib_cost(node, t, pathlib_gridsize);
49 plib_points2[0] = plib_points[0];
52 for(i = 0; i < 8; ++i)
55 nap = pathlib_nodeatpoint(plib_points[i]);
57 if(nap.owner == openlist)
63 if(plib_fvals[i] < fc)
67 plib_points2[fc2] = plib_points[i];
72 nap = pathlib_nodeatpoint(plib_points[i]);
74 if not nap.owner == closedlist)
80 pathlib_makenode(node, start, bp, goal, pathlib_gridsize);
82 for(i = 0; i < 3; ++i)
84 pathlib_makenode(node, start, plib_points2[i], goal, pathlib_gridsize);
87 return pathlib_open_cnt;
90 float pathlib_expandnode_star(entity node, vector start, vector goal)
92 vector point, where, f, r;
96 f = PLIB_FORWARD * pathlib_gridsize;
97 r = PLIB_RIGHT * pathlib_gridsize;
99 if (node.pathlib_node_edgeflags == pathlib_node_edgeflag_unknown)
100 node.pathlib_node_edgeflags = tile_check_plus2(node.origin);
102 if(node.pathlib_node_edgeflags == pathlib_node_edgeflag_none)
104 dprint("Node at ", vtos(node.origin), " not expanable");
105 return pathlib_open_cnt;
109 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forward)
112 pathlib_makenode(node, start, point, goal, pathlib_movecost);
116 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_back)
119 pathlib_makenode(node, start, point, goal, pathlib_movecost);
123 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_right)
126 pathlib_makenode(node, start, point, goal, pathlib_movecost);
130 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_left)
133 pathlib_makenode(node, start, point, goal, pathlib_movecost);
138 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardright)
140 point = where + f + r;
141 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
145 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardleft)
147 point = where + f - r;
148 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
153 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backright)
155 point = where - f + r;
156 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
160 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backleft)
162 point = where - f - r;
163 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
166 return pathlib_open_cnt;
169 float pathlib_expandnode_octagon(entity node, vector start, vector goal)
171 vector point,where,f,r;
175 f = PLIB_FORWARD * pathlib_gridsize;
176 r = PLIB_RIGHT * pathlib_gridsize;
180 pathlib_makenode(node, start, point, goal, pathlib_movecost);
184 pathlib_makenode(node, start, point, goal, pathlib_movecost);
188 pathlib_makenode(node, start, point, goal, pathlib_movecost);
192 pathlib_makenode(node, start, point, goal, pathlib_movecost);
194 f = PLIB_FORWARD * pathlib_gridsize * 0.5;
195 r = PLIB_RIGHT * pathlib_gridsize * 0.5;
198 point = where + f + r;
199 pathlib_makenode(node, start, point, goal, pathlib_movecost);
203 point = where + f - r;
204 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);
215 return pathlib_open_cnt;
218 float pathlib_expandnode_box(entity node, vector start, vector goal)
222 for(v_z = node.origin_z - pathlib_gridsize; v_z <= node.origin_z + pathlib_gridsize; v_z += pathlib_gridsize)
223 for(v_y = node.origin_y - pathlib_gridsize; v_y <= node.origin_y + pathlib_gridsize; v_y += pathlib_gridsize)
224 for(v_x = node.origin_x - pathlib_gridsize; v_x <= node.origin_x + pathlib_gridsize; v_x += pathlib_gridsize)
226 //if(vlen(v - node.origin))
227 pathlib_makenode(node,start,v,goal,pathlib_movecost);
230 return pathlib_open_cnt;