23template<
class Po
intSetType>
62 MaxGraphDistance = 0.0;
63 MaxGraphDistancePointID = -1;
78 IDToNodeIndexMap.Reset();
79 AllocatedNodes.
Clear();
81 MaxGraphDistance = 0.0;
82 MaxGraphDistancePointID = -1;
107 MaxGraphDistance = 0.0f;
108 MaxGraphDistancePointID = -1;
113 int32 NewIndex = SeedPoints.Num();
119 FGraphNode* Node = GetNodeForPointSetID(PointID,
true);
120 Node->GraphDistance =
SeedPoint.StartDistance;
121 Node->bFrozen =
true;
122 Node->SeedPointID = NewIndex;
123 Queue.
Insert(PointID,
float(Node->GraphDistance));
130 FGraphNode* Node = GetNodeForPointSetID(NextID,
false);
131 check(Node !=
nullptr);
139 Node->bFrozen =
true;
140 MaxGraphDistancePointID = Node->PointID;
141 UpdateNeighboursSparse(Node);
157 for (
int32 k = 0; k < N; ++k)
175 MaxGraphDistance = 0.0f;
176 MaxGraphDistancePointID = -1;
181 int32 NewIndex = SeedPoints.Num();
187 FGraphNode* Node = GetNodeForPointSetID(PointID,
true);
188 Node->GraphDistance =
SeedPoint.StartDistance;
189 Node->bFrozen =
true;
190 Node->SeedPointID = NewIndex;
191 Queue.
Insert(PointID, (
float)Node->GraphDistance);
198 FGraphNode* Node = GetNodeForPointSetID(NextID,
false);
199 check(Node !=
nullptr);
207 Node->bFrozen =
true;
208 MaxGraphDistancePointID = Node->PointID;
215 UpdateNeighboursSparse(Node);
229 return MaxGraphDistance;
238 return MaxGraphDistancePointID;
247 const FGraphNode* Node = GetNodeForPointSetID(PointID);
248 if (Node ==
nullptr || Node->bFrozen ==
false)
262 const FGraphNode* Node = GetNodeForPointSetID(PointID);
263 return (Node !=
nullptr && Node->bFrozen);
272 const FGraphNode* Node = GetNodeForPointSetID(PointID);
273 return (Node !=
nullptr && Node->bFrozen) ? Node->GraphDistance :
InvalidDistance();
285 const FGraphNode*
CurNode = GetNodeForPointSetID(PointID);
297 if (
CurNode->ParentPointID == -1)
322 double GraphDistance;
329 TDynamicVector<FGraphNode> AllocatedNodes;
332 FIndexPriorityQueue Queue;
337 double MaxGraphDistance;
339 int32 MaxGraphDistancePointID;
341 FGraphNode* GetNodeForPointSetID(
int32 PointSetID,
bool bCreateIfMissing)
346 if (bCreateIfMissing)
348 FGraphNode NewNode{
PointSetID, -1, 0,
false };
349 int32 NewIndex = AllocatedNodes.Num();
350 AllocatedNodes.Add(NewNode);
352 return &AllocatedNodes[NewIndex];
376 void UpdateNeighboursSparse(FGraphNode*
Parent)
392 int SeedPointID = SeedPoints[
Parent->SeedPointID].PointID;
#define check(expr)
Definition AssertionMacros.h:314
#define ensure( InExpression)
Definition AssertionMacros.h:464
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
UE::Math::TVector< double > FVector3d
Definition MathFwd.h:60
UE_REWRITE SizeType Num() const
Definition Array.h:1144
Definition UnrealString.h.inl:34
static RealType Max(const RealType A, const RealType B)
Definition MathUtil.h:246
Definition FunctionFwd.h:19
bool Contains(int NodeID) const
Definition IndexPriorityQueue.h:106
void Clear(bool bFreeMemory=true)
Definition IndexPriorityQueue.h:79
int GetCount() const
Definition IndexPriorityQueue.h:88
void Insert(int NodeID, float priority)
Definition IndexPriorityQueue.h:121
void Initialize(int MaxNodeID)
Definition IndexPriorityQueue.h:67
int Dequeue()
Definition IndexPriorityQueue.h:142
void Clear()
Definition DynamicVector.h:578
Definition MeshDijkstra.h:25
TMeshDijkstra(const PointSetType *PointSetIn)
Definition MeshDijkstra.h:55
int32 GetSeedExternalIDForPointSetID(int32 PointID)
Definition MeshDijkstra.h:245
const PointSetType * PointSet
Definition MeshDijkstra.h:28
bool HasDistance(int32 PointID) const
Definition MeshDijkstra.h:260
int32 GetMaxGraphDistancePointID() const
Definition MeshDijkstra.h:236
TUniqueFunction< double(int32 FromVID, int32 ToVID, int32 SeedVID, double EuclideanDistance)> GetWeightedDistanceFunc
Definition MeshDijkstra.h:48
bool FindPathToNearestSeed(int32 PointID, TArray< int32 > &PathToSeedOut, int32 MaxLength=100000)
Definition MeshDijkstra.h:283
double GetMaxGraphDistance() const
Definition MeshDijkstra.h:227
void ComputeToMaxDistance(const TArray< FSeedPoint > &SeedPointsIn, double ComputeToMaxDistanceIn)
Definition MeshDijkstra.h:105
bool ComputeToTargetPoint(const TArray< FSeedPoint > &SeedPointsIn, int32 TargetPointID, double ComputeToMaxDistanceIn=TNumericLimits< double >::Max())
Definition MeshDijkstra.h:173
double GetDistance(int32 PointID) const
Definition MeshDijkstra.h:270
bool bEnableDistanceWeighting
Definition MeshDijkstra.h:41
void ComputeToMaxDistance(const TArray< FVector2d > &SeedPointsIn, double ComputeToMaxDistanceIn)
Definition MeshDijkstra.h:152
static double InvalidDistance()
Definition MeshDijkstra.h:71
TUniqueFunction< FVector3d(int32)> GetPositionFunc
Definition MeshDijkstra.h:35
void Reset()
Definition MeshDijkstra.h:76
Definition AdvancedWidgetsModule.cpp:13
Definition NumericLimits.h:41
Definition MeshDijkstra.h:90
double StartDistance
Definition MeshDijkstra.h:96
int32 PointID
Definition MeshDijkstra.h:94
int32 ExternalID
Definition MeshDijkstra.h:92