UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
DetourNavLinkBuilder.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreTypes.h"
5#include "DetourAlloc.h"
8
9//@UE BEGIN
10
21
22struct rcHeightfield;
24
26{
27 bool generatingLinks = false;
28};
29
30class rcContext;
31struct rcConfig;
32
34{
35 dtLinkBuilderConfig m_linkBuilderConfig;
36
37 dtReal m_cs = 0;
38 dtReal m_csSquared = 0;
39 dtReal m_ch = 0;
40 dtReal m_invCs = 0;
41 const rcHeightfield* m_solid = nullptr;
42 const rcCompactHeightfield* m_chf = nullptr;
43
44 struct Edge
45 {
46 dtReal sp[3], sq[3];
47 };
49
50public:
51 static constexpr int MAX_SPINE = 8;
52 int getEdgeCount() const { return m_edges.Num(); }
53
55 {
56 // Min and max heights relative to the height on the segment between the start and the end point (at the sampling locations).
57 float ymin = 0.f;
58 float ymax = 0.f;
59
60 bool floorStart = false;
61 bool floorEnd = false;
62 };
63
65 {
66 float spine[2*MAX_SPINE]; // [x,y] relative points representing the desired trajectory (one spine with MAX_SPINE points)
67 float radiusOverflow = 0.f; // extra distance at the start and end of the spine to lookup for samples
68
69 TArray<TrajectorySample, TInlineAllocator<8>> samples; // samples along trajectory slices to check for collision
70
71 unsigned char nspine = 0; // @todo: remove (use direclty MAX_SPINE) or make relative to trajectory type and config
72 };
73
74private:
75 enum GroundSampleFlag : unsigned char
76 {
77 UNSET = 0,
78 HAS_GROUND = 1,
79 UNRESTRICTED = 4,
80 };
81
82 struct GroundSample
83 {
84 dtReal height;
85 GroundSampleFlag flags;
86 };
87
88 struct PotentialSeg
89 {
90 unsigned char mark;
91 int idx;
92 float umin, umax;
93 float dmin, dmax;
94 float sp[3], sq[3];
95 };
96
97 struct GroundSegment
98 {
99 GroundSegment() : ngsamples(0) {}
100 NAVMESH_API ~GroundSegment();
101
102 dtReal p[3], q[3];
104 unsigned short ngsamples;
105 unsigned short npass;
106 };
107
108public:
109 static constexpr uint8 INVALID_CONFIG_INDEX = 0xFF;
110
112 {
114
115 GroundSegment start;
116 GroundSegment end;
117
118 dtReal rigp[3], rigq[3]; // edge
119 dtReal ax[3], ay[3], az[3]; // axis along edge
120
123 };
124
125 enum JumpLinkFlag : unsigned char
126 {
128 VALID = 1,
129 };
130
131 struct JumpLink
132 {
135 int nspine = 0;
138#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
139 short debugSourceEdge = -1;
140#endif
141 };
143
144private:
145 int m_debugSelectedEdge = -1;
146
147 friend NAVMESH_API void duDebugDrawNavLinkBuilder(struct duDebugDraw* dd, const dtNavLinkBuilder& linkBuilder, unsigned int drawFlags, const EdgeSampler* es);
148
150 const dtNavLinkBuilder::Trajectory2D* trajectory, const dtReal* trajectoryDir);
151
152 friend NAVMESH_API void duDrawGroundSegment(struct duDebugDraw* dd, const dtNavLinkBuilder::GroundSegment& segment);
153
154public:
155 // Loops through contours to store edge points in world coordinates.
157 const struct dtTileCacheContourSet& lcset, const dtReal* orig,
159
160 // For all edges, sample edges (sampleEdge) and add links to m_links
162
164
165private:
166 void initTrajectorySamples(const float groundRange, Trajectory2D* trajectory) const;
167 bool isTrajectoryClear(const dtReal* pa, const dtReal* pb, const Trajectory2D* trajectory, const dtReal* trajectoryDir) const;
168
169 void initJumpRig(EdgeSampler* es, const dtReal* sp, const dtReal* sq,
170 const dtNavLinkBuilderJumpConfig& config) const;
171
172 bool getCompactHeightfieldHeight(const dtReal* pt, const dtReal hrange, dtReal* height) const;
173 bool checkHeightfieldCollision(const dtReal x, const dtReal ymin, const dtReal ymax, const dtReal z) const;
174
175 void sampleGroundSegment(GroundSegment* seg, const int nsamples, const float groundRange) const;
176
177 // Update the min height of the trajectory samples from the height of the ground at the start and the end of the trajectories.
178 // This method must be called after the segments have been sampled for ground.
179 void updateTrajectorySamples(EdgeSampler* es) const;
180
181 void sampleAction(EdgeSampler* es) const;
182
183 void filterOverlappingLinks(const float edgeDistanceThreshold);
184
185 bool sampleEdge(const dtNavLinkBuilderJumpConfig& jumpConfig, const dtReal* sp, const dtReal* sq, dtNavLinkBuilder::EdgeSampler* sampler) const;
186 void addEdgeLinks(const dtLinkBuilderConfig& builderConfig, const EdgeSampler* es, const int edgeIndex);
187};
188//@UE END
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
double dtReal
Definition DetourLargeWorldCoordinates.h:15
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition Array.h:670
UE_REWRITE SizeType Num() const
Definition Array.h:1144
Definition DetourNavLinkBuilder.h:34
static constexpr uint8 INVALID_CONFIG_INDEX
Definition DetourNavLinkBuilder.h:109
friend NAVMESH_API void duDrawGroundSegment(struct duDebugDraw *dd, const dtNavLinkBuilder::GroundSegment &segment)
Definition DetourNavLinkDebugDraw.cpp:557
NAVMESH_API void buildForAllEdges(rcContext &ctx, const dtLinkBuilderConfig &acfg, const dtNavLinkBuilderJumpConfig &jumpConfig)
Definition DetourNavLinkBuilder.cpp:343
static constexpr int MAX_SPINE
Definition DetourNavLinkBuilder.h:51
NAVMESH_API void debugBuildEdge(const dtLinkBuilderConfig &acfg, int edgeIndex, EdgeSampler &sampler, const dtNavLinkBuilderJumpConfig &jumpConfig)
Definition DetourNavLinkBuilder.cpp:360
friend NAVMESH_API void duDebugDrawNavLinkBuilder(struct duDebugDraw *dd, const dtNavLinkBuilder &linkBuilder, unsigned int drawFlags, const EdgeSampler *es)
Definition DetourNavLinkDebugDraw.cpp:231
int getEdgeCount() const
Definition DetourNavLinkBuilder.h:52
NAVMESH_API bool findEdges(rcContext &ctx, const rcConfig &cfg, const dtLinkBuilderConfig &builderConfig, const struct dtTileCacheContourSet &lcset, const dtReal *orig, const rcHeightfield *solidHF, const rcCompactHeightfield *compactHF)
Definition DetourNavLinkBuilder.cpp:64
TArray< JumpLink, TInlineAllocator< 16 > > m_links
Definition DetourNavLinkBuilder.h:142
JumpLinkFlag
Definition DetourNavLinkBuilder.h:126
@ VALID
Definition DetourNavLinkBuilder.h:128
@ FILTERED
Definition DetourNavLinkBuilder.h:127
friend NAVMESH_API void duDebugDrawTrajectorySamples(struct duDebugDraw *dd, const dtNavLinkBuilder &linkBuilder, const dtReal *pa, const dtReal *pb, const dtNavLinkBuilder::Trajectory2D *trajectory, const dtReal *trajectoryDir)
Definition DetourNavLinkDebugDraw.cpp:184
Definition Recast.h:165
Definition DetourNavLinkBuilder.h:12
dtReal cellHeight
Definition DetourNavLinkBuilder.h:19
TArray< dtNavLinkBuilderJumpConfig > jumpConfigs
Definition DetourNavLinkBuilder.h:13
dtReal agentHeight
Definition DetourNavLinkBuilder.h:16
dtReal cellSize
Definition DetourNavLinkBuilder.h:18
dtReal agentRadius
Definition DetourNavLinkBuilder.h:15
dtReal agentClimb
Definition DetourNavLinkBuilder.h:17
Definition DetourNavLinkBuilder.h:26
bool generatingLinks
Definition DetourNavLinkBuilder.h:27
Definition DetourNavLinkBuilderConfig.h:14
Definition DetourNavLinkBuilder.h:112
Trajectory2D trajectory
Definition DetourNavLinkBuilder.h:113
GroundSegment end
Definition DetourNavLinkBuilder.h:116
uint8 configIndex
Definition DetourNavLinkBuilder.h:122
dtReal rigq[3]
Definition DetourNavLinkBuilder.h:118
dtReal ax[3]
Definition DetourNavLinkBuilder.h:119
GroundSegment start
Definition DetourNavLinkBuilder.h:115
dtReal az[3]
Definition DetourNavLinkBuilder.h:119
dtReal rigp[3]
Definition DetourNavLinkBuilder.h:118
dtReal ay[3]
Definition DetourNavLinkBuilder.h:119
float groundRange
Definition DetourNavLinkBuilder.h:121
Definition DetourNavLinkBuilder.h:65
float radiusOverflow
Definition DetourNavLinkBuilder.h:67
unsigned char nspine
Definition DetourNavLinkBuilder.h:71
float spine[2 *MAX_SPINE]
Definition DetourNavLinkBuilder.h:66
TArray< TrajectorySample, TInlineAllocator< 8 > > samples
Definition DetourNavLinkBuilder.h:69
Definition DetourNavLinkBuilder.h:55
bool floorEnd
Definition DetourNavLinkBuilder.h:61
float ymin
Definition DetourNavLinkBuilder.h:57
float ymax
Definition DetourNavLinkBuilder.h:58
bool floorStart
Definition DetourNavLinkBuilder.h:60
Definition DetourTileCacheBuilder.h:68
Abstract debug draw interface.
Definition DebugDraw.h:81
Definition Recast.h:447
Definition Recast.h:260
Definition Recast.h:408