MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / FindBestIndex

Method FindBestIndex

engine/Poseidon/AI/Path/PathPlanner.cpp:1431–1453  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1429}
1430
1431int 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
1455void AIPathPlanner::CalculatePlanPositions()
1456{

Callers 4

ExposureChangedMethod · 0.80
CopyPathMethod · 0.80
OperPathMethod · 0.80
DrawExtMethod · 0.80

Calls 2

saturateFunction · 0.85
SizeMethod · 0.45

Tested by

no test coverage detected