finally I made some polishing and place code to:
1: class NavigationMesh
/// NavAreas for this NavMesh
PODVector<Node*> areas_;
2: To reduce performance penalty I placed getNodes into CollectGeometries(). So in this case we update areas_ array only when we doing navMesh->Build()
3: simplify NavigationMesh::FindPath
[code] // Transform path result back to world space
for (int i = 0; i < numPathPoints; ++i)
{
bool find = false;
NavigationPathPoint pt;
pt.position_ = transform * pathData_->pathPoints_[i];
pt.flag_ = (NavigationPathPointFlag)pathData_->pathFlags_[i];
pt.areaID_ = pathData_->pathAreras_[i];
// Fix2-begin for NavArea components
for (unsigned j = 0; j < areas_.Size(); j++)
{
NavArea* area = areas_[j]->GetComponent<NavArea>();
if (area && area->IsEnabledEffective())
{
BoundingBox bb = area->GetWorldBoundingBox();
if (bb.IsInside(pt.position_) == INSIDE)
{
pt.areaID_ = (unsigned char)area->GetAreaID();
break;
}
}
}
// Fix2-end for NavArea components
dest.Push(pt);
}
[/code]
so after this fixes it’s works fine for my using case, expect one moment when agent travelling though offMeshConnection, it not get areaID from this offMeshConnection.
(actually as before they also return garbage values, but now my navAreas override garbage values then by new execution path)
4: also I think if few navAreas have the same point within need doing some kind of sorting by distance to navArea origin for choose nearest navArea
- so, since this feature works without Detour middleware(above it / over it) there is no need keep only 64 max navAreas i suppose.