Payback 0.0.1
CK Graduation Project
로딩중...
검색중...
일치하는것 없음
FProjectilePathSelector 구조체 참조

#include <ProjectilePathSelector.h>

FProjectilePathSelector에 대한 협력 다이어그램:
Collaboration graph

Public 멤버 함수

bool ResolveImpactPoint (const AActor *RequestingActor, const FTargetSelectionResult &TargetResult, float MaxImpactDistance, float ImpactObstructionOffset, FWeaponRequestImpactResult &OutImpactResult) const
 
bool ResolveLaunchPath (const AActor *RequestingActor, const FVector &ImpactPoint, float SpawnHeightAboveImpact, float SpawnLateralOffset, float SpawnForwardOffset, FVector &OutFrom, FVector &OutDirection) const
 
bool ResolveTargetHeightLocation (const UObject *WorldContextObject, const FVector &PathStart, const FVector &PathEnd, float TargetHeight, FProjectilePathResult &OutResult) const
 

Private 멤버 함수

float ClampDistanceByObstruction (const AActor *RequestingActor, const FVector &StartLocation, const FVector &Direction, float Distance, float ImpactObstructionOffset) const
 
bool BSForHeight (const FVector &PathStart, const FVector &PathEnd, float TargetHeight, FProjectilePathResult &OutResult, float PreviousAlpha, float PreviousDelta, float CurrentAlpha, float CurrentDelta, bool &bValue) const
 
bool EvaluateHeightAtAlpha (const FVector &PathStart, const FVector &PathEnd, float Alpha, float TargetHeight, FProjectilePathResult &OutResult) const
 
bool FindGroundLocation (const FVector &PathLocation, FVector &OutGroundLocation) const
 

Private 속성

float GroundTraceUpOffset = 1000.0f
 
float GroundTraceDownDistance = 10000.0f
 
int32 SegmentCount = 16
 
int32 BinarySearchIterationCount = 12
 
TObjectPtr< UWorld > CachedWorld
 

멤버 함수 문서화

◆ BSForHeight()

bool FProjectilePathSelector::BSForHeight ( const FVector &  PathStart,
const FVector &  PathEnd,
float  TargetHeight,
FProjectilePathResult OutResult,
float  PreviousAlpha,
float  PreviousDelta,
float  CurrentAlpha,
float  CurrentDelta,
bool &  bValue 
) const
private
133{
134 const bool bPreviousAbove = PreviousDelta > KINDA_SMALL_NUMBER;
135 const bool bPreviousBelow = PreviousDelta < -KINDA_SMALL_NUMBER;
136 const bool bCurrentAbove = CurrentDelta > KINDA_SMALL_NUMBER;
137 const bool bCurrentBelow = CurrentDelta < -KINDA_SMALL_NUMBER;
138
139 if ((bPreviousAbove && bCurrentBelow) == false && (bPreviousBelow && bCurrentAbove) == false)
140 {
141 return false;
142 }
143
144 float LowAlpha = PreviousAlpha;
145 float HighAlpha = CurrentAlpha;
146
147 for (int32 IterationIndex = 0; IterationIndex < BinarySearchIterationCount; ++IterationIndex)
148 {
149 const float MidAlpha = (LowAlpha + HighAlpha) * 0.5f;
150 FProjectilePathResult MidResult;
151
152 if (EvaluateHeightAtAlpha(PathStart, PathEnd, MidAlpha, TargetHeight, MidResult) == false)
153 {
154 bValue = false;
155 return true;
156 }
157
158 const float MidDelta = MidResult.HeightAboveGround - TargetHeight;
159
160 const bool bMidAbove = MidDelta > KINDA_SMALL_NUMBER;
161 const bool bMidBelow = MidDelta < -KINDA_SMALL_NUMBER;
162
163 if ((bPreviousAbove && bMidAbove) || (bPreviousBelow && bMidBelow))
164 {
165 LowAlpha = MidAlpha;
166 }
167 else
168 {
169 HighAlpha = MidAlpha;
170 }
171
172 OutResult = MidResult;
173 }
174
175 bValue = true;
176 return true;
177}
Definition ProjectilePathSelector.h:14
float HeightAboveGround
Definition ProjectilePathSelector.h:25
int32 BinarySearchIterationCount
Definition ProjectilePathSelector.h:70
bool EvaluateHeightAtAlpha(const FVector &PathStart, const FVector &PathEnd, float Alpha, float TargetHeight, FProjectilePathResult &OutResult) const
Definition ProjectilePathSelector.cpp:248
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ClampDistanceByObstruction()

float FProjectilePathSelector::ClampDistanceByObstruction ( const AActor *  RequestingActor,
const FVector &  StartLocation,
const FVector &  Direction,
float  Distance,
float  ImpactObstructionOffset 
) const
private
71{
72 UWorld* World = RequestingActor ? RequestingActor->GetWorld() : nullptr;
73
74 if (World == nullptr || Distance <= KINDA_SMALL_NUMBER)
75 {
76 return Distance;
77 }
78
79 const FVector TraceStart = StartLocation;
80 const FVector TraceEnd = StartLocation + Direction * Distance;
81
82 FCollisionObjectQueryParams ObjectQuery;
83 ObjectQuery.AddObjectTypesToQuery(ECC_WorldStatic);
84
85 FCollisionQueryParams TraceParams(SCENE_QUERY_STAT(WeaponRequestImpactObstruction), false);
86
87 FHitResult Hit;
88
89 if (World->LineTraceSingleByObjectType(Hit, TraceStart, TraceEnd, ObjectQuery, TraceParams) == false)
90 {
91 return Distance;
92 }
93
94 return FMath::Max(Hit.Distance - ImpactObstructionOffset, KINDA_SMALL_NUMBER);
95}
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ EvaluateHeightAtAlpha()

bool FProjectilePathSelector::EvaluateHeightAtAlpha ( const FVector &  PathStart,
const FVector &  PathEnd,
float  Alpha,
float  TargetHeight,
FProjectilePathResult OutResult 
) const
private
249{
250 OutResult = FProjectilePathResult();
251
252 if (CachedWorld == nullptr)
253 {
254 return false;
255 }
256
257 const float ClampedAlpha = FMath::Clamp(Alpha, 0.0f, 1.0f);
258 const FVector PathLocation = FMath::Lerp(PathStart, PathEnd, ClampedAlpha);
259 FVector GroundLocation = FVector::ZeroVector;
260
261 if (FindGroundLocation(PathLocation, GroundLocation) == false)
262 {
263 return false;
264 }
265
266 OutResult.TargetLocation = PathLocation;
267 OutResult.GroundLocation = GroundLocation;
268 OutResult.HeightAboveGround = PathLocation.Z - GroundLocation.Z;
269 OutResult.PathAlpha = ClampedAlpha;
270 return OutResult.HeightAboveGround >= -KINDA_SMALL_NUMBER || TargetHeight <= KINDA_SMALL_NUMBER;
271}
FVector GroundLocation
Definition ProjectilePathSelector.h:22
float PathAlpha
Definition ProjectilePathSelector.h:28
FVector TargetLocation
Definition ProjectilePathSelector.h:19
bool FindGroundLocation(const FVector &PathLocation, FVector &OutGroundLocation) const
Definition ProjectilePathSelector.cpp:274
TObjectPtr< UWorld > CachedWorld
Definition ProjectilePathSelector.h:74
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ FindGroundLocation()

bool FProjectilePathSelector::FindGroundLocation ( const FVector &  PathLocation,
FVector &  OutGroundLocation 
) const
private
275{
276 OutGroundLocation = FVector::ZeroVector;
277
278 if (CachedWorld == nullptr)
279 {
280 return false;
281 }
282
283 const FVector TraceStart = PathLocation + FVector::UpVector * GroundTraceUpOffset;
284 const FVector TraceEnd = PathLocation - FVector::UpVector * GroundTraceDownDistance;
285
286 FCollisionObjectQueryParams ObjectQuery;
287 ObjectQuery.AddObjectTypesToQuery(ECC_WorldStatic);
288
289 FCollisionQueryParams TraceParams(SCENE_QUERY_STAT(ProjectilePathHeightSelector), false);
290
291 FHitResult Hit;
292
293 if (CachedWorld->LineTraceSingleByObjectType(Hit, TraceStart, TraceEnd, ObjectQuery, TraceParams) == false)
294 {
295 return false;
296 }
297
298 OutGroundLocation = Hit.ImpactPoint;
299 return true;
300}
float GroundTraceDownDistance
Definition ProjectilePathSelector.h:67
float GroundTraceUpOffset
Definition ProjectilePathSelector.h:66
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ResolveImpactPoint()

bool FProjectilePathSelector::ResolveImpactPoint ( const AActor *  RequestingActor,
const FTargetSelectionResult TargetResult,
float  MaxImpactDistance,
float  ImpactObstructionOffset,
FWeaponRequestImpactResult OutImpactResult 
) const
13{
14 OutImpactResult = FWeaponRequestImpactResult();
15
16 if (RequestingActor == nullptr)
17 {
18 return false;
19 }
20
21 const FVector RequesterLocation = RequestingActor->GetActorLocation();
22
23 if (TargetResult.bHasTarget == false)
24 {
25 FVector FallbackDirection = RequestingActor->GetActorForwardVector();
26 FallbackDirection.Z = 0.0f;
27 FallbackDirection = FallbackDirection.GetSafeNormal();
28
29 if (FallbackDirection.IsNearlyZero())
30 {
31 return false;
32 }
33
34 const float SafeDistance = ClampDistanceByObstruction(RequestingActor, RequesterLocation, FallbackDirection, MaxImpactDistance, ImpactObstructionOffset);
35
36 OutImpactResult.TargetLocation = RequesterLocation + FallbackDirection * MaxImpactDistance;
37 OutImpactResult.ImpactPoint = RequesterLocation + FallbackDirection * SafeDistance;
38 return true;
39 }
40
41 FVector RequesterToTarget = TargetResult.TargetLocation - RequesterLocation;
42 RequesterToTarget.Z = 0.0f;
43
44 FVector Direction = RequesterToTarget.GetSafeNormal();
45
46 if (Direction.IsNearlyZero())
47 {
48 Direction = RequestingActor->GetActorForwardVector();
49 Direction.Z = 0.0f;
50 Direction = Direction.GetSafeNormal();
51 }
52
53 if (Direction.IsNearlyZero())
54 {
55 return false;
56 }
57
58 const float ImpactDistance = FMath::Min(TargetResult.TargetDistance, MaxImpactDistance);
59 const float SafeDistance = ClampDistanceByObstruction(RequestingActor, RequesterLocation, Direction, ImpactDistance, ImpactObstructionOffset);
60 FVector ImpactPoint = RequesterLocation + Direction * SafeDistance;
61 ImpactPoint.Z = TargetResult.TargetLocation.Z;
62
63 OutImpactResult.TargetLocation = TargetResult.TargetLocation;
64 OutImpactResult.ImpactPoint = ImpactPoint;
65 OutImpactResult.TargetDistance = TargetResult.TargetDistance;
66 return true;
67}
float ClampDistanceByObstruction(const AActor *RequestingActor, const FVector &StartLocation, const FVector &Direction, float Distance, float ImpactObstructionOffset) const
Definition ProjectilePathSelector.cpp:70
float TargetDistance
Definition TargetSelector.h:40
bool bHasTarget
Definition TargetSelector.h:31
FVector TargetLocation
Definition TargetSelector.h:37
Definition ProjectilePathSelector.h:34
FVector ImpactPoint
Definition ProjectilePathSelector.h:42
float TargetDistance
Definition ProjectilePathSelector.h:45
FVector TargetLocation
Definition ProjectilePathSelector.h:39
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ResolveLaunchPath()

bool FProjectilePathSelector::ResolveLaunchPath ( const AActor *  RequestingActor,
const FVector &  ImpactPoint,
float  SpawnHeightAboveImpact,
float  SpawnLateralOffset,
float  SpawnForwardOffset,
FVector &  OutFrom,
FVector &  OutDirection 
) const
99{
100 OutFrom = FVector::ZeroVector;
101 OutDirection = FVector::ZeroVector;
102
103 if (RequestingActor == nullptr)
104 {
105 return false;
106 }
107
108 FVector ForwardFlat = ImpactPoint - RequestingActor->GetActorLocation();
109 ForwardFlat.Z = 0.0f;
110 ForwardFlat = ForwardFlat.GetSafeNormal();
111
112 if (ForwardFlat.IsNearlyZero())
113 {
114 ForwardFlat = RequestingActor->GetActorForwardVector();
115 ForwardFlat.Z = 0.0f;
116 ForwardFlat = ForwardFlat.GetSafeNormal();
117 }
118
119 const FVector RightFlat = FVector::CrossProduct(FVector::UpVector, ForwardFlat).GetSafeNormal();
120
121 OutFrom = ImpactPoint;
122 OutFrom += FVector::UpVector * SpawnHeightAboveImpact;
123 OutFrom += RightFlat * SpawnLateralOffset;
124 OutFrom += ForwardFlat * SpawnForwardOffset;
125
126 OutDirection = (ImpactPoint - OutFrom).GetSafeNormal();
127
128 return OutDirection.IsNearlyZero() == false;
129}
이 함수를 호출하는 함수들에 대한 그래프입니다.:

◆ ResolveTargetHeightLocation()

bool FProjectilePathSelector::ResolveTargetHeightLocation ( const UObject *  WorldContextObject,
const FVector &  PathStart,
const FVector &  PathEnd,
float  TargetHeight,
FProjectilePathResult OutResult 
) const
181{
182 OutResult = FProjectilePathResult();
183
184 if (WorldContextObject == nullptr || TargetHeight < KINDA_SMALL_NUMBER)
185 {
186 return false;
187 }
188
189 CachedWorld = WorldContextObject->GetWorld();
190 check(CachedWorld);
191
192 if (FVector::DistSquared(PathStart, PathEnd) < KINDA_SMALL_NUMBER)
193 {
194 return false;
195 }
196
197 const int32 SafeSegmentCount = FMath::Max(SegmentCount, 1);
198 FProjectilePathResult PreviousResult;
199
200 if (EvaluateHeightAtAlpha(PathStart, PathEnd, 0.0f, TargetHeight, PreviousResult) == false)
201 {
202 return false;
203 }
204
205 float PreviousAlpha = 0.0f;
206 float PreviousDelta = PreviousResult.HeightAboveGround - TargetHeight;
207
208 if (FMath::Abs(PreviousDelta) <= KINDA_SMALL_NUMBER)
209 {
210 OutResult = PreviousResult;
211 return true;
212 }
213
214 for (int32 SegmentIndex = 1; SegmentIndex <= SafeSegmentCount; ++SegmentIndex)
215 {
216 const float CurrentAlpha = static_cast<float>(SegmentIndex) / static_cast<float>(SafeSegmentCount);
217 FProjectilePathResult CurrentResult;
218
219 if (EvaluateHeightAtAlpha(PathStart, PathEnd, CurrentAlpha, TargetHeight, CurrentResult) == false)
220 {
221 return false;
222 }
223
224 const float CurrentDelta = CurrentResult.HeightAboveGround - TargetHeight;
225
226 if (FMath::Abs(CurrentDelta) <= KINDA_SMALL_NUMBER)
227 {
228 OutResult = CurrentResult;
229 return true;
230 }
231
232 bool bValue;
233
234 if (BSForHeight(PathStart, PathEnd, TargetHeight, OutResult, PreviousAlpha, PreviousDelta, CurrentAlpha, CurrentDelta, bValue))
235 {
236 return bValue;
237 }
238
239 PreviousAlpha = CurrentAlpha;
240 PreviousDelta = CurrentDelta;
241 PreviousResult = CurrentResult;
242 }
243
244 return false;
245}
int32 SegmentCount
Definition ProjectilePathSelector.h:69
bool BSForHeight(const FVector &PathStart, const FVector &PathEnd, float TargetHeight, FProjectilePathResult &OutResult, float PreviousAlpha, float PreviousDelta, float CurrentAlpha, float CurrentDelta, bool &bValue) const
Definition ProjectilePathSelector.cpp:132
이 함수 내부에서 호출하는 함수들에 대한 그래프입니다.:

멤버 데이터 문서화

◆ BinarySearchIterationCount

int32 FProjectilePathSelector::BinarySearchIterationCount = 12
private

◆ CachedWorld

TObjectPtr<UWorld> FProjectilePathSelector::CachedWorld
mutableprivate

◆ GroundTraceDownDistance

float FProjectilePathSelector::GroundTraceDownDistance = 10000.0f
private

◆ GroundTraceUpOffset

float FProjectilePathSelector::GroundTraceUpOffset = 1000.0f
private

◆ SegmentCount

int32 FProjectilePathSelector::SegmentCount = 16
private

이 구조체에 대한 문서화 페이지는 다음의 파일들로부터 생성되었습니다.: