diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index eb99b16caef319a69bce83a022b4e6cf72db25fd..e798e2ea6a7c87da5055e21fc9f625bc00a8bca9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ #------------------------------------------------------------------------------- -# Copyright (c) 2020 RWTH Aachen University, Germany, +# Copyright (c) 2022 RWTH Aachen University, Germany, # Virtual Reality & Immersive Visualisation Group. #------------------------------------------------------------------------------- @@ -27,11 +27,11 @@ include: # only: ['web', 'schedules'] # extends: .Generate_Project_ # variables: -# GEN_TEMPLATE_REPO: "https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/unrealprojecttemplate.git" +# GEN_TEMPLATE_REPO: "https://git-ce.rwth-aachen.de/vr-vis/VR-Group/unreal-development/unrealprojecttemplate.git" # GEN_TEMPLATE_BRANCH: "4.26" # GEN_DEPENDENCIES: "( -# [4.26@RWTHVRToolkit]='https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/Plugins/rwth-vr-toolkit.git' -# [4.26@UniversalLogging]='https://devhub.vr.rwth-aachen.de/VR-Group/unreal-development/Plugins/universallogging.git' +# [4.26@RWTHVRToolkit]='https://git-ce.rwth-aachen.de/vr-vis/VR-Group/unreal-development/Plugins/rwth-vr-toolkit.git' +# [4.26@UniversalLogging]='https://git-ce.rwth-aachen.de/vr-vis/VR-Group/unreal-development/Plugins/universallogging.git' # )" # # You can uncomment the deploy lines to deploy your project to the CAVE/VRDev. This only makes sense, if your plugin works @@ -47,7 +47,7 @@ Generate_Project: extends: .Generate_Project_ variables: RUN_SETUP: "false" - GEN_TEMPLATE_BRANCH: "5.1" + GEN_TEMPLATE_BRANCH: "5.1" Build_Windows: only: ['web', 'schedules'] @@ -78,17 +78,18 @@ Build_Linux: needs: - job: "Generate_Project" artifacts: true - -Deploy_CAVE: - only: ['web', 'schedules'] - extends: .Deploy_CAVE_ - needs: - - job: "Build_Linux" - artifacts: true Deploy_Windows: only: ['web', 'schedules'] extends: .Deploy_VRDev_ needs: - job: "Build_Windows" + artifacts: true + +Deploy_CAVE: + only: ['web', 'schedules'] + extends: .Deploy_CAVE_ + needs: + - job: "Build_Linux" artifacts: true + diff --git a/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp b/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp index 49df1bd3574dc6277f9900b2bc10a4f45ae791a8..1ab4410875ce73d3fff4caec2755d16b4bc6cdc6 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/BasicVRInteractionComponent.cpp @@ -64,7 +64,7 @@ void UBasicVRInteractionComponent::BeginInteraction() PressPointerKey(EKeys::LeftMouseButton); - if (HitActor->Implements<UGrabable>() && Hit->Distance < MaxGrabDistance) + if (HitActor && HitActor->Implements<UGrabable>() && Hit->Distance < MaxGrabDistance) { // call grabable actors function so he reacts to our grab IGrabable::Execute_OnBeginGrab(HitActor); @@ -77,7 +77,7 @@ void UBasicVRInteractionComponent::BeginInteraction() // we save the grabbedActor in a general form to access all of AActors functions easily later GrabbedActor = HitActor; } - else if (HitActor->Implements<UClickable>() && Hit->Distance < MaxClickDistance) + else if (HitActor && HitActor->Implements<UClickable>() && Hit->Distance < MaxClickDistance) { IClickable::Execute_OnClick(HitActor, Hit->Location); } @@ -139,7 +139,7 @@ void UBasicVRInteractionComponent::TickComponent(float DeltaTime, ELevelTick Tic const FTwoVectors StartEnd = GetHandRay(MaxClickDistance); TOptional<FHitResult> Hit = RaytraceForFirstHit(StartEnd); - if (!Hit.IsSet()) + if (!Hit.IsSet() || !Hit->GetActor()) { if(InteractionRayVisibility==EInteractionRayVisibility::VisibleOnHoverOnly) { diff --git a/Source/RWTHVRToolkit/Private/Pawn/VirtualRealityPawn.cpp b/Source/RWTHVRToolkit/Private/Pawn/VirtualRealityPawn.cpp index e38268da2b1135548b81f154b27578fee7d2dbee..d65ca8ab248d384fd9094b38b0f5cc1936947ccd 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/VirtualRealityPawn.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/VirtualRealityPawn.cpp @@ -57,12 +57,37 @@ void AVirtualRealityPawn::SetupPlayerInputComponent(UInputComponent* PlayerInput PlayerInputComponent->BindAxis("MoveForward", this, &AVirtualRealityPawn::OnForward); PlayerInputComponent->BindAxis("MoveRight", this, &AVirtualRealityPawn::OnRight); + PlayerInputComponent->BindAxis("MoveUp", this, &AVirtualRealityPawn::OnUp); PlayerInputComponent->BindAxis("TurnRate", this, &AVirtualRealityPawn::OnTurnRate); PlayerInputComponent->BindAxis("LookUpRate", this, &AVirtualRealityPawn::OnLookUpRate); // function bindings for grabbing and releasing PlayerInputComponent->BindAction("Fire", IE_Pressed, this, &AVirtualRealityPawn::OnBeginFire); PlayerInputComponent->BindAction("Fire", IE_Released, this, &AVirtualRealityPawn::OnEndFire); + + // bind functions for desktop rotations only on holding down right mouse + if (UVirtualRealityUtilities::IsDesktopMode()) + { + APlayerController* PC = Cast<APlayerController>(GetController()); + if (PC) + { + PC->bShowMouseCursor = true; + PC->bEnableClickEvents = true; + PC->bEnableMouseOverEvents = true; + } + PlayerInputComponent->BindAction("EnableDesktopRotation", IE_Pressed, this, &AVirtualRealityPawn::StartDesktopRotation); + PlayerInputComponent->BindAction("EnableDesktopRotation", IE_Released, this, &AVirtualRealityPawn::EndDesktopRotation); + } +} + +void AVirtualRealityPawn::StartDesktopRotation() +{ + bApplyDesktopRotation = true; +} + +void AVirtualRealityPawn::EndDesktopRotation() +{ + bApplyDesktopRotation = false; } void AVirtualRealityPawn::SetCameraOffset() const @@ -75,35 +100,74 @@ void AVirtualRealityPawn::SetCameraOffset() const CameraComponent->SetWorldLocationAndRotation(Location, Rotation); } +void AVirtualRealityPawn::UpdateRightHandForDesktopInteraction() +{ + APlayerController* PC = Cast<APlayerController>(GetController()); + if (PC) + { + FVector MouseLocation, MouseDirection; + PC->DeprojectMousePositionToWorld(MouseLocation, MouseDirection); + FRotator HandOrientation = MouseDirection.ToOrientationRotator(); + RightHand->SetWorldRotation(HandOrientation); + } +} + void AVirtualRealityPawn::OnForward_Implementation(float Value) { - if (RightHand) + //the right hand is rotated on desktop to follow the cursor so it's forward is also changing with cursor position + if (RightHand && !UVirtualRealityUtilities::IsDesktopMode()) { AddMovementInput(RightHand->GetForwardVector(), Value); } + else if (Head) + { + AddMovementInput(Head->GetForwardVector(), Value); + } } void AVirtualRealityPawn::OnRight_Implementation(float Value) { - if (RightHand) + //the right hand is rotated on desktop to follow the cursor so it's forward is also changing with cursor position + if (RightHand && !UVirtualRealityUtilities::IsDesktopMode()) { AddMovementInput(RightHand->GetRightVector(), Value); } + else if (Head) + { + AddMovementInput(Head->GetRightVector(), Value); + } +} + +void AVirtualRealityPawn::OnUp_Implementation(float Value) +{ + //the right hand is rotated on desktop to follow the cursor so it's forward is also changing with cursor position + if (RightHand && !UVirtualRealityUtilities::IsDesktopMode()) + { + AddMovementInput(RightHand->GetUpVector(), Value); + } + else if (Head) + { + AddMovementInput(Head->GetUpVector(), Value); + } } void AVirtualRealityPawn::OnTurnRate_Implementation(float Rate) { /* Turning the user externally will make them sick */ - if (UVirtualRealityUtilities::IsDesktopMode()) + if (UVirtualRealityUtilities::IsDesktopMode() && bApplyDesktopRotation) { AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds() * CustomTimeDilation); } + if (UVirtualRealityUtilities::IsDesktopMode()) + { + UpdateRightHandForDesktopInteraction(); + } } void AVirtualRealityPawn::OnLookUpRate_Implementation(float Rate) { /* Turning the user externally will make them sick */ - if (UVirtualRealityUtilities::IsDesktopMode()) + if (UVirtualRealityUtilities::IsDesktopMode() && bApplyDesktopRotation) { AddControllerPitchInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds() * CustomTimeDilation); SetCameraOffset(); diff --git a/Source/RWTHVRToolkit/Public/Pawn/VirtualRealityPawn.h b/Source/RWTHVRToolkit/Public/Pawn/VirtualRealityPawn.h index baa9f9939f5e932651c108f62d7205d7f3cada71..c1c0789f9f48b5f5a6d03a9b9d7448cd7d00cd4b 100644 --- a/Source/RWTHVRToolkit/Public/Pawn/VirtualRealityPawn.h +++ b/Source/RWTHVRToolkit/Public/Pawn/VirtualRealityPawn.h @@ -50,6 +50,7 @@ protected: /* Movement */ UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn|Movement") void OnForward(float Value); UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn|Movement") void OnRight(float Value); + UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn|Movement") void OnUp(float Value); UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn|Movement") void OnTurnRate(float Rate); UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn|Movement") void OnLookUpRate(float Rate); @@ -57,5 +58,12 @@ protected: UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn|Interaction") void OnBeginFire(); UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = "Pawn|Interaction") void OnEndFire(); + /*Desktop Testing*/ + // the idea is that you have to hold the right mouse button to do rotations + UFUNCTION() void StartDesktopRotation(); + UFUNCTION() void EndDesktopRotation(); + bool bApplyDesktopRotation = false; + void SetCameraOffset() const; + void UpdateRightHandForDesktopInteraction(); };