diff --git a/Source/RWTHVRCluster/Private/CAVEOverlay/CAVEOverlayController.cpp b/Source/RWTHVRCluster/Private/CAVEOverlay/CAVEOverlayController.cpp index d1f5849d13b9ea52be233f4a8798023da7daf6bc..157e44d8a64c5d79b5aa6c8a0376838bc2c1842e 100644 --- a/Source/RWTHVRCluster/Private/CAVEOverlay/CAVEOverlayController.cpp +++ b/Source/RWTHVRCluster/Private/CAVEOverlay/CAVEOverlayController.cpp @@ -46,7 +46,7 @@ ACAVEOverlayController::ACAVEOverlayController() PrimaryActorTick.bCanEverTick = true; bAllowTickBeforeBeginPlay = false; - //Creation of sub-components + // Creation of sub-components Root = CreateDefaultSubobject<USceneComponent>("DefaultSceneRoot"); SetRootComponent(Root); @@ -73,8 +73,8 @@ void ACAVEOverlayController::CycleDoorType() void ACAVEOverlayController::HandleClusterEvent(const FDisplayClusterClusterEventJson& Event) { - if (Event.Category.Equals("CAVEOverlay") && Event.Type.Equals("DoorChange") && Event.Parameters.Contains( - "NewDoorState")) + if (Event.Category.Equals("CAVEOverlay") && Event.Type.Equals("DoorChange") && + Event.Parameters.Contains("NewDoorState")) { SetDoorMode(static_cast<EDoorMode>(FCString::Atoi(*Event.Parameters["NewDoorState"]))); } @@ -91,8 +91,7 @@ void ACAVEOverlayController::SetDoorMode(const EDoorMode NewMode) if (ScreenType == SCREEN_DOOR) Overlay->BlackBox->SetRenderScale(FVector2D(0, 1)); if (ScreenType == SCREEN_DOOR_PARTIAL) - Overlay->BlackBox-> - SetRenderScale(FVector2D(DoorOpeningWidthRelative, 1)); + Overlay->BlackBox->SetRenderScale(FVector2D(DoorOpeningWidthRelative, 1)); if (ScreenType == SCREEN_PRIMARY) Overlay->BlackBox->SetRenderScale(FVector2D(0, 1)); @@ -120,7 +119,7 @@ void ACAVEOverlayController::SetDoorMode(const EDoorMode NewMode) Overlay->BlackBox->SetVisibility(ESlateVisibility::Hidden); break; - default: ; + default:; } // On the secondary nodes that are not the door, hide the overlay completely @@ -129,7 +128,7 @@ void ACAVEOverlayController::SetDoorMode(const EDoorMode NewMode) Overlay->BlackBox->SetRenderScale(FVector2D(0, 1)); UE_LOGFMT(LogCAVEOverlay, Log, "Switched door state to {State}. New opening width is {Width}.", - *DoorModeNames[DoorCurrentMode], DoorCurrentOpeningWidthAbsolute); + *DoorModeNames[DoorCurrentMode], DoorCurrentOpeningWidthAbsolute); // On the primary node, show which door mode is currently active. if (ScreenType == SCREEN_PRIMARY) @@ -163,7 +162,7 @@ void ACAVEOverlayController::BeginPlay() if (!bValidPC || !URWTHVRUtilities::IsRoomMountedMode()) return; - //Input config + // Input config if (URWTHVRUtilities::IsPrimaryNode()) { if (CycleDoorTypeInputAction == nullptr || IMCCaveOverlayInputMapping == nullptr) @@ -174,12 +173,12 @@ void ACAVEOverlayController::BeginPlay() UEnhancedInputComponent* Input = Cast<UEnhancedInputComponent>(PC->InputComponent); Input->BindAction(CycleDoorTypeInputAction, ETriggerEvent::Triggered, this, - &ACAVEOverlayController::CycleDoorType); + &ACAVEOverlayController::CycleDoorType); if (const ULocalPlayer* LocalPlayer = PC->GetLocalPlayer()) { - if (UEnhancedInputLocalPlayerSubsystem* InputSystem = LocalPlayer->GetSubsystem< - UEnhancedInputLocalPlayerSubsystem>()) + if (UEnhancedInputLocalPlayerSubsystem* InputSystem = + LocalPlayer->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>()) { InputSystem->AddMappingContext(IMCCaveOverlayInputMapping, 0); } @@ -190,8 +189,8 @@ void ACAVEOverlayController::BeginPlay() IDisplayClusterClusterManager* ClusterManager = IDisplayCluster::Get().GetClusterMgr(); if (ClusterManager && !ClusterEventListenerDelegate.IsBound()) { - ClusterEventListenerDelegate = FOnClusterEventJsonListener::CreateUObject( - this, &ACAVEOverlayController::HandleClusterEvent); + ClusterEventListenerDelegate = + FOnClusterEventJsonListener::CreateUObject(this, &ACAVEOverlayController::HandleClusterEvent); ClusterManager->AddClusterEventJsonListener(ClusterEventListenerDelegate); } @@ -226,7 +225,7 @@ void ACAVEOverlayController::BeginPlay() // Set the default door mode (partially open) SetDoorMode(DoorCurrentMode); - //Set Text to "" until someone presses the key for the first time + // Set Text to "" until someone presses the key for the first time Overlay->CornerText->SetText(FText::FromString("")); // Get the pawn so we can have access to head and hand positions @@ -241,7 +240,7 @@ void ACAVEOverlayController::BeginPlay() UE_LOGFMT(LogCAVEOverlay, Error, "No VirtualRealityPawn found which we could attach to!"); } - //Create dynamic materials at runtime + // Create dynamic materials at runtime TapeMaterialDynamic = Tape->CreateDynamicMaterialInstance(0); RightSignMaterialDynamic = SignRightHand->CreateDynamicMaterialInstance(0); LeftSignMaterialDynamic = SignLeftHand->CreateDynamicMaterialInstance(0); @@ -266,38 +265,37 @@ double ACAVEOverlayController::CalculateOpacityFromPosition(const FVector& Posit // fully opaque when WallFadeDistance away from the wall. Could just use a lerp here.. return FMath::Max( FMath::Clamp((FMath::Abs(Position.X) - (WallDistance - WallCloseDistance)) / WallFadeDistance, 0.0, 1.0), - FMath::Clamp((FMath::Abs(Position.Y) - (WallDistance - WallCloseDistance)) / WallFadeDistance, 0.0, 1.0) - ); + FMath::Clamp((FMath::Abs(Position.Y) - (WallDistance - WallCloseDistance)) / WallFadeDistance, 0.0, 1.0)); } bool ACAVEOverlayController::PositionInDoorOpening(const FVector& Position) const { - // The position of the corner with 10cm of buffer. In negative direction because the door is in negative direction of the cave + // The position of the corner with 10cm of buffer. In negative direction because the door is in negative direction + // of the cave const float CornerValue = -(WallDistance + 10); // Check whether our X position is within the door zone. This zone starts 10cm further away from the wall // than the WallCloseDistance, and ends 10cm outside of the wall (door). As the door is in negative X direction, // the signs need to be negated. - const bool bXWithinDoor = FMath::IsWithinInclusive(Position.X, CornerValue, - -(WallDistance - WallCloseDistance - 10)); + const bool bXWithinDoor = + FMath::IsWithinInclusive(Position.X, CornerValue, -(WallDistance - WallCloseDistance - 10)); // Checks whether our Y position is between the lower corner with some overlap and // the door corner (CornerValue + DoorCurrentOpeningWidthAbsolute) - const bool bYWithinDoor = FMath::IsWithinInclusive(Position.Y, CornerValue, - CornerValue + DoorCurrentOpeningWidthAbsolute); + const bool bYWithinDoor = + FMath::IsWithinInclusive(Position.Y, CornerValue, CornerValue + DoorCurrentOpeningWidthAbsolute); return bXWithinDoor && bYWithinDoor; } void ACAVEOverlayController::SetSignsForHand(UStaticMeshComponent* Sign, const FVector& HandPosition, - UMaterialInstanceDynamic* HandMaterial) const + UMaterialInstanceDynamic* HandMaterial) const { - const bool bHandIsCloseToWall = FMath::IsWithinInclusive(HandPosition.GetAbsMax(), - WallDistance - WallCloseDistance, WallDistance); + const bool bHandIsCloseToWall = + FMath::IsWithinInclusive(HandPosition.GetAbsMax(), WallDistance - WallCloseDistance, WallDistance); if (bHandIsCloseToWall && !PositionInDoorOpening(HandPosition)) { Sign->SetVisibility(true); - HandMaterial->SetScalarParameterValue("SignOpacity", - CalculateOpacityFromPosition(HandPosition)); + HandMaterial->SetScalarParameterValue("SignOpacity", CalculateOpacityFromPosition(HandPosition)); // Which wall are we closest to? This is the wall we project the sign onto const bool bXWallCloser = FMath::Abs(HandPosition.X) > FMath::Abs(HandPosition.Y); @@ -330,8 +328,8 @@ void ACAVEOverlayController::Tick(float DeltaTime) // Head/Tape Logic const FVector HeadPosition = VRPawn->HeadCameraComponent->GetRelativeTransform().GetLocation(); - const bool bHeadIsCloseToWall = FMath::IsWithinInclusive(HeadPosition.GetAbsMax(), - WallDistance - WallCloseDistance, WallDistance); + const bool bHeadIsCloseToWall = + FMath::IsWithinInclusive(HeadPosition.GetAbsMax(), WallDistance - WallCloseDistance, WallDistance); // Only show the tape when close to a wall and not within the door opening if (bHeadIsCloseToWall && !PositionInDoorOpening(HeadPosition)) diff --git a/Source/RWTHVRCluster/Private/CaveSetup.cpp b/Source/RWTHVRCluster/Private/CaveSetup.cpp index da178a98f0fdceaacee7bd4c3b331fbc0e8bf621..c39e47d4997863ee26b9fe5065c327efc6aa669f 100644 --- a/Source/RWTHVRCluster/Private/CaveSetup.cpp +++ b/Source/RWTHVRCluster/Private/CaveSetup.cpp @@ -35,7 +35,7 @@ void ACaveSetup::BeginPlay() const auto Actor = World->SpawnActor(ActorClass); Actor->AttachToActor(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale); UE_LOGFMT(LogTemp, Display, "CaveSetup: Spawned Actor {Actor} on the Cave and attached it.", - Actor->GetName()); + Actor->GetName()); } } @@ -48,7 +48,7 @@ void ACaveSetup::BeginPlay() LiveLinkPresetToApplyOnCave->ApplyToClientLatent(); UE_LOGFMT(LogTemp, Display, "CaveSetup: Applied LiveLinkPreset {Preset} to Client.", - LiveLinkPresetToApplyOnCave->GetName()); + LiveLinkPresetToApplyOnCave->GetName()); } } } diff --git a/Source/RWTHVRCluster/Private/ClusterConsole/ClusterConsole.cpp b/Source/RWTHVRCluster/Private/ClusterConsole/ClusterConsole.cpp index b1d1a9019223ac0cee588aaeceb003b3ad36be7a..a0a7c49523e7191163cb53a5c290f9459c73f3f1 100644 --- a/Source/RWTHVRCluster/Private/ClusterConsole/ClusterConsole.cpp +++ b/Source/RWTHVRCluster/Private/ClusterConsole/ClusterConsole.cpp @@ -9,19 +9,21 @@ void FClusterConsole::Register() ClusterConsoleCommand = IConsoleManager::Get().RegisterConsoleCommand( TEXT("ClusterExecute"), TEXT("<Your Command> - Execute commands on every node of the nDisplay cluster by prepending ClusterExecute"), - FConsoleCommandWithArgsDelegate::CreateLambda([](const TArray<FString>& Args) - { - if (IDisplayCluster::Get().GetClusterMgr() == nullptr || Args.Num() == 0) return; + FConsoleCommandWithArgsDelegate::CreateLambda( + [](const TArray<FString>& Args) + { + if (IDisplayCluster::Get().GetClusterMgr() == nullptr || Args.Num() == 0) + return; - /* Emitting cluster event */ - FDisplayClusterClusterEventJson ClusterEvent; - ClusterEvent.Name = "ClusterExecute " + Args[0]; - ClusterEvent.Type = Args[0]; - ClusterEvent.Category = "NDisplayClusterExecute"; - ClusterEvent.Parameters.Add("Command", FString::Join(Args, TEXT(" "))); + /* Emitting cluster event */ + FDisplayClusterClusterEventJson ClusterEvent; + ClusterEvent.Name = "ClusterExecute " + Args[0]; + ClusterEvent.Type = Args[0]; + ClusterEvent.Category = "NDisplayClusterExecute"; + ClusterEvent.Parameters.Add("Command", FString::Join(Args, TEXT(" "))); - IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventJson(ClusterEvent, false); - })); + IDisplayCluster::Get().GetClusterMgr()->EmitClusterEventJson(ClusterEvent, false); + })); /* Register cluster event handling */ const IDisplayCluster* DisplayCluster = FModuleManager::LoadModulePtr<IDisplayCluster>(IDisplayCluster::ModuleName); diff --git a/Source/RWTHVRCluster/Private/RWTHVRCluster.cpp b/Source/RWTHVRCluster/Private/RWTHVRCluster.cpp index 121a015a5c5321ac75864da5997743572c43464e..3f0955de6db6984ba796eb5c6ae793141456c25e 100644 --- a/Source/RWTHVRCluster/Private/RWTHVRCluster.cpp +++ b/Source/RWTHVRCluster/Private/RWTHVRCluster.cpp @@ -2,15 +2,9 @@ #define LOCTEXT_NAMESPACE "FRWTHVRClusterModule" -void FRWTHVRClusterModule::StartupModule() -{ - ClusterConsole.Register(); -} +void FRWTHVRClusterModule::StartupModule() { ClusterConsole.Register(); } -void FRWTHVRClusterModule::ShutdownModule() -{ - ClusterConsole.Unregister(); -} +void FRWTHVRClusterModule::ShutdownModule() { ClusterConsole.Unregister(); } #undef LOCTEXT_NAMESPACE diff --git a/Source/RWTHVRCluster/Public/CAVEOverlay/CAVEOverlayController.h b/Source/RWTHVRCluster/Public/CAVEOverlay/CAVEOverlayController.h index ed2ffe10bd2160d900b318c11dd8b4ce4c6e7719..234344221310b07fe6fe657468100cb4e4e11714 100644 --- a/Source/RWTHVRCluster/Public/CAVEOverlay/CAVEOverlayController.h +++ b/Source/RWTHVRCluster/Public/CAVEOverlay/CAVEOverlayController.h @@ -13,7 +13,7 @@ DECLARE_LOG_CATEGORY_EXTERN(LogCAVEOverlay, Log, All); * Actor which controls the cave overlay. The overlay displays a warning tape around the cave * when the user moves their head too close to the wall, and a warning sign when the hands are * too close. -*/ + */ UCLASS() class RWTHVRCLUSTER_API ACAVEOverlayController : public AActor { @@ -44,28 +44,33 @@ private: EScreen_Type ScreenType = SCREEN_NORMAL; // which additional node names define the screens that cover the door - const TArray<FString> ScreensDoor = { - "node_bul_left_eye", "node_bul_right_eye", "node_bll_left_eye", "node_bll_right_eye" - }; + const TArray<FString> ScreensDoor = {"node_bul_left_eye", "node_bul_right_eye", "node_bll_left_eye", + "node_bll_right_eye"}; // which node names define the screens that cover the partial door - const TArray<FString> ScreensDoorPartial = { - "node_bur_left_eye", "node_bur_right_eye", "node_blr_left_eye", "node_blr_right_eye" - }; + const TArray<FString> ScreensDoorPartial = {"node_bur_left_eye", "node_bur_right_eye", "node_blr_left_eye", + "node_blr_right_eye"}; const FString ScreenMain = "node_main"; - //Door Mode - enum EDoorMode { DOOR_PARTIALLY_OPEN = 0, DOOR_OPEN = 1, DOOR_CLOSED = 2, DOOR_DEBUG = 3, DOOR_NUM_MODES = 4 }; + // Door Mode + enum EDoorMode + { + DOOR_PARTIALLY_OPEN = 0, + DOOR_OPEN = 1, + DOOR_CLOSED = 2, + DOOR_DEBUG = 3, + DOOR_NUM_MODES = 4 + }; const FString DoorModeNames[DOOR_NUM_MODES] = {"Partially Open", "Open", "Closed", "Debug"}; EDoorMode DoorCurrentMode = DOOR_PARTIALLY_OPEN; const float DoorOpeningWidthRelative = 0.522; //%, used for the overlay width on the screen - const float DoorOpeningWidthAbsolute = 165; //cm, used for the non tape part at the door - const float WallDistance = 262.5; //cm, distance from center to a wall, *2 = wall width - const float WallCloseDistance = 75; //cm, the distance considered to be too close to the walls - const float WallFadeDistance = 35; //cm, the distance over which the tape is faded - const float WallWarningDistance = 40; //cm, distance on which the tape turns red, measured from wall + const float DoorOpeningWidthAbsolute = 165; // cm, used for the non tape part at the door + const float WallDistance = 262.5; // cm, distance from center to a wall, *2 = wall width + const float WallCloseDistance = 75; // cm, the distance considered to be too close to the walls + const float WallFadeDistance = 35; // cm, the distance over which the tape is faded + const float WallWarningDistance = 40; // cm, distance on which the tape turns red, measured from wall float DoorCurrentOpeningWidthAbsolute = 0; // Helper function to create a mesh component in the constructor @@ -79,7 +84,7 @@ private: // Sets the position, orientation and opacity/visibility of the Sign according to the HandPosition. void SetSignsForHand(UStaticMeshComponent* Sign, const FVector& HandPosition, - UMaterialInstanceDynamic* HandMaterial) const; + UMaterialInstanceDynamic* HandMaterial) const; // Only calculate positions and material values when we're fully initialized. bool bInitialized = false; @@ -123,7 +128,7 @@ public: UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "CAVEOverlay") UInputAction* CycleDoorTypeInputAction; - UPROPERTY(BlueprintReadOnly, EditAnywhere, Category="CAVEOverlay") + UPROPERTY(BlueprintReadOnly, EditAnywhere, Category = "CAVEOverlay") UInputMappingContext* IMCCaveOverlayInputMapping; UPROPERTY() diff --git a/Source/RWTHVRCluster/Public/CAVEOverlay/CAVEOverlaySettings.h b/Source/RWTHVRCluster/Public/CAVEOverlay/CAVEOverlaySettings.h index e902289363d7cd73cd127faa4837782763116e6e..eee4b554ffa439a6d1f743144fa44689de5193d7 100644 --- a/Source/RWTHVRCluster/Public/CAVEOverlay/CAVEOverlaySettings.h +++ b/Source/RWTHVRCluster/Public/CAVEOverlay/CAVEOverlaySettings.h @@ -10,7 +10,7 @@ enum DefaultActivationType DefaultActivationType_ON UMETA(DisplayName = "On by default") }; -UCLASS(config=Game, defaultconfig, meta=(DisplayName="CAVE Overlay")) +UCLASS(config = Game, defaultconfig, meta = (DisplayName = "CAVE Overlay")) class RWTHVRCLUSTER_API UCAVEOverlaySettings : public UDeveloperSettings { GENERATED_BODY() @@ -19,6 +19,6 @@ public: UPROPERTY(EditAnywhere, config, Category = "General", meta = (DisplayName = "Default Activation Type")) TEnumAsByte<DefaultActivationType> DefaultActivationType = DefaultActivationType_ON; - UPROPERTY(EditAnywhere, config, Category = Maps, meta=(AllowedClasses="/Script/Engine.World")) + UPROPERTY(EditAnywhere, config, Category = Maps, meta = (AllowedClasses = "/Script/Engine.World")) TArray<FSoftObjectPath> ExcludedMaps; }; diff --git a/Source/RWTHVRCluster/Public/CAVEOverlay/DoorOverlayData.h b/Source/RWTHVRCluster/Public/CAVEOverlay/DoorOverlayData.h index 0fb53f02a1c8084b13d14e05ff5106ca261433b9..b4a0fada65f6f01d398e73a33de60b4fec4dc307 100644 --- a/Source/RWTHVRCluster/Public/CAVEOverlay/DoorOverlayData.h +++ b/Source/RWTHVRCluster/Public/CAVEOverlay/DoorOverlayData.h @@ -17,8 +17,8 @@ class RWTHVRCLUSTER_API UDoorOverlayData : public UUserWidget GENERATED_BODY() public: - //These declarations are magically bound to the UMG blueprints elements, - //if they are named the same + // These declarations are magically bound to the UMG blueprints elements, + // if they are named the same UPROPERTY(BlueprintReadWrite, meta = (BindWidget)) UTextBlock* CornerText; diff --git a/Source/RWTHVRCluster/Public/ClusterConsole/ClusterConsole.h b/Source/RWTHVRCluster/Public/ClusterConsole/ClusterConsole.h index 46453808be934f5e9d6782f638c984c3f03ec0d8..f09a948c64f5b82b1c50c62cfb5b4a7ca86118a8 100644 --- a/Source/RWTHVRCluster/Public/ClusterConsole/ClusterConsole.h +++ b/Source/RWTHVRCluster/Public/ClusterConsole/ClusterConsole.h @@ -8,8 +8,9 @@ /** * The ClusterConsole provides the console command "ClusterExecute" * The code catches your command, broadcasts it to every nDisplay node and executes it everywhere - * - * This class has to be registered and unregistered. This can easily be done in every StartupModule/ShutdownModule functions. + * + * This class has to be registered and unregistered. This can easily be done in every StartupModule/ShutdownModule + * functions. */ USTRUCT() struct RWTHVRCLUSTER_API FClusterConsole diff --git a/Source/RWTHVRCluster/Public/Events/DisplayClusterEventParameterHelper.h b/Source/RWTHVRCluster/Public/Events/DisplayClusterEventParameterHelper.h index aa633d5fe15fe79c4462495363c4ffc3dbb2fcf6..49500b767751ada9db7d935be95de34311540ad5 100644 --- a/Source/RWTHVRCluster/Public/Events/DisplayClusterEventParameterHelper.h +++ b/Source/RWTHVRCluster/Public/Events/DisplayClusterEventParameterHelper.h @@ -6,7 +6,7 @@ template <typename ParameterType, typename... RemainingParameterTypes> inline void SerializeParameters(FMemoryWriter* MemoryWriter, ParameterType&& Parameter, - RemainingParameterTypes&&... RemainingParameters) + RemainingParameterTypes&&... RemainingParameters) { using NonConstType = typename std::remove_cv_t<typename TRemoveReference<ParameterType>::Type>; // const_cast because the same operator (<<) is used for reading and writing @@ -14,18 +14,17 @@ inline void SerializeParameters(FMemoryWriter* MemoryWriter, ParameterType&& Par SerializeParameters(MemoryWriter, Forward<RemainingParameterTypes>(RemainingParameters)...); } -inline void SerializeParameters(FMemoryWriter* MemoryWriter) -{ -} +inline void SerializeParameters(FMemoryWriter* MemoryWriter) {} -// This is a wrapper function to recursively fill the argument tuple. This overload is only used if the index indicating the -// currently handled attribute is less than the number of total attributes. I.e., if the attribute index is valid. +// This is a wrapper function to recursively fill the argument tuple. This overload is only used if the index indicating +// the currently handled attribute is less than the number of total attributes. I.e., if the attribute index is valid. template <int CurrentIndex, typename... ArgTypes> inline typename TEnableIf<(CurrentIndex < sizeof...(ArgTypes))>::Type FillArgumentTuple(FMemoryReader* MemoryReader, TTuple<ArgTypes...>* ArgumentTuple) { - // Read the "<<" as ">>" operator here. FArchive uses the same for both and decides based on an internal type on what to do. So - // this statement parses the bytes that were passed into reader and puts the parsed object into the tuple at index CurrentIndex. + // Read the "<<" as ">>" operator here. FArchive uses the same for both and decides based on an internal type on + // what to do. So this statement parses the bytes that were passed into reader and puts the parsed object into the + // tuple at index CurrentIndex. (*MemoryReader) << ArgumentTuple->template Get<CurrentIndex>(); // Recursive call for the remaining attributes. @@ -40,20 +39,18 @@ FillArgumentTuple(FMemoryReader* MemoryReader, TTuple<ArgTypes...>* ArgumentTupl } template <typename RetType, typename... ArgTypes> -inline RetType CallDelegateWithParameterMap( - const TDelegate<RetType, ArgTypes...>& Delegate, const TMap<FString, FString>& Parameters) +inline RetType CallDelegateWithParameterMap(const TDelegate<RetType, ArgTypes...>& Delegate, + const TMap<FString, FString>& Parameters) { - // Create a tuple that holds all arguments. This assumes that all argument types are default constructible. However, all - // types that overload the FArchive "<<" operator probably are. + // Create a tuple that holds all arguments. This assumes that all argument types are default constructible. However, + // all types that overload the FArchive "<<" operator probably are. TTuple<typename std::remove_cv_t<typename TRemoveReference<ArgTypes>::Type>...> ArgumentTuple; // This call will parse the string map and fill all values in the tuple appropriately. FillArgumentTuple<0>(&ArgumentTuple, Parameters); - // The lambda function is only necessary because delegates do not overload the ()-operator but use the Execute() method - // instead. So, the lambda acts as a wrapper. + // The lambda function is only necessary because delegates do not overload the ()-operator but use the Execute() + // method instead. So, the lambda acts as a wrapper. return ArgumentTuple.ApplyBefore([Delegate](ArgTypes&&... Arguments) - { - Delegate.Execute(Forward<ArgTypes>(Arguments)...); - }); + { Delegate.Execute(Forward<ArgTypes>(Arguments)...); }); } diff --git a/Source/RWTHVRCluster/Public/Events/DisplayClusterEventWrapper.h b/Source/RWTHVRCluster/Public/Events/DisplayClusterEventWrapper.h index ef39e5ed0c21f99774ee2d36aae6f0dd5b8d10cc..e08fed921287bbad6a76367e590cc21e2b476b5d 100644 --- a/Source/RWTHVRCluster/Public/Events/DisplayClusterEventWrapper.h +++ b/Source/RWTHVRCluster/Public/Events/DisplayClusterEventWrapper.h @@ -11,8 +11,8 @@ static constexpr int32 CLUSTER_EVENT_WRAPPER_EVENT_ID = 1337420; template <typename MemberFunctionType, MemberFunctionType MemberFunction> class ClusterEventWrapperEvent; -template <typename ObjectType, typename ReturnType, typename... ArgTypes, ReturnType (ObjectType::* - MemberFunction)(ArgTypes...)> +template <typename ObjectType, typename ReturnType, typename... ArgTypes, + ReturnType (ObjectType::*MemberFunction)(ArgTypes...)> class ClusterEventWrapperEvent<ReturnType (ObjectType::*)(ArgTypes...), MemberFunction> { static_assert(TIsDerivedFrom<ObjectType, UObject>::IsDerived, "Object needs to derive from UObject"); @@ -20,9 +20,7 @@ class ClusterEventWrapperEvent<ReturnType (ObjectType::*)(ArgTypes...), MemberFu public: using MemberFunctionType = decltype(MemberFunction); - ClusterEventWrapperEvent(const TCHAR* MethodName) : MethodName{MethodName} - { - } + ClusterEventWrapperEvent(const TCHAR* MethodName) : MethodName{MethodName} {} void Attach(ObjectType* NewObject) { @@ -58,7 +56,7 @@ public: FString EventMethodName; // This reads the value! - MemoryReader << EventMethodName; + MemoryReader << EventMethodName; if (EventMethodName != MethodName) { // This event does not belong to this method. @@ -74,9 +72,7 @@ public: FillArgumentTuple<0>(&MemoryReader, &ArgumentTuple); ArgumentTuple.ApplyBefore([this](const ArgTypes&... Arguments) - { - (Object->*MemberFunction)(Forward<const ArgTypes&>(Arguments)...); - }); + { (Object->*MemberFunction)(Forward<const ArgTypes&>(Arguments)...); }); }); ClusterManager->AddClusterEventBinaryListener(ClusterEventListenerDelegate); } @@ -134,8 +130,9 @@ private: #define DCEW_STRINGIFY(x) #x #define DCEW_TOSTRING(x) DCEW_STRINGIFY(x) -#define DECLARE_DISPLAY_CLUSTER_EVENT(OwningType, MethodIdentifier) \ - ClusterEventWrapperEvent<decltype(&OwningType::MethodIdentifier), &OwningType::MethodIdentifier> MethodIdentifier##Event \ - { \ - TEXT(DCEW_TOSTRING(OwningType) DCEW_TOSTRING(MethodIdentifier)) \ +#define DECLARE_DISPLAY_CLUSTER_EVENT(OwningType, MethodIdentifier) \ + ClusterEventWrapperEvent<decltype(&OwningType::MethodIdentifier), &OwningType::MethodIdentifier> \ + MethodIdentifier##Event \ + { \ + TEXT(DCEW_TOSTRING(OwningType) DCEW_TOSTRING(MethodIdentifier)) \ } diff --git a/Source/RWTHVRToolkit/Private/Core/ClientTransformReplication.cpp b/Source/RWTHVRToolkit/Private/Core/ClientTransformReplication.cpp index 5063c9cf2b4642b2751275094775d8650521ae4e..0bce9302ae30860f0211918a620be91e9666ea21 100644 --- a/Source/RWTHVRToolkit/Private/Core/ClientTransformReplication.cpp +++ b/Source/RWTHVRToolkit/Private/Core/ClientTransformReplication.cpp @@ -39,7 +39,7 @@ void UClientTransformReplication::UpdateState(float DeltaTime) ControllerNetUpdateCount = 0.0f; // The local state has changed and we're within the update rate. Apply the new local state to the - // replicated variable - this just saves the new local state on the local net owner. + // replicated variable - this just saves the new local state on the local net owner. ReplicatedTransform.Position = Loc; ReplicatedTransform.Rotation = Rot; @@ -57,7 +57,7 @@ void UClientTransformReplication::UpdateState(float DeltaTime) } void UClientTransformReplication::TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) + FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); diff --git a/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp b/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp index dfc80f27c13289b3a40dbbd728adeb8ec2314674..4d9b4b6e4dcdb1447e2d9ff98fbfc5400f000589 100644 --- a/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp +++ b/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp @@ -11,7 +11,7 @@ FString ARWTHVRGameModeBase::InitNewPlayer(APlayerController* NewPlayerController, const FUniqueNetIdRepl& UniqueId, - const FString& Options, const FString& Portal) + const FString& Options, const FString& Portal) { // Used by the DisplayClusterNetDriver/Connection to handshake nodes. Could use their types directly // but I don't really want to introduce a hard dependency here. @@ -31,12 +31,11 @@ FString ARWTHVRGameModeBase::InitNewPlayer(APlayerController* NewPlayerControlle // When the primary node is a listen server, it apparently doesn't get the node option... // Could additionally check for listen, but this should be save enough. const FString NodeName = UGameplayStatics::HasOption(Options, NodeNameKey) - ? UGameplayStatics::ParseOption(Options, NodeNameKey) - : PrimaryNodeId; + ? UGameplayStatics::ParseOption(Options, NodeNameKey) + : PrimaryNodeId; - const EPlayerType Type = NodeName == PrimaryNodeId - ? EPlayerType::nDisplayPrimary - : EPlayerType::nDisplaySecondary; + const EPlayerType Type = + NodeName == PrimaryNodeId ? EPlayerType::nDisplayPrimary : EPlayerType::nDisplaySecondary; State->RequestSetPlayerType(Type); } } @@ -52,7 +51,7 @@ void ARWTHVRGameModeBase::PostLogin(APlayerController* NewPlayer) if (NewPlayer->GetPawn() && NewPlayer->GetPawn()->IsValidLowLevelFast()) { UE_LOGFMT(Toolkit, Display, - "ARWTHVRGameModeBase::PostLogin: New player already auto-possessed a pawn, not spawning new one"); + "ARWTHVRGameModeBase::PostLogin: New player already auto-possessed a pawn, not spawning new one"); Super::PostLogin(NewPlayer); return; } diff --git a/Source/RWTHVRToolkit/Private/Fixes/ActivateConsoleInShipping.cpp b/Source/RWTHVRToolkit/Private/Fixes/ActivateConsoleInShipping.cpp index e24d994d25ac8d2db0e3ed89b021f93a7dcfb03f..5c0d0a6c31c6806bdcad11052732b812a119496b 100644 --- a/Source/RWTHVRToolkit/Private/Fixes/ActivateConsoleInShipping.cpp +++ b/Source/RWTHVRToolkit/Private/Fixes/ActivateConsoleInShipping.cpp @@ -4,7 +4,8 @@ void FActivateConsoleInShipping::Register() { /* Should only enable console in shipping */ - if (FApp::GetBuildConfiguration() != EBuildConfiguration::Shipping) return; + if (FApp::GetBuildConfiguration() != EBuildConfiguration::Shipping) + return; On_Post_World_Initialization_Delegate.BindRaw(this, &FActivateConsoleInShipping::OnSessionStart); StartHandle = FWorldDelegates::OnPostWorldInitialization.Add(On_Post_World_Initialization_Delegate); @@ -12,7 +13,8 @@ void FActivateConsoleInShipping::Register() void FActivateConsoleInShipping::Unregister() const { - if (FApp::GetBuildConfiguration() != EBuildConfiguration::Shipping) return; + if (FApp::GetBuildConfiguration() != EBuildConfiguration::Shipping) + return; FWorldDelegates::OnPostWorldInitialization.Remove(StartHandle); } diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/ActionBehaviour.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/ActionBehaviour.cpp index 0b7ff6e65729a8c27204edff42de1369bd74f8b2..4e9c3fd662dd3baa2a30fddd8f516022e4efa9ba 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/ActionBehaviour.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/ActionBehaviour.cpp @@ -4,18 +4,15 @@ #include "Interaction/Interactables/ActionBehaviour.h" // We disable ticking here, as we are mainly interested in the events -UActionBehaviour::UActionBehaviour() -{ - PrimaryComponentTick.bCanEverTick = false; -} +UActionBehaviour::UActionBehaviour() { PrimaryComponentTick.bCanEverTick = false; } void UActionBehaviour::OnActionStart(USceneComponent* TriggeredComponent, const UInputAction* InputAction, - const FInputActionValue& Value) + const FInputActionValue& Value) { } void UActionBehaviour::OnActionEnd(USceneComponent* TriggeredComponent, const UInputAction* InputAction, - const FInputActionValue& Value) + const FInputActionValue& Value) { } @@ -29,7 +26,7 @@ void UActionBehaviour::BeginPlay() // Called every frame void UActionBehaviour::TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) + FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); } diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/GrabBehavior.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/GrabBehavior.cpp index 0acf4d7abd92c4ef4ac0e555c8ce3387b6c6ce43..0ff95d0c6fc823faef1016badc7fb8330beb9679 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/GrabBehavior.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/GrabBehavior.cpp @@ -36,7 +36,7 @@ UPrimitiveComponent* UGrabBehavior::GetHighestParentSimulatingPhysics(UPrimitive } void UGrabBehavior::OnActionStart(USceneComponent* TriggeredComponent, const UInputAction* InputAction, - const FInputActionValue& Value) + const FInputActionValue& Value) { const APawn* Player = UGameplayStatics::GetPlayerPawn(GetWorld(), 0); @@ -69,7 +69,7 @@ void UGrabBehavior::OnActionStart(USceneComponent* TriggeredComponent, const UIn } void UGrabBehavior::OnActionEnd(USceneComponent* TriggeredComponent, const UInputAction* InputAction, - const FInputActionValue& Value) + const FInputActionValue& Value) { if (MyPhysicsComponent) { diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/HoverBehaviour.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/HoverBehaviour.cpp index 22986668f167c91498e6be7da5c2058bfac38856..96897613cd2f536cb9625a9b395ce49181656e70 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/HoverBehaviour.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/HoverBehaviour.cpp @@ -3,13 +3,9 @@ #include "Interaction/Interactables/HoverBehaviour.h" -void UHoverBehaviour::OnHoverStart(const USceneComponent* TriggeredComponent, FHitResult Hit) -{ -} +void UHoverBehaviour::OnHoverStart(const USceneComponent* TriggeredComponent, FHitResult Hit) {} -void UHoverBehaviour::OnHoverEnd(const USceneComponent* TriggeredComponent) -{ -} +void UHoverBehaviour::OnHoverEnd(const USceneComponent* TriggeredComponent) {} void UHoverBehaviour::BeginPlay() { diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/InteractableComponent.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/InteractableComponent.cpp index d354afa8768f1973d740239eaa223e3bc8c5ab88..29ee75b08e1d37147671228e167c09e4cde462f8 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/InteractableComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/InteractableComponent.cpp @@ -41,15 +41,17 @@ void UInteractableComponent::BeginPlay() // This functions dispatches the HoverStart Event to the attached Hover Behaviour Components void UInteractableComponent::HandleOnHoverStartEvents(USceneComponent* TriggerComponent, - const EInteractorType Interactor) + const EInteractorType Interactor) { // We early return if there the InteractorFilter is set and the Interactor is allowed. - if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) return; + if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) + return; // We early return if the source Interactor is not part of the allowed components - if (!IsComponentAllowed(TriggerComponent)) return; + if (!IsComponentAllowed(TriggerComponent)) + return; - //Broadcast event to all HoverBehaviours + // Broadcast event to all HoverBehaviours for (const UHoverBehaviour* b : OnHoverBehaviours) { b->OnHoverStartEvent.Broadcast(TriggerComponent, HitResult); @@ -60,12 +62,14 @@ void UInteractableComponent::HandleOnHoverStartEvents(USceneComponent* TriggerCo void UInteractableComponent::HandleOnHoverEndEvents(USceneComponent* TriggerComponent, const EInteractorType Interactor) { // We early return if there the InteractorFilter is set and the Interactor is allowed. - if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) return; + if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) + return; // We early return if the source Interactor is not part of the allowed components - if (!IsComponentAllowed(TriggerComponent)) return; + if (!IsComponentAllowed(TriggerComponent)) + return; - //Broadcast event to all HoverBehaviours + // Broadcast event to all HoverBehaviours for (const UHoverBehaviour* b : OnHoverBehaviours) { b->OnHoverEndEvent.Broadcast(TriggerComponent); @@ -74,17 +78,18 @@ void UInteractableComponent::HandleOnHoverEndEvents(USceneComponent* TriggerComp // This functions dispatches the ActionStart Event to the attached Action Behaviour Components void UInteractableComponent::HandleOnActionStartEvents(USceneComponent* TriggerComponent, - const UInputAction* InputAction, - const FInputActionValue& Value, - const EInteractorType Interactor) + const UInputAction* InputAction, const FInputActionValue& Value, + const EInteractorType Interactor) { // We early return if there the InteractorFilter is set and the Interactor is allowed. - if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) return; + if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) + return; // We early return if the source Interactor is not part of the allowed components - if (!IsComponentAllowed(TriggerComponent)) return; + if (!IsComponentAllowed(TriggerComponent)) + return; - //Broadcast event to all ActionBehaviours + // Broadcast event to all ActionBehaviours for (const UActionBehaviour* b : OnActionBehaviours) { b->OnActionBeginEvent.Broadcast(TriggerComponent, InputAction, Value); @@ -93,16 +98,17 @@ void UInteractableComponent::HandleOnActionStartEvents(USceneComponent* TriggerC // This functions dispatches the ActionEnd Event to the attached Action Behaviour Components void UInteractableComponent::HandleOnActionEndEvents(USceneComponent* TriggerComponent, const UInputAction* InputAction, - const FInputActionValue& Value, - const EInteractorType Interactor) + const FInputActionValue& Value, const EInteractorType Interactor) { // We early return if there the InteractorFilter is set and the Interactor is allowed. - if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) return; + if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) + return; // We early return if the source Interactor is not part of the allowed components - if (!IsComponentAllowed(TriggerComponent)) return; + if (!IsComponentAllowed(TriggerComponent)) + return; - //Broadcast event to all ActionBehaviours + // Broadcast event to all ActionBehaviours for (const UActionBehaviour* b : OnActionBehaviours) { b->OnActionEndEvent.Broadcast(TriggerComponent, InputAction, Value); @@ -116,7 +122,7 @@ void UInteractableComponent::InitDefaultBehaviourReferences() // only do this if empty, otherwise the user has explicitly stated, which behaviors to include if (OnHoverBehaviours.IsEmpty()) { - //Selecting + // Selecting TInlineComponentArray<UHoverBehaviour*> AttachedHoverBehaviours; GetOwner()->GetComponents(AttachedHoverBehaviours, true); @@ -126,7 +132,7 @@ void UInteractableComponent::InitDefaultBehaviourReferences() // only do this if empty, otherwise the user has explicitly stated, which behaviors to include if (OnActionBehaviours.IsEmpty()) { - //Clicking + // Clicking TInlineComponentArray<UActionBehaviour*> AttachedClickBehaviours; GetOwner()->GetComponents(AttachedClickBehaviours, true); diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactors/GrabComponent.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactors/GrabComponent.cpp index 32df40be5c43d29f66c99351bd0c28165ec48c48..fcc3abae942e3baa4d1fd01f453dabb6cf9d3b81 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactors/GrabComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactors/GrabComponent.cpp @@ -13,8 +13,8 @@ // Sets default values for this component's properties UGrabComponent::UGrabComponent() { - // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features - // off to improve performance if you don't need them. + // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these + // features off to improve performance if you don't need them. PrimaryComponentTick.bCanEverTick = true; // ... @@ -34,9 +34,8 @@ void UGrabComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorC auto DebugTrace = bShowDebugTrace ? EDrawDebugTrace::ForOneFrame : EDrawDebugTrace::None; UKismetSystemLibrary::SphereTraceMulti(GetWorld(), GetAttachParent()->GetComponentLocation(), - GetAttachParent()->GetComponentLocation(), GrabSphereRadius, TraceType, true, - ActorsToIgnore, DebugTrace, - OutHits, true, FColor::Green); + GetAttachParent()->GetComponentLocation(), GrabSphereRadius, TraceType, true, + ActorsToIgnore, DebugTrace, OutHits, true, FColor::Green); for (FHitResult Hit : OutHits) { @@ -94,7 +93,7 @@ void UGrabComponent::SetupPlayerInput(UInputComponent* PlayerInputComponent) if (!InputSubsystem) return; - // add Input Mapping context + // add Input Mapping context InputSubsystem->AddMappingContext(IMCGrab, 0); UEnhancedInputComponent* EI = Cast<UEnhancedInputComponent>(Pawn->InputComponent); diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactors/RaycastSelectionComponent.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactors/RaycastSelectionComponent.cpp index be22429936c5b2aeea654f8b05c3c302f2950bee..dc88e0375bf44a01c62aa2c91de71e9f18643bca 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactors/RaycastSelectionComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactors/RaycastSelectionComponent.cpp @@ -11,8 +11,8 @@ // Sets default values for this component's properties URaycastSelectionComponent::URaycastSelectionComponent() { - // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features - // off to improve performance if you don't need them. + // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these + // features off to improve performance if you don't need them. PrimaryComponentTick.bCanEverTick = true; // ... @@ -20,7 +20,7 @@ URaycastSelectionComponent::URaycastSelectionComponent() // Called every frame void URaycastSelectionComponent::TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) + FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); @@ -35,9 +35,8 @@ void URaycastSelectionComponent::TickComponent(float DeltaTime, ELevelTick TickT auto DebugTrace = bShowDebugTrace ? EDrawDebugTrace::ForOneFrame : EDrawDebugTrace::None; - UKismetSystemLibrary::LineTraceSingle(GetWorld(), TraceStart, TraceEnd - , TraceType, true, ActorsToIgnore, DebugTrace, - Hit, true, FColor::Green); + UKismetSystemLibrary::LineTraceSingle(GetWorld(), TraceStart, TraceEnd, TraceType, true, ActorsToIgnore, DebugTrace, + Hit, true, FColor::Green); AActor* HitActor = Hit.GetActor(); if (HitActor) @@ -66,15 +65,13 @@ void URaycastSelectionComponent::TickComponent(float DeltaTime, ELevelTick TickT void URaycastSelectionComponent::OnBeginSelect(const FInputActionValue& Value) { if (CurrentInteractable && CurrentInteractable->HasInteractionTypeFlag(EInteractorType::Raycast)) - CurrentInteractable->HandleOnActionStartEvents(this, RayCastSelectInputAction, Value, - EInteractorType::Raycast); + CurrentInteractable->HandleOnActionStartEvents(this, RayCastSelectInputAction, Value, EInteractorType::Raycast); } void URaycastSelectionComponent::OnEndSelect(const FInputActionValue& Value) { if (CurrentInteractable && CurrentInteractable->HasInteractionTypeFlag(EInteractorType::Raycast)) - CurrentInteractable->HandleOnActionEndEvents(this, RayCastSelectInputAction, Value, - EInteractorType::Raycast); + CurrentInteractable->HandleOnActionEndEvents(this, RayCastSelectInputAction, Value, EInteractorType::Raycast); } void URaycastSelectionComponent::SetupPlayerInput(UInputComponent* PlayerInputComponent) @@ -89,7 +86,7 @@ void URaycastSelectionComponent::SetupPlayerInput(UInputComponent* PlayerInputCo if (!InputSubsystem) return; - // add Input Mapping context + // add Input Mapping context InputSubsystem->AddMappingContext(IMCRaycastSelection, 0); UEnhancedInputComponent* EI = Cast<UEnhancedInputComponent>(Pawn->InputComponent); diff --git a/Source/RWTHVRToolkit/Private/Pawn/InputExtensionInterface.cpp b/Source/RWTHVRToolkit/Private/Pawn/InputExtensionInterface.cpp index 9d0fc069ab4be6f1478f57ff67f665aff2db7f6e..ddee08706d0f68ad5a5ce1bd4c632642b3bc971f 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/InputExtensionInterface.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/InputExtensionInterface.cpp @@ -3,10 +3,11 @@ #include "Pawn/InputExtensionInterface.h" -UEnhancedInputLocalPlayerSubsystem* IInputExtensionInterface::GetEnhancedInputLocalPlayerSubsystem(const APawn* Pawn) const +UEnhancedInputLocalPlayerSubsystem* +IInputExtensionInterface::GetEnhancedInputLocalPlayerSubsystem(const APawn* Pawn) const { const APlayerController* PlayerController = Pawn ? Cast<APlayerController>(Pawn->GetController()) : nullptr; const ULocalPlayer* LP = PlayerController ? PlayerController->GetLocalPlayer() : nullptr; - - return LP->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(); + + return LP->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(); } diff --git a/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp b/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp index 2d273b753dbff1f7df0a88af5c31286d8c71cdb6..f644f4add3b96e08f66f28a873e57fba8a504dbd 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/Navigation/CollisionHandlingMovement.cpp @@ -2,7 +2,8 @@ #include "Kismet/KismetSystemLibrary.h" -UCollisionHandlingMovement::UCollisionHandlingMovement(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) +UCollisionHandlingMovement::UCollisionHandlingMovement(const FObjectInitializer& ObjectInitializer) : + Super(ObjectInitializer) { // the capsule is used to store the players size and position, e.g., for other interactions and as starting point // for the capsule trace (which however not use the capsule component directly) @@ -10,10 +11,10 @@ UCollisionHandlingMovement::UCollisionHandlingMovement(const FObjectInitializer& CapsuleColliderComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); CapsuleColliderComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap); CapsuleColliderComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, - ECollisionResponse::ECR_Block); + ECollisionResponse::ECR_Block); CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, 80.0f); - //set some defaults for the UFloatingPawnMovement component, which are more reasonable for usage in VR + // set some defaults for the UFloatingPawnMovement component, which are more reasonable for usage in VR MaxSpeed = 300.f; Acceleration = 800.f; Deceleration = 2000.f; @@ -30,7 +31,7 @@ void UCollisionHandlingMovement::BeginPlay() void UCollisionHandlingMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) + FActorComponentTickFunction* ThisTickFunction) { SetCapsuleColliderToUserSize(); @@ -49,9 +50,9 @@ void UCollisionHandlingMovement::TickComponent(float DeltaTime, enum ELevelTick if (NavigationMode == EVRNavigationModes::NAV_FLY || NavigationMode == EVRNavigationModes::NAV_WALK) { - //if me managed to get into a collision revert the movement since last Tick + // if me managed to get into a collision revert the movement since last Tick CheckAndRevertCollisionSinceLastTick(); - //check whether we are still in collision e.g. if an object has moved and got us into collision + // check whether we are still in collision e.g. if an object has moved and got us into collision MoveOutOfNewDynamicCollisions(); if (InputVector.Size() > 0.001) @@ -71,13 +72,13 @@ void UCollisionHandlingMovement::TickComponent(float DeltaTime, enum ELevelTick // and gravity for walking only MoveByGravityOrStepUp(DeltaTime); - //if we physically (in the tracking space) walked into something, move the world away (by moving the pawn) + // if we physically (in the tracking space) walked into something, move the world away (by moving the pawn) CheckForPhysWalkingCollision(); } if (NavigationMode == EVRNavigationModes::NAV_NONE) { - //just remove whatever input is there + // just remove whatever input is there ConsumeInputVector(); } @@ -88,7 +89,7 @@ void UCollisionHandlingMovement::SetHeadComponent(USceneComponent* NewHeadCompon { HeadComponent = NewHeadComponent; CapsuleColliderComponent->SetupAttachment(HeadComponent); - const float HalfHeight = 80.0f; //this is just an initial value to look good in editor + const float HalfHeight = 80.0f; // this is just an initial value to look good in editor CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, HalfHeight); CapsuleColliderComponent->SetWorldLocation(FVector(0.0f, 0.0f, -HalfHeight)); } @@ -120,7 +121,7 @@ void UCollisionHandlingMovement::SetCapsuleColliderToUserSize() const const float ColliderHalfHeight = ColliderHeight / 2.0f; if (ColliderHalfHeight <= CapsuleRadius) { - //the capsule will actually be compressed to a sphere + // the capsule will actually be compressed to a sphere CapsuleColliderComponent->SetCapsuleSize(ColliderHalfHeight, ColliderHalfHeight); } else @@ -128,8 +129,8 @@ void UCollisionHandlingMovement::SetCapsuleColliderToUserSize() const CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, ColliderHalfHeight); } - CapsuleColliderComponent->SetWorldLocation( - HeadComponent->GetComponentLocation() - FVector(0, 0, ColliderHalfHeight)); + CapsuleColliderComponent->SetWorldLocation(HeadComponent->GetComponentLocation() - + FVector(0, 0, ColliderHalfHeight)); } else { @@ -145,7 +146,7 @@ void UCollisionHandlingMovement::CheckAndRevertCollisionSinceLastTick() if (!LastCollisionFreeCapsulePosition.IsSet()) { - //we cannot revert anyways so only check if the current position is collision free + // we cannot revert anyways so only check if the current position is collision free if (!CreateCapsuleTrace(CapsuleLocation, CapsuleLocation).bBlockingHit) { LastCollisionFreeCapsulePosition = CapsuleLocation; @@ -153,10 +154,10 @@ void UCollisionHandlingMovement::CheckAndRevertCollisionSinceLastTick() return; } - //check whether we are in a collision at the current position + // check whether we are in a collision at the current position if (CreateCapsuleTrace(CapsuleLocation, CapsuleLocation).bBlockingHit) { - //if so move back to last position + // if so move back to last position UpdatedComponent->AddWorldOffset(LastCollisionFreeCapsulePosition.GetValue() - CapsuleLocation); } else @@ -171,10 +172,10 @@ void UCollisionHandlingMovement::MoveOutOfNewDynamicCollisions() if (ResolveDirectionOptional.IsSet()) { - FVector ResolveDirection = 1.5f * ResolveDirectionOptional.GetValue(); //scale it up for security distance + FVector ResolveDirection = 1.5f * ResolveDirectionOptional.GetValue(); // scale it up for security distance UpdatedComponent->AddWorldOffset(ResolveDirection); - //invalidate the last collision-free position, since apparently something changed so we got into this collision + // invalidate the last collision-free position, since apparently something changed so we got into this collision LastCollisionFreeCapsulePosition.Reset(); } } @@ -183,18 +184,18 @@ void UCollisionHandlingMovement::CheckForPhysWalkingCollision() { if (!LastCollisionFreeCapsulePosition.IsSet()) { - //we don't know any old collision-free location, so do nothing here + // we don't know any old collision-free location, so do nothing here return; } const FVector CapsuleLocation = CapsuleColliderComponent->GetComponentLocation(); const FHitResult HitResult = CreateCapsuleTrace(LastCollisionFreeCapsulePosition.GetValue(), CapsuleLocation); - //if this was not possible move the entire pawn away to avoid the head collision + // if this was not possible move the entire pawn away to avoid the head collision if (HitResult.bBlockingHit) { const FVector MoveOutVector = HitResult.Location - CapsuleLocation; - //move it out twice as far, to avoid getting stuck situations + // move it out twice as far, to avoid getting stuck situations UpdatedComponent->AddWorldOffset(2 * MoveOutVector); } } @@ -209,23 +210,23 @@ FVector UCollisionHandlingMovement::GetCollisionSafeVirtualSteeringVec(FVector I } - const float SafetyFactor = 3.0f; //so we detect collision a bit earlier + const float SafetyFactor = 3.0f; // so we detect collision a bit earlier const FVector CapsuleLocation = CapsuleColliderComponent->GetComponentLocation(); FVector ProbePosition = SafetyFactor * InputVector.GetSafeNormal() * GetMaxSpeed() * DeltaTime + CapsuleLocation; const FHitResult TraceResult = CreateCapsuleTrace(CapsuleLocation, ProbePosition); if (!TraceResult.bBlockingHit) { - //everything is fine, use that vector + // everything is fine, use that vector return InputVector; } - //otherwise remove the component of that vector that goes towards the collision + // otherwise remove the component of that vector that goes towards the collision FVector CollisionVector = TraceResult.Location - CapsuleLocation; - //sometimes (if by chance we already moved into collision entirely CollisionVector is 0 + // sometimes (if by chance we already moved into collision entirely CollisionVector is 0 if (!CollisionVector.Normalize()) { - //then we probably start already in collision, so we use the last one + // then we probably start already in collision, so we use the last one CollisionVector = LastSteeringCollisionVector; } else @@ -256,10 +257,10 @@ void UCollisionHandlingMovement::MoveByGravityOrStepUp(float DeltaSeconds) if (DownTraceHitResult.bBlockingHit) { HeightDifference = DownTraceHitResult.ImpactPoint.Z - UpdatedComponent->GetComponentLocation().Z; - //so for HeightDifference>0, we have to move the pawn up; for HeightDifference<0 we have to move it down + // so for HeightDifference>0, we have to move the pawn up; for HeightDifference<0 we have to move it down } - //Going up (in Fly and Walk Mode) + // Going up (in Fly and Walk Mode) if (HeightDifference > 0.0f && HeightDifference <= MaxStepHeight) { ShiftVertically(HeightDifference, UpSteppingAcceleration, DeltaSeconds); @@ -272,10 +273,10 @@ void UCollisionHandlingMovement::MoveByGravityOrStepUp(float DeltaSeconds) if (!DownTraceHitResult.bBlockingHit && MaxFallingDepth < 0.0f) { - HeightDifference = -1000.0f; //just fall + HeightDifference = -1000.0f; // just fall } - //Gravity (only in Walk Mode) + // Gravity (only in Walk Mode) if (HeightDifference < 0.0f) { ShiftVertically(HeightDifference, GravityAcceleration, DeltaSeconds); @@ -296,17 +297,18 @@ void UCollisionHandlingMovement::ShiftVertically(float Distance, float VerticalA } } -FHitResult UCollisionHandlingMovement::CreateCapsuleTrace(const FVector& Start, const FVector& End, const bool DrawDebug) const +FHitResult UCollisionHandlingMovement::CreateCapsuleTrace(const FVector& Start, const FVector& End, + const bool DrawDebug) const { const EDrawDebugTrace::Type DrawType = DrawDebug ? EDrawDebugTrace::Type::ForDuration : EDrawDebugTrace::Type::None; - //UE_LOG(LogTemp, Warning, TEXT("Capsule from %s to %s"), *Start.ToString(), *End.ToString()) + // UE_LOG(LogTemp, Warning, TEXT("Capsule from %s to %s"), *Start.ToString(), *End.ToString()) FHitResult Hit; UKismetSystemLibrary::CapsuleTraceSingle(GetWorld(), Start, End, CapsuleColliderComponent->GetScaledCapsuleRadius(), - CapsuleColliderComponent->GetScaledCapsuleHalfHeight(), - UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Visibility), true, - ActorsToIgnore, DrawType, Hit, true); + CapsuleColliderComponent->GetScaledCapsuleHalfHeight(), + UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Visibility), true, + ActorsToIgnore, DrawType, Hit, true); return Hit; } @@ -316,9 +318,9 @@ TOptional<FVector> UCollisionHandlingMovement::GetOverlapResolveDirection() cons TArray<TEnumAsByte<EObjectTypeQuery>> traceObjectTypes; traceObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Visibility)); UKismetSystemLibrary::CapsuleOverlapComponents(GetWorld(), CapsuleColliderComponent->GetComponentLocation(), - CapsuleColliderComponent->GetScaledCapsuleRadius(), - CapsuleColliderComponent->GetScaledCapsuleHalfHeight(), - traceObjectTypes, nullptr, ActorsToIgnore, OverlappingComponents); + CapsuleColliderComponent->GetScaledCapsuleRadius(), + CapsuleColliderComponent->GetScaledCapsuleHalfHeight(), + traceObjectTypes, nullptr, ActorsToIgnore, OverlappingComponents); if (OverlappingComponents.Num() == 0) { @@ -327,12 +329,13 @@ TOptional<FVector> UCollisionHandlingMovement::GetOverlapResolveDirection() cons } FVector ResolveVector = FVector::ZeroVector; - //check what to do to move out of these collisions (or nothing if none is there) - //we just add the penetrations so in very unfortunate conditions this can become problematic/blocking but for now and our regular use cases this works + // check what to do to move out of these collisions (or nothing if none is there) + // we just add the penetrations so in very unfortunate conditions this can become problematic/blocking but for now + // and our regular use cases this works for (const UPrimitiveComponent* OverlappingComp : OverlappingComponents) { FHitResult Hit = CreateCapsuleTrace(CapsuleColliderComponent->GetComponentLocation(), - OverlappingComp->GetComponentLocation(), false); + OverlappingComp->GetComponentLocation(), false); ResolveVector += Hit.ImpactNormal * Hit.PenetrationDepth; } return ResolveVector; diff --git a/Source/RWTHVRToolkit/Private/Pawn/Navigation/ContinuousMovementComponent.cpp b/Source/RWTHVRToolkit/Private/Pawn/Navigation/ContinuousMovementComponent.cpp index 19b461a2b8a55978141906fb98ac98a645410a94..9954fc63fe80c2c19602fdd77ee2c52e1bffd848 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/Navigation/ContinuousMovementComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/Navigation/ContinuousMovementComponent.cpp @@ -32,7 +32,7 @@ void UContinuousMovementComponent::SetupPlayerInput(UInputComponent* PlayerInput IMCMovement = IMCMovementLeft; } - // add Input Mapping context + // add Input Mapping context InputSubsystem->AddMappingContext(IMCMovement, 0); UEnhancedInputComponent* EI = Cast<UEnhancedInputComponent>(PlayerInputComponent); @@ -54,15 +54,13 @@ void UContinuousMovementComponent::OnMove(const FInputActionValue& Value) if (!VRPawn || !VRPawn->Controller) return; - const bool bGazeDirected = URWTHVRUtilities::IsDesktopMode() || SteeringMode == - EVRSteeringModes::STEER_GAZE_DIRECTED; + const bool bGazeDirected = + URWTHVRUtilities::IsDesktopMode() || SteeringMode == EVRSteeringModes::STEER_GAZE_DIRECTED; - const FVector ForwardDir = bGazeDirected - ? VRPawn->HeadCameraComponent->GetForwardVector() - : MovementHand->GetForwardVector(); - const FVector RightDir = bGazeDirected - ? VRPawn->HeadCameraComponent->GetRightVector() - : MovementHand->GetRightVector(); + const FVector ForwardDir = + bGazeDirected ? VRPawn->HeadCameraComponent->GetForwardVector() : MovementHand->GetForwardVector(); + const FVector RightDir = + bGazeDirected ? VRPawn->HeadCameraComponent->GetRightVector() : MovementHand->GetRightVector(); const FVector2D MoveValue = Value.Get<FVector2D>(); @@ -85,6 +83,6 @@ void UContinuousMovementComponent::OnMoveUp(const FInputActionValue& Value) return; const float MoveValue = Value.Get<FVector2D>().X; - //the right hand is rotated on desktop to follow the cursor so it's forward is also changing with cursor position + // the right hand is rotated on desktop to follow the cursor so it's forward is also changing with cursor position VRPawn->AddMovementInput(FVector::UpVector, MoveValue); } diff --git a/Source/RWTHVRToolkit/Private/Pawn/Navigation/TeleportationComponent.cpp b/Source/RWTHVRToolkit/Private/Pawn/Navigation/TeleportationComponent.cpp index 29b3fda86929d0106488a9eca83965b246095d35..3e1e14b8f4ab4bf57ad956550afa9059ff93162a 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/Navigation/TeleportationComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/Navigation/TeleportationComponent.cpp @@ -24,18 +24,9 @@ void UTeleportationComponent::SetupPlayerInput(UInputComponent* PlayerInputCompo return; } - TeleportTraceComponent = UNiagaraFunctionLibrary::SpawnSystemAtLocation - ( - GetWorld(), - TeleportTraceSystem, - VRPawn->GetActorLocation(), - FRotator(0), - FVector(1), - true, - true, - ENCPoolMethod::AutoRelease, - true - ); + TeleportTraceComponent = UNiagaraFunctionLibrary::SpawnSystemAtLocation( + GetWorld(), TeleportTraceSystem, VRPawn->GetActorLocation(), FRotator(0), FVector(1), true, true, + ENCPoolMethod::AutoRelease, true); FActorSpawnParameters SpawnParameters = FActorSpawnParameters(); SpawnParameters.Name = "TeleportVisualizer"; @@ -43,7 +34,7 @@ void UTeleportationComponent::SetupPlayerInput(UInputComponent* PlayerInputCompo if (BPTeleportVisualizer) { TeleportVisualizer = GetWorld()->SpawnActor<AActor>(BPTeleportVisualizer, VRPawn->GetActorLocation(), - VRPawn->GetActorRotation(), SpawnParameters); + VRPawn->GetActorRotation(), SpawnParameters); } TeleportTraceComponent->SetVisibility(false); TeleportVisualizer->SetActorHiddenInGame(true); @@ -62,7 +53,7 @@ void UTeleportationComponent::SetupPlayerInput(UInputComponent* PlayerInputCompo IMCMovement = IMCTeleportLeft; } - // add Input Mapping context + // add Input Mapping context InputSubsystem->AddMappingContext(IMCMovement, 0); UEnhancedInputComponent* EI = Cast<UEnhancedInputComponent>(PlayerInputComponent); @@ -99,14 +90,8 @@ void UTeleportationComponent::UpdateTeleportTrace(const FInputActionValue& Value TArray<AActor> ActorsToIgnore; - FPredictProjectilePathParams PredictParams = FPredictProjectilePathParams - ( - TeleportProjectileRadius, - StartPosition, - TeleportLaunchSpeed * ForwardVector, - 5.0, - ECC_WorldStatic - ); + FPredictProjectilePathParams PredictParams = FPredictProjectilePathParams( + TeleportProjectileRadius, StartPosition, TeleportLaunchSpeed * ForwardVector, 5.0, ECC_WorldStatic); PredictParams.ActorsToIgnore.Add(VRPawn); PredictParams.ActorsToIgnore.Add(TeleportVisualizer); @@ -147,7 +132,7 @@ void UTeleportationComponent::UpdateTeleportTrace(const FInputActionValue& Value PathPoints.Add(PData.Location); } UNiagaraDataInterfaceArrayFunctionLibrary::SetNiagaraArrayVector(TeleportTraceComponent, FName("User.PointArray"), - PathPoints); + PathPoints); } bool UTeleportationComponent::IsValidTeleportLocation(const FHitResult& Hit, FVector& ProjectedLocation) const @@ -155,8 +140,9 @@ bool UTeleportationComponent::IsValidTeleportLocation(const FHitResult& Hit, FVe UNavigationSystemV1* NavSys = FNavigationSystem::GetCurrent<UNavigationSystemV1>(GetWorld()); const FNavAgentProperties& AgentProps = FNavAgentProperties(15, 160); FNavLocation ProjectedNavLocation; - const bool bProjectPoint = (NavSys && NavSys->ProjectPointToNavigation( - Hit.Location, ProjectedNavLocation, INVALID_NAVEXTENT, &AgentProps)); + const bool bProjectPoint = + (NavSys && + NavSys->ProjectPointToNavigation(Hit.Location, ProjectedNavLocation, INVALID_NAVEXTENT, &AgentProps)); ProjectedLocation = ProjectedNavLocation.Location; return bProjectPoint /*&& Hit.IsValidBlockingHit()*/; } diff --git a/Source/RWTHVRToolkit/Private/Pawn/Navigation/TurnComponent.cpp b/Source/RWTHVRToolkit/Private/Pawn/Navigation/TurnComponent.cpp index 44735faf76e3acf9a44214d8a7ff0e6e47ab2e14..31e57513a8de14a7f2aab645ef6ec69a497d0bf4 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/Navigation/TurnComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/Navigation/TurnComponent.cpp @@ -67,15 +67,9 @@ void UTurnComponent::SetupPlayerInput(UInputComponent* PlayerInputComponent) } // A separate button has to be pressed, for when mouse movement should contribute to turning -void UTurnComponent::StartDesktopRotation() -{ - bApplyDesktopRotation = true; -} +void UTurnComponent::StartDesktopRotation() { bApplyDesktopRotation = true; } -void UTurnComponent::EndDesktopRotation() -{ - bApplyDesktopRotation = false; -} +void UTurnComponent::EndDesktopRotation() { bApplyDesktopRotation = false; } void UTurnComponent::OnBeginTurn(const FInputActionValue& Value) { diff --git a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp index 546d1bcfe32e78c4aab50ff4b161175c83b094af..ee080a8799635fa3d0ad53d3af18c4f396988096 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp @@ -15,8 +15,7 @@ #include "Roles/LiveLinkTransformTypes.h" #include "Utility/RWTHVRUtilities.h" -ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) +ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer) { BaseEyeHeight = 160.0f; @@ -25,7 +24,7 @@ ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) HeadCameraComponent = CreateDefaultSubobject<UReplicatedCameraComponent>(TEXT("Camera")); HeadCameraComponent->SetupAttachment(RootComponent); HeadCameraComponent->SetRelativeLocation(FVector(0.0f, 0.0f, BaseEyeHeight)); - //so it is rendered correctly in editor + // so it is rendered correctly in editor PawnMovement = CreateDefaultSubobject<UCollisionHandlingMovement>(TEXT("Pawn Movement")); PawnMovement->SetUpdatedComponent(RootComponent); @@ -64,8 +63,8 @@ void ARWTHVRPawn::NotifyControllerChanged() if (IsLocallyControlled()) { // Only do this for the primary node or when we're running in standalone - if (URWTHVRUtilities::IsRoomMountedMode() && (URWTHVRUtilities::IsPrimaryNode() || - GetNetMode() == NM_Standalone)) + if (URWTHVRUtilities::IsRoomMountedMode() && + (URWTHVRUtilities::IsPrimaryNode() || GetNetMode() == NM_Standalone)) { // If we are also the authority (standalone or listen server), directly attach it to us. // If we are not (client), ask the server to do it. @@ -88,10 +87,10 @@ void ARWTHVRPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponen return; } - // Set the control rotation of the PC to zero again. There is a small period of 2 frames where, when the pawn gets possessed, - // the PC takes on the rotation of the VR Headset ONLY WHEN SPAWNING ON A CLIENT. Reset the rotation here such that - // bUseControllerRotationYaw=true does not pass the wrong yaw value to the pawn initially. - // There is probably a checkbox or way of spawning that prevents that in a better way that this, change if found. + // Set the control rotation of the PC to zero again. There is a small period of 2 frames where, when the pawn gets + // possessed, the PC takes on the rotation of the VR Headset ONLY WHEN SPAWNING ON A CLIENT. Reset the rotation here + // such that bUseControllerRotationYaw=true does not pass the wrong yaw value to the pawn initially. There is + // probably a checkbox or way of spawning that prevents that in a better way that this, change if found. PlayerController->SetControlRotation(FRotator::ZeroRotator); SetupMotionControllerSources(); @@ -137,16 +136,17 @@ void ARWTHVRPawn::EvaluateLivelink() const } // Get the LiveLink interface and evaluate the current existing frame data for the given Subject and Role. - ILiveLinkClient& LiveLinkClient = IModularFeatures::Get().GetModularFeature<ILiveLinkClient>( - ILiveLinkClient::ModularFeatureName); + ILiveLinkClient& LiveLinkClient = + IModularFeatures::Get().GetModularFeature<ILiveLinkClient>(ILiveLinkClient::ModularFeatureName); FLiveLinkSubjectFrameData SubjectData; - const bool bHasValidData = LiveLinkClient.EvaluateFrame_AnyThread( - HeadSubjectRepresentation.Subject, HeadSubjectRepresentation.Role, SubjectData); + const bool bHasValidData = LiveLinkClient.EvaluateFrame_AnyThread(HeadSubjectRepresentation.Subject, + HeadSubjectRepresentation.Role, SubjectData); if (!bHasValidData) return; - // Assume we are using a Transform Role to track the components! This is a slightly dangerous assumption, and could be further improved. + // Assume we are using a Transform Role to track the components! This is a slightly dangerous assumption, and + // could be further improved. const FLiveLinkTransformStaticData* StaticData = SubjectData.StaticData.Cast<FLiveLinkTransformStaticData>(); const FLiveLinkTransformFrameData* FrameData = SubjectData.FrameData.Cast<FLiveLinkTransformFrameData>(); @@ -204,7 +204,7 @@ void ARWTHVRPawn::AttachDCRAtoPawn() else { UE_LOGFMT(Toolkit, Warning, - "No CaveSetup Actor found which can be attached to the Pawn! This won't work on the Cave."); + "No CaveSetup Actor found which can be attached to the Pawn! This won't work on the Cave."); } } @@ -246,19 +246,19 @@ void ARWTHVRPawn::SetCameraOffset() const } void ARWTHVRPawn::ApplyLiveLinkTransform(const FTransform& Transform, - const FLiveLinkTransformStaticData& StaticData) const + const FLiveLinkTransformStaticData& StaticData) const { if (StaticData.bIsLocationSupported) { if (bWorldTransform) { HeadCameraComponent->SetWorldLocation(Transform.GetLocation(), false, nullptr, - ETeleportType::TeleportPhysics); + ETeleportType::TeleportPhysics); } else { HeadCameraComponent->SetRelativeLocation(Transform.GetLocation(), false, nullptr, - ETeleportType::TeleportPhysics); + ETeleportType::TeleportPhysics); } } @@ -267,12 +267,12 @@ void ARWTHVRPawn::ApplyLiveLinkTransform(const FTransform& Transform, if (bWorldTransform) { HeadCameraComponent->SetWorldRotation(Transform.GetRotation(), false, nullptr, - ETeleportType::TeleportPhysics); + ETeleportType::TeleportPhysics); } else { HeadCameraComponent->SetRelativeRotation(Transform.GetRotation(), false, nullptr, - ETeleportType::TeleportPhysics); + ETeleportType::TeleportPhysics); } } diff --git a/Source/RWTHVRToolkit/Private/Pawn/ReplicatedMotionControllerComponent.cpp b/Source/RWTHVRToolkit/Private/Pawn/ReplicatedMotionControllerComponent.cpp index 7de46b1f7e230e3d8135602e752aec351c676ebf..086457f502ea0bee1c5fac994ac92f2f5e85598a 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/ReplicatedMotionControllerComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/ReplicatedMotionControllerComponent.cpp @@ -46,7 +46,7 @@ void UReplicatedMotionControllerComponent::UpdateState(float DeltaTime) } void UReplicatedMotionControllerComponent::TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) + FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); UpdateState(DeltaTime); @@ -57,7 +57,8 @@ void UReplicatedMotionControllerComponent::GetLifetimeReplicatedProps( { Super::GetLifetimeReplicatedProps(OutLifetimeProps); - // Disable the basic built in replication of relative transform data, as we are using our own transform sync/state update + // Disable the basic built in replication of relative transform data, as we are using our own transform sync/state + // update DISABLE_REPLICATED_PRIVATE_PROPERTY(USceneComponent, RelativeLocation); DISABLE_REPLICATED_PRIVATE_PROPERTY(USceneComponent, RelativeRotation); DISABLE_REPLICATED_PRIVATE_PROPERTY(USceneComponent, RelativeScale3D); diff --git a/Source/RWTHVRToolkit/Private/RWTHVRToolkit.cpp b/Source/RWTHVRToolkit/Private/RWTHVRToolkit.cpp index 6e2fa82b1da92fe488f05da6c86441fe03607b66..31f42c2b8498fd8dba6cf44598375648e7ae4622 100644 --- a/Source/RWTHVRToolkit/Private/RWTHVRToolkit.cpp +++ b/Source/RWTHVRToolkit/Private/RWTHVRToolkit.cpp @@ -7,9 +7,8 @@ void FRWTHVRToolkitModule::StartupModule() IModularFeatures& ModularFeatures = IModularFeatures::Get(); if (ModularFeatures.IsModularFeatureAvailable(ILiveLinkClient::ModularFeatureName)) { - FLiveLinkClient* LiveLinkClient = static_cast<FLiveLinkClient*>(&IModularFeatures::Get().GetModularFeature< - ILiveLinkClient>( - ILiveLinkClient::ModularFeatureName)); + FLiveLinkClient* LiveLinkClient = static_cast<FLiveLinkClient*>( + &IModularFeatures::Get().GetModularFeature<ILiveLinkClient>(ILiveLinkClient::ModularFeatureName)); LiveLinkMotionController = MakeUnique<FLiveLinkMotionControllerFix>(*LiveLinkClient); LiveLinkMotionController->RegisterController(); } diff --git a/Source/RWTHVRToolkit/Private/UI/ExternalImage.cpp b/Source/RWTHVRToolkit/Private/UI/ExternalImage.cpp index 378aa32524b650e036b9e44637ea9f139c0d642e..c5e4a7e8c91f61d290183abb74bc6893aaca9285 100644 --- a/Source/RWTHVRToolkit/Private/UI/ExternalImage.cpp +++ b/Source/RWTHVRToolkit/Private/UI/ExternalImage.cpp @@ -5,9 +5,7 @@ #include "Misc/FileHelper.h" #include "Runtime/ImageWrapper/Public/IImageWrapperModule.h" -UExternalImage::UExternalImage() -{ -} +UExternalImage::UExternalImage() {} void UExternalImage::LoadImageFromURL(const FString& ImageURL) { @@ -76,7 +74,7 @@ bool UExternalImage::LoadCompressedDataIntoTexture2D(const TArray<uint8>& InComp } void UExternalImage::LoadDataFromURL(const FString& ImageURL, TArray<uint8>& OutCompressedData, - TFunction<void()> OnSuccessCallback) + TFunction<void()> OnSuccessCallback) { TSharedRef<IHttpRequest, ESPMode::ThreadSafe> Request = FHttpModule::Get().CreateRequest(); @@ -92,7 +90,7 @@ void UExternalImage::LoadDataFromURL(const FString& ImageURL, TArray<uint8>& Out else { UE_LOG(LogTemp, Log, TEXT("UExternalyLoadedImage Request unsucessful (%d): %s"), - Response->GetResponseCode(), *Request->GetURL()); + Response->GetResponseCode(), *Request->GetURL()); } }); @@ -102,7 +100,8 @@ void UExternalImage::LoadDataFromURL(const FString& ImageURL, TArray<uint8>& Out } void UExternalImage::LoadDataFromFile(const FString& ImagePath, TArray<uint8>& OutCompressedData, - TFunction<void()> OnSuccessCallback) + TFunction<void()> OnSuccessCallback) { - if (FFileHelper::LoadFileToArray(OutCompressedData, *ImagePath)) OnSuccessCallback(); + if (FFileHelper::LoadFileToArray(OutCompressedData, *ImagePath)) + OnSuccessCallback(); } diff --git a/Source/RWTHVRToolkit/Public/Core/ClientTransformReplication.h b/Source/RWTHVRToolkit/Public/Core/ClientTransformReplication.h index 7791947cbb6e7d60c654458756cb4e5937dd0078..ac364067efcca3c0c21a6ae940b25ece78914647 100644 --- a/Source/RWTHVRToolkit/Public/Core/ClientTransformReplication.h +++ b/Source/RWTHVRToolkit/Public/Core/ClientTransformReplication.h @@ -9,10 +9,10 @@ /* -* Simple Client Transform Replication Component. Replicates the owning actor's root transform from owning client to server, -* from there to all other clients. -*/ -UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) + * Simple Client Transform Replication Component. Replicates the owning actor's root transform from owning client to + * server, from there to all other clients. + */ +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UClientTransformReplication : public UActorComponent { GENERATED_BODY() @@ -22,21 +22,22 @@ public: protected: /* - * For now, replicate in a naive sending every x ms if the transform has changed. - * This is way overkill, as we should only be sending input. However, I am not yet fully sure how - * the Unreal Client-Authoritative thingy works and what part simulates e.g. gravity. - * As this modifies only the tracking origin, latency should not be that much of an issue, so theoretically - * Server-Authority should work here too, in which case we'd just send the x and y input. - * Try both ways. - */ + * For now, replicate in a naive sending every x ms if the transform has changed. + * This is way overkill, as we should only be sending input. However, I am not yet fully sure how + * the Unreal Client-Authoritative thingy works and what part simulates e.g. gravity. + * As this modifies only the tracking origin, latency should not be that much of an issue, so theoretically + * Server-Authority should work here too, in which case we'd just send the x and y input. + * Try both ways. + */ ///////////////////////////////////////////////////////////////////////////////////////////////////// // Full transform update replication ///////////////////////////////////////////////////////////////////////////////////////////////////// - // Rate to update the position to the server, 100htz is default (same as replication rate, should also hit every tick). + // Rate to update the position to the server, 100htz is default (same as replication rate, should also hit every + // tick). UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "Networking", - meta = (ClampMin = "0", UIMin = "0")) + meta = (ClampMin = "0", UIMin = "0")) float ControllerNetUpdateRate; // Accumulates time until next send @@ -46,7 +47,8 @@ protected: UPROPERTY(EditDefaultsOnly, ReplicatedUsing = OnRep_ReplicatedTransform, Category = "Networking") FReplicatedTransform ReplicatedTransform; - // Called whenever ReplicatedTransform is replicated to clients. Not called on Owning client, manually called on server + // Called whenever ReplicatedTransform is replicated to clients. Not called on Owning client, manually called on + // server UFUNCTION() virtual void OnRep_ReplicatedTransform() { @@ -66,5 +68,5 @@ protected: public: virtual void TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) override; + FActorComponentTickFunction* ThisTickFunction) override; }; diff --git a/Source/RWTHVRToolkit/Public/Core/RWTHVRGameModeBase.h b/Source/RWTHVRToolkit/Public/Core/RWTHVRGameModeBase.h index 16e0efcefd41472fe45dcd209d89935a7bca5d1f..1469ac36caa9b571b765622766a01ed103b26252 100644 --- a/Source/RWTHVRToolkit/Public/Core/RWTHVRGameModeBase.h +++ b/Source/RWTHVRToolkit/Public/Core/RWTHVRGameModeBase.h @@ -22,11 +22,11 @@ protected: * If we are, set the player types correspondingly. */ virtual FString InitNewPlayer(APlayerController* NewPlayerController, const FUniqueNetIdRepl& UniqueId, - const FString& Options, const FString& Portal) override; + const FString& Options, const FString& Portal) override; /** - * Checks the player type of the NewPlayer. If it has been set to nDisplaySecondary, spawn a spectator pawn and possess. - * If not, spawn a DefaultPawnClass Pawn and Possess it (Should be BP_VirtualRealityPawn to make sense). + * Checks the player type of the NewPlayer. If it has been set to nDisplaySecondary, spawn a spectator pawn and + * possess. If not, spawn a DefaultPawnClass Pawn and Possess it (Should be BP_VirtualRealityPawn to make sense). */ virtual void PostLogin(APlayerController* NewPlayer) override; }; diff --git a/Source/RWTHVRToolkit/Public/Core/RWTHVRPlayerState.h b/Source/RWTHVRToolkit/Public/Core/RWTHVRPlayerState.h index 546a3095c75a4df8855467a14788c8000c84b88f..4c709e204428e4cbcd20d782823676c5b8e12c7c 100644 --- a/Source/RWTHVRToolkit/Public/Core/RWTHVRPlayerState.h +++ b/Source/RWTHVRToolkit/Public/Core/RWTHVRPlayerState.h @@ -19,7 +19,7 @@ class RWTHVRTOOLKIT_API ARWTHVRPlayerState : public APlayerState private: /** Replicated player type for this player*/ - UPROPERTY(Replicated, Category=PlayerState, BlueprintGetter=GetPlayerType, meta=(AllowPrivateAccess)) + UPROPERTY(Replicated, Category = PlayerState, BlueprintGetter = GetPlayerType, meta = (AllowPrivateAccess)) EPlayerType PlayerType = EPlayerType::Desktop; UFUNCTION(Reliable, Server) @@ -29,10 +29,7 @@ private: public: UFUNCTION(BlueprintGetter) - EPlayerType GetPlayerType() const - { - return PlayerType; - } + EPlayerType GetPlayerType() const { return PlayerType; } UFUNCTION(BlueprintCallable) void RequestSetPlayerType(EPlayerType NewPlayerType); diff --git a/Source/RWTHVRToolkit/Public/Fixes/ActivateConsoleInShipping.h b/Source/RWTHVRToolkit/Public/Fixes/ActivateConsoleInShipping.h index 140b05449e0b4dce98499a4190151a060e6e80fa..f13734b9ed4881f4bc3682805f1d4f4364a66ec4 100644 --- a/Source/RWTHVRToolkit/Public/Fixes/ActivateConsoleInShipping.h +++ b/Source/RWTHVRToolkit/Public/Fixes/ActivateConsoleInShipping.h @@ -5,7 +5,8 @@ #include "ActivateConsoleInShipping.generated.h" /** - * This fixes activates the debugging console shipping builds. Unfortunately, it can't activate the auto-completion inside the console + * This fixes activates the debugging console shipping builds. Unfortunately, it can't activate the auto-completion + * inside the console */ USTRUCT() struct RWTHVRTOOLKIT_API FActivateConsoleInShipping @@ -18,7 +19,7 @@ struct RWTHVRTOOLKIT_API FActivateConsoleInShipping private: void OnSessionStart(UWorld*, const UWorld::InitializationValues) const; - TDelegate<void (UWorld*, const UWorld::InitializationValues)> On_Post_World_Initialization_Delegate; + TDelegate<void(UWorld*, const UWorld::InitializationValues)> On_Post_World_Initialization_Delegate; FDelegateHandle StartHandle; }; diff --git a/Source/RWTHVRToolkit/Public/Fixes/LiveLinkMotionControllerFix.h b/Source/RWTHVRToolkit/Public/Fixes/LiveLinkMotionControllerFix.h index ad6e78c1e0e421bfa46de8ddac047db8f8c25aa3..131ed7d1ecb55500e3b87fbec68894dea1b0c0fa 100644 --- a/Source/RWTHVRToolkit/Public/Fixes/LiveLinkMotionControllerFix.h +++ b/Source/RWTHVRToolkit/Public/Fixes/LiveLinkMotionControllerFix.h @@ -20,7 +20,7 @@ * As they are a modular feature, this is a copy & paste of the original class with just that simple line changed. * Works well non-invasive and can be removed if the PR is merged or they fix it another way: * https://github.com/EpicGames/UnrealEngine/pull/10895 -*/ + */ class FLiveLinkMotionControllerFix : public IMotionController { @@ -46,8 +46,8 @@ public: FLiveLinkMotionControllerFix(FLiveLinkClient& InClient) : Client(InClient) { BuildSourceData(); - OnSubjectsChangedHandle = Client.OnLiveLinkSubjectsChanged().AddRaw( - this, &FLiveLinkMotionControllerFix::OnSubjectsChangedHandler); + OnSubjectsChangedHandle = + Client.OnLiveLinkSubjectsChanged().AddRaw(this, &FLiveLinkMotionControllerFix::OnSubjectsChangedHandler); WildcardSource = FGuid::NewGuid(); } @@ -57,27 +57,21 @@ public: OnSubjectsChangedHandle.Reset(); } - void RegisterController() - { - IModularFeatures::Get().RegisterModularFeature(GetModularFeatureName(), this); - } + void RegisterController() { IModularFeatures::Get().RegisterModularFeature(GetModularFeatureName(), this); } - void UnregisterController() - { - IModularFeatures::Get().UnregisterModularFeature(GetModularFeatureName(), this); - } + void UnregisterController() { IModularFeatures::Get().UnregisterModularFeature(GetModularFeatureName(), this); } virtual bool GetControllerOrientationAndPosition(const int32 ControllerIndex, const FName MotionSource, - FRotator& OutOrientation, FVector& OutPosition, - float) const override + FRotator& OutOrientation, FVector& OutPosition, + float) const override { FLiveLinkSubjectKey SubjectKey = GetSubjectKeyFromMotionSource(MotionSource); FLiveLinkSubjectFrameData FrameData; if (Client.EvaluateFrame_AnyThread(SubjectKey.SubjectName, ULiveLinkTransformRole::StaticClass(), FrameData)) { - if (FLiveLinkTransformFrameData* TransformFrameData = FrameData.FrameData.Cast< - FLiveLinkTransformFrameData>()) + if (FLiveLinkTransformFrameData* TransformFrameData = + FrameData.FrameData.Cast<FLiveLinkTransformFrameData>()) { OutPosition = TransformFrameData->Transform.GetLocation(); OutOrientation = TransformFrameData->Transform.GetRotation().Rotator(); @@ -87,39 +81,31 @@ public: return false; } - virtual bool GetControllerOrientationAndPosition(const int32 ControllerIndex, const FName MotionSource, - FRotator& OutOrientation, FVector& OutPosition, - bool& OutbProvidedLinearVelocity, FVector& OutLinearVelocity, - bool& OutbProvidedAngularVelocity, - FVector& OutAngularVelocityAsAxisAndLength, - bool& OutbProvidedLinearAcceleration, - FVector& OutLinearAcceleration, - float WorldToMetersScale) const override + virtual bool GetControllerOrientationAndPosition( + const int32 ControllerIndex, const FName MotionSource, FRotator& OutOrientation, FVector& OutPosition, + bool& OutbProvidedLinearVelocity, FVector& OutLinearVelocity, bool& OutbProvidedAngularVelocity, + FVector& OutAngularVelocityAsAxisAndLength, bool& OutbProvidedLinearAcceleration, + FVector& OutLinearAcceleration, float WorldToMetersScale) const override { OutbProvidedLinearVelocity = false; OutbProvidedAngularVelocity = false; OutbProvidedLinearAcceleration = false; return GetControllerOrientationAndPosition(ControllerIndex, MotionSource, OutOrientation, OutPosition, - WorldToMetersScale); + WorldToMetersScale); } - virtual bool GetControllerOrientationAndPositionForTime(const int32 ControllerIndex, const FName MotionSource, - FTimespan Time, bool& OutTimeWasUsed, - FRotator& OutOrientation, FVector& OutPosition, - bool& OutbProvidedLinearVelocity, - FVector& OutLinearVelocity, - bool& OutbProvidedAngularVelocity, - FVector& OutAngularVelocityAsAxisAndLength, - bool& OutbProvidedLinearAcceleration, - FVector& OutLinearAcceleration, - float WorldToMetersScale) const override + virtual bool GetControllerOrientationAndPositionForTime( + const int32 ControllerIndex, const FName MotionSource, FTimespan Time, bool& OutTimeWasUsed, + FRotator& OutOrientation, FVector& OutPosition, bool& OutbProvidedLinearVelocity, FVector& OutLinearVelocity, + bool& OutbProvidedAngularVelocity, FVector& OutAngularVelocityAsAxisAndLength, + bool& OutbProvidedLinearAcceleration, FVector& OutLinearAcceleration, float WorldToMetersScale) const override { OutTimeWasUsed = false; OutbProvidedLinearVelocity = false; OutbProvidedAngularVelocity = false; OutbProvidedLinearAcceleration = false; return GetControllerOrientationAndPosition(ControllerIndex, MotionSource, OutOrientation, OutPosition, - WorldToMetersScale); + WorldToMetersScale); } float GetCustomParameterValue(const FName MotionSource, FName ParameterName, bool& bValueFound) const override @@ -146,8 +132,8 @@ public: return 0.f; } - virtual ETrackingStatus - GetControllerTrackingStatus(const int32 ControllerIndex, const FName MotionSource) const override + virtual ETrackingStatus GetControllerTrackingStatus(const int32 ControllerIndex, + const FName MotionSource) const override { FLiveLinkSubjectKey SubjectKey = GetSubjectKeyFromMotionSource(MotionSource); @@ -189,21 +175,18 @@ public: for (const FGuid& Source : SourceGuids) { - FText SourceName = (Source == WildcardSource) - ? LOCTEXT("LiveLinkAnySource", "Any") - : Client.GetSourceType(Source); + FText SourceName = + (Source == WildcardSource) ? LOCTEXT("LiveLinkAnySource", "Any") : Client.GetSourceType(Source); Headers.Emplace(Source, SourceName); } { FGuid& CaptureWildcardSource = WildcardSource; Headers.Sort([CaptureWildcardSource](const FHeaderEntry& A, const FHeaderEntry& B) - { - return A.Key == CaptureWildcardSource || A.Value.CompareToCaseIgnored(B.Value) <= 0; - }); + { return A.Key == CaptureWildcardSource || A.Value.CompareToCaseIgnored(B.Value) <= 0; }); } - //Build EnumeratedSources data + // Build EnumeratedSources data EnumeratedSources.Reset(); EnumeratedSources.Reserve(SubjectKeys.Num()); diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/ActionBehaviour.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/ActionBehaviour.h index 14d2f407da84e380576e13d6dcc6cfaa7b0506f0..755d876dc3205b0538f6bc394352def55b2da670 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/ActionBehaviour.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/ActionBehaviour.h @@ -11,13 +11,12 @@ DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnActionBegin, USceneComponent*, TriggeredComponent, - const UInputAction*, - InputAction, const FInputActionValue&, Value); + const UInputAction*, InputAction, const FInputActionValue&, Value); DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FOnActionEnd, USceneComponent*, TriggeredComponent, const UInputAction*, - InputAction, const FInputActionValue&, Value); + InputAction, const FInputActionValue&, Value); -UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UActionBehaviour : public USceneComponent { GENERATED_BODY() @@ -35,14 +34,14 @@ public: protected: UFUNCTION() virtual void OnActionStart(USceneComponent* TriggeredComponent, const UInputAction* InputAction, - const FInputActionValue& Value); + const FInputActionValue& Value); UFUNCTION() virtual void OnActionEnd(USceneComponent* TriggeredComponent, const UInputAction* InputAction, - const FInputActionValue& Value); + const FInputActionValue& Value); virtual void BeginPlay() override; virtual void TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) override; + FActorComponentTickFunction* ThisTickFunction) override; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/GrabBehavior.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/GrabBehavior.h index b50766d60b6e71a8146f640ec3382a1637c4adff..9978823ad96b612d920c6135886d333717a90d7a 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/GrabBehavior.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/GrabBehavior.h @@ -8,19 +8,19 @@ #include "GrabBehavior.generated.h" -UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UGrabBehavior : public UActionBehaviour { GENERATED_BODY() public: - UPROPERTY(EditAnywhere, Category="Grabbing") + UPROPERTY(EditAnywhere, Category = "Grabbing") bool bBlockOtherInteractionsWhileGrabbed = true; virtual void OnActionStart(USceneComponent* TriggeredComponent, const UInputAction* InputAction, - const FInputActionValue& Value) override; + const FInputActionValue& Value) override; virtual void OnActionEnd(USceneComponent* TriggeredComponent, const UInputAction* InputAction, - const FInputActionValue& Value) override; + const FInputActionValue& Value) override; UPrimitiveComponent* GetFirstComponentSimulatingPhysics(const AActor* TargetActor); diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/HoverBehaviour.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/HoverBehaviour.h index 3bdcde4f47ed5bdfb91451f716070a494dda528d..7557653fbf02dc8d1780bbb32804c583324281ad 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/HoverBehaviour.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/HoverBehaviour.h @@ -7,30 +7,31 @@ #include "HoverBehaviour.generated.h" -DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnHoverStart, const USceneComponent*, TriggeredComponent,FHitResult, Hit); +DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnHoverStart, const USceneComponent*, TriggeredComponent, FHitResult, + Hit); DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOnHoverEnd, const USceneComponent*, TriggeredComponent); -UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) ) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UHoverBehaviour : public USceneComponent { GENERATED_BODY() -public: +public: /** - * TriggeredComponent: Component that triggered this event (e.g. GrabComponent, RayCastComponent attached at the VRPawn) - * Hit: Hit Result of the trace to get access to e.g. contact point/normals etc. - */ + * TriggeredComponent: Component that triggered this event (e.g. GrabComponent, RayCastComponent attached at the + * VRPawn) Hit: Hit Result of the trace to get access to e.g. contact point/normals etc. + */ UPROPERTY(BlueprintAssignable) - FOnHoverStart OnHoverStartEvent; + FOnHoverStart OnHoverStartEvent; UPROPERTY(BlueprintAssignable) - FOnHoverEnd OnHoverEndEvent; + FOnHoverEnd OnHoverEndEvent; protected: UFUNCTION() - virtual void OnHoverStart(const USceneComponent* TriggeredComponent, FHitResult Hit); + virtual void OnHoverStart(const USceneComponent* TriggeredComponent, FHitResult Hit); UFUNCTION() - virtual void OnHoverEnd(const USceneComponent* TriggeredComponent); - + virtual void OnHoverEnd(const USceneComponent* TriggeredComponent); + virtual void BeginPlay() override; }; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/InteractableComponent.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/InteractableComponent.h index 61352414cc6098457d1e19bf9b2e418703ed92a3..8332a897126c46ccb62418b04da0808b6a1bd2b0 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/InteractableComponent.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/InteractableComponent.h @@ -22,13 +22,13 @@ class UHoverBehaviour; * * The Interactable can be filtered. * Currently we filter on the InteractorType, e.g.: Raycast, Spherecast, etc. - * + * * Action and Hover Behaviours can be manually added via Blueprints on a per-Interactable basis. * If no Action and Hover Behaviours are set manually, all Action and Hover behaviours that are * attached to the Actor are used. * */ -UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UInteractableComponent : public UActorComponent { GENERATED_BODY() @@ -47,14 +47,12 @@ public: TArray<UActionBehaviour*> OnActionBehaviours; UFUNCTION(BlueprintCallable) - FORCEINLINE bool HasInteractionTypeFlag(EInteractorType type) - { - return type & InteractorFilter; - } + FORCEINLINE bool HasInteractionTypeFlag(EInteractorType type) { return type & InteractorFilter; } /** - * @brief Restrict interactability to given components (e.g. if an object is grabbed, block interactions from other components) - * @param Components + * @brief Restrict interactability to given components (e.g. if an object is grabbed, block interactions from other + * components) + * @param Components */ UFUNCTION() void RestrictInteractionToComponents(const TArray<USceneComponent*>& Components); @@ -73,11 +71,9 @@ public: void HandleOnHoverStartEvents(USceneComponent* TriggerComponent, const EInteractorType Interactor); void HandleOnHoverEndEvents(USceneComponent* TriggerComponent, const EInteractorType Interactor); void HandleOnActionStartEvents(USceneComponent* TriggerComponent, const UInputAction* InputAction, - const FInputActionValue& Value, - const EInteractorType Interactor); + const FInputActionValue& Value, const EInteractorType Interactor); void HandleOnActionEndEvents(USceneComponent* TriggerComponent, const UInputAction* InputAction, - const FInputActionValue& Value, - const EInteractorType Interactor); + const FInputActionValue& Value, const EInteractorType Interactor); /** * @brief If click and grab behaviors are not explicitly specified, load all existing ones diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/InteractionBitSet.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/InteractionBitSet.h index e8dd1afcdc3c58c33fbe31ad01eeedf145ea26ec..a317318d9d4af78e1a640c76ce6e7629dbbefae7 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/InteractionBitSet.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/InteractionBitSet.h @@ -1,7 +1,7 @@ #pragma once UENUM(BlueprintType, meta = (Bitflags, UseEnumValuesAsMaskValuesInEditor = "true")) -enum EInteractorType: int +enum EInteractorType : int { None = 0 UMETA(Hidden), Raycast = 1 << 0, diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactors/GrabComponent.h b/Source/RWTHVRToolkit/Public/Interaction/Interactors/GrabComponent.h index cb154963f9c86ca26e7f20cd9e8afb38821c2037..84e1eea6a0eb35fe03519d7eebf39fc93fa0fde0 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactors/GrabComponent.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactors/GrabComponent.h @@ -20,7 +20,7 @@ public: UGrabComponent(); virtual void TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) override; + FActorComponentTickFunction* ThisTickFunction) override; UPROPERTY(EditDefaultsOnly, Category = "Input") class UInputMappingContext* IMCGrab; diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactors/RaycastSelectionComponent.h b/Source/RWTHVRToolkit/Public/Interaction/Interactors/RaycastSelectionComponent.h index 9d70e04e2ecce78fe053c0cdbd0951a1deda5737..45095c3ac50cc2b81e691e9463d3af2253815173 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactors/RaycastSelectionComponent.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactors/RaycastSelectionComponent.h @@ -20,7 +20,7 @@ public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) override; + FActorComponentTickFunction* ThisTickFunction) override; UPROPERTY(EditDefaultsOnly, Category = "Input") diff --git a/Source/RWTHVRToolkit/Public/Pawn/InputExtensionInterface.h b/Source/RWTHVRToolkit/Public/Pawn/InputExtensionInterface.h index 323049f53909e167dbd5997d18d03d07c657621a..51963c0a1514950229a8b8286ad41e407accd362 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/InputExtensionInterface.h +++ b/Source/RWTHVRToolkit/Public/Pawn/InputExtensionInterface.h @@ -9,7 +9,7 @@ class UEnhancedInputLocalPlayerSubsystem; /** * Simple interface that can be implemented if your class/component defines input actions. - * Use SetupPlayerInput to bind actions, it will be called by VirtualRealityPawn::SetupPlayerInputComponent. + * Use SetupPlayerInput to bind actions, it will be called by VirtualRealityPawn::SetupPlayerInputComponent. */ UINTERFACE(MinimalAPI, NotBlueprintable) class UInputExtensionInterface : public UInterface @@ -22,11 +22,9 @@ class RWTHVRTOOLKIT_API IInputExtensionInterface GENERATED_BODY() public: - // Called by VirtualRealityPawn::SetupPlayerInputComponent virtual void SetupPlayerInput(UInputComponent* PlayerInputComponent) {} - // Helper function to get the local player subsystem + // Helper function to get the local player subsystem virtual UEnhancedInputLocalPlayerSubsystem* GetEnhancedInputLocalPlayerSubsystem(const APawn* Pawn) const; - }; diff --git a/Source/RWTHVRToolkit/Public/Pawn/Navigation/ContinuousMovementComponent.h b/Source/RWTHVRToolkit/Public/Pawn/Navigation/ContinuousMovementComponent.h index 13c3d03b28f6a9f43033e623dbeead3ba7d622ac..adbcef6f926e48e57d379423f0b1829f699fe4e3 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/Navigation/ContinuousMovementComponent.h +++ b/Source/RWTHVRToolkit/Public/Pawn/Navigation/ContinuousMovementComponent.h @@ -17,7 +17,7 @@ enum class EVRSteeringModes : uint8 }; /** - * + * */ UCLASS(Blueprintable) class RWTHVRTOOLKIT_API UContinuousMovementComponent : public UMovementComponentBase diff --git a/Source/RWTHVRToolkit/Public/Pawn/Navigation/TurnComponent.h b/Source/RWTHVRToolkit/Public/Pawn/Navigation/TurnComponent.h index d137cf82a3fd2e2083730879e95a1307d7664e59..de3f274e28caf8f353349798a84c4f2dfc02356d 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/Navigation/TurnComponent.h +++ b/Source/RWTHVRToolkit/Public/Pawn/Navigation/TurnComponent.h @@ -22,15 +22,15 @@ public: bool bAllowTurning = true; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", - meta = (EditCondition = "bAllowTurning")) + meta = (EditCondition = "bAllowTurning")) bool bSnapTurn = false; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", - meta = (EditCondition = "!bSnapTurn && bAllowTurning")) + meta = (EditCondition = "!bSnapTurn && bAllowTurning")) float TurnRateFactor = 1.0f; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", - meta = (EditCondition = "bSnapTurn && bAllowTurning", ClampMin = 0, ClampMax = 360)) + meta = (EditCondition = "bSnapTurn && bAllowTurning", ClampMin = 0, ClampMax = 360)) float SnapTurnAngle = 22.5; UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions") @@ -44,7 +44,7 @@ public: UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input") class UInputMappingContext* IMCMovement_Right; - + /**Input Mapping Context that maps buttons for desktop mode*/ UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input") class UInputMappingContext* IMCDesktopRotation; @@ -57,9 +57,9 @@ public: void OnBeginTurn(const FInputActionValue& Value); /** - * Called once if stick input is received to rotate player at constant value - * @param Value Stick input value determines turn direction - */ + * Called once if stick input is received to rotate player at constant value + * @param Value Stick input value determines turn direction + */ UFUNCTION(BlueprintCallable) void OnBeginSnapTurn(const FInputActionValue& Value); @@ -79,8 +79,9 @@ private: class UInputMappingContext* IMCTurn; /** - * If we just use VRPawn->AddControllerYawInput(Yaw), rotation is around tracking origin instead of the actual player position - * This function updates the pawns rotation and location to result in a rotation around the users tracked position. + * If we just use VRPawn->AddControllerYawInput(Yaw), rotation is around tracking origin instead of the actual + * player position This function updates the pawns rotation and location to result in a rotation around the users + * tracked position. */ void RotateCameraAndPawn(float Yaw) const; bool bApplyDesktopRotation; diff --git a/Source/RWTHVRToolkit/Public/Pawn/ReplicatedCameraComponent.h b/Source/RWTHVRToolkit/Public/Pawn/ReplicatedCameraComponent.h index a68cee69704922d66e715506097ae95ad67384d1..a6b0649b9598b4933b439f1e0b497476124f24a4 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/ReplicatedCameraComponent.h +++ b/Source/RWTHVRToolkit/Public/Pawn/ReplicatedCameraComponent.h @@ -25,12 +25,13 @@ protected: ///////////////////////////////////////////////////////////////////////////////////////////////////// /* - * See UClientTransformReplication for a description of the replication functions, they work exactly the same way. - */ + * See UClientTransformReplication for a description of the replication functions, they work exactly the same way. + */ - // Rate to update the position to the server, 100htz is default (same as replication rate, should also hit every tick). + // Rate to update the position to the server, 100htz is default (same as replication rate, should also hit every + // tick). UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "Networking", - meta = (ClampMin = "0", UIMin = "0")) + meta = (ClampMin = "0", UIMin = "0")) float ControllerNetUpdateRate; // Accumulates time until next send @@ -44,7 +45,7 @@ protected: UFUNCTION() virtual void OnRep_ReplicatedTransform() { - //For now, directly apply the transforms: + // For now, directly apply the transforms: if (!GetOwner()->HasLocalNetOwner()) SetRelativeLocationAndRotation(ReplicatedTransform.Position, ReplicatedTransform.Rotation); } @@ -55,5 +56,5 @@ protected: public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) override; + FActorComponentTickFunction* ThisTickFunction) override; }; diff --git a/Source/RWTHVRToolkit/Public/Pawn/ReplicatedMotionControllerComponent.h b/Source/RWTHVRToolkit/Public/Pawn/ReplicatedMotionControllerComponent.h index a743dbf84363018dde8eaa5d3540cff7e75f9fef..563bc6ca86cccbe8832f09e565b9e8b81d0c6d00 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/ReplicatedMotionControllerComponent.h +++ b/Source/RWTHVRToolkit/Public/Pawn/ReplicatedMotionControllerComponent.h @@ -10,7 +10,7 @@ /** * Simple MotionControllerComponent with added client-side transform replication. */ -UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +UCLASS(ClassGroup = (Custom), meta = (BlueprintSpawnableComponent)) class RWTHVRTOOLKIT_API UReplicatedMotionControllerComponent : public UMotionControllerComponent { GENERATED_BODY() @@ -24,9 +24,10 @@ protected: // Full transform update replication ///////////////////////////////////////////////////////////////////////////////////////////////////// - // Rate to update the position to the server, 100htz is default (same as replication rate, should also hit every tick). + // Rate to update the position to the server, 100htz is default (same as replication rate, should also hit every + // tick). UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "Networking", - meta = (ClampMin = "0", UIMin = "0")) + meta = (ClampMin = "0", UIMin = "0")) float ControllerNetUpdateRate; // Accumulates time until next send @@ -53,5 +54,5 @@ protected: public: // Called every frame virtual void TickComponent(float DeltaTime, ELevelTick TickType, - FActorComponentTickFunction* ThisTickFunction) override; + FActorComponentTickFunction* ThisTickFunction) override; }; diff --git a/Source/RWTHVRToolkit/Public/UI/ExternalImage.h b/Source/RWTHVRToolkit/Public/UI/ExternalImage.h index d566a6782262c65267c02c055044ae42ca5166cf..c9570244c452e0596e81c18f42553a689c70cecf 100644 --- a/Source/RWTHVRToolkit/Public/UI/ExternalImage.h +++ b/Source/RWTHVRToolkit/Public/UI/ExternalImage.h @@ -26,7 +26,7 @@ private: bool LoadCompressedDataIntoTexture2D(const TArray<uint8>& InCompressedData, UTexture2D*& OutTexture); static void LoadDataFromURL(const FString& ImageURL, TArray<uint8>& OutCompressedData, - TFunction<void()> OnSuccessCallback); + TFunction<void()> OnSuccessCallback); static void LoadDataFromFile(const FString& ImagePath, TArray<uint8>& OutCompressedData, - TFunction<void()> OnSuccessCallback); + TFunction<void()> OnSuccessCallback); }; diff --git a/Source/RWTHVRToolkit/Public/Utility/DemoConfig.h b/Source/RWTHVRToolkit/Public/Utility/DemoConfig.h index 51c20241f8809a3c63409682367809bf9ffb08bb..1470622aaea52af2e41e9a8aa9dcb079ee1eeab7 100644 --- a/Source/RWTHVRToolkit/Public/Utility/DemoConfig.h +++ b/Source/RWTHVRToolkit/Public/Utility/DemoConfig.h @@ -7,8 +7,10 @@ /** * This DeveloperSettings derivative has the following behavior: * 1. Creates a DefaultDemo.ini in your projects config folder (Name can be changed via "config =" parameter in UCLASS) - * 2. Creates a settings page in the project settings (ProjectSettings|Game|Demo) for all UPROPERTY-s and stores all UPROPERTY-s with a "Config" flag into (1.), that are altered - * 3. When packaged, creates a Demo.ini (without "Default") in the config directory of the game and dumps the contents of the DefaultDemo.ini into it + * 2. Creates a settings page in the project settings (ProjectSettings|Game|Demo) for all UPROPERTY-s and stores all + * UPROPERTY-s with a "Config" flag into (1.), that are altered + * 3. When packaged, creates a Demo.ini (without "Default") in the config directory of the game and dumps the contents + * of the DefaultDemo.ini into it * 4. When packaged, loads the config file from (3.) into this class * 5. Settings can be accessed from everywhere via `GetDefault<UYourSubClass>()->PropertyName` */ @@ -28,11 +30,12 @@ class RWTHVRTOOLKIT_API UDemoConfig : public UDeveloperSettings Super::PostInitProperties(); // Do not create/load this config file in the editor. We have the DefaultDemo.ini already - if (FApp::GetBuildTargetType() == EBuildTargetType::Editor) return; + if (FApp::GetBuildTargetType() == EBuildTargetType::Editor) + return; // Load config file (does nothing if not exist) - const FString ConfigFile = FPaths::Combine(FPaths::ProjectConfigDir(), - FPaths::GetCleanFilename(GetClass()->GetConfigName())); + const FString ConfigFile = + FPaths::Combine(FPaths::ProjectConfigDir(), FPaths::GetCleanFilename(GetClass()->GetConfigName())); FConfigCacheIni Config(EConfigCacheType::DiskBacked); Config.LoadFile(ConfigFile); diff --git a/Source/RWTHVRToolkitEditor/Private/RWTHVRToolkitEditor.cpp b/Source/RWTHVRToolkitEditor/Private/RWTHVRToolkitEditor.cpp index 4925935177729451b963577e93d723878edcd790..e53695d2b66804e9131f4dccbd5ec9a2856c6d71 100644 --- a/Source/RWTHVRToolkitEditor/Private/RWTHVRToolkitEditor.cpp +++ b/Source/RWTHVRToolkitEditor/Private/RWTHVRToolkitEditor.cpp @@ -7,12 +7,8 @@ IMPLEMENT_GAME_MODULE(FRWTHVRToolkitEditorModule, RWTHVRToolkitEditor); #define LOCTEXT_NAMESPACE "RWTHVRToolkitEditor" -void FRWTHVRToolkitEditorModule::StartupModule() -{ -} +void FRWTHVRToolkitEditorModule::StartupModule() {} -void FRWTHVRToolkitEditorModule::ShutdownModule() -{ -} +void FRWTHVRToolkitEditorModule::ShutdownModule() {} #undef LOCTEXT_NAMESPACE