Skip to content
Snippets Groups Projects
Commit 804dfb19 authored by Kris Tabea Helwig's avatar Kris Tabea Helwig
Browse files

Merge remote-tracking branch 'remotes/origin/dev/5.3' into feature/toolkit_examples

parents b16b0605 af35f5a9
No related branches found
No related tags found
3 merge requests!90Draft: Forward propagate dev/5.3 changes into 5.4,!86Moves Content Examples into own project,!85UE5.3-2023.1-rc3
...@@ -3,3 +3,7 @@ The **RWTH VR Toolkit** contains a collection of extensions which are used in ma ...@@ -3,3 +3,7 @@ The **RWTH VR Toolkit** contains a collection of extensions which are used in ma
The contents of this plugin are constantly extended and improved to reflect changes in the Unreal nDisplay Plugin that we use to support our aixCAVE with Unreal. The contents of this plugin are constantly extended and improved to reflect changes in the Unreal nDisplay Plugin that we use to support our aixCAVE with Unreal.
[Check out the repository's wiki page for installation, usage and documentation](https://git-ce.rwth-aachen.de/vr-vis/VR-Group/unreal-development/plugins/rwth-vr-toolkit/-/wikis/home). [Check out the repository's wiki page for installation, usage and documentation](https://git-ce.rwth-aachen.de/vr-vis/VR-Group/unreal-development/plugins/rwth-vr-toolkit/-/wikis/home).
## Citation
If you need to reference the toolkit in your scientific work, please use https://zenodo.org/records/10817754
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "Interaction/Interactables/IntenSelect/IntenSelectable.h" #include "Interaction/Interactables/IntenSelect/IntenSelectable.h"
#include "Interaction/Interactables/IntenSelect/IntenSelectableScoring.h" #include "Interaction/Interactables/IntenSelect/IntenSelectableScoring.h"
#include "Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h" #include "Interaction/Interactables/IntenSelect/IntenSelectableSinglePointScoring.h"
#include "Kismet/KismetSystemLibrary.h" #include "Kismet/KismetSystemLibrary.h"
...@@ -16,8 +15,44 @@ TPair<FHitResult, float> UIntenSelectable::GetBestPointScorePair(const FVector& ...@@ -16,8 +15,44 @@ TPair<FHitResult, float> UIntenSelectable::GetBestPointScorePair(const FVector&
const float ConeAngle, const float LastValue, const float ConeAngle, const float LastValue,
const float DeltaTime) const const float DeltaTime) const
{ {
checkf(ScoringBehaviour, TEXT("%s"), *GetOwner()->GetName()) return ScoringBehaviour->GetBestPointScorePair( 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); 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) void UIntenSelectable::HandleOnSelectStartEvents(const UIntenSelectComponent* IntenSelect, const FHitResult& HitResult)
...@@ -58,18 +93,24 @@ void UIntenSelectable::HandleOnClickEndEvents(UIntenSelectComponent* IntenSelect ...@@ -58,18 +93,24 @@ void UIntenSelectable::HandleOnClickEndEvents(UIntenSelectComponent* IntenSelect
void UIntenSelectable::InitDefaultBehaviourReferences() void UIntenSelectable::InitDefaultBehaviourReferences()
{ {
// Scoring // 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"); this, UIntenSelectableSinglePointScoring::StaticClass(), "Default Scoring");
ScoringBehaviour->SetWorldLocation(GetOwner()->GetActorLocation()); InitScoringBehaviour->SetWorldLocation(GetOwner()->GetActorLocation());
ScoringBehaviour->AttachToComponent(GetOwner()->GetRootComponent(), InitScoringBehaviour->AttachToComponent(GetOwner()->GetRootComponent(),
FAttachmentTransformRules::SnapToTargetNotIncludingScale); FAttachmentTransformRules::SnapToTargetNotIncludingScale);
ScoringBehaviours.Add(InitScoringBehaviour);
} }
// Selecting // Selecting
...@@ -93,24 +134,3 @@ void UIntenSelectable::ShowErrorAndQuit(const FString& Message) const ...@@ -93,24 +134,3 @@ void UIntenSelectable::ShowErrorAndQuit(const FString& Message) const
#endif #endif
UKismetSystemLibrary::QuitGame(this, nullptr, EQuitPreference::Quit, false); 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();
}
}
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "InputActionValue.h" #include "InputActionValue.h"
#include "Components/ActorComponent.h" #include "Components/ActorComponent.h"
#include "Interaction/Interactables/ActionBehaviour.h"
#include "Interaction/Interactables/HoverBehaviour.h"
#include "IntenSelectable.generated.h" #include "IntenSelectable.generated.h"
...@@ -23,7 +25,7 @@ public: ...@@ -23,7 +25,7 @@ public:
bool IsSelectable = true; bool IsSelectable = true;
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
UIntenSelectableScoring* ScoringBehaviour; TArray<UIntenSelectableScoring*> ScoringBehaviours;
UPROPERTY(EditAnywhere, BlueprintReadWrite) UPROPERTY(EditAnywhere, BlueprintReadWrite)
TArray<UHoverBehaviour*> OnSelectBehaviours; TArray<UHoverBehaviour*> OnSelectBehaviours;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment