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];
53 for(i = 0; i < 8; ++i)
56 nap = pathlib_nodeatpoint(plib_points[i]);
58 if(nap.owner == openlist)
64 if(plib_fvals[i] < fc)
68 plib_points2[fc2] = plib_points[i];
73 nap = pathlib_nodeatpoint(plib_points[i]);
75 if not nap.owner == closedlist)
81 pathlib_makenode(node, start, bp, goal, pathlib_gridsize);
83 for(i = 0; i < 3; ++i)
85 pathlib_makenode(node, start, plib_points2[i], goal, pathlib_gridsize);
88 return pathlib_open_cnt;
91 float pathlib_expandnode_star(entity node, vector start, vector goal)
93 vector point, where, f, r;
97 f = PLIB_FORWARD * pathlib_gridsize;
98 r = PLIB_RIGHT * pathlib_gridsize;
100 if (node.pathlib_node_edgeflags == pathlib_node_edgeflag_unknown)
101 node.pathlib_node_edgeflags = tile_check_plus2(node.origin);
103 if(node.pathlib_node_edgeflags == pathlib_node_edgeflag_none)
105 dprint("Node at ", vtos(node.origin), " not expanable");
106 return pathlib_open_cnt;
110 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forward)
113 pathlib_makenode(node, start, point, goal, pathlib_movecost);
117 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_back)
120 pathlib_makenode(node, start, point, goal, pathlib_movecost);
124 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_right)
127 pathlib_makenode(node, start, point, goal, pathlib_movecost);
131 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_left)
134 pathlib_makenode(node, start, point, goal, pathlib_movecost);
139 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardright)
141 point = where + f + r;
142 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
146 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardleft)
148 point = where + f - r;
149 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
154 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backright)
156 point = where - f + r;
157 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
161 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backleft)
163 point = where - f - r;
164 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
167 return pathlib_open_cnt;
170 float pathlib_expandnode_octagon(entity node, vector start, vector goal)
172 vector point,where,f,r;
176 f = PLIB_FORWARD * pathlib_gridsize;
177 r = PLIB_RIGHT * pathlib_gridsize;
181 pathlib_makenode(node, start, point, goal, pathlib_movecost);
185 pathlib_makenode(node, start, point, goal, pathlib_movecost);
189 pathlib_makenode(node, start, point, goal, pathlib_movecost);
193 pathlib_makenode(node, start, point, goal, pathlib_movecost);
195 f = PLIB_FORWARD * pathlib_gridsize * 0.5;
196 r = PLIB_RIGHT * pathlib_gridsize * 0.5;
199 point = where + f + r;
200 pathlib_makenode(node, start, point, goal, pathlib_movecost);
204 point = where + f - r;
205 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);
216 return pathlib_open_cnt;
219 float pathlib_expandnode_box(entity node, vector start, vector goal)
223 for(v.z = node.origin.z - pathlib_gridsize; v.z <= node.origin.z + pathlib_gridsize; v.z += pathlib_gridsize)
224 for(v.y = node.origin.y - pathlib_gridsize; v.y <= node.origin.y + pathlib_gridsize; v.y += pathlib_gridsize)
225 for(v.x = node.origin.x - pathlib_gridsize; v.x <= node.origin.x + pathlib_gridsize; v.x += pathlib_gridsize)
227 //if(vlen(v - node.origin))
228 pathlib_makenode(node,start,v,goal,pathlib_movecost);
231 return pathlib_open_cnt;