46 UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions", meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
52 UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions|Collision", meta = (bIgnoreSelf = "true", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
53 static
void SetObjectsIgnoreCollision(
UObject* WorldContextObject, UPrimitiveComponent* Prim1 =
nullptr, FName OptionalBoneName1 = NAME_None,
bool bAddChildBones1 = false, UPrimitiveComponent* Prim2 =
nullptr, FName OptionalBoneName2 = NAME_None,
bool bAddChildBones2 = false,
bool bIgnoreCollision = true);
56 UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions|Collision", meta = (bIgnoreSelf = "true", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
57 static
void SetActorsIgnoreAllCollision(
UObject* WorldContextObject,
AActor* Actor1 =
nullptr,
AActor* Actor2 =
nullptr,
bool bIgnoreCollision = true);
60 UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions|Collision", meta = (bIgnoreSelf = "true", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
61 static
void RemoveObjectCollisionIgnore(
UObject* WorldContextObject, UPrimitiveComponent* Prim1);
64 UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions|Collision", meta = (bIgnoreSelf = "true", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
65 static
void RemoveActorCollisionIgnore(
UObject* WorldContextObject,
AActor* Actor1);
68 UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions|Collision", meta = (bIgnoreSelf = "true", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
69 static
bool IsComponentIgnoringCollision(
UObject* WorldContextObject, UPrimitiveComponent* Prim1);
73 UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions|Collision", meta = (bIgnoreSelf = "true", WorldContext = "WorldContextObject", CallableWithoutWorldContext))
74 static
bool AreComponentsIgnoringCollisions(
UObject* WorldContextObject, UPrimitiveComponent* Prim1, UPrimitiveComponent* Prim2);
76 UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions", meta = (bIgnoreSelf = "true",
DisplayName = "GetHandFromMotionSourceName"))
77 static
bool GetHandFromMotionSourceName(FName MotionSource, EControllerHand& Hand)
79 Hand = EControllerHand::Left;
80 if (FXRMotionControllerBase::GetHandEnumForSourceName(MotionSource, Hand))
89 UFUNCTION(BlueprintPure, Category =
"VRExpansionFunctions", meta = (bIgnoreSelf =
"true",
DisplayName =
"GetHMDPureYaw"))
90 static FRotator GetHMDPureYaw(FRotator HMDRotation);
92 inline static FRotator GetHMDPureYaw_I(FRotator HMDRotation)
95 FRotationMatrix HeadMat(HMDRotation);
96 FVector forward = HeadMat.GetScaledAxis(EAxis::X);
97 FVector forwardLeveled = forward;
99 forwardLeveled.Normalize();
100 FVector mixedInLocalForward = HeadMat.GetScaledAxis(EAxis::Z);
104 mixedInLocalForward = -mixedInLocalForward;
107 mixedInLocalForward.Z = 0;
108 mixedInLocalForward.Normalize();
109 float dot = FMath::Clamp(FVector::DotProduct(forwardLeveled, forward), 0.0f, 1.0f);
110 FVector finalForward = FMath::Lerp(mixedInLocalForward, forwardLeveled, dot * dot);
112 return FRotationMatrix::MakeFromXZ(finalForward, FVector::UpVector).Rotator();
116 UFUNCTION(BlueprintCallable, Category =
"VRExpansionFunctions", meta = (bIgnoreSelf =
"true",
DisplayName =
"RotateAroundPivot"))
117 static
void RotateAroundPivot(FRotator RotationDelta, FVector OriginalLocation, FRotator OriginalRotation, FVector PivotPoint, FVector & NewLocation, FRotator & NewRotation,
bool bUseOriginalYawOnly = true)
119 if (bUseOriginalYawOnly)
122 NewRotation.Pitch = OriginalRotation.Pitch;
123 NewRotation.Roll = OriginalRotation.Roll;
126 OriginalRotation.Roll = 0;
127 OriginalRotation.Pitch = 0;
130 NewLocation = OriginalLocation + OriginalRotation.RotateVector(PivotPoint);
133 OriginalRotation.Yaw = (OriginalRotation.Quaternion() * RotationDelta.Quaternion()).Rotator().Yaw;
134 NewRotation.Yaw = OriginalRotation.Yaw;
137 NewLocation -= OriginalRotation.RotateVector(PivotPoint);
142 NewLocation = OriginalLocation + OriginalRotation.RotateVector(PivotPoint);
143 NewRotation = (OriginalRotation.Quaternion() * RotationDelta.Quaternion()).Rotator();
144 NewLocation -= NewRotation.RotateVector(PivotPoint);
149 UFUNCTION(BlueprintPure, Category =
"VRExpansionFunctions", meta = (bIgnoreSelf =
"true",
DisplayName =
"FindBetween"))
150 static FRotator BPQuat_FindBetween(FVector Vec1, FVector Vec2)
152 return FQuat::FindBetween(Vec1, Vec2).Rotator();
156 UFUNCTION(BlueprintPure, Category =
"VRExpansionFunctions", meta = (bIgnoreSelf =
"true",
DisplayName =
"GetIsHMDConnected"))
157 static
bool GetIsHMDConnected();
160 UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions", meta = (bIgnoreSelf = "true",
DisplayName = "GetIsHMDWorn"))
164 UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions", meta = (bIgnoreSelf = "true",
DisplayName = "GetHMDType"))
168 UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions", meta = (bIgnoreSelf = "true",
DisplayName = "IsInVREditorPreviewOrGame"))
169 static
bool IsInVREditorPreviewOrGame();
172 UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions", meta = (bIgnoreSelf = "true",
DisplayName = "IsInVREditorPreview"))
173 static
bool IsInVREditorPreview();
185 UFUNCTION(BlueprintCallable, Category = "VRExpansionFunctions", meta = (WorldContext = "WorldContextObject", CallableWithoutWorldContext))
186 static
void NonAuthorityMinimumAreaRectangle(
UObject* WorldContextObject, const TArray<FVector>& InVerts, const FVector& SampleSurfaceNormal, FVector& OutRectCenter, FRotator& OutRectRotation,
float& OutSideLengthX,
float& OutSideLengthY,
bool bDebugDraw = false);
189 UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions", meta = (bIgnoreSelf = "true",
DisplayName = "LowPassFilter_RollingAverage"))
190 static
void LowPassFilter_RollingAverage(FVector lastAverage, FVector newSample, FVector & newAverage, int32 numSamples = 10);
193 UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions", meta = (bIgnoreSelf = "true",
DisplayName = "LowPassFilter_Exponential"))
194 static
void LowPassFilter_Exponential(FVector lastAverage, FVector newSample, FVector & newAverage,
float sampleFactor = 0.25f);
197 UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions", meta = (bIgnoreSelf = "true",
DisplayName = "GetIsActorMovable"))
198 static
bool GetIsActorMovable(
AActor * ActorToCheck);
201 UFUNCTION(BlueprintPure, Category = "
VRGrip", meta = (bIgnoreSelf = "true",
DisplayName = "GetGripSlotInRangeByTypeName"))
202 static
void GetGripSlotInRangeByTypeName(FName SlotType,
AActor *
Actor, FVector WorldLocation,
float MaxRange,
bool & bHadSlotInRange, FTransform & SlotWorldTransform, FName & SlotName,
UGripMotionControllerComponent* QueryController =
nullptr);
205 UFUNCTION(BlueprintPure, Category = "
VRGrip", meta = (bIgnoreSelf = "true",
DisplayName = "GetGripSlotInRangeByTypeName_Component"))
206 static
void GetGripSlotInRangeByTypeName_Component(FName SlotType,
USceneComponent * Component, FVector WorldLocation,
float MaxRange,
bool & bHadSlotInRange, FTransform & SlotWorldTransform, FName & SlotName,
UGripMotionControllerComponent* QueryController =
nullptr);
209 UFUNCTION(BlueprintPure, meta = (
DisplayName = "
Equal VR Grip", CompactNodeTitle = "==", Keywords = "== equal"), Category = "VRExpansionFunctions")
213 UFUNCTION(BlueprintPure, Category = "VRExpansionFunctions")
218 UFUNCTION(BlueprintPure, meta = (Scale = "1,1,1", Keywords = "construct build", NativeMakeFunc), Category = "VRExpansionLibrary|TransformNetQuantize")
219 static
FTransform_NetQuantize MakeTransform_NetQuantize(FVector Location, FRotator Rotation, FVector Scale);
222 UFUNCTION(BlueprintPure, Category = "VRExpansionLibrary|TransformNetQuantize", meta = (NativeBreakFunc))
223 static
void BreakTransform_NetQuantize(const
FTransform_NetQuantize& InTransform, FVector& Location, FRotator& Rotation, FVector& Scale);
226 UFUNCTION(BlueprintPure, meta = (
DisplayName = "ToTransform_NetQuantize (Transform)", CompactNodeTitle = "->", BlueprintAutocast), Category = "VRExpansionLibrary|TransformNetQuantize")
230 UFUNCTION(BlueprintPure, meta = (
DisplayName = "ToVector_NetQuantize (Vector)", CompactNodeTitle = "->", BlueprintAutocast), Category = "VRExpansionLibrary|FVectorNetQuantize")
231 static FVector_NetQuantize Conv_FVectorToFVectorNetQuantize(const FVector &InVector);
234 UFUNCTION(BlueprintPure, meta = (Scale = "1,1,1", Keywords = "construct build", NativeMakeFunc), Category = "VRExpansionLibrary|FVectorNetQuantize")
235 static FVector_NetQuantize MakeVector_NetQuantize(FVector InVector);
238 UFUNCTION(BlueprintPure, meta = (
DisplayName = "ToVector_NetQuantize10 (Vector)", CompactNodeTitle = "->", BlueprintAutocast), Category = "VRExpansionLibrary|FVectorNetQuantize")
239 static FVector_NetQuantize10 Conv_FVectorToFVectorNetQuantize10(const FVector &InVector);
242 UFUNCTION(BlueprintPure, meta = (Scale = "1,1,1", Keywords = "construct build", NativeMakeFunc), Category = "VRExpansionLibrary|FVectorNetQuantize")
243 static FVector_NetQuantize10 MakeVector_NetQuantize10(FVector InVector);
246 UFUNCTION(BlueprintPure, meta = (
DisplayName = "ToVector_NetQuantize100 (Vector)", CompactNodeTitle = "->", BlueprintAutocast), Category = "VRExpansionLibrary|FVectorNetQuantize")
247 static FVector_NetQuantize100 Conv_FVectorToFVectorNetQuantize100(const FVector &InVector);
250 UFUNCTION(BlueprintPure, meta = (Scale = "1,1,1", Keywords = "construct build", NativeMakeFunc), Category = "VRExpansionLibrary|FVectorNetQuantize")
251 static FVector_NetQuantize100 MakeVector_NetQuantize100(FVector InVector);
254 UFUNCTION(BlueprintPure, meta = (
DisplayName = "ToController (
FBPGripPair)", CompactNodeTitle = "->", BlueprintAutocast), Category = "VRExpansionLibrary")
258 UFUNCTION(BlueprintPure, meta = (
DisplayName = "ToGripID (
FBPGripPair)", CompactNodeTitle = "->", BlueprintAutocast), Category = "VRExpansionLibrary")
259 static uint8 Conv_GripPairToGripID(const
FBPGripPair &GripPair);
262 UFUNCTION(BlueprintCallable, meta = (
DisplayName = "Add Scene Component By Class"), Category = "VRExpansionLibrary")
267 UFUNCTION(BlueprintCallable, Category = "LowPassFilter_Peak")
270 TargetPeakFilter.Reset();
274 UFUNCTION(BlueprintCallable, Category =
"LowPassFilter_Peak")
275 static
void UpdatePeakLowPassFilter(UPARAM(ref)
FBPLowPassPeakFilter& TargetPeakFilter, FVector NewSample)
277 TargetPeakFilter.AddSample(NewSample);
281 UFUNCTION(BlueprintCallable, Category =
"LowPassFilter_Peak")
284 return TargetPeakFilter.GetPeak();
289 UFUNCTION(BlueprintCallable, Category =
"EuroLowPassFilter")
292 TargetEuroFilter.ResetSmoothingFilter();
296 UFUNCTION(BlueprintCallable, Category =
"EuroLowPassFilter")
297 static
void RunEuroSmoothingFilter(UPARAM(ref)
FBPEuroLowPassFilter& TargetEuroFilter, FVector InRawValue, const
float DeltaTime, FVector & SmoothedValue)
299 SmoothedValue = TargetEuroFilter.RunFilterSmoothing(InRawValue, DeltaTime);
303 UFUNCTION(BlueprintCallable, meta = (
DisplayName =
"Smooth Update Laser Spline"), Category =
"VRExpansionLibrary")
304 static
void SmoothUpdateLaserSpline(USplineComponent * LaserSplineComponent, TArray<USplineMeshComponent *> LaserSplineMeshComponents, FVector InStartLocation, FVector InEndLocation, FVector InForward,
float LaserRadius)
306 if (LaserSplineComponent ==
nullptr)
309 LaserSplineComponent->ClearSplinePoints();
311 const FVector SmoothLaserDirection = InEndLocation - InStartLocation;
312 float Distance = SmoothLaserDirection.Size();
313 const FVector StraightLaserEndLocation = InStartLocation + (InForward * Distance);
314 const int32 NumLaserSplinePoints = LaserSplineMeshComponents.Num();
316 LaserSplineComponent->AddSplinePoint(InStartLocation, ESplineCoordinateSpace::World,
false);
317 for (int32 Index = 1; Index < NumLaserSplinePoints; Index++)
319 float Alpha = (float)Index / (
float)NumLaserSplinePoints;
320 Alpha = FMath::Sin(Alpha * PI * 0.5f);
321 const FVector PointOnStraightLaser = FMath::Lerp(InStartLocation, StraightLaserEndLocation, Alpha);
322 const FVector PointOnSmoothLaser = FMath::Lerp(InStartLocation, InEndLocation, Alpha);
323 const FVector PointBetweenLasers = FMath::Lerp(PointOnStraightLaser, PointOnSmoothLaser, Alpha);
324 LaserSplineComponent->AddSplinePoint(PointBetweenLasers, ESplineCoordinateSpace::World,
false);
326 LaserSplineComponent->AddSplinePoint(InEndLocation, ESplineCoordinateSpace::World,
false);
329 LaserSplineComponent->UpdateSpline();
331 const float LaserPointerRadius = LaserRadius;
333 for (int32 Index = 0; Index < NumLaserSplinePoints; Index++)
335 USplineMeshComponent* SplineMeshComponent = LaserSplineMeshComponents[Index];
336 check(SplineMeshComponent !=
nullptr);
338 FVector StartLoc, StartTangent, EndLoc, EndTangent;
339 LaserSplineComponent->GetLocationAndTangentAtSplinePoint(Index, StartLoc, StartTangent, ESplineCoordinateSpace::Local);
340 LaserSplineComponent->GetLocationAndTangentAtSplinePoint(Index + 1, EndLoc, EndTangent, ESplineCoordinateSpace::Local);
342 const float AlphaIndex = (float)Index / (
float)NumLaserSplinePoints;
343 const float AlphaDistance = Distance * AlphaIndex;
344 float Radius = LaserPointerRadius * ((AlphaIndex * AlphaDistance) + 1);
345 FVector2D LaserScale(Radius, Radius);
346 SplineMeshComponent->SetStartScale(LaserScale,
false);
348 const float NextAlphaIndex = (float)(Index + 1) / (float)NumLaserSplinePoints;
349 const float NextAlphaDistance = Distance * NextAlphaIndex;
350 Radius = LaserPointerRadius * ((NextAlphaIndex * NextAlphaDistance) + 1);
351 LaserScale = FVector2D(Radius, Radius);
352 SplineMeshComponent->SetEndScale(LaserScale,
false);
354 SplineMeshComponent->SetStartAndEnd(StartLoc, StartTangent, EndLoc, EndTangent,
true);
368 UFUNCTION(BlueprintPure, Category =
"GameplayTags")
369 static
bool MatchesAnyTagsWithDirectParentTag(FGameplayTag DirectParentTag,const FGameplayTagContainer& BaseContainer, const FGameplayTagContainer& OtherContainer)
371 TArray<FGameplayTag> BaseContainerTags;
372 BaseContainer.GetGameplayTagArray(BaseContainerTags);
374 for (
const FGameplayTag& OtherTag : BaseContainerTags)
376 if (OtherTag.RequestDirectParent().MatchesTagExact(DirectParentTag))
378 if (OtherContainer.HasTagExact(OtherTag))
393 UFUNCTION(BlueprintPure, Category =
"GameplayTags")
394 static
bool GetFirstGameplayTagWithExactParent(FGameplayTag DirectParentTag, const FGameplayTagContainer& BaseContainer, FGameplayTag& FoundTag)
396 TArray<FGameplayTag> BaseContainerTags;
397 BaseContainer.GetGameplayTagArray(BaseContainerTags);
399 for (
const FGameplayTag& OtherTag : BaseContainerTags)
401 if (OtherTag.RequestDirectParent().MatchesTagExact(DirectParentTag))