4 vector plib_points2[8];
8 float pathlib_expandnode_starf(entity node, vector start, vector goal)
16 f = PLIB_FORWARD * pathlib_gridsize;
17 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)
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 nap = pathlib_nodeatpoint(plib_points[i]);
61 if(nap.owner == openlist)
67 if(plib_fvals[i] < fc)
71 plib_points2[fc2] = plib_points[i];
76 nap = pathlib_nodeatpoint(plib_points[i]);
78 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;
94 float pathlib_expandnode_star(entity node, vector start, vector goal)
96 vector point, where, f, r;
100 f = PLIB_FORWARD * pathlib_gridsize;
101 r = PLIB_RIGHT * pathlib_gridsize;
103 if (node.pathlib_node_edgeflags == pathlib_node_edgeflag_unknown)
104 node.pathlib_node_edgeflags = tile_check_plus2(node.origin);
106 if(node.pathlib_node_edgeflags == pathlib_node_edgeflag_none)
108 dprint("Node at ", vtos(node.origin), " not expanable");
109 return pathlib_open_cnt;
113 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forward)
116 pathlib_makenode(node, start, point, goal, pathlib_movecost);
120 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_back)
123 pathlib_makenode(node, start, point, goal, pathlib_movecost);
127 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_right)
130 pathlib_makenode(node, start, point, goal, pathlib_movecost);
134 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_left)
137 pathlib_makenode(node, start, point, goal, pathlib_movecost);
142 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardright)
144 point = where + f + r;
145 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
149 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_forwardleft)
151 point = where + f - r;
152 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
157 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backright)
159 point = where - f + r;
160 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
164 if (node.pathlib_node_edgeflags & pathlib_node_edgeflag_backleft)
166 point = where - f - r;
167 pathlib_makenode(node, start, point, goal, pathlib_movecost_diag);
170 return pathlib_open_cnt;
173 float pathlib_expandnode_octagon(entity node, vector start, vector goal)
175 vector point,where,f,r;
179 f = PLIB_FORWARD * pathlib_gridsize;
180 r = PLIB_RIGHT * pathlib_gridsize;
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);
196 pathlib_makenode(node, start, point, goal, pathlib_movecost);
198 f = PLIB_FORWARD * pathlib_gridsize * 0.5;
199 r = PLIB_RIGHT * pathlib_gridsize * 0.5;
202 point = where + f + r;
203 pathlib_makenode(node, start, point, goal, pathlib_movecost);
207 point = where + f - r;
208 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;
222 float pathlib_expandnode_box(entity node, vector start, vector goal)
226 for(v.z = node.origin.z - pathlib_gridsize; v.z <= node.origin.z + pathlib_gridsize; v.z += pathlib_gridsize)
227 for(v.y = node.origin.y - pathlib_gridsize; v.y <= node.origin.y + pathlib_gridsize; v.y += pathlib_gridsize)
228 for(v.x = node.origin.x - pathlib_gridsize; v.x <= node.origin.x + pathlib_gridsize; v.x += pathlib_gridsize)
230 //if(vlen(v - node.origin))
231 pathlib_makenode(node,start,v,goal,pathlib_movecost);
234 return pathlib_open_cnt;