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

Merge remote-tracking branch 'origin/develop'

parents b694c83b 0dbe6c12
Branches
Tags
No related merge requests found
...@@ -12,7 +12,7 @@ URwthComponent::URwthComponent() ...@@ -12,7 +12,7 @@ URwthComponent::URwthComponent()
void URwthComponent::Init() void URwthComponent::Init()
{ {
bShowDebug = true; SetVisibility(true);
InteractionDistance = 1000000.0f; InteractionDistance = 1000000.0f;
auto input_cmp = dynamic_cast<UInputComponent*>(GetOwner()->GetComponentByClass(UInputComponent::StaticClass())); auto input_cmp = dynamic_cast<UInputComponent*>(GetOwner()->GetComponentByClass(UInputComponent::StaticClass()));
...@@ -23,6 +23,10 @@ void URwthComponent::Init() ...@@ -23,6 +23,10 @@ void URwthComponent::Init()
RegisterComponent(); RegisterComponent();
} }
void URwthComponent::SetVisibility(bool visible) {
bShowDebug = visible;
}
void URwthComponent::OnFire(bool val) void URwthComponent::OnFire(bool val)
{ {
if (val == true) if (val == true)
......
...@@ -21,20 +21,26 @@ void FWidgetInteractionModule::ShutdownModule() ...@@ -21,20 +21,26 @@ void FWidgetInteractionModule::ShutdownModule()
void FWidgetInteractionModule::OnWorldTickStart(ELevelTick level_tick, float val) void FWidgetInteractionModule::OnWorldTickStart(ELevelTick level_tick, float val)
{ {
//called every Tick()
auto worlds = GEngine->GetWorldContexts(); auto worlds = GEngine->GetWorldContexts();
if (widget_interaction_cmp_ != nullptr) { for (auto world_context : worlds) {
if (widget_interaction_cmp_->IsValidLowLevel() == true) {
return;
}
else {
widget_interaction_cmp_ = nullptr;
}
}
for (auto & world_context : worlds)
{
auto world = world_context.World(); auto world = world_context.World();
if (last_world == world && widget_interaction_cmp_ != nullptr) {
if (widget_interaction_cmp_->IsValidLowLevel() == true) {
continue;
}
else {
widget_interaction_cmp_ = nullptr;
}
}
if (world == nullptr)
continue;
auto player_controller = world->GetFirstPlayerController(); auto player_controller = world->GetFirstPlayerController();
if (player_controller == nullptr) if (player_controller == nullptr)
continue; continue;
...@@ -43,6 +49,8 @@ void FWidgetInteractionModule::OnWorldTickStart(ELevelTick level_tick, float val ...@@ -43,6 +49,8 @@ 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();
...@@ -63,15 +71,26 @@ void FWidgetInteractionModule::OnWorldTickStart(ELevelTick level_tick, float val ...@@ -63,15 +71,26 @@ void FWidgetInteractionModule::OnWorldTickStart(ELevelTick level_tick, float val
else { else {
//if this is a cluster setup we attach it to the flystick //if this is a cluster setup we attach it to the flystick
name = TEXT("flystick"); name = TEXT("flystick");
component_class = UMotionControllerComponent::StaticClass(); component_class = UDisplayClusterSceneComponent::StaticClass();
} }
auto parent_vec = vr_pawn->GetComponentsByClass(component_class); auto parent_vec = vr_pawn->GetComponentsByClass(component_class);
for (auto parent : parent_vec) bool success;
if (parent->GetName() == FString(name)) for (auto parent : parent_vec) {
if (parent->GetName() == FString(name)) {
CreateWidgetInteraction(dynamic_cast<USceneComponent*>(parent), vr_pawn); CreateWidgetInteraction(dynamic_cast<USceneComponent*>(parent), vr_pawn);
success = true;
last_world = world;
}
}
if (!success)
UE_LOG(LogTemp, Error, TEXT("Failed to load widget asset \"%s\", cannot attach widget interaction component"), *name);
} }
}
URwthComponent* FWidgetInteractionModule::GetWidgetInteractionComponent() {
return widget_interaction_cmp_;
} }
void FWidgetInteractionModule::CreateWidgetInteraction(USceneComponent * parent, AVirtualRealityPawn* outer) void FWidgetInteractionModule::CreateWidgetInteraction(USceneComponent * parent, AVirtualRealityPawn* outer)
......
...@@ -18,6 +18,8 @@ public: ...@@ -18,6 +18,8 @@ public:
void Init(); void Init();
void SetVisibility(bool visible);
protected: protected:
void OnFire(bool val); void OnFire(bool val);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
#include "RwthComponent.h" #include "RwthComponent.h"
#include "Modules/ModuleManager.h" #include "Modules/ModuleManager.h"
class FWidgetInteractionModule : public IModuleInterface class WIDGETINTERACTION_API FWidgetInteractionModule : public IModuleInterface
{ {
public: public:
...@@ -18,6 +18,7 @@ public: ...@@ -18,6 +18,7 @@ public:
UFUNCTION() UFUNCTION()
void OnWorldTickStart(ELevelTick, float); void OnWorldTickStart(ELevelTick, float);
URwthComponent* GetWidgetInteractionComponent();
private: private:
void CreateWidgetInteraction(USceneComponent * parent, AVirtualRealityPawn* outer); void CreateWidgetInteraction(USceneComponent * parent, AVirtualRealityPawn* outer);
...@@ -26,4 +27,5 @@ private: ...@@ -26,4 +27,5 @@ private:
TBaseDelegate<void, ELevelTick, float> on_world_tick_start_delegate_; TBaseDelegate<void, ELevelTick, float> on_world_tick_start_delegate_;
URwthComponent * widget_interaction_cmp_; URwthComponent * widget_interaction_cmp_;
UWorld* last_world;
}; };
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment