5#include "CoreMinimal.h"
6#include "Engine/Engine.h"
9#include "GS_GunTools.generated.h"
17USTRUCT(BlueprintType, Category =
"GunSettings")
24 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock")
25 bool bUseDistanceBasedStockSnapping;
28 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock")
29 float StockSnapDistance;
34 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock", meta = (ClampMin = "0.00", UIMin = "0.00"))
35 float StockSnapLerpThreshold;
38 UPROPERTY(BlueprintReadOnly, Category = "VirtualStock")
42 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock")
43 FVector_NetQuantize100 StockSnapOffset;
46 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock")
47 bool bAdjustZOfStockToPrimaryHand;
50 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock|Smoothing")
51 bool bSmoothStockHand;
55 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock|Smoothing", meta = (editcondition = "bSmoothStockHand", ClampMin = "0.00", UIMin = "0.00", ClampMax = "1.00", UIMax = "1.00"))
56 float SmoothingValueForStock;
59 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings|VirtualStock|Smoothing")
63 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings|VirtualStock|
Debug")
64 bool bDebugDrawVirtualStock;
68 bUseDistanceBasedStockSnapping = B.bUseDistanceBasedStockSnapping;
69 StockSnapDistance = B.StockSnapDistance;
70 StockSnapLerpThreshold = B.StockSnapLerpThreshold;
71 StockSnapOffset = B.StockSnapOffset;
72 bAdjustZOfStockToPrimaryHand = B.bAdjustZOfStockToPrimaryHand;
73 bSmoothStockHand = B.bSmoothStockHand;
74 SmoothingValueForStock = B.SmoothingValueForStock;
75 StockHandSmoothing = B.StockHandSmoothing;
80 StockSnapOffset = FVector(0.f, 0.f, 0.f);
81 bAdjustZOfStockToPrimaryHand =
true;
82 StockSnapDistance = 35.f;
83 StockSnapLerpThreshold = 20.0f;
84 StockLerpValue = 0.0f;
85 bUseDistanceBasedStockSnapping =
true;
86 SmoothingValueForStock = 0.0f;
87 bSmoothStockHand =
false;
90 StockHandSmoothing.DeltaCutoff = 20.0f;
91 StockHandSmoothing.MinCutoff = 5.0f;
93 bDebugDrawVirtualStock =
false;
97USTRUCT(BlueprintType, Category =
"VRExpansionLibrary")
103 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"AdvSecondarySettings")
104 bool bUseAdvancedSecondarySettings;
108 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"AdvSecondarySettings|Smoothing", meta = (editcondition =
"bUseAdvancedSecondarySettings", ClampMin =
"0.00", UIMin =
"0.00", ClampMax =
"1.00", UIMax =
"1.00"))
109 float SecondaryGripScaler;
112 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AdvSecondarySettings|Smoothing", meta = (editcondition = "bUseAdvancedSecondarySettings"))
113 bool bUseConstantGripScaler;
116 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AdvSecondarySettings|Smoothing", meta = (editcondition = "bUseAdvancedSecondarySettings"))
117 bool bUseGlobalSmoothingSettings;
120 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AdvSecondarySettings|Smoothing")
124 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AdvSecondarySettings|DistanceInfluence", meta = (editcondition = "bUseAdvancedSecondarySettings"))
125 bool bUseSecondaryGripDistanceInfluence;
132 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AdvSecondarySettings|DistanceInfluence", meta = (editcondition = "bUseSecondaryGripDistanceInfluence", ClampMin = "0.00", UIMin = "0.00", ClampMax = "256.00", UIMax = "256.00"))
133 float GripInfluenceDeadZone;
137 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "AdvSecondarySettings|DistanceInfluence", meta = (editcondition = "bUseSecondaryGripDistanceInfluence", ClampMin = "1.00", UIMin = "1.00", ClampMax = "256.00", UIMax = "256.00"))
138 float GripInfluenceDistanceToZero;
142 bUseAdvancedSecondarySettings =
false;
143 SecondaryGripScaler = 0.0f;
144 bUseGlobalSmoothingSettings =
true;
145 bUseSecondaryGripDistanceInfluence =
false;
147 GripInfluenceDeadZone = 50.0f;
148 GripInfluenceDistanceToZero = 100.0f;
149 bUseConstantGripScaler =
false;
157UCLASS(NotBlueprintable, ClassGroup = (
VRExpansionPlugin), hideCategories = TickSettings)
163 UGS_GunTools(
const FObjectInitializer& ObjectInitializer);
167 virtual void OnBeginPlay_Implementation(
UObject* CallingOwner)
override;
176 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category =
"Weapon Settings")
177 FName WeaponRootOrientationComponent;
178 FTransform OrientationComponentRelativeFacing;
179 FQuat StoredRootOffset;
182 UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "GunSettings")
183 bool bUseHighQualityRemoteSimulation;
185 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings")
192 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Pivot")
193 FVector_NetQuantize100 PivotOffset;
195 UFUNCTION(BlueprintCallable, Category = "VirtualStock")
198 VirtualStockComponent = NewStockComponent;
201 UFUNCTION(BlueprintCallable, Category =
"VirtualStock")
202 void SetVirtualStockEnabled(
bool bAllowVirtualStock)
204 if (!bUseVirtualStock && bAllowVirtualStock)
205 ResetStockVariables();
207 bUseVirtualStock = bAllowVirtualStock;
210 void ResetStockVariables()
212 VirtualStockSettings.StockHandSmoothing.ResetSmoothingFilter();
218 UPROPERTY(BlueprintAssignable, Category =
"VirtualStock")
219 FVRVirtualStockModeChangedSignature OnVirtualStockModeChanged;
222 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock")
223 bool bUseVirtualStock;
225 FTransform MountWorldTransform;
227 FTransform RelativeTransOnSecondaryRelease;
231 UPROPERTY(BlueprintReadWrite, Category = "VirtualStock")
236 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock")
237 bool bUseGlobalVirtualStockSettings;
239 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock", meta = (editcondition = "!bUseGlobalVirtualStockSettings"))
243 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Recoil")
247 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Recoil")
248 bool bApplyRecoilAsPhysicalForce;
251 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Recoil", meta = (editcondition = "bHasRecoil"))
252 FVector_NetQuantize100 MaxRecoilTranslation;
254 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Recoil", meta = (editcondition = "bHasRecoil"))
255 FVector_NetQuantize100 MaxRecoilRotation;
257 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Recoil", meta = (editcondition = "bHasRecoil"))
258 FVector_NetQuantize100 MaxRecoilScale;
261 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Recoil", meta = (editcondition = "bHasRecoil"))
265 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Recoil", meta = (editcondition = "bHasRecoil"))
269 FTransform BackEndRecoilStorage;
272 FTransform BackEndRecoilTarget;
274 bool bHasActiveRecoil;
279 UFUNCTION(BlueprintCallable, Category = "Recoil")
280 void AddRecoilInstance(const FTransform & RecoilAddition, FVector Optional_Location = FVector::ZeroVector);
282 UFUNCTION(BlueprintCallable, Category = "Recoil")
285 virtual
bool GetWorldTransform_Implementation(
UGripMotionControllerComponent * GrippingController,
float DeltaTime, FTransform & WorldTransform, const FTransform &ParentTransform,
FBPActorGripInformation &Grip,
AActor * actor, UPrimitiveComponent * root,
bool bRootHasInterface,
bool bActorHasInterface,
bool bIsForTeleport) override;
288 static
void ApplyTwoHandModifier(FTransform & OriginalTransform)
295 inline FVector GunTools_ApplySmoothingAndLerp(
FBPActorGripInformation & Grip, FVector &frontLoc, FVector & frontLocOrig,
float DeltaTime,
bool bSkipHighQualitySimulations)
297 FVector SmoothedValue = frontLoc;
301 if (!bSkipHighQualitySimulations && AdvSecondarySettings.SecondaryGripScaler < 1.0f)
303 SmoothedValue = AdvSecondarySettings.SecondarySmoothing.RunFilterSmoothing(frontLoc, DeltaTime);
304 frontLoc = FMath::Lerp(frontLoc, SmoothedValue, AdvSecondarySettings.SecondaryGripScaler);
309 else if (!bSkipHighQualitySimulations && AdvSecondarySettings.bUseAdvancedSecondarySettings && AdvSecondarySettings.bUseConstantGripScaler)
311 SmoothedValue = AdvSecondarySettings.SecondarySmoothing.RunFilterSmoothing(frontLoc, DeltaTime);
312 frontLoc = FMath::Lerp(frontLoc, SmoothedValue, AdvSecondarySettings.SecondaryGripScaler);
315 return SmoothedValue;
UCLASS(NotBlueprintable, ClassGroup = (VRExpansionPlugin))
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = MotionController)
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
FVector RunFilterSmoothing(const FVector &InRawValue, const float &InDeltaTime)
USTRUCT(BlueprintType, Category = "VRExpansionLibrary")
float MinCutoff
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "FilterSettings")
float DeltaCutoff
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "FilterSettings")
EGripLerpState GripLerpState
USTRUCT(BlueprintType, Category = "GunSettings")
bool bSmoothStockHand
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock|Smoothing")
FBPVirtualStockSettings()
void CopyFrom(FBPVirtualStockSettings &B)
FVector_NetQuantize100 StockSnapOffset
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock")
float StockSnapLerpThreshold
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock", meta = (ClampMin = "0....
float StockSnapDistance
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock")
float StockLerpValue
UPROPERTY(BlueprintReadOnly, Category = "VirtualStock")
bool bAdjustZOfStockToPrimaryHand
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock")
bool bUseDistanceBasedStockSnapping
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock")
FBPEuroLowPassFilterTrans StockHandSmoothing
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings|VirtualStock|Smoothing")
float SmoothingValueForStock
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VirtualStock|Smoothing", meta = (editconditio...
bool bDebugDrawVirtualStock
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "GunSettings|VirtualStock|Debug")