Config for building for Quest

This commit is contained in:
2024-05-29 11:53:41 +03:00
parent 15cbcf8752
commit 0db31c34d1
353 changed files with 74095 additions and 3 deletions

View File

@@ -0,0 +1,37 @@
// @lint-ignore-every LICENSELINT
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "Modules/ModuleManager.h"
#define OCULUS_SCENE_SUPPORTED_PLATFORMS (PLATFORM_WINDOWS && WINVER > 0x0502) || (PLATFORM_ANDROID_ARM || PLATFORM_ANDROID_ARM64)
/**
* The public interface to this module. In most cases, this interface is only public to sibling modules
* within this plugin.
*/
class IOculusXRSceneModule : public IModuleInterface
{
public:
/**
* 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 IOculusXRSceneModule& Get()
{
return FModuleManager::LoadModuleChecked<IOculusXRSceneModule>("OculusXRScene");
}
/**
* 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("OculusXRScene");
}
};

View File

@@ -0,0 +1,14 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
#pragma once
#include "OculusXRAnchorTypes.h"
#include "OculusXRSceneTypes.h"
namespace OculusXRScene
{
struct OCULUSXRSCENE_API FOculusXRScene
{
};
} // namespace OculusXRScene

View File

@@ -0,0 +1,178 @@
// @lint-ignore-every LICENSELINT
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/Actor.h"
#include "OculusXRRoomLayoutManagerComponent.h"
#include "OculusXRAnchorComponent.h"
#include "OculusXRFunctionLibrary.h"
#include "OculusXRSceneAnchorComponent.h"
#include "OculusXRSceneTypes.h"
#include "OculusXRSceneActor.generated.h"
/** EOculusXRLaunchCaptureFlowWhenMissingScene
* Used to dictate whether the actor should launch the Capture Flow application when a scene is not detected on the device.
* The Actor will check if a scene capture is either non-existent or invalid (ie. missing walls/ceiling/floor) before checking if Capture Flow
* should be launched.
*
* NEVER: will never launch Flow Capture.
* ONCE: will only launch it once. If the actor still doesn't detect that a scene was captured, it will not launch Capture Flow again.
* ALWAYS: will always re-launch Flow Capture if a scene was not detected on the device.
*/
UENUM(BlueprintType)
enum EOculusXRLaunchCaptureFlowWhenMissingScene
{
NEVER UMETA(DisplayName = "Never"),
ONCE UMETA(DisplayName = "Once"),
ALWAYS UMETA(DisplayName = "Always")
};
/** FOculusXRSpawnedSceneAnchorProperties
* Properties/Components that a spawned scene anchor will use.
*/
USTRUCT(BlueprintType)
struct FOculusXRSpawnedSceneAnchorProperties
{
GENERATED_BODY()
UPROPERTY(EditAnywhere, Category = "Spawned Scene Anchor Properties")
TSoftClassPtr<UOculusXRSceneAnchorComponent> ActorComponent = TSoftClassPtr<UOculusXRSceneAnchorComponent>(FSoftClassPath(UOculusXRSceneAnchorComponent::StaticClass()));
UPROPERTY(EditAnywhere, Category = "Spawned Scene Anchor Properties")
TSoftObjectPtr<UStaticMesh> StaticMesh;
UPROPERTY(EditAnywhere, Category = "Spawned Scene Anchor Properties", Meta = (DeprecatedProperty, DeprecationMessage = "This property is deprecated. Alignment is done automatically at lower level."))
bool ForceParallelToFloor = false;
UPROPERTY(EditAnywhere, Category = "Spawned Scene Anchor Properties")
FVector AddOffset = FVector::ZeroVector;
};
/**
* AOculusXRSceneActor
* The purpose of this actor is to be able to spawn "scene anchor" actors.
*
* Each actor type (based on their semantic label) can be configured to be spawned with a specific mesh and actor component.
*
* Overall, it provides a simple interface to be able to quickly get a captured scene from Capture Flow populated at runtime.
* It also provides a basic and flexible template to making use of the OculusAnchorSDK and UOculusXRRoomLayoutManagerComponent
* to drive the actor's logic. This removes the need for the developer to implement a system from scratch that makes use of
* the native methods and components.
*
* TLDR:
* - This actor populates a captured scene (created in Capture Flow) by spawning child actors with predefined actor and mesh components.
* - Can be used as is, or can be derived or modified as needed depending on the application's needs.
*/
UCLASS(ClassGroup = OculusXRScene)
class OCULUSXRSCENE_API AOculusXRSceneActor : public AActor
{
GENERATED_BODY()
public:
UFUNCTION(BlueprintCallable, Category = "OculusXR|Scene Actor")
void LaunchCaptureFlow();
UFUNCTION(BlueprintCallable, Category = "OculusXR|Scene Actor")
bool IsScenePopulated();
UFUNCTION(BlueprintCallable, Category = "OculusXR|Scene Actor", Meta = (DeprecatedFunction, DeprecationMessage = "Is Room Layout Valid is deprecated and no longer returns any value but true. Please validate your room configuration in the way your application requires."))
bool IsRoomLayoutValid();
UFUNCTION(BlueprintCallable, Category = "OculusXR|Scene Actor")
void PopulateScene();
UFUNCTION(BlueprintCallable, Category = "OculusXR|Scene Actor")
void ClearScene();
UFUNCTION(BlueprintCallable, Category = "OculusXR|Scene Actor")
void SetVisibilityToAllSceneAnchors(const bool bIsVisible);
UFUNCTION(BlueprintCallable, Category = "OculusXR|Scene Actor")
void SetVisibilityToSceneAnchorsBySemanticLabel(const FString SemanticLabel, const bool bIsVisible);
UFUNCTION(BlueprintCallable, Category = "OculusXR|Scene Actor")
TArray<AActor*> GetActorsBySemanticLabel(const FString SemanticLabel);
UFUNCTION(BlueprintPure, BlueprintCallable, Category = "OculusXR|Scene Actor")
TArray<FOculusXRRoomLayout> GetRoomLayouts() const;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OculusXR|Scene Actor")
TEnumAsByte<EOculusXRLaunchCaptureFlowWhenMissingScene> LauchCaptureFlowWhenMissingScene = EOculusXRLaunchCaptureFlowWhenMissingScene::ALWAYS;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OculusXR|Scene Actor", meta = (UIMin = 1, ClampMin = 1, UIMax = 1024, ClampMax = 1024))
int32 MaxQueries = 64;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OculusXR|Scene Actor")
bool bPopulateSceneOnBeginPlay = true;
// If true then when the scene model is loaded we will only attempt to populate the room the user is standing in.
// Otherwise all rooms and all scene anchors will be loaded.
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "OculusXR|Scene Actor")
bool bActiveRoomOnly = true;
UPROPERTY(EditAnywhere, Category = "OculusXR|Scene Actor")
TMap<FString, FOculusXRSpawnedSceneAnchorProperties> ScenePlaneSpawnedSceneAnchorProperties;
UPROPERTY(EditAnywhere, Category = "OculusXR|Scene Actor")
TMap<FString, FOculusXRSpawnedSceneAnchorProperties> SceneVolumeSpawnedSceneAnchorProperties;
public:
AOculusXRSceneActor(const FObjectInitializer& ObjectInitializer);
virtual void BeginPlay() override;
virtual void EndPlay(EEndPlayReason::Type Reason) override;
virtual void Tick(float DeltaTime) override;
virtual void PostLoad() override;
private:
EOculusXRAnchorResult::Type QueryAllRooms();
void RoomLayoutQueryComplete(EOculusXRAnchorResult::Type AnchorResult, const TArray<FOculusXRSpaceQueryResult>& QueryResults);
EOculusXRAnchorResult::Type QueryRoomUUIDs(const FOculusXRUInt64 RoomSpaceID, const TArray<FOculusXRUUID>& RoomUUIDs);
void SceneRoomQueryComplete(EOculusXRAnchorResult::Type AnchorResult, const TArray<FOculusXRSpaceQueryResult>& QueryResults, const FOculusXRUInt64 RoomSpaceID);
void StartSingleRoomQuery(FOculusXRUInt64 RoomSpaceID, FOculusXRRoomLayout RoomLayout);
EOculusXRAnchorResult::Type QueryFloorForActiveRoom(FOculusXRUInt64 RoomSpaceID, FOculusXRRoomLayout RoomLayout);
void ActiveRoomFloorQueryComplete(EOculusXRAnchorResult::Type AnchorResult, const TArray<FOculusXRSpaceQueryResult>& QueryResults, FOculusXRUInt64 RoomSpaceID, FOculusXRRoomLayout RoomLayout);
bool PointInPolygon2D(FVector2f PointToTest, const TArray<FVector2f>& PolyVerts) const;
void GetSemanticClassifications(uint64 Space, TArray<FString>& OutSemanticLabels) const;
// Scene capture event handler
void SceneCaptureComplete_Handler(FOculusXRUInt64 RequestId, bool bResult);
// Launches Capture Flow if (based on LauchCaptureFlowWhenMissingScene member value)
void LaunchCaptureFlowIfNeeded();
// Resets states of the Actor
void ResetStates();
// Validates UUID
bool IsValidUuid(const FOculusXRUUID& Uuid);
// Helper method to spawn an actor for anchor
AActor* SpawnActorWithSceneComponent(const FOculusXRUInt64& Space, const FOculusXRUInt64& RoomSpaceID, const TArray<FString>& SemanticClassifications, UClass* sceneAnchorComponentInstanceClass);
// Spawns a scene anchor
AActor* SpawnOrUpdateSceneAnchor(AActor* Anchor, const FOculusXRUInt64& Space, const FOculusXRUInt64& RoomSpaceID, const FVector& BoundedPos, const FVector& BoundedSize, const TArray<FString>& SemanticClassifications, const EOculusXRSpaceComponentType AnchorComponentType);
// Components for room layout and spatial anchors functionalities
UOculusXRRoomLayoutManagerComponent* RoomLayoutManagerComponent = nullptr;
class UOculusXRSceneGlobalMeshComponent* SceneGlobalMeshComponent = nullptr;
// Whether Capture Flow was already launched once
bool bCaptureFlowWasLaunched;
// Whether last room layout was valid
bool bRoomLayoutIsValid;
// Whether we found a captured scene
bool bFoundCapturedScene;
UPROPERTY(Transient)
TMap<FOculusXRUInt64, FOculusXRRoomLayout> RoomLayouts;
};

View File

@@ -0,0 +1,24 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
#pragma once
#include "CoreMinimal.h"
#include "OculusXRAnchorComponent.h"
#include "OculusXRSceneAnchorComponent.generated.h"
UCLASS(meta = (DisplayName = "OculusXR Scene Anchor Component", BlueprintSpawnableComponent))
class OCULUSXRSCENE_API UOculusXRSceneAnchorComponent : public UOculusXRAnchorComponent
{
GENERATED_BODY()
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
public:
UOculusXRSceneAnchorComponent(const FObjectInitializer& ObjectInitializer);
UPROPERTY(Transient, BlueprintReadOnly, Category = "OculusXR|Scene Anchor Component")
TArray<FString> SemanticClassifications;
UPROPERTY(Transient, BlueprintReadOnly, Category = "OculusXR|Scene Anchor Component")
FOculusXRUInt64 RoomSpaceID = 0;
};

View File

@@ -0,0 +1,13 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
#pragma once
#include "CoreTypes.h"
#include "OculusXRSceneTypes.h"
#include "Delegates/Delegate.h"
class FOculusXRSceneEventDelegates
{
public:
};

View File

@@ -0,0 +1,17 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
#pragma once
#include <Subsystems/EngineSubsystem.h>
#include "OculusXRSceneTypes.h"
#include "OculusXRSceneEventDelegates.generated.h"
UCLASS()
class UOculusXRSceneEventDelegates : public UEngineSubsystem
{
GENERATED_BODY()
public:
};

View File

@@ -0,0 +1,16 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
#pragma once
#include "OculusXRAnchorTypes.h"
#include "Kismet/BlueprintFunctionLibrary.h"
#include "OculusXRSceneFunctionLibrary.generated.h"
UCLASS()
class OCULUSXRSCENE_API UOculusXRSceneFunctionLibrary : public UBlueprintFunctionLibrary
{
GENERATED_BODY()
public:
};

View File

@@ -0,0 +1,49 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
#pragma once
#include "CoreMinimal.h"
#include "OculusXRSceneAnchorComponent.h"
#include "Engine/CollisionProfile.h"
#include "OculusXRRoomLayoutManagerComponent.h"
#include "OculusXRSceneGlobalMeshComponent.generated.h"
class UMaterialInterface;
UCLASS(meta = (DisplayName = "OculusXR Scene Global Mesh Component", BlueprintSpawnableComponent))
class OCULUSXRSCENE_API UOculusXRSceneGlobalMeshComponent : public UActorComponent
{
GENERATED_BODY()
virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) override;
public:
UOculusXRSceneGlobalMeshComponent(const FObjectInitializer& ObjectInitializer);
void CreateMeshComponent(const FOculusXRUInt64& Space, AActor* GlobalMeshAnchor, const UOculusXRRoomLayoutManagerComponent* RoomLayoutManagerComponent) const;
static const FString GlobalMeshSemanticLabel;
public:
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "OculusXR")
bool Collision = false;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "OculusXR")
FCollisionProfileName CollisionProfileName;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "OculusXR")
bool Visible = false;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "OculusXR")
UMaterialInterface* Material = nullptr;
UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "OculusXR")
TSoftClassPtr<UOculusXRSceneAnchorComponent> SceneAnchorComponent = TSoftClassPtr<UOculusXRSceneAnchorComponent>(FSoftClassPath(UOculusXRSceneAnchorComponent::StaticClass()));
public:
bool HasCollision() const;
bool IsVisible() const;
UClass* GetAnchorComponentClass() const;
};

View File

@@ -0,0 +1,31 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
#pragma once
#include "OculusXRSceneTypes.h"
#include <Subsystems/GameInstanceSubsystem.h>
#include <Tickable.h>
#include "OculusXRSceneSubsystem.generated.h"
UCLASS()
class UOculusXRSceneSubsystem : public UGameInstanceSubsystem, public FTickableGameObject
{
GENERATED_BODY()
public:
UOculusXRSceneSubsystem();
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
virtual void Deinitialize() override;
// FTickableGameObject implementation Begin
virtual ETickableTickType GetTickableTickType() const override;
virtual bool IsAllowedToTick() const override final;
virtual void Tick(float DeltaTime) override;
virtual TStatId GetStatId() const override { RETURN_QUICK_DECLARE_CYCLE_STAT(UOculusXRSceneSubsystem, STATGROUP_Tickables); }
// FTickableGameObject implementation End
private:
};

View File

@@ -0,0 +1,14 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
#pragma once
#include "OculusXRSceneTypes.generated.h"
USTRUCT()
struct FSceneTypesPlaceholder
{
GENERATED_BODY()
public:
};