Virtual Scouting: GetHMDDeviceType backward compatibility under OpenXR.
Fixes several bugs sharing the same root cause, where code/blueprints were attempting to branch on UVREditorMode::GetHMDDeviceType() or UVREditorInteractor::GetHMDDeviceType(). These calls previously returned the result of IXRTrackingSystem::GetSystemName(), and the call sites were only set up to handle "OculusHMD" or "SteamVR," and were now seeing "OpenXR". Instead, we now return one of those legacy plugin names, depending on the current OpenXR hand controller interaction profile. Longer term, we will want to revisit each of these decision points individually, and take into account support for future unknown XR devices.
An alternative subclass of UVREditorMode can now be configured in the editor settings alongside the interactor and teleporter classes, and a new UVirtualScoutingMode subclass splits the mode entry into two phases. This is necessary because OpenXR may not return the correct interaction profile for several frames after the OpenXR session / stereo rendering has started, and we need to defer creation of the interactors, etc.
#jira UE-150037
#rb jason.walter, Lauren.Barnes
#preflight 6287f49a6c7692ac8cd00f29
[CL 20302573 by zach brockway in ue5-main branch]
2022-05-20 16:40:40 -04:00
|
|
|
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
|
|
2022-10-19 15:09:43 -04:00
|
|
|
#include "VPScoutingMode.h"
|
Virtual Scouting: GetHMDDeviceType backward compatibility under OpenXR.
Fixes several bugs sharing the same root cause, where code/blueprints were attempting to branch on UVREditorMode::GetHMDDeviceType() or UVREditorInteractor::GetHMDDeviceType(). These calls previously returned the result of IXRTrackingSystem::GetSystemName(), and the call sites were only set up to handle "OculusHMD" or "SteamVR," and were now seeing "OpenXR". Instead, we now return one of those legacy plugin names, depending on the current OpenXR hand controller interaction profile. Longer term, we will want to revisit each of these decision points individually, and take into account support for future unknown XR devices.
An alternative subclass of UVREditorMode can now be configured in the editor settings alongside the interactor and teleporter classes, and a new UVirtualScoutingMode subclass splits the mode entry into two phases. This is necessary because OpenXR may not return the correct interaction profile for several frames after the OpenXR session / stereo rendering has started, and we need to defer creation of the interactors, etc.
#jira UE-150037
#rb jason.walter, Lauren.Barnes
#preflight 6287f49a6c7692ac8cd00f29
[CL 20302573 by zach brockway in ue5-main branch]
2022-05-20 16:40:40 -04:00
|
|
|
#include "VirtualScoutingOpenXR.h"
|
|
|
|
|
#include "VirtualScoutingOpenXRModule.h"
|
|
|
|
|
|
2022-05-23 12:33:59 -04:00
|
|
|
#if WITH_EDITOR
|
|
|
|
|
#include "Editor.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-07-07 17:11:33 -04:00
|
|
|
#include "IOpenXRHMDModule.h"
|
2022-08-12 14:05:16 -04:00
|
|
|
#include "IVREditorModule.h"
|
Virtual Scouting: GetHMDDeviceType backward compatibility under OpenXR.
Fixes several bugs sharing the same root cause, where code/blueprints were attempting to branch on UVREditorMode::GetHMDDeviceType() or UVREditorInteractor::GetHMDDeviceType(). These calls previously returned the result of IXRTrackingSystem::GetSystemName(), and the call sites were only set up to handle "OculusHMD" or "SteamVR," and were now seeing "OpenXR". Instead, we now return one of those legacy plugin names, depending on the current OpenXR hand controller interaction profile. Longer term, we will want to revisit each of these decision points individually, and take into account support for future unknown XR devices.
An alternative subclass of UVREditorMode can now be configured in the editor settings alongside the interactor and teleporter classes, and a new UVirtualScoutingMode subclass splits the mode entry into two phases. This is necessary because OpenXR may not return the correct interaction profile for several frames after the OpenXR session / stereo rendering has started, and we need to defer creation of the interactors, etc.
#jira UE-150037
#rb jason.walter, Lauren.Barnes
#preflight 6287f49a6c7692ac8cd00f29
[CL 20302573 by zach brockway in ue5-main branch]
2022-05-20 16:40:40 -04:00
|
|
|
#include "IXRTrackingSystem.h"
|
|
|
|
|
#include "Logging/LogMacros.h"
|
|
|
|
|
#include "Modules/ModuleManager.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define LOCTEXT_NAMESPACE "VirtualScouting"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DECLARE_LOG_CATEGORY_EXTERN(LogVirtualScouting, Log, All);
|
|
|
|
|
DEFINE_LOG_CATEGORY(LogVirtualScouting);
|
|
|
|
|
|
|
|
|
|
|
2022-07-07 17:11:33 -04:00
|
|
|
static const FName OpenXRSystemName = FName(TEXT("OpenXR"));
|
|
|
|
|
|
|
|
|
|
|
Virtual Scouting: GetHMDDeviceType backward compatibility under OpenXR.
Fixes several bugs sharing the same root cause, where code/blueprints were attempting to branch on UVREditorMode::GetHMDDeviceType() or UVREditorInteractor::GetHMDDeviceType(). These calls previously returned the result of IXRTrackingSystem::GetSystemName(), and the call sites were only set up to handle "OculusHMD" or "SteamVR," and were now seeing "OpenXR". Instead, we now return one of those legacy plugin names, depending on the current OpenXR hand controller interaction profile. Longer term, we will want to revisit each of these decision points individually, and take into account support for future unknown XR devices.
An alternative subclass of UVREditorMode can now be configured in the editor settings alongside the interactor and teleporter classes, and a new UVirtualScoutingMode subclass splits the mode entry into two phases. This is necessary because OpenXR may not return the correct interaction profile for several frames after the OpenXR session / stereo rendering has started, and we need to defer creation of the interactors, etc.
#jira UE-150037
#rb jason.walter, Lauren.Barnes
#preflight 6287f49a6c7692ac8cd00f29
[CL 20302573 by zach brockway in ue5-main branch]
2022-05-20 16:40:40 -04:00
|
|
|
class FVirtualScoutingEditorModule : public IModuleInterface
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
virtual void StartupModule() override
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
virtual void ShutdownModule() override
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_MODULE(FVirtualScoutingEditorModule, VirtualScoutingEditor);
|
|
|
|
|
|
|
|
|
|
|
2022-10-19 15:09:43 -04:00
|
|
|
UVPScoutingMode::UVPScoutingMode(const FObjectInitializer& ObjectInitializer)
|
2022-08-12 13:05:45 -04:00
|
|
|
{
|
|
|
|
|
InteractorClass = FSoftObjectPath("/VirtualProductionUtilities/VR/VirtualScoutingInteractor.VirtualScoutingInteractor_C");
|
|
|
|
|
TeleporterClass = FSoftObjectPath("/VirtualProductionUtilities/VR/VirtualScoutingTeleporter.VirtualScoutingTeleporter_C");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-10-19 15:09:43 -04:00
|
|
|
bool UVPScoutingMode::NeedsSyntheticDpad()
|
2022-07-07 17:11:33 -04:00
|
|
|
{
|
|
|
|
|
if (!GEngine->XRSystem.IsValid() || GEngine->XRSystem->GetSystemName() != OpenXRSystemName)
|
|
|
|
|
{
|
|
|
|
|
return Super::NeedsSyntheticDpad();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return !IOpenXRHMDModule::Get().IsExtensionEnabled("XR_EXT_dpad_binding");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-10-19 15:09:43 -04:00
|
|
|
void UVPScoutingMode::Enter()
|
Virtual Scouting: GetHMDDeviceType backward compatibility under OpenXR.
Fixes several bugs sharing the same root cause, where code/blueprints were attempting to branch on UVREditorMode::GetHMDDeviceType() or UVREditorInteractor::GetHMDDeviceType(). These calls previously returned the result of IXRTrackingSystem::GetSystemName(), and the call sites were only set up to handle "OculusHMD" or "SteamVR," and were now seeing "OpenXR". Instead, we now return one of those legacy plugin names, depending on the current OpenXR hand controller interaction profile. Longer term, we will want to revisit each of these decision points individually, and take into account support for future unknown XR devices.
An alternative subclass of UVREditorMode can now be configured in the editor settings alongside the interactor and teleporter classes, and a new UVirtualScoutingMode subclass splits the mode entry into two phases. This is necessary because OpenXR may not return the correct interaction profile for several frames after the OpenXR session / stereo rendering has started, and we need to defer creation of the interactors, etc.
#jira UE-150037
#rb jason.walter, Lauren.Barnes
#preflight 6287f49a6c7692ac8cd00f29
[CL 20302573 by zach brockway in ue5-main branch]
2022-05-20 16:40:40 -04:00
|
|
|
{
|
2022-07-07 17:11:33 -04:00
|
|
|
if (!GEngine->XRSystem.IsValid() || GEngine->XRSystem->GetSystemName() != OpenXRSystemName)
|
Virtual Scouting: GetHMDDeviceType backward compatibility under OpenXR.
Fixes several bugs sharing the same root cause, where code/blueprints were attempting to branch on UVREditorMode::GetHMDDeviceType() or UVREditorInteractor::GetHMDDeviceType(). These calls previously returned the result of IXRTrackingSystem::GetSystemName(), and the call sites were only set up to handle "OculusHMD" or "SteamVR," and were now seeing "OpenXR". Instead, we now return one of those legacy plugin names, depending on the current OpenXR hand controller interaction profile. Longer term, we will want to revisit each of these decision points individually, and take into account support for future unknown XR devices.
An alternative subclass of UVREditorMode can now be configured in the editor settings alongside the interactor and teleporter classes, and a new UVirtualScoutingMode subclass splits the mode entry into two phases. This is necessary because OpenXR may not return the correct interaction profile for several frames after the OpenXR session / stereo rendering has started, and we need to defer creation of the interactors, etc.
#jira UE-150037
#rb jason.walter, Lauren.Barnes
#preflight 6287f49a6c7692ac8cd00f29
[CL 20302573 by zach brockway in ue5-main branch]
2022-05-20 16:40:40 -04:00
|
|
|
{
|
|
|
|
|
Super::Enter();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TSharedPtr<FVirtualScoutingOpenXRExtension> XrExt = FVirtualScoutingOpenXRModule::Get().GetOpenXRExt();
|
|
|
|
|
if (!XrExt)
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogVirtualScouting, Error, TEXT("OpenXR extension plugin invalid"));
|
2022-08-12 14:05:16 -04:00
|
|
|
IVREditorModule::Get().EnableVREditor(false);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!ValidateSettings())
|
|
|
|
|
{
|
|
|
|
|
IVREditorModule::Get().EnableVREditor(false);
|
Virtual Scouting: GetHMDDeviceType backward compatibility under OpenXR.
Fixes several bugs sharing the same root cause, where code/blueprints were attempting to branch on UVREditorMode::GetHMDDeviceType() or UVREditorInteractor::GetHMDDeviceType(). These calls previously returned the result of IXRTrackingSystem::GetSystemName(), and the call sites were only set up to handle "OculusHMD" or "SteamVR," and were now seeing "OpenXR". Instead, we now return one of those legacy plugin names, depending on the current OpenXR hand controller interaction profile. Longer term, we will want to revisit each of these decision points individually, and take into account support for future unknown XR devices.
An alternative subclass of UVREditorMode can now be configured in the editor settings alongside the interactor and teleporter classes, and a new UVirtualScoutingMode subclass splits the mode entry into two phases. This is necessary because OpenXR may not return the correct interaction profile for several frames after the OpenXR session / stereo rendering has started, and we need to defer creation of the interactors, etc.
#jira UE-150037
#rb jason.walter, Lauren.Barnes
#preflight 6287f49a6c7692ac8cd00f29
[CL 20302573 by zach brockway in ue5-main branch]
2022-05-20 16:40:40 -04:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-05-23 12:33:59 -04:00
|
|
|
#if WITH_EDITOR
|
Virtual Scouting: GetHMDDeviceType backward compatibility under OpenXR.
Fixes several bugs sharing the same root cause, where code/blueprints were attempting to branch on UVREditorMode::GetHMDDeviceType() or UVREditorInteractor::GetHMDDeviceType(). These calls previously returned the result of IXRTrackingSystem::GetSystemName(), and the call sites were only set up to handle "OculusHMD" or "SteamVR," and were now seeing "OpenXR". Instead, we now return one of those legacy plugin names, depending on the current OpenXR hand controller interaction profile. Longer term, we will want to revisit each of these decision points individually, and take into account support for future unknown XR devices.
An alternative subclass of UVREditorMode can now be configured in the editor settings alongside the interactor and teleporter classes, and a new UVirtualScoutingMode subclass splits the mode entry into two phases. This is necessary because OpenXR may not return the correct interaction profile for several frames after the OpenXR session / stereo rendering has started, and we need to defer creation of the interactors, etc.
#jira UE-150037
#rb jason.walter, Lauren.Barnes
#preflight 6287f49a6c7692ac8cd00f29
[CL 20302573 by zach brockway in ue5-main branch]
2022-05-20 16:40:40 -04:00
|
|
|
// This causes FOpenXRInput to rebuild and reattach actions.
|
|
|
|
|
FEditorDelegates::OnActionAxisMappingsChanged.Broadcast();
|
2022-05-23 12:33:59 -04:00
|
|
|
#endif
|
Virtual Scouting: GetHMDDeviceType backward compatibility under OpenXR.
Fixes several bugs sharing the same root cause, where code/blueprints were attempting to branch on UVREditorMode::GetHMDDeviceType() or UVREditorInteractor::GetHMDDeviceType(). These calls previously returned the result of IXRTrackingSystem::GetSystemName(), and the call sites were only set up to handle "OculusHMD" or "SteamVR," and were now seeing "OpenXR". Instead, we now return one of those legacy plugin names, depending on the current OpenXR hand controller interaction profile. Longer term, we will want to revisit each of these decision points individually, and take into account support for future unknown XR devices.
An alternative subclass of UVREditorMode can now be configured in the editor settings alongside the interactor and teleporter classes, and a new UVirtualScoutingMode subclass splits the mode entry into two phases. This is necessary because OpenXR may not return the correct interaction profile for several frames after the OpenXR session / stereo rendering has started, and we need to defer creation of the interactors, etc.
#jira UE-150037
#rb jason.walter, Lauren.Barnes
#preflight 6287f49a6c7692ac8cd00f29
[CL 20302573 by zach brockway in ue5-main branch]
2022-05-20 16:40:40 -04:00
|
|
|
|
|
|
|
|
// Split the mode entry into two phases. This is necessary because we have to poll OpenXR for
|
|
|
|
|
// the active interaction profile and translate it into a legacy plugin name, but OpenXR may
|
|
|
|
|
// not return the correct interaction profile for several frames after the OpenXR session
|
|
|
|
|
// (stereo rendering) has started, and we need to defer creation of the interactors, etc.
|
|
|
|
|
BeginEntry();
|
|
|
|
|
|
|
|
|
|
XrExt->GetHmdDeviceTypeFuture() = XrExt->GetHmdDeviceTypeFuture().Next([this](FName DeviceType)
|
|
|
|
|
{
|
|
|
|
|
if (DeviceType != NAME_None)
|
|
|
|
|
{
|
|
|
|
|
SetHMDDeviceTypeOverride(DeviceType);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogVirtualScouting, Error, TEXT("Unable to map legacy HMD device type"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetupSubsystems();
|
|
|
|
|
FinishEntry();
|
|
|
|
|
|
|
|
|
|
return DeviceType;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-12 13:05:45 -04:00
|
|
|
|
2022-10-19 15:09:43 -04:00
|
|
|
bool UVPScoutingMode::ValidateSettings()
|
2022-08-12 14:05:16 -04:00
|
|
|
{
|
|
|
|
|
bool bSettingsValid = true;
|
|
|
|
|
|
|
|
|
|
IConsoleManager& ConsoleMgr = IConsoleManager::Get();
|
|
|
|
|
if (IConsoleVariable* PropagateAlpha = ConsoleMgr.FindConsoleVariable(TEXT("r.PostProcessing.PropagateAlpha")))
|
|
|
|
|
{
|
|
|
|
|
if (PropagateAlpha->GetInt() != 0)
|
|
|
|
|
{
|
|
|
|
|
UE_LOG(LogVirtualScouting, Error, TEXT("r.PostProcessing.PropagateAlpha must be set to 0 (and requires an engine restart)"));
|
|
|
|
|
bSettingsValid = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bSettingsValid;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
Virtual Scouting: GetHMDDeviceType backward compatibility under OpenXR.
Fixes several bugs sharing the same root cause, where code/blueprints were attempting to branch on UVREditorMode::GetHMDDeviceType() or UVREditorInteractor::GetHMDDeviceType(). These calls previously returned the result of IXRTrackingSystem::GetSystemName(), and the call sites were only set up to handle "OculusHMD" or "SteamVR," and were now seeing "OpenXR". Instead, we now return one of those legacy plugin names, depending on the current OpenXR hand controller interaction profile. Longer term, we will want to revisit each of these decision points individually, and take into account support for future unknown XR devices.
An alternative subclass of UVREditorMode can now be configured in the editor settings alongside the interactor and teleporter classes, and a new UVirtualScoutingMode subclass splits the mode entry into two phases. This is necessary because OpenXR may not return the correct interaction profile for several frames after the OpenXR session / stereo rendering has started, and we need to defer creation of the interactors, etc.
#jira UE-150037
#rb jason.walter, Lauren.Barnes
#preflight 6287f49a6c7692ac8cd00f29
[CL 20302573 by zach brockway in ue5-main branch]
2022-05-20 16:40:40 -04:00
|
|
|
#undef LOCTEXT_NAMESPACE
|