1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196
|
vector plib_points2[8];
vector plib_points[8];
float plib_fvals[8];
float pathlib_expandnode_starf(entity node, vector start, vector goal)
{
vector where,f,r,t;
float i,fc,fc2,c;
entity nap;
where = node.origin;
f = PLIB_FORWARD * pathlib_gridsize;
r = PLIB_RIGHT * pathlib_gridsize;
// Forward
plib_points[0] = where + f;
// Back
plib_points[1] = where - f;
// Right
plib_points[2] = where + r;
// Left
plib_points[3] = where - r;
// Forward-right
plib_points[4] = where + f + r;
// Forward-left
plib_points[5] = where + f - r;
// Back-right
plib_points[6] = where - f + r;
// Back-left
plib_points[7] = where - f - r;
for(i=0;i < 8; ++i)
{
t = plib_points[i];
fc = pathlib_heuristic(t,goal) + pathlib_cost(node,t,pathlib_gridsize);
plib_fvals[i] = fc;
}
fc = plib_fvals[0];
plib_points2[0] = plib_points[0];
vector bp;
bp = plib_points[0];
for(i = 0; i < 8; ++i)
{
c = 0;
nap = pathlib_nodeatpoint(plib_points[i]);
if(nap)
if(nap.owner == openlist)
c = 1;
else
c = 1;
if(c)
if(plib_fvals[i] < fc)
{
bp = plib_points[i];
fc = plib_fvals[i];
plib_points2[fc2] = plib_points[i];
++fc2;
}
/*
nap = pathlib_nodeatpoint(plib_points[i]);
if(nap)
if not nap.owner == closedlist)
{
}
*/
}
pathlib_makenode(node,start,bp,goal,pathlib_gridsize);
for(i = 0; i < 3; ++i)
{
pathlib_makenode(node,start,plib_points2[i],goal,pathlib_gridsize);
}
return pathlib_open_cnt;
}
float pathlib_expandnode_star(entity node, vector start, vector goal)
{
vector point,where,f,r;
where = node.origin;
f = PLIB_FORWARD * pathlib_gridsize;
r = PLIB_RIGHT * pathlib_gridsize;
// Forward
point = where + f;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
// Back
point = where - f;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
// Right
point = where + r;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
// Left
point = where - r;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
// Forward-right
point = where + f + r;
pathlib_makenode(node,start,point,goal,pathlib_movecost_diag);
// Forward-left
point = where + f - r;
pathlib_makenode(node,start,point,goal,pathlib_movecost_diag);
// Back-right
point = where - f + r;
pathlib_makenode(node,start,point,goal,pathlib_movecost_diag);
// Back-left
point = where - f - r;
pathlib_makenode(node,start,point,goal,pathlib_movecost_diag);
return pathlib_open_cnt;
}
float pathlib_expandnode_octagon(entity node, vector start, vector goal)
{
vector point,where,f,r;
where = node.origin;
f = PLIB_FORWARD * pathlib_gridsize;
r = PLIB_RIGHT * pathlib_gridsize;
// Forward
point = where + f;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
// Back
point = where - f;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
// Right
point = where + r;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
// Left
point = where - r;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
f = PLIB_FORWARD * pathlib_gridsize * 0.5;
r = PLIB_RIGHT * pathlib_gridsize * 0.5;
// Forward-right
point = where + f + r;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
// Forward-left
point = where + f - r;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
// Back-right
point = where - f + r;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
// Back-left
point = where - f - r;
pathlib_makenode(node,start,point,goal,pathlib_movecost);
return pathlib_open_cnt;
}
float pathlib_expandnode_box(entity node, vector start, vector goal)
{
vector v;
for(v_z = node.origin_z - pathlib_gridsize; v_z <= node.origin_z + pathlib_gridsize; v_z += pathlib_gridsize)
for(v_y = node.origin_y - pathlib_gridsize; v_y <= node.origin_y + pathlib_gridsize; v_y += pathlib_gridsize)
for(v_x = node.origin_x - pathlib_gridsize; v_x <= node.origin_x + pathlib_gridsize; v_x += pathlib_gridsize)
{
//if(vlen(v - node.origin))
pathlib_makenode(node,start,v,goal,pathlib_movecost);
}
return pathlib_open_cnt;
}
|