diff --git a/Content/Components/DirectInteraction/IA_DirectInteractionLeft.uasset b/Content/Components/DirectInteraction/IA_DirectInteractionLeft.uasset index 05597e706243b8138bcea4da36fcc87849b6ba51..777321ddbb5e3586fe3bb2132495977c4798417e 100644 Binary files a/Content/Components/DirectInteraction/IA_DirectInteractionLeft.uasset and b/Content/Components/DirectInteraction/IA_DirectInteractionLeft.uasset differ diff --git a/Content/Components/DirectInteraction/IA_DirectInteractionRight.uasset b/Content/Components/DirectInteraction/IA_DirectInteractionRight.uasset index 76128dfe613f4825b57d9a27ac9c93e1829554de..9a06001e6ecb2c86136df84977087b4713bb6b70 100644 Binary files a/Content/Components/DirectInteraction/IA_DirectInteractionRight.uasset and b/Content/Components/DirectInteraction/IA_DirectInteractionRight.uasset differ diff --git a/Content/Components/Movement/IA_Move.uasset b/Content/Components/Movement/IA_Move.uasset index 3ed093a673b85e12d24ec5b3e8899478d8dddecf..3bc9a527ec86673e8f8e988f755708a4f1ba6dbc 100644 Binary files a/Content/Components/Movement/IA_Move.uasset and b/Content/Components/Movement/IA_Move.uasset differ diff --git a/Content/Components/Movement/IA_MoveUp.uasset b/Content/Components/Movement/IA_MoveUp.uasset index 99fa5ec30e16ae367180e862e408e913549f1d99..a85002e5cc20b787cc6930a835affdf9b0e0302e 100644 Binary files a/Content/Components/Movement/IA_MoveUp.uasset and b/Content/Components/Movement/IA_MoveUp.uasset differ diff --git a/Content/Components/Movement/Turn/IA_DesktopRotation.uasset b/Content/Components/Movement/Turn/IA_DesktopRotation.uasset index a31b6eedb823e53462e894c609c4658aed308a9a..9a780d7a9679fdf2a68a1fca575200140e057a73 100644 Binary files a/Content/Components/Movement/Turn/IA_DesktopRotation.uasset and b/Content/Components/Movement/Turn/IA_DesktopRotation.uasset differ diff --git a/Content/Components/Movement/Turn/IA_Turn.uasset b/Content/Components/Movement/Turn/IA_Turn.uasset index 04177c48d4d84d602b92c021357d7145c7a14010..eb14d702537bd15f6d2e6ae3badcd935bc4126c0 100644 Binary files a/Content/Components/Movement/Turn/IA_Turn.uasset and b/Content/Components/Movement/Turn/IA_Turn.uasset differ diff --git a/Content/Components/RaycastInteraction/IA_RaycastInteractionLeft.uasset b/Content/Components/RaycastInteraction/IA_RaycastInteractionLeft.uasset index 13494f735ac48c8c86551b18695f3a0cd064d524..d97225cf998fc828f5d8d4b0d75efa45c9107e4a 100644 Binary files a/Content/Components/RaycastInteraction/IA_RaycastInteractionLeft.uasset and b/Content/Components/RaycastInteraction/IA_RaycastInteractionLeft.uasset differ diff --git a/Content/Components/RaycastInteraction/IA_RaycastInteractionRight.uasset b/Content/Components/RaycastInteraction/IA_RaycastInteractionRight.uasset index f6ffa30dcc98699d57b19eacfa02bd0701e076e0..3b8c855173d49cb285e76e7167012ac521b594c7 100644 Binary files a/Content/Components/RaycastInteraction/IA_RaycastInteractionRight.uasset and b/Content/Components/RaycastInteraction/IA_RaycastInteractionRight.uasset differ diff --git a/Content/Components/WidgetInteraction/IA_WidgetClick.uasset b/Content/Components/WidgetInteraction/IA_WidgetClick.uasset index a178015abe4a9f945703f46f936b35b97850bc91..470e02e6edeec5b128dd66f602fc5680e3fb9dbe 100644 Binary files a/Content/Components/WidgetInteraction/IA_WidgetClick.uasset and b/Content/Components/WidgetInteraction/IA_WidgetClick.uasset differ diff --git a/Content/IntenSelect/IntenSelectClick.uasset b/Content/IntenSelect/IntenSelectClick.uasset index e14a0945ac964c604bd4ed0e0365e22142de84c3..a6f1bea361671c714db945ffff629342cb6f104d 100644 Binary files a/Content/IntenSelect/IntenSelectClick.uasset and b/Content/IntenSelect/IntenSelectClick.uasset differ diff --git a/Content/RWTHVRCluster/CAVEOverlay/IA_ToggleOverlay.uasset b/Content/RWTHVRCluster/CAVEOverlay/IA_ToggleOverlay.uasset index cd88d95745f6bdcf8fef70bfbe5c98a969281fcf..77af01f0b1f00c791d5b4baf06ac3136355776fe 100644 Binary files a/Content/RWTHVRCluster/CAVEOverlay/IA_ToggleOverlay.uasset and b/Content/RWTHVRCluster/CAVEOverlay/IA_ToggleOverlay.uasset differ diff --git a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp index 3cd0e3d97f05cd11f45f107103511fa3ec28c48a..9352bc3f8e0c1e734579c94bf7326175af7089f3 100644 --- a/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp +++ b/Source/RWTHVRToolkit/Private/Interaction/Interactables/IntenSelect/IntenSelectable.cpp @@ -1,7 +1,6 @@ // Fill out your copyright notice in the Description page of Project Settings. #include "Interaction/Interactables/IntenSelect/IntenSelectable.h" - #include "Interaction/Interactables/IntenSelect/IntenSelectableScoring.h" #include "Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h" #include "Kismet/KismetSystemLibrary.h" @@ -16,8 +15,44 @@ TPair<FHitResult, float> UIntenSelectable::GetBestPointScorePair(const FVector& const float ConeAngle, const float LastValue, const float DeltaTime) const { - checkf(ScoringBehaviour, TEXT("%s"), *GetOwner()->GetName()) return ScoringBehaviour->GetBestPointScorePair( - ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, LastValue, DeltaTime); + checkf(ScoringBehaviours.Num() > 0, TEXT("%s"), *GetOwner()->GetName()); + + float MaxScore = -1; + FHitResult MaxResult; + + for (UIntenSelectableScoring* s : ScoringBehaviours) + { + const TPair<FHitResult, float> Score_Pair = s->GetBestPointScorePair( + ConeOrigin, ConeForwardDirection, ConeBackwardShiftDistance, ConeAngle, LastValue, DeltaTime); + + if (Score_Pair.Value >= MaxScore) + { + MaxResult = Score_Pair.Key; + MaxScore = Score_Pair.Value; + } + } + return TPair<FHitResult, float>{MaxResult, MaxScore}; +} + +void UIntenSelectable::BeginPlay() +{ + Super::BeginPlay(); + + TInlineComponentArray<UIntenSelectable*> AttachedIntenSelectables; + GetOwner()->GetComponents(AttachedIntenSelectables, false); + + if (AttachedIntenSelectables.Num() > 1) + { + if (ScoringBehaviours.Num() == 0) + { + ShowErrorAndQuit( + "Please assign the Scoring Behaviour manually when using more than one IntenSelectable Component!"); + } + } + else + { + InitDefaultBehaviourReferences(); + } } void UIntenSelectable::HandleOnSelectStartEvents(const UIntenSelectComponent* IntenSelect, const FHitResult& HitResult) @@ -58,18 +93,24 @@ void UIntenSelectable::HandleOnClickEndEvents(UIntenSelectComponent* IntenSelect void UIntenSelectable::InitDefaultBehaviourReferences() { // Scoring - if (UIntenSelectableScoring* AttachedScoring = - Cast<UIntenSelectableScoring>(GetOwner()->GetComponentByClass(UIntenSelectableScoring::StaticClass()))) + + for (TSet<UActorComponent*> AllComponents = GetOwner()->GetComponents(); UActorComponent * c : AllComponents) { - ScoringBehaviour = AttachedScoring; + if (UIntenSelectableScoring* TryToGetScoring = Cast<UIntenSelectableScoring>(c)) + { + ScoringBehaviours.Add(TryToGetScoring); + } } - else + + if (ScoringBehaviours.Num() == 0) { - ScoringBehaviour = NewObject<UIntenSelectableSinglePointScoring>( + const auto InitScoringBehaviour = NewObject<UIntenSelectableSinglePointScoring>( this, UIntenSelectableSinglePointScoring::StaticClass(), "Default Scoring"); - ScoringBehaviour->SetWorldLocation(GetOwner()->GetActorLocation()); - ScoringBehaviour->AttachToComponent(GetOwner()->GetRootComponent(), - FAttachmentTransformRules::SnapToTargetNotIncludingScale); + InitScoringBehaviour->SetWorldLocation(GetOwner()->GetActorLocation()); + InitScoringBehaviour->AttachToComponent(GetOwner()->GetRootComponent(), + FAttachmentTransformRules::SnapToTargetNotIncludingScale); + + ScoringBehaviours.Add(InitScoringBehaviour); } // Selecting @@ -93,24 +134,3 @@ void UIntenSelectable::ShowErrorAndQuit(const FString& Message) const #endif UKismetSystemLibrary::QuitGame(this, nullptr, EQuitPreference::Quit, false); } - -void UIntenSelectable::BeginPlay() -{ - Super::BeginPlay(); - - TInlineComponentArray<UIntenSelectable*> AttachedIntenSelectables; - GetOwner()->GetComponents(AttachedIntenSelectables, false); - - if (AttachedIntenSelectables.Num() > 1) - { - if (!ScoringBehaviour) - { - ShowErrorAndQuit( - "Please assign the Scoring Behaviour manually when using more than one IntenSelectable Component!"); - } - } - else - { - InitDefaultBehaviourReferences(); - } -} diff --git a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h index ea8fccb95d7a1fad3a1a5e87ed78ea2a50c90861..45e6a7726227e26c299399ba733a143909ae32b7 100644 --- a/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h +++ b/Source/RWTHVRToolkit/Public/Interaction/Interactables/IntenSelect/IntenSelectable.h @@ -5,6 +5,8 @@ #include "CoreMinimal.h" #include "InputActionValue.h" #include "Components/ActorComponent.h" +#include "Interaction/Interactables/ActionBehaviour.h" +#include "Interaction/Interactables/HoverBehaviour.h" #include "IntenSelectable.generated.h" @@ -23,7 +25,7 @@ public: bool IsSelectable = true; UPROPERTY(EditAnywhere, BlueprintReadWrite) - UIntenSelectableScoring* ScoringBehaviour; + TArray<UIntenSelectableScoring*> ScoringBehaviours; UPROPERTY(EditAnywhere, BlueprintReadWrite) TArray<UHoverBehaviour*> OnSelectBehaviours;