VRInputConfig and start of VRUtils done
parent
d0cae51cca
commit
8313c57825
|
|
@ -2,17 +2,6 @@
|
|||
# Visual Studio 2015 user specific files
|
||||
.vs/
|
||||
|
||||
#Jetbrains IDE files
|
||||
.idea/
|
||||
.fleet/
|
||||
*.DotSettings
|
||||
|
||||
# VS Code files
|
||||
.vscode/
|
||||
*.code-workspace
|
||||
|
||||
# Linux Makefile
|
||||
Makefile
|
||||
|
||||
# Compiled Object files
|
||||
*.slo
|
||||
|
|
@ -86,3 +75,30 @@ Plugins/*/Intermediate/*
|
|||
# Cache files for the editor to use
|
||||
DerivedDataCache/*
|
||||
|
||||
# Visual Studio 2015+ user-specific files
|
||||
.vs/
|
||||
.vsconfig
|
||||
*.user
|
||||
*.userosscache
|
||||
*.VC.opendb
|
||||
|
||||
# Don't ignore whitelist PakBlacklist-<BuildConfiguration>.txt files
|
||||
!Build/*/
|
||||
Build/*/**
|
||||
!Build/*/PakBlacklist*.txt
|
||||
|
||||
# Don't ignore icon files in Build
|
||||
!Build/**/*.ico
|
||||
|
||||
|
||||
#Files Ignored
|
||||
Makefile.bin
|
||||
Makefile
|
||||
*.directory
|
||||
.idea/*
|
||||
.vscode/*
|
||||
*.code-workspace
|
||||
*.opendb
|
||||
*.DotSettings
|
||||
.fleet/
|
||||
Cooked/*
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
[/Script/EngineSettings.GeneralProjectSettings]
|
||||
ProjectID=B0DD2F214F0AC320FA72EB9C9432375E
|
||||
CopyrightNotice=Copyright Vagabond Rose Interactive, all rights reserved
|
||||
CopyrightNotice=Copyright
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
// Copyright
|
||||
|
||||
|
||||
#include "Input/VRInputComponent.h"
|
||||
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright
|
||||
|
||||
|
||||
#include "Input/VRInputConfig.h"
|
||||
|
||||
UInputAction* UVRInputConfig::FindNativeInputActionForTag(const FGameplayTag& InTag, bool bLogNotFound) const
|
||||
{
|
||||
if (!InTag.IsValid()) return nullptr;
|
||||
|
||||
for (const FVRTagInputAction& Action : NativeInputActions)
|
||||
{
|
||||
if (!Action.IsValid()) continue;
|
||||
|
||||
if (Action.InputAction && Action.InputTag.IsValid())
|
||||
{
|
||||
return Action.InputAction.Get();
|
||||
}
|
||||
}
|
||||
|
||||
if (bLogNotFound)
|
||||
{
|
||||
// TODO: Add logging for VRGAS
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
UInputAction* UVRInputConfig::FindAbilityInputActionForTag(const FGameplayTag& InTag, bool bLogNotFound) const
|
||||
{
|
||||
if (!InTag.IsValid()) return nullptr;
|
||||
|
||||
for (const FVRTagInputAction& Action : AbilityInputActions)
|
||||
{
|
||||
if (!Action.IsValid() && Action.InputTag.IsValid())
|
||||
{
|
||||
return Action.InputAction.Get();
|
||||
}
|
||||
}
|
||||
|
||||
if (bLogNotFound)
|
||||
{
|
||||
// TODO: Add logging for VRGAS
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
// Copyright
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "EnhancedInputComponent.h"
|
||||
#include "VRInputComponent.generated.h"
|
||||
|
||||
|
||||
UCLASS()
|
||||
class VRGAS_API UVRInputComponent : public UEnhancedInputComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
};
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
// Copyright
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameplayTagContainer.h"
|
||||
#include "Engine/DataAsset.h"
|
||||
#include "VRInputConfig.generated.h"
|
||||
|
||||
|
||||
class UInputAction;
|
||||
|
||||
USTRUCT(BlueprintType)
|
||||
struct FVRTagInputAction
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly)
|
||||
TObjectPtr<UInputAction> InputAction = nullptr;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (Categories = "InputTag"))
|
||||
FGameplayTag InputTag;
|
||||
|
||||
bool IsValid() const
|
||||
{
|
||||
return InputTag.IsValid() && InputAction != nullptr;
|
||||
}
|
||||
};
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS(BlueprintType, Const) // Const for now, since we aren't doing anything beyond what lyra does here
|
||||
class VRGAS_API UVRInputConfig : public UDataAsset
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (TitleProperty = "InputAction"))
|
||||
TArray<FVRTagInputAction> NativeInputActions;
|
||||
|
||||
UPROPERTY(EditDefaultsOnly, BlueprintReadOnly, Meta = (TitleProperty = "InputAction"))
|
||||
TArray<FVRTagInputAction> AbilityInputActions;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
UInputAction* FindNativeInputActionForTag(const FGameplayTag& InTag, bool bLogNotFound = true) const;
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "Input")
|
||||
UInputAction* FindAbilityInputActionForTag(const FGameplayTag& InTag, bool bLogNotFound = true) const;
|
||||
};
|
||||
|
|
@ -1,10 +1,51 @@
|
|||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
// Copyright
|
||||
|
||||
#include "VRUtilsBPLibrary.h"
|
||||
#include "VRUtils.h"
|
||||
|
||||
UVRUtilsBPLibrary::UVRUtilsBPLibrary(const FObjectInitializer& ObjectInitializer)
|
||||
: Super(ObjectInitializer)
|
||||
float UVRUtilsBPLibrary::GetPawnSpeedAlongVector(const APawn* InPawn, const FVector& InVector)
|
||||
{
|
||||
if (!InPawn) return 0.0f;
|
||||
|
||||
const FVector Velocity = InPawn->GetVelocity();
|
||||
const FVector InVectorNormalized = InVector.GetSafeNormal();
|
||||
|
||||
return FVector::DotProduct(Velocity, InVectorNormalized);
|
||||
}
|
||||
|
||||
// The following speed functions do not use GetPawnSpeedAlongVector to avoid one extra copy
|
||||
float UVRUtilsBPLibrary::GetPawnForwardVectorSpeed(const APawn* InPawn)
|
||||
{
|
||||
if (!InPawn) return 0.0f;
|
||||
|
||||
const FVector Velocity = InPawn->GetVelocity();
|
||||
const FVector ForwardVector = InPawn->GetActorForwardVector();
|
||||
|
||||
return FVector::DotProduct(Velocity, ForwardVector);
|
||||
}
|
||||
|
||||
float UVRUtilsBPLibrary::GetPawnRightVectorSpeed(const APawn* InPawn)
|
||||
{
|
||||
if (!InPawn) return 0.0f;
|
||||
|
||||
const FVector Velocity = InPawn->GetVelocity();
|
||||
const FVector RightVector = InPawn->GetActorRightVector();
|
||||
|
||||
return FVector::DotProduct(Velocity, RightVector);
|
||||
}
|
||||
|
||||
float UVRUtilsBPLibrary::GetPawnUpVectorSpeed(const APawn* InPawn)
|
||||
{
|
||||
if (!InPawn) return 0.0f;
|
||||
|
||||
const FVector Velocity = InPawn->GetVelocity();
|
||||
const FVector UpVector = InPawn->GetActorUpVector();
|
||||
|
||||
return FVector::DotProduct(Velocity, UpVector);
|
||||
}
|
||||
|
||||
float UVRUtilsBPLibrary::GetDegreeDiff(const FVector& A, const FVector& B)
|
||||
{
|
||||
const float DotResult = FVector::DotProduct(A, B);
|
||||
return FMath::RadiansToDegrees(FMath::Acos(DotResult));
|
||||
}
|
||||
|
|
@ -1,30 +1,49 @@
|
|||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
// Copyright
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "VRUtilsBPLibrary.generated.h"
|
||||
|
||||
/*
|
||||
* Function library class.
|
||||
* Each function in it is expected to be static and represents blueprint node that can be called in any blueprint.
|
||||
*
|
||||
* When declaring function you can define metadata for the node. Key function specifiers will be BlueprintPure and BlueprintCallable.
|
||||
* BlueprintPure - means the function does not affect the owning object in any way and thus creates a node without Exec pins.
|
||||
* BlueprintCallable - makes a function which can be executed in Blueprints - Thus it has Exec pins.
|
||||
* DisplayName - full name of the node, shown when you mouse over the node and in the blueprint drop down menu.
|
||||
* Its lets you name the node using characters not allowed in C++ function names.
|
||||
* CompactNodeTitle - the word(s) that appear on the node.
|
||||
* Keywords - the list of keywords that helps you to find node when you search for it using Blueprint drop-down menu.
|
||||
* Good example is "Print String" node which you can find also by using keyword "log".
|
||||
* Category - the category your node will be under in the Blueprint drop-down menu.
|
||||
*
|
||||
* For more info on custom blueprint nodes visit documentation:
|
||||
* https://wiki.unrealengine.com/Custom_Blueprint_Node_Creation
|
||||
*/
|
||||
/**
|
||||
* Vagabond Rose core utility functions, exposed to blueprints.
|
||||
*/
|
||||
UCLASS()
|
||||
class UVRUtilsBPLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
#pragma region MovementSpeeds
|
||||
/**
|
||||
* Computes the pawn's speed along a given vector.
|
||||
*
|
||||
* @param InPawn The pawn whose speed is being measured. If null, the function returns 0.
|
||||
* @param InVector The vector along which the speed is to be measured.
|
||||
* @return The speed of the pawn along the provided vector.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "VRUtils|Movement|Speed")
|
||||
static float GetPawnSpeedAlongVector(const APawn* InPawn, UPARAM(ref) const FVector& InVector);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "VRUtils|Movement|Speed")
|
||||
static float GetPawnForwardVectorSpeed(const APawn* InPawn);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "VRUtils|Movement|Speed")
|
||||
static float GetPawnRightVectorSpeed(const APawn* InPawn);
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "VRUtils|Movement|Speed")
|
||||
static float GetPawnUpVectorSpeed(const APawn* InPawn);
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Math
|
||||
/**
|
||||
* Calculates the angular difference in degrees between two vectors.
|
||||
*
|
||||
* @param A The first vector.
|
||||
* @param B The second vector.
|
||||
* @return The angular difference between the two vectors in degrees.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "VRUtils|Math")
|
||||
static float GetDegreeDiff(const FVector& A, const FVector& B);
|
||||
#pragma endregion
|
||||
};
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@
|
|||
"Editor"
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "GameplayAbilities",
|
||||
"Enabled": true
|
||||
},
|
||||
{
|
||||
"Name": "VRGAS",
|
||||
"Enabled": true
|
||||
|
|
|
|||
Loading…
Reference in New Issue