Skip to content

Commit 3b500ec

Browse files
Merge branch 'dev/5.4' into '5.4'
UE5.4-2024.1-rc1 Closes #659 See merge request vr-vis/VR-Group/unreal-development/plugins/rwth-vr-toolkit!107
2 parents 3da9a6a + 0b09ea2 commit 3b500ec

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1133
-290
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ include:
4242

4343
variables:
4444
UNREAL_VERSION: "5.4"
45-
CUSTOM_NDISPLAY_CONFIG: "aixcave_5_3_dev.ndisplay"
45+
CUSTOM_NDISPLAY_CONFIG: "aixcave_5_4.ndisplay"
4646

4747
stages:
4848
- analyze
@@ -83,7 +83,7 @@ Generate_Project:
8383
RUN_SETUP: "false"
8484
GEN_DEPENDENCIES: "(
8585
[master@UnrealDTrackPlugin]='https://github.com/VRGroupRWTH/UnrealDTrackPlugin.git'
86-
[dev/5.3@RWTHVRCluster]='https://git-ce.rwth-aachen.de/vr-vis/VR-Group/unreal-development/plugins/rwth-vr-cluster-plugin.git'
86+
[dev/5.4@RWTHVRCluster]='https://git-ce.rwth-aachen.de/vr-vis/VR-Group/unreal-development/plugins/rwth-vr-cluster-plugin.git'
8787
)"
8888

8989
Generate_Project_Without_Cluster:

Config/DefaultRWTHVRToolkit.ini

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,15 @@
1818
+FunctionRedirects = (OldName="/Script/RWTHVRToolkit.DirectInteractionComponent.OnBeginGrab",NewName="/Script/RWTHVRToolkit.DirectInteractionComponent.OnBeginInteraction")
1919
+FunctionRedirects = (OldName="/Script/RWTHVRToolkit.DirectInteractionComponent.OnEndGrab",NewName="/Script/RWTHVRToolkit.DirectInteractionComponent.OnEndInteraction")
2020
+PropertyRedirects = (OldName="/Script/RWTHVRToolkit.DirectInteractionComponent.PreviousGrabBehavioursInRange",NewName="/Script/RWTHVRToolkit.DirectInteractionComponent.PreviousInteractableComponentsInRange")
21-
+PropertyRedirects = (OldName="/Script/RWTHVRToolkit.DirectInteractionComponent.CurrentGrabBehavioursInRange",NewName="/Script/RWTHVRToolkit.DirectInteractionComponent.CurrentInteractableComponentsInRange")
21+
+PropertyRedirects = (OldName="/Script/RWTHVRToolkit.DirectInteractionComponent.CurrentGrabBehavioursInRange",NewName="/Script/RWTHVRToolkit.DirectInteractionComponent.CurrentInteractableComponentsInRange")
22+
+PropertyRedirects = (OldName="/Script/RWTHVRToolkit.TurnComponent.DesktopRotation",NewName="/Script/RWTHVRToolkit.TurnComponent.DesktopTurnCondition")
23+
+PropertyRedirects = (OldName="/Script/RWTHVRToolkit.TurnComponent.Turn",NewName="/Script/RWTHVRToolkit.TurnComponent.XRTurn")
24+
+PropertyRedirects = (OldName="/Script/RWTHVRToolkit.RWTHVRWidgetInteractionComponent.WidgetClickInputAction",NewName="/Script/RWTHVRToolkit.RWTHVRWidgetInteractionComponent.WidgetLeftClickInputAction")
25+
+FunctionRedirects = (OldName="/Script/RWTHVRToolkit.RWTHVRWidgetInteractionComponent.OnBeginClick",NewName="/Script/RWTHVRToolkit.RWTHVRWidgetInteractionComponent.OnBeginLeftClick")
26+
+FunctionRedirects = (OldName="/Script/RWTHVRToolkit.RWTHVRWidgetInteractionComponent.OnEndClick",NewName="/Script/RWTHVRToolkit.RWTHVRWidgetInteractionComponent.OnEndLeftClick")
27+
+FunctionRedirects=(OldName="/Script/RWTHVRToolkit.UBaseInteractionComponent.OnBeginInteraction",NewName="/Script/RWTHVRToolkit.UBaseInteractionComponent.OnBeginInteractionInputAction")
28+
+FunctionRedirects=(OldName="/Script/RWTHVRToolkit.UBaseInteractionComponent.OnEndInteraction",NewName="/Script/RWTHVRToolkit.UBaseInteractionComponent.OnEndInteractionInputAction")
29+
+FunctionRedirects=(OldName="/Script/RWTHVRToolkit.UBaseInteractionComponent.MulticastHoverBehaviourStartRpc",NewName="/Script/RWTHVRToolkit.UBaseInteractionComponent.MulticastHoverBehaviourReplicationStartRpc")
30+
+FunctionRedirects=(OldName="/Script/RWTHVRToolkit.UBaseInteractionComponent.MulticastActionBehaviourStartRpc",NewName="/Script/RWTHVRToolkit.UBaseInteractionComponent.MulticastActionBehaviourReplicationStartRpc")
31+
+FunctionRedirects=(OldName="/Script/RWTHVRToolkit.ActionBehaviour.OnActionStart",NewName="/Script/RWTHVRToolkit.ActionBehaviour.OnActionEvent")
32+
+PropertyRedirects=(OldName="/Script/RWTHVRToolkit.ActionBehaviour.OnActionBeginEvent",NewName="/Script/RWTHVRToolkit.ActionBehaviour.OnActionEventEvent")

Content/BP_RWTHVRGameModeBase.uasset

0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3.76 KB
Binary file not shown.
Binary file not shown.
Binary file not shown.
2.34 KB
Binary file not shown.
1.17 KB
Binary file not shown.

Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp

Lines changed: 72 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,31 @@
77
#include "GameFramework/SpectatorPawn.h"
88
#include "Kismet/GameplayStatics.h"
99
#include "Logging/StructuredLog.h"
10+
#include "Pawn/ClusterRepresentationActor.h"
1011
#include "Utility/RWTHVRUtilities.h"
1112

1213

14+
ARWTHVRGameModeBase::ARWTHVRGameModeBase(const FObjectInitializer& ObjectInitializer)
15+
{
16+
PlayerStateClass = ARWTHVRPlayerState::StaticClass();
17+
}
18+
1319
FString ARWTHVRGameModeBase::InitNewPlayer(APlayerController* NewPlayerController, const FUniqueNetIdRepl& UniqueId,
1420
const FString& Options, const FString& Portal)
1521
{
1622
// Used by the DisplayClusterNetDriver/Connection to handshake nodes. Could use their types directly
1723
// but I don't really want to introduce a hard dependency here.
1824
const FString NodeNameKey = "node";
1925
const FString PrimaryNodeIdKey = "PrimaryNodeId";
26+
const FString ClusterIdKey = "ClusterId";
2027

2128
// Check if we're using our custom PlayerState so that we can save the player type there.
2229
// If not, just ingore all related args.
2330
ARWTHVRPlayerState* State = Cast<ARWTHVRPlayerState>(NewPlayerController->PlayerState);
2431

2532
if (State != nullptr)
2633
{
34+
int32 ClusterId = -1;
2735
if (UGameplayStatics::HasOption(Options, PrimaryNodeIdKey))
2836
{
2937
const FString PrimaryNodeId = UGameplayStatics::ParseOption(Options, PrimaryNodeIdKey);
@@ -34,19 +42,70 @@ FString ARWTHVRGameModeBase::InitNewPlayer(APlayerController* NewPlayerControlle
3442
? UGameplayStatics::ParseOption(Options, NodeNameKey)
3543
: PrimaryNodeId;
3644

45+
ClusterId = UGameplayStatics::HasOption(Options, ClusterIdKey)
46+
? FCString::Atoi(*UGameplayStatics::ParseOption(Options, ClusterIdKey))
47+
: -1;
48+
3749
const EPlayerType Type =
3850
NodeName == PrimaryNodeId ? EPlayerType::nDisplayPrimary : EPlayerType::nDisplaySecondary;
3951
State->RequestSetPlayerType(Type);
4052
}
53+
else if (GetNetMode() == NM_Standalone && URWTHVRUtilities::IsRoomMountedMode())
54+
{
55+
ClusterId = 0;
56+
const EPlayerType Type =
57+
URWTHVRUtilities::IsPrimaryNode() ? EPlayerType::nDisplayPrimary : EPlayerType::nDisplaySecondary;
58+
State->RequestSetPlayerType(Type);
59+
}
60+
State->SetCorrespondingClusterId(ClusterId);
4161
}
4262

4363
return Super::InitNewPlayer(NewPlayerController, UniqueId, Options, Portal);
4464
}
4565

4666
void ARWTHVRGameModeBase::PostLogin(APlayerController* NewPlayer)
4767
{
48-
if (const ARWTHVRPlayerState* State = Cast<ARWTHVRPlayerState>(NewPlayer->PlayerState); State != nullptr)
68+
if (ARWTHVRPlayerState* State = Cast<ARWTHVRPlayerState>(NewPlayer->PlayerState); State != nullptr)
4969
{
70+
// If we're in none-standalone netmode, this is only executed on the server, as the GM only exists there.
71+
// On standalone, this is executed on every node.
72+
int32 ClusterId = State->GetCorrespondingClusterId();
73+
if (ClusterId >= 0) // we're either standalone (0) or in an acutal cluster
74+
{
75+
AClusterRepresentationActor** ClusterRepresentationPtr = ConnectedClusters.Find(ClusterId);
76+
AClusterRepresentationActor* ClusterRepresentation;
77+
if (!ClusterRepresentationPtr)
78+
{
79+
// No actor there yet, spawn it
80+
FActorSpawnParameters SpawnParameters;
81+
SpawnParameters.Name = FName(*FString::Printf(TEXT("ClusterRepresentation_%d"), ClusterId));
82+
SpawnParameters.NameMode = FActorSpawnParameters::ESpawnActorNameMode::Requested;
83+
ClusterRepresentation = GetWorld()->SpawnActor<AClusterRepresentationActor>(SpawnParameters);
84+
UE_LOGFMT(Toolkit, Display,
85+
"ARWTHVRGameModeBase: Spawned ClusterRepresentationActor {Name} for Cluster {Id}",
86+
ClusterRepresentation->GetName(), ClusterId);
87+
ConnectedClusters.Add(ClusterId, ClusterRepresentation);
88+
}
89+
else
90+
{
91+
ClusterRepresentation = *ClusterRepresentationPtr;
92+
}
93+
94+
UE_LOGFMT(Toolkit, Display, "ARWTHVRGameModeBase: Using ClusterRepresentationActor {Name} for Cluster {Id}",
95+
*ClusterRepresentation->GetName(), ClusterId);
96+
97+
// Double check for sanity
98+
check(ClusterRepresentation != nullptr);
99+
100+
State->SetCorrespondingClusterActor(ClusterRepresentation);
101+
102+
if (State->GetPlayerType() == EPlayerType::nDisplayPrimary)
103+
{
104+
// We're the owner of the actor!
105+
ClusterRepresentation->SetOwner(NewPlayer);
106+
}
107+
}
108+
50109
// Do we already have an auto-possessing pawn possessed?
51110
if (NewPlayer->GetPawn() && NewPlayer->GetPawn()->IsValidLowLevelFast())
52111
{
@@ -56,10 +115,11 @@ void ARWTHVRGameModeBase::PostLogin(APlayerController* NewPlayer)
56115
return;
57116
}
58117

118+
// When we're not in standalone:
59119
// If the new player is a secondary nDisplay node, spawn it only as a Spectator
60120
// Potentially we can use MustSpectate instead.
61121
UClass* PawnClass;
62-
if (State->GetPlayerType() == EPlayerType::nDisplaySecondary)
122+
if (GetNetMode() != NM_Standalone && State->GetPlayerType() == EPlayerType::nDisplaySecondary)
63123
{
64124
// For now, simply use the BP approach of spawning the pawn here. Can do this in a better way potentially.
65125
PawnClass = SpectatorClass;
@@ -83,11 +143,20 @@ void ARWTHVRGameModeBase::PostLogin(APlayerController* NewPlayer)
83143
}
84144
}
85145

146+
if (GetNetMode() == NM_Standalone)
147+
{
148+
const FName BaseName = PawnClass->HasAnyFlags(RF_ClassDefaultObject)
149+
? PawnClass->GetFName()
150+
: *PawnClass->GetFName().GetPlainNameString();
151+
152+
SpawnInfo.Name = BaseName;
153+
SpawnInfo.NameMode = FActorSpawnParameters::ESpawnActorNameMode::Requested;
154+
}
155+
86156
// Spawn and possess the pawn
87157
APawn* ResultPawn = GetWorld()->SpawnActor<APawn>(PawnClass, StartSpot->GetTransform(), SpawnInfo);
88158
NewPlayer->Possess(ResultPawn);
89159
}
90160

91-
92161
Super::PostLogin(NewPlayer);
93162
}

Source/RWTHVRToolkit/Private/Core/RWTHVRPlayerState.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33

44
#include "Core/RWTHVRPlayerState.h"
55

6+
#include "Logging/StructuredLog.h"
67
#include "Net/UnrealNetwork.h"
78
#include "Net/Core/PushModel/PushModel.h"
9+
#include "Utility/RWTHVRUtilities.h"
810

911
// Boilerplate, copies properties to new state
1012
void ARWTHVRPlayerState::CopyProperties(class APlayerState* PlayerState)
@@ -17,6 +19,8 @@ void ARWTHVRPlayerState::CopyProperties(class APlayerState* PlayerState)
1719
if (IsValid(RWTHVRPlayerState))
1820
{
1921
RWTHVRPlayerState->SetPlayerType(GetPlayerType());
22+
RWTHVRPlayerState->SetCorrespondingClusterId(CorrespondingClusterId);
23+
RWTHVRPlayerState->SetCorrespondingClusterActor(CorrespondingClusterActor);
2024
}
2125
}
2226
}
@@ -32,6 +36,8 @@ void ARWTHVRPlayerState::OverrideWith(class APlayerState* PlayerState)
3236
if (IsValid(RWTHVRPlayerState))
3337
{
3438
SetPlayerType(RWTHVRPlayerState->GetPlayerType());
39+
SetCorrespondingClusterId(RWTHVRPlayerState->CorrespondingClusterId);
40+
SetCorrespondingClusterActor(RWTHVRPlayerState->CorrespondingClusterActor);
3541
}
3642
}
3743
}
@@ -45,6 +51,8 @@ void ARWTHVRPlayerState::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& O
4551
SharedParams.bIsPushBased = true;
4652

4753
DOREPLIFETIME_WITH_PARAMS_FAST(ARWTHVRPlayerState, PlayerType, SharedParams);
54+
DOREPLIFETIME_WITH_PARAMS_FAST(ARWTHVRPlayerState, CorrespondingClusterId, SharedParams);
55+
DOREPLIFETIME_WITH_PARAMS_FAST(ARWTHVRPlayerState, CorrespondingClusterActor, SharedParams);
4856
}
4957

5058
void ARWTHVRPlayerState::ServerSetPlayerTypeRpc_Implementation(const EPlayerType NewPlayerType)
@@ -57,6 +65,28 @@ void ARWTHVRPlayerState::SetPlayerType(const EPlayerType NewPlayerType)
5765
MARK_PROPERTY_DIRTY_FROM_NAME(ARWTHVRPlayerState, PlayerType, this);
5866
PlayerType = NewPlayerType;
5967
}
68+
void ARWTHVRPlayerState::SetCorrespondingClusterId(int32 NewCorrespondingClusterId)
69+
{
70+
if (!HasAuthority())
71+
{
72+
UE_LOGFMT(Toolkit, Warning, "ARWTHVRPlayerState: Cannot set cluster Id on non-authority!");
73+
return;
74+
}
75+
76+
MARK_PROPERTY_DIRTY_FROM_NAME(ARWTHVRPlayerState, CorrespondingClusterId, this);
77+
CorrespondingClusterId = NewCorrespondingClusterId;
78+
}
79+
void ARWTHVRPlayerState::SetCorrespondingClusterActor(AClusterRepresentationActor* NewCorrespondingClusterActor)
80+
{
81+
if (!HasAuthority())
82+
{
83+
UE_LOGFMT(Toolkit, Warning, "ARWTHVRPlayerState: Cannot set cluster actor ref on non-authority!");
84+
return;
85+
}
86+
87+
MARK_PROPERTY_DIRTY_FROM_NAME(ARWTHVRPlayerState, CorrespondingClusterActor, this);
88+
CorrespondingClusterActor = NewCorrespondingClusterActor;
89+
}
6090

6191
void ARWTHVRPlayerState::RequestSetPlayerType(const EPlayerType NewPlayerType)
6292
{

Source/RWTHVRToolkit/Private/Interaction/Interactables/ActionBehaviour.cpp

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,27 +6,14 @@
66
// We disable ticking here, as we are mainly interested in the events
77
UActionBehaviour::UActionBehaviour() { PrimaryComponentTick.bCanEverTick = false; }
88

9-
void UActionBehaviour::OnActionStart(USceneComponent* TriggeredComponent, const UInputAction* InputAction,
9+
void UActionBehaviour::OnActionEvent(USceneComponent* TriggerComponent, const EInteractionEventType EventType,
1010
const FInputActionValue& Value)
1111
{
1212
}
1313

14-
void UActionBehaviour::OnActionEnd(USceneComponent* TriggeredComponent, const UInputAction* InputAction,
15-
const FInputActionValue& Value)
16-
{
17-
}
18-
1914
void UActionBehaviour::BeginPlay()
2015
{
2116
Super::BeginPlay();
2217

23-
OnActionBeginEvent.AddDynamic(this, &UActionBehaviour::OnActionStart);
24-
OnActionEndEvent.AddDynamic(this, &UActionBehaviour::OnActionEnd);
25-
}
26-
27-
// Called every frame
28-
void UActionBehaviour::TickComponent(float DeltaTime, ELevelTick TickType,
29-
FActorComponentTickFunction* ThisTickFunction)
30-
{
31-
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
18+
OnActionEventEvent.AddDynamic(this, &UActionBehaviour::OnActionEvent);
3219
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Fill out your copyright notice in the Description page of Project Settings.
2+
3+
4+
#include "Interaction/Interactables/BaseBehaviour.h"

0 commit comments

Comments
 (0)