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

Huge reformatting / cosmetic fixes commit.

parent ce188108
No related branches found
No related tags found
1 merge request!36Huge reformatting / cosmetic fixes commit.
Showing
with 295 additions and 248 deletions
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include "Pawn/InputExtensionInterface.h" #include "Pawn/InputExtensionInterface.h"
UEnhancedInputLocalPlayerSubsystem* IInputExtensionInterface::GetEnhancedInputLocalPlayerSubsystem(APawn* Pawn) const UEnhancedInputLocalPlayerSubsystem* IInputExtensionInterface::GetEnhancedInputLocalPlayerSubsystem(const APawn* Pawn) const
{ {
const APlayerController* PlayerController = Pawn ? Cast<APlayerController>(Pawn->GetController()) : nullptr; const APlayerController* PlayerController = Pawn ? Cast<APlayerController>(Pawn->GetController()) : nullptr;
const ULocalPlayer* LP = PlayerController ? PlayerController->GetLocalPlayer() : nullptr; const ULocalPlayer* LP = PlayerController ? PlayerController->GetLocalPlayer() : nullptr;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "Pawn/InputExtensionInterface.h" #include "Pawn/InputExtensionInterface.h"
#include "MovementComponentBase.generated.h" #include "MovementComponentBase.generated.h"
class AVirtualRealityPawn;
/** /**
* *
*/ */
...@@ -16,19 +17,21 @@ class RWTHVRTOOLKIT_API UMovementComponentBase : public UActorComponent, public ...@@ -16,19 +17,21 @@ class RWTHVRTOOLKIT_API UMovementComponentBase : public UActorComponent, public
GENERATED_BODY() GENERATED_BODY()
public: public:
virtual void SetupPlayerInput(UInputComponent* PlayerInputComponent) override; virtual void SetupPlayerInput(UInputComponent* PlayerInputComponent) override;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
bool bAllowTurning = true; bool bAllowTurning = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", meta = (EditCondition = "bAllowTurning")) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning",
meta = (EditCondition = "bAllowTurning"))
bool bSnapTurn = false; bool bSnapTurn = false;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", meta = (EditCondition = "!bSnapTurn && bAllowTurning")) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning",
meta = (EditCondition = "!bSnapTurn && bAllowTurning"))
float TurnRateFactor = 1.0f; float TurnRateFactor = 1.0f;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning", meta = (EditCondition = "bSnapTurn && bAllowTurning", ClampMin = 0, ClampMax = 360)) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement|Turning",
meta = (EditCondition = "bSnapTurn && bAllowTurning", ClampMin = 0, ClampMax = 360))
float SnapTurnAngle = 22.5; float SnapTurnAngle = 22.5;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions")
...@@ -54,7 +57,6 @@ public: ...@@ -54,7 +57,6 @@ public:
void EndDesktopRotation(); void EndDesktopRotation();
protected: protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input") UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input")
class UInputMappingContext* IMCRotation; class UInputMappingContext* IMCRotation;
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
#include "Pawn/ReplicatedMotionControllerComponent.h" #include "Pawn/ReplicatedMotionControllerComponent.h"
#include "Net/UnrealNetwork.h" #include "Net/UnrealNetwork.h"
UReplicatedMotionControllerComponent::UReplicatedMotionControllerComponent() UReplicatedMotionControllerComponent::UReplicatedMotionControllerComponent()
...@@ -54,7 +53,8 @@ void UReplicatedMotionControllerComponent::TickComponent(float DeltaTime, ELevel ...@@ -54,7 +53,8 @@ void UReplicatedMotionControllerComponent::TickComponent(float DeltaTime, ELevel
UpdateState(DeltaTime); UpdateState(DeltaTime);
} }
void UReplicatedMotionControllerComponent::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty >& OutLifetimeProps) const void UReplicatedMotionControllerComponent::GetLifetimeReplicatedProps(
TArray<class FLifetimeProperty>& OutLifetimeProps) const
{ {
Super::GetLifetimeReplicatedProps(OutLifetimeProps); Super::GetLifetimeReplicatedProps(OutLifetimeProps);
...@@ -67,7 +67,8 @@ void UReplicatedMotionControllerComponent::GetLifetimeReplicatedProps(TArray< cl ...@@ -67,7 +67,8 @@ void UReplicatedMotionControllerComponent::GetLifetimeReplicatedProps(TArray< cl
DOREPLIFETIME(UReplicatedMotionControllerComponent, ControllerNetUpdateRate); DOREPLIFETIME(UReplicatedMotionControllerComponent, ControllerNetUpdateRate);
} }
void UReplicatedMotionControllerComponent::SendControllerTransform_ServerRpc_Implementation(FVRTransformRep NewTransform) void UReplicatedMotionControllerComponent::SendControllerTransform_ServerRpc_Implementation(
FVRTransformRep NewTransform)
{ {
// Store new transform and trigger OnRep_Function // Store new transform and trigger OnRep_Function
ReplicatedTransform = NewTransform; ReplicatedTransform = NewTransform;
......
...@@ -147,7 +147,8 @@ void UTeleportationComponent::UpdateTeleportTrace(const FInputActionValue& Value ...@@ -147,7 +147,8 @@ void UTeleportationComponent::UpdateTeleportTrace(const FInputActionValue& Value
{ {
PathPoints.Add(PData.Location); PathPoints.Add(PData.Location);
} }
UNiagaraDataInterfaceArrayFunctionLibrary::SetNiagaraArrayVector(TeleportTraceComponent,FName("User.PointArray"),PathPoints); UNiagaraDataInterfaceArrayFunctionLibrary::SetNiagaraArrayVector(TeleportTraceComponent, FName("User.PointArray"),
PathPoints);
} }
bool UTeleportationComponent::IsValidTeleportLocation(const FHitResult& Hit, FVector& ProjectedLocation) const bool UTeleportationComponent::IsValidTeleportLocation(const FHitResult& Hit, FVector& ProjectedLocation) const
...@@ -155,7 +156,8 @@ bool UTeleportationComponent::IsValidTeleportLocation(const FHitResult& Hit, FVe ...@@ -155,7 +156,8 @@ bool UTeleportationComponent::IsValidTeleportLocation(const FHitResult& Hit, FVe
UNavigationSystemV1* NavSys = FNavigationSystem::GetCurrent<UNavigationSystemV1>(GetWorld()); UNavigationSystemV1* NavSys = FNavigationSystem::GetCurrent<UNavigationSystemV1>(GetWorld());
const FNavAgentProperties& AgentProps = FNavAgentProperties(15, 160); const FNavAgentProperties& AgentProps = FNavAgentProperties(15, 160);
FNavLocation ProjectedNavLocation; 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; ProjectedLocation = ProjectedNavLocation.Location;
return bProjectPoint /*&& Hit.IsValidBlockingHit()*/; return bProjectPoint /*&& Hit.IsValidBlockingHit()*/;
} }
...@@ -173,4 +175,3 @@ void UTeleportationComponent::OnEndTeleportTrace(const FInputActionValue& Value) ...@@ -173,4 +175,3 @@ void UTeleportationComponent::OnEndTeleportTrace(const FInputActionValue& Value)
bValidTeleportLocation = false; bValidTeleportLocation = false;
VRPawn->TeleportTo(FinalTeleportLocation, VRPawn->GetActorRotation()); VRPawn->TeleportTo(FinalTeleportLocation, VRPawn->GetActorRotation());
} }
 #include "Pawn/VRPawnMovement.h"
#include "Pawn/VRPawnMovement.h"
#include "DrawDebugHelpers.h" #include "DrawDebugHelpers.h"
#include "Kismet/KismetSystemLibrary.h" #include "Kismet/KismetSystemLibrary.h"
...@@ -10,7 +9,8 @@ UVRPawnMovement::UVRPawnMovement(const FObjectInitializer& ObjectInitializer) : ...@@ -10,7 +9,8 @@ UVRPawnMovement::UVRPawnMovement(const FObjectInitializer& ObjectInitializer) :
CapsuleColliderComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CapsuleCollider")); CapsuleColliderComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CapsuleCollider"));
CapsuleColliderComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics); CapsuleColliderComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
CapsuleColliderComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap); CapsuleColliderComponent->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Overlap);
CapsuleColliderComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic, ECollisionResponse::ECR_Block); CapsuleColliderComponent->SetCollisionResponseToChannel(ECollisionChannel::ECC_WorldStatic,
ECollisionResponse::ECR_Block);
CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, 80.0f); 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
...@@ -29,8 +29,9 @@ void UVRPawnMovement::BeginPlay() ...@@ -29,8 +29,9 @@ void UVRPawnMovement::BeginPlay()
} }
void UVRPawnMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction){ void UVRPawnMovement::TickComponent(float DeltaTime, enum ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction)
{
SetCapsuleColliderToUserSize(); SetCapsuleColliderToUserSize();
FVector InputVector = GetPendingInputVector(); FVector InputVector = GetPendingInputVector();
...@@ -52,7 +53,8 @@ void UVRPawnMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, F ...@@ -52,7 +53,8 @@ void UVRPawnMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, F
if (NavigationMode == EVRNavigationModes::NAV_FLY || NavigationMode == EVRNavigationModes::NAV_WALK) if (NavigationMode == EVRNavigationModes::NAV_FLY || NavigationMode == EVRNavigationModes::NAV_WALK)
{ {
if(InputVector.Size() > 0.001){ if (InputVector.Size() > 0.001)
{
const FVector SafeSteeringInput = GetCollisionSafeVirtualSteeringVec(InputVector, DeltaTime); const FVector SafeSteeringInput = GetCollisionSafeVirtualSteeringVec(InputVector, DeltaTime);
if (SafeSteeringInput != InputVector) if (SafeSteeringInput != InputVector)
{ {
...@@ -89,9 +91,8 @@ void UVRPawnMovement::SetHeadComponent(USceneComponent* NewHeadComponent) ...@@ -89,9 +91,8 @@ void UVRPawnMovement::SetHeadComponent(USceneComponent* NewHeadComponent)
CapsuleColliderComponent->SetWorldLocation(FVector(0.0f, 0.0f, -HalfHeight)); CapsuleColliderComponent->SetWorldLocation(FVector(0.0f, 0.0f, -HalfHeight));
} }
void UVRPawnMovement::SetCapsuleColliderToUserSize() void UVRPawnMovement::SetCapsuleColliderToUserSize() const
{ {
// the collider should be placed // the collider should be placed
// between head and floor + MaxStepHeight // between head and floor + MaxStepHeight
// head // head
...@@ -125,7 +126,8 @@ void UVRPawnMovement::SetCapsuleColliderToUserSize() ...@@ -125,7 +126,8 @@ void UVRPawnMovement::SetCapsuleColliderToUserSize()
CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, ColliderHalfHeight); CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, ColliderHalfHeight);
} }
CapsuleColliderComponent->SetWorldLocation(HeadComponent->GetComponentLocation() - FVector(0, 0, ColliderHalfHeight)); CapsuleColliderComponent->SetWorldLocation(
HeadComponent->GetComponentLocation() - FVector(0, 0, ColliderHalfHeight));
} }
else else
{ {
...@@ -173,7 +175,6 @@ void UVRPawnMovement::CheckForPhysWalkingCollision() ...@@ -173,7 +175,6 @@ void UVRPawnMovement::CheckForPhysWalkingCollision()
FVector UVRPawnMovement::GetCollisionSafeVirtualSteeringVec(FVector InputVector, float DeltaTime) FVector UVRPawnMovement::GetCollisionSafeVirtualSteeringVec(FVector InputVector, float DeltaTime)
{ {
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(); const FVector CapsuleLocation = CapsuleColliderComponent->GetComponentLocation();
FVector ProbePosition = SafetyFactor * InputVector.GetSafeNormal() * GetMaxSpeed() * DeltaTime + CapsuleLocation; FVector ProbePosition = SafetyFactor * InputVector.GetSafeNormal() * GetMaxSpeed() * DeltaTime + CapsuleLocation;
...@@ -261,14 +262,17 @@ void UVRPawnMovement::ShiftVertically(float Distance, float VerticalAcceleration ...@@ -261,14 +262,17 @@ void UVRPawnMovement::ShiftVertically(float Distance, float VerticalAcceleration
} }
} }
FHitResult UVRPawnMovement::CreateCapsuleTrace(const FVector Start, FVector End, bool DrawDebug) FHitResult UVRPawnMovement::CreateCapsuleTrace(const FVector& Start, const FVector& End, const bool DrawDebug) const
{ {
const EDrawDebugTrace::Type DrawType = DrawDebug ? EDrawDebugTrace::Type::ForDuration : EDrawDebugTrace::Type::None; 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; FHitResult Hit;
UKismetSystemLibrary::CapsuleTraceSingle(GetWorld(), Start, End, CapsuleColliderComponent->GetScaledCapsuleRadius(), CapsuleColliderComponent->GetScaledCapsuleHalfHeight(), UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Visibility), true, ActorsToIgnore, DrawType, Hit, true); UKismetSystemLibrary::CapsuleTraceSingle(GetWorld(), Start, End, CapsuleColliderComponent->GetScaledCapsuleRadius(),
CapsuleColliderComponent->GetScaledCapsuleHalfHeight(),
UEngineTypes::ConvertToTraceType(ECollisionChannel::ECC_Visibility), true,
ActorsToIgnore, DrawType, Hit, true);
return Hit; return Hit;
} }
...@@ -277,7 +281,10 @@ FVector UVRPawnMovement::GetOverlapResolveDirection() ...@@ -277,7 +281,10 @@ FVector UVRPawnMovement::GetOverlapResolveDirection()
TArray<UPrimitiveComponent*> OverlappingComponents; TArray<UPrimitiveComponent*> OverlappingComponents;
TArray<TEnumAsByte<EObjectTypeQuery>> traceObjectTypes; TArray<TEnumAsByte<EObjectTypeQuery>> traceObjectTypes;
traceObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Visibility)); traceObjectTypes.Add(UEngineTypes::ConvertToObjectType(ECollisionChannel::ECC_Visibility));
UKismetSystemLibrary::CapsuleOverlapComponents(GetWorld(), CapsuleColliderComponent->GetComponentLocation(), CapsuleColliderComponent->GetScaledCapsuleRadius(), CapsuleColliderComponent->GetScaledCapsuleHalfHeight(), traceObjectTypes, nullptr, ActorsToIgnore, OverlappingComponents); UKismetSystemLibrary::CapsuleOverlapComponents(GetWorld(), CapsuleColliderComponent->GetComponentLocation(),
CapsuleColliderComponent->GetScaledCapsuleRadius(),
CapsuleColliderComponent->GetScaledCapsuleHalfHeight(),
traceObjectTypes, nullptr, ActorsToIgnore, OverlappingComponents);
FVector ResolveVector = FVector::ZeroVector; FVector ResolveVector = FVector::ZeroVector;
...@@ -285,7 +292,8 @@ FVector UVRPawnMovement::GetOverlapResolveDirection() ...@@ -285,7 +292,8 @@ FVector UVRPawnMovement::GetOverlapResolveDirection()
//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 //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) for (const UPrimitiveComponent* OverlappingComp : OverlappingComponents)
{ {
FHitResult Hit = CreateCapsuleTrace(CapsuleColliderComponent->GetComponentLocation(), OverlappingComp->GetComponentLocation(), false); FHitResult Hit = CreateCapsuleTrace(CapsuleColliderComponent->GetComponentLocation(),
OverlappingComp->GetComponentLocation(), false);
ResolveVector += Hit.ImpactNormal * Hit.PenetrationDepth; ResolveVector += Hit.ImpactNormal * Hit.PenetrationDepth;
} }
return ResolveVector; return ResolveVector;
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
void FRWTHVRToolkitModule::StartupModule() void FRWTHVRToolkitModule::StartupModule()
{ {
IModularFeatures& ModularFeatures = IModularFeatures::Get(); IModularFeatures& ModularFeatures = IModularFeatures::Get();
if (ModularFeatures.IsModularFeatureAvailable(ILiveLinkClient::ModularFeatureName)) if (ModularFeatures.IsModularFeatureAvailable(ILiveLinkClient::ModularFeatureName))
{ {
FLiveLinkClient* LiveLinkClient = static_cast<FLiveLinkClient*>(&IModularFeatures::Get().GetModularFeature<ILiveLinkClient>( FLiveLinkClient* LiveLinkClient = static_cast<FLiveLinkClient*>(&IModularFeatures::Get().GetModularFeature<
ILiveLinkClient>(
ILiveLinkClient::ModularFeatureName)); ILiveLinkClient::ModularFeatureName));
LiveLinkMotionController = MakeUnique<FLiveLinkMotionControllerFix>(*LiveLinkClient); LiveLinkMotionController = MakeUnique<FLiveLinkMotionControllerFix>(*LiveLinkClient);
LiveLinkMotionController->RegisterController(); LiveLinkMotionController->RegisterController();
...@@ -24,7 +24,6 @@ void FRWTHVRToolkitModule::ShutdownModule() ...@@ -24,7 +24,6 @@ void FRWTHVRToolkitModule::ShutdownModule()
LiveLinkMotionController->UnregisterController(); LiveLinkMotionController->UnregisterController();
} }
#undef LOCTEXT_NAMESPACE #undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FRWTHVRToolkitModule, RWTHVRToolkit) IMPLEMENT_MODULE(FRWTHVRToolkitModule, RWTHVRToolkit)
#include "UI/ExternalImage.h" #include "UI/ExternalImage.h"
#include "Interfaces/IHttpResponse.h"
#include "HttpModule.h" #include "HttpModule.h"
#include "Interfaces/IHttpResponse.h"
#include "Misc/FileHelper.h" #include "Misc/FileHelper.h"
#include "Runtime/ImageWrapper/Public/IImageWrapperModule.h" #include "Runtime/ImageWrapper/Public/IImageWrapperModule.h"
UExternalImage::UExternalImage(){} UExternalImage::UExternalImage()
{
}
void UExternalImage::LoadImageFromURL(const FString& ImageURL) void UExternalImage::LoadImageFromURL(const FString& ImageURL)
{ {
...@@ -73,11 +75,13 @@ bool UExternalImage::LoadCompressedDataIntoTexture2D(const TArray<uint8>& InComp ...@@ -73,11 +75,13 @@ bool UExternalImage::LoadCompressedDataIntoTexture2D(const TArray<uint8>& InComp
return true; return true;
} }
void UExternalImage::LoadDataFromURL(const FString& ImageURL, TArray<uint8>& OutCompressedData, TFunction<void()> OnSuccessCallback) void UExternalImage::LoadDataFromURL(const FString& ImageURL, TArray<uint8>& OutCompressedData,
TFunction<void()> OnSuccessCallback)
{ {
TSharedRef<IHttpRequest, ESPMode::ThreadSafe> Request = FHttpModule::Get().CreateRequest(); TSharedRef<IHttpRequest, ESPMode::ThreadSafe> Request = FHttpModule::Get().CreateRequest();
Request->OnProcessRequestComplete().BindLambda([OnSuccessCallback, &OutCompressedData](FHttpRequestPtr Request, FHttpResponsePtr Response, bool) Request->OnProcessRequestComplete().BindLambda(
[OnSuccessCallback, &OutCompressedData](FHttpRequestPtr Request, FHttpResponsePtr Response, bool)
{ {
if (Response.IsValid() && EHttpResponseCodes::IsOk(Response->GetResponseCode())) if (Response.IsValid() && EHttpResponseCodes::IsOk(Response->GetResponseCode()))
{ {
...@@ -87,7 +91,8 @@ void UExternalImage::LoadDataFromURL(const FString& ImageURL, TArray<uint8>& Out ...@@ -87,7 +91,8 @@ void UExternalImage::LoadDataFromURL(const FString& ImageURL, TArray<uint8>& Out
} }
else else
{ {
UE_LOG(LogTemp, Log, TEXT("UExternalyLoadedImage Request unsucessful (%d): %s"), Response->GetResponseCode(), *Request->GetURL()); UE_LOG(LogTemp, Log, TEXT("UExternalyLoadedImage Request unsucessful (%d): %s"),
Response->GetResponseCode(), *Request->GetURL());
} }
}); });
...@@ -96,7 +101,8 @@ void UExternalImage::LoadDataFromURL(const FString& ImageURL, TArray<uint8>& Out ...@@ -96,7 +101,8 @@ void UExternalImage::LoadDataFromURL(const FString& ImageURL, TArray<uint8>& Out
Request->ProcessRequest(); Request->ProcessRequest();
} }
void UExternalImage::LoadDataFromFile(const FString& ImagePath, TArray<uint8>& OutCompressedData, TFunction<void()> OnSuccessCallback) void UExternalImage::LoadDataFromFile(const FString& ImagePath, TArray<uint8>& OutCompressedData,
TFunction<void()> OnSuccessCallback)
{ {
if (FFileHelper::LoadFileToArray(OutCompressedData, *ImagePath)) OnSuccessCallback(); if (FFileHelper::LoadFileToArray(OutCompressedData, *ImagePath)) OnSuccessCallback();
} }
#include "Utility/VirtualRealityUtilities.h" #include "Utility/VirtualRealityUtilities.h"
#if PLATFORM_SUPPORTS_NDISPLAY #if PLATFORM_SUPPORTS_NDISPLAY
#include "DisplayClusterConfigurationTypes.h"
#include "DisplayClusterRootActor.h"
#include "IDisplayCluster.h"
#include "Cluster/IDisplayClusterClusterManager.h" #include "Cluster/IDisplayClusterClusterManager.h"
#include "Components/DisplayClusterCameraComponent.h" #include "Components/DisplayClusterCameraComponent.h"
#include "Config/IDisplayClusterConfigManager.h" #include "Config/IDisplayClusterConfigManager.h"
#include "DisplayClusterRootActor.h"
#include "DisplayClusterConfigurationTypes.h"
#include "Game/IDisplayClusterGameManager.h" #include "Game/IDisplayClusterGameManager.h"
#include "IDisplayCluster.h"
#endif #endif
#include "Engine/Engine.h"
#include "IXRTrackingSystem.h"
#include "IHeadMountedDisplay.h"
#include "AudioDevice.h" #include "AudioDevice.h"
#include "EnhancedInputComponent.h" #include "IHeadMountedDisplay.h"
#include "EnhancedInputSubsystems.h" #include "IXRTrackingSystem.h"
#include "Engine/Engine.h"
#include "Engine/LocalPlayer.h" #include "Engine/LocalPlayer.h"
#include "Kismet/GameplayStatics.h" #include "Kismet/GameplayStatics.h"
#include "Pawn/VirtualRealityPawn.h"
DEFINE_LOG_CATEGORY(Toolkit); DEFINE_LOG_CATEGORY(Toolkit);
...@@ -64,7 +61,8 @@ bool UVirtualRealityUtilities::IsTdw() ...@@ -64,7 +61,8 @@ bool UVirtualRealityUtilities::IsTdw()
const UDisplayClusterConfigurationData* ClusterConfig = IDisplayCluster::Get().GetConfigMgr()->GetConfig(); const UDisplayClusterConfigurationData* ClusterConfig = IDisplayCluster::Get().GetConfigMgr()->GetConfig();
return ClusterConfig->CustomParameters.Contains("Hardware_Platform") return ClusterConfig->CustomParameters.Contains("Hardware_Platform")
&& ClusterConfig->CustomParameters.Find("Hardware_Platform")->Equals("TiledDisplayWall", ESearchCase::IgnoreCase); && ClusterConfig->CustomParameters.Find("Hardware_Platform")->Equals(
"TiledDisplayWall", ESearchCase::IgnoreCase);
#else #else
return false; return false;
#endif #endif
...@@ -137,7 +135,9 @@ EEyeStereoOffset UVirtualRealityUtilities::GetNodeEyeType() ...@@ -137,7 +135,9 @@ EEyeStereoOffset UVirtualRealityUtilities::GetNodeEyeType()
{ {
#if PLATFORM_SUPPORTS_NDISPLAY #if PLATFORM_SUPPORTS_NDISPLAY
ADisplayClusterRootActor* RootActor = IDisplayCluster::Get().GetGameMgr()->GetRootActor(); ADisplayClusterRootActor* RootActor = IDisplayCluster::Get().GetGameMgr()->GetRootActor();
return static_cast<EEyeStereoOffset>((RootActor) ? RootActor->GetDefaultCamera()->GetStereoOffset() : EDisplayClusterEyeStereoOffset::None); return static_cast<EEyeStereoOffset>((RootActor)
? RootActor->GetDefaultCamera()->GetStereoOffset()
: EDisplayClusterEyeStereoOffset::None);
#else #else
return EDisplayClusterEyeStereoOffset::None; return EDisplayClusterEyeStereoOffset::None;
#endif #endif
...@@ -146,7 +146,7 @@ EEyeStereoOffset UVirtualRealityUtilities::GetNodeEyeType() ...@@ -146,7 +146,7 @@ EEyeStereoOffset UVirtualRealityUtilities::GetNodeEyeType()
USceneComponent* UVirtualRealityUtilities::GetClusterComponent(const FString& Name) USceneComponent* UVirtualRealityUtilities::GetClusterComponent(const FString& Name)
{ {
#if PLATFORM_SUPPORTS_NDISPLAY #if PLATFORM_SUPPORTS_NDISPLAY
ADisplayClusterRootActor* RootActor = IDisplayCluster::Get().GetGameMgr()->GetRootActor(); const ADisplayClusterRootActor* RootActor = IDisplayCluster::Get().GetGameMgr()->GetRootActor();
return (RootActor) ? RootActor->GetComponentByName<USceneComponent>(Name) : nullptr; return (RootActor) ? RootActor->GetComponentByName<USceneComponent>(Name) : nullptr;
#else #else
return nullptr; return nullptr;
...@@ -185,5 +185,4 @@ void UVirtualRealityUtilities::ShowErrorAndQuit(UWorld* WorldContext, const FStr ...@@ -185,5 +185,4 @@ void UVirtualRealityUtilities::ShowErrorAndQuit(UWorld* WorldContext, const FStr
FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(Message), Title); FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(Message), Title);
#endif #endif
UKismetSystemLibrary::QuitGame(WorldContext, nullptr, EQuitPreference::Quit, false); UKismetSystemLibrary::QuitGame(WorldContext, nullptr, EQuitPreference::Quit, false);
} }
...@@ -21,7 +21,6 @@ public: ...@@ -21,7 +21,6 @@ public:
UClientTransformReplication(); UClientTransformReplication();
protected: protected:
/* /*
* For now, replicate in a naive sending every x ms if the transform has changed. * 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 * This is way overkill, as we should only be sending input. However, I am not yet fully sure how
...@@ -36,7 +35,8 @@ protected: ...@@ -36,7 +35,8 @@ protected:
///////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////
// 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")) UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "Networking",
meta = (ClampMin = "0", UIMin = "0"))
float ControllerNetUpdateRate; float ControllerNetUpdateRate;
// Accumulates time until next send // Accumulates time until next send
......
...@@ -28,7 +28,6 @@ private: ...@@ -28,7 +28,6 @@ private:
void SetPlayerType(EPlayerType NewPlayerType); void SetPlayerType(EPlayerType NewPlayerType);
public: public:
UFUNCTION(BlueprintGetter) UFUNCTION(BlueprintGetter)
EPlayerType GetPlayerType() const EPlayerType GetPlayerType() const
{ {
......
...@@ -33,7 +33,10 @@ class FLiveLinkMotionControllerFix : public IMotionController ...@@ -33,7 +33,10 @@ class FLiveLinkMotionControllerFix : public IMotionController
// MotionSource name for interacting with Motion Controller system // MotionSource name for interacting with Motion Controller system
FName MotionSource; FName MotionSource;
FLiveLinkMotionControllerEnumeratedSource(const FLiveLinkSubjectKey& Key, FName MotionSourceName) : SubjectKey(Key), MotionSource(MotionSourceName) {} FLiveLinkMotionControllerEnumeratedSource(const FLiveLinkSubjectKey& Key, FName MotionSourceName) :
SubjectKey(Key), MotionSource(MotionSourceName)
{
}
}; };
// Built array of Live Link Sources to give to Motion Controller system // Built array of Live Link Sources to give to Motion Controller system
...@@ -43,7 +46,8 @@ public: ...@@ -43,7 +46,8 @@ public:
FLiveLinkMotionControllerFix(FLiveLinkClient& InClient) : Client(InClient) FLiveLinkMotionControllerFix(FLiveLinkClient& InClient) : Client(InClient)
{ {
BuildSourceData(); BuildSourceData();
OnSubjectsChangedHandle = Client.OnLiveLinkSubjectsChanged().AddRaw(this, &FLiveLinkMotionControllerFix::OnSubjectsChangedHandler); OnSubjectsChangedHandle = Client.OnLiveLinkSubjectsChanged().AddRaw(
this, &FLiveLinkMotionControllerFix::OnSubjectsChangedHandler);
WildcardSource = FGuid::NewGuid(); WildcardSource = FGuid::NewGuid();
} }
...@@ -63,14 +67,17 @@ public: ...@@ -63,14 +67,17 @@ public:
IModularFeatures::Get().UnregisterModularFeature(GetModularFeatureName(), this); IModularFeatures::Get().UnregisterModularFeature(GetModularFeatureName(), this);
} }
virtual bool GetControllerOrientationAndPosition(const int32 ControllerIndex, const FName MotionSource, FRotator& OutOrientation, FVector& OutPosition, float) const override virtual bool GetControllerOrientationAndPosition(const int32 ControllerIndex, const FName MotionSource,
FRotator& OutOrientation, FVector& OutPosition,
float) const override
{ {
FLiveLinkSubjectKey SubjectKey = GetSubjectKeyFromMotionSource(MotionSource); FLiveLinkSubjectKey SubjectKey = GetSubjectKeyFromMotionSource(MotionSource);
FLiveLinkSubjectFrameData FrameData; FLiveLinkSubjectFrameData FrameData;
if (Client.EvaluateFrame_AnyThread(SubjectKey.SubjectName, ULiveLinkTransformRole::StaticClass(), 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(); OutPosition = TransformFrameData->Transform.GetLocation();
OutOrientation = TransformFrameData->Transform.GetRotation().Rotator(); OutOrientation = TransformFrameData->Transform.GetRotation().Rotator();
...@@ -80,21 +87,39 @@ public: ...@@ -80,21 +87,39 @@ public:
return false; 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; OutbProvidedLinearVelocity = false;
OutbProvidedAngularVelocity = false; OutbProvidedAngularVelocity = false;
OutbProvidedLinearAcceleration = false; OutbProvidedLinearAcceleration = false;
return GetControllerOrientationAndPosition(ControllerIndex, MotionSource, OutOrientation, OutPosition, WorldToMetersScale); return GetControllerOrientationAndPosition(ControllerIndex, MotionSource, OutOrientation, OutPosition,
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; OutTimeWasUsed = false;
OutbProvidedLinearVelocity = false; OutbProvidedLinearVelocity = false;
OutbProvidedAngularVelocity = false; OutbProvidedAngularVelocity = false;
OutbProvidedLinearAcceleration = false; OutbProvidedLinearAcceleration = false;
return GetControllerOrientationAndPosition(ControllerIndex, MotionSource, OutOrientation, OutPosition, WorldToMetersScale); return GetControllerOrientationAndPosition(ControllerIndex, MotionSource, OutOrientation, OutPosition,
WorldToMetersScale);
} }
float GetCustomParameterValue(const FName MotionSource, FName ParameterName, bool& bValueFound) const override float GetCustomParameterValue(const FName MotionSource, FName ParameterName, bool& bValueFound) const override
...@@ -121,7 +146,8 @@ public: ...@@ -121,7 +146,8 @@ public:
return 0.f; 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); FLiveLinkSubjectKey SubjectKey = GetSubjectKeyFromMotionSource(MotionSource);
...@@ -163,13 +189,18 @@ public: ...@@ -163,13 +189,18 @@ public:
for (const FGuid& Source : SourceGuids) 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); Headers.Emplace(Source, SourceName);
} }
{ {
FGuid& CaptureWildcardSource = WildcardSource; FGuid& CaptureWildcardSource = WildcardSource;
Headers.Sort([CaptureWildcardSource](const FHeaderEntry& A, const FHeaderEntry& B) { return A.Key == CaptureWildcardSource || A.Value.CompareToCaseIgnored(B.Value) <= 0; }); Headers.Sort([CaptureWildcardSource](const FHeaderEntry& A, const FHeaderEntry& B)
{
return A.Key == CaptureWildcardSource || A.Value.CompareToCaseIgnored(B.Value) <= 0;
});
} }
//Build EnumeratedSources data //Build EnumeratedSources data
...@@ -201,12 +232,16 @@ public: ...@@ -201,12 +232,16 @@ public:
} }
} }
virtual bool GetHandJointPosition(const FName MotionSource, int jointIndex, FVector& OutPosition) const override { return false; } virtual bool GetHandJointPosition(const FName MotionSource, int jointIndex, FVector& OutPosition) const override
{
return false;
}
private: private:
FLiveLinkSubjectKey GetSubjectKeyFromMotionSource(FName MotionSource) const FLiveLinkSubjectKey GetSubjectKeyFromMotionSource(FName MotionSource) const
{ {
const FLiveLinkMotionControllerEnumeratedSource* EnumeratedSource = EnumeratedSources.FindByPredicate([&](const FLiveLinkMotionControllerEnumeratedSource& Item) { return Item.MotionSource == MotionSource; }); const FLiveLinkMotionControllerEnumeratedSource* EnumeratedSource = EnumeratedSources.FindByPredicate(
[&](const FLiveLinkMotionControllerEnumeratedSource& Item) { return Item.MotionSource == MotionSource; });
if (EnumeratedSource) if (EnumeratedSource)
{ {
return EnumeratedSource->SubjectKey; return EnumeratedSource->SubjectKey;
......
...@@ -8,9 +8,11 @@ ...@@ -8,9 +8,11 @@
#include "ClickBehaviour.generated.h" #include "ClickBehaviour.generated.h"
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnClickStart, USceneComponent*, TriggeredComponent,
const FInputActionValue&, Value);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnClickStart, USceneComponent*, TriggeredComponent, const FInputActionValue&, Value); DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnClicktEnd, USceneComponent*, TriggeredComponent,
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnClicktEnd, USceneComponent*, TriggeredComponent, const FInputActionValue&, Value); const FInputActionValue&, Value);
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class RWTHVRTOOLKIT_API UClickBehaviour : public USceneComponent class RWTHVRTOOLKIT_API UClickBehaviour : public USceneComponent
...@@ -23,18 +25,19 @@ public: ...@@ -23,18 +25,19 @@ public:
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FOnClickStart OnClickStartEvent; FOnClickStart OnClickStartEvent;
UPROPERTY(BlueprintAssignable) UPROPERTY(BlueprintAssignable)
FOnClicktEnd OnClickEndEvent; FOnClicktEnd OnClickEndEvent;
protected: protected:
UFUNCTION() UFUNCTION()
virtual void OnClickStart(USceneComponent* TriggeredComponent, const FInputActionValue& Value); virtual void OnClickStart(USceneComponent* TriggeredComponent, const FInputActionValue& Value);
UFUNCTION() UFUNCTION()
virtual void OnClickEnd(USceneComponent* TriggeredComponent, const FInputActionValue& Value); virtual void OnClickEnd(USceneComponent* TriggeredComponent, const FInputActionValue& Value);
virtual void BeginPlay() override; virtual void BeginPlay() override;
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; virtual void TickComponent(float DeltaTime, ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction) override;
}; };
...@@ -11,16 +11,15 @@ UINTERFACE(BlueprintType) ...@@ -11,16 +11,15 @@ UINTERFACE(BlueprintType)
class RWTHVRTOOLKIT_API UClickable : public UInterface class RWTHVRTOOLKIT_API UClickable : public UInterface
{ {
// has to be empty, this is Unreals syntax to make it visible in blueprints // has to be empty, this is Unreals syntax to make it visible in blueprints
GENERATED_UINTERFACE_BODY() GENERATED_BODY()
}; };
class RWTHVRTOOLKIT_API IClickable class RWTHVRTOOLKIT_API IClickable
{ {
GENERATED_IINTERFACE_BODY() GENERATED_BODY()
public: public:
// function that will be called when clickable actor got clicked, and passed the world pos of the click // function that will be called when clickable actor got clicked, and passed the world pos of the click
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = Gameplay) UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = Gameplay)
void OnClick(FVector WorldPositionOfClick); void OnClick(FVector WorldPositionOfClick);
}; };
...@@ -4,12 +4,13 @@ ...@@ -4,12 +4,13 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "Components/SceneComponent.h" #include "Components/SceneComponent.h"
#include "Pawn/InputExtensionInterface.h"
#include "GrabComponent.generated.h" #include "GrabComponent.generated.h"
class UGrabbableComponent; class UGrabbableComponent;
UCLASS(Abstract, Blueprintable) UCLASS(Abstract, Blueprintable)
class RWTHVRTOOLKIT_API UGrabComponent : public USceneComponent class RWTHVRTOOLKIT_API UGrabComponent : public USceneComponent, public IInputExtensionInterface
{ {
GENERATED_BODY() GENERATED_BODY()
...@@ -17,7 +18,8 @@ public: ...@@ -17,7 +18,8 @@ public:
// Sets default values for this component's properties // Sets default values for this component's properties
UGrabComponent(); UGrabComponent();
virtual void TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override; virtual void TickComponent(float DeltaTime, ELevelTick TickType,
FActorComponentTickFunction* ThisTickFunction) override;
UPROPERTY(EditDefaultsOnly, Category = "Input") UPROPERTY(EditDefaultsOnly, Category = "Input")
class UInputMappingContext* IMCGrab; class UInputMappingContext* IMCGrab;
...@@ -31,14 +33,9 @@ public: ...@@ -31,14 +33,9 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Grabbing") UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Grabbing")
bool bShowDebugTrace = false; bool bShowDebugTrace = false;
virtual void SetupPlayerInput(UInputComponent* PlayerInputComponent) override;
protected:
// Called when the game starts
virtual void BeginPlay() override;
private: private:
void SetupInputActions();
UFUNCTION() UFUNCTION()
void OnBeginGrab(const FInputActionValue& Value); void OnBeginGrab(const FInputActionValue& Value);
...@@ -50,6 +47,4 @@ private: ...@@ -50,6 +47,4 @@ private:
UPROPERTY() UPROPERTY()
TArray<UGrabbableComponent*> CurrentGrabbableInRange; TArray<UGrabbableComponent*> CurrentGrabbableInRange;
}; };
...@@ -11,12 +11,12 @@ UINTERFACE(BlueprintType) ...@@ -11,12 +11,12 @@ UINTERFACE(BlueprintType)
class RWTHVRTOOLKIT_API UGrabable : public UInterface class RWTHVRTOOLKIT_API UGrabable : public UInterface
{ {
// has to be empty, this is Unreals syntax to make it visible in blueprints // has to be empty, this is Unreals syntax to make it visible in blueprints
GENERATED_UINTERFACE_BODY() GENERATED_BODY()
}; };
class RWTHVRTOOLKIT_API IGrabable class RWTHVRTOOLKIT_API IGrabable
{ {
GENERATED_IINTERFACE_BODY() GENERATED_BODY()
public: public:
// function that will be called when grabbed by a pawn // function that will be called when grabbed by a pawn
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment