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
Branches
Tags
1 merge request!36Huge reformatting / cosmetic fixes commit.
Showing
with 295 additions and 248 deletions
......@@ -3,7 +3,7 @@
#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 ULocalPlayer* LP = PlayerController ? PlayerController->GetLocalPlayer() : nullptr;
......
......@@ -7,6 +7,7 @@
#include "Pawn/InputExtensionInterface.h"
#include "MovementComponentBase.generated.h"
class AVirtualRealityPawn;
/**
*
*/
......@@ -16,19 +17,21 @@ class RWTHVRTOOLKIT_API UMovementComponentBase : public UActorComponent, public
GENERATED_BODY()
public:
virtual void SetupPlayerInput(UInputComponent* PlayerInputComponent) override;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "VR Movement")
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;
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;
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;
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input|Actions")
......@@ -54,7 +57,6 @@ public:
void EndDesktopRotation();
protected:
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Category = "VR Movement|Input")
class UInputMappingContext* IMCRotation;
......
......@@ -3,7 +3,6 @@
#include "Pawn/ReplicatedMotionControllerComponent.h"
#include "Net/UnrealNetwork.h"
UReplicatedMotionControllerComponent::UReplicatedMotionControllerComponent()
......@@ -54,7 +53,8 @@ void UReplicatedMotionControllerComponent::TickComponent(float DeltaTime, ELevel
UpdateState(DeltaTime);
}
void UReplicatedMotionControllerComponent::GetLifetimeReplicatedProps(TArray< class FLifetimeProperty >& OutLifetimeProps) const
void UReplicatedMotionControllerComponent::GetLifetimeReplicatedProps(
TArray<class FLifetimeProperty>& OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
......@@ -67,7 +67,8 @@ void UReplicatedMotionControllerComponent::GetLifetimeReplicatedProps(TArray< cl
DOREPLIFETIME(UReplicatedMotionControllerComponent, ControllerNetUpdateRate);
}
void UReplicatedMotionControllerComponent::SendControllerTransform_ServerRpc_Implementation(FVRTransformRep NewTransform)
void UReplicatedMotionControllerComponent::SendControllerTransform_ServerRpc_Implementation(
FVRTransformRep NewTransform)
{
// Store new transform and trigger OnRep_Function
ReplicatedTransform = NewTransform;
......
......@@ -147,7 +147,8 @@ void UTeleportationComponent::UpdateTeleportTrace(const FInputActionValue& Value
{
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
......@@ -155,7 +156,8 @@ bool UTeleportationComponent::IsValidTeleportLocation(const FHitResult& Hit, FVe
UNavigationSystemV1* NavSys = FNavigationSystem::GetCurrent<UNavigationSystemV1>(GetWorld());
const FNavAgentProperties& AgentProps = FNavAgentProperties(15, 160);
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;
return bProjectPoint /*&& Hit.IsValidBlockingHit()*/;
}
......@@ -173,4 +175,3 @@ void UTeleportationComponent::OnEndTeleportTrace(const FInputActionValue& Value)
bValidTeleportLocation = false;
VRPawn->TeleportTo(FinalTeleportLocation, VRPawn->GetActorRotation());
}

#include "Pawn/VRPawnMovement.h"
#include "Pawn/VRPawnMovement.h"
#include "DrawDebugHelpers.h"
#include "Kismet/KismetSystemLibrary.h"
......@@ -10,7 +9,8 @@ UVRPawnMovement::UVRPawnMovement(const FObjectInitializer& ObjectInitializer) :
CapsuleColliderComponent = CreateDefaultSubobject<UCapsuleComponent>(TEXT("CapsuleCollider"));
CapsuleColliderComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
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);
//set some defaults for the UFloatingPawnMovement component, which are more reasonable for usage in VR
......@@ -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();
FVector InputVector = GetPendingInputVector();
......@@ -52,7 +53,8 @@ void UVRPawnMovement::TickComponent(float DeltaTime, enum ELevelTick TickType, F
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);
if (SafeSteeringInput != InputVector)
{
......@@ -89,9 +91,8 @@ void UVRPawnMovement::SetHeadComponent(USceneComponent* NewHeadComponent)
CapsuleColliderComponent->SetWorldLocation(FVector(0.0f, 0.0f, -HalfHeight));
}
void UVRPawnMovement::SetCapsuleColliderToUserSize()
void UVRPawnMovement::SetCapsuleColliderToUserSize() const
{
// the collider should be placed
// between head and floor + MaxStepHeight
// head
......@@ -125,7 +126,8 @@ void UVRPawnMovement::SetCapsuleColliderToUserSize()
CapsuleColliderComponent->SetCapsuleSize(CapsuleRadius, ColliderHalfHeight);
}
CapsuleColliderComponent->SetWorldLocation(HeadComponent->GetComponentLocation() - FVector(0, 0, ColliderHalfHeight));
CapsuleColliderComponent->SetWorldLocation(
HeadComponent->GetComponentLocation() - FVector(0, 0, ColliderHalfHeight));
}
else
{
......@@ -173,7 +175,6 @@ void UVRPawnMovement::CheckForPhysWalkingCollision()
FVector UVRPawnMovement::GetCollisionSafeVirtualSteeringVec(FVector InputVector, float DeltaTime)
{
const float SafetyFactor = 3.0f; //so we detect collision a bit earlier
const FVector CapsuleLocation = CapsuleColliderComponent->GetComponentLocation();
FVector ProbePosition = SafetyFactor * InputVector.GetSafeNormal() * GetMaxSpeed() * DeltaTime + CapsuleLocation;
......@@ -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;
//UE_LOG(LogTemp, Warning, TEXT("Capsule from %s to %s"), *Start.ToString(), *End.ToString())
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;
}
......@@ -277,7 +281,10 @@ FVector UVRPawnMovement::GetOverlapResolveDirection()
TArray<UPrimitiveComponent*> OverlappingComponents;
TArray<TEnumAsByte<EObjectTypeQuery>> traceObjectTypes;
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;
......@@ -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
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;
}
return ResolveVector;
......
......@@ -4,11 +4,11 @@
void FRWTHVRToolkitModule::StartupModule()
{
IModularFeatures& ModularFeatures = IModularFeatures::Get();
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));
LiveLinkMotionController = MakeUnique<FLiveLinkMotionControllerFix>(*LiveLinkClient);
LiveLinkMotionController->RegisterController();
......@@ -24,7 +24,6 @@ void FRWTHVRToolkitModule::ShutdownModule()
LiveLinkMotionController->UnregisterController();
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FRWTHVRToolkitModule, RWTHVRToolkit)
#include "UI/ExternalImage.h"
#include "Interfaces/IHttpResponse.h"
#include "HttpModule.h"
#include "Interfaces/IHttpResponse.h"
#include "Misc/FileHelper.h"
#include "Runtime/ImageWrapper/Public/IImageWrapperModule.h"
UExternalImage::UExternalImage(){}
UExternalImage::UExternalImage()
{
}
void UExternalImage::LoadImageFromURL(const FString& ImageURL)
{
......@@ -73,11 +75,13 @@ bool UExternalImage::LoadCompressedDataIntoTexture2D(const TArray<uint8>& InComp
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();
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()))
{
......@@ -87,7 +91,8 @@ void UExternalImage::LoadDataFromURL(const FString& ImageURL, TArray<uint8>& Out
}
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
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();
}
#include "Utility/VirtualRealityUtilities.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 "DisplayClusterRootActor.h"
#include "DisplayClusterConfigurationTypes.h"
#include "Game/IDisplayClusterGameManager.h"
#include "IDisplayCluster.h"
#endif
#include "Engine/Engine.h"
#include "IXRTrackingSystem.h"
#include "IHeadMountedDisplay.h"
#include "AudioDevice.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "IHeadMountedDisplay.h"
#include "IXRTrackingSystem.h"
#include "Engine/Engine.h"
#include "Engine/LocalPlayer.h"
#include "Kismet/GameplayStatics.h"
#include "Pawn/VirtualRealityPawn.h"
DEFINE_LOG_CATEGORY(Toolkit);
......@@ -64,7 +61,8 @@ bool UVirtualRealityUtilities::IsTdw()
const UDisplayClusterConfigurationData* ClusterConfig = IDisplayCluster::Get().GetConfigMgr()->GetConfig();
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
return false;
#endif
......@@ -137,7 +135,9 @@ EEyeStereoOffset UVirtualRealityUtilities::GetNodeEyeType()
{
#if PLATFORM_SUPPORTS_NDISPLAY
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
return EDisplayClusterEyeStereoOffset::None;
#endif
......@@ -146,7 +146,7 @@ EEyeStereoOffset UVirtualRealityUtilities::GetNodeEyeType()
USceneComponent* UVirtualRealityUtilities::GetClusterComponent(const FString& Name)
{
#if PLATFORM_SUPPORTS_NDISPLAY
ADisplayClusterRootActor* RootActor = IDisplayCluster::Get().GetGameMgr()->GetRootActor();
const ADisplayClusterRootActor* RootActor = IDisplayCluster::Get().GetGameMgr()->GetRootActor();
return (RootActor) ? RootActor->GetComponentByName<USceneComponent>(Name) : nullptr;
#else
return nullptr;
......@@ -185,5 +185,4 @@ void UVirtualRealityUtilities::ShowErrorAndQuit(UWorld* WorldContext, const FStr
FMessageDialog::Open(EAppMsgType::Ok, FText::FromString(Message), Title);
#endif
UKismetSystemLibrary::QuitGame(WorldContext, nullptr, EQuitPreference::Quit, false);
}
......@@ -21,7 +21,6 @@ public:
UClientTransformReplication();
protected:
/*
* 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
......@@ -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).
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "Networking", meta = (ClampMin = "0", UIMin = "0"))
UPROPERTY(EditAnywhere, BlueprintReadWrite, Replicated, Category = "Networking",
meta = (ClampMin = "0", UIMin = "0"))
float ControllerNetUpdateRate;
// Accumulates time until next send
......
......@@ -28,7 +28,6 @@ private:
void SetPlayerType(EPlayerType NewPlayerType);
public:
UFUNCTION(BlueprintGetter)
EPlayerType GetPlayerType() const
{
......
......@@ -33,7 +33,10 @@ class FLiveLinkMotionControllerFix : public IMotionController
// MotionSource name for interacting with Motion Controller system
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
......@@ -43,7 +46,8 @@ public:
FLiveLinkMotionControllerFix(FLiveLinkClient& InClient) : Client(InClient)
{
BuildSourceData();
OnSubjectsChangedHandle = Client.OnLiveLinkSubjectsChanged().AddRaw(this, &FLiveLinkMotionControllerFix::OnSubjectsChangedHandler);
OnSubjectsChangedHandle = Client.OnLiveLinkSubjectsChanged().AddRaw(
this, &FLiveLinkMotionControllerFix::OnSubjectsChangedHandler);
WildcardSource = FGuid::NewGuid();
}
......@@ -63,14 +67,17 @@ public:
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);
FLiveLinkSubjectFrameData 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();
OutOrientation = TransformFrameData->Transform.GetRotation().Rotator();
......@@ -80,21 +87,39 @@ public:
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;
OutbProvidedAngularVelocity = 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;
OutbProvidedLinearVelocity = false;
OutbProvidedAngularVelocity = 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
......@@ -121,7 +146,8 @@ public:
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);
......@@ -163,13 +189,18 @@ public:
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);
}
{
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
......@@ -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:
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)
{
return EnumeratedSource->SubjectKey;
......
......@@ -8,9 +8,11 @@
#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, const FInputActionValue&, Value);
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOnClicktEnd, USceneComponent*, TriggeredComponent,
const FInputActionValue&, Value);
UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class RWTHVRTOOLKIT_API UClickBehaviour : public USceneComponent
......@@ -23,18 +25,19 @@ public:
UPROPERTY(BlueprintAssignable)
FOnClickStart OnClickStartEvent;
UPROPERTY(BlueprintAssignable)
FOnClicktEnd OnClickEndEvent;
protected:
UFUNCTION()
virtual void OnClickStart(USceneComponent* TriggeredComponent, const FInputActionValue& Value);
UFUNCTION()
virtual void OnClickEnd(USceneComponent* TriggeredComponent, const FInputActionValue& Value);
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)
class RWTHVRTOOLKIT_API UClickable : public UInterface
{
// has to be empty, this is Unreals syntax to make it visible in blueprints
GENERATED_UINTERFACE_BODY()
GENERATED_BODY()
};
class RWTHVRTOOLKIT_API IClickable
{
GENERATED_IINTERFACE_BODY()
GENERATED_BODY()
public:
// function that will be called when clickable actor got clicked, and passed the world pos of the click
UFUNCTION(BlueprintNativeEvent, BlueprintCallable, Category = Gameplay)
void OnClick(FVector WorldPositionOfClick);
};
......@@ -4,12 +4,13 @@
#include "CoreMinimal.h"
#include "Components/SceneComponent.h"
#include "Pawn/InputExtensionInterface.h"
#include "GrabComponent.generated.h"
class UGrabbableComponent;
UCLASS(Abstract, Blueprintable)
class RWTHVRTOOLKIT_API UGrabComponent : public USceneComponent
class RWTHVRTOOLKIT_API UGrabComponent : public USceneComponent, public IInputExtensionInterface
{
GENERATED_BODY()
......@@ -17,7 +18,8 @@ public:
// Sets default values for this component's properties
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")
class UInputMappingContext* IMCGrab;
......@@ -31,14 +33,9 @@ public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Grabbing")
bool bShowDebugTrace = false;
protected:
// Called when the game starts
virtual void BeginPlay() override;
virtual void SetupPlayerInput(UInputComponent* PlayerInputComponent) override;
private:
void SetupInputActions();
UFUNCTION()
void OnBeginGrab(const FInputActionValue& Value);
......@@ -50,6 +47,4 @@ private:
UPROPERTY()
TArray<UGrabbableComponent*> CurrentGrabbableInRange;
};
......@@ -11,12 +11,12 @@ UINTERFACE(BlueprintType)
class RWTHVRTOOLKIT_API UGrabable : public UInterface
{
// has to be empty, this is Unreals syntax to make it visible in blueprints
GENERATED_UINTERFACE_BODY()
GENERATED_BODY()
};
class RWTHVRTOOLKIT_API IGrabable
{
GENERATED_IINTERFACE_BODY()
GENERATED_BODY()
public:
// 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