UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
GraphAStar.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "AI/NavigationSystemBase.h" // Needed for LogAStar
6
8{
9 static const int32 NodePoolSize = 64;
10 static const int32 OpenSetSize = 64;
11 static const int32 FatalPathLength = 10000;
12 static const bool bReuseNodePoolInSubsequentSearches = false;
13};
14
22
23inline const int32 NO_COUNT = INT_MAX;
24
25// To get AStar Graph tracing, enable this define
26#define ENABLE_GRAPH_ASTAR_LOGGING 0
27#if ENABLE_GRAPH_ASTAR_LOGGING
28 #define UE_GRAPH_ASTAR_LOG(Verbosity, Format, ...) UE_LOG(LogAStar, Verbosity, Format, __VA_ARGS__)
29#else
30 #define UE_GRAPH_ASTAR_LOG(...)
31#endif
32
37template<typename TGraph>
69
70#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_IMPL( TemplateClass, TemplateClassParameter, ConditionalReturnType, ConditionalFunctionName, DefaultImpl ) \
71struct CQuery##ConditionalFunctionName \
72{ \
73 template<typename TemplateClass> auto Requires(TemplateClassParameter& Obj) -> decltype(Obj.ConditionalFunctionName()); \
74}; \
75template <typename TemplateClass> \
76static inline decltype(auto) ConditionalFunctionName(TemplateClassParameter & Obj) \
77{ \
78 if constexpr (TModels_V<CQuery##ConditionalFunctionName, TemplateClass>) \
79 { \
80 return Obj.ConditionalFunctionName(); \
81 } \
82 else \
83 { \
84 return (ConditionalReturnType)(DefaultImpl); \
85 } \
86}
87#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION( ConditionalReturnType, ConditionalFunctionName, DefaultImpl ) DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_IMPL( TemplateClass, TemplateClass, ConditionalReturnType, ConditionalFunctionName, DefaultImpl )
88#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_CONST( ConditionalReturnType, ConditionalFunctionName, DefaultImpl ) DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_IMPL( TemplateClass, const TemplateClass, ConditionalReturnType, ConditionalFunctionName, DefaultImpl )
89
90#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_1PARAM_IMPL( TemplateClass, TemplateClassParameter, ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, DefaultImpl) \
91struct CQuery##ConditionalFunctionName \
92{ \
93 template<typename TemplateClass> auto Requires(TemplateClassParameter& Obj, ConditionalParamType1 Param1) -> decltype(Obj.ConditionalFunctionName(Param1)); \
94}; \
95template <typename TemplateClass> \
96static inline decltype(auto) ConditionalFunctionName(TemplateClassParameter & Obj, ConditionalParamType1 Param1) \
97{ \
98 if constexpr (TModels_V<CQuery##ConditionalFunctionName, TemplateClass>) \
99 { \
100 return Obj.ConditionalFunctionName(Param1); \
101 } \
102 else \
103 { \
104 return (ConditionalReturnType)(DefaultImpl); \
105 } \
106}
107#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_1PARAM( ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, DefaultImpl) DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_1PARAM_IMPL( TemplateClass, TemplateClass, ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, DefaultImpl)
108#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_1PARAM_CONST( ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, DefaultImpl) DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_1PARAM_IMPL( TemplateClass, const TemplateClass, ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, DefaultImpl)
109
110#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_2PARAMS_IMPL( TemplateClass, TemplateClassParameter, ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, ConditionalParamType2, DefaultImpl) \
111struct CQuery##ConditionalFunctionName \
112{ \
113 template<typename TemplateClass> auto Requires(TemplateClassParameter& Obj, ConditionalParamType1 Param1, ConditionalParamType2 Param2) -> decltype(Obj.ConditionalFunctionName(Param1,Param2)); \
114}; \
115template <typename TemplateClass> \
116static inline decltype(auto) ConditionalFunctionName(TemplateClassParameter & Obj, ConditionalParamType1 Param1, ConditionalParamType2 Param2) \
117{ \
118 if constexpr (TModels_V<CQuery##ConditionalFunctionName, TemplateClass>) \
119 { \
120 return Obj.ConditionalFunctionName(Param1, Param2); \
121 } \
122 else \
123 { \
124 return (ConditionalReturnType)(DefaultImpl); \
125 } \
126}
127#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_2PARAMS( ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, ConditionalParamType2, DefaultImpl) DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_2PARAMS_IMPL( TemplateClass, TemplateClass, ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, ConditionalParamType2, DefaultImpl)
128#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_2PARAMS_CONST( ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, ConditionalParamType2, DefaultImpl) DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_2PARAMS_IMPL(TemplateClass, const TemplateClass, ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, ConditionalParamType2, DefaultImpl)
129
130#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_CUSTOM( ConditionalFunctionName, QueryReturnType, QueryFunctionName, QueryParam, QueryDefaultImpl, QueryImpl) \
131struct CQuery##QueryFunctionName \
132{ \
133 template<typename TemplateClass> auto Requires(const TemplateClass& Obj) -> decltype(Obj.ConditionalFunctionName()); \
134}; \
135template <typename TemplateClass> \
136static inline QueryReturnType QueryFunctionName(const TemplateClass& Obj, QueryParam) \
137{ \
138 if constexpr (TModels_V<CQuery##QueryFunctionName, TemplateClass>) \
139 { \
140 return QueryImpl; \
141 } \
142 else \
143 { \
144 return QueryDefaultImpl; \
145 } \
146}
147
148template<bool DoRangeCheck>
150{
151public:
152
155};
156template <> struct TAllocatorTraits<FRangeChecklessAllocator<true>> : TAllocatorTraits<FDefaultAllocator> {};
157template <> struct TAllocatorTraits<FRangeChecklessAllocator<false>> : TAllocatorTraits<FDefaultAllocator> {};
158
189template<typename TGraph, typename Policy = FGraphAStarDefaultPolicy, typename TSearchNode = FGraphAStarDefaultNode<TGraph>, bool DoRangeCheck = false >
191{
192 typedef typename TGraph::FNodeRef FGraphNodeRef;
194
199
201 {
203
207
208 inline bool operator()(const int32 A, const int32 B) const
209 {
210 return NodePool[A].TotalCost < NodePool[B].TotalCost;
211 }
212 };
213
215 {
218
220 {
221 Super::Reserve(Policy::NodePoolSize);
222 NodeMap.Reserve(FMath::RoundUpToPowerOfTwo(Policy::NodePoolSize / 4));
223 }
224
226 {
228 NewNode.SearchNodeIndex = UE_PTRDIFF_TO_INT32(&NewNode - Super::GetData());
229 NodeMap.Add(SearchNode.NodeRef, NewNode.SearchNodeIndex);
230 return NewNode;
231 }
232
233 inline FSearchNode& FindOrAdd(const FGraphNodeRef NodeRef)
234 {
235 // first find if node already exist in node map
236 const int32 NotInMapIndex = -1;
237 int32& Index = NodeMap.FindOrAdd(NodeRef, NotInMapIndex);
238 if (Index != NotInMapIndex)
239 {
240 return (*this)[Index];
241 }
242
243 // node not found, add it and setup index in node map
244 FSearchNode& NewNode = Super::Emplace_GetRef(NodeRef);
245 NewNode.SearchNodeIndex = UE_PTRDIFF_TO_INT32(&NewNode - Super::GetData());
246 Index = NewNode.SearchNodeIndex;
247
248 return NewNode;
249 }
250
251 inline FSearchNode* Find(const FGraphNodeRef NodeRef)
252 {
253 const int32* IndexPtr = NodeMap.Find(NodeRef);
254 return IndexPtr ? &(*this)[*IndexPtr] : nullptr;
255 }
256
257 inline void Reset()
258 {
259 Super::Reset(Policy::NodePoolSize);
260 NodeMap.Reset();
261 }
262
263 inline void ReinitNodes()
264 {
265 for (FSearchNode& Node : *this)
266 {
267 new (&Node) FSearchNode(Node.NodeRef);
268 }
269 }
270 };
271
273 {
277
283
285 {
286 Super::HeapPush(SearchNode.SearchNodeIndex, NodeSorter);
287 SearchNode.MarkOpened();
288 }
289
291 {
292 for (int32& NodeIndex : *this)
293 {
294 if (NodeIndex == SearchNode.SearchNodeIndex)
295 {
297 return;
298 }
299 }
300 check(false); // We should never reach here.
301 }
302
304 {
305 int32 SearchNodeIndex = INDEX_NONE;
306
307 // During A* we grow the array as needed and it does not make sense to shrink in the process.
309 NodePool[SearchNodeIndex].MarkNotOpened();
310 return SearchNodeIndex;
311 }
312
313 UE_DEPRECATED(5.4, "PopIndex with a boolean bAllowShrinking has been deprecated - please use the version without parameter")
314 inline int32 PopIndex(bool bAllowShrinking)
315 {
316 return PopIndex();
317 }
318 };
319
320 const TGraph& Graph;
324
325
326 // TGraph optionally implemented wrapper methods
330
331 // TQueryFilter optionally implemented wrapper methods
332 DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_2PARAMS_CONST(FVector::FReal, GetTraversalCost, const FSearchNode&, const FSearchNode&, Obj.GetTraversalCost(Param1.NodeRef, Param2.NodeRef))
333 DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_2PARAMS_CONST(FVector::FReal, GetHeuristicCost, const FSearchNode&, const FSearchNode&, Obj.GetHeuristicCost(Param1.NodeRef, Param2.NodeRef))
338 // Custom methods implemented over TQueryFilter optionally implemented methods
339 DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_CUSTOM(GetMaxSearchNodes, bool, HasReachMaxSearchNodes, uint32 NodeCount, false, NodeCount >= Obj.GetMaxSearchNodes());
341
342 // TResultPathInfo optionally implemented wrapper methods
344
347 {
348 NodePool.Reserve(Policy::NodePoolSize);
349 }
350
355 template<typename TQueryFilter>
356 UE_DEPRECATED(5.1, "Please use ProcessSingleNode() taking FVector::FReal& OutBestNodeCost instead!")
357 inline bool ProcessSingleNode(const FSearchNode& EndNode, const bool bIsBound, const TQueryFilter& Filter, int32& OutBestNodeIndex, float& OutBestNodeCost)
358 {
359 double BestNodeCost;
360
361 const bool bSucess = ProcessSingleNode(EndNode, bIsBound, Filter, OutBestNodeIndex, BestNodeCost);
363 return bSucess;
364 }
365
370 template<typename TQueryFilter>
371 inline bool ProcessSingleNode(const FSearchNode& EndNode, const bool bIsBound, const TQueryFilter& Filter, int32& OutBestNodeIndex, FVector::FReal& OutBestNodeCost)
372 {
373 // Pop next best node and put it on closed list
376 ConsideredNodeUnsafe.MarkClosed();
377 UE_GRAPH_ASTAR_LOG(Display, TEXT(" Best node %i (end node %i)"), ConsideredNodeUnsafe.NodeRef, EndNode.NodeRef);
378
379 // We're there, store and move to result composition
380 if (bIsBound && (ConsideredNodeUnsafe.NodeRef == EndNode.NodeRef))
381 {
382 OutBestNodeIndex = ConsideredNodeUnsafe.SearchNodeIndex;
383 OutBestNodeCost = 0.;
384 return false;
385 }
386
387 const FVector::FReal HeuristicScale = Filter.GetHeuristicScale();
388
389 // consider every neighbor of BestNode
391 UE_GRAPH_ASTAR_LOG(Display, TEXT(" Found %i neighbor"), NeighbourCount);
392
394 {
396
397 // invalid neigbour check
398 if (Graph.IsValidRef(NeighbourRef) == false)
399 {
401 {
402 // if user did not implemented the GetNeighbourCount method, let stop at the first invalid neighbour
403 break;
404 }
405 else
406 {
407 // skipping invalid neighbours
408 continue;
409 }
410 }
411
412 // validate and sanitize
415 || Filter.IsTraversalAllowed(NodePool[ConsideredNodeIndex].NodeRef, NeighbourRef) == false)
416 {
417 UE_GRAPH_ASTAR_LOG(Display, TEXT(" Filtered %lld from %lld"), (uint64)NeighbourRef, (uint64)NodePool[ConsideredNodeIndex].NodeRef);
418 continue;
419 }
420
421 // check against max search nodes limit
424 {
425 // let's skip this one if it is not already in the NodePool
428 {
429 UE_GRAPH_ASTAR_LOG(Display, TEXT(" Reach Limit %lld from %lld"), (uint64)NeighbourRef, (uint64)NodePool[ConsideredNodeIndex].NodeRef);
430 continue;
431 }
432 }
434
435 // check condition to avoid search of closed nodes even if they could have lower cost
437 {
438 UE_GRAPH_ASTAR_LOG(Display, TEXT(" Skipping closed %lld from %lld"), (uint64)NeighbourRef, (uint64)NodePool[ConsideredNodeIndex].NodeRef);
439 continue;
440 }
441
442 // calculate cost and heuristic.
444 const FVector::FReal NewHeuristicCost = bIsBound && (NeighbourNode.NodeRef != EndNode.NodeRef)
445 ? (GetHeuristicCost(Filter, NeighbourNode, EndNode) * HeuristicScale)
446 : 0.;
448
449 // check against cost limit
451 {
452 UE_GRAPH_ASTAR_LOG(Display, TEXT(" Skipping reach cost limit %lld from %lld cost %f total %f prev cost %f limit %f"), (uint64)NeighbourRef, (uint64)NodePool[ConsideredNodeIndex].NodeRef, NewTraversalCost, NewTotalCost, NeighbourNode.TotalCost, GetCostLimit(Filter));
453 continue;
454 }
455
456 // check if this is better then the potential previous approach
457 if (NewTotalCost >= NeighbourNode.TotalCost)
458 {
459 // if not, skip
460 UE_GRAPH_ASTAR_LOG(Display, TEXT(" Skipping new cost higher %lld from %lld cost %f total %f prev cost %f"), (uint64)NeighbourRef, (uint64)NodePool[ConsideredNodeIndex].NodeRef, NewTraversalCost, NewTotalCost, NeighbourNode.TotalCost);
461 continue;
462 }
463
464 // fill in
465 NeighbourNode.TraversalCost = NewTraversalCost;
466 NeighbourNode.TotalCost = NewTotalCost;
467 NeighbourNode.ParentRef = NodePool[ConsideredNodeIndex].NodeRef;
468 NeighbourNode.ParentNodeIndex = NodePool[ConsideredNodeIndex].SearchNodeIndex;
469 NeighbourNode.MarkNotClosed();
470
471 if (NeighbourNode.IsOpened() == false)
472 {
473 UE_GRAPH_ASTAR_LOG(Display, TEXT(" Pushing %lld from %lld cost %f total %f"), (uint64)NeighbourRef, (uint64)NodePool[ConsideredNodeIndex].NodeRef, NewTraversalCost, NewTotalCost);
475 }
476 else
477 {
478 UE_GRAPH_ASTAR_LOG(Display, TEXT(" Modifying %lld from %lld cost %f total %f"), (uint64)NeighbourRef, (uint64)NodePool[ConsideredNodeIndex].NodeRef, NewTraversalCost, NewTotalCost);
480 }
481
482 // in case there's no path let's store information on
483 // "closest to goal" node
484 // using Heuristic cost here rather than Traversal or Total cost
485 // since this is what we'll care about if there's no solution - this node
486 // will be the one estimated-closest to the goal
488 {
489 UE_GRAPH_ASTAR_LOG(Display, TEXT(" New best path %lld from %lld new best heuristic %f prev best heuristic %f"), (uint64)NeighbourRef, (uint64)NodePool[ConsideredNodeIndex].NodeRef, NewHeuristicCost, OutBestNodeCost);
491 OutBestNodeIndex = NeighbourNode.SearchNodeIndex;
492 }
493 }
494
495 return true;
496 }
497
503 template<typename TQueryFilter, typename TResultPathInfo = TArray<FGraphNodeRef> >
505 {
507 UE_GRAPH_ASTAR_LOG(Display, TEXT("Starting FindPath request..."));
508
509 if (!Graph.IsValidRef(StartNode.NodeRef) || (ShouldFailOnInvalidEndNode(Filter) && !Graph.IsValidRef(EndNode.NodeRef)))
510 {
511 return SearchFail;
512 }
513
514 if (StartNode.NodeRef == EndNode.NodeRef)
515 {
516 UE_GRAPH_ASTAR_LOG(Display, TEXT("Storing path result (length=1)..."));
517 OutPath.Reset(1);
518 OutPath.AddZeroed(1);
519
520 FSearchNode InitialNode = StartNode;
521 InitialNode.TraversalCost = 0;
522 InitialNode.TotalCost = 0;
523
524 UE_GRAPH_ASTAR_LOG(Display, TEXT(" NodeRef %i"), InitialNode.NodeRef);
526 return SearchSuccess;
527 }
528
529 if (Policy::bReuseNodePoolInSubsequentSearches)
530 {
532 }
533 else
534 {
535 NodePool.Reset();
536 }
537 OpenList.Reset();
538
539 // kick off the search with the first node
542 {
543 // scoping StartPoolNode to make it clear it's not safe to use after ProcessSingleNode due to potential NodePool reallocation
545 StartPoolNode.TraversalCost = 0;
546 StartPoolNode.TotalCost = GetHeuristicCost(Filter, StartNode, EndNode) * Filter.GetHeuristicScale();
547
549
550 BestNodeIndex = StartPoolNode.SearchNodeIndex;
551 BestNodeCost = StartPoolNode.TotalCost;
552 }
553
554 const int32 StartPoolSearchNodeIndex = NodePool[BestNodeIndex].SearchNodeIndex;
556
558 const bool bIsBound = true;
559
560 bool bProcessNodes = true;
561 while (OpenList.Num() > 0 && bProcessNodes)
562 {
564 }
565
566 // check if we've reached the goal
567 if (BestNodeCost != 0.)
568 {
570 }
571
572 // no point to waste perf creating the path if querier doesn't want it
573 if (Result == EGraphAStarResult::SearchSuccess || Filter.WantsPartialSolution())
574 {
575 // store the path. Note that it will be reversed!
576 int32 SearchNodeIndex = BestNodeIndex;
578 do
579 {
580 PathLength++;
581 SearchNodeIndex = NodePool[SearchNodeIndex].ParentNodeIndex;
582 } while (NodePool.IsValidIndex(SearchNodeIndex) && NodePool[SearchNodeIndex].NodeRef != StartPoolNodeRef && ensure(PathLength < Policy::FatalPathLength));
583
584 if (PathLength >= Policy::FatalPathLength)
585 {
587 }
588
589 OutPath.Reset(PathLength);
590 OutPath.AddZeroed(PathLength);
591
592 // store the path
593 UE_GRAPH_ASTAR_LOG(Display, TEXT("Storing path result (length=%i)..."), PathLength);
594 SearchNodeIndex = BestNodeIndex;
595 int32 ResultNodeIndex = PathLength - 1;
596 do
597 {
598 UE_GRAPH_ASTAR_LOG(Display, TEXT(" NodeRef %i"), NodePool[SearchNodeIndex].NodeRef);
599 SetPathInfo(OutPath, ResultNodeIndex--, NodePool[SearchNodeIndex]);
600 SearchNodeIndex = NodePool[SearchNodeIndex].ParentNodeIndex;
601 } while (ResultNodeIndex >= 0);
602 }
603
604 return Result;
605 }
606
608 template<typename TQueryFilter>
610 {
611 if (!(Graph.IsValidRef(StartNode.NodeRef)))
612 {
613 return SearchFail;
614 }
615
616 NodePool.Reset();
617 OpenList.Reset();
618
619 // kick off the search with the first node
622 {
623 // scoping StartPoolNode to make it clear it's not safe to use after ProcessSingleNode due to potential NodePool reallocation
625 StartPoolNode.TraversalCost = 0;
626 StartPoolNode.TotalCost = 0;
627
629
630 BestNodeIndex = StartPoolNode.SearchNodeIndex;
631 BestNodeCost = StartPoolNode.TotalCost;
632 }
633
634 const FSearchNode FakeEndNode = StartNode;
635 const bool bIsBound = false;
636
637 bool bProcessNodes = true;
638 while (OpenList.Num() > 0 && bProcessNodes)
639 {
641 }
642
644 }
645
646 template<typename TQueryFilter>
651};
#define check(expr)
Definition AssertionMacros.h:314
#define ensure( InExpression)
Definition AssertionMacros.h:464
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define UE_PTRDIFF_TO_INT32(argument)
Definition CoreMiscDefines.h:442
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
DIRECTLINK_API Display
Definition DirectLinkLog.h:8
return true
Definition ExternalRpcRegistry.cpp:601
EGraphAStarResult
Definition GraphAStar.h:16
@ SearchSuccess
Definition GraphAStar.h:18
@ InfiniteLoop
Definition GraphAStar.h:20
@ SearchFail
Definition GraphAStar.h:17
@ GoalUnreachable
Definition GraphAStar.h:19
#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_CUSTOM(ConditionalFunctionName, QueryReturnType, QueryFunctionName, QueryParam, QueryDefaultImpl, QueryImpl)
Definition GraphAStar.h:130
const int32 NO_COUNT
Definition GraphAStar.h:23
#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_2PARAMS(ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, ConditionalParamType2, DefaultImpl)
Definition GraphAStar.h:127
#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_2PARAMS_CONST(ConditionalReturnType, ConditionalFunctionName, ConditionalParamType1, ConditionalParamType2, DefaultImpl)
Definition GraphAStar.h:128
#define UE_GRAPH_ASTAR_LOG(...)
Definition GraphAStar.h:30
#define DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_CONST(ConditionalReturnType, ConditionalFunctionName, DefaultImpl)
Definition GraphAStar.h:88
#define UE_REAL_TO_FLOAT_CLAMPED_MAX(argument)
Definition LargeWorldCoordinates.h:33
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition GraphAStar.h:150
@ RequireRangeCheck
Definition GraphAStar.h:154
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
void Reset(SizeType NewSize=0)
Definition Array.h:2246
UE_NODEBUG UE_FORCEINLINE_HINT ElementType * GetData() UE_LIFETIMEBOUND
Definition Array.h:1027
SizeType HeapPush(ElementType &&InItem, const PREDICATE_CLASS &Predicate)
Definition Array.h:3671
UE_FORCEINLINE_HINT ElementType & Emplace_GetRef(ArgsType &&... Args) UE_LIFETIMEBOUND
Definition Array.h:2613
void HeapPop(ElementType &OutItem, const PREDICATE_CLASS &Predicate, EAllowShrinking AllowShrinking=UE::Core::Private::AllowShrinkingByDefault< AllocatorType >())
Definition Array.h:3748
UE_NODEBUG UE_FORCEINLINE_HINT bool IsValidIndex(SizeType Index) const
Definition Array.h:1122
UE_FORCEINLINE_HINT void Reserve(SizeType Number)
Definition Array.h:3016
Definition ContainerAllocationPolicies.h:1662
Definition ContainerAllocationPolicies.h:830
Definition ContainerAllocationPolicies.h:894
CORE_API void Reset(int32 NewReservedSize=0)
Definition String.cpp.inl:326
IndexType HeapSiftUp(RangeValueType *Heap, IndexType RootIndex, IndexType NodeIndex, const ProjectionType &InProj, const PredicateType &Predicate)
Definition BinaryHeap.h:109
@ false
Definition radaudio_common.h:23
U16 Index
Definition radfft.cpp:71
Definition GraphAStar.h:39
TGraph::FNodeRef FGraphNodeRef
Definition GraphAStar.h:40
bool IsClosed() const
Definition GraphAStar.h:67
bool IsOpened() const
Definition GraphAStar.h:66
uint8 bIsClosed
Definition GraphAStar.h:49
int32 ParentNodeIndex
Definition GraphAStar.h:47
FGraphNodeRef ParentRef
Definition GraphAStar.h:43
FVector::FReal TotalCost
Definition GraphAStar.h:45
FGraphAStarDefaultNode(const FGraphNodeRef &InNodeRef)
Definition GraphAStar.h:51
void MarkNotClosed()
Definition GraphAStar.h:65
const FGraphNodeRef NodeRef
Definition GraphAStar.h:42
uint8 bIsOpened
Definition GraphAStar.h:48
int32 SearchNodeIndex
Definition GraphAStar.h:46
FVector::FReal TraversalCost
Definition GraphAStar.h:44
void MarkClosed()
Definition GraphAStar.h:64
void MarkNotOpened()
Definition GraphAStar.h:63
void MarkOpened()
Definition GraphAStar.h:62
Definition GraphAStar.h:8
static const int32 FatalPathLength
Definition GraphAStar.h:11
static const int32 OpenSetSize
Definition GraphAStar.h:10
static const int32 NodePoolSize
Definition GraphAStar.h:9
static const bool bReuseNodePoolInSubsequentSearches
Definition GraphAStar.h:12
Definition GraphAStar.h:215
void ReinitNodes()
Definition GraphAStar.h:263
FSearchNode & FindOrAdd(const FGraphNodeRef NodeRef)
Definition GraphAStar.h:233
FSearchNode * Find(const FGraphNodeRef NodeRef)
Definition GraphAStar.h:251
FNodeMap NodeMap
Definition GraphAStar.h:217
FNodePool()
Definition GraphAStar.h:219
void Reset()
Definition GraphAStar.h:257
FSearchNode & Add(const FSearchNode &SearchNode)
Definition GraphAStar.h:225
FNodeArray Super
Definition GraphAStar.h:216
Definition GraphAStar.h:201
const FNodeArray & NodePool
Definition GraphAStar.h:202
bool operator()(const int32 A, const int32 B) const
Definition GraphAStar.h:208
FNodeSorter(const FNodeArray &InNodePool)
Definition GraphAStar.h:204
Definition GraphAStar.h:273
FOpenList(FNodeArray &InNodePool, const FNodeSorter &InNodeSorter)
Definition GraphAStar.h:278
const FNodeSorter & NodeSorter
Definition GraphAStar.h:276
FIndexArray Super
Definition GraphAStar.h:274
void Modify(FSearchNode &SearchNode)
Definition GraphAStar.h:290
void Push(FSearchNode &SearchNode)
Definition GraphAStar.h:284
int32 PopIndex()
Definition GraphAStar.h:303
FNodeArray & NodePool
Definition GraphAStar.h:275
Definition GraphAStar.h:191
bool HasReachMaxSearchNodes(const TQueryFilter &Filter) const
Definition GraphAStar.h:647
FNodeSorter NodeSorter
Definition GraphAStar.h:322
EGraphAStarResult FindPath(const FSearchNode &StartNode, const FSearchNode &EndNode, const TQueryFilter &Filter, TResultPathInfo &OutPath)
Definition GraphAStar.h:504
TSearchNode FSearchNode
Definition GraphAStar.h:193
bool ProcessSingleNode(const FSearchNode &EndNode, const bool bIsBound, const TQueryFilter &Filter, int32 &OutBestNodeIndex, FVector::FReal &OutBestNodeCost)
Definition GraphAStar.h:371
TGraph::FNodeRef FGraphNodeRef
Definition GraphAStar.h:192
DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_2PARAMS_CONST(FGraphNodeRef, GetNeighbour, const FSearchNode &, const int32, Obj.GetNeighbour(Param1.NodeRef, Param2))
DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_1PARAM_CONST(int32, GetNeighbourCountV2, const FSearchNode &, Obj.GetNeighbourCount(Param1.NodeRef))
const TGraph & Graph
Definition GraphAStar.h:320
FNodePool NodePool
Definition GraphAStar.h:321
bool ProcessSingleNode(const FSearchNode &EndNode, const bool bIsBound, const TQueryFilter &Filter, int32 &OutBestNodeIndex, float &OutBestNodeCost)
Definition GraphAStar.h:357
DECLARE_OPTIONALLY_IMPLEMENTED_TEMPLATE_CLASS_FUNCTION_1PARAM_CONST(int32, GetNeighbourCount, const FGraphNodeRef, NO_COUNT)
EGraphAStarResult FloodFrom(const FSearchNode &StartNode, const TQueryFilter &Filter)
Definition GraphAStar.h:609
FOpenList OpenList
Definition GraphAStar.h:323
Definition IdentityFunctor.h:11
Definition ContainerAllocationPolicies.h:256
Definition IsPointer.h:12
Definition NumericLimits.h:41
T FReal
Definition Vector.h:55