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

refactor(cave): Optionally enable RWTHVRCluster Plugin.

If enabled, Utilities forwards to cluster specific utilities and the pawn gets a cluster sync component spawned at runtime. Removes Cluster specific input from general imc
parent 18dcb53b
Branches
Tags
2 merge requests!85UE5.3-2023.1-rc3,!79Plugin Separation: Move the RWTHVRCluster Module into its own Plugin with respective content. Removes Toolkit dependency to nDisplay
Pipeline #350385 passed
No preview for this file type
......@@ -27,6 +27,15 @@
}
],
"Plugins": [
{
"Name": "RWTHVRCluster",
"Enabled": true,
"Optional": true,
"SupportedTargetPlatforms": [
"Win64",
"Linux"
]
},
{
"Name": "LiveLink",
"Enabled": true
......
......@@ -16,6 +16,10 @@
#include "Roles/LiveLinkTransformTypes.h"
#include "Utility/RWTHVRUtilities.h"
#if PLATFORM_SUPPORTS_CLUSTER
#include "Components/DisplayClusterSceneComponentSyncParent.h"
#endif
ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
BaseEyeHeight = 160.0f;
......@@ -36,15 +40,19 @@ ARWTHVRPawn::ARWTHVRPawn(const FObjectInitializer& ObjectInitializer) : Super(Ob
LeftHand = CreateDefaultSubobject<UReplicatedMotionControllerComponent>(TEXT("Left Hand MCC"));
LeftHand->SetupAttachment(RootComponent);
}
void ARWTHVRPawn::BeginPlay()
{
Super::BeginPlay();
#if 0
#if PLATFORM_SUPPORTS_CLUSTER
// Add an nDisplay Parent Sync Component. It syncs the parent's transform from master to clients.
// This is required because for collision based movement, it can happen that the physics engine
// for some reason acts different on the nodes, therefore leading to a potential desync when
// e.g. colliding with an object while moving.
SyncComponent =
CreateDefaultSubobject<UDisplayClusterSceneComponentSyncParent>(TEXT("Parent Display Cluster Sync Component"));
SyncComponent = NewObject<UDisplayClusterSceneComponentSyncParent>();
SyncComponent->SetupAttachment(RootComponent);
SyncComponent->RegisterComponent();
#endif
}
......
#include "Utility/RWTHVRUtilities.h"
#if PLATFORM_SUPPORTS_NDISPLAY
#include "DisplayClusterConfigurationTypes.h"
#include "DisplayClusterRootActor.h"
#include "IDisplayCluster.h"
#include "Cluster/IDisplayClusterClusterManager.h"
#include "Components/DisplayClusterCameraComponent.h"
#include "Config/IDisplayClusterConfigManager.h"
#include "Game/IDisplayClusterGameManager.h"
#endif
#include "AudioDevice.h"
#include "IHeadMountedDisplay.h"
#include "IXRTrackingSystem.h"
......@@ -17,6 +7,10 @@
#include "Engine/LocalPlayer.h"
#include "Kismet/GameplayStatics.h"
#if PLATFORM_SUPPORTS_CLUSTER
#include "Utility/RWTHVRClusterUtilities.h"
#endif
DEFINE_LOG_CATEGORY(Toolkit);
......@@ -25,15 +19,6 @@ bool URWTHVRUtilities::IsDesktopMode()
return !IsRoomMountedMode() && !IsHeadMountedMode();
}
bool URWTHVRUtilities::IsRoomMountedMode()
{
#if PLATFORM_SUPPORTS_NDISPLAY
return IDisplayCluster::Get().GetOperationMode() == EDisplayClusterOperationMode::Cluster;
#else
return false;
#endif
}
bool URWTHVRUtilities::IsHeadMountedMode()
{
// In editor builds: checks for EdEngine->IsVRPreviewActive()
......@@ -41,65 +26,20 @@ bool URWTHVRUtilities::IsHeadMountedMode()
return FAudioDevice::CanUseVRAudioDevice();
}
bool URWTHVRUtilities::IsCave()
bool URWTHVRUtilities::IsRoomMountedMode()
{
#if PLATFORM_SUPPORTS_NDISPLAY
if (!IsRoomMountedMode())
return false;
const UDisplayClusterConfigurationData* ClusterConfig = IDisplayCluster::Get().GetConfigMgr()->GetConfig();
return ClusterConfig->CustomParameters.Contains("Hardware_Platform")
&& ClusterConfig->CustomParameters.Find("Hardware_Platform")->Equals("aixcave", ESearchCase::IgnoreCase);
#else
return false;
#if PLATFORM_SUPPORTS_CLUSTER
URWTHVRClusterUtilities::IsRoomMountedMode();
#endif
}
bool URWTHVRUtilities::IsRolv()
{
#if PLATFORM_SUPPORTS_NDISPLAY
if (!IsRoomMountedMode())
return false;
const UDisplayClusterConfigurationData* ClusterConfig = IDisplayCluster::Get().GetConfigMgr()->GetConfig();
return ClusterConfig->CustomParameters.Contains("Hardware_Platform")
&& ClusterConfig->CustomParameters.Find("Hardware_Platform")->Equals("ROLV", ESearchCase::IgnoreCase);
#else
return false;
#endif
}
/* Return true on the Primary in cluster mode and in a normal desktop session. Otherwise false */
bool URWTHVRUtilities::IsPrimaryNode()
{
#if PLATFORM_SUPPORTS_NDISPLAY
if (!IDisplayCluster::IsAvailable())
{
return true;
}
IDisplayClusterClusterManager* Manager = IDisplayCluster::Get().GetClusterMgr();
if (Manager == nullptr)
{
return true; // if we are not in cluster mode, we are always the primary node
}
return Manager->IsPrimary() || !Manager->IsSecondary();
#else
return true;
#endif
}
bool URWTHVRUtilities::IsSecondaryNode()
{
return !IsPrimaryNode();
}
FString URWTHVRUtilities::GetNodeName()
{
#if PLATFORM_SUPPORTS_NDISPLAY
return IsRoomMountedMode() ? IDisplayCluster::Get().GetClusterMgr()->GetNodeId() : FString(TEXT("Localhost"));
#else
return FString(TEXT("Localhost"));
#if PLATFORM_SUPPORTS_CLUSTER
URWTHVRClusterUtilities::IsPrimaryNode();
#endif
return false;
}
float URWTHVRUtilities::GetEyeDistance()
......@@ -108,71 +48,7 @@ float URWTHVRUtilities::GetEyeDistance()
{
return GEngine->XRSystem->GetHMDDevice()->GetInterpupillaryDistance();
}
else
{
#if PLATFORM_SUPPORTS_NDISPLAY
const ADisplayClusterRootActor* RootActor = IDisplayCluster::Get().GetGameMgr()->GetRootActor();
return (RootActor) ? RootActor->GetDefaultCamera()->GetInterpupillaryDistance() : 0.0f;
#else
return 0.0f;
#endif
}
}
EEyeStereoOffset URWTHVRUtilities::GetNodeEyeType()
{
#if PLATFORM_SUPPORTS_NDISPLAY
const ADisplayClusterRootActor* RootActor = IDisplayCluster::Get().GetGameMgr()->GetRootActor();
return static_cast<EEyeStereoOffset>((RootActor)
? RootActor->GetDefaultCamera()->GetStereoOffset()
: EDisplayClusterEyeStereoOffset::None);
#else
return EEyeStereoOffset::None;
#endif
}
USceneComponent* URWTHVRUtilities::GetClusterComponent(const FString& Name)
{
#if PLATFORM_SUPPORTS_NDISPLAY
const ADisplayClusterRootActor* RootActor = IDisplayCluster::Get().GetGameMgr()->GetRootActor();
return (RootActor) ? RootActor->GetComponentByName<USceneComponent>(Name) : nullptr;
#else
return nullptr;
#endif
}
USceneComponent* URWTHVRUtilities::GetNamedClusterComponent(const ENamedClusterComponent& Component)
{
switch (Component)
{
case ENamedClusterComponent::NCC_CAVE_ORIGIN:
return GetClusterComponent("cave_origin");
case ENamedClusterComponent::NCC_CAVE_CENTER:
return GetClusterComponent("cave_center");
case ENamedClusterComponent::NCC_CAVE_LHT:
return GetClusterComponent("left_hand_target");
case ENamedClusterComponent::NCC_CAVE_RHT:
return GetClusterComponent("right_hand_target");
case ENamedClusterComponent::NCC_SHUTTERGLASSES:
return GetClusterComponent("shutter_glasses");
case ENamedClusterComponent::NCC_ROLV_ORIGIN:
return GetClusterComponent("rolv_origin");
case ENamedClusterComponent::NCC_FLYSTICK:
return GetClusterComponent("flystick");
case ENamedClusterComponent::NCC_CALIBRATIO:
return GetClusterComponent("calibratio");
case ENamedClusterComponent::NCC_TRACKING_ORIGIN:
USceneComponent* Result;
if ((Result = GetClusterComponent("cave_origin")))
return Result;
if ((Result = GetClusterComponent("rolv_origin")))
return Result;
if ((Result = GetClusterComponent("tdw_origin_floor")))
return Result;
return nullptr;
default:
return nullptr;
}
return 0;
}
void URWTHVRUtilities::ShowErrorAndQuit(UWorld* WorldContext, const FString& Message)
......
......@@ -6,10 +6,6 @@
#include "LiveLinkRole.h"
#include "Pawn/Navigation/CollisionHandlingMovement.h"
#if 0
#include "Components/DisplayClusterSceneComponentSyncParent.h"
#endif
#include "RWTHVRPawn.generated.h"
class UInputMappingContext;
......@@ -29,6 +25,8 @@ class RWTHVRTOOLKIT_API ARWTHVRPawn : public APawn
public:
ARWTHVRPawn(const FObjectInitializer& ObjectInitializer);
virtual void BeginPlay() override;
virtual void Tick(float DeltaSeconds) override;
virtual void NotifyControllerChanged() override;
......@@ -56,7 +54,7 @@ public:
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|Camera")
UCameraComponent* HeadCameraComponent;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn|Camera")
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = "Pawn")
USceneComponent* SyncComponent;
// LiveLink functionality
......
......@@ -2,7 +2,6 @@
#include "CoreMinimal.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "UObject/ConstructorHelpers.h"
#include "RWTHVRUtilities.generated.h"
......@@ -12,33 +11,6 @@
*/
DECLARE_LOG_CATEGORY_EXTERN(Toolkit, Log, All);
UENUM(BlueprintType)
enum class ENamedClusterComponent : uint8
{
/* CAVE Specific */
NCC_CAVE_ORIGIN UMETA(DisplayName = "CAVE Origin"),
NCC_CAVE_CENTER UMETA(DisplayName = "CAVE Center"),
NCC_CAVE_LHT UMETA(DisplayName = "CAVE Left Hand Target"),
NCC_CAVE_RHT UMETA(DisplayName = "CAVE Right Hand Target"),
/* ROLV Specific */
NCC_ROLV_ORIGIN UMETA(DisplayName = "ROLV Origin"),
/* Non Specific */
NCC_CALIBRATIO UMETA(DisplayName = "Calibratio Motion to Photon Measurement Device"),
NCC_SHUTTERGLASSES UMETA(DisplayName = "CAVE/ROLV/TDW Shutter Glasses"),
NCC_FLYSTICK UMETA(DisplayName = "CAVE/ROLV/TDW Flystick"),
NCC_TRACKING_ORIGIN UMETA(DisplayName = "CAVE/ROLV/TDW Origin")
};
UENUM()
enum class EEyeStereoOffset
{
None,
Left,
Right
};
UCLASS()
class RWTHVRTOOLKIT_API URWTHVRUtilities : public UBlueprintFunctionLibrary
{
......@@ -48,37 +20,16 @@ public:
UFUNCTION(BlueprintPure, Category = "DisplayCluster|Platform")
static bool IsDesktopMode();
UFUNCTION(BlueprintPure, Category = "DisplayCluster|Platform")
static bool IsRoomMountedMode();
UFUNCTION(BlueprintPure, Category = "DisplayCluster|Platform")
static bool IsHeadMountedMode();
UFUNCTION(BlueprintPure, Category = "DisplayCluster|Platform")
static bool IsCave();
static bool IsRoomMountedMode();
UFUNCTION(BlueprintPure, Category = "DisplayCluster|Platform")
static bool IsRolv();
UFUNCTION(BlueprintPure, Category = "DisplayCluster")
static bool IsPrimaryNode();
UFUNCTION(BlueprintPure, Category = "DisplayCluster")
static bool IsSecondaryNode();
UFUNCTION(BlueprintPure, Category = "DisplayCluster")
static FString GetNodeName();
/* Distance in meters */
UFUNCTION(BlueprintPure, Category = "DisplayCluster")
static float GetEyeDistance();
UFUNCTION(BlueprintPure, Category = "DisplayCluster")
static EEyeStereoOffset GetNodeEyeType();
//Get Component of Display Cluster by it's name, which is specified in the nDisplay config
UE_DEPRECATED(5.4, "GetClusterComponent has been removed because it is obsolete.")
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "DisplayCluster", meta = (DeprecatedFunction))
static USceneComponent* GetClusterComponent(const FString& Name);
UE_DEPRECATED(5.4, "GetNamedClusterComponent has been removed because it is obsolete.")
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "DisplayCluster", meta = (DeprecatedFunction))
static USceneComponent* GetNamedClusterComponent(const ENamedClusterComponent& Component);
UFUNCTION(BlueprintCallable)
static void ShowErrorAndQuit(UWorld* WorldContext, const FString& Message);
};
......@@ -50,9 +50,16 @@ public class RWTHVRToolkit : ModuleRules
new string[]{}
);
PublicDefinitions.Add(IsPluginEnabledForTarget("nDisplay", base.Target)
? "PLATFORM_SUPPORTS_NDISPLAY=1"
: "PLATFORM_SUPPORTS_NDISPLAY=0");
if (IsPluginEnabledForTarget("RWTHVRCluster", base.Target))
{
PrivateDependencyModuleNames.Add("RWTHVRCluster");
PrivateDependencyModuleNames.Add("DisplayCluster");
PublicDefinitions.Add("PLATFORM_SUPPORTS_CLUSTER=1");
}
else
{
PublicDefinitions.Add("PLATFORM_SUPPORTS_CLUSTER=0");
}
}
private static bool IsPluginEnabledForTarget(string PluginName, ReadOnlyTargetRules Target)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment