UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PImplRecastNavMesh.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3//
4// Private implementation for communication with Recast library
5//
6// All functions should be called through RecastNavMesh actor to make them thread safe!
7//
8
9#pragma once
10
11#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_4
12#include "CoreMinimal.h"
13#endif
15#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_4
17#endif
23
24#if RECAST_INTERNAL_DEBUG_DATA
26#endif
27
28#if WITH_RECAST
31#endif
32
34struct FNavLinkId;
35
36#if WITH_RECAST
37
38#define RECAST_VERY_SMALL_AGENT_RADIUS 0.0f
39
42{
43public:
44
47
50
57
58 /* Gather debug geometry.
59 * @params OutGeometry Output geometry.
60 * @params TileIndex Used to collect geometry for a specific tile, INDEX_NONE will gather all tiles.
61 * @return True if done collecting.
62 */
63 UE_DEPRECATED(5.5, "Use the version of this function that takes a FNavTileRef instead.")
65
66 /* Gather debug geometry.
67 * @params OutGeometry Output geometry.
68 * @params TileRef Used to collect geometry for a specific tile, an invalid FNavTileRef will gather all tiles.
69 * @return True if done collecting.
70 */
72
75
77 UE_DEPRECATED(5.5, "Use the version of this function on ARecastNavMesh that takes a FNavTileRef instead.")
79
81 UE_DEPRECATED(5.5, "Use the version of this function on ARecastNavMesh that takes a FNavTileRef instead.")
83
86
88 UE_DEPRECATED(5.5, "Use the version of this function on ARecastNavMesh that takes an array of FNavTileRefs instead.")
89 NAVIGATIONSYSTEM_API void GetNavMeshTilesAt(int32 TileX, int32 TileY, TArray<int32>& Indices) const;
90
92 UE_DEPRECATED(5.5, "Use the version of the function that takes an array of FNavTileRefs instead")
94
97
99 inline int32 GetNavMeshTilesCount() const { return DetourNavMesh ? DetourNavMesh->getMaxTiles() : 0; }
100
104 NAVIGATIONSYSTEM_API ENavigationQueryResult::Type FindPath(const FVector& StartLoc, const FVector& EndLoc, const FVector::FReal CostLimit, const bool bRequireNavigableEndLocation, FNavMeshPath& Path, const FNavigationQueryFilter& Filter, const UObject* Owner) const;
105
107 NAVIGATIONSYSTEM_API ENavigationQueryResult::Type TestPath(const FVector& StartLoc, const FVector& EndLoc, const bool bRequireNavigableEndLocation, const FNavigationQueryFilter& Filter, const UObject* Owner, int32* NumVisitedNodes = 0) const;
108
109 template< typename TRecastAStar, typename TRecastAStartGraph, typename TRecastGraphAStarFilter, typename TRecastAStarResult >
111
113 NAVIGATIONSYSTEM_API void Raycast(const FVector& StartLoc, const FVector& EndLoc, const FNavigationQueryFilter& InQueryFilter, const UObject* Owner,
115
117 NAVIGATIONSYSTEM_API int32 DebugPathfinding(const FVector& StartLoc, const FVector& EndLoc, const FVector::FReal CostLimit, const bool bRequireNavigableEndLocation, const FNavigationQueryFilter& Filter, const UObject* Owner, TArray<FRecastDebugPathfindingData>& Steps);
118
120 NAVIGATIONSYSTEM_API FNavLocation GetRandomPoint(const FNavigationQueryFilter& Filter, const UObject* Owner) const;
121
122#if WITH_NAVMESH_CLUSTER_LINKS
125
128#endif // WITH_NAVMESH_CLUSTER_LINKS
129
134 NAVIGATIONSYSTEM_API bool FindMoveAlongSurface(const FNavLocation& StartLocation, const FVector& TargetPosition, FNavLocation& OutLocation, const FNavigationQueryFilter& Filter, const UObject* Owner) const;
135
137
141
144
147
155
156 //@todo document
157 NAVIGATIONSYSTEM_API void GetEdgesForPathCorridor(const TArray<NavNodeRef>* PathCorridor, TArray<FNavigationPortalEdge>* PathCorridorEdges) const;
158
160 NAVIGATIONSYSTEM_API bool FindStraightPath(const FVector& StartLoc, const FVector& EndLoc, const TArray<NavNodeRef>& PathCorridor, TArray<FNavPathPoint>& PathPoints, TArray<FNavLinkId>* CustomLinks = NULL) const;
161
164
166 UE_DEPRECATED(5.5, "Use the version of this function in ARecastNavMesh that takes a FNavTileRef instead.")
167 NAVIGATIONSYSTEM_API bool GetPolysInTile(int32 TileIndex, TArray<FNavPoly>& Polys) const;
168
171
172#if WITH_NAVMESH_SEGMENT_LINKS
175
178
181#endif // WITH_NAVMESH_SEGMENT_LINKS
182
212 UE_DEPRECATED(5.3, "Please use GetNavLinkUserId() instead. This function only returns Invalid.")
214 {
215 return static_cast<int32>(FNavLinkId::Invalid.GetId());
216 }
222
223#if WITH_NAVMESH_CLUSTER_LINKS
227#endif // WITH_NAVMESH_CLUSTER_LINKS
228
229 uint32 GetTileIndexFromPolyRef(const NavNodeRef PolyRef) const { return DetourNavMesh != NULL ? DetourNavMesh->decodePolyIdTile(PolyRef) : uint32(INDEX_NONE); }
230
233
235
236public:
237 dtNavMesh const* GetRecastMesh() const { return DetourNavMesh; };
240
248 NAVIGATIONSYSTEM_API bool HasTileCacheLayers(int32 TileX, int32 TileY) const;
249
255
257
259#if !UE_BUILD_SHIPPING
261#endif
262
264 NAVIGATIONSYSTEM_API void ApplyWorldOffset(const FVector& InOffset, bool bWorldShift);
265
270
272
275
278
279#if RECAST_INTERNAL_DEBUG_DATA
281#endif
282
285
287 static NAVIGATIONSYSTEM_API void SerializeRecastMeshTile(FArchive& Ar, int32 NavMeshVersion, unsigned char*& TileData, int32& TileDataSize);
288
291
307 FNavMeshPath* OutPath = nullptr) const;
308
310 NAVIGATIONSYSTEM_API void PostProcessPath(dtStatus PathfindResult, FNavMeshPath& Path,
312 NavNodeRef StartNode, NavNodeRef EndNode,
316
317 UE_DEPRECATED(5.5, "Use GetTilePolyEdges instead.")
319
331
333 NAVIGATIONSYSTEM_API void GetEdgesForPathCorridorImpl(const TArray<NavNodeRef>* PathCorridor, TArray<FNavigationPortalEdge>* PathCorridorEdges, const dtNavMeshQuery& NavQuery) const;
334
342
348
350 const dtNavMeshQuery& NavQuery, const dtQueryFilter* QueryFilter,
354};
355
358{
359 const FRecastQueryFilter* FilterImplementation = (const FRecastQueryFilter*)(InQueryFilter.GetImplementation());
360 if (FilterImplementation == nullptr)
361 {
362 UE_VLOG(NavMeshOwner, LogNavigation, Error, TEXT("FPImplRecastNavMesh::FindPath failed due to passed filter having NULL implementation!"));
364 }
365
366 const dtQueryFilter* QueryFilter = FilterImplementation->GetAsDetourQueryFilter();
367 if (QueryFilter == nullptr)
368 {
369 UE_VLOG(NavMeshOwner, LogNavigation, Warning, TEXT("FPImplRecastNavMesh::FindPath failing due to QueryFilter == NULL"));
371 }
372
373 // initialize recast wrapper with the NavMeshOwner, not multithread safe!
376
379 const bool bCanSearch = InitPathfinding(StartLoc, EndLoc, RecastGraphWrapper.GetRecastQuery(), QueryFilter, RecastStartPos, StartPolyID, RecastEndPos, EndPolyID, &Path);
380 if (!bCanSearch)
381 {
383 }
384
385 typename TRecastAStar::FSearchNode StartNode(StartPolyID, RecastStartPos);
386 typename TRecastAStar::FSearchNode EndNode(EndPolyID, RecastEndPos);
387 StartNode.Initialize(RecastGraphWrapper);
388 EndNode.Initialize(RecastGraphWrapper);
390 auto AStarResult = AStarAlgo.FindPath(StartNode, EndNode, AStarFilter, PathResult);
391
393 return PostProcessPathInternal(FindPathStatus, Path, RecastGraphWrapper.GetRecastQuery(), FilterImplementation, StartNode.NodeRef, EndNode.NodeRef,
394 FVector(StartNode.Position[0], StartNode.Position[1], StartNode.Position[2]),
395 FVector(EndNode.Position[0], EndNode.Position[1], EndNode.Position[2]),
396 PathResult);
397}
398
399#endif // WITH_RECAST
OODEFFUNC typedef const int const char * function
Definition oodle2.h:710
#define NULL
Definition oodle2base.h:134
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::SIZE_T SIZE_T
An unsigned integer the same size as a pointer, the same as UPTRINT.
Definition Platform.h:1150
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
uint64 NavNodeRef
Definition NavigationTypes.h:34
#define INVALID_NAVNODEREF
Definition NavigationTypes.h:35
unsigned int dtStatus
Definition RecastGraphAStar.h:29
uint64 dtPolyRef
Definition RecastGraphAStar.h:28
#define UE_VLOG(LogOwner, CategoryName, Verbosity, Format,...)
Definition VisualLogger.h:133
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition RecastNavMesh.h:574
Definition Archive.h:1208
Definition UnrealType.h:3087
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition Object.h:95
Definition DetourNavMeshQuery.h:349
Definition DetourNavMesh.h:503
Definition DetourNavMeshQuery.h:96
UEType_uint64 dtTileRef
Definition DetourNavMesh.h:60
Definition NavigationTypes.h:627
Type
Definition NavigationTypes.h:629
@ Error
Definition NavigationTypes.h:631
Definition RecastNavMesh.h:938
Definition NavigationTypes.h:150
uint64 GetId() const
Definition NavigationTypes.h:175
static ENGINE_API const FNavLinkId Invalid
Definition NavigationTypes.h:212
Definition NavigationTypes.h:252
Definition NavMeshPath.h:39
Definition RecastNavMesh.h:460
Definition NavigationTypes.h:227
Definition NavQueryFilter.h:39
double FReal
Definition Vector.h:55
Definition DetourNavMesh.h:422
Definition DetourNavMeshQuery.h:316