2020-10-22 19:19:16 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
|
|
|
|
#include "IXRTrackingSystem.h"
|
2021-06-23 17:51:32 -04:00
|
|
|
#include "IHeadMountedDisplay.h"
|
2020-10-22 19:19:16 -04:00
|
|
|
#include "EngineGlobals.h"
|
|
|
|
|
#include "Engine/Engine.h"
|
|
|
|
|
#include "Kismet/GameplayStatics.h"
|
2023-01-27 14:17:39 -05:00
|
|
|
#include "Misc/App.h"
|
2020-10-22 19:19:16 -04:00
|
|
|
|
|
|
|
|
void IXRTrackingSystem::GetHMDData(UObject* WorldContext, FXRHMDData& HMDData)
|
|
|
|
|
{
|
|
|
|
|
HMDData.bValid = true;
|
2021-06-23 17:51:32 -04:00
|
|
|
HMDData.DeviceName = GetHMDDevice() ? GetHMDDevice()->GetHMDName() : GetSystemName();
|
2020-10-22 19:19:16 -04:00
|
|
|
HMDData.ApplicationInstanceID = FApp::GetInstanceId();
|
|
|
|
|
|
|
|
|
|
bool bIsTracking = IsTracking(IXRTrackingSystem::HMDDeviceId);
|
|
|
|
|
HMDData.TrackingStatus = bIsTracking ? ETrackingStatus::Tracked : ETrackingStatus::NotTracked;
|
|
|
|
|
|
|
|
|
|
APlayerCameraManager* CameraManager = UGameplayStatics::GetPlayerCameraManager(WorldContext, 0);
|
|
|
|
|
if (CameraManager)
|
|
|
|
|
{
|
|
|
|
|
HMDData.Rotation = CameraManager->GetCameraRotation().Quaternion();
|
|
|
|
|
HMDData.Position = CameraManager->GetCameraLocation();
|
|
|
|
|
}
|
|
|
|
|
//GetCurrentPose(0, HMDVisualizationData.Rotation, HMDVisualizationData.Position);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IXRTrackingSystem::IsHeadTrackingAllowedForWorld(UWorld& World) const
|
|
|
|
|
{
|
|
|
|
|
#if WITH_EDITOR
|
2022-06-24 18:23:15 -04:00
|
|
|
// For VR PIE only the primary instance uses the headset.
|
2022-04-26 20:14:45 -04:00
|
|
|
|
|
|
|
|
if (!IsHeadTrackingAllowed())
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (World.WorldType != EWorldType::PIE)
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-24 18:23:15 -04:00
|
|
|
FWorldContext* const WorldContext = GEngine->GetWorldContextFromWorld(&World);
|
|
|
|
|
return WorldContext && WorldContext->bIsPrimaryPIEInstance;
|
2020-10-22 19:19:16 -04:00
|
|
|
#else
|
|
|
|
|
return IsHeadTrackingAllowed();
|
|
|
|
|
#endif
|
|
|
|
|
}
|