Skip to content

Commit

Permalink
Add support for the Meta scene capture API
Browse files Browse the repository at this point in the history
Merge pull request #1266 from dsnopek/automatic-engine-class-registration

Automatically register only engine classes whose header has been included
  • Loading branch information
m4gr3d committed Oct 18, 2023
1 parent 710a722 commit b3f31b4
Show file tree
Hide file tree
Showing 53 changed files with 16,897 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "thirdparty/godot-cpp"]
path = thirdparty/godot-cpp
url = https://github.com/godotengine/godot-cpp
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Add support for Quest 3 devices
- Update the directory structure for the v2 plugin
- Update Meta OpenXR mobile SDK to version 57
- Add support for the Meta scene capture API

## 1.1.0
- Update Meta OpenXR loader to version 54
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ const PASSTHROUGH_OPTION = {
"update_visibility": false,
}

const USE_ANCHOR_API_OPTION = {
"option": {
"name": "meta_xr_features/use_anchor_api",
"class_name": "",
"type": TYPE_BOOL,
"hint": PROPERTY_HINT_NONE,
"hint_string": "",
"usage": PROPERTY_USAGE_DEFAULT,
},
"default_value": false,
"update_visibility": false,
}

const SUPPORT_QUEST_1_OPTION = {
"option": {
"name": "meta_xr_features/quest_1_support",
Expand Down Expand Up @@ -130,6 +143,7 @@ func _get_export_options(platform) -> Array[Dictionary]:
HAND_TRACKING_OPTION,
HAND_TRACKING_FREQUENCY_OPTION,
PASSTHROUGH_OPTION,
USE_ANCHOR_API_OPTION,
SUPPORT_QUEST_1_OPTION,
SUPPORT_QUEST_2_OPTION,
SUPPORT_QUEST_3_OPTION,
Expand Down Expand Up @@ -195,6 +209,10 @@ func _get_export_option_warning(platform, option) -> String:
if not(openxr_enabled) and _get_int_option(option, PASSTHROUGH_NONE_VALUE) > PASSTHROUGH_NONE_VALUE:
warning = "\"Passthrough\" requires \"XR Mode\" to be \"OpenXR\".\n"

"meta_xr_features/use_anchor_api":
if not(openxr_enabled) and _get_bool_option(option):
warning = "\"Use anchor API\" is only valid when \"XR Mode\" is \"OpenXR\"."

_:
warning = super._get_export_option_warning(platform, option)

Expand Down Expand Up @@ -234,6 +252,11 @@ func _get_android_manifest_element_contents(platform, debug) -> String:
elif passthrough_mode == PASSTHROUGH_REQUIRED_VALUE:
contents += " <uses-feature tools:node=\"replace\" android:name=\"com.oculus.feature.PASSTHROUGH\" android:required=\"true\" />\n"

# Check for anchor api
var use_anchor_api = _get_bool_option("meta_xr_features/use_anchor_api")
if use_anchor_api:
contents += " <uses-permission android:name=\"com.oculus.permission.USE_ANCHOR_API\" />\n"

return contents


Expand Down
1 change: 1 addition & 0 deletions demo/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -211,3 +211,4 @@ meta_xr_features/quest_1_support=false
meta_xr_features/quest_2_support=true
meta_xr_features/quest_3_support=true
meta_xr_features/quest_pro_support=true
meta_xr_features/use_anchor_api=false
161 changes: 161 additions & 0 deletions godotopenxrmeta/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
cmake_minimum_required(VERSION 3.22.1)

## Default configs
# Default android abi is arm64-v8a
if (NOT ANDROID_ABI)
set(ANDROID_ABI "arm64-v8a")
endif (NOT ANDROID_ABI)

if (ANDROID_ABI STREQUAL "armeabi-v7a")
set(GODOT_CPP_LIB_ABI "arm32")
elseif (ANDROID_ABI STREQUAL "x86")
set(GODOT_CPP_LIB_ABI "x86_32")
elseif (ANDROID_ABI STREQUAL "x86_64")
set(GODOT_CPP_LIB_ABI "x86_64")
else ()
set(GODOT_CPP_LIB_ABI "arm64")
endif ()

# Default android platform is android-21
if (NOT ANDROID_PLATFORM)
set(ANDROID_PLATFORM "android-21")
endif (NOT ANDROID_PLATFORM)

# Default build type is Debug
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif (NOT CMAKE_BUILD_TYPE)

if (CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-D_DEBUG)
set(GODOT_CPP_LIB_BUILD_TYPE debug)
set(OPENXR_MOBILE_LIB_BUILD_TYPE Debug)
else ()
add_definitions(-DNDEBUG)
set(GODOT_CPP_LIB_BUILD_TYPE release)
set(OPENXR_MOBILE_LIB_BUILD_TYPE Release)
endif (CMAKE_BUILD_TYPE MATCHES Debug)

if (NOT (ANDROID_STL STREQUAL "c++_shared"))
set(ANDROID_STL "c++_shared")
endif (NOT (ANDROID_STL STREQUAL "c++_shared"))

# Check if ANDROID_NDK is set.
if (NOT ANDROID_NDK)
# Set to ANDROID_NDK_HOME environment variable if it's set.
if (DEFINED ENV{ANDROID_NDK_HOME})
set(ANDROID_NDK $ENV{ANDROID_NDK_HOME})
else (DEFINED ENV{ANDROID_NDK_HOME})
message(WARNING "ANDROID_NDK_HOME is not set")
endif (DEFINED ENV{ANDROID_NDK_HOME})
endif (NOT ANDROID_NDK)

# Check if CMAKE_TOOLCHAIN_FILE is set.
if (NOT CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE "${ANDROID_NDK}/build/cmake/android.toolchain.cmake")
endif (NOT CMAKE_TOOLCHAIN_FILE)

if (NOT DEFINED BITS)
set(BITS 32)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITS 64)
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
endif (NOT DEFINED BITS)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)


project(godotopenxrmeta LANGUAGES CXX)

add_definitions(-DANDROID)

set(GODOT_COMPILE_FLAGS)
set(GODOT_LINKER_FLAGS)

set(GODOT_LINKER_FLAGS "-Wl")

set(GODOT_COMPILE_FLAGS "-fPIC -g -Wwrite-strings")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wchar-subscripts -Wcomment -Wdisabled-optimization")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wformat -Wformat=2 -Wformat-security -Wformat-y2k")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wimport -Winit-self -Winline -Winvalid-pch")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wlong-long -Wmissing-braces -Wmissing-format-attribute")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpointer-arith")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wredundant-decls -Wreturn-type -Wsequence-point")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wswitch -Wswitch-enum -Wtrigraphs")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused-label")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wunused-value -Wvariadic-macros -Wvolatile-register-var -Wno-error=attributes")

if (NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wno-ignored-attributes")
endif ()

if (CMAKE_BUILD_TYPE MATCHES Debug)
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -fno-omit-frame-pointer -O0")
else ()
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -O3")
endif (CMAKE_BUILD_TYPE MATCHES Debug)


## godot-cpp library
set(GODOT_CPP_DIR "${CMAKE_SOURCE_DIR}/../thirdparty/godot-cpp")
set(GODOT-CPP "godot-cpp")

# Use the godot-cpp prebuilt static binary
set(GODOT_CPP_STATIC_LIB "${GODOT_CPP_DIR}/bin/libgodot-cpp.android.template_${GODOT_CPP_LIB_BUILD_TYPE}.${GODOT_CPP_LIB_ABI}.a")

list(APPEND GODOT_CPP_INCLUDE_DIRECTORIES "${GODOT_CPP_DIR}/include")
list(APPEND GODOT_CPP_INCLUDE_DIRECTORIES "${GODOT_CPP_DIR}/gen/include")
list(APPEND GODOT_CPP_INCLUDE_DIRECTORIES "${GODOT_CPP_DIR}/gdextension")

add_library(${GODOT-CPP}
STATIC
IMPORTED GLOBAL
INTERFACE_INCLUDE_DIRECTORIES "${GODOT_CPP_INCLUDE_DIRECTORIES}"
)
set_target_properties(${GODOT-CPP} PROPERTIES IMPORTED_LOCATION ${GODOT_CPP_STATIC_LIB})


## OpenXR Mobile loader library
# Sets the path to the OpenXR mobile library directory.
set(OPENXR_MOBILE_ROOT_DIR "${CMAKE_SOURCE_DIR}/libs/ovr_openxr_mobile_sdk/OpenXR")
set(OPENXR_MOBILE_HEADERS_DIR "${OPENXR_MOBILE_ROOT_DIR}/Include" CACHE STRING "")

set(OPENXR_HEADERS_DIR "${CMAKE_SOURCE_DIR}/../thirdparty/openxr/include")

set(OPENXR_MOBILE_LIB_PATH "${OPENXR_MOBILE_ROOT_DIR}/Libs/Android/${ANDROID_ABI}/${OPENXR_MOBILE_LIB_BUILD_TYPE}/libopenxr_loader.so")
add_library(openxr_loader
SHARED
IMPORTED GLOBAL
)
set_target_properties(openxr_loader PROPERTIES IMPORTED_LOCATION ${OPENXR_MOBILE_LIB_PATH})


## Setup the project sources
file(GLOB_RECURSE ANDROID_SOURCES ${CMAKE_SOURCE_DIR}/src/main/cpp/*.c**)
file(GLOB_RECURSE ANDROID_HEADERS ${CMAKE_SOURCE_DIR}/src/main/cpp/*.h**)

add_library(${CMAKE_PROJECT_NAME}
SHARED
${ANDROID_SOURCES}
${ANDROID_HEADERS}
)

target_include_directories(${CMAKE_PROJECT_NAME}
SYSTEM PUBLIC
${GODOT_CPP_INCLUDE_DIRECTORIES}
${OPENXR_HEADERS_DIR}
${OPENXR_MOBILE_HEADERS_DIR}
)

target_link_libraries(${CMAKE_PROJECT_NAME}
android
log
${GODOT-CPP}
openxr_loader
)

# Add the compile flags
set_property(TARGET ${CMAKE_PROJECT_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${GODOT_COMPILE_FLAGS})
set_property(TARGET ${CMAKE_PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LINKER_FLAGS})
21 changes: 21 additions & 0 deletions godotopenxrmeta/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,23 @@ android {
minSdk versions.minSdk
targetSdk versions.targetSdk
versionName getReleaseVersion()
externalNativeBuild {
cmake {
cppFlags ''
}
}

ndk {
//noinspection ChromeOsAbiSupport
abiFilters "arm64-v8a"
}
}
externalNativeBuild {
cmake {
path file('CMakeLists.txt')
version '3.22.1'
}
}

namespace = "org.godotengine.openxrloaders.meta"

Expand All @@ -46,6 +57,16 @@ android {
withJavadocJar()
}
}

buildFeatures {
prefabPublishing true
}

prefab {
openxr_loader {
headers "libs/ovr_openxr_mobile_sdk/OpenXR/Include"
}
}
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
#ifndef EXTX1_EVENT_CHANNEL_H_
#define EXTX1_EVENT_CHANNEL_H_ 1

/**********************
This file is @generated from the OpenXR XML API registry.
Language : C99
Copyright : (c) Meta Platforms, Inc. and affiliates. Confidential and proprietary.
***********************/

#include <openxr/openxr.h>

#ifdef __cplusplus
extern "C" {
#endif


#ifndef XR_EXTX1_event_channel

#define XR_EXTX1_event_channel 1
XR_DEFINE_HANDLE(XrEventChannelEXTX1)
#define XR_EXTX1_event_channel_SPEC_VERSION 3
#define XR_EXTX1_EVENT_CHANNEL_EXTENSION_NAME "XR_EXTX1_event_channel"
static const XrStructureType XR_TYPE_EVENT_CHANNEL_CREATE_INFO_EXTX1 = (XrStructureType) 1000170001;
static const XrStructureType XR_TYPE_EVENT_CHANNEL_TARGET_EXTX1 = (XrStructureType) 1000170002;
static const XrStructureType XR_TYPE_SELECT_EVENT_CHANNEL_INFO_EXTX1 = (XrStructureType) 1000170003;
// XrEventChannelEXTX1
static const XrObjectType XR_OBJECT_TYPE_EVENT_CHANNEL_EXTX1 = (XrObjectType) 1000170000;

typedef enum XrSelectEventChannelFlagsEXTX1 {
XR_SELECT_EVENT_CHANNEL_FLAGS_EXTX1_MAX_ENUM = 0x7FFFFFFF
} XrSelectEventChannelFlagsEXTX1;
typedef struct XrEventChannelCreateInfoEXTX1 {
XrStructureType type;
const void* XR_MAY_ALIAS next;
} XrEventChannelCreateInfoEXTX1;

typedef struct XrEventChannelTargetEXTX1 {
XrStructureType type;
const void* XR_MAY_ALIAS next;
XrEventChannelEXTX1 channel;
} XrEventChannelTargetEXTX1;

typedef struct XrSelectEventChannelInfoEXTX1 {
XrStructureType type;
const void* XR_MAY_ALIAS next;
XrSelectEventChannelFlagsEXTX1 flags;
XrDuration timeout;
uint32_t eventChannelCount;
const XrEventChannelEXTX1* eventChannels;
} XrSelectEventChannelInfoEXTX1;

typedef XrResult (XRAPI_PTR *PFN_xrCreateEventChannelEXTX1)(XrInstance instance, const XrEventChannelCreateInfoEXTX1* createInfo, XrEventChannelEXTX1* channel);
typedef XrResult (XRAPI_PTR *PFN_xrDestroyEventChannelEXTX1)(XrEventChannelEXTX1 channel);
typedef XrResult (XRAPI_PTR *PFN_xrPollEventChannelEXTX1)(XrEventChannelEXTX1 channel, XrEventDataBuffer* eventData);
typedef XrResult (XRAPI_PTR *PFN_xrSelectEventChannelEXTX1)(XrInstance instance, XrSelectEventChannelInfoEXTX1* info, uint32_t* channelWithEvent);
typedef XrResult (XRAPI_PTR *PFN_xrSetDefaultEventChannelEXTX1)(XrInstance instance, XrEventChannelEXTX1 channel);

#ifndef XR_NO_PROTOTYPES
#ifdef XR_EXTENSION_PROTOTYPES
XRAPI_ATTR XrResult XRAPI_CALL xrCreateEventChannelEXTX1(
XrInstance instance,
const XrEventChannelCreateInfoEXTX1* createInfo,
XrEventChannelEXTX1* channel);

XRAPI_ATTR XrResult XRAPI_CALL xrDestroyEventChannelEXTX1(
XrEventChannelEXTX1 channel);

XRAPI_ATTR XrResult XRAPI_CALL xrPollEventChannelEXTX1(
XrEventChannelEXTX1 channel,
XrEventDataBuffer* eventData);

XRAPI_ATTR XrResult XRAPI_CALL xrSelectEventChannelEXTX1(
XrInstance instance,
XrSelectEventChannelInfoEXTX1* info,
uint32_t* channelWithEvent);

XRAPI_ATTR XrResult XRAPI_CALL xrSetDefaultEventChannelEXTX1(
XrInstance instance,
XrEventChannelEXTX1 channel);
#endif /* XR_EXTENSION_PROTOTYPES */
#endif /* !XR_NO_PROTOTYPES */
#endif /* XR_EXTX1_event_channel */

#ifdef XR_EXTX1_EVENT_CHANNEL_TAG_ALIAS
typedef XrEventChannelCreateInfoEXTX1 XrEventChannelCreateInfoEXT;
typedef XrEventChannelEXTX1 XrEventChannelEXT;
typedef XrEventChannelTargetEXTX1 XrEventChannelTargetEXT;
typedef XrSelectEventChannelFlagsEXTX1 XrSelectEventChannelFlagsEXT;
typedef XrSelectEventChannelInfoEXTX1 XrSelectEventChannelInfoEXT;
#define XR_EXT_event_channel_SPEC_VERSION XR_EXTX1_event_channel_SPEC_VERSION
#define XR_EXT_EVENT_CHANNEL_EXTENSION_NAME XR_EXTX1_EVENT_CHANNEL_EXTENSION_NAME
#define XR_TYPE_EVENT_CHANNEL_CREATE_INFO_EXT XR_TYPE_EVENT_CHANNEL_CREATE_INFO_EXTX1
#define XR_TYPE_EVENT_CHANNEL_TARGET_EXT XR_TYPE_EVENT_CHANNEL_TARGET_EXTX1
#define XR_TYPE_SELECT_EVENT_CHANNEL_INFO_EXT XR_TYPE_SELECT_EVENT_CHANNEL_INFO_EXTX1
#define XR_OBJECT_TYPE_EVENT_CHANNEL_EXT XR_OBJECT_TYPE_EVENT_CHANNEL_EXTX1
#endif /* XR_EXTX1_EVENT_CHANNEL_TAG_ALIAS */


#ifdef __cplusplus
}
#endif

#endif
Loading

0 comments on commit b3f31b4

Please sign in to comment.