RapyutaSimulationPlugins
RRFloatingMovementComponent.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 
16 
17 // UE
18 
19 #include "AI/Navigation/AvoidanceManager.h"
20 
21 #include "GameFramework/FloatingPawnMovement.h"
22 
23 
24 
25 #include "RRFloatingMovementComponent.generated.h"
26 
27 
28 
29 #define RAPYUTA_FLOAT_MOVEMENT_DEBUG (0)
30 
50 class RAPYUTASIMULATIONPLUGINS_API URRFloatingMovementComponent : public UFloatingPawnMovement
51 
52 {
53 
54 
55 
56 public:
57 
59 
60  URRFloatingMovementComponent(const FObjectInitializer& ObjectInitializer);
61 
62  void SetupDefault();
63 
64  virtual void SetUpdatedComponent(USceneComponent* InNewUpdatedComponent) override;
65 
66  void Set2DMovement(bool bEnabled)
67 
68  {
69 
70  b2DMovement = bEnabled;
71 
72  }
73 
74  FORCEINLINE bool Is2DMovement() const
75 
76  {
77 
78  return b2DMovement;
79 
80  }
81 
82 
83 
85 
86 
91  FVector AngularVelocity = FVector::ZeroVector;
92 
93 
94 
96 
98 
99 
104  float MaxAngularSpeed = 360.f;
105 
106 
107 
108  void SetUseDecelerationForPaths(bool bEnabled)
109 
110  {
111 
112  bUseDecelerationForPaths = bEnabled;
113 
114  }
115 
116 
117 
118  FORCEINLINE bool UseDecelerationForPathFollowing() const
119 
120  {
121 
122  return bUseDecelerationForPaths;
123 
124  }
125 
126 
127 
128  void SetUseAccelerationForPaths(bool bEnabled)
129 
130  {
131 
132  bUseAccelerationForPaths = bEnabled;
133 
134  }
135 
136 
137 
138  void SetPenetrationPullbackDistance(float PullbackDistance)
139 
140  {
141 
142  PenetrationPullbackDistance = PullbackDistance;
143 
144  }
145 
146 
147 
148  virtual void StopMovementImmediately() override;
149 
150 
151 
152  // RVO Avoidance
153 
154  // Ref: UCharacterMovementComponent
155 
156 
161  int32 RVOAvoidanceUID = 0;
162 
164 
165 
170  uint8 bUseRVOAvoidance : 1;
171 
172 
177  float RVOAvoidanceWeight = 0.5f;
178 
179 
185 
186 
191  TObjectPtr<UAvoidanceManager> RVOAvoidanceManager = nullptr;
192 
193  void SetRVOAvoidanceEnabled(bool bEnabled);
194 
195  void SetRVOAvoidanceVelocityLock(float InDuration);
196 
198 
199 
204  FVector RVOAvoidanceLockVelocity = FVector::ZeroVector;
205 
206 
211  float RVOAvoidanceLockTimeout = 0.f;
212 
213 
214 
215 protected:
216 
217  virtual void OnRegister() override;
218 
219  virtual void TickComponent(float InDeltaTime, enum ELevelTick InTickType, FActorComponentTickFunction* InTickFunction) override;
220 
221  virtual bool IsExceedingMaxSpeed(float InMaxSpeed) const override;
222 
223  virtual FVector GetPenetrationAdjustment(const FHitResult& Hit) const;
224 
225 #if RAPYUTA_FLOAT_MOVEMENT_DEBUG
226 
227  virtual bool ResolvePenetrationImpl(const FVector& InProposedAdjustment,
228 
229  const FHitResult& InHit,
230 
231  const FQuat& InNewRotationQuat) override;
232 
233 #endif
234 
235  void UpdateDefaultAvoidance();
236 
237  void CalculateRVOAvoidanceVelocity(float InDeltaTime);
238 
239  virtual void PostProcessRVOAvoidanceVelocity(FVector& InNewVelocity)
240 
241  {
242 
243  }
244 
245 
246 
247 private:
248 
249 
254  uint8 bSweepEnabled : 1;
255 
256 
257 
258 
263  uint8 b2DMovement : 1;
264 
265 
266 
267 
273 
274 
275 
276 
281  float PenetrationPullbackDistance = 0.f;
282 
283 };
284 
URRFloatingMovementComponent::UseDecelerationForPathFollowing
FORCEINLINE bool UseDecelerationForPathFollowing() const
Definition: RRFloatingMovementComponent.h:118
URRFloatingMovementComponent::Is2DMovement
FORCEINLINE bool Is2DMovement() const
Definition: RRFloatingMovementComponent.h:74
URRFloatingMovementComponent::bUseRVOAvoidance
uint8 bUseRVOAvoidance
Whether to use RVO avoidance (instead of crowd avoidance). This only runs on the server.
Definition: RRFloatingMovementComponent.h:170
URRFloatingMovementComponent::b2DMovement
uint8 b2DMovement
Definition: RRFloatingMovementComponent.h:263
URRFloatingMovementComponent::Set2DMovement
void Set2DMovement(bool bEnabled)
Definition: RRFloatingMovementComponent.h:66
URRFloatingMovementComponent::SetPenetrationPullbackDistance
void SetPenetrationPullbackDistance(float PullbackDistance)
Definition: RRFloatingMovementComponent.h:138
URRFloatingMovementComponent::SetUseAccelerationForPaths
void SetUseAccelerationForPaths(bool bEnabled)
Definition: RRFloatingMovementComponent.h:128
URRFloatingMovementComponent::PostProcessRVOAvoidanceVelocity
virtual void PostProcessRVOAvoidanceVelocity(FVector &InNewVelocity)
Definition: RRFloatingMovementComponent.h:239
URRFloatingMovementComponent::bSweepEnabled
uint8 bSweepEnabled
Definition: RRFloatingMovementComponent.h:254
URRFloatingMovementComponent::bUseDecelerationForPaths
uint8 bUseDecelerationForPaths
Definition: RRFloatingMovementComponent.h:272
URRFloatingMovementComponent::bRVOAvoidanceRecentlyUpdated
uint8 bRVOAvoidanceRecentlyUpdated
Definition: RRFloatingMovementComponent.h:184
URRFloatingMovementComponent
Base Robot floating movement class.
Definition: RRFloatingMovementComponent.h:50
URRFloatingMovementComponent::SetUseDecelerationForPaths
void SetUseDecelerationForPaths(bool bEnabled)
Definition: RRFloatingMovementComponent.h:108