Android build settings + metaxr
This commit is contained in:
134
Plugins/MetaXR/Source/OculusXRHMD/Public/IOculusXRHMDModule.h
Normal file
134
Plugins/MetaXR/Source/OculusXRHMD/Public/IOculusXRHMDModule.h
Normal file
@@ -0,0 +1,134 @@
|
||||
// @lint-ignore-every LICENSELINT
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
#include "Modules/ModuleManager.h"
|
||||
#include "IHeadMountedDisplayModule.h"
|
||||
#include "HeadMountedDisplayTypes.h"
|
||||
|
||||
// Oculus support is not available on Windows XP
|
||||
#define OCULUS_HMD_SUPPORTED_PLATFORMS (PLATFORM_WINDOWS && WINVER > 0x0502) || (PLATFORM_ANDROID_ARM || PLATFORM_ANDROID_ARM64 || PLATFORM_ANDROID_X64)
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// IOculusXRHMDModule
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* The public interface to this module. In most cases, this interface is only public to sibling modules
|
||||
* within this plugin.
|
||||
*/
|
||||
class IOculusXRHMDModule : public IHeadMountedDisplayModule
|
||||
{
|
||||
public:
|
||||
static OCULUSXRHMD_API const FName NAME_OculusXRHMD;
|
||||
|
||||
/**
|
||||
* Singleton-like access to this module's interface. This is just for convenience!
|
||||
* Beware of calling this during the shutdown phase, though. Your module might have been unloaded already.
|
||||
*
|
||||
* @return Returns singleton instance, loading the module on demand if needed
|
||||
*/
|
||||
static inline IOculusXRHMDModule& Get()
|
||||
{
|
||||
return FModuleManager::LoadModuleChecked<IOculusXRHMDModule>(NAME_OculusXRHMD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to see if this module is loaded and ready. It is only valid to call Get() if IsAvailable() returns true.
|
||||
*
|
||||
* @return True if the module is loaded and ready to use
|
||||
*/
|
||||
static inline bool IsAvailable()
|
||||
{
|
||||
return FModuleManager::Get().IsModuleLoaded(NAME_OculusXRHMD);
|
||||
}
|
||||
|
||||
/**
|
||||
* Grabs the current orientation and position for the HMD. If positional tracking is not available, DevicePosition will be a zero vector
|
||||
*
|
||||
* @param DeviceRotation (out) The device's current rotation
|
||||
* @param DevicePosition (out) The device's current position, in its own tracking space
|
||||
* @param NeckPosition (out) The estimated neck position, calculated using NeckToEye vector from User Profile. Same coordinate space as DevicePosition.
|
||||
* @param bUseOrienationForPlayerCamera (in) Should be set to 'true' if the orientation is going to be used to update orientation of the camera manually.
|
||||
* @param bUsePositionForPlayerCamera (in) Should be set to 'true' if the position is going to be used to update position of the camera manually.
|
||||
* @param PositionScale (in) The 3D scale that will be applied to position.
|
||||
*/
|
||||
virtual void GetPose(FRotator& DeviceRotation, FVector& DevicePosition, FVector& NeckPosition, bool bUseOrienationForPlayerCamera = false, bool bUsePositionForPlayerCamera = false, const FVector PositionScale = FVector::ZeroVector) = 0;
|
||||
|
||||
/**
|
||||
* Reports raw sensor data. If HMD doesn't support any of the parameters then it will be set to zero.
|
||||
*
|
||||
* @param AngularAcceleration (out) Angular acceleration in radians per second per second.
|
||||
* @param LinearAcceleration (out) Acceleration in meters per second per second.
|
||||
* @param AngularVelocity (out) Angular velocity in radians per second.
|
||||
* @param LinearVelocity (out) Velocity in meters per second.
|
||||
* @param TimeInSeconds (out) Time when the reported IMU reading took place, in seconds.
|
||||
*/
|
||||
virtual void GetRawSensorData(FVector& AngularAcceleration, FVector& LinearAcceleration, FVector& AngularVelocity, FVector& LinearVelocity, float& TimeInSeconds) = 0;
|
||||
|
||||
/**
|
||||
* Returns current user profile.
|
||||
*
|
||||
* @param Profile (out) Structure to hold current user profile.
|
||||
* @return (boolean) True, if user profile was acquired.
|
||||
*/
|
||||
virtual bool GetUserProfile(struct FOculusXRHmdUserProfile& Profile) = 0;
|
||||
|
||||
/**
|
||||
* Sets 'base rotation' - the rotation that will be subtracted from
|
||||
* the actual HMD orientation.
|
||||
* Sets base position offset (in meters). The base position offset is the distance from the physical (0, 0, 0) position
|
||||
* to current HMD position (bringing the (0, 0, 0) point to the current HMD position)
|
||||
* Note, this vector is set by ResetPosition call; use this method with care.
|
||||
* The axis of the vector are the same as in Unreal: X - forward, Y - right, Z - up.
|
||||
*
|
||||
* @param Rotation (in) Rotator object with base rotation
|
||||
* @param BaseOffsetInMeters (in) the vector to be set as base offset, in meters.
|
||||
* @param Options (in) specifies either position, orientation or both should be set.
|
||||
*/
|
||||
virtual void SetBaseRotationAndBaseOffsetInMeters(FRotator Rotation, FVector BaseOffsetInMeters, EOrientPositionSelector::Type Options) = 0;
|
||||
|
||||
/**
|
||||
* Returns current base rotation and base offset.
|
||||
* The base offset is currently used base position offset, previously set by the
|
||||
* ResetPosition or SetBasePositionOffset calls. It represents a vector that translates the HMD's position
|
||||
* into (0,0,0) point, in meters.
|
||||
* The axis of the vector are the same as in Unreal: X - forward, Y - right, Z - up.
|
||||
*
|
||||
* @param OutRotation (out) Rotator object with base rotation
|
||||
* @param OutBaseOffsetInMeters (out) base position offset, vector, in meters.
|
||||
*/
|
||||
virtual void GetBaseRotationAndBaseOffsetInMeters(FRotator& OutRotation, FVector& OutBaseOffsetInMeters) = 0;
|
||||
|
||||
/**
|
||||
* Sets 'base rotation' - the rotation that will be subtracted from
|
||||
* the actual HMD orientation.
|
||||
* The position offset might be added to current HMD position,
|
||||
* effectively moving the virtual camera by the specified offset. The addition
|
||||
* occurs after the HMD orientation and position are applied.
|
||||
*
|
||||
* @param BaseRot (in) Rotator object with base rotation
|
||||
* @param PosOffset (in) the vector to be added to HMD position.
|
||||
* @param Options (in) specifies either position, orientation or both should be set.
|
||||
*/
|
||||
virtual void SetBaseRotationAndPositionOffset(FRotator BaseRot, FVector PosOffset, EOrientPositionSelector::Type Options) = 0;
|
||||
|
||||
/**
|
||||
* Returns current base rotation and position offset.
|
||||
*
|
||||
* @param OutRot (out) Rotator object with base rotation
|
||||
* @param OutPosOffset (out) the vector with previously set position offset.
|
||||
*/
|
||||
virtual void GetBaseRotationAndPositionOffset(FRotator& OutRot, FVector& OutPosOffset) = 0;
|
||||
|
||||
/**
|
||||
* Returns IStereoLayers interface to work with overlays.
|
||||
*/
|
||||
virtual class IStereoLayers* GetStereoLayers() = 0;
|
||||
|
||||
virtual FString GetDeviceSystemName() = 0;
|
||||
|
||||
#if OCULUS_HMD_SUPPORTED_PLATFORMS
|
||||
virtual bool PoseToOrientationAndPosition(const FQuat& InOrientation, const FVector& InPosition, FQuat& OutOrientation, FVector& OutPosition) const = 0;
|
||||
#endif // OCULUS_HMD_SUPPORTED_PLATFORMS
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
// @lint-ignore-every LICENSELINT
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/SoftObjectPath.h"
|
||||
|
||||
class FOculusAssetDirectory
|
||||
{
|
||||
public:
|
||||
#if WITH_EDITORONLY_DATA
|
||||
OCULUSXRHMD_API static void LoadForCook();
|
||||
OCULUSXRHMD_API static void ReleaseAll();
|
||||
#endif
|
||||
|
||||
static FSoftObjectPath AssetListing[];
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
// @lint-ignore-every LICENSELINT
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
// OculusEventComponent.h: Component to handle receiving events from Oculus HMDs
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/ObjectMacros.h"
|
||||
#include "Components/ActorComponent.h"
|
||||
#include "OculusXREventComponent.generated.h"
|
||||
|
||||
UCLASS(Blueprintable, meta = (BlueprintSpawnableComponent), ClassGroup = OculusXRHMD)
|
||||
class OCULUSXRHMD_API UOculusXREventComponent : public UActorComponent
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FOculusDisplayRefreshRateChangedEventDelegate, float, fromRefreshRate, float, toRefreshRate);
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_OneParam(FOculusEyeTrackingStateChangedEventDelegate, bool, bEyeTrackingOn);
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOculusDisplayRefreshRateChangedEventDelegate OculusDisplayRefreshRateChanged;
|
||||
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FOculusEyeTrackingStateChangedEventDelegate OculusEyeTrackingStateChanged;
|
||||
|
||||
void OnRegister() override;
|
||||
void OnUnregister() override;
|
||||
|
||||
private:
|
||||
/** Native handlers that get registered with the actual FCoreDelegates, and then proceed to broadcast to the delegates above */
|
||||
void OculusDisplayRefreshRateChanged_Handler(float fromRefresh, float toRefresh) { OculusDisplayRefreshRateChanged.Broadcast(fromRefresh, toRefresh); }
|
||||
void OculusEyeTrackingStateChanged_Handler(bool bEyeTrackingOn) { OculusEyeTrackingStateChanged.Broadcast(bEyeTrackingOn); }
|
||||
};
|
||||
@@ -0,0 +1,531 @@
|
||||
// @lint-ignore-every LICENSELINT
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "OculusXRHMDTypes.h"
|
||||
#include "UObject/ObjectMacros.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "IOculusXRHMDModule.h"
|
||||
#include "OculusXRFunctionLibrary.generated.h"
|
||||
|
||||
namespace OculusXRHMD
|
||||
{
|
||||
class FOculusXRHMD;
|
||||
class IOculusXRFunctionLibrary
|
||||
{
|
||||
public:
|
||||
virtual void GetPose(FRotator& DeviceRotation, FVector& DevicePosition, FVector& NeckPosition) = 0;
|
||||
virtual void SetBaseRotationAndBaseOffsetInMeters(FRotator Rotation, FVector BaseOffsetInMeters, EOrientPositionSelector::Type Options) = 0;
|
||||
virtual void GetBaseRotationAndBaseOffsetInMeters(FRotator& OutRotation, FVector& OutBaseOffsetInMeters) = 0;
|
||||
virtual void GetRawSensorData(FVector& AngularAcceleration, FVector& LinearAcceleration, FVector& AngularVelocity, FVector& LinearVelocity, float& TimeInSeconds, EOculusXRTrackedDeviceType DeviceType) = 0;
|
||||
virtual bool IsDeviceTracked(EOculusXRTrackedDeviceType DeviceType) = 0;
|
||||
virtual void GetSuggestedCpuAndGpuPerformanceLevels(EOculusXRProcessorPerformanceLevel& CpuPerfLevel, EOculusXRProcessorPerformanceLevel& GpuPerfLevel) = 0;
|
||||
virtual void SetSuggestedCpuAndGpuPerformanceLevels(EOculusXRProcessorPerformanceLevel CpuPerfLevel, EOculusXRProcessorPerformanceLevel GpuPerfLevel) = 0;
|
||||
virtual bool GetUserProfile(FOculusXRHmdUserProfile& Profile) = 0;
|
||||
virtual void SetBaseRotationAndPositionOffset(FRotator BaseRot, FVector PosOffset, EOrientPositionSelector::Type Options) = 0;
|
||||
virtual void GetBaseRotationAndPositionOffset(FRotator& OutRot, FVector& OutPosOffset) = 0;
|
||||
virtual void AddLoadingSplashScreen(class UTexture2D* Texture, FVector TranslationInMeters, FRotator Rotation, FVector2D SizeInMeters, FRotator DeltaRotation, bool bClearBeforeAdd) = 0;
|
||||
virtual void ClearLoadingSplashScreens() = 0;
|
||||
virtual bool HasInputFocus() = 0;
|
||||
virtual bool HasSystemOverlayPresent() = 0;
|
||||
virtual void GetGPUUtilization(bool& IsGPUAvailable, float& GPUUtilization) = 0;
|
||||
virtual float GetGPUFrameTime() = 0;
|
||||
virtual void GetPerformanceMetrics(FOculusXRPerformanceMetrics& PerformanceMetrics) = 0;
|
||||
|
||||
|
||||
virtual EOculusXRFoveatedRenderingMethod GetFoveatedRenderingMethod() = 0;
|
||||
virtual void SetFoveatedRenderingMethod(EOculusXRFoveatedRenderingMethod Method) = 0;
|
||||
virtual void SetFoveatedRenderingLevel(EOculusXRFoveatedRenderingLevel level, bool isDynamic) = 0;
|
||||
virtual EOculusXRFoveatedRenderingLevel GetFoveatedRenderingLevel() = 0;
|
||||
virtual bool GetEyeTrackedFoveatedRenderingSupported() = 0;
|
||||
virtual FString GetDeviceName() = 0;
|
||||
virtual EOculusXRDeviceType GetDeviceType() = 0;
|
||||
virtual EOculusXRControllerType GetControllerType(EControllerHand deviceHand) = 0;
|
||||
virtual TArray<float> GetAvailableDisplayFrequencies() = 0;
|
||||
virtual float GetCurrentDisplayFrequency() = 0;
|
||||
virtual void SetDisplayFrequency(float RequestedFrequency) = 0;
|
||||
virtual void EnablePositionTracking(bool bPositionTracking) = 0;
|
||||
virtual void EnableOrientationTracking(bool bOrientationTracking) = 0;
|
||||
virtual void SetColorScaleAndOffset(FLinearColor ColorScale, FLinearColor ColorOffset, bool bApplyToAllLayers) = 0;
|
||||
virtual class IStereoLayers* GetStereoLayers() = 0;
|
||||
virtual bool IsGuardianConfigured() = 0;
|
||||
virtual bool IsGuardianDisplayed() = 0;
|
||||
virtual TArray<FVector> GetGuardianPoints(EOculusXRBoundaryType BoundaryType, bool UsePawnSpace /* = false */) = 0;
|
||||
virtual FVector GetGuardianDimensions(EOculusXRBoundaryType BoundaryType) = 0;
|
||||
virtual FTransform GetPlayAreaTransform() = 0;
|
||||
virtual FOculusXRGuardianTestResult GetPointGuardianIntersection(const FVector Point, EOculusXRBoundaryType BoundaryType) = 0;
|
||||
virtual FOculusXRGuardianTestResult GetNodeGuardianIntersection(EOculusXRTrackedDeviceType DeviceType, EOculusXRBoundaryType BoundaryType) = 0;
|
||||
virtual void SetGuardianVisibility(bool GuardianVisible) = 0;
|
||||
virtual bool GetSystemHmd3DofModeEnabled() = 0;
|
||||
virtual EOculusXRColorSpace GetHmdColorDesc() = 0;
|
||||
virtual void SetClientColorDesc(EOculusXRColorSpace ColorSpace) = 0;
|
||||
virtual void SetLocalDimmingOn(bool LocalDimmingOn) = 0;
|
||||
virtual bool IsPassthroughSupported() = 0;
|
||||
virtual bool IsColorPassthroughSupported() = 0;
|
||||
virtual void StartEnvironmentDepth() = 0;
|
||||
virtual void StopEnvironmentDepth() = 0;
|
||||
virtual bool IsEnvironmentDepthStarted() = 0;
|
||||
virtual void SetEnvironmentDepthHandRemoval(bool RemoveHands) = 0;
|
||||
virtual void SetXROcclusionsMode(UObject* WorldContextObject, EOculusXROcclusionsMode Mode) = 0;
|
||||
virtual void SetEyeBufferSharpenType(EOculusXREyeBufferSharpenType EyeBufferSharpenType) = 0;
|
||||
virtual bool IsPassthroughRecommended() = 0;
|
||||
virtual void GetOpenXRInstanceProcAddrFunc(void** Func) = 0;
|
||||
virtual void GetNativeOpenXRHandles(uint64_t* OutXrInstance, uint64_t* OutXrSession) = 0;
|
||||
virtual void GetAppSpace(uint64_t* OutAppSpace) = 0;
|
||||
virtual void GetNextPredictedDisplayTime(uint64_t* NextPredictedDisplayTime) = 0;
|
||||
virtual void RegisterOpenXrEventHandler(void (*OpenXrEventHandler)(void* data, void* context), void* Context) = 0;
|
||||
virtual void UnregisterOpenXrEventHandler(void (*OpenXrEventHandler)(void* data, void* context)) = 0;
|
||||
};
|
||||
} // namespace OculusXRHMD
|
||||
|
||||
UCLASS()
|
||||
class OCULUSXRHMD_API UOculusXRFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
/**
|
||||
* Grabs the current orientation and position for the HMD. If positional tracking is not available, DevicePosition will be a zero vector
|
||||
*
|
||||
* @param DeviceRotation (out) The device's current rotation
|
||||
* @param DevicePosition (out) The device's current position, in its own tracking space
|
||||
* @param NeckPosition (out) The estimated neck position, calculated using NeckToEye vector from User Profile. Same coordinate space as DevicePosition.
|
||||
* @param bUseOrienationForPlayerCamera (in) Should be set to 'true' if the orientation is going to be used to update orientation of the camera manually.
|
||||
* @param bUsePositionForPlayerCamera (in) Should be set to 'true' if the position is going to be used to update position of the camera manually.
|
||||
* @param PositionScale (in) The 3D scale that will be applied to position.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static void GetPose(FRotator& DeviceRotation, FVector& DevicePosition, FVector& NeckPosition, bool bUseOrienationForPlayerCamera = false, bool bUsePositionForPlayerCamera = false, const FVector PositionScale = FVector::ZeroVector);
|
||||
|
||||
/**
|
||||
* Reports raw sensor data. If HMD doesn't support any of the parameters then it will be set to zero.
|
||||
*
|
||||
* @param AngularAcceleration [Deprecated] (out) Angular acceleration in radians per second per second.
|
||||
* @param LinearAcceleration [Deprecated] (out) Acceleration in meters per second per second.
|
||||
* @param AngularVelocity (out) Angular velocity in radians per second.
|
||||
* @param LinearVelocity (out) Velocity in meters per second.
|
||||
* @param TimeInSeconds (out) Time when the reported IMU reading took place, in seconds.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static void GetRawSensorData(FVector& AngularAcceleration, FVector& LinearAcceleration, FVector& AngularVelocity, FVector& LinearVelocity, float& TimeInSeconds, EOculusXRTrackedDeviceType DeviceType = EOculusXRTrackedDeviceType::HMD);
|
||||
|
||||
/**
|
||||
* Returns if the device is currently tracked by the runtime or not.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static bool IsDeviceTracked(EOculusXRTrackedDeviceType DeviceType);
|
||||
|
||||
/**
|
||||
* Set the CPU and GPU levels as hints to the Oculus device (Deprecated).
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary", meta = (DeprecatedFunction, DeprecatedMessage = "Deprecated. Please use Get/SetSuggestedCpuAndGpuPerformanceLevels instead"))
|
||||
static void SetCPUAndGPULevels(int CPULevel, int GPULevel);
|
||||
|
||||
/**
|
||||
* Get the suggested CPU and GPU levels to the Oculus device.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void GetSuggestedCpuAndGpuPerformanceLevels(EOculusXRProcessorPerformanceLevel& CpuPerfLevel, EOculusXRProcessorPerformanceLevel& GpuPerfLevel);
|
||||
|
||||
/**
|
||||
* Set the suggested CPU and GPU levels to the Oculus device.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void SetSuggestedCpuAndGpuPerformanceLevels(EOculusXRProcessorPerformanceLevel CpuPerfLevel, EOculusXRProcessorPerformanceLevel GpuPerfLevel);
|
||||
|
||||
/**
|
||||
* Returns current user profile.
|
||||
*
|
||||
* @param Profile (out) Structure to hold current user profile.
|
||||
* @return (boolean) True, if user profile was acquired.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static bool GetUserProfile(FOculusXRHmdUserProfile& Profile);
|
||||
|
||||
/**
|
||||
* Sets 'base rotation' - the rotation that will be subtracted from
|
||||
* the actual HMD orientation.
|
||||
* Sets base position offset (in meters). The base position offset is the distance from the physical (0, 0, 0) position
|
||||
* to current HMD position (bringing the (0, 0, 0) point to the current HMD position)
|
||||
* Note, this vector is set by ResetPosition call; use this method with care.
|
||||
* The axis of the vector are the same as in Unreal: X - forward, Y - right, Z - up.
|
||||
*
|
||||
* @param Rotation (in) Rotator object with base rotation
|
||||
* @param BaseOffsetInMeters (in) the vector to be set as base offset, in meters.
|
||||
* @param Options (in) specifies either position, orientation or both should be set.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void SetBaseRotationAndBaseOffsetInMeters(FRotator Rotation, FVector BaseOffsetInMeters, EOrientPositionSelector::Type Options);
|
||||
|
||||
/**
|
||||
* Returns current base rotation and base offset.
|
||||
* The base offset is currently used base position offset, previously set by the
|
||||
* ResetPosition or SetBasePositionOffset calls. It represents a vector that translates the HMD's position
|
||||
* into (0,0,0) point, in meters.
|
||||
* The axis of the vector are the same as in Unreal: X - forward, Y - right, Z - up.
|
||||
*
|
||||
* @param OutRotation (out) Rotator object with base rotation
|
||||
* @param OutBaseOffsetInMeters (out) base position offset, vector, in meters.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static void GetBaseRotationAndBaseOffsetInMeters(FRotator& OutRotation, FVector& OutBaseOffsetInMeters);
|
||||
|
||||
/**
|
||||
* Scales the HMD position that gets added to the virtual camera position.
|
||||
*
|
||||
* @param PosScale3D (in) the scale to apply to the HMD position.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary", meta = (DeprecatedFunction, DeprecationMessage = "This feature is no longer supported."))
|
||||
static void SetPositionScale3D(FVector PosScale3D) {}
|
||||
|
||||
/**
|
||||
* Sets 'base rotation' - the rotation that will be subtracted from
|
||||
* the actual HMD orientation.
|
||||
* The position offset might be added to current HMD position,
|
||||
* effectively moving the virtual camera by the specified offset. The addition
|
||||
* occurs after the HMD orientation and position are applied.
|
||||
*
|
||||
* @param BaseRot (in) Rotator object with base rotation
|
||||
* @param PosOffset (in) the vector to be added to HMD position.
|
||||
* @param Options (in) specifies either position, orientation or both should be set.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary", meta = (DeprecatedFunction, DeprecationMessage = "A hack, proper camera positioning should be used"))
|
||||
static void SetBaseRotationAndPositionOffset(FRotator BaseRot, FVector PosOffset, EOrientPositionSelector::Type Options);
|
||||
|
||||
/**
|
||||
* Returns current base rotation and position offset.
|
||||
*
|
||||
* @param OutRot (out) Rotator object with base rotation
|
||||
* @param OutPosOffset (out) the vector with previously set position offset.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary", meta = (DeprecatedFunction, DeprecationMessage = "A hack, proper camera positioning should be used"))
|
||||
static void GetBaseRotationAndPositionOffset(FRotator& OutRot, FVector& OutPosOffset);
|
||||
|
||||
/**
|
||||
* Adds loading splash screen with parameters
|
||||
*
|
||||
* @param Texture (in) A texture asset to be used for the splash.
|
||||
* @param TranslationInMeters (in) Initial translation of the center of the splash screen (in meters).
|
||||
* @param Rotation (in) Initial rotation of the splash screen, with the origin at the center of the splash screen.
|
||||
* @param SizeInMeters (in) Size, in meters, of the quad with the splash screen.
|
||||
* @param DeltaRotation (in) Incremental rotation, that is added each 2nd frame to the quad transform. The quad is rotated around the center of the quad.
|
||||
* @param bClearBeforeAdd (in) If true, clears splashes before adding a new one.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary", meta = (DeprecatedFunction, DeprecationMessage = "Use Add Loading Screen Splash from the Head Mounted Display Loading Screen functions instead."))
|
||||
static void AddLoadingSplashScreen(class UTexture2D* Texture, FVector TranslationInMeters, FRotator Rotation, FVector2D SizeInMeters = FVector2D(1.0f, 1.0f), FRotator DeltaRotation = FRotator::ZeroRotator, bool bClearBeforeAdd = false);
|
||||
|
||||
/**
|
||||
* Removes all the splash screens.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary", meta = (DeprecatedFunction, DeprecationMessage = "Use Clear Loading Screen Splashes from the Head Mounted Display Loading Screen functions instead."))
|
||||
static void ClearLoadingSplashScreens();
|
||||
|
||||
/**
|
||||
* Returns true, if the app has input focus.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static bool HasInputFocus();
|
||||
|
||||
/**
|
||||
* Returns true, if the system overlay is present.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static bool HasSystemOverlayPresent();
|
||||
|
||||
/**
|
||||
* Returns the GPU utilization availability and value
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static void GetGPUUtilization(bool& IsGPUAvailable, float& GPUUtilization);
|
||||
|
||||
/**
|
||||
* Returns the GPU frame time on supported mobile platforms (Go for now)
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static float GetGPUFrameTime();
|
||||
|
||||
/**
|
||||
* Returns the performance metrics
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static void GetPerformanceMetrics(FOculusXRPerformanceMetrics& PerformanceMetrics);
|
||||
|
||||
/**
|
||||
* Returns the foveated rendering method currently being used.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static EOculusXRFoveatedRenderingMethod GetFoveatedRenderingMethod();
|
||||
|
||||
/**
|
||||
* Set the requested foveated rendering method. Changes to foveated rendering persist across map changes.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void SetFoveatedRenderingMethod(EOculusXRFoveatedRenderingMethod Method);
|
||||
|
||||
/**
|
||||
* Returns the current multiresolution level
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static EOculusXRFoveatedRenderingLevel GetFoveatedRenderingLevel();
|
||||
|
||||
/**
|
||||
* Set the requested foveated rendering level for the next frame, and whether FFR's level is now dynamic or not. Changes to foveated rendering persist across map changes.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void SetFoveatedRenderingLevel(EOculusXRFoveatedRenderingLevel level, bool isDynamic);
|
||||
|
||||
/**
|
||||
* Returns whether eye-tracked foveated rendering is supported or not
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static bool GetEyeTrackedFoveatedRenderingSupported();
|
||||
|
||||
/**
|
||||
* Returns the current device's name
|
||||
*/
|
||||
UE_DEPRECATED(4.22, "UOculusXRFunctionLibrary::GetDeviceName has been deprecated and no longer functions as before. Please use the enum-based GetDeviceType instead.")
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary", meta = (DeprecatedFunction, DeprecationMessage = "UOculusXRFunctionLibrary::GetDeviceName has been deprecated and no longer functions as before. Please use the enum-based GetDeviceType instead."))
|
||||
static FString GetDeviceName();
|
||||
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static EOculusXRDeviceType GetDeviceType();
|
||||
|
||||
/**
|
||||
* Returns the current controller's type
|
||||
* @param deviceHand (in) The hand to get the position from
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static EOculusXRControllerType GetControllerType(EControllerHand deviceHand);
|
||||
|
||||
/**
|
||||
* Returns the current available frequencies
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static TArray<float> GetAvailableDisplayFrequencies();
|
||||
|
||||
/**
|
||||
* Returns the current display frequency
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static float GetCurrentDisplayFrequency();
|
||||
|
||||
/**
|
||||
* Sets the requested display frequency
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void SetDisplayFrequency(float RequestedFrequency);
|
||||
|
||||
/**
|
||||
* Enables/disables positional tracking on devices that support it.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void EnablePositionTracking(bool bPositionTracking);
|
||||
|
||||
/**
|
||||
* Enables/disables orientation tracking on devices that support it.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void EnableOrientationTracking(bool bOrientationTracking);
|
||||
|
||||
/**
|
||||
* Set the Color Scale/Offset
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void SetColorScaleAndOffset(FLinearColor ColorScale, FLinearColor ColorOffset, bool bApplyToAllLayers = false);
|
||||
|
||||
/**
|
||||
* Returns true if system headset is in 3dof mode
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static bool GetSystemHmd3DofModeEnabled();
|
||||
|
||||
/**
|
||||
* Returns the color space of the target HMD
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static EOculusXRColorSpace GetHmdColorDesc();
|
||||
|
||||
/**
|
||||
* Sets the target HMD to do color space correction to a specific color space
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void SetClientColorDesc(EOculusXRColorSpace ColorSpace);
|
||||
|
||||
/**
|
||||
* Turns on or off local dimming
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void SetLocalDimmingOn(bool LocalDimmingOn);
|
||||
|
||||
/**
|
||||
* Checks if passthrough is supported
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static bool IsPassthroughSupported();
|
||||
|
||||
/**
|
||||
* Checks if color passthrough is supported
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static bool IsColorPassthroughSupported();
|
||||
|
||||
/**
|
||||
* Create the environment depth texture swap chain and start receiving
|
||||
* depth texture every frame until stopped.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void StartEnvironmentDepth();
|
||||
|
||||
/**
|
||||
* Destroy the environment depth texture swap chain and stop receiving
|
||||
* new depth textures every frame. Call this when environment depth is
|
||||
* no longer needed to free up resources.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void StopEnvironmentDepth();
|
||||
|
||||
/**
|
||||
* Returns true if StartEnvironmentDepth() has been called and is currently running.
|
||||
* If called right after calling StartEnvironmentDepth() it'll return false as it needs some time for EnvironmentDepth to start
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary")
|
||||
static bool IsEnvironmentDepthStarted();
|
||||
|
||||
/**
|
||||
* When hands removal is enabled and hand tracking is active, the region
|
||||
* of the depth texture which contains the hands will be replaced with
|
||||
* the best estimate for depth behind the hands.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void SetEnvironmentDepthHandRemoval(bool RemoveHands);
|
||||
|
||||
/**
|
||||
* Sets the occlusions mode using environment depth. When occlusions are enabled
|
||||
* virtual objects that are behind physical objects will be occluded so that
|
||||
* the sense of immersion is preserved.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary", meta = (WorldContext = "WorldContextObject"))
|
||||
static void SetXROcclusionsMode(UObject* WorldContextObject, EOculusXROcclusionsMode Mode);
|
||||
|
||||
/**
|
||||
* Sets the eyebuffer sharpen type. This amplifies contrast and fine details.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static void SetEyeBufferSharpenType(EOculusXREyeBufferSharpenType EyeBufferSharpenType);
|
||||
|
||||
/**
|
||||
* Get a system recommendation on whether Passthrough should be active.
|
||||
* When set, it is recommended for apps which optionally support an MR experience
|
||||
* with Passthrough to default to that mode.
|
||||
* Currently, this is determined based on whether the user has Passthrough active in the home environment.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary")
|
||||
static bool IsPassthroughRecommended();
|
||||
|
||||
/**
|
||||
* Returns IStereoLayers interface to work with overlays.
|
||||
*/
|
||||
static class IStereoLayers* GetStereoLayers();
|
||||
|
||||
|
||||
/* GUARDIAN API */
|
||||
/**
|
||||
* Returns true if the Guardian Outer Boundary is being displayed
|
||||
*/
|
||||
UE_DEPRECATED(4.27, "UOculusXRFunctionLibrary::IsGuardianDisplayed has been deprecated.")
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary|Guardian")
|
||||
static bool IsGuardianDisplayed();
|
||||
|
||||
/* GUARDIAN API */
|
||||
/**
|
||||
* Returns true if the Guardian has been set up by the user, false if the user is in "seated" mode and has not set up a play space.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary|Guardian")
|
||||
static bool IsGuardianConfigured();
|
||||
|
||||
/**
|
||||
* Returns the list of points in UE world space of the requested Boundary Type
|
||||
* @param BoundaryType (in) An enum representing the boundary type requested, either Outer Boundary (exact guardian bounds) or PlayArea (rectangle inside the Outer Boundary)
|
||||
* @param UsePawnSpace (in) Boolean indicating to return the points in world space or pawn space
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary|Guardian")
|
||||
static TArray<FVector> GetGuardianPoints(EOculusXRBoundaryType BoundaryType, bool UsePawnSpace = false);
|
||||
|
||||
/**
|
||||
* Returns the dimensions in UE world space of the requested Boundary Type
|
||||
* @param BoundaryType (in) An enum representing the boundary type requested, either Outer Boundary (exact guardian bounds) or PlayArea (rectangle inside the Outer Boundary)
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary|Guardian")
|
||||
static FVector GetGuardianDimensions(EOculusXRBoundaryType BoundaryType);
|
||||
|
||||
/**
|
||||
* Returns the transform of the play area rectangle, defining its position, rotation and scale to apply to a unit cube to match it with the play area.
|
||||
*/
|
||||
UFUNCTION(BlueprintPure, Category = "OculusLibrary|Guardian")
|
||||
static FTransform GetPlayAreaTransform();
|
||||
|
||||
/**
|
||||
* Get the intersection result between a UE4 coordinate and a guardian boundary
|
||||
* @param Point (in) Point in UE space to test against guardian boundaries
|
||||
* @param BoundaryType (in) An enum representing the boundary type requested, either Outer Boundary (exact guardian bounds) or PlayArea (rectangle inside the Outer Boundary)
|
||||
*/
|
||||
UE_DEPRECATED(4.27, "UOculusXRFunctionLibrary::GetPointGuardianIntersection has been deprecated.")
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary|Guardian")
|
||||
static FOculusXRGuardianTestResult GetPointGuardianIntersection(const FVector Point, EOculusXRBoundaryType BoundaryType);
|
||||
|
||||
/**
|
||||
* Get the intersection result between a tracked device (HMD or controllers) and a guardian boundary
|
||||
* @param DeviceType (in) Tracked Device type to test against guardian boundaries
|
||||
* @param BoundaryType (in) An enum representing the boundary type requested, either Outer Boundary (exact guardian bounds) or PlayArea (rectangle inside the Outer Boundary)
|
||||
*/
|
||||
UE_DEPRECATED(4.27, "UOculusXRFunctionLibrary::GetNodeGuardianIntersection has been deprecated.")
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary|Guardian")
|
||||
static FOculusXRGuardianTestResult GetNodeGuardianIntersection(EOculusXRTrackedDeviceType DeviceType, EOculusXRBoundaryType BoundaryType);
|
||||
|
||||
/**
|
||||
* Forces the runtime to render guardian at all times or not
|
||||
* @param GuardianVisible (in) True will display guardian, False will hide it
|
||||
*/
|
||||
UE_DEPRECATED(4.27, "UOculusXRFunctionLibrary::SetGuardianVisibility has been deprecated.")
|
||||
UFUNCTION(BlueprintCallable, Category = "OculusLibrary|Guardian")
|
||||
static void SetGuardianVisibility(bool GuardianVisible);
|
||||
|
||||
/** When player triggers the Guardian boundary */
|
||||
DECLARE_MULTICAST_DELEGATE_OneParam(FOculusGuardianTriggeredEvent, FOculusXRGuardianTestResult);
|
||||
|
||||
/** When player returns within outer bounds */
|
||||
DECLARE_MULTICAST_DELEGATE(FOculusGuardianReturnedEvent);
|
||||
|
||||
/**
|
||||
* For outer boundary only. Devs can bind delegates via something like: BoundaryComponent->OnOuterBoundaryTriggered.AddDynamic(this, &UCameraActor::PauseGameForBoundarySystem) where
|
||||
* PauseGameForBoundarySystem() takes a TArray<FBoundaryTestResult> parameter.
|
||||
*/
|
||||
// UPROPERTY(BlueprintAssignable, Category = "Input|OculusLibrary|Guardian")
|
||||
// static FOculusGuardianTriggeredEvent OnGuardianTriggered;
|
||||
|
||||
/** For outer boundary only. Devs can bind delegates via something like: BoundaryComponent->OnOuterBoundaryReturned.AddDynamic(this, &UCameraActor::ResumeGameForBoundarySystem) */
|
||||
// UPROPERTY(BlueprintAssignable, Category = "OculusLibrary|Guardian")
|
||||
// FOculusGuardianReturnedEvent OnGuardianReturned;
|
||||
|
||||
static void ShutdownXRFunctionLibrary();
|
||||
|
||||
protected:
|
||||
static class OculusXRHMD::FOculusXRHMD* GetOculusXRHMD();
|
||||
static TSharedPtr<OculusXRHMD::IOculusXRFunctionLibrary> GetOculusXRFunctionImpl();
|
||||
static TSharedPtr<OculusXRHMD::IOculusXRFunctionLibrary> FunctionLibraryImpl;
|
||||
|
||||
private:
|
||||
friend class UMRUKSubsytem;
|
||||
|
||||
static void GetOpenXRInstanceProcAddrFunc(void** func);
|
||||
|
||||
static void GetNativeOpenXRHandles(uint64_t* OutXrInstance, uint64_t* OutXrSession);
|
||||
|
||||
static void GetAppSpace(uint64_t* OutAppSpace);
|
||||
|
||||
static void GetNextPredictedDisplayTime(uint64_t* NextPredictedDisplayTime);
|
||||
|
||||
static void RegisterOpenXrEventHandler(void (*OpenXrEventHandler)(void* data, void* context), void* Context);
|
||||
|
||||
static void UnregisterOpenXrEventHandler(void (*OpenXrEventHandler)(void* data, void* context));
|
||||
};
|
||||
@@ -0,0 +1,268 @@
|
||||
// @lint-ignore-every LICENSELINT
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/Object.h"
|
||||
#include "OculusXRHMDTypes.h"
|
||||
#include "OculusXRFunctionLibrary.h"
|
||||
#include "OculusXRHMDRuntimeSettings.generated.h"
|
||||
|
||||
UENUM()
|
||||
enum class EOculusXRSupportedDevices : uint8
|
||||
{
|
||||
/** 0 was the deprecated Meta Quest */
|
||||
Quest2 = 1 UMETA(DisplayName = "Meta Quest 2"),
|
||||
QuestPro = 2 UMETA(DisplayName = "Meta Quest Pro"),
|
||||
Quest3 = 3 UMETA(DisplayName = "Meta Quest 3"),
|
||||
Quest3S = 4 UMETA(DisplayName = "Meta Quest 3S")
|
||||
};
|
||||
|
||||
/**
|
||||
* Implements the settings for the OculusVR plugin.
|
||||
*/
|
||||
UCLASS(config = Engine, defaultconfig)
|
||||
class OCULUSXRHMD_API UOculusXRHMDRuntimeSettings : public UObject
|
||||
{
|
||||
GENERATED_UCLASS_BODY()
|
||||
|
||||
public:
|
||||
/** Configure System Splash Screen background type. To configure Splash Image go to Project Settings > Platforms > Android > Launch Image. */
|
||||
UPROPERTY(config, EditAnywhere, Category = "System SplashScreen", meta = (DisplayName = "System Splash Screen Background", EditCondition = "!bInsightPassthroughEnabled"))
|
||||
ESystemSplashBackgroundType SystemSplashBackground;
|
||||
|
||||
/** Whether the Splash screen is enabled. */
|
||||
UPROPERTY(config, EditAnywhere, Category = "Engine SplashScreen")
|
||||
bool bAutoEnabled;
|
||||
|
||||
/** An array of splash screen descriptors listing textures to show and their positions. */
|
||||
UPROPERTY(config, EditAnywhere, Category = "Engine SplashScreen")
|
||||
TArray<FOculusXRSplashDesc> SplashDescs;
|
||||
|
||||
/**
|
||||
This selects the XR API that the engine will use. If unsure, OVRPlugin OpenXR is the recommended API.
|
||||
The OpenXR plugin must also be enabled to use Native OpenXR.
|
||||
*/
|
||||
UPROPERTY(config, EditAnywhere, Category = General, meta = (DisplayName = "XR API", ConfigRestartRequired = true))
|
||||
EOculusXRXrApi XrApi;
|
||||
|
||||
/** The target color space */
|
||||
UPROPERTY(config, EditAnywhere, Category = General)
|
||||
EOculusXRColorSpace ColorSpace;
|
||||
|
||||
/** Whether the controller hand poses align to the Meta XR pose definitions or the OpenXR pose definitions */
|
||||
UPROPERTY(config, EditAnywhere, Category = General, meta = (EditCondition = "XrApi != EOculusXRXrApi::NativeOpenXR"))
|
||||
EOculusXRControllerPoseAlignment ControllerPoseAlignment;
|
||||
|
||||
/** Whether the app uses emulated thumbstick dpad inputs (ex: thumbstick up) when using Epic's Native OpenXR. */
|
||||
UPROPERTY(config, EditAnywhere, Category = General, meta = (EditCondition = "XrApi == EOculusXRXrApi::NativeOpenXR"))
|
||||
bool bThumbstickDpadEmulationEnabled;
|
||||
|
||||
/** Whether Dash is supported by the app, which will keep the app in foreground when the User presses the oculus button (needs the app to handle input focus loss!) */
|
||||
UPROPERTY(config, EditAnywhere, Category = PC)
|
||||
bool bSupportsDash;
|
||||
|
||||
/** Whether the app's depth buffer is shared with the Rift Compositor, for layer (including Dash) compositing, PTW, and potentially more. */
|
||||
UPROPERTY(config, EditAnywhere, Category = PC)
|
||||
bool bCompositesDepth;
|
||||
|
||||
/** Computes mipmaps for the eye buffers every frame, for a higher quality distortion */
|
||||
UPROPERTY(config, EditAnywhere, Category = PC)
|
||||
bool bHQDistortion;
|
||||
|
||||
/** When running multiple player windows in a single process with VRPreview, this option determins whether to set the current active PIE to the primary one on the fly.*/
|
||||
UPROPERTY(config, EditAnywhere, Category = "PC|Multiplayer Options", meta = (DisplayName = "Set Active PIE To Primary"))
|
||||
bool bSetActivePIEToPrimary;
|
||||
|
||||
/** When running multiple player windows in a single process with VRPreview, this option determins whether to set the PIE specified by CVar vr.PrimaryPIEIndex to the primary one on the fly.*/
|
||||
UPROPERTY(config, EditAnywhere, Category = "PC|Multiplayer Options", meta = (DisplayName = "Set CVar PIE To Primary"))
|
||||
bool bSetCVarPIEToPrimary;
|
||||
|
||||
/**
|
||||
In case of multiple players testing, when the current player is inactive, disabling this setting will make sure the current player does NOT update headpose until it is active again.
|
||||
This setting is not limited to multiple players testing and it will be applied to any VRPreview PIE window.
|
||||
*/
|
||||
UPROPERTY(config, EditAnywhere, Category = "PC|Multiplayer Options", meta = (DisplayName = "Enable head pose update for inactive VRPreview player."))
|
||||
bool bUpdateHeadPoseForInactivePlayer;
|
||||
|
||||
/**
|
||||
In case of multiple players testing, when the primary player, which is connected to the HMD, is changed, this setting determins how to restore the previous player's head pose
|
||||
*/
|
||||
UPROPERTY(config, EditAnywhere, Category = "PC|Multiplayer Options", meta = (DisplayName = "MultiPlayer Pose Restore Type."))
|
||||
EOculusXRMPPoseRestoreType MPPoseRestoreType;
|
||||
|
||||
/** Maximum allowed pixel density. */
|
||||
UPROPERTY(config, EditAnywhere, Category = "Mobile|Dynamic Resolution", DisplayName = "Enable Dynamic Resolution. (min, max) can be set in device profile.")
|
||||
bool bDynamicResolution;
|
||||
|
||||
/** Minimum allowed pixel density. */
|
||||
UPROPERTY(config, meta = (DeprecatedProperty, DeprecationMessage = "Use DynamicResolutionSettings instead."))
|
||||
float PixelDensityMin;
|
||||
|
||||
/** Maximum allowed pixel density. */
|
||||
UPROPERTY(config, meta = (DeprecatedProperty, DeprecationMessage = "Use DynamicResolutionSettings instead."))
|
||||
float PixelDensityMax;
|
||||
|
||||
/** Default CPU level controlling CPU frequency on the mobile device */
|
||||
UPROPERTY(config, meta = (DeprecatedProperty, DeprecationMessage = "Use Blueprint Function Get/SetSuggestedCpuAndGpuPerformanceLevels instead."))
|
||||
int CPULevel_DEPRECATED;
|
||||
|
||||
/** Default GPU level controlling GPU frequency on the mobile device */
|
||||
UPROPERTY(config, meta = (DeprecatedProperty, DeprecationMessage = "Use Blueprint Function Get/SetSuggestedCpuAndGpuPerformanceLevels instead."))
|
||||
int GPULevel_DEPRECATED;
|
||||
|
||||
/** Select supported Meta Quest Devices */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Supported Meta Quest devices"))
|
||||
TArray<EOculusXRSupportedDevices> SupportedDevices;
|
||||
|
||||
/** Suggested CPU perf level when application starts on Oculus Quest */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile)
|
||||
EOculusXRProcessorPerformanceLevel SuggestedCpuPerfLevel;
|
||||
|
||||
/** Suggested GPU perf level when application starts on Oculus Quest */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile)
|
||||
EOculusXRProcessorPerformanceLevel SuggestedGpuPerfLevel;
|
||||
|
||||
/** Foveated rendering method */
|
||||
UPROPERTY(config, EditAnywhere, Category = "Mobile|Foveated Rendering", meta = (EditCondition = "XrApi == EOculusXRXrApi::OVRPluginOpenXR"))
|
||||
EOculusXRFoveatedRenderingMethod FoveatedRenderingMethod;
|
||||
|
||||
/** Foveated rendering level (maximum level for dynamic foveated rendering)
|
||||
* A higher foveated rendering level improves GPU performance at the cost of a blurrier periphery
|
||||
*/
|
||||
UPROPERTY(config, EditAnywhere, Category = "Mobile|Foveated Rendering")
|
||||
EOculusXRFoveatedRenderingLevel FoveatedRenderingLevel;
|
||||
|
||||
/** Whether foveated rendering levels will change dynamically based on performance headroom or not (up to the set foveated rendering level) */
|
||||
UPROPERTY(config, EditAnywhere, Category = "Mobile|Foveated Rendering")
|
||||
bool bDynamicFoveatedRendering;
|
||||
|
||||
/** Whether eye tracked foveated rendering can be used with the app. */
|
||||
UPROPERTY(config, EditAnywhere, Category = "Mobile|Foveated Rendering", meta = (EditCondition = "XrApi == EOculusXRXrApi::OVRPluginOpenXR"))
|
||||
bool bSupportEyeTrackedFoveatedRendering;
|
||||
|
||||
/** Whether the app's depth buffer is shared with the compositor to enable depth testing against other layers.
|
||||
Mobile depth composition has performance overhead both on the engine (for resolving depth) and on the compositor (for depth testing against other layers) */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Composite Depth"))
|
||||
bool bCompositeDepthMobile;
|
||||
|
||||
/** If enabled the app will be focus aware. This will keep the app in foreground when the User presses the oculus button (needs the app to handle input focus loss!) */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (EditCondition = "false"))
|
||||
bool bFocusAware;
|
||||
|
||||
/** [Experimental]Enable Late latching for reducing HMD and controller latency, improve tracking prediction quality, multiview and vulkan must be enabled for this feature. */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile)
|
||||
bool bLateLatching;
|
||||
|
||||
/** If enabled the app will use the Oculus system keyboard for input fields. This requires that the app be focus aware. */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile)
|
||||
bool bRequiresSystemKeyboard;
|
||||
|
||||
/** Whether controllers and/or hands can be used with the app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile)
|
||||
EOculusXRHandTrackingSupport HandTrackingSupport;
|
||||
|
||||
/** Note that a higher tracking frequency will reserve some performance headroom from the application's budget. */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile)
|
||||
EOculusXRHandTrackingFrequency HandTrackingFrequency;
|
||||
|
||||
/** The version of hand tracking algorithm */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile)
|
||||
EOculusXRHandTrackingVersion HandTrackingVersion;
|
||||
|
||||
/** Whether passthrough functionality can be used with the app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Passthrough Enabled"))
|
||||
bool bInsightPassthroughEnabled;
|
||||
|
||||
/** Whether Spatial Anchors can be used with the app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Anchor Support"))
|
||||
bool bAnchorSupportEnabled;
|
||||
|
||||
/** Whether Spatial Anchor Sharing can be used with the app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Anchor Sharing"))
|
||||
bool bAnchorSharingEnabled;
|
||||
|
||||
/** Whether Scene can be used with the app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Scene Support"))
|
||||
bool bSceneSupportEnabled;
|
||||
|
||||
/** Can boundary visibility be toggled in app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Boundary Visibility Support"))
|
||||
bool bBoundaryVisibilitySupportEnabled;
|
||||
|
||||
/** Should the guardian boundary visibility be suppressed by default */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Default Is Boundary Visibility Suppressed"))
|
||||
bool bDefaultBoundaryVisibilitySuppressed;
|
||||
|
||||
/** Whether Colocation Sessions can be used with the app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Colocation Sessions"))
|
||||
bool bColocationSessionsEnabled;
|
||||
|
||||
/** Whether body tracking functionality can be used with the app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Body Tracking Enabled", EditCondition = "XrApi == EOculusXRXrApi::OVRPluginOpenXR"))
|
||||
bool bBodyTrackingEnabled;
|
||||
|
||||
/** Select a Body Tracking Fidelity */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Body Tracking Fidelity", EditCondition = "XrApi == EOculusXRXrApi::OVRPluginOpenXR"))
|
||||
EOculusXRHMDBodyTrackingFidelity BodyTrackingFidelity;
|
||||
|
||||
/** Select a Body Tracking joint set */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Body Tracking Joint Set", EditCondition = "XrApi == EOculusXRXrApi::OVRPluginOpenXR"))
|
||||
EOculusXRHMDBodyJointSet BodyTrackingJointSet;
|
||||
|
||||
/** Whether eye tracking functionality can be used with the app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Eye Tracking Enabled", EditCondition = "XrApi == EOculusXRXrApi::OVRPluginOpenXR"))
|
||||
bool bEyeTrackingEnabled;
|
||||
|
||||
/** Whether face tracking functionality can be used with the app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Face Tracking Enabled", EditCondition = "XrApi == EOculusXRXrApi::OVRPluginOpenXR"))
|
||||
bool bFaceTrackingEnabled;
|
||||
|
||||
/** Select preffered Face Tracking data sources */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Face Tracking Source", EditCondition = "XrApi == EOculusXRXrApi::OVRPluginOpenXR"))
|
||||
TSet<EFaceTrackingDataSourceConfig> FaceTrackingDataSource;
|
||||
|
||||
/** Whether face tracking returns visemes */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Face Tracking Visemes Enabled", EditCondition = "XrApi == EOculusXRXrApi::OVRPluginOpenXR"))
|
||||
bool bFaceTrackingVisemesEnabled;
|
||||
|
||||
/** On supported Oculus mobile platforms, copy compiled .so directly to device. Allows updating compiled code without rebuilding and installing an APK. */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Deploy compiled .so directly to device"))
|
||||
bool bDeploySoToDevice;
|
||||
|
||||
/** Keep previously deployed device contents. Allows cook-on-the-fly to reuse assets from previous runs. */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Enable Iterative Cook on the Fly"))
|
||||
bool bIterativeCookOnTheFly;
|
||||
|
||||
/** Whether experimental features listed below can be used with the app. */
|
||||
UPROPERTY(config, EditAnywhere, Category = Experimental)
|
||||
bool bSupportExperimentalFeatures;
|
||||
|
||||
/** If selected, will increase the frequency of one processor at the expense of decreasing the frequency of the other on supported devices. */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Processor Favor"))
|
||||
EProcessorFavor ProcessorFavor;
|
||||
|
||||
/** Whether Tile Turn Off is enabled in app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Tile Turn Off", EditCondition = "false"))
|
||||
bool bTileTurnOffEnabled;
|
||||
|
||||
/** Whether Shader Binary Cache is enabled in app */
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Shader Binary Cache"))
|
||||
bool bSupportSBC;
|
||||
|
||||
/** Shader Binary Cache path used to save shader cache*/
|
||||
UPROPERTY(config, EditAnywhere, Category = Mobile, meta = (DisplayName = "Shader Binary Cache Path", EditCondition = "bSupportSBC"))
|
||||
FString SBCPath;
|
||||
|
||||
private:
|
||||
#if WITH_EDITOR
|
||||
virtual bool CanEditChange(const FProperty* InProperty) const override;
|
||||
virtual void PostEditChangeProperty(struct FPropertyChangedEvent& PropertyChangedEvent) override;
|
||||
#endif // WITH_EDITOR
|
||||
virtual void PostInitProperties() override;
|
||||
|
||||
void LoadFromIni();
|
||||
void RenameProperties();
|
||||
void MigratePixelDensityRange();
|
||||
};
|
||||
436
Plugins/MetaXR/Source/OculusXRHMD/Public/OculusXRHMDTypes.h
Normal file
436
Plugins/MetaXR/Source/OculusXRHMD/Public/OculusXRHMDTypes.h
Normal file
@@ -0,0 +1,436 @@
|
||||
// @lint-ignore-every LICENSELINT
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "UObject/ObjectMacros.h"
|
||||
#include "RHI.h"
|
||||
#include "RHIResources.h"
|
||||
#include "Engine/Texture2D.h"
|
||||
#include "UObject/SoftObjectPath.h"
|
||||
#include "OculusXRHMDTypes.generated.h"
|
||||
|
||||
static const TCHAR* VAR_PixelDensityMin = TEXT("r.Oculus.DynamicResolution.PixelDensityMin");
|
||||
static const TCHAR* VAR_PixelDensityMax = TEXT("r.Oculus.DynamicResolution.PixelDensityMax");
|
||||
/* Tracked device types corresponding to ovrTrackedDeviceType enum*/
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRTrackedDeviceType : uint8
|
||||
{
|
||||
None UMETA(DisplayName = "No Devices"),
|
||||
HMD UMETA(DisplayName = "HMD"),
|
||||
LTouch UMETA(DisplayName = "Left Hand"),
|
||||
RTouch UMETA(DisplayName = "Right Hand"),
|
||||
Touch UMETA(DisplayName = "All Hands"),
|
||||
DeviceObjectZero UMETA(DisplayName = "DeviceObject Zero"),
|
||||
All UMETA(DisplayName = "All Devices")
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType, meta = (DisplayName = "HMD User Profile Data Field"))
|
||||
struct FOculusXRHmdUserProfileField
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Input|HeadMountedDisplay")
|
||||
FString FieldName;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Input|HeadMountedDisplay")
|
||||
FString FieldValue;
|
||||
|
||||
FOculusXRHmdUserProfileField() {}
|
||||
FOculusXRHmdUserProfileField(const FString& Name, const FString& Value)
|
||||
: FieldName(Name), FieldValue(Value) {}
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType, meta = (DisplayName = "HMD User Profile Data"))
|
||||
struct FOculusXRHmdUserProfile
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
/** Name of the user's profile. */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Input|HeadMountedDisplay")
|
||||
FString Name;
|
||||
|
||||
/** Gender of the user ("male", "female", etc). */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Input|HeadMountedDisplay")
|
||||
FString Gender;
|
||||
|
||||
/** Height of the player, in meters */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Input|HeadMountedDisplay")
|
||||
float PlayerHeight;
|
||||
|
||||
/** Height of the player, in meters */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Input|HeadMountedDisplay")
|
||||
float EyeHeight;
|
||||
|
||||
/** Interpupillary distance of the player, in meters */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Input|HeadMountedDisplay")
|
||||
float IPD;
|
||||
|
||||
/** Neck-to-eye distance, in meters. X - horizontal, Y - vertical. */
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Input|HeadMountedDisplay")
|
||||
FVector2D NeckToEyeDistance;
|
||||
|
||||
UPROPERTY(BlueprintReadWrite, Category = "Input|HeadMountedDisplay")
|
||||
TArray<FOculusXRHmdUserProfileField> ExtraFields;
|
||||
|
||||
FOculusXRHmdUserProfile()
|
||||
: PlayerHeight(0.f), EyeHeight(0.f), IPD(0.f), NeckToEyeDistance(FVector2D::ZeroVector) {}
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRFoveatedRenderingMethod : uint8
|
||||
{
|
||||
FixedFoveatedRendering = 0,
|
||||
EyeTrackedFoveatedRendering = 1,
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRFoveatedRenderingLevel : uint8
|
||||
{
|
||||
Off = 0,
|
||||
Low = 1,
|
||||
Medium = 2,
|
||||
High = 3,
|
||||
// High foveation setting with more detail toward the bottom of the view and more foveation near the top
|
||||
HighTop = 4
|
||||
};
|
||||
|
||||
/* Guardian boundary types*/
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRBoundaryType : uint8
|
||||
{
|
||||
Boundary_Outer UMETA(DisplayName = "Outer Boundary"),
|
||||
Boundary_PlayArea UMETA(DisplayName = "Play Area"),
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRColorSpace : uint8
|
||||
{
|
||||
/// The default value from GetHmdColorSpace until SetClientColorDesc is called. Only valid on PC, and will be remapped to Quest on Mobile
|
||||
Unknown = 0,
|
||||
/// No color correction, not recommended for production use. See documentation for more info
|
||||
Unmanaged = 1,
|
||||
/// Color space for standardized color across all Oculus HMDs with D65 white point
|
||||
Rec_2020 = 2,
|
||||
/// Rec. 709 is used on Oculus Go and shares the same primary color coordinates as sRGB
|
||||
Rec_709 = 3,
|
||||
/// Oculus Rift CV1 uses a unique color space, see documentation for more info
|
||||
Rift_CV1 = 4 UMETA(DisplayName = "Rift CV1"),
|
||||
/// Oculus Rift S uses a unique color space, see documentation for more info
|
||||
Rift_S = 5,
|
||||
/// Oculus Quest's native color space is slightly different than Rift CV1
|
||||
Quest = 6 UMETA(DisplayName = "Quest 1"),
|
||||
/// DCI-P3 color space. See documentation for more details
|
||||
P3 = 7 UMETA(DisplayName = "P3 (Recommended)"),
|
||||
/// Similar to sRGB but with deeper greens using D65 white point
|
||||
Adobe_RGB = 8,
|
||||
};
|
||||
|
||||
/*
|
||||
* Hand tracking settings. Please check https://developer.oculus.com/documentation/unreal/unreal-hand-tracking/
|
||||
* for detailed information.
|
||||
*/
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRHandTrackingSupport : uint8
|
||||
{
|
||||
ControllersOnly,
|
||||
ControllersAndHands,
|
||||
HandsOnly,
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRHandTrackingFrequency : uint8
|
||||
{
|
||||
LOW,
|
||||
HIGH,
|
||||
MAX,
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRHandTrackingVersion : uint8
|
||||
{
|
||||
Default,
|
||||
V1,
|
||||
V2,
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRProcessorPerformanceLevel : uint8
|
||||
{
|
||||
PowerSavings = 0 UMETA(DisplayName = "PowerSavings", ToolTip = "Usually used in non-XR section (head-locked / static screen), during which power savings are to be prioritized"),
|
||||
SustainedLow = 1 UMETA(DisplayName = "SustainedLow", ToolTip = "App enters a low and stable complexity section, during which reducing power is more important than occasional late rendering frames"),
|
||||
SustainedHigh = 2 UMETA(DisplayName = "SustainedHigh", ToolTip = "Let XR Runtime to perform consistent XR compositing and frame rendering within a thermally sustainable range"),
|
||||
Boost = 3 UMETA(DisplayName = "Boost(*)", ToolTip = "Allow XR Runtime to step up beyond the thermally sustainable range for short period. (Currently equivalent to SustainedHigh and not recommended to be used on Quest)")
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRDeviceType : uint8
|
||||
{
|
||||
// mobile HMDs
|
||||
OculusMobile_Deprecated0 = 0,
|
||||
OculusQuest_Deprecated,
|
||||
OculusQuest2,
|
||||
MetaQuestPro,
|
||||
MetaQuest3,
|
||||
MetaQuest3S,
|
||||
|
||||
// PC HMDs
|
||||
Rift = 100,
|
||||
Rift_S,
|
||||
Quest_Link_Deprecated,
|
||||
Quest2_Link,
|
||||
MetaQuestProLink,
|
||||
MetaQuest3Link,
|
||||
MetaQuest3SLink,
|
||||
|
||||
// default
|
||||
OculusUnknown = 200,
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRControllerType : uint8
|
||||
{
|
||||
None = 0,
|
||||
MetaQuestTouch = 1,
|
||||
MetaQuestTouchPro = 2,
|
||||
MetaQuestTouchPlus = 3,
|
||||
Unknown = 0x7f,
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRXrApi : uint8
|
||||
{
|
||||
OVRPluginOpenXR = 0 UMETA(DisplayName = "Oculus OVRPlugin + OpenXR backend (current recommended)", ToolTip = "Oculus plugin integration using OpenXR backend on both Mobile and PC. All new features will ship on backend for the forseeable future."),
|
||||
|
||||
NativeOpenXR = 1 UMETA(DisplayName = "Epic Native OpenXR with Oculus vendor extensions", ToolTip = "Disable Legacy Oculus in favor of the native OpenXR implementation, with Oculus vendor extensions. Must enable the OpenXR plugin. This will be where Epic focuses XR development going forward. Oculus OpenXR extensions may be moved into a separate plugin (or plugins) in the future to improve modularity. The features supported by OpenXR are listed in the OpenXR specification on khronos.org, and the features supported by a given runtime can be verified with the \"OpenXR Explorer\" application on GitHub."),
|
||||
};
|
||||
|
||||
/*
|
||||
* Information about relationships between a triggered boundary (EOculusXRBoundaryType::Boundary_Outer or
|
||||
* EOculusXRBoundaryType::Boundary_PlayArea) and a device or point in the world.
|
||||
* All dimensions, points, and vectors are returned in Unreal world coordinate space.
|
||||
*/
|
||||
USTRUCT(BlueprintType)
|
||||
struct FOculusXRGuardianTestResult
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
/** Is there a triggering interaction between the device/point and specified boundary? */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Boundary Test Result")
|
||||
bool IsTriggering = false;
|
||||
|
||||
/** Device type triggering boundary (EOculusXRTrackedDeviceType::None if BoundaryTestResult corresponds to a point rather than a device) */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Boundary Test Result")
|
||||
EOculusXRTrackedDeviceType DeviceType = EOculusXRTrackedDeviceType::None;
|
||||
|
||||
/** Distance of device/point to surface of boundary specified by BoundaryType */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Boundary Test Result")
|
||||
float ClosestDistance = 0.0f;
|
||||
|
||||
/** Closest point on surface corresponding to specified boundary */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Boundary Test Result")
|
||||
FVector ClosestPoint = FVector(0.0f);
|
||||
|
||||
/** Normal of closest point */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Boundary Test Result")
|
||||
FVector ClosestPointNormal = FVector(0.0f, 0.0f, 1.0f);
|
||||
};
|
||||
|
||||
UENUM()
|
||||
enum class EOculusXRControllerPoseAlignment : uint8
|
||||
{
|
||||
Default = 0 UMETA(ToolTip = "Default pose alignment used in all versions of the Meta XR plugin. Recommended pose for compatibility with previous assets designed for the Meta XR plugin."),
|
||||
|
||||
Grip = 1 UMETA(ToolTip = "Grip pose alignment as defined by OpenXR. Use this for cross-plugin compatibility with assets designed for the native OpenXR grip pose."),
|
||||
|
||||
Aim = 2 UMETA(ToolTip = "Aim pose alignment as defined by OpenXR. Use this for cross-plugin compatibility with assets designed for the native OpenXR aim pose."),
|
||||
};
|
||||
|
||||
USTRUCT()
|
||||
struct FOculusXRSplashDesc
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
UPROPERTY(config, EditAnywhere, Category = Settings, meta = (AllowedClasses = "/Script/Engine.Texture", ToolTip = "Texture to display"))
|
||||
FSoftObjectPath TexturePath;
|
||||
|
||||
UPROPERTY(config, EditAnywhere, Category = Settings, meta = (ToolTip = "transform of center of quad (meters)."))
|
||||
FTransform TransformInMeters;
|
||||
|
||||
UPROPERTY(config, EditAnywhere, Category = Settings, meta = (ToolTip = "Dimensions in meters."))
|
||||
FVector2D QuadSizeInMeters;
|
||||
|
||||
UPROPERTY(config, EditAnywhere, Category = Settings, meta = (ToolTip = "A delta rotation that will be added each rendering frame (half rate of full vsync)."))
|
||||
FQuat DeltaRotation;
|
||||
|
||||
UPROPERTY(config, EditAnywhere, Category = Settings, meta = (ToolTip = "Texture offset amount from the top left corner."))
|
||||
FVector2D TextureOffset;
|
||||
|
||||
UPROPERTY(config, EditAnywhere, Category = Settings, meta = (ToolTip = "Texture scale."))
|
||||
FVector2D TextureScale;
|
||||
|
||||
UPROPERTY(config, EditAnywhere, Category = Settings, meta = (ToolTip = "Whether the splash layer uses it's alpha channel."))
|
||||
bool bNoAlphaChannel;
|
||||
|
||||
// Runtime data
|
||||
UTexture* LoadingTexture;
|
||||
FTextureRHIRef LoadedTexture;
|
||||
bool bIsDynamic;
|
||||
|
||||
FOculusXRSplashDesc()
|
||||
: TransformInMeters(FVector(4.0f, 0.f, 0.f))
|
||||
, QuadSizeInMeters(3.f, 3.f)
|
||||
, DeltaRotation(FQuat::Identity)
|
||||
, TextureOffset(0.0f, 0.0f)
|
||||
, TextureScale(1.0f, 1.0f)
|
||||
, bNoAlphaChannel(false)
|
||||
, LoadingTexture(nullptr)
|
||||
, LoadedTexture(nullptr)
|
||||
, bIsDynamic(false)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const FOculusXRSplashDesc& d) const
|
||||
{
|
||||
return TexturePath == d.TexturePath && TransformInMeters.Equals(d.TransformInMeters) && QuadSizeInMeters == d.QuadSizeInMeters && DeltaRotation.Equals(d.DeltaRotation) && TextureOffset == d.TextureOffset && TextureScale == d.TextureScale && bNoAlphaChannel == d.bNoAlphaChannel && LoadingTexture == d.LoadingTexture && LoadedTexture == d.LoadedTexture && bIsDynamic == d.bIsDynamic;
|
||||
}
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXROcclusionsMode : uint8
|
||||
{
|
||||
/// Environment depth occlusions disabled.
|
||||
Disabled = 0,
|
||||
/// Hard occlusions, this is deprecated. Use soft occlusions instead.
|
||||
HardOcclusions_Deprecated = 1,
|
||||
/// Soft occlusions, shows soft edges between the real and virtual world.
|
||||
SoftOcclusions = 2,
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXREyeBufferSharpenType : uint8
|
||||
{
|
||||
/// No Sharpening
|
||||
SLST_None UMETA(DisplayName = "No Sharpening"),
|
||||
|
||||
/// Normal Sharpening
|
||||
SLST_Normal UMETA(DisplayName = "Normal Sharpening"),
|
||||
|
||||
/// Quality Sharpening
|
||||
SLST_Quality UMETA(DisplayName = "Quality Sharpening"),
|
||||
|
||||
/// Auto Filtering: Runtime automatically chooses the appropriate sharpening filter
|
||||
SLST_Auto UMETA(DisplayName = "Auto Filtering"),
|
||||
|
||||
SLST_MAX,
|
||||
};
|
||||
|
||||
UENUM()
|
||||
enum class EProcessorFavor : int8
|
||||
{
|
||||
FavorEqually = 0 UMETA(DisplayName = "Favor Equally"),
|
||||
FavorCPU = 1 UMETA(DisplayName = "Favor CPU"),
|
||||
FavorGPU = 2 UMETA(DisplayName = "Favor GPU"),
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRHMDBodyTrackingFidelity : uint8
|
||||
{
|
||||
Unset = 0 UMETA(Hidden),
|
||||
Low = 1,
|
||||
High = 2,
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRHMDBodyJointSet : uint8
|
||||
{
|
||||
UpperBody = 0,
|
||||
FullBody = 1,
|
||||
};
|
||||
|
||||
UENUM()
|
||||
enum class EFaceTrackingDataSourceConfig : int8
|
||||
{
|
||||
Visual = 0 UMETA(DisplayName = "Visual"),
|
||||
Audio = 1 UMETA(DisplayName = "Audio"),
|
||||
MAX = 2 UMETA(Hidden),
|
||||
};
|
||||
|
||||
UENUM()
|
||||
enum class ESystemSplashBackgroundType : int8
|
||||
{
|
||||
Black = 0 UMETA(DisplayName = "Black"),
|
||||
Contextual = 1 UMETA(DisplayName = "Passthrough (Contextual)"),
|
||||
};
|
||||
|
||||
USTRUCT(BlueprintType, meta = (DisplayName = "Oculus Performance Metrics"))
|
||||
struct FOculusXRPerformanceMetrics
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
/** App CPU Time (ms) */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Performance Metrics")
|
||||
float AppCpuTime;
|
||||
|
||||
/** App GPU Time (ms) */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Performance Metrics")
|
||||
float AppGpuTime;
|
||||
|
||||
/** Compositor CPU Time (ms) */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Performance Metrics")
|
||||
float ComCpuTime;
|
||||
|
||||
/** Compositor GPU Time (ms) */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Performance Metrics")
|
||||
float ComGpuTime;
|
||||
|
||||
/** Compositor Dropped Frames */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Performance Metrics")
|
||||
int DroppedFrames;
|
||||
|
||||
/** System GPU Util % */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Performance Metrics")
|
||||
float GpuUtil;
|
||||
|
||||
/** System CPU Util Avg % */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Performance Metrics")
|
||||
float CpuUtilAvg;
|
||||
|
||||
/** System CPU Util Worst % */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Performance Metrics")
|
||||
float CpuUtilWorst;
|
||||
|
||||
/** Compositor SpaceWarp Mode: 0: Disabled; 1: Enabled */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Performance Metrics")
|
||||
int ComSpaceWarpMode;
|
||||
|
||||
/** CPU Core Util % */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Performance Metrics")
|
||||
TArray<float> CpuCoreUtil;
|
||||
|
||||
FOculusXRPerformanceMetrics()
|
||||
: AppCpuTime(0.f)
|
||||
, AppGpuTime(0.f)
|
||||
, ComCpuTime(0.f)
|
||||
, ComGpuTime(0.f)
|
||||
, DroppedFrames(0)
|
||||
, GpuUtil(0.f)
|
||||
, CpuUtilAvg(0.f)
|
||||
, CpuUtilWorst(0.f)
|
||||
, ComSpaceWarpMode(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
UENUM(BlueprintType)
|
||||
enum class EOculusXRMPPoseRestoreType : uint8
|
||||
{
|
||||
/// DONOT restore head and controller poses
|
||||
Disabled = 0 UMETA(DisplayName = "Disabled"),
|
||||
/// Only restore head and controller position
|
||||
PositionOnly = 1 UMETA(DisplayName = "Restore Position Only"),
|
||||
/// Restore head and controller position and rotation
|
||||
PositionAndRotation = 2 UMETA(DisplayName = "Restore Position And Rotation"),
|
||||
};
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Tickable.h"
|
||||
#include "Subsystems/EngineSubsystem.h"
|
||||
#include "IOculusXRHMDModule.h"
|
||||
#include "Engine/GameViewportClient.h"
|
||||
|
||||
#include "OculusXRMultiPlayerTestingSubsystem.generated.h"
|
||||
|
||||
/**
|
||||
* The rule processor handles registration and querying of rules
|
||||
*/
|
||||
UCLASS()
|
||||
class OCULUSXRHMD_API UOculusXRMultiPlayerTestingSubsystem final : public UEngineSubsystem, public FTickableGameObject
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
/**
|
||||
* Initialize the subsystem. USubsystem override
|
||||
*/
|
||||
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
|
||||
|
||||
/**
|
||||
* De-initializes the subsystem. USubsystem override
|
||||
*/
|
||||
virtual void Deinitialize() override;
|
||||
|
||||
//~ Begin FTickableGameObject interface
|
||||
virtual bool IsTickableInEditor() const { return true; }
|
||||
virtual ETickableTickType GetTickableTickType() const override;
|
||||
virtual bool IsAllowedToTick() const override;
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
TStatId GetStatId() const override { RETURN_QUICK_DECLARE_CYCLE_STAT(UOculusXRMultiPlayerTestingSubsystem, STATGROUP_Tickables); }
|
||||
//~ End FTickableGameObject interface
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
void SwitchPrimaryPIE(UGameViewportClient* InViewport, TOptional<int> PrimaryPIEIndex);
|
||||
void SwitchPrimaryPIE_MultiProcess(int PrimaryPIEIndex);
|
||||
#if WITH_EDITOR
|
||||
void SwitchPrimaryPIE_SingleProcess();
|
||||
void SwitchPrimaryPIE(FWorldContext* OldPrimaryWorld, FWorldContext* NewPrimaryWorld);
|
||||
void SwitchPrimaryPIE_SingleProcess(UGameViewportClient* InViewport, TOptional<int> PrimaryPIEIndex);
|
||||
#endif // WITH_EDITOR
|
||||
#endif // PLATFORM_WINDOWS
|
||||
|
||||
private:
|
||||
bool IsMultiPlayerTestingSupported() const;
|
||||
#if PLATFORM_WINDOWS
|
||||
void GetUnrealEditorProcs(TArray<int32>& ProcIds);
|
||||
bool IsMultiPlayerTestingEnabled(bool& bSingleProcessMode);
|
||||
int32 NumClients;
|
||||
#endif // PLATFORM_WINDOWS
|
||||
};
|
||||
@@ -0,0 +1,171 @@
|
||||
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Misc/EngineVersionComparison.h"
|
||||
|
||||
#include "StereoLayerShapes.h"
|
||||
#include "OculusXRPassthroughMesh.h"
|
||||
#include "OculusXRPassthroughLayerShapes.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE(FOculusXRPassthrough_LayerResumed);
|
||||
|
||||
/**
|
||||
* The color mapping technique which can be applied to a passthrough layer.
|
||||
* @see https://developers.meta.com/horizon/documentation/unreal/unreal-customize-passthrough-color-mapping/ for more details.
|
||||
*/
|
||||
UENUM()
|
||||
enum EOculusXRColorMapType
|
||||
{
|
||||
/** No color map is applied */
|
||||
ColorMapType_None = 0 UMETA(DisplayName = "None"),
|
||||
|
||||
/** Map input color to an RGB color, optionally with brightness/constrast adjustment or posterization applied */
|
||||
ColorMapType_GrayscaleToColor = 1 UMETA(DisplayName = "Grayscale To Color"),
|
||||
|
||||
/** Map input color to a grayscale color, optionally with brightness/constrast adjustment or posterization applied */
|
||||
ColorMapType_Grayscale = 2 UMETA(DisplayName = "Grayscale"),
|
||||
|
||||
/** Adjust brightness and contrast */
|
||||
ColorMapType_ColorAdjustment = 3 UMETA(DisplayName = "Color Adjustment"),
|
||||
|
||||
/** Apply a color look-up table (LUT), which maps each RGB input color into an arbitrary RGB(A) in the passthrough image stream */
|
||||
ColorMapType_ColorLut = 4 UMETA(DisplayName = "Color LUT"),
|
||||
|
||||
/** Apply the blend between two color LUTs to the passthrough image stream. */
|
||||
ColorMapType_ColorLut_Interpolated = 5 UMETA(DisplayName = "Interpolated Color LUT"),
|
||||
|
||||
ColorMapType_MAX = 255,
|
||||
};
|
||||
|
||||
UENUM()
|
||||
enum EOculusXRPassthroughLayerOrder
|
||||
{
|
||||
/** Layer is rendered on top of scene */
|
||||
PassthroughLayerOrder_Overlay = 0 UMETA(DisplayName = "Overlay"),
|
||||
|
||||
/** Layer is rendered under scene */
|
||||
PassthroughLayerOrder_Underlay = 1 UMETA(DisplayName = "Underlay"),
|
||||
|
||||
PassthroughLayerOrder_MAX = 255,
|
||||
};
|
||||
|
||||
struct OCULUSXRHMD_API FColorLutDesc
|
||||
{
|
||||
FColorLutDesc();
|
||||
|
||||
FColorLutDesc(const TArray<uint64>& InColorLuts, float InWeight);
|
||||
|
||||
float Weight;
|
||||
TArray<uint64> ColorLuts;
|
||||
};
|
||||
|
||||
struct OCULUSXRHMD_API FEdgeStyleParameters
|
||||
{
|
||||
public:
|
||||
FEdgeStyleParameters();
|
||||
|
||||
FEdgeStyleParameters(
|
||||
bool bEnableEdgeColor,
|
||||
bool bEnableColorMap,
|
||||
float TextureOpacityFactor,
|
||||
float Brightness,
|
||||
float Contrast,
|
||||
float Posterize,
|
||||
float Saturation,
|
||||
FLinearColor EdgeColor,
|
||||
FLinearColor ColorScale,
|
||||
FLinearColor ColorOffset,
|
||||
EOculusXRColorMapType InColorMapType,
|
||||
const TArray<FLinearColor>& InColorMapGradient,
|
||||
const FColorLutDesc& InLutDesc);
|
||||
|
||||
bool bEnableEdgeColor;
|
||||
bool bEnableColorMap;
|
||||
bool bUseColorLuts;
|
||||
float TextureOpacityFactor;
|
||||
float Brightness;
|
||||
float Contrast;
|
||||
float Posterize;
|
||||
float Saturation;
|
||||
FLinearColor EdgeColor;
|
||||
FLinearColor ColorScale;
|
||||
FLinearColor ColorOffset;
|
||||
EOculusXRColorMapType ColorMapType;
|
||||
TArray<uint8> ColorMapData;
|
||||
FColorLutDesc ColorLutDesc;
|
||||
|
||||
private:
|
||||
/** Generates the corresponding color map based on given color map type */
|
||||
TArray<uint8> GenerateColorMapData(EOculusXRColorMapType InColorMapType, const TArray<FLinearColor>& InColorMapGradient);
|
||||
|
||||
/** Generates a grayscale to color color map based on given gradient --> It also applies the color scale and offset */
|
||||
TArray<uint8> GenerateMonoToRGBA(const TArray<FLinearColor>& InGradient, const TArray<uint8>& InColorMapData);
|
||||
|
||||
/** Generates a grayscale color map with given Brightness/Contrast/Posterize settings */
|
||||
TArray<uint8> GenerateMonoBrightnessContrastPosterizeMap();
|
||||
|
||||
/** Generates a luminance based colormap from the the Brightness/Contrast */
|
||||
TArray<uint8> GenerateBrightnessContrastSaturationColorMap();
|
||||
};
|
||||
|
||||
#if UE_VERSION_OLDER_THAN(5, 3, 0)
|
||||
#define OCULUSXRHMD_API_CLASS OCULUSXRHMD_API
|
||||
#define OCULUSXRHMD_API_MEMBER
|
||||
#else
|
||||
#define OCULUSXRHMD_API_CLASS
|
||||
#define OCULUSXRHMD_API_MEMBER OCULUSXRHMD_API
|
||||
#endif
|
||||
|
||||
class OCULUSXRHMD_API_CLASS FReconstructedLayer : public IStereoLayerShape
|
||||
{
|
||||
public:
|
||||
OCULUSXRHMD_API_MEMBER static const FName ShapeName;
|
||||
virtual FName GetShapeName() override { return ShapeName; }
|
||||
virtual IStereoLayerShape* Clone() const override { return new FReconstructedLayer(*this); }
|
||||
|
||||
public:
|
||||
FReconstructedLayer(){};
|
||||
FReconstructedLayer(const FEdgeStyleParameters& EdgeStyleParameters, EOculusXRPassthroughLayerOrder PassthroughLayerOrder)
|
||||
: EdgeStyleParameters(EdgeStyleParameters), PassthroughLayerOrder(PassthroughLayerOrder){};
|
||||
FEdgeStyleParameters EdgeStyleParameters;
|
||||
EOculusXRPassthroughLayerOrder PassthroughLayerOrder;
|
||||
};
|
||||
|
||||
struct FUserDefinedGeometryDesc
|
||||
{
|
||||
FUserDefinedGeometryDesc(const FString& MeshName, OculusXRHMD::FOculusPassthroughMeshRef PassthroughMesh, const FTransform& Transform, bool bUpdateTransform)
|
||||
: MeshName(MeshName)
|
||||
, PassthroughMesh(PassthroughMesh)
|
||||
, Transform(Transform)
|
||||
, bUpdateTransform(bUpdateTransform){};
|
||||
|
||||
FString MeshName;
|
||||
OculusXRHMD::FOculusPassthroughMeshRef PassthroughMesh;
|
||||
FTransform Transform;
|
||||
bool bUpdateTransform;
|
||||
};
|
||||
|
||||
class OCULUSXRHMD_API_CLASS FUserDefinedLayer : public IStereoLayerShape
|
||||
{
|
||||
public:
|
||||
OCULUSXRHMD_API_MEMBER static const FName ShapeName;
|
||||
virtual FName GetShapeName() override { return ShapeName; }
|
||||
virtual IStereoLayerShape* Clone() const override { return new FUserDefinedLayer(*this); }
|
||||
|
||||
public:
|
||||
FUserDefinedLayer(){};
|
||||
FUserDefinedLayer(TArray<FUserDefinedGeometryDesc> InUserGeometryList, const FEdgeStyleParameters& EdgeStyleParameters, EOculusXRPassthroughLayerOrder PassthroughLayerOrder)
|
||||
: UserGeometryList{}
|
||||
, EdgeStyleParameters(EdgeStyleParameters)
|
||||
, PassthroughLayerOrder(PassthroughLayerOrder)
|
||||
{
|
||||
UserGeometryList = InUserGeometryList;
|
||||
}
|
||||
|
||||
TArray<FUserDefinedGeometryDesc> UserGeometryList;
|
||||
FEdgeStyleParameters EdgeStyleParameters;
|
||||
EOculusXRPassthroughLayerOrder PassthroughLayerOrder;
|
||||
|
||||
private:
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Templates/RefCounting.h"
|
||||
|
||||
namespace OculusXRHMD
|
||||
{
|
||||
|
||||
class FOculusPassthroughMesh : public FRefCountedObject
|
||||
{
|
||||
public:
|
||||
FOculusPassthroughMesh(const TArray<FVector>& InVertices, const TArray<int32>& InTriangles)
|
||||
: Vertices(InVertices)
|
||||
, Triangles(InTriangles)
|
||||
{
|
||||
}
|
||||
|
||||
const TArray<FVector>& GetVertices() const { return Vertices; };
|
||||
const TArray<int32>& GetTriangles() const { return Triangles; };
|
||||
|
||||
private:
|
||||
TArray<FVector> Vertices;
|
||||
TArray<int32> Triangles;
|
||||
};
|
||||
|
||||
typedef TRefCountPtr<FOculusPassthroughMesh> FOculusPassthroughMeshRef;
|
||||
|
||||
} // namespace OculusXRHMD
|
||||
75
Plugins/MetaXR/Source/OculusXRHMD/Public/OculusXRQPL.h
Normal file
75
Plugins/MetaXR/Source/OculusXRHMD/Public/OculusXRQPL.h
Normal file
@@ -0,0 +1,75 @@
|
||||
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "Misc/DateTime.h"
|
||||
|
||||
namespace OculusXRTelemetry
|
||||
{
|
||||
enum class OCULUSXRHMD_API EAction : short
|
||||
{
|
||||
Start = 1,
|
||||
Success = 2,
|
||||
Fail = 3,
|
||||
Cancel = 4,
|
||||
DrawComplete = 5,
|
||||
OnResume = 6
|
||||
};
|
||||
|
||||
class OCULUSXRHMD_API FTelemetryInstanceKey
|
||||
{
|
||||
public:
|
||||
constexpr FTelemetryInstanceKey(const int InstanceKey)
|
||||
: Value(InstanceKey){};
|
||||
|
||||
constexpr int GetValue() const { return Value; }
|
||||
|
||||
private:
|
||||
int Value;
|
||||
};
|
||||
|
||||
constexpr FTelemetryInstanceKey DefaultTelemetryInstance = FTelemetryInstanceKey(0);
|
||||
|
||||
class OCULUSXRHMD_API FTelemetryTimestamp
|
||||
{
|
||||
static constexpr int OneHundredNsToMs = 1000;
|
||||
|
||||
public:
|
||||
FTelemetryTimestamp(FDateTime Timestamp)
|
||||
: TotalMs(Timestamp.GetTicks() / OneHundredNsToMs){};
|
||||
constexpr FTelemetryTimestamp(int64 TimestampMs)
|
||||
: TotalMs(TimestampMs){};
|
||||
|
||||
constexpr int64 GetTimestamp() const { return TotalMs; }
|
||||
|
||||
private:
|
||||
int64 TotalMs;
|
||||
};
|
||||
|
||||
constexpr FTelemetryTimestamp AutoSetTimestamp = FTelemetryTimestamp(-1);
|
||||
|
||||
struct OCULUSXRHMD_API FEmptyBackend
|
||||
{
|
||||
static bool MarkerStart(int, FTelemetryInstanceKey, FTelemetryTimestamp) { return false; };
|
||||
static bool MarkerEnd(int, EAction, FTelemetryInstanceKey, FTelemetryTimestamp) { return false; };
|
||||
static bool MarkerPoint(int, const char*, FTelemetryInstanceKey, FTelemetryTimestamp) { return false; };
|
||||
static bool MarkerPointCached(int, int, FTelemetryInstanceKey, FTelemetryTimestamp) { return false; };
|
||||
static bool MarkerAnnotation(int, const char*, const char*, FTelemetryInstanceKey) { return false; };
|
||||
static bool CreateMarkerHandle(const char*, int*) { return false; };
|
||||
static bool DestroyMarkerHandle(int) { return false; };
|
||||
static bool OnEditorShutdown() { return false; };
|
||||
static constexpr bool IsNullBackend() { return true; };
|
||||
};
|
||||
struct OCULUSXRHMD_API FQPLBackend
|
||||
{
|
||||
static bool MarkerStart(int MarkerId, FTelemetryInstanceKey InstanceKey, FTelemetryTimestamp Timestamp);
|
||||
static bool MarkerEnd(int MarkerId, EAction Action, FTelemetryInstanceKey InstanceKey, FTelemetryTimestamp Timestamp);
|
||||
static bool MarkerPoint(int MarkerId, const char* Name, FTelemetryInstanceKey InstanceKey, FTelemetryTimestamp Timestamp);
|
||||
static bool MarkerPointCached(int MarkerId, int NameHandle, FTelemetryInstanceKey InstanceKey, FTelemetryTimestamp Timestamp);
|
||||
static bool MarkerAnnotation(int MarkerId, const char* AnnotationKey, const char* AnnotationValue, FTelemetryInstanceKey InstanceKey);
|
||||
static bool CreateMarkerHandle(const char* Name, int* NameHandle);
|
||||
static bool DestroyMarkerHandle(int NameHandle);
|
||||
static bool OnEditorShutdown();
|
||||
static constexpr bool IsNullBackend() { return false; };
|
||||
};
|
||||
} // namespace OculusXRTelemetry
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Misc\EngineVersionComparison.h"
|
||||
#if !UE_VERSION_OLDER_THAN(5, 4, 0)
|
||||
#include "IStereoLayersFlagsSupplier.h"
|
||||
#endif // !UE_VERSION_OLDER_THAN(5, 4, 0)
|
||||
|
||||
class FOculusXRStereoLayersFlagsSupplier
|
||||
#if !UE_VERSION_OLDER_THAN(5, 4, 0)
|
||||
: public IStereoLayersFlagsSupplier
|
||||
#endif // !UE_VERSION_OLDER_THAN(5, 4, 0)
|
||||
{
|
||||
// Required for creating a TSharedPtr because this class has a private constructor.
|
||||
template <typename, ESPMode>
|
||||
friend class SharedPointerInternals::TIntrusiveReferenceController;
|
||||
|
||||
public:
|
||||
/** Returns instance of this class. If it doesn't exist yet, it creates one and collects all the flags. */
|
||||
OCULUSXRHMD_API static TSharedPtr<FOculusXRStereoLayersFlagsSupplier> Get();
|
||||
|
||||
virtual ~FOculusXRStereoLayersFlagsSupplier() {}
|
||||
|
||||
#if !UE_VERSION_OLDER_THAN(5, 4, 0)
|
||||
virtual void EnumerateFlags(TSet<FName>& OutFlags) override
|
||||
{
|
||||
OutFlags.Append(SupportedFilters);
|
||||
}
|
||||
#endif // !UE_VERSION_OLDER_THAN(5, 4, 0)
|
||||
|
||||
OCULUSXRHMD_API int GetOvrpFlag(uint32 DescFlags, bool bMQSR = true);
|
||||
|
||||
private:
|
||||
FOculusXRStereoLayersFlagsSupplier();
|
||||
|
||||
static TSharedPtr<FOculusXRStereoLayersFlagsSupplier> Instance;
|
||||
|
||||
TMap<uint32, uint32> UnrealFlagValOvrpFlagValMap;
|
||||
TArray<FName> SupportedFilters;
|
||||
};
|
||||
195
Plugins/MetaXR/Source/OculusXRHMD/Public/OculusXRTelemetry.h
Normal file
195
Plugins/MetaXR/Source/OculusXRHMD/Public/OculusXRTelemetry.h
Normal file
@@ -0,0 +1,195 @@
|
||||
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "OculusXRQPL.h"
|
||||
#include "Containers/StringConv.h"
|
||||
#include "Templates/Function.h"
|
||||
|
||||
namespace OculusXRTelemetry
|
||||
{
|
||||
#ifndef TURN_OFF_META_TELEMETRY
|
||||
using FTelemetryBackend = FQPLBackend;
|
||||
#else
|
||||
using FTelemetryBackend = FEmptyBackend;
|
||||
#endif
|
||||
|
||||
constexpr int UNREAL_TOOL_ID = 2;
|
||||
OCULUSXRHMD_API bool IsActive();
|
||||
OCULUSXRHMD_API void IfActiveThen(TUniqueFunction<void()> Function);
|
||||
OCULUSXRHMD_API void PropagateTelemetryConsent();
|
||||
|
||||
OCULUSXRHMD_API FString GetProjectId();
|
||||
|
||||
OCULUSXRHMD_API bool IsConsentGiven();
|
||||
|
||||
template <typename Backend = FTelemetryBackend>
|
||||
class OCULUSXRHMD_API TMarkerPoint : FNoncopyable
|
||||
{
|
||||
public:
|
||||
explicit TMarkerPoint(const char* Name)
|
||||
: bCreated(Backend::CreateMarkerHandle(Name, Handle)) {}
|
||||
~TMarkerPoint()
|
||||
{
|
||||
if (bCreated)
|
||||
{
|
||||
Backend::DestroyMarkerHandle(Handle);
|
||||
}
|
||||
}
|
||||
int GetHandle() const { return Handle; }
|
||||
|
||||
private:
|
||||
const bool bCreated{ false };
|
||||
const int Handle{ -1 };
|
||||
};
|
||||
|
||||
enum class EAnnotationType
|
||||
{
|
||||
Required,
|
||||
Optional,
|
||||
};
|
||||
|
||||
template <int MarkerId, typename Backend = FTelemetryBackend>
|
||||
class TMarker
|
||||
{
|
||||
public:
|
||||
explicit TMarker(const FTelemetryInstanceKey InstanceKey = DefaultTelemetryInstance)
|
||||
: InstanceKey(InstanceKey)
|
||||
{
|
||||
}
|
||||
TMarker(const TMarker&& Other) noexcept
|
||||
: InstanceKey(Other.GetMarkerId()) {}
|
||||
|
||||
const TMarker& Start(const FTelemetryTimestamp Timestamp = AutoSetTimestamp) const
|
||||
{
|
||||
Backend::MarkerStart(MarkerId, InstanceKey, Timestamp);
|
||||
return *this;
|
||||
}
|
||||
const TMarker& AddAnnotation(const char* Key, const char* Value, EAnnotationType bExtraAnnotation = EAnnotationType::Required) const
|
||||
{
|
||||
if (bExtraAnnotation == EAnnotationType::Required || IsConsentGiven())
|
||||
{
|
||||
Backend::MarkerAnnotation(MarkerId, Key, Value, InstanceKey);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
const TMarker& AddPoint(const char* Name, const FTelemetryTimestamp Timestamp = AutoSetTimestamp) const
|
||||
{
|
||||
Backend::MarkerPoint(MarkerId, Name, InstanceKey, Timestamp);
|
||||
return *this;
|
||||
}
|
||||
const TMarker& AddPoint(const TMarkerPoint<Backend>& MarkerPoint, const FTelemetryTimestamp Timestamp = AutoSetTimestamp) const
|
||||
{
|
||||
Backend::MarkerPoint(MarkerId, MarkerPoint.GetHandle(), InstanceKey, Timestamp);
|
||||
return *this;
|
||||
}
|
||||
void End(EAction Result, const FTelemetryTimestamp Timestamp = AutoSetTimestamp) const
|
||||
{
|
||||
Backend::MarkerEnd(MarkerId, Result, InstanceKey, Timestamp);
|
||||
}
|
||||
constexpr static int GetMarkerId()
|
||||
{
|
||||
return MarkerId;
|
||||
}
|
||||
|
||||
private:
|
||||
const FTelemetryInstanceKey InstanceKey;
|
||||
};
|
||||
|
||||
struct FIgnoreNotEndedMarker
|
||||
{
|
||||
template <int MarkerId, typename Backend>
|
||||
constexpr const FIgnoreNotEndedMarker& operator=(const TMarker<MarkerId, Backend>&) const noexcept
|
||||
{
|
||||
// do nothing
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
constexpr FIgnoreNotEndedMarker NotEnd{};
|
||||
|
||||
enum class EScopeMode
|
||||
{
|
||||
StartAndEnd,
|
||||
Start,
|
||||
End
|
||||
};
|
||||
|
||||
template <typename TMarker, EScopeMode TScope = EScopeMode::StartAndEnd>
|
||||
class TScopedMarker : public FNoncopyable
|
||||
{
|
||||
TOptional<TMarker> Marker;
|
||||
EAction Result{ EAction::Success };
|
||||
static constexpr EScopeMode Scope{ TScope };
|
||||
|
||||
public:
|
||||
TScopedMarker(const FTelemetryInstanceKey InstanceKey = DefaultTelemetryInstance)
|
||||
{
|
||||
if (IsActive())
|
||||
{
|
||||
Marker.Emplace(InstanceKey);
|
||||
if constexpr (Scope != EScopeMode::End)
|
||||
{
|
||||
const auto& Self = Start();
|
||||
}
|
||||
|
||||
const FString ProjectIdString = GetProjectId();
|
||||
const auto& AnnotatedWithProjectId = AddAnnotation("project_hash", StringCast<ANSICHAR>(*ProjectIdString).Get(), EAnnotationType::Optional);
|
||||
|
||||
}
|
||||
}
|
||||
~TScopedMarker()
|
||||
{
|
||||
if constexpr (Scope != EScopeMode::Start)
|
||||
{
|
||||
End();
|
||||
}
|
||||
}
|
||||
|
||||
const TScopedMarker& Start() const
|
||||
{
|
||||
if (Marker)
|
||||
{
|
||||
Marker->Start();
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
const TScopedMarker& AddPoint(const char* Name) const
|
||||
{
|
||||
if (Marker)
|
||||
{
|
||||
Marker->AddPoint(Name);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
const TScopedMarker& AddAnnotation(const char* Key, const char* Value, EAnnotationType bExtraAnnotation = EAnnotationType::Required) const
|
||||
{
|
||||
if (Marker && (bExtraAnnotation == EAnnotationType::Required || IsConsentGiven()))
|
||||
{
|
||||
Marker->AddAnnotation(Key, Value);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
const TScopedMarker& SetResult(EAction InResult)
|
||||
{
|
||||
Result = InResult;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void End() const
|
||||
{
|
||||
if (Marker)
|
||||
{
|
||||
Marker->End(Result);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void SendEvent(const TCHAR* EventName, const TCHAR* Param);
|
||||
void SendEvent(const TCHAR* EventName, bool bParam);
|
||||
void SendEvent(const TCHAR* EventName, float Param);
|
||||
|
||||
} // namespace OculusXRTelemetry
|
||||
@@ -0,0 +1,21 @@
|
||||
// Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
|
||||
#pragma once
|
||||
|
||||
// DO NOT REMOVE
|
||||
// This include is needed in order to have the latest openxr header (from Thirdparty/KhronosOpenXR/)
|
||||
// Without it, IOpenXRExtensionPlugin.h will include the openxr header from the Engine itself, which is outdated.
|
||||
#include "khronos/openxr/openxr.h"
|
||||
|
||||
#include "IOpenXRExtensionPlugin.h"
|
||||
|
||||
class IOculusXRExtensionPlugin : public IOpenXRExtensionPlugin
|
||||
{
|
||||
public:
|
||||
void RegisterOpenXRExtensionPlugin()
|
||||
{
|
||||
#if defined(WITH_OCULUS_BRANCH)
|
||||
RegisterOpenXRExtensionModularFeature();
|
||||
#endif
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user