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

update attachement method

parent 942e7a53
No related branches found
No related tags found
1 merge request!2Feature/update to new VRPawn structure and adding an interaction ray that is also available in shipping builds
This commit is part of merge request !2. Comments created here will be created in the context of that merge request.
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#define LOCTEXT_NAMESPACE "FWidgetInteractionModule" #define LOCTEXT_NAMESPACE "FWidgetInteractionModule"
DEFINE_LOG_CATEGORY(WidgetIntLog);
void FWidgetInteractionModule::StartupModule() void FWidgetInteractionModule::StartupModule()
{ {
on_world_tick_start_delegate_.BindRaw(this, &FWidgetInteractionModule::OnWorldTickStart); on_world_tick_start_delegate_.BindRaw(this, &FWidgetInteractionModule::OnWorldTickStart);
...@@ -49,53 +51,25 @@ void FWidgetInteractionModule::OnWorldTickStart(ELevelTick level_tick, float val ...@@ -49,53 +51,25 @@ void FWidgetInteractionModule::OnWorldTickStart(ELevelTick level_tick, float val
if (vr_pawn == nullptr) if (vr_pawn == nullptr)
continue; continue;
UE_LOG(LogTemp, Warning, TEXT("OnWorldTickStart called and interaction component will be updated"));
FString name = ""; FString name = "";
UClass* component_class = UMotionControllerComponent::StaticClass(); UClass* component_class = UMotionControllerComponent::StaticClass();
auto right_hand = vr_pawn->GetRightHandComponent();
if (IDisplayCluster::Get().GetClusterMgr()->IsStandalone()) { CreateWidgetInteraction(vr_pawn->GetRightHandComponent(), vr_pawn);
//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;
last_world = world; last_world = world;
}
}
if (!success) UE_LOG(WidgetIntLog, Verbose, TEXT("VRInteractionComponent attached to right hand"));
UE_LOG(LogTemp, Error, TEXT("Failed to load widget asset \"%s\", cannot attach widget interaction component"), *name);
} }
} }
URwthComponent* FWidgetInteractionModule::GetWidgetInteractionComponent() { UVRWidgetInteractionComponent* FWidgetInteractionModule::GetWidgetInteractionComponent() {
return widget_interaction_cmp_; return widget_interaction_cmp_;
} }
void FWidgetInteractionModule::CreateWidgetInteraction(USceneComponent * parent, AVirtualRealityPawn* outer) 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_->AttachToComponent(parent, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false));
widget_interaction_cmp_->Init(); widget_interaction_cmp_->Init();
} }
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#include "VRWidgetInteractionComponent.h" #include "VRWidgetInteractionComponent.h"
#include "Modules/ModuleManager.h" #include "Modules/ModuleManager.h"
DECLARE_LOG_CATEGORY_EXTERN(WidgetIntLog, Log, All);
class WIDGETINTERACTION_API FWidgetInteractionModule : public IModuleInterface class WIDGETINTERACTION_API FWidgetInteractionModule : public IModuleInterface
{ {
public: public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment