| 1429 | } |
| 1430 | |
| 1431 | int AIPathPlanner::FindBestIndex(Vector3Par pos) const |
| 1432 | { |
| 1433 | int n = _plan.Size(); |
| 1434 | if (n == 0) |
| 1435 | { |
| 1436 | return -1; |
| 1437 | } |
| 1438 | |
| 1439 | int planIndex = -1; |
| 1440 | float dist2Min = FLT_MAX; |
| 1441 | for (int i = 0; i < n - 1; i++) |
| 1442 | { |
| 1443 | float dist2 = Distance(i, pos); |
| 1444 | if (dist2 < dist2Min) |
| 1445 | { |
| 1446 | dist2Min = dist2; |
| 1447 | planIndex = i; |
| 1448 | } |
| 1449 | } |
| 1450 | planIndex += 2; |
| 1451 | saturate(planIndex, 0, _plan.Size() - 1); |
| 1452 | return planIndex; |
| 1453 | } |
| 1454 | |
| 1455 | void AIPathPlanner::CalculatePlanPositions() |
| 1456 | { |