Skip to content
Snippets Groups Projects
Commit a388e09a authored by David Gilbert's avatar David Gilbert :bug:
Browse files

Merge from 5.0

parents 18aeea5f deed8379
No related branches found
No related tags found
1 merge request!13Draft: Improve walking implementation
#-------------------------------------------------------------------------------
# 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
......@@ -79,16 +79,17 @@ Build_Linux:
- job: "Generate_Project"
artifacts: true
Deploy_CAVE:
Deploy_Windows:
only: ['web', 'schedules']
extends: .Deploy_CAVE_
extends: .Deploy_VRDev_
needs:
- job: "Build_Linux"
- job: "Build_Windows"
artifacts: true
Deploy_Windows:
Deploy_CAVE:
only: ['web', 'schedules']
extends: .Deploy_VRDev_
extends: .Deploy_CAVE_
needs:
- job: "Build_Windows"
- job: "Build_Linux"
artifacts: true
......@@ -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)
{
......
......@@ -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();
......
......@@ -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();
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment