Skip to content
Snippets Groups Projects
Commit d5c30d7b authored by Jonathan Wendt's avatar Jonathan Wendt
Browse files

update attachement method

parent 942e7a53
Branches
Tags
1 merge request!2Feature/update to new VRPawn structure and adding an interaction ray that is also available in shipping builds
......@@ -8,6 +8,8 @@
#define LOCTEXT_NAMESPACE "FWidgetInteractionModule"
DEFINE_LOG_CATEGORY(WidgetIntLog);
void FWidgetInteractionModule::StartupModule()
{
on_world_tick_start_delegate_.BindRaw(this, &FWidgetInteractionModule::OnWorldTickStart);
......@@ -49,53 +51,25 @@ void FWidgetInteractionModule::OnWorldTickStart(ELevelTick level_tick, float val
if (vr_pawn == nullptr)
continue;
UE_LOG(LogTemp, Warning, TEXT("OnWorldTickStart called and interaction component will be updated"));
FString name = "";
UClass* component_class = UMotionControllerComponent::StaticClass();
if (IDisplayCluster::Get().GetClusterMgr()->IsStandalone()) {
//if this is a standalone setup ...
if (UHeadMountedDisplayFunctionLibrary::IsHeadMountedDisplayEnabled()) {
//.. with an HMD, we attach the intercation component to the right hand
name = FString("HMDRightMotionController");
component_class = UMotionControllerComponent::StaticClass();
}
else {
//... without an HMD, we also attach it to the virtual right hand, since it exists in this case
name = TEXT("HMDRightMotionController");
component_class = UMotionControllerComponent::StaticClass();
}
}
else {
//if this is a cluster setup we attach it to the flystick
name = TEXT("flystick");
component_class = UDisplayClusterSceneComponent::StaticClass();
}
auto parent_vec = vr_pawn->GetComponentsByClass(component_class);
bool success;
for (auto parent : parent_vec) {
if (parent->GetName() == FString(name)) {
CreateWidgetInteraction(dynamic_cast<USceneComponent*>(parent), vr_pawn);
success = true;
auto right_hand = vr_pawn->GetRightHandComponent();
CreateWidgetInteraction(vr_pawn->GetRightHandComponent(), vr_pawn);
last_world = world;
}
}
if (!success)
UE_LOG(LogTemp, Error, TEXT("Failed to load widget asset \"%s\", cannot attach widget interaction component"), *name);
UE_LOG(WidgetIntLog, Verbose, TEXT("VRInteractionComponent attached to right hand"));
}
}
URwthComponent* FWidgetInteractionModule::GetWidgetInteractionComponent() {
UVRWidgetInteractionComponent* FWidgetInteractionModule::GetWidgetInteractionComponent() {
return widget_interaction_cmp_;
}
void FWidgetInteractionModule::CreateWidgetInteraction(USceneComponent * parent, AVirtualRealityPawn* outer)
{
widget_interaction_cmp_ = NewObject<URwthComponent>(outer, URwthComponent::StaticClass());
widget_interaction_cmp_ = NewObject<UVRWidgetInteractionComponent>(outer, UVRWidgetInteractionComponent::StaticClass());
widget_interaction_cmp_->AttachToComponent(parent, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false));
widget_interaction_cmp_->Init();
}
......
......@@ -7,6 +7,8 @@
#include "VRWidgetInteractionComponent.h"
#include "Modules/ModuleManager.h"
DECLARE_LOG_CATEGORY_EXTERN(WidgetIntLog, Log, All);
class WIDGETINTERACTION_API FWidgetInteractionModule : public IModuleInterface
{
public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment