34 for (
int x = 0; x < 8; x++)
40 neighbors.push_back(tmp);
49 for (
int x = 0; x < 8; x++)
53 actions.push_back(act);
58 actions.push_back(act);
81 case 6: s.
y -= 1;
break;
82 case 0: s.
x += 1;
break;
83 case 2: s.
y += 1;
break;
84 case 4: s.
x -= 1;
break;
85 case 7: s.
y -= 1; s.
x += 1;
break;
86 case 1: s.
y += 1; s.
x += 1;
break;
87 case 3: s.
y += 1; s.
x -= 1;
break;
88 case 5: s.
y -= 1; s.
x -= 1;
break;
100 double a = ((l1.
x>l2.
x)?(l1.
x-l2.
x):(l2.
x-l1.
x));
101 double b = ((l1.
y>l2.
y)?(l1.
y-l2.
y):(l2.
y-l1.
y));
111 if (a.
x == b.
x && a.
y == b.
y)
116 float heading = atan2(a.
x-b.
x, a.
y-b.
y);
117 int conv = (360.0*heading/(2*3.1415)+180+(b.
h+2)*45);
129 float cost1 =
max(-P*cos(1.0*2*3.1415*conv/360.0), 0);
132 float dist = sqrt((a.
x-b.
x)*(a.
x-b.
x)+(a.
y-b.
y)*(a.
y-b.
y));
134 float cost2 =
min(fabs(D-dist)/D, 1.0);
137 return 10*cost1/dist+cost2;
142 if (node1.
h != node2.
h)
145 double costModifier = 1.0;
148 for (
const auto &it :
costs)
153 costModifier +=
GetCost(node1, tmp, it.second.seen, it.second.dist);
162 if (0 == (node1.
h%2))
172 double costModifier = 1.0;
174 for (
const auto &it :
costs)
179 costModifier +=
GetCost(node1, tmp, it.second.seen, it.second.dist);
202 return (
node == goal);
207 uint64_t res =
node.x;
208 res = (res<<16)|
node.y;
209 res = (res<<16)|
node.h;
216 node.h = hash&0xFFFF;
218 node.y = hash&0xFFFF;
220 node.x = hash&0xFFFF;
236 for (CostTable::const_iterator it =
costs.begin(); it !=
costs.end(); it++)
246 GLdouble xx, yy, zz, rad;
251 GLdouble yoffset =
mySin(l.
h)*rad;
252 GLdouble xoffset =
myCos(l.
h)*rad;
254 glBegin(GL_TRIANGLES);
256 surfaceNormal.
x = (((-0.5*xoffset) * (-rad)) - ((+rad) - (-2*yoffset)));
257 surfaceNormal.
y = (((rad) * (-2*xoffset)) - ((0.5*yoffset) - (rad)));
258 surfaceNormal.
z = (((0.5*yoffset) * (-2*yoffset)) - ((-0.5*xoffset) - (-2*xoffset)));
260 glNormal3f(surfaceNormal.
x, surfaceNormal.
y, surfaceNormal.
z);
261 glColor4f(r, g, b/2, t);
262 glVertex3f(xx+xoffset, yy+yoffset, zz);
263 glColor4f(r, g/2, b, t);
264 glVertex3f(xx-xoffset, yy-yoffset, zz-rad);
265 glColor4f(r, g, b/2, t);
266 glVertex3f(xx-xoffset+0.5*yoffset, yy-yoffset-0.5*xoffset, zz);
268 surfaceNormal.
x = (((+0.5*xoffset) * (-rad)) - ((+rad) - (-2*yoffset)));
269 surfaceNormal.
y = (((rad) * (-2*xoffset)) - ((-0.5*yoffset) - (rad)));
270 surfaceNormal.
z = (((-0.5*yoffset) * (-2*yoffset)) - ((+0.5*xoffset) - (-2*xoffset)));
272 glNormal3f(surfaceNormal.
x, surfaceNormal.
y, surfaceNormal.
z);
273 glColor4f(r, g/2, b, t);
274 glVertex3f(xx+xoffset, yy+yoffset, zz);
275 glColor4f(r, g, b/2, t);
276 glVertex3f(xx-xoffset, yy-yoffset, zz-rad);
277 glColor4f(r, g/2, b, t);
278 glVertex3f(xx-xoffset-0.5*yoffset, yy-yoffset+0.5*xoffset, zz);
292 GLdouble xx, yy, zz, rad;
294 map->
GetOpenGLCoord(perc*newState.
x + (1-perc)*oldState.
x, perc*newState.
y + (1-perc)*oldState.
y, xx, yy, zz, rad);
296 float rot = (1-perc)*oldState.
h+perc*newState.
h;
298 if ((oldState.
h >= DEG-2) && (newState.
h <= 2))
300 rot = (1-perc)*oldState.
h+perc*(newState.
h+DEG);
304 else if ((newState.
h >= DEG-2) && (oldState.
h <= 2))
306 rot = (1-perc)*(oldState.
h+DEG)+perc*(newState.
h);
311 GLdouble yoffset = sin(
TWOPI*rot/8.0)*rad;
312 GLdouble xoffset = cos(
TWOPI*rot/8.0)*rad;
314 glBegin(GL_TRIANGLES);
316 surfaceNormal.
x = (((-0.5*xoffset) * (-rad)) - ((+rad) - (-2*yoffset)));
317 surfaceNormal.
y = (((rad) * (-2*xoffset)) - ((0.5*yoffset) - (rad)));
318 surfaceNormal.
z = (((0.5*yoffset) * (-2*yoffset)) - ((-0.5*xoffset) - (-2*xoffset)));
320 glNormal3f(surfaceNormal.
x, surfaceNormal.
y, surfaceNormal.
z);
321 glColor4f(r, g, b/2, t);
322 glVertex3f(xx+xoffset, yy+yoffset, zz);
323 glColor4f(r, g/2, b, t);
324 glVertex3f(xx-xoffset, yy-yoffset, zz-rad);
325 glColor4f(r, g, b/2, t);
326 glVertex3f(xx-xoffset+0.5*yoffset, yy-yoffset-0.5*xoffset, zz);
328 surfaceNormal.
x = (((+0.5*xoffset) * (-rad)) - ((+rad) - (-2*yoffset)));
329 surfaceNormal.
y = (((rad) * (-2*xoffset)) - ((-0.5*yoffset) - (rad)));
330 surfaceNormal.
z = (((-0.5*yoffset) * (-2*yoffset)) - ((+0.5*xoffset) - (-2*xoffset)));
332 glNormal3f(surfaceNormal.
x, surfaceNormal.
y, surfaceNormal.
z);
333 glColor4f(r, g/2, b, t);
334 glVertex3f(xx+xoffset, yy+yoffset, zz);
335 glColor4f(r, g, b/2, t);
336 glVertex3f(xx-xoffset, yy-yoffset, zz-rad);
337 glColor4f(r, g/2, b, t);
338 glVertex3f(xx-xoffset-0.5*yoffset, yy-yoffset+0.5*xoffset, zz);
367 for (
float x = 0; x < DEG; x++)