void UNavigationPath::SetPathPointsFromPath(FNavigationPath& NativePath) { PathPoints.Reset(NativePath.GetPathPoints().Num()); for (const auto& PathPoint : NativePath.GetPathPoints()) { PathPoints.Add(PathPoint.Location); } }
void FGameplayDebuggerCategory_AI::CollectPathData(AAIController* DebugAI) { UPathFollowingComponent* PathComp = DebugAI ? DebugAI->GetPathFollowingComponent() : nullptr; DataPack.bIsUsingPathFollowing = (PathComp != nullptr); if (PathComp) { TArray<FString> Tokens; TArray<EPathFollowingDebugTokens::Type> Flags; PathComp->GetDebugStringTokens(Tokens, Flags); for (int32 Idx = 0; Idx < Tokens.Num(); Idx++) { switch (Flags[Idx]) { case EPathFollowingDebugTokens::Description: DataPack.PathFollowingInfo += Tokens[Idx]; break; case EPathFollowingDebugTokens::ParamName: DataPack.PathFollowingInfo += TEXT(", {yellow}"); DataPack.PathFollowingInfo += Tokens[Idx]; DataPack.PathFollowingInfo += TEXT(":"); break; case EPathFollowingDebugTokens::PassedValue: DataPack.PathFollowingInfo += TEXT("{yellow}"); DataPack.PathFollowingInfo += Tokens[Idx]; break; case EPathFollowingDebugTokens::FailedValue: DataPack.PathFollowingInfo += TEXT("{orange}"); DataPack.PathFollowingInfo += Tokens[Idx]; break; default: break; } } FNavigationPath* CurrentPath = PathComp->GetPath().Get(); if (CurrentPath) { DataPack.bPathHasGoalActor = (CurrentPath->GetGoalActor() != nullptr); DataPack.PathGoalLocation = CurrentPath->GetGoalLocation(); DataPack.NextPathPointIndex = PathComp->GetNextPathIndex(); } if ((CurrentPath != RawLastPath) || (CurrentPath && (CurrentPath->GetLastUpdateTime() != LastPathUpdateTime) )) { RawLastPath = CurrentPath; PathDataPack = FRepDataPath(); if (CurrentPath) { LastPathUpdateTime = CurrentPath->GetLastUpdateTime(); const FNavMeshPath* NavMeshPath = CurrentPath->CastPath<FNavMeshPath>(); const ARecastNavMesh* NavData = Cast<const ARecastNavMesh>(CurrentPath->GetNavigationDataUsed()); if (NavMeshPath && NavData) { for (int32 Idx = 0; Idx < NavMeshPath->PathCorridor.Num(); Idx++) { FRepDataPath::FPoly PolyData; NavData->GetPolyVerts(NavMeshPath->PathCorridor[Idx], PolyData.Points); const uint32 AreaId = NavData->GetPolyAreaID(NavMeshPath->PathCorridor[Idx]); PolyData.Color = NavData->GetAreaIDColor(AreaId); PathDataPack.PathCorridor.Add(PolyData); } } for (int32 Idx = 0; Idx < CurrentPath->GetPathPoints().Num(); Idx++) { PathDataPack.PathPoints.Add(CurrentPath->GetPathPoints()[Idx].Location); } } } } }