1
0
Fork 0

Add ‘nearest node not on a runway’ to ground-net

This will be used shortly to find a better (not on the grass, ideally)
start position when using multi-player but requesting a runway start.
This commit is contained in:
James Turner 2016-11-08 09:27:52 +01:00
parent e523b57215
commit 5fe4486df1
2 changed files with 20 additions and 0 deletions

View file

@ -222,6 +222,24 @@ FGTaxiNodeRef FGGroundNetwork::findNearestNode(const SGGeod & aGeod) const
return result;
}
FGTaxiNodeRef FGGroundNetwork::findNearestNodeOffRunway(const SGGeod& aGeod) const
{
SGVec3d cartPos = SGVec3d::fromGeod(aGeod);
auto node = std::min_element(m_nodes.begin(), m_nodes.end(),
[cartPos](const FGTaxiNodeRef& a, const FGTaxiNodeRef& b)
{
double aDist = a->getIsOnRunway() ? DBL_MAX : distSqr(cartPos, a->cart());
double bDist = b->getIsOnRunway() ? DBL_MAX : distSqr(cartPos, b->cart());
return aDist < bDist;
});
if (node == m_nodes.end()) {
return FGTaxiNodeRef();
}
return *node;
}
FGTaxiNodeRef FGGroundNetwork::findNearestNodeOnRunway(const SGGeod & aGeod, FGRunway* aRunway) const
{
SG_UNUSED(aRunway);

View file

@ -249,6 +249,8 @@ public:
FGTaxiNodeRef findNearestNode(const SGGeod& aGeod) const;
FGTaxiNodeRef findNearestNodeOnRunway(const SGGeod& aGeod, FGRunway* aRunway = NULL) const;
FGTaxiNodeRef findNearestNodeOffRunway(const SGGeod& aGeod) const;
FGTaxiSegment *findSegment(unsigned int idx) const;
FGTaxiSegment* findOppositeSegment(unsigned int index) const;