Skip to content
Snippets Groups Projects

Release dev to main branch

Open David Gilbert requested to merge dev/5.4 into 5.4
2 files
+ 43
9
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -149,6 +149,10 @@ void ACAVEOverlayController::BeginPlay()
@@ -149,6 +149,10 @@ void ACAVEOverlayController::BeginPlay()
if (GetNetMode() != NM_Standalone)
if (GetNetMode() != NM_Standalone)
return;
return;
 
// If we're not in room-mounted mode, return as well
 
if (!URWTHVRClusterUtilities::IsRoomMountedMode())
 
return;
 
// This should return the respective client's local playercontroller or, if we're a listen server, our own PC.
// This should return the respective client's local playercontroller or, if we're a listen server, our own PC.
auto* PC = GetWorld() ? GetWorld()->GetFirstPlayerController() : nullptr;
auto* PC = GetWorld() ? GetWorld()->GetFirstPlayerController() : nullptr;
@@ -157,7 +161,7 @@ void ACAVEOverlayController::BeginPlay()
@@ -157,7 +161,7 @@ void ACAVEOverlayController::BeginPlay()
// Not sure which place would be best...
// Not sure which place would be best...
const bool bValidPC = PC && PC->GetLocalPlayer();
const bool bValidPC = PC && PC->GetLocalPlayer();
if (!bValidPC || !URWTHVRClusterUtilities::IsRoomMountedMode())
if (!bValidPC)
return;
return;
// Input config
// Input config
@@ -223,11 +227,33 @@ void ACAVEOverlayController::BeginPlay()
@@ -223,11 +227,33 @@ void ACAVEOverlayController::BeginPlay()
return;
return;
}
}
 
PC->OnPossessedPawnChanged.AddUniqueDynamic(this, &ACAVEOverlayController::UpdatePossessedPawn);
 
 
// I think this breaks in multiplayer mode
 
InitFromPawn(PC->GetPawn());
 
 
// Create dynamic material for tape
 
TapeMaterialDynamic = Tape->CreateDynamicMaterialInstance(0);
 
 
UE_LOGFMT(LogCAVEOverlay, Display, "CaveOverlay Initialization was successfull.");
 
}
 
 
void ACAVEOverlayController::UpdatePossessedPawn(APawn* OldPawn, APawn* NewPawn) { InitFromPawn(NewPawn); }
 
 
 
void ACAVEOverlayController::InitFromPawn(const APawn* CurrentPawn)
 
{
 
// Clear previous properties. We could reuse the SMCs and MIDs, clearing them might be dangerous.
 
// Too much in a hurry here to make this better.
 
MotionControllers.Empty();
 
SignsStaticMeshComponents.Empty();
 
SignsMIDs.Empty();
 
// Get the pawn so we can have access to head and hand positions
// Get the pawn so we can have access to head and hand positions
if (const auto* VRPawn = Cast<APawn>(PC->GetPawnOrSpectator()))
if (CurrentPawn)
{
{
PawnCamera = VRPawn->GetComponentByClass<UCameraComponent>();
PawnCamera = CurrentPawn->GetComponentByClass<UCameraComponent>();
auto FoundMotionControllers = VRPawn->K2_GetComponentsByClass(UMotionControllerComponent::StaticClass());
auto FoundMotionControllers = CurrentPawn->K2_GetComponentsByClass(UMotionControllerComponent::StaticClass());
for (const auto FoundMotionController : FoundMotionControllers)
for (const auto FoundMotionController : FoundMotionControllers)
{
{
@@ -261,13 +287,9 @@ void ACAVEOverlayController::BeginPlay()
@@ -261,13 +287,9 @@ void ACAVEOverlayController::BeginPlay()
}
}
else
else
{
{
 
bInitialized = false;
UE_LOGFMT(LogCAVEOverlay, Error, "No VirtualRealityPawn found which we could attach to!");
UE_LOGFMT(LogCAVEOverlay, Error, "No VirtualRealityPawn found which we could attach to!");
}
}
// Create dynamic material for tape
TapeMaterialDynamic = Tape->CreateDynamicMaterialInstance(0);
UE_LOGFMT(LogCAVEOverlay, Display, "CaveOverlay Initialization was successfull.");
}
}
void ACAVEOverlayController::EndPlay(const EEndPlayReason::Type EndPlayReason)
void ACAVEOverlayController::EndPlay(const EEndPlayReason::Type EndPlayReason)
@@ -386,6 +408,12 @@ void ACAVEOverlayController::Tick(float DeltaTime)
@@ -386,6 +408,12 @@ void ACAVEOverlayController::Tick(float DeltaTime)
// Hand Logic
// Hand Logic
for (int i = 0; i < MotionControllers.Num(); i++)
for (int i = 0; i < MotionControllers.Num(); i++)
{
{
 
if (MotionControllers[i] == nullptr)
 
{
 
UE_LOGFMT(LogCAVEOverlay, Error, "Motion Controller was nullptr, disabling overlay!");
 
bInitialized = false;
 
return;
 
}
const FVector HandPosition = MotionControllers[i]->GetRelativeLocation();
const FVector HandPosition = MotionControllers[i]->GetRelativeLocation();
// Set the position rotation, opacity, visibility of the hand warning signs.
// Set the position rotation, opacity, visibility of the hand warning signs.
Loading