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

Merge branch 'style/initial_clang_format' into 'dev/5.3'

style(all): Applies clang-format once for all files.

See merge request !55
parents dc57f757 bea4c99c
No related branches found
No related tags found
1 merge request!55style(all): Applies clang-format once for all files.
Showing
with 159 additions and 168 deletions
...@@ -73,8 +73,8 @@ void ACAVEOverlayController::CycleDoorType() ...@@ -73,8 +73,8 @@ void ACAVEOverlayController::CycleDoorType()
void ACAVEOverlayController::HandleClusterEvent(const FDisplayClusterClusterEventJson& Event) void ACAVEOverlayController::HandleClusterEvent(const FDisplayClusterClusterEventJson& Event)
{ {
if (Event.Category.Equals("CAVEOverlay") && Event.Type.Equals("DoorChange") && Event.Parameters.Contains( if (Event.Category.Equals("CAVEOverlay") && Event.Type.Equals("DoorChange") &&
"NewDoorState")) Event.Parameters.Contains("NewDoorState"))
{ {
SetDoorMode(static_cast<EDoorMode>(FCString::Atoi(*Event.Parameters["NewDoorState"]))); SetDoorMode(static_cast<EDoorMode>(FCString::Atoi(*Event.Parameters["NewDoorState"])));
} }
...@@ -91,8 +91,7 @@ void ACAVEOverlayController::SetDoorMode(const EDoorMode NewMode) ...@@ -91,8 +91,7 @@ void ACAVEOverlayController::SetDoorMode(const EDoorMode NewMode)
if (ScreenType == SCREEN_DOOR) if (ScreenType == SCREEN_DOOR)
Overlay->BlackBox->SetRenderScale(FVector2D(0, 1)); Overlay->BlackBox->SetRenderScale(FVector2D(0, 1));
if (ScreenType == SCREEN_DOOR_PARTIAL) if (ScreenType == SCREEN_DOOR_PARTIAL)
Overlay->BlackBox-> Overlay->BlackBox->SetRenderScale(FVector2D(DoorOpeningWidthRelative, 1));
SetRenderScale(FVector2D(DoorOpeningWidthRelative, 1));
if (ScreenType == SCREEN_PRIMARY) if (ScreenType == SCREEN_PRIMARY)
Overlay->BlackBox->SetRenderScale(FVector2D(0, 1)); Overlay->BlackBox->SetRenderScale(FVector2D(0, 1));
...@@ -178,8 +177,8 @@ void ACAVEOverlayController::BeginPlay() ...@@ -178,8 +177,8 @@ void ACAVEOverlayController::BeginPlay()
if (const ULocalPlayer* LocalPlayer = PC->GetLocalPlayer()) if (const ULocalPlayer* LocalPlayer = PC->GetLocalPlayer())
{ {
if (UEnhancedInputLocalPlayerSubsystem* InputSystem = LocalPlayer->GetSubsystem< if (UEnhancedInputLocalPlayerSubsystem* InputSystem =
UEnhancedInputLocalPlayerSubsystem>()) LocalPlayer->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>())
{ {
InputSystem->AddMappingContext(IMCCaveOverlayInputMapping, 0); InputSystem->AddMappingContext(IMCCaveOverlayInputMapping, 0);
} }
...@@ -190,8 +189,8 @@ void ACAVEOverlayController::BeginPlay() ...@@ -190,8 +189,8 @@ void ACAVEOverlayController::BeginPlay()
IDisplayClusterClusterManager* ClusterManager = IDisplayCluster::Get().GetClusterMgr(); IDisplayClusterClusterManager* ClusterManager = IDisplayCluster::Get().GetClusterMgr();
if (ClusterManager && !ClusterEventListenerDelegate.IsBound()) if (ClusterManager && !ClusterEventListenerDelegate.IsBound())
{ {
ClusterEventListenerDelegate = FOnClusterEventJsonListener::CreateUObject( ClusterEventListenerDelegate =
this, &ACAVEOverlayController::HandleClusterEvent); FOnClusterEventJsonListener::CreateUObject(this, &ACAVEOverlayController::HandleClusterEvent);
ClusterManager->AddClusterEventJsonListener(ClusterEventListenerDelegate); ClusterManager->AddClusterEventJsonListener(ClusterEventListenerDelegate);
} }
...@@ -266,38 +265,37 @@ double ACAVEOverlayController::CalculateOpacityFromPosition(const FVector& Posit ...@@ -266,38 +265,37 @@ double ACAVEOverlayController::CalculateOpacityFromPosition(const FVector& Posit
// fully opaque when WallFadeDistance away from the wall. Could just use a lerp here.. // fully opaque when WallFadeDistance away from the wall. Could just use a lerp here..
return FMath::Max( return FMath::Max(
FMath::Clamp((FMath::Abs(Position.X) - (WallDistance - WallCloseDistance)) / WallFadeDistance, 0.0, 1.0), FMath::Clamp((FMath::Abs(Position.X) - (WallDistance - WallCloseDistance)) / WallFadeDistance, 0.0, 1.0),
FMath::Clamp((FMath::Abs(Position.Y) - (WallDistance - WallCloseDistance)) / WallFadeDistance, 0.0, 1.0) FMath::Clamp((FMath::Abs(Position.Y) - (WallDistance - WallCloseDistance)) / WallFadeDistance, 0.0, 1.0));
);
} }
bool ACAVEOverlayController::PositionInDoorOpening(const FVector& Position) const bool ACAVEOverlayController::PositionInDoorOpening(const FVector& Position) const
{ {
// The position of the corner with 10cm of buffer. In negative direction because the door is in negative direction of the cave // The position of the corner with 10cm of buffer. In negative direction because the door is in negative direction
// of the cave
const float CornerValue = -(WallDistance + 10); const float CornerValue = -(WallDistance + 10);
// Check whether our X position is within the door zone. This zone starts 10cm further away from the wall // Check whether our X position is within the door zone. This zone starts 10cm further away from the wall
// than the WallCloseDistance, and ends 10cm outside of the wall (door). As the door is in negative X direction, // than the WallCloseDistance, and ends 10cm outside of the wall (door). As the door is in negative X direction,
// the signs need to be negated. // the signs need to be negated.
const bool bXWithinDoor = FMath::IsWithinInclusive(Position.X, CornerValue, const bool bXWithinDoor =
-(WallDistance - WallCloseDistance - 10)); FMath::IsWithinInclusive(Position.X, CornerValue, -(WallDistance - WallCloseDistance - 10));
// Checks whether our Y position is between the lower corner with some overlap and // Checks whether our Y position is between the lower corner with some overlap and
// the door corner (CornerValue + DoorCurrentOpeningWidthAbsolute) // the door corner (CornerValue + DoorCurrentOpeningWidthAbsolute)
const bool bYWithinDoor = FMath::IsWithinInclusive(Position.Y, CornerValue, const bool bYWithinDoor =
CornerValue + DoorCurrentOpeningWidthAbsolute); FMath::IsWithinInclusive(Position.Y, CornerValue, CornerValue + DoorCurrentOpeningWidthAbsolute);
return bXWithinDoor && bYWithinDoor; return bXWithinDoor && bYWithinDoor;
} }
void ACAVEOverlayController::SetSignsForHand(UStaticMeshComponent* Sign, const FVector& HandPosition, void ACAVEOverlayController::SetSignsForHand(UStaticMeshComponent* Sign, const FVector& HandPosition,
UMaterialInstanceDynamic* HandMaterial) const UMaterialInstanceDynamic* HandMaterial) const
{ {
const bool bHandIsCloseToWall = FMath::IsWithinInclusive(HandPosition.GetAbsMax(), const bool bHandIsCloseToWall =
WallDistance - WallCloseDistance, WallDistance); FMath::IsWithinInclusive(HandPosition.GetAbsMax(), WallDistance - WallCloseDistance, WallDistance);
if (bHandIsCloseToWall && !PositionInDoorOpening(HandPosition)) if (bHandIsCloseToWall && !PositionInDoorOpening(HandPosition))
{ {
Sign->SetVisibility(true); Sign->SetVisibility(true);
HandMaterial->SetScalarParameterValue("SignOpacity", HandMaterial->SetScalarParameterValue("SignOpacity", CalculateOpacityFromPosition(HandPosition));
CalculateOpacityFromPosition(HandPosition));
// Which wall are we closest to? This is the wall we project the sign onto // Which wall are we closest to? This is the wall we project the sign onto
const bool bXWallCloser = FMath::Abs(HandPosition.X) > FMath::Abs(HandPosition.Y); const bool bXWallCloser = FMath::Abs(HandPosition.X) > FMath::Abs(HandPosition.Y);
...@@ -330,8 +328,8 @@ void ACAVEOverlayController::Tick(float DeltaTime) ...@@ -330,8 +328,8 @@ void ACAVEOverlayController::Tick(float DeltaTime)
// Head/Tape Logic // Head/Tape Logic
const FVector HeadPosition = VRPawn->HeadCameraComponent->GetRelativeTransform().GetLocation(); const FVector HeadPosition = VRPawn->HeadCameraComponent->GetRelativeTransform().GetLocation();
const bool bHeadIsCloseToWall = FMath::IsWithinInclusive(HeadPosition.GetAbsMax(), const bool bHeadIsCloseToWall =
WallDistance - WallCloseDistance, WallDistance); FMath::IsWithinInclusive(HeadPosition.GetAbsMax(), WallDistance - WallCloseDistance, WallDistance);
// Only show the tape when close to a wall and not within the door opening // Only show the tape when close to a wall and not within the door opening
if (bHeadIsCloseToWall && !PositionInDoorOpening(HeadPosition)) if (bHeadIsCloseToWall && !PositionInDoorOpening(HeadPosition))
......
...@@ -9,9 +9,11 @@ void FClusterConsole::Register() ...@@ -9,9 +9,11 @@ void FClusterConsole::Register()
ClusterConsoleCommand = IConsoleManager::Get().RegisterConsoleCommand( ClusterConsoleCommand = IConsoleManager::Get().RegisterConsoleCommand(
TEXT("ClusterExecute"), TEXT("ClusterExecute"),
TEXT("<Your Command> - Execute commands on every node of the nDisplay cluster by prepending ClusterExecute"), TEXT("<Your Command> - Execute commands on every node of the nDisplay cluster by prepending ClusterExecute"),
FConsoleCommandWithArgsDelegate::CreateLambda([](const TArray<FString>& Args) FConsoleCommandWithArgsDelegate::CreateLambda(
[](const TArray<FString>& Args)
{ {
if (IDisplayCluster::Get().GetClusterMgr() == nullptr || Args.Num() == 0) return; if (IDisplayCluster::Get().GetClusterMgr() == nullptr || Args.Num() == 0)
return;
/* Emitting cluster event */ /* Emitting cluster event */
FDisplayClusterClusterEventJson ClusterEvent; FDisplayClusterClusterEventJson ClusterEvent;
......
...@@ -2,15 +2,9 @@ ...@@ -2,15 +2,9 @@
#define LOCTEXT_NAMESPACE "FRWTHVRClusterModule" #define LOCTEXT_NAMESPACE "FRWTHVRClusterModule"
void FRWTHVRClusterModule::StartupModule() void FRWTHVRClusterModule::StartupModule() { ClusterConsole.Register(); }
{
ClusterConsole.Register();
}
void FRWTHVRClusterModule::ShutdownModule() void FRWTHVRClusterModule::ShutdownModule() { ClusterConsole.Unregister(); }
{
ClusterConsole.Unregister();
}
#undef LOCTEXT_NAMESPACE #undef LOCTEXT_NAMESPACE
......
...@@ -44,19 +44,24 @@ private: ...@@ -44,19 +44,24 @@ private:
EScreen_Type ScreenType = SCREEN_NORMAL; EScreen_Type ScreenType = SCREEN_NORMAL;
// which additional node names define the screens that cover the door // which additional node names define the screens that cover the door
const TArray<FString> ScreensDoor = { const TArray<FString> ScreensDoor = {"node_bul_left_eye", "node_bul_right_eye", "node_bll_left_eye",
"node_bul_left_eye", "node_bul_right_eye", "node_bll_left_eye", "node_bll_right_eye" "node_bll_right_eye"};
};
// which node names define the screens that cover the partial door // which node names define the screens that cover the partial door
const TArray<FString> ScreensDoorPartial = { const TArray<FString> ScreensDoorPartial = {"node_bur_left_eye", "node_bur_right_eye", "node_blr_left_eye",
"node_bur_left_eye", "node_bur_right_eye", "node_blr_left_eye", "node_blr_right_eye" "node_blr_right_eye"};
};
const FString ScreenMain = "node_main"; const FString ScreenMain = "node_main";
// Door Mode // Door Mode
enum EDoorMode { DOOR_PARTIALLY_OPEN = 0, DOOR_OPEN = 1, DOOR_CLOSED = 2, DOOR_DEBUG = 3, DOOR_NUM_MODES = 4 }; enum EDoorMode
{
DOOR_PARTIALLY_OPEN = 0,
DOOR_OPEN = 1,
DOOR_CLOSED = 2,
DOOR_DEBUG = 3,
DOOR_NUM_MODES = 4
};
const FString DoorModeNames[DOOR_NUM_MODES] = {"Partially Open", "Open", "Closed", "Debug"}; const FString DoorModeNames[DOOR_NUM_MODES] = {"Partially Open", "Open", "Closed", "Debug"};
EDoorMode DoorCurrentMode = DOOR_PARTIALLY_OPEN; EDoorMode DoorCurrentMode = DOOR_PARTIALLY_OPEN;
......
...@@ -9,7 +9,8 @@ ...@@ -9,7 +9,8 @@
* The ClusterConsole provides the console command "ClusterExecute" * The ClusterConsole provides the console command "ClusterExecute"
* The code catches your command, broadcasts it to every nDisplay node and executes it everywhere * The code catches your command, broadcasts it to every nDisplay node and executes it everywhere
* *
* This class has to be registered and unregistered. This can easily be done in every StartupModule/ShutdownModule functions. * This class has to be registered and unregistered. This can easily be done in every StartupModule/ShutdownModule
* functions.
*/ */
USTRUCT() USTRUCT()
struct RWTHVRCLUSTER_API FClusterConsole struct RWTHVRCLUSTER_API FClusterConsole
......
...@@ -14,18 +14,17 @@ inline void SerializeParameters(FMemoryWriter* MemoryWriter, ParameterType&& Par ...@@ -14,18 +14,17 @@ inline void SerializeParameters(FMemoryWriter* MemoryWriter, ParameterType&& Par
SerializeParameters(MemoryWriter, Forward<RemainingParameterTypes>(RemainingParameters)...); SerializeParameters(MemoryWriter, Forward<RemainingParameterTypes>(RemainingParameters)...);
} }
inline void SerializeParameters(FMemoryWriter* MemoryWriter) inline void SerializeParameters(FMemoryWriter* MemoryWriter) {}
{
}
// This is a wrapper function to recursively fill the argument tuple. This overload is only used if the index indicating the // This is a wrapper function to recursively fill the argument tuple. This overload is only used if the index indicating
// currently handled attribute is less than the number of total attributes. I.e., if the attribute index is valid. // the currently handled attribute is less than the number of total attributes. I.e., if the attribute index is valid.
template <int CurrentIndex, typename... ArgTypes> template <int CurrentIndex, typename... ArgTypes>
inline typename TEnableIf<(CurrentIndex < sizeof...(ArgTypes))>::Type inline typename TEnableIf<(CurrentIndex < sizeof...(ArgTypes))>::Type
FillArgumentTuple(FMemoryReader* MemoryReader, TTuple<ArgTypes...>* ArgumentTuple) FillArgumentTuple(FMemoryReader* MemoryReader, TTuple<ArgTypes...>* ArgumentTuple)
{ {
// Read the "<<" as ">>" operator here. FArchive uses the same for both and decides based on an internal type on what to do. So // Read the "<<" as ">>" operator here. FArchive uses the same for both and decides based on an internal type on
// this statement parses the bytes that were passed into reader and puts the parsed object into the tuple at index CurrentIndex. // what to do. So this statement parses the bytes that were passed into reader and puts the parsed object into the
// tuple at index CurrentIndex.
(*MemoryReader) << ArgumentTuple->template Get<CurrentIndex>(); (*MemoryReader) << ArgumentTuple->template Get<CurrentIndex>();
// Recursive call for the remaining attributes. // Recursive call for the remaining attributes.
...@@ -40,20 +39,18 @@ FillArgumentTuple(FMemoryReader* MemoryReader, TTuple<ArgTypes...>* ArgumentTupl ...@@ -40,20 +39,18 @@ FillArgumentTuple(FMemoryReader* MemoryReader, TTuple<ArgTypes...>* ArgumentTupl
} }
template <typename RetType, typename... ArgTypes> template <typename RetType, typename... ArgTypes>
inline RetType CallDelegateWithParameterMap( inline RetType CallDelegateWithParameterMap(const TDelegate<RetType, ArgTypes...>& Delegate,
const TDelegate<RetType, ArgTypes...>& Delegate, const TMap<FString, FString>& Parameters) const TMap<FString, FString>& Parameters)
{ {
// Create a tuple that holds all arguments. This assumes that all argument types are default constructible. However, all // Create a tuple that holds all arguments. This assumes that all argument types are default constructible. However,
// types that overload the FArchive "<<" operator probably are. // all types that overload the FArchive "<<" operator probably are.
TTuple<typename std::remove_cv_t<typename TRemoveReference<ArgTypes>::Type>...> ArgumentTuple; TTuple<typename std::remove_cv_t<typename TRemoveReference<ArgTypes>::Type>...> ArgumentTuple;
// This call will parse the string map and fill all values in the tuple appropriately. // This call will parse the string map and fill all values in the tuple appropriately.
FillArgumentTuple<0>(&ArgumentTuple, Parameters); FillArgumentTuple<0>(&ArgumentTuple, Parameters);
// The lambda function is only necessary because delegates do not overload the ()-operator but use the Execute() method // The lambda function is only necessary because delegates do not overload the ()-operator but use the Execute()
// instead. So, the lambda acts as a wrapper. // method instead. So, the lambda acts as a wrapper.
return ArgumentTuple.ApplyBefore([Delegate](ArgTypes&&... Arguments) return ArgumentTuple.ApplyBefore([Delegate](ArgTypes&&... Arguments)
{ { Delegate.Execute(Forward<ArgTypes>(Arguments)...); });
Delegate.Execute(Forward<ArgTypes>(Arguments)...);
});
} }
...@@ -11,8 +11,8 @@ static constexpr int32 CLUSTER_EVENT_WRAPPER_EVENT_ID = 1337420; ...@@ -11,8 +11,8 @@ static constexpr int32 CLUSTER_EVENT_WRAPPER_EVENT_ID = 1337420;
template <typename MemberFunctionType, MemberFunctionType MemberFunction> template <typename MemberFunctionType, MemberFunctionType MemberFunction>
class ClusterEventWrapperEvent; class ClusterEventWrapperEvent;
template <typename ObjectType, typename ReturnType, typename... ArgTypes, ReturnType (ObjectType::* template <typename ObjectType, typename ReturnType, typename... ArgTypes,
MemberFunction)(ArgTypes...)> ReturnType (ObjectType::*MemberFunction)(ArgTypes...)>
class ClusterEventWrapperEvent<ReturnType (ObjectType::*)(ArgTypes...), MemberFunction> class ClusterEventWrapperEvent<ReturnType (ObjectType::*)(ArgTypes...), MemberFunction>
{ {
static_assert(TIsDerivedFrom<ObjectType, UObject>::IsDerived, "Object needs to derive from UObject"); static_assert(TIsDerivedFrom<ObjectType, UObject>::IsDerived, "Object needs to derive from UObject");
...@@ -20,9 +20,7 @@ class ClusterEventWrapperEvent<ReturnType (ObjectType::*)(ArgTypes...), MemberFu ...@@ -20,9 +20,7 @@ class ClusterEventWrapperEvent<ReturnType (ObjectType::*)(ArgTypes...), MemberFu
public: public:
using MemberFunctionType = decltype(MemberFunction); using MemberFunctionType = decltype(MemberFunction);
ClusterEventWrapperEvent(const TCHAR* MethodName) : MethodName{MethodName} ClusterEventWrapperEvent(const TCHAR* MethodName) : MethodName{MethodName} {}
{
}
void Attach(ObjectType* NewObject) void Attach(ObjectType* NewObject)
{ {
...@@ -74,9 +72,7 @@ public: ...@@ -74,9 +72,7 @@ public:
FillArgumentTuple<0>(&MemoryReader, &ArgumentTuple); FillArgumentTuple<0>(&MemoryReader, &ArgumentTuple);
ArgumentTuple.ApplyBefore([this](const ArgTypes&... Arguments) ArgumentTuple.ApplyBefore([this](const ArgTypes&... Arguments)
{ { (Object->*MemberFunction)(Forward<const ArgTypes&>(Arguments)...); });
(Object->*MemberFunction)(Forward<const ArgTypes&>(Arguments)...);
});
}); });
ClusterManager->AddClusterEventBinaryListener(ClusterEventListenerDelegate); ClusterManager->AddClusterEventBinaryListener(ClusterEventListenerDelegate);
} }
...@@ -135,7 +131,8 @@ private: ...@@ -135,7 +131,8 @@ private:
#define DCEW_TOSTRING(x) DCEW_STRINGIFY(x) #define DCEW_TOSTRING(x) DCEW_STRINGIFY(x)
#define DECLARE_DISPLAY_CLUSTER_EVENT(OwningType, MethodIdentifier) \ #define DECLARE_DISPLAY_CLUSTER_EVENT(OwningType, MethodIdentifier) \
ClusterEventWrapperEvent<decltype(&OwningType::MethodIdentifier), &OwningType::MethodIdentifier> MethodIdentifier##Event \ ClusterEventWrapperEvent<decltype(&OwningType::MethodIdentifier), &OwningType::MethodIdentifier> \
MethodIdentifier##Event \
{ \ { \
TEXT(DCEW_TOSTRING(OwningType) DCEW_TOSTRING(MethodIdentifier)) \ TEXT(DCEW_TOSTRING(OwningType) DCEW_TOSTRING(MethodIdentifier)) \
} }
...@@ -34,9 +34,8 @@ FString ARWTHVRGameModeBase::InitNewPlayer(APlayerController* NewPlayerControlle ...@@ -34,9 +34,8 @@ FString ARWTHVRGameModeBase::InitNewPlayer(APlayerController* NewPlayerControlle
? UGameplayStatics::ParseOption(Options, NodeNameKey) ? UGameplayStatics::ParseOption(Options, NodeNameKey)
: PrimaryNodeId; : PrimaryNodeId;
const EPlayerType Type = NodeName == PrimaryNodeId const EPlayerType Type =
? EPlayerType::nDisplayPrimary NodeName == PrimaryNodeId ? EPlayerType::nDisplayPrimary : EPlayerType::nDisplaySecondary;
: EPlayerType::nDisplaySecondary;
State->RequestSetPlayerType(Type); State->RequestSetPlayerType(Type);
} }
} }
......
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
void FActivateConsoleInShipping::Register() void FActivateConsoleInShipping::Register()
{ {
/* Should only enable console in shipping */ /* Should only enable console in shipping */
if (FApp::GetBuildConfiguration() != EBuildConfiguration::Shipping) return; if (FApp::GetBuildConfiguration() != EBuildConfiguration::Shipping)
return;
On_Post_World_Initialization_Delegate.BindRaw(this, &FActivateConsoleInShipping::OnSessionStart); On_Post_World_Initialization_Delegate.BindRaw(this, &FActivateConsoleInShipping::OnSessionStart);
StartHandle = FWorldDelegates::OnPostWorldInitialization.Add(On_Post_World_Initialization_Delegate); StartHandle = FWorldDelegates::OnPostWorldInitialization.Add(On_Post_World_Initialization_Delegate);
...@@ -12,7 +13,8 @@ void FActivateConsoleInShipping::Register() ...@@ -12,7 +13,8 @@ void FActivateConsoleInShipping::Register()
void FActivateConsoleInShipping::Unregister() const void FActivateConsoleInShipping::Unregister() const
{ {
if (FApp::GetBuildConfiguration() != EBuildConfiguration::Shipping) return; if (FApp::GetBuildConfiguration() != EBuildConfiguration::Shipping)
return;
FWorldDelegates::OnPostWorldInitialization.Remove(StartHandle); FWorldDelegates::OnPostWorldInitialization.Remove(StartHandle);
} }
......
...@@ -4,10 +4,7 @@ ...@@ -4,10 +4,7 @@
#include "Interaction/Interactables/ActionBehaviour.h" #include "Interaction/Interactables/ActionBehaviour.h"
// We disable ticking here, as we are mainly interested in the events // We disable ticking here, as we are mainly interested in the events
UActionBehaviour::UActionBehaviour() UActionBehaviour::UActionBehaviour() { PrimaryComponentTick.bCanEverTick = false; }
{
PrimaryComponentTick.bCanEverTick = false;
}
void UActionBehaviour::OnActionStart(USceneComponent* TriggeredComponent, const UInputAction* InputAction, void UActionBehaviour::OnActionStart(USceneComponent* TriggeredComponent, const UInputAction* InputAction,
const FInputActionValue& Value) const FInputActionValue& Value)
......
...@@ -3,13 +3,9 @@ ...@@ -3,13 +3,9 @@
#include "Interaction/Interactables/HoverBehaviour.h" #include "Interaction/Interactables/HoverBehaviour.h"
void UHoverBehaviour::OnHoverStart(const USceneComponent* TriggeredComponent, FHitResult Hit) void UHoverBehaviour::OnHoverStart(const USceneComponent* TriggeredComponent, FHitResult Hit) {}
{
}
void UHoverBehaviour::OnHoverEnd(const USceneComponent* TriggeredComponent) void UHoverBehaviour::OnHoverEnd(const USceneComponent* TriggeredComponent) {}
{
}
void UHoverBehaviour::BeginPlay() void UHoverBehaviour::BeginPlay()
{ {
......
...@@ -44,10 +44,12 @@ void UInteractableComponent::HandleOnHoverStartEvents(USceneComponent* TriggerCo ...@@ -44,10 +44,12 @@ void UInteractableComponent::HandleOnHoverStartEvents(USceneComponent* TriggerCo
const EInteractorType Interactor) const EInteractorType Interactor)
{ {
// We early return if there the InteractorFilter is set and the Interactor is allowed. // We early return if there the InteractorFilter is set and the Interactor is allowed.
if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) return; if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor))
return;
// We early return if the source Interactor is not part of the allowed components // We early return if the source Interactor is not part of the allowed components
if (!IsComponentAllowed(TriggerComponent)) return; if (!IsComponentAllowed(TriggerComponent))
return;
// Broadcast event to all HoverBehaviours // Broadcast event to all HoverBehaviours
for (const UHoverBehaviour* b : OnHoverBehaviours) for (const UHoverBehaviour* b : OnHoverBehaviours)
...@@ -60,10 +62,12 @@ void UInteractableComponent::HandleOnHoverStartEvents(USceneComponent* TriggerCo ...@@ -60,10 +62,12 @@ void UInteractableComponent::HandleOnHoverStartEvents(USceneComponent* TriggerCo
void UInteractableComponent::HandleOnHoverEndEvents(USceneComponent* TriggerComponent, const EInteractorType Interactor) void UInteractableComponent::HandleOnHoverEndEvents(USceneComponent* TriggerComponent, const EInteractorType Interactor)
{ {
// We early return if there the InteractorFilter is set and the Interactor is allowed. // We early return if there the InteractorFilter is set and the Interactor is allowed.
if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) return; if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor))
return;
// We early return if the source Interactor is not part of the allowed components // We early return if the source Interactor is not part of the allowed components
if (!IsComponentAllowed(TriggerComponent)) return; if (!IsComponentAllowed(TriggerComponent))
return;
// Broadcast event to all HoverBehaviours // Broadcast event to all HoverBehaviours
for (const UHoverBehaviour* b : OnHoverBehaviours) for (const UHoverBehaviour* b : OnHoverBehaviours)
...@@ -74,15 +78,16 @@ void UInteractableComponent::HandleOnHoverEndEvents(USceneComponent* TriggerComp ...@@ -74,15 +78,16 @@ void UInteractableComponent::HandleOnHoverEndEvents(USceneComponent* TriggerComp
// This functions dispatches the ActionStart Event to the attached Action Behaviour Components // This functions dispatches the ActionStart Event to the attached Action Behaviour Components
void UInteractableComponent::HandleOnActionStartEvents(USceneComponent* TriggerComponent, void UInteractableComponent::HandleOnActionStartEvents(USceneComponent* TriggerComponent,
const UInputAction* InputAction, const UInputAction* InputAction, const FInputActionValue& Value,
const FInputActionValue& Value,
const EInteractorType Interactor) const EInteractorType Interactor)
{ {
// We early return if there the InteractorFilter is set and the Interactor is allowed. // We early return if there the InteractorFilter is set and the Interactor is allowed.
if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) return; if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor))
return;
// We early return if the source Interactor is not part of the allowed components // We early return if the source Interactor is not part of the allowed components
if (!IsComponentAllowed(TriggerComponent)) return; if (!IsComponentAllowed(TriggerComponent))
return;
// Broadcast event to all ActionBehaviours // Broadcast event to all ActionBehaviours
for (const UActionBehaviour* b : OnActionBehaviours) for (const UActionBehaviour* b : OnActionBehaviours)
...@@ -93,14 +98,15 @@ void UInteractableComponent::HandleOnActionStartEvents(USceneComponent* TriggerC ...@@ -93,14 +98,15 @@ void UInteractableComponent::HandleOnActionStartEvents(USceneComponent* TriggerC
// This functions dispatches the ActionEnd Event to the attached Action Behaviour Components // This functions dispatches the ActionEnd Event to the attached Action Behaviour Components
void UInteractableComponent::HandleOnActionEndEvents(USceneComponent* TriggerComponent, const UInputAction* InputAction, void UInteractableComponent::HandleOnActionEndEvents(USceneComponent* TriggerComponent, const UInputAction* InputAction,
const FInputActionValue& Value, const FInputActionValue& Value, const EInteractorType Interactor)
const EInteractorType Interactor)
{ {
// We early return if there the InteractorFilter is set and the Interactor is allowed. // We early return if there the InteractorFilter is set and the Interactor is allowed.
if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor)) return; if (!(InteractorFilter == EInteractorType::None || InteractorFilter & Interactor))
return;
// We early return if the source Interactor is not part of the allowed components // We early return if the source Interactor is not part of the allowed components
if (!IsComponentAllowed(TriggerComponent)) return; if (!IsComponentAllowed(TriggerComponent))
return;
// Broadcast event to all ActionBehaviours // Broadcast event to all ActionBehaviours
for (const UActionBehaviour* b : OnActionBehaviours) for (const UActionBehaviour* b : OnActionBehaviours)
......
...@@ -13,8 +13,8 @@ ...@@ -13,8 +13,8 @@
// Sets default values for this component's properties // Sets default values for this component's properties
UGrabComponent::UGrabComponent() UGrabComponent::UGrabComponent()
{ {
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these
// off to improve performance if you don't need them. // features off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true; PrimaryComponentTick.bCanEverTick = true;
// ... // ...
...@@ -35,8 +35,7 @@ void UGrabComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorC ...@@ -35,8 +35,7 @@ void UGrabComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorC
UKismetSystemLibrary::SphereTraceMulti(GetWorld(), GetAttachParent()->GetComponentLocation(), UKismetSystemLibrary::SphereTraceMulti(GetWorld(), GetAttachParent()->GetComponentLocation(),
GetAttachParent()->GetComponentLocation(), GrabSphereRadius, TraceType, true, GetAttachParent()->GetComponentLocation(), GrabSphereRadius, TraceType, true,
ActorsToIgnore, DebugTrace, ActorsToIgnore, DebugTrace, OutHits, true, FColor::Green);
OutHits, true, FColor::Green);
for (FHitResult Hit : OutHits) for (FHitResult Hit : OutHits)
{ {
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
// Sets default values for this component's properties // Sets default values for this component's properties
URaycastSelectionComponent::URaycastSelectionComponent() URaycastSelectionComponent::URaycastSelectionComponent()
{ {
// Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these features // Set this component to be initialized when the game starts, and to be ticked every frame. You can turn these
// off to improve performance if you don't need them. // features off to improve performance if you don't need them.
PrimaryComponentTick.bCanEverTick = true; PrimaryComponentTick.bCanEverTick = true;
// ... // ...
...@@ -35,8 +35,7 @@ void URaycastSelectionComponent::TickComponent(float DeltaTime, ELevelTick TickT ...@@ -35,8 +35,7 @@ void URaycastSelectionComponent::TickComponent(float DeltaTime, ELevelTick TickT
auto DebugTrace = bShowDebugTrace ? EDrawDebugTrace::ForOneFrame : EDrawDebugTrace::None; auto DebugTrace = bShowDebugTrace ? EDrawDebugTrace::ForOneFrame : EDrawDebugTrace::None;
UKismetSystemLibrary::LineTraceSingle(GetWorld(), TraceStart, TraceEnd UKismetSystemLibrary::LineTraceSingle(GetWorld(), TraceStart, TraceEnd, TraceType, true, ActorsToIgnore, DebugTrace,
, TraceType, true, ActorsToIgnore, DebugTrace,
Hit, true, FColor::Green); Hit, true, FColor::Green);
AActor* HitActor = Hit.GetActor(); AActor* HitActor = Hit.GetActor();
...@@ -66,15 +65,13 @@ void URaycastSelectionComponent::TickComponent(float DeltaTime, ELevelTick TickT ...@@ -66,15 +65,13 @@ void URaycastSelectionComponent::TickComponent(float DeltaTime, ELevelTick TickT
void URaycastSelectionComponent::OnBeginSelect(const FInputActionValue& Value) void URaycastSelectionComponent::OnBeginSelect(const FInputActionValue& Value)
{ {
if (CurrentInteractable && CurrentInteractable->HasInteractionTypeFlag(EInteractorType::Raycast)) if (CurrentInteractable && CurrentInteractable->HasInteractionTypeFlag(EInteractorType::Raycast))
CurrentInteractable->HandleOnActionStartEvents(this, RayCastSelectInputAction, Value, CurrentInteractable->HandleOnActionStartEvents(this, RayCastSelectInputAction, Value, EInteractorType::Raycast);
EInteractorType::Raycast);
} }
void URaycastSelectionComponent::OnEndSelect(const FInputActionValue& Value) void URaycastSelectionComponent::OnEndSelect(const FInputActionValue& Value)
{ {
if (CurrentInteractable && CurrentInteractable->HasInteractionTypeFlag(EInteractorType::Raycast)) if (CurrentInteractable && CurrentInteractable->HasInteractionTypeFlag(EInteractorType::Raycast))
CurrentInteractable->HandleOnActionEndEvents(this, RayCastSelectInputAction, Value, CurrentInteractable->HandleOnActionEndEvents(this, RayCastSelectInputAction, Value, EInteractorType::Raycast);
EInteractorType::Raycast);
} }
void URaycastSelectionComponent::SetupPlayerInput(UInputComponent* PlayerInputComponent) void URaycastSelectionComponent::SetupPlayerInput(UInputComponent* PlayerInputComponent)
......
...@@ -3,7 +3,8 @@ ...@@ -3,7 +3,8 @@
#include "Pawn/InputExtensionInterface.h" #include "Pawn/InputExtensionInterface.h"
UEnhancedInputLocalPlayerSubsystem* IInputExtensionInterface::GetEnhancedInputLocalPlayerSubsystem(const 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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment