diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..1df6c35b --- /dev/null +++ b/.clang-format @@ -0,0 +1,199 @@ +# Commented out parameters are those with the same value as base LLVM style. +# We can uncomment them if we want to change their value, or enforce the +# chosen value in case the base style changes (last sync: Clang 14.0). +--- +### General config, applies to all languages ### +BasedOnStyle: LLVM +AccessModifierOffset: -4 +AlignAfterOpenBracket: DontAlign +# AlignArrayOfStructures: None +# AlignConsecutiveMacros: None +# AlignConsecutiveAssignments: None +# AlignConsecutiveBitFields: None +# AlignConsecutiveDeclarations: None +# AlignEscapedNewlines: Right +AlignOperands: DontAlign +AlignTrailingComments: false +# AllowAllArgumentsOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false +# AllowShortEnumsOnASingleLine: true +# AllowShortBlocksOnASingleLine: Never +# AllowShortCaseLabelsOnASingleLine: false +# AllowShortFunctionsOnASingleLine: All +# AllowShortLambdasOnASingleLine: All +# AllowShortIfStatementsOnASingleLine: Never +# AllowShortLoopsOnASingleLine: false +# AlwaysBreakAfterDefinitionReturnType: None +# AlwaysBreakAfterReturnType: None +# AlwaysBreakBeforeMultilineStrings: false +# AlwaysBreakTemplateDeclarations: MultiLine +# AttributeMacros: +# - __capability +# BinPackArguments: true +# BinPackParameters: true +# BraceWrapping: +# AfterCaseLabel: false +# AfterClass: false +# AfterControlStatement: Never +# AfterEnum: false +# AfterFunction: false +# AfterNamespace: false +# AfterObjCDeclaration: false +# AfterStruct: false +# AfterUnion: false +# AfterExternBlock: false +# BeforeCatch: false +# BeforeElse: false +# BeforeLambdaBody: false +# BeforeWhile: false +# IndentBraces: false +# SplitEmptyFunction: true +# SplitEmptyRecord: true +# SplitEmptyNamespace: true +# BreakBeforeBinaryOperators: None +# BreakBeforeConceptDeclarations: true +# BreakBeforeBraces: Attach +# BreakBeforeInheritanceComma: false +# BreakInheritanceList: BeforeColon +# BreakBeforeTernaryOperators: true +# BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: AfterColon +# BreakStringLiterals: true +ColumnLimit: 0 +# CommentPragmas: '^ IWYU pragma:' +# QualifierAlignment: Leave +# CompactNamespaces: false +ConstructorInitializerIndentWidth: 8 +ContinuationIndentWidth: 8 +Cpp11BracedListStyle: false +# DeriveLineEnding: true +# DerivePointerAlignment: false +# DisableFormat: false +# EmptyLineAfterAccessModifier: Never +# EmptyLineBeforeAccessModifier: LogicalBlock +# ExperimentalAutoDetectBinPacking: false +# PackConstructorInitializers: BinPack +ConstructorInitializerAllOnOneLineOrOnePerLine: true +# AllowAllConstructorInitializersOnNextLine: true +# FixNamespaceComments: true +# ForEachMacros: +# - foreach +# - Q_FOREACH +# - BOOST_FOREACH +# IfMacros: +# - KJ_IF_MAYBE +# IncludeBlocks: Preserve +IncludeCategories: + - Regex: '".*"' + Priority: 1 + - Regex: '^<.*\.h>' + Priority: 2 + - Regex: '^<.*' + Priority: 3 +# IncludeIsMainRegex: '(Test)?$' +# IncludeIsMainSourceRegex: '' +# IndentAccessModifiers: false +IndentCaseLabels: true +# IndentCaseBlocks: false +# IndentGotoLabels: true +# IndentPPDirectives: None +# IndentExternBlock: AfterExternBlock +# IndentRequires: false +IndentWidth: 4 +# IndentWrappedFunctionNames: false +# InsertTrailingCommas: None +# JavaScriptQuotes: Leave +# JavaScriptWrapImports: true +KeepEmptyLinesAtTheStartOfBlocks: false +# LambdaBodyIndentation: Signature +# MacroBlockBegin: '' +# MacroBlockEnd: '' +# MaxEmptyLinesToKeep: 1 +# NamespaceIndentation: None +# PenaltyBreakAssignment: 2 +# PenaltyBreakBeforeFirstCallParameter: 19 +# PenaltyBreakComment: 300 +# PenaltyBreakFirstLessLess: 120 +# PenaltyBreakOpenParenthesis: 0 +# PenaltyBreakString: 1000 +# PenaltyBreakTemplateDeclaration: 10 +# PenaltyExcessCharacter: 1000000 +# PenaltyReturnTypeOnItsOwnLine: 60 +# PenaltyIndentedWhitespace: 0 +# PointerAlignment: Right +# PPIndentWidth: -1 +# ReferenceAlignment: Pointer +# ReflowComments: true +# RemoveBracesLLVM: false +# SeparateDefinitionBlocks: Leave +# ShortNamespaceLines: 1 +# SortIncludes: CaseSensitive +# SortJavaStaticImport: Before +# SortUsingDeclarations: true +# SpaceAfterCStyleCast: false +# SpaceAfterLogicalNot: false +# SpaceAfterTemplateKeyword: true +# SpaceBeforeAssignmentOperators: true +# SpaceBeforeCaseColon: false +# SpaceBeforeCpp11BracedList: false +# SpaceBeforeCtorInitializerColon: true +# SpaceBeforeInheritanceColon: true +# SpaceBeforeParens: ControlStatements +# SpaceBeforeParensOptions: +# AfterControlStatements: true +# AfterForeachMacros: true +# AfterFunctionDefinitionName: false +# AfterFunctionDeclarationName: false +# AfterIfMacros: true +# AfterOverloadedOperator: false +# BeforeNonEmptyParentheses: false +# SpaceAroundPointerQualifiers: Default +# SpaceBeforeRangeBasedForLoopColon: true +# SpaceInEmptyBlock: false +# SpaceInEmptyParentheses: false +# SpacesBeforeTrailingComments: 1 +# SpacesInAngles: Never +# SpacesInConditionalStatement: false +# SpacesInContainerLiterals: true +# SpacesInCStyleCastParentheses: false +## Godot TODO: We'll want to use a min of 1, but we need to see how to fix +## our comment capitalization at the same time. +SpacesInLineCommentPrefix: + Minimum: 0 + Maximum: -1 +# SpacesInParentheses: false +# SpacesInSquareBrackets: false +# SpaceBeforeSquareBrackets: false +# BitFieldColonSpacing: Both +# StatementAttributeLikeMacros: +# - Q_EMIT +# StatementMacros: +# - Q_UNUSED +# - QT_REQUIRE_VERSION +TabWidth: 4 +# UseCRLF: false +UseTab: Always +# WhitespaceSensitiveMacros: +# - STRINGIZE +# - PP_STRINGIZE +# - BOOST_PP_STRINGIZE +# - NS_SWIFT_NAME +# - CF_SWIFT_NAME +--- +### C++ specific config ### +Language: Cpp +Standard: c++17 +--- +### ObjC specific config ### +Language: ObjC +# ObjCBinPackProtocolList: Auto +ObjCBlockIndentWidth: 4 +# ObjCBreakBeforeNestedBlockParam: true +# ObjCSpaceAfterProperty: false +# ObjCSpaceBeforeProtocolList: true +--- +### Java specific config ### +Language: Java +# BreakAfterJavaFieldAnnotations: false +JavaImportGroups: ['org.godotengine', 'android', 'androidx', 'com.android', 'com.google', 'java', 'javax'] +... diff --git a/.github/workflows/build-addon-on-push.yml b/.github/workflows/build-addon-on-push.yml index 727195e1..9e8d2920 100644 --- a/.github/workflows/build-addon-on-push.yml +++ b/.github/workflows/build-addon-on-push.yml @@ -1,8 +1,7 @@ # Workflow to automatically create the godot openxr loaders addon name: Build on push -on: - [push, pull_request] +on: [push, pull_request] jobs: build: @@ -66,7 +65,7 @@ jobs: - name: Set up Python (for SCons) uses: actions/setup-python@v4 with: - python-version: '3.x' + python-version: "3.x" - name: Android dependencies uses: nttld/setup-ndk@v1 with: @@ -87,7 +86,7 @@ jobs: uses: actions/setup-java@v3 with: java-version: 17 - distribution: 'adopt' + distribution: "adopt" if: matrix.platform == 'android' - name: Validate Gradle wrapper uses: gradle/wrapper-validation-action@v1 @@ -95,7 +94,7 @@ jobs: - name: Create Godot-CPP library run: | cd aar/thirdparty/godot-cpp - scons platform=${{ matrix.platform }} target=template_debug arch=arm64 + scons platform=${{ matrix.platform }} target=template_debug arch=arm64 scons platform=${{ matrix.platform }} target=template_release arch=arm64 scons platform=${{ matrix.platform }} target=template_debug arch=x86_64 scons platform=${{ matrix.platform }} target=template_release arch=x86_64 @@ -138,10 +137,10 @@ jobs: run: | mkdir -p asset/addons/godotopenxrvendors/meta/ cp aar/godotopenxrmeta/LICENSE.txt asset/addons/godotopenxrvendors/meta/ - + mkdir -p asset/addons/godotopenxrvendors/pico/ cp aar/godotopenxrpico/libs/pico_openxr_sdk/arm64-v8a/README.md asset/addons/godotopenxrvendors/pico/LICENSE.md - + mkdir -p asset/addons/godotopenxrvendors/khronos/ cp aar/godotopenxrkhronos/LICENSE asset/addons/godotopenxrvendors/khronos/LICENSE @@ -150,13 +149,13 @@ jobs: mkdir -p asset/addons/godotopenxrvendors/.bin/android/ cp -r build-files-android-aar/* asset/addons/godotopenxrvendors/.bin/android/ cp -r build-files-android-so/* asset/addons/godotopenxrvendors/.bin/android/ - + mkdir -p asset/addons/godotopenxrvendors/.bin/linux/ cp -r build-files-linux-x86_64/* asset/addons/godotopenxrvendors/.bin/linux/ - + mkdir -p asset/addons/godotopenxrvendors/.bin/windows/ cp -r build-files-windows/* asset/addons/godotopenxrvendors/.bin/windows/ - + mkdir -p asset/addons/godotopenxrvendors/.bin/macos/ cp -r build-files-macos/* asset/addons/godotopenxrvendors/.bin/macos/ @@ -181,4 +180,3 @@ jobs: omitPrereleaseDuringUpdate: true token: ${{ secrets.GITHUB_TOKEN }} if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') - diff --git a/.github/workflows/mavencentral-publish.yml b/.github/workflows/mavencentral-publish.yml index 879f38e9..3944e576 100644 --- a/.github/workflows/mavencentral-publish.yml +++ b/.github/workflows/mavencentral-publish.yml @@ -18,7 +18,7 @@ jobs: - name: Set up Python (for SCons) uses: actions/setup-python@v4 with: - python-version: '3.x' + python-version: "3.x" - name: Android dependencies uses: nttld/setup-ndk@v1 with: diff --git a/.github/workflows/scripts/clang_format.sh b/.github/workflows/scripts/clang_format.sh new file mode 100644 index 00000000..be25242a --- /dev/null +++ b/.github/workflows/scripts/clang_format.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +# This script runs clang-format and fixes copyright headers on all relevant files in the repo. +# This is the primary script responsible for fixing style violations. + +set -uo pipefail +IFS=$'\n\t' + +CLANG_FORMAT_FILE_EXTS=(".c" ".h" ".cpp" ".hpp" ".cc" ".hh" ".cxx" ".m" ".mm" ".inc" ".java" ".glsl") + +# Loops through all text files tracked by Git. +git grep -zIl '' | +while IFS= read -rd '' f; do + # Exclude 3rd party files. + if [[ "$f" == "thirdparty"* ]]; then + continue + elif [[ "$f" == "demo/addons/godotopenxrvendors"* ]]; then + continue + elif [[ "$f" == "gradle"* ]]; then + continue + elif [[ "$f" == "build"* ]]; then + continue + elif [[ "$f" == "android"* ]]; then + continue + elif [[ "$f" == ".github"* ]]; then + continue + fi + for extension in ${CLANG_FORMAT_FILE_EXTS[@]}; do + if [[ "$f" == *"$extension" ]]; then + # Run clang-format. + clang-format -i "$f" + fi + done +done + +git diff > patch.patch + +# If no patch has been generated all is OK, clean up, and exit. +if [ ! -s patch.patch ] ; then + printf "Files in this commit comply with the clang-format style rules.\n" + rm -f patch.patch + exit 0 +fi + +# A patch has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the formatting rules:\n\n" +cat patch.patch +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +rm -f patch.patch +exit 1 diff --git a/.github/workflows/scripts/file_format.sh b/.github/workflows/scripts/file_format.sh new file mode 100644 index 00000000..df7b13e5 --- /dev/null +++ b/.github/workflows/scripts/file_format.sh @@ -0,0 +1,69 @@ +#!/usr/bin/env bash + +# This script ensures proper POSIX text file formatting and a few other things. +# This is supplementary to clang_format.sh, but should be run before it. + +# We need dos2unix and recode. +if [ ! -x "$(command -v dos2unix)" -o ! -x "$(command -v recode)" ]; then + printf "Install 'dos2unix' and 'recode' to use this script.\n" +fi + +set -uo pipefail +IFS=$'\n\t' + +# Loops through all text files tracked by Git. +git grep -zIl '' | +while IFS= read -rd '' f; do + # Exclude 3rd party files + if [[ "$f" == "thirdparty"* ]]; then + continue + elif [[ "$f" == "demo/addons/godotopenxrvendors"* ]]; then + continue + elif [[ "$f" == "gradle"* ]]; then + continue + elif [[ "$f" == "build"* ]]; then + continue + elif [[ "$f" == "android"* ]]; then + continue + elif [[ "$f" == *"NOTICE"* ]]; then + continue + elif [[ "$f" == *"LICENSE"* ]]; then + continue + fi + # Ensure that files are UTF-8 formatted. + recode UTF-8 "$f" 2> /dev/null + # Ensure that files have LF line endings and do not contain a BOM. + dos2unix "$f" 2> /dev/null + # Remove trailing space characters and ensures that files end + # with newline characters. -l option handles newlines conveniently. + perl -i -ple 's/\s*$//g' "$f" + # Remove the character sequence "== true" if it has a leading space. + perl -i -pe 's/\x20== true//g' "$f" + # We don't want to change lines around braces in godot/tscn files. + if [[ "$f" == *"godot" ]]; then + continue + elif [[ "$f" == *"tscn" ]]; then + continue + fi + # Disallow empty lines after the opening brace. + sed -z -i 's/\x7B\x0A\x0A/\x7B\x0A/g' "$f" + # Disallow some empty lines before the closing brace. + sed -z -i 's/\x0A\x0A\x7D/\x0A\x7D/g' "$f" +done + +git diff > patch.patch + +# If no patch has been generated all is OK, clean up, and exit. +if [ ! -s patch.patch ] ; then + printf "Files in this commit comply with the formatting rules.\n" + rm -f patch.patch + exit 0 +fi + +# A patch has been created, notify the user, clean up, and exit. +printf "\n*** The following differences were found between the code " +printf "and the formatting rules:\n\n" +cat patch.patch +printf "\n*** Aborting, please fix your commit(s) with 'git commit --amend' or 'git rebase -i '\n" +rm -f patch.patch +exit 1 diff --git a/.github/workflows/static_checks.yml b/.github/workflows/static_checks.yml new file mode 100644 index 00000000..be1cc40b --- /dev/null +++ b/.github/workflows/static_checks.yml @@ -0,0 +1,22 @@ +name: 📊 Static Checks +on: [push, pull_request] + +jobs: + static-checks: + name: Formatting (clang-format, file format) + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install dependencies + run: | + sudo apt-get install -qq dos2unix recode clang-format + + - name: File formatting checks (file_format.sh) + run: | + bash ./.github/workflows/scripts/file_format.sh + + - name: Style checks via clang-format (clang_format.sh) + run: | + bash ./.github/workflows/scripts/clang_format.sh diff --git a/.gitignore b/.gitignore index 817a2c2c..bd2783c8 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,4 @@ local.properties *.lib # Misc -.DS_Store \ No newline at end of file +.DS_Store diff --git a/README.md b/README.md index ea0c1b6f..89660f70 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,24 @@ # Godot OpenXR Vendors plugin -This plugin provides the functionality to support vendor-specific XR +This plugin provides the functionality to support vendor-specific XR devices (e.g: Meta, Pico devices) and access vendor-specific OpenXR extensions -**Note:** +**Note:** Version `2.x` and higher of this plugin requires **Godot 4.2**. -Check the [`1.x` branch](https://github.com/GodotVR/godot_openxr_vendors/tree/1.x) and releases +Check the [`1.x` branch](https://github.com/GodotVR/godot_openxr_vendors/tree/1.x) and releases for support on prior versions of Godot 4. ## Building this asset -After cloning this project, run the following command in the project root directory to initialize +After cloning this project, run the following command in the project root directory to initialize the `godot-cpp` submodule: ``` git submodule update --init ``` ### Building the Godot-CPP bindings -Build the Android C++ bindings using the following commands. +Build the Android C++ bindings using the following commands. ``` cd thirdparty/godot-cpp scons platform=android target=template_debug arch=arm64 @@ -27,7 +27,7 @@ scons platform=android target=template_debug arch=x86_64 scons platform=android target=template_release arch=x86_64 ``` -When the command is completed, you should have static libraries stored in `thirdparty/godot-cpp/bin` +When the command is completed, you should have static libraries stored in `thirdparty/godot-cpp/bin` that will be used for compilation by the plugin. ### Building the Plugin @@ -69,19 +69,19 @@ The use of a Godot Android plugin requires the use of the gradle build option in ### Copying the plugin into place -When downloading this asset from Godot's asset library it should place the required files into +When downloading this asset from Godot's asset library it should place the required files into the `addons`directory. -If you've downloaded the zip file from the releases page, copy the files in `asset/addons` +If you've downloaded the zip file from the releases page, copy the files in `asset/addons` manually to `addons` in your project. You may need to create the `addons` folder. -If you have build the asset from source, you need to create the `addons` folder in your project -if it doesn't exist already, and then copy the content of the `demo/addons` folder to `addons` +If you have build the asset from source, you need to create the `addons` folder in your project +if it doesn't exist already, and then copy the content of the `demo/addons` folder to `addons` in your project. ### Configuring your export Back in Godot open the `Project` menu and select `Export...`: -- If it doesn't already exist, create an Android export configuration by pressing `Add...` and +- If it doesn't already exist, create an Android export configuration by pressing `Add...` and selecting `Android` - Tick the `Use Gradle Build` tickbox - Select `OpenXR` as the **XR Mode** under the **XR Features** section @@ -92,6 +92,11 @@ selecting `Android` **Do not** select multiple vendors in the same export template! You can instead create multiple export templates, one for each vendor. +## Hooks + +When contributing to the source code for the plugin, we highly recommend you install clang-format and copy the contents of the `hooks` folder into the folder `.git/hooks/`. +This will ensure clang-format is run on any changed files before commiting the changes to github and prevent disappointment when formatting issues prevent changes from being merged. + ## License Unless specified otherwise, sources in this repository are licensed under MIT, see `LICENSE` for more information. diff --git a/common/src/main/cpp/export/export_plugin.cpp b/common/src/main/cpp/export/export_plugin.cpp index ed097711..d7cbf0ca 100644 --- a/common/src/main/cpp/export/export_plugin.cpp +++ b/common/src/main/cpp/export/export_plugin.cpp @@ -33,17 +33,18 @@ using namespace godot; -OpenXREditorExportPlugin::OpenXREditorExportPlugin() : _plugin_version(PLUGIN_VERSION) {} +OpenXREditorExportPlugin::OpenXREditorExportPlugin() : + _plugin_version(PLUGIN_VERSION) {} void OpenXREditorExportPlugin::_bind_methods() {} Dictionary OpenXREditorExportPlugin::_generate_export_option(const String &name, const String &class_name, - Variant::Type type, - PropertyHint property_hint, - const String &hint_string, - PropertyUsageFlags property_usage, - const Variant &default_value, - bool update_visibility) { + Variant::Type type, + PropertyHint property_hint, + const String &hint_string, + PropertyUsageFlags property_usage, + const Variant &default_value, + bool update_visibility) { Dictionary option_info; option_info["name"] = name; option_info["class_name"] = class_name; @@ -86,8 +87,7 @@ Dictionary OpenXREditorExportPlugin::_get_vendor_toggle_option(const String &ven "", PROPERTY_USAGE_DEFAULT, false, - false - ); + false); } bool OpenXREditorExportPlugin::_is_openxr_enabled() const { diff --git a/common/src/main/cpp/export/meta_export_plugin.cpp b/common/src/main/cpp/export/meta_export_plugin.cpp index a55419f3..ed37d72a 100644 --- a/common/src/main/cpp/export/meta_export_plugin.cpp +++ b/common/src/main/cpp/export/meta_export_plugin.cpp @@ -59,8 +59,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "None,Optional,Required", PROPERTY_USAGE_DEFAULT, EYE_TRACKING_NONE_VALUE, - false - ); + false); _face_tracking_option = _generate_export_option( "meta_xr_features/face_tracking", "", @@ -69,8 +68,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "None,Optional,Required", PROPERTY_USAGE_DEFAULT, FACE_TRACKING_NONE_VALUE, - false - ); + false); _hand_tracking_option = _generate_export_option( "meta_xr_features/hand_tracking", "", @@ -79,8 +77,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "None,Optional,Required", PROPERTY_USAGE_DEFAULT, HAND_TRACKING_NONE_VALUE, - false - ); + false); _hand_tracking_frequency_option = _generate_export_option( "meta_xr_features/hand_tracking_frequency", "", @@ -89,8 +86,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "Low,High", PROPERTY_USAGE_DEFAULT, HAND_TRACKING_FREQUENCY_LOW_VALUE, - false - ); + false); _passthrough_option = _generate_export_option( "meta_xr_features/passthrough", "", @@ -99,8 +95,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "None,Optional,Required", PROPERTY_USAGE_DEFAULT, PASSTHROUGH_NONE_VALUE, - false - ); + false); _use_anchor_api_option = _generate_export_option( "meta_xr_features/use_anchor_api", "", @@ -109,8 +104,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "", PROPERTY_USAGE_DEFAULT, false, - false - ); + false); _use_scene_api_option = _generate_export_option( "meta_xr_features/use_scene_api", "", @@ -119,8 +113,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "", PROPERTY_USAGE_DEFAULT, false, - false - ); + false); _use_overlay_keyboard_option = _generate_export_option( "meta_xr_features/use_overlay_keyboard", "", @@ -129,8 +122,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "", PROPERTY_USAGE_DEFAULT, false, - false - ); + false); _use_experimental_features_option = _generate_export_option( "meta_xr_features/use_experimental_features", "", @@ -139,8 +131,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "", PROPERTY_USAGE_DEFAULT, false, - false - ); + false); _boundary_mode_option = _generate_export_option( "meta_xr_features/boundary_mode", "", @@ -149,8 +140,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "Enabled,Disabled,Contextual", PROPERTY_USAGE_DEFAULT, BOUNDARY_ENABLED_VALUE, - false - ); + false); _support_quest_1_option = _generate_export_option( "meta_xr_features/quest_1_support", "", @@ -159,8 +149,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "", PROPERTY_USAGE_DEFAULT, false, - false - ); + false); _support_quest_2_option = _generate_export_option( "meta_xr_features/quest_2_support", "", @@ -169,8 +158,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "", PROPERTY_USAGE_DEFAULT, true, - false - ); + false); _support_quest_3_option = _generate_export_option( "meta_xr_features/quest_3_support", "", @@ -179,8 +167,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "", PROPERTY_USAGE_DEFAULT, true, - false - ); + false); _support_quest_pro_option = _generate_export_option( "meta_xr_features/quest_pro_support", "", @@ -189,8 +176,7 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() { "", PROPERTY_USAGE_DEFAULT, true, - false - ); + false); } void MetaEditorExportPlugin::_bind_methods() {} diff --git a/common/src/main/cpp/extensions/openxr_fb_face_tracking_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_face_tracking_extension_wrapper.cpp index 16060bd7..6fb2f281 100644 --- a/common/src/main/cpp/extensions/openxr_fb_face_tracking_extension_wrapper.cpp +++ b/common/src/main/cpp/extensions/openxr_fb_face_tracking_extension_wrapper.cpp @@ -178,11 +178,11 @@ void OpenXRFbFaceTrackingExtensionWrapper::_on_session_created(uint64_t instance face_expression_weights.type = XR_TYPE_FACE_EXPRESSION_WEIGHTS_FB; face_expression_weights.weightCount = XR_FACE_EXPRESSION_COUNT_FB; face_expression_weights.weights = weights; - face_expression_weights.confidenceCount = XR_FACE_CONFIDENCE_COUNT_FB; + face_expression_weights.confidenceCount = XR_FACE_CONFIDENCE_COUNT_FB; face_expression_weights.confidences = confidences; // Create the face-tracker handle - XrFaceTrackerCreateInfoFB createInfo = {XR_TYPE_FACE_TRACKER_CREATE_INFO_FB}; + XrFaceTrackerCreateInfoFB createInfo = { XR_TYPE_FACE_TRACKER_CREATE_INFO_FB }; createInfo.faceExpressionSet = XR_FACE_EXPRESSION_SET_DEFAULT_FB; XrResult result = xrCreateFaceTrackerFB(SESSION, &createInfo, &face_tracker); if (XR_FAILED(result)) { @@ -220,7 +220,7 @@ void OpenXRFbFaceTrackingExtensionWrapper::_on_process() { } // Read the expression weights - XrFaceExpressionInfoFB expression_info = {XR_TYPE_FACE_EXPRESSION_INFO_FB}; + XrFaceExpressionInfoFB expression_info = { XR_TYPE_FACE_EXPRESSION_INFO_FB }; expression_info.time = next_frame_time; XrResult result = xrGetFaceExpressionWeightsFB(face_tracker, &expression_info, &face_expression_weights); if (XR_FAILED(result)) { diff --git a/common/src/main/cpp/extensions/openxr_fb_scene_capture_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_scene_capture_extension_wrapper.cpp index 6c70906e..d97e87a1 100644 --- a/common/src/main/cpp/extensions/openxr_fb_scene_capture_extension_wrapper.cpp +++ b/common/src/main/cpp/extensions/openxr_fb_scene_capture_extension_wrapper.cpp @@ -32,10 +32,10 @@ #include "extensions/openxr_fb_scene_capture_extension_wrapper.h" -#include -#include -#include #include +#include +#include +#include using namespace godot; @@ -50,7 +50,6 @@ OpenXRFbSceneCaptureExtensionWrapper *OpenXRFbSceneCaptureExtensionWrapper::get_ OpenXRFbSceneCaptureExtensionWrapper::OpenXRFbSceneCaptureExtensionWrapper() : OpenXRExtensionWrapperExtension() { - ERR_FAIL_COND_MSG(singleton != nullptr, "An OpenXRFbSceneCaptureExtensionWrapper singleton already exists."); request_extensions[XR_FB_SCENE_CAPTURE_EXTENSION_NAME] = &fb_scene_capture_ext; @@ -62,13 +61,11 @@ OpenXRFbSceneCaptureExtensionWrapper::~OpenXRFbSceneCaptureExtensionWrapper() { } void OpenXRFbSceneCaptureExtensionWrapper::_bind_methods() { - ClassDB::bind_method(D_METHOD("is_scene_capture_supported"), &OpenXRFbSceneCaptureExtensionWrapper::is_scene_capture_supported); ClassDB::bind_method(D_METHOD("is_scene_capture_enabled"), &OpenXRFbSceneCaptureExtensionWrapper::is_scene_capture_enabled); ClassDB::bind_method(D_METHOD("request_scene_capture"), &OpenXRFbSceneCaptureExtensionWrapper::request_scene_capture); ADD_SIGNAL(MethodInfo("scene_capture_completed")); - } void OpenXRFbSceneCaptureExtensionWrapper::cleanup() { @@ -77,7 +74,7 @@ void OpenXRFbSceneCaptureExtensionWrapper::cleanup() { godot::Dictionary OpenXRFbSceneCaptureExtensionWrapper::_get_requested_extensions() { godot::Dictionary result; - for (auto ext: request_extensions) { + for (auto ext : request_extensions) { godot::String key = ext.first; uint64_t value = reinterpret_cast(ext.second); result[key] = (godot::Variant)value; @@ -122,8 +119,7 @@ bool OpenXRFbSceneCaptureExtensionWrapper::initialize_fb_scene_capture_extension } bool OpenXRFbSceneCaptureExtensionWrapper::_on_event_polled(const void *event) { - - if (static_cast(event)->type == XR_TYPE_EVENT_DATA_SCENE_CAPTURE_COMPLETE_FB) { + if (static_cast(event)->type == XR_TYPE_EVENT_DATA_SCENE_CAPTURE_COMPLETE_FB) { scene_capture_enabled = false; Object::emit_signal("scene_capture_completed"); return true; diff --git a/common/src/main/cpp/extensions/openxr_fb_scene_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_scene_extension_wrapper.cpp index 5e046694..4e3e90a7 100644 --- a/common/src/main/cpp/extensions/openxr_fb_scene_extension_wrapper.cpp +++ b/common/src/main/cpp/extensions/openxr_fb_scene_extension_wrapper.cpp @@ -29,9 +29,9 @@ #include "extensions/openxr_fb_scene_extension_wrapper.h" -#include -#include #include +#include +#include #ifdef META_VENDOR_ENABLED #include @@ -72,7 +72,7 @@ void OpenXRFbSceneExtensionWrapper::cleanup() { Dictionary OpenXRFbSceneExtensionWrapper::_get_requested_extensions() { Dictionary result; - for (auto ext: request_extensions) { + for (auto ext : request_extensions) { uint64_t value = reinterpret_cast(ext.value); result[ext.key] = (Variant)value; } @@ -93,7 +93,7 @@ void OpenXRFbSceneExtensionWrapper::_on_instance_destroyed() { cleanup(); } -std::optional OpenXRFbSceneExtensionWrapper::get_semantic_labels(const XrSpace& space) { +std::optional OpenXRFbSceneExtensionWrapper::get_semantic_labels(const XrSpace &space) { if (!OpenXRFbSpatialEntityExtensionWrapper::get_singleton()->is_component_enabled(space, XR_SPACE_COMPONENT_TYPE_SEMANTIC_LABELS_FB)) { return std::nullopt; } @@ -112,7 +112,7 @@ std::optional OpenXRFbSceneExtensionWrapper::get_semantic_labels(const X recognizedLabels.ptr(), }; - XrSemanticLabelsFB labels = {XR_TYPE_SEMANTIC_LABELS_FB, &semanticLabelsSupportInfo, 0}; + XrSemanticLabelsFB labels = { XR_TYPE_SEMANTIC_LABELS_FB, &semanticLabelsSupportInfo, 0 }; // First call. xrGetSpaceSemanticLabelsFB(SESSION, space, &labels); @@ -127,7 +127,7 @@ std::optional OpenXRFbSceneExtensionWrapper::get_semantic_labels(const X return String(std::string(labels.buffer, labels.bufferCountOutput).c_str()); } -void OpenXRFbSceneExtensionWrapper::get_shapes(const XrSpace& space, XrSceneObjectInternal& object) { +void OpenXRFbSceneExtensionWrapper::get_shapes(const XrSpace &space, XrSceneObjectInternal &object) { if (OpenXRFbSpatialEntityExtensionWrapper::get_singleton()->is_component_enabled(space, XR_SPACE_COMPONENT_TYPE_BOUNDED_2D_FB)) { // Grab both the bounding box 2D and the boundary XrRect2Df boundingBox2D; @@ -135,7 +135,7 @@ void OpenXRFbSceneExtensionWrapper::get_shapes(const XrSpace& space, XrSceneObje object.boundingBox2D = boundingBox2D; } - XrBoundary2DFB boundary2D = {XR_TYPE_BOUNDARY_2D_FB, nullptr, 0}; + XrBoundary2DFB boundary2D = { XR_TYPE_BOUNDARY_2D_FB, nullptr, 0 }; if (XR_SUCCEEDED(xrGetSpaceBoundary2DFB(SESSION, space, &boundary2D))) { Vector vertices; vertices.resize(boundary2D.vertexCountOutput); diff --git a/common/src/main/cpp/extensions/openxr_fb_spatial_entity_container_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_spatial_entity_container_extension_wrapper.cpp index a0a98a3a..ca15dd32 100644 --- a/common/src/main/cpp/extensions/openxr_fb_spatial_entity_container_extension_wrapper.cpp +++ b/common/src/main/cpp/extensions/openxr_fb_spatial_entity_container_extension_wrapper.cpp @@ -28,9 +28,9 @@ /**************************************************************************/ #include "extensions/openxr_fb_spatial_entity_container_extension_wrapper.h" -#include -#include #include +#include +#include using namespace godot; @@ -65,7 +65,7 @@ void OpenXRFbSpatialEntityContainerExtensionWrapper::cleanup() { Dictionary OpenXRFbSpatialEntityContainerExtensionWrapper::_get_requested_extensions() { Dictionary result; - for (auto ext: request_extensions) { + for (auto ext : request_extensions) { uint64_t value = reinterpret_cast(ext.value); result[ext.key] = (Variant)value; } @@ -86,13 +86,13 @@ void OpenXRFbSpatialEntityContainerExtensionWrapper::_on_instance_destroyed() { cleanup(); } -bool OpenXRFbSpatialEntityContainerExtensionWrapper::initialize_fb_spatial_entity_container_extension(const XrInstance& p_instance) { +bool OpenXRFbSpatialEntityContainerExtensionWrapper::initialize_fb_spatial_entity_container_extension(const XrInstance &p_instance) { GDEXTENSION_INIT_XR_FUNC_V(xrGetSpaceContainerFB); return true; } -Vector OpenXRFbSpatialEntityContainerExtensionWrapper::get_contained_uuids(const XrSpace& space) { - XrSpaceContainerFB spaceContainer = {XR_TYPE_SPACE_CONTAINER_FB}; +Vector OpenXRFbSpatialEntityContainerExtensionWrapper::get_contained_uuids(const XrSpace &space) { + XrSpaceContainerFB spaceContainer = { XR_TYPE_SPACE_CONTAINER_FB }; xrGetSpaceContainerFB(SESSION, space, &spaceContainer); Vector uuids; uuids.resize(spaceContainer.uuidCountOutput); diff --git a/common/src/main/cpp/extensions/openxr_fb_spatial_entity_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_spatial_entity_extension_wrapper.cpp index e06224c9..cb892af0 100644 --- a/common/src/main/cpp/extensions/openxr_fb_spatial_entity_extension_wrapper.cpp +++ b/common/src/main/cpp/extensions/openxr_fb_spatial_entity_extension_wrapper.cpp @@ -29,8 +29,8 @@ #include "extensions/openxr_fb_spatial_entity_extension_wrapper.h" -#include #include +#include #include #include @@ -67,7 +67,7 @@ void OpenXRFbSpatialEntityExtensionWrapper::cleanup() { Dictionary OpenXRFbSpatialEntityExtensionWrapper::_get_requested_extensions() { Dictionary result; - for (auto ext: request_extensions) { + for (auto ext : request_extensions) { uint64_t value = reinterpret_cast(ext.value); result[ext.key] = (Variant)value; } @@ -88,7 +88,7 @@ void OpenXRFbSpatialEntityExtensionWrapper::_on_instance_destroyed() { cleanup(); } -bool OpenXRFbSpatialEntityExtensionWrapper::initialize_fb_spatial_entity_extension(const XrInstance& p_instance) { +bool OpenXRFbSpatialEntityExtensionWrapper::initialize_fb_spatial_entity_extension(const XrInstance &p_instance) { GDEXTENSION_INIT_XR_FUNC_V(xrCreateSpatialAnchorFB); GDEXTENSION_INIT_XR_FUNC_V(xrGetSpaceUuidFB); GDEXTENSION_INIT_XR_FUNC_V(xrEnumerateSpaceSupportedComponentsFB); @@ -99,8 +99,8 @@ bool OpenXRFbSpatialEntityExtensionWrapper::initialize_fb_spatial_entity_extensi } bool OpenXRFbSpatialEntityExtensionWrapper::_on_event_polled(const void *event) { - if (static_cast(event)->type == XR_TYPE_EVENT_DATA_SPACE_SET_STATUS_COMPLETE_FB) { - auto eventData = (const XrEventDataSpaceSetStatusCompleteFB*) event; + if (static_cast(event)->type == XR_TYPE_EVENT_DATA_SPACE_SET_STATUS_COMPLETE_FB) { + auto eventData = (const XrEventDataSpaceSetStatusCompleteFB *)event; if (set_status_callbacks.has(eventData->requestId)) { set_status_callbacks[eventData->requestId](eventData); set_status_callbacks.erase(eventData->requestId); @@ -111,7 +111,7 @@ bool OpenXRFbSpatialEntityExtensionWrapper::_on_event_polled(const void *event) return false; } -bool OpenXRFbSpatialEntityExtensionWrapper::is_component_supported(const XrSpace& space, XrSpaceComponentTypeFB type) { +bool OpenXRFbSpatialEntityExtensionWrapper::is_component_supported(const XrSpace &space, XrSpaceComponentTypeFB type) { uint32_t numComponents = 0; xrEnumerateSpaceSupportedComponentsFB(space, 0, &numComponents, nullptr); Vector components; @@ -128,14 +128,14 @@ bool OpenXRFbSpatialEntityExtensionWrapper::is_component_supported(const XrSpace return supported; } -bool OpenXRFbSpatialEntityExtensionWrapper::is_component_enabled(const XrSpace& space, XrSpaceComponentTypeFB type) { - XrSpaceComponentStatusFB status = {XR_TYPE_SPACE_COMPONENT_STATUS_FB, nullptr}; +bool OpenXRFbSpatialEntityExtensionWrapper::is_component_enabled(const XrSpace &space, XrSpaceComponentTypeFB type) { + XrSpaceComponentStatusFB status = { XR_TYPE_SPACE_COMPONENT_STATUS_FB, nullptr }; xrGetSpaceComponentStatusFB(space, type, &status); return (status.enabled && !status.changePending); } void OpenXRFbSpatialEntityExtensionWrapper::set_component_enabled( - const XrSpace& space, + const XrSpace &space, XrSpaceComponentTypeFB type, bool status, std::optional callback) { @@ -148,7 +148,7 @@ void OpenXRFbSpatialEntityExtensionWrapper::set_component_enabled( }; XrAsyncRequestIdFB requestId; if (!XR_SUCCEEDED(xrSetSpaceComponentStatusFB(space, &request, &requestId))) { - if (callback != std::nullopt){ + if (callback != std::nullopt) { (*callback)(nullptr); } } diff --git a/common/src/main/cpp/extensions/openxr_fb_spatial_entity_query_extension_wrapper.cpp b/common/src/main/cpp/extensions/openxr_fb_spatial_entity_query_extension_wrapper.cpp index b2d28ccc..31bda2db 100644 --- a/common/src/main/cpp/extensions/openxr_fb_spatial_entity_query_extension_wrapper.cpp +++ b/common/src/main/cpp/extensions/openxr_fb_spatial_entity_query_extension_wrapper.cpp @@ -29,9 +29,9 @@ #include "extensions/openxr_fb_spatial_entity_query_extension_wrapper.h" -#include -#include #include +#include +#include using namespace godot; @@ -66,7 +66,7 @@ void OpenXRFbSpatialEntityQueryExtensionWrapper::cleanup() { Dictionary OpenXRFbSpatialEntityQueryExtensionWrapper::_get_requested_extensions() { Dictionary result; - for (auto ext: request_extensions) { + for (auto ext : request_extensions) { uint64_t value = reinterpret_cast(ext.value); result[ext.key] = (Variant)value; } @@ -87,7 +87,7 @@ void OpenXRFbSpatialEntityQueryExtensionWrapper::_on_instance_destroyed() { cleanup(); } -bool OpenXRFbSpatialEntityQueryExtensionWrapper::initialize_fb_spatial_entity_query_extension(const XrInstance& p_instance) { +bool OpenXRFbSpatialEntityQueryExtensionWrapper::initialize_fb_spatial_entity_query_extension(const XrInstance &p_instance) { GDEXTENSION_INIT_XR_FUNC_V(xrQuerySpacesFB); GDEXTENSION_INIT_XR_FUNC_V(xrRetrieveSpaceQueryResultsFB); @@ -95,20 +95,20 @@ bool OpenXRFbSpatialEntityQueryExtensionWrapper::initialize_fb_spatial_entity_qu } bool OpenXRFbSpatialEntityQueryExtensionWrapper::_on_event_polled(const void *event) { - if (static_cast(event)->type == XR_TYPE_EVENT_DATA_SPACE_QUERY_RESULTS_AVAILABLE_FB) { - on_space_query_results((const XrEventDataSpaceQueryResultsAvailableFB*) event); + if (static_cast(event)->type == XR_TYPE_EVENT_DATA_SPACE_QUERY_RESULTS_AVAILABLE_FB) { + on_space_query_results((const XrEventDataSpaceQueryResultsAvailableFB *)event); return true; } - if (static_cast(event)->type == XR_TYPE_EVENT_DATA_SPACE_QUERY_COMPLETE_FB) { - on_space_query_complete((const XrEventDataSpaceQueryCompleteFB*) event); + if (static_cast(event)->type == XR_TYPE_EVENT_DATA_SPACE_QUERY_COMPLETE_FB) { + on_space_query_complete((const XrEventDataSpaceQueryCompleteFB *)event); return true; } return false; } -void OpenXRFbSpatialEntityQueryExtensionWrapper::query_spatial_entities(const XrSpaceQueryInfoBaseHeaderFB* info, SpaceQueryCompleteCallback_t callback) { +void OpenXRFbSpatialEntityQueryExtensionWrapper::query_spatial_entities(const XrSpaceQueryInfoBaseHeaderFB *info, SpaceQueryCompleteCallback_t callback) { XrAsyncRequestIdFB requestId; const XrResult result = xrQuerySpacesFB(SESSION, info, &requestId); if (!XR_SUCCEEDED(result)) { @@ -120,7 +120,7 @@ void OpenXRFbSpatialEntityQueryExtensionWrapper::query_spatial_entities(const Xr query_complete_callbacks[requestId] = callback; } -void OpenXRFbSpatialEntityQueryExtensionWrapper::on_space_query_results(const XrEventDataSpaceQueryResultsAvailableFB* event) { +void OpenXRFbSpatialEntityQueryExtensionWrapper::on_space_query_results(const XrEventDataSpaceQueryResultsAvailableFB *event) { // Query the results that are now available using two-call idiom XrSpaceQueryResultsFB queryResults{ XR_TYPE_SPACE_QUERY_RESULTS_FB, // type @@ -153,7 +153,7 @@ void OpenXRFbSpatialEntityQueryExtensionWrapper::on_space_query_results(const Xr query_results[event->requestId].append_array(results); } -void OpenXRFbSpatialEntityQueryExtensionWrapper::on_space_query_complete(const XrEventDataSpaceQueryCompleteFB* event) { +void OpenXRFbSpatialEntityQueryExtensionWrapper::on_space_query_complete(const XrEventDataSpaceQueryCompleteFB *event) { if (query_complete_callbacks.has(event->requestId)) { WARN_PRINT("Received unexpected XR_TYPE_EVENT_DATA_SPACE_QUERY_RESULTS_AVAILABLE_FB"); return; diff --git a/common/src/main/cpp/include/export/export_plugin.h b/common/src/main/cpp/include/export/export_plugin.h index 51a54168..4cff440d 100644 --- a/common/src/main/cpp/include/export/export_plugin.h +++ b/common/src/main/cpp/include/export/export_plugin.h @@ -29,9 +29,9 @@ #pragma once -#include #include #include +#include #include #include @@ -46,10 +46,10 @@ static const char *LYNX_VENDOR_NAME = "lynx"; static const char *KHRONOS_VENDOR_NAME = "khronos"; static const char *VENDORS_LIST[] = { - META_VENDOR_NAME, - PICO_VENDOR_NAME, - LYNX_VENDOR_NAME, - KHRONOS_VENDOR_NAME, + META_VENDOR_NAME, + PICO_VENDOR_NAME, + LYNX_VENDOR_NAME, + KHRONOS_VENDOR_NAME, }; // Set of custom feature tags supported by the plugin @@ -59,7 +59,7 @@ static const int REGULAR_MODE_VALUE = 0; static const int OPENXR_MODE_VALUE = 1; /// Base class for the vendor editor export plugin -class OpenXREditorExportPlugin: public EditorExportPlugin { +class OpenXREditorExportPlugin : public EditorExportPlugin { GDCLASS(OpenXREditorExportPlugin, EditorExportPlugin) public: @@ -87,12 +87,12 @@ class OpenXREditorExportPlugin: public EditorExportPlugin { static void _bind_methods(); static Dictionary _generate_export_option(const String &name, const String &class_name, - Variant::Type type, - PropertyHint property_hint, - const String &hint_string, - PropertyUsageFlags property_usage, - const Variant &default_value, - bool update_visibility); + Variant::Type type, + PropertyHint property_hint, + const String &hint_string, + PropertyUsageFlags property_usage, + const Variant &default_value, + bool update_visibility); Dictionary _get_vendor_toggle_option() const { return _get_vendor_toggle_option(_vendor); @@ -133,7 +133,6 @@ class OpenXREditorExportPlugin: public EditorExportPlugin { String _get_vendor_toggle_option_name(const String &vendor_name) const; - String _vendor; const String _plugin_version; }; diff --git a/common/src/main/cpp/include/export/meta_export_plugin.h b/common/src/main/cpp/include/export/meta_export_plugin.h index b0c675ea..9bc06bc7 100644 --- a/common/src/main/cpp/include/export/meta_export_plugin.h +++ b/common/src/main/cpp/include/export/meta_export_plugin.h @@ -36,7 +36,6 @@ using namespace godot; namespace { - static const int EYE_TRACKING_NONE_VALUE = 0; static const int EYE_TRACKING_OPTIONAL_VALUE = 1; static const int EYE_TRACKING_REQUIRED_VALUE = 2; @@ -59,7 +58,6 @@ static const int HAND_TRACKING_FREQUENCY_HIGH_VALUE = 1; static const int BOUNDARY_ENABLED_VALUE = 0; static const int BOUNDARY_DISABLED_VALUE = 1; static const int BOUNDARY_CONTEXTUAL_VALUE = 2; - } // namespace class MetaEditorExportPlugin : public OpenXREditorExportPlugin { diff --git a/common/src/main/cpp/include/extensions/openxr_fb_scene_capture_extension_wrapper.h b/common/src/main/cpp/include/extensions/openxr_fb_scene_capture_extension_wrapper.h index a7c1f34c..af4f0d1b 100644 --- a/common/src/main/cpp/include/extensions/openxr_fb_scene_capture_extension_wrapper.h +++ b/common/src/main/cpp/include/extensions/openxr_fb_scene_capture_extension_wrapper.h @@ -33,8 +33,8 @@ #ifndef OPENXR_FB_SCENE_CAPTURE_EXTENSION_WRAPPER_H #define OPENXR_FB_SCENE_CAPTURE_EXTENSION_WRAPPER_H -#include #include +#include #include #include "util.h" diff --git a/common/src/main/cpp/include/extensions/openxr_fb_scene_extension_wrapper.h b/common/src/main/cpp/include/extensions/openxr_fb_scene_extension_wrapper.h index 48372860..0462b9b4 100644 --- a/common/src/main/cpp/include/extensions/openxr_fb_scene_extension_wrapper.h +++ b/common/src/main/cpp/include/extensions/openxr_fb_scene_extension_wrapper.h @@ -29,16 +29,16 @@ #pragma once -#include #include +#include #include #include #include #include "util.h" -#include #include +#include using namespace godot; @@ -76,8 +76,8 @@ class OpenXRFbSceneExtensionWrapper : public OpenXRExtensionWrapperExtension { OpenXRFbSceneExtensionWrapper(); ~OpenXRFbSceneExtensionWrapper(); - std::optional get_semantic_labels(const XrSpace& space); - void get_shapes(const XrSpace& space, XrSceneObjectInternal& object); + std::optional get_semantic_labels(const XrSpace &space); + void get_shapes(const XrSpace &space, XrSceneObjectInternal &object); protected: static void _bind_methods(); diff --git a/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_container_extension_wrapper.h b/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_container_extension_wrapper.h index da1f5678..bdccbe47 100644 --- a/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_container_extension_wrapper.h +++ b/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_container_extension_wrapper.h @@ -29,8 +29,8 @@ #pragma once -#include #include +#include #include #include #include @@ -59,7 +59,7 @@ class OpenXRFbSpatialEntityContainerExtensionWrapper : public OpenXRExtensionWra static OpenXRFbSpatialEntityContainerExtensionWrapper *get_singleton(); - Vector get_contained_uuids(const XrSpace& space); + Vector get_contained_uuids(const XrSpace &space); OpenXRFbSpatialEntityContainerExtensionWrapper(); ~OpenXRFbSpatialEntityContainerExtensionWrapper(); @@ -73,7 +73,7 @@ class OpenXRFbSpatialEntityContainerExtensionWrapper : public OpenXRExtensionWra (XrSpace), space, (XrSpaceContainerFB *), spaceContainerOutput) - bool initialize_fb_spatial_entity_container_extension(const XrInstance& instance); + bool initialize_fb_spatial_entity_container_extension(const XrInstance &instance); HashMap request_extensions; diff --git a/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_extension_wrapper.h b/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_extension_wrapper.h index fd6791e9..b7f1796a 100644 --- a/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_extension_wrapper.h +++ b/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_extension_wrapper.h @@ -29,8 +29,8 @@ #pragma once -#include #include +#include #include #include @@ -42,7 +42,7 @@ using namespace godot; -typedef std::function SetSpaceComponentStatusCallback_t; +typedef std::function SetSpaceComponentStatusCallback_t; // Wrapper for the set of Facebook XR spatial entity extension. class OpenXRFbSpatialEntityExtensionWrapper : public OpenXRExtensionWrapperExtension { @@ -59,8 +59,8 @@ class OpenXRFbSpatialEntityExtensionWrapper : public OpenXRExtensionWrapperExten return fb_spatial_entity_ext; } - bool is_component_supported(const XrSpace& space, XrSpaceComponentTypeFB type); - bool is_component_enabled(const XrSpace& space, XrSpaceComponentTypeFB type); + bool is_component_supported(const XrSpace &space, XrSpaceComponentTypeFB type); + bool is_component_enabled(const XrSpace &space, XrSpaceComponentTypeFB type); // Attempts to set the enabled status for the given component of an XrSpace. The callback will // run to deliver results, with an arg of either: @@ -69,10 +69,10 @@ class OpenXRFbSpatialEntityExtensionWrapper : public OpenXRExtensionWrapperExten // Both cases should be handled, and the second may still indicate an error depending on the // contained XrResult. void set_component_enabled( - const XrSpace& space, - XrSpaceComponentTypeFB type, - bool status, - std::optional callback = std::nullopt); + const XrSpace &space, + XrSpaceComponentTypeFB type, + bool status, + std::optional callback = std::nullopt); virtual bool _on_event_polled(const void *event) override; @@ -110,7 +110,7 @@ class OpenXRFbSpatialEntityExtensionWrapper : public OpenXRExtensionWrapperExten (XrSpaceComponentTypeFB), componentType, (XrSpaceComponentStatusFB *), status) - bool initialize_fb_spatial_entity_extension(const XrInstance& instance); + bool initialize_fb_spatial_entity_extension(const XrInstance &instance); HashMap request_extensions; HashMap set_status_callbacks; diff --git a/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_query_extension_wrapper.h b/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_query_extension_wrapper.h index 8cfe7250..b3de5108 100644 --- a/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_query_extension_wrapper.h +++ b/common/src/main/cpp/include/extensions/openxr_fb_spatial_entity_query_extension_wrapper.h @@ -29,8 +29,8 @@ #pragma once -#include #include +#include #include #include #include @@ -65,7 +65,7 @@ class OpenXRFbSpatialEntityQueryExtensionWrapper : public OpenXRExtensionWrapper // Attempts to query spatial entities given an XrSpaceQueryInfoFB. The callback will run to // deliver results when they are available. - void query_spatial_entities(const XrSpaceQueryInfoBaseHeaderFB* info, SpaceQueryCompleteCallback_t callback); + void query_spatial_entities(const XrSpaceQueryInfoBaseHeaderFB *info, SpaceQueryCompleteCallback_t callback); OpenXRFbSpatialEntityQueryExtensionWrapper(); ~OpenXRFbSpatialEntityQueryExtensionWrapper(); @@ -84,9 +84,9 @@ class OpenXRFbSpatialEntityQueryExtensionWrapper : public OpenXRExtensionWrapper (XrAsyncRequestIdFB), requestId, (XrSpaceQueryResultsFB *), results) - bool initialize_fb_spatial_entity_query_extension(const XrInstance& instance); - void on_space_query_results(const XrEventDataSpaceQueryResultsAvailableFB* event); - void on_space_query_complete(const XrEventDataSpaceQueryCompleteFB* event); + bool initialize_fb_spatial_entity_query_extension(const XrInstance &instance); + void on_space_query_results(const XrEventDataSpaceQueryResultsAvailableFB *event); + void on_space_query_complete(const XrEventDataSpaceQueryCompleteFB *event); HashMap> query_results; HashMap request_extensions; diff --git a/common/src/main/cpp/include/util.h b/common/src/main/cpp/include/util.h index baac4799..7b880993 100644 --- a/common/src/main/cpp/include/util.h +++ b/common/src/main/cpp/include/util.h @@ -118,6 +118,6 @@ return (*func_name##_ptr)(p_##arg1, p_##arg2, p_##arg3, p_##arg4, p_##arg5, p_##arg6); \ } -#define SESSION (XrSession) get_openxr_api()->get_session() +#define SESSION (XrSession) get_openxr_api()->get_session() #endif // UTIL_H diff --git a/common/src/main/cpp/register_types.cpp b/common/src/main/cpp/register_types.cpp index eed240cb..040300b8 100644 --- a/common/src/main/cpp/register_types.cpp +++ b/common/src/main/cpp/register_types.cpp @@ -44,17 +44,16 @@ #include "export/pico_export_plugin.h" #include "extensions/openxr_fb_face_tracking_extension_wrapper.h" -#include "extensions/openxr_fb_scene_extension_wrapper.h" #include "extensions/openxr_fb_scene_capture_extension_wrapper.h" -#include "extensions/openxr_fb_spatial_entity_extension_wrapper.h" +#include "extensions/openxr_fb_scene_extension_wrapper.h" #include "extensions/openxr_fb_spatial_entity_container_extension_wrapper.h" +#include "extensions/openxr_fb_spatial_entity_extension_wrapper.h" #include "extensions/openxr_fb_spatial_entity_query_extension_wrapper.h" using namespace godot; -void initialize_plugin_module(ModuleInitializationLevel p_level) -{ - switch(p_level) { +void initialize_plugin_module(ModuleInitializationLevel p_level) { + switch (p_level) { case MODULE_INITIALIZATION_LEVEL_CORE: { ClassDB::register_class(); OpenXRFbSceneCaptureExtensionWrapper::get_singleton()->register_extension_wrapper(); @@ -108,24 +107,19 @@ void initialize_plugin_module(ModuleInitializationLevel p_level) case MODULE_INITIALIZATION_LEVEL_MAX: break; } - - } -void terminate_plugin_module(ModuleInitializationLevel p_level) -{ +void terminate_plugin_module(ModuleInitializationLevel p_level) { } -extern "C" -{ - GDExtensionBool GDE_EXPORT plugin_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) - { - godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); +extern "C" { +GDExtensionBool GDE_EXPORT plugin_library_init(GDExtensionInterfaceGetProcAddress p_get_proc_address, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) { + godot::GDExtensionBinding::InitObject init_obj(p_get_proc_address, p_library, r_initialization); - init_obj.register_initializer(initialize_plugin_module); - init_obj.register_terminator(terminate_plugin_module); - init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); + init_obj.register_initializer(initialize_plugin_module); + init_obj.register_terminator(terminate_plugin_module); + init_obj.set_minimum_library_initialization_level(MODULE_INITIALIZATION_LEVEL_SCENE); - return init_obj.init(); - } + return init_obj.init(); +} } diff --git a/demo/assets/face/Thank You.txt b/demo/assets/face/Thank You.txt index a65488f0..3fcfc3bb 100644 --- a/demo/assets/face/Thank You.txt +++ b/demo/assets/face/Thank You.txt @@ -4,4 +4,4 @@ So go wild with whatever your heart desires!!! I hope he will be an amazing companion in your journey! --Kana Fuyuko \ No newline at end of file +-Kana Fuyuko diff --git a/godotopenxrlynx/NOTICE.txt b/godotopenxrlynx/NOTICE.txt index 328fad8c..e6bd78c5 100755 --- a/godotopenxrlynx/NOTICE.txt +++ b/godotopenxrlynx/NOTICE.txt @@ -1,309 +1,309 @@ -===================================================================================== - -This file contains certain notices of software components included with the software that Qualcomm Technologies, Inc. ("QTI") and/or its subsidiaries are required to provide you. Except where prohibited by the open source license, the content of this file is provided solely to satisfy QTI's and/or its subsidiaries’ attribution and notice requirements, and your use of these software components together with the software of QTI and/or its subsidiaries ("Software") is subject to the terms of your license from QTI and/or its subsidiaries, as the case may be. Compliance with all copyright laws and software license agreements included in the notice section of this file are the responsibility of the user. Except as may be granted by separate express written agreement, this file provides no license to any patents, trademarks, copyrights, or other intellectual property of Qualcomm Incorporated or any of its subsidiaries. - -Software provided with this notice is NOT A CONTRIBUTION to any open source project. If alternative licensing is available for any of the components with licenses or attributions provided below, a license choice is made for receiving such code by QTI and/or its subsidiaries, as the case may be. - -Copyright (c) 2021-2022 of Qualcomm Technologies, Inc. All rights reserved. - -Qualcomm is a trademark of Qualcomm Incorporated, registered in the United States and other countries. All Qualcomm Incorporated trademarks are used with permission. Other products and brand names may be trademarks or registered trademarks of their respective owners. - -This software may be subject to U.S. and international export, re-export or transfer (export) laws. Diversion contrary to U.S. and international law is strictly prohibited. - -===================================================================================== -"Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors -Distributed under MIT license, or public domain if desired and -recognized in your jurisdiction. -See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE" -"Copyright 2007-2011 Baptiste Lepilleur and The JsonCpp Authors -Copyright (C) 2016 InfoTeCS JSC. All rights reserved. -Distributed under MIT license, or public domain if desired and -recognized in your jurisdiction. -See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE" -"Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors -Distributed under MIT license, or public domain if desired and -recognized in your jurisdiction. -See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE" -license : 'Public Domain', -"Copyright (c) 2017 The Khronos Group Inc. - -Licensed under the Apache License, Version 2.0 (the ""License""); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an ""AS IS"" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License." -"Copyright (c) 2017-2021, The Khronos Group Inc. - -SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the ""License""); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an ""AS IS"" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License." -"Copyright (c) 2020 The Khronos Group Inc. -SPDX-License-Identifier: Apache-2.0" -"Copyright 2000-2020 Kitware, Inc. and Contributors -All rights reserved. - -SPDX-License-Identifier: BSD-3-Clause - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - -Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - -Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - -Neither the name of Kitware, Inc. nor the names of Contributors -may be used to endorse or promote products derived from this -software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -"Copyright (c) 2018-2019 Valve Corporation -Copyright (c) 2018-2019 LunarG, Inc. - -SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the ""License""); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an ""AS IS"" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License." -"Copyright 2020 Collabora, Ltd. -SPDX-License-Identifier: BSL-1.0 -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE_1_0.txt or copy at -http://www.boost.org/LICENSE_1_0.txt)" -"Copyright (c) 2017 The Khronos Group Inc. - -SPDX-License-Identifier: Apache-2.0" -"Copyright Philippe Crassous 2011. -Copyright Sensics, Inc. 2016. - -SPDX-License-Identifier: BSL-1.0 - -Distributed under the Boost Software License, Version 1.0. -(See accompanying file LICENSE_1_0.txt or copy at -http://www.boost.org/LICENSE_1_0.txt)" -"SPDX-FileCopyrightText: Copyright 2007-2014, 2017 the original author or authors. -SPDX-License-Identifier: Apache-2.0" -"Copyright (c) 2018-2021, The Khronos Group Inc. - -SPDX-License-Identifier: Apache-2.0 OR MIT" -"@rem Copyright 2015 the original author or authors. -@rem -@rem SPDX-License-Identifier: Apache-2.0 -@rem -@rem Licensed under the Apache License, Version 2.0 (the ""License""); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an ""AS IS"" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem" -"SPDX-FileCopyrightText: Copyright 2010 the original author or authors. -SPDX-License-Identifier: Apache-2.0" -"Copyright 2020-2021, Collabora, Ltd. -SPDX-License-Identifier: BSL-1.0 -Author: Ryan Pavlik " -"Copyright 2020, Collabora, Ltd. -SPDX-License-Identifier: BSL-1.0 -Author: Ryan Pavlik " -"Copyright (c) 2017 The Khronos Group Inc. -Copyright (c) 2017 Valve Corporation -Copyright (c) 2017 LunarG, Inc. - -Licensed under the Apache License, Version 2.0 (the ""License""); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an ""AS IS"" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License." -"Copyright (c) 2017 The Khronos Group Inc. -Copyright (c) 2017 Valve Corporation -Copyright (c) 2017 LunarG, Inc. - -SPDX-License-Identifier: Apache-2.0 OR MIT" -"Copyright (c) 2020-2021 The Khronos Group Inc. - -SPDX-License-Identifier: Apache-2.0" -"Copyright 2020-2021, Collabora, Ltd. -SPDX-License-Identifier: BSL-1.0 -Author: Ryan Pavlik -Inline implementations: do not include on its own!" -"Copyright 2010 Baptiste Lepilleur and The JsonCpp Authors -Distributed under MIT license, or public domain if desired and -recognized in your jurisdiction. -See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE" -"Copyright (c) 2017-2021, The Khronos Group Inc. -Copyright (c) 2017-2019 Valve Corporation -Copyright (c) 2017-2019 LunarG, Inc. -Copyright (c) 2019 Collabora, Ltd. - -SPDX-License-Identifier: Apache-2.0 OR MIT" -"Copyright (c) 2017-2021, The Khronos Group Inc. -Copyright (c) 2017 Valve Corporation -Copyright (c) 2017 LunarG, Inc. - -SPDX-License-Identifier: Apache-2.0 OR MIT" -"Copyright (c) 2020 The Khronos Group Inc. -SPDX-License-Identifier: Apache-2.0 ->" -"Copyright (c) 2017-2021, The Khronos Group Inc. -Copyright (c) 2017-2019 Valve Corporation -Copyright (c) 2017-2019 LunarG, Inc. - -SPDX-License-Identifier: Apache-2.0 OR MIT" -"Copyright (c) 2020-2021, The Khronos Group Inc. -Copyright (c) 2020-2021, Collabora, Ltd. - -SPDX-License-Identifier: Apache-2.0 OR MIT" -"Copyright 2015 the original author or authors. - -SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the ""License""); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -https://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an ""AS IS"" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License." -"Copyright (c) 2017-2021, The Khronos Group Inc. - -SPDX-License-Identifier: Apache-2.0" -"Copyright (c) 2017-2021, The Khronos Group Inc. - -SPDX-License-Identifier: Apache-2.0 OR MIT" -"Copyright (c) 2020-2021 The Khronos Group Inc. -SPDX-License-Identifier: Apache-2.0" -"Copyright (c) 2017 The Khronos Group Inc. -Copyright (c) 2016 Oculus VR, LLC. - -SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the ""License""); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an ""AS IS"" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License." -"Copyright (c) 2017 The Khronos Group Inc. - -SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the ""License""); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an ""AS IS"" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License." -"Copyright (c) 2019-2021, The Khronos Group Inc. - -SPDX-License-Identifier: Apache-2.0 OR MIT" -"[Copyright (c) 2017-2021, The Khronos Group Inc. -Copyright (c) 2017-2019 Valve Corporation -Copyright (c) 2017-2019 LunarG, Inc. -SPDX-License-Identifier: Apache-2.0 OR MIT -******* THIS FILE IS GENERATED - DO NOT EDIT ********* -See loader_source_generator.py for modifications]" -"Copyright (c) 2017-2021, The Khronos Group Inc. -Copyright (c) 2017-2019 Valve Corporation -Copyright (c) 2017-2019 LunarG, Inc. - -SPDX-License-Identifier: Apache-2.0 - -Licensed under the Apache License, Version 2.0 (the ""License""); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - -http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an ""AS IS"" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License." -url = "http://www.apache.org/licenses/LICENSE-2.0.txt" -"[Copyright (c) 2017-2021, The Khronos Group Inc. -Copyright (c) 2017-2019 Valve Corporation -Copyright (c) 2017-2019 LunarG, Inc. -SPDX-License-Identifier: Apache-2.0 OR MIT -==================================================================================================== -Copyright (c) 2016 Mitchell Dowd - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -==================================================================================================== +===================================================================================== + +This file contains certain notices of software components included with the software that Qualcomm Technologies, Inc. ("QTI") and/or its subsidiaries are required to provide you. Except where prohibited by the open source license, the content of this file is provided solely to satisfy QTI's and/or its subsidiaries� attribution and notice requirements, and your use of these software components together with the software of QTI and/or its subsidiaries ("Software") is subject to the terms of your license from QTI and/or its subsidiaries, as the case may be. Compliance with all copyright laws and software license agreements included in the notice section of this file are the responsibility of the user. Except as may be granted by separate express written agreement, this file provides no license to any patents, trademarks, copyrights, or other intellectual property of Qualcomm Incorporated or any of its subsidiaries. + +Software provided with this notice is NOT A CONTRIBUTION to any open source project. If alternative licensing is available for any of the components with licenses or attributions provided below, a license choice is made for receiving such code by QTI and/or its subsidiaries, as the case may be. + +Copyright (c) 2021-2022 of Qualcomm Technologies, Inc. All rights reserved. + +Qualcomm is a trademark of Qualcomm Incorporated, registered in the United States and other countries. All Qualcomm Incorporated trademarks are used with permission. Other products and brand names may be trademarks or registered trademarks of their respective owners. + +This software may be subject to U.S. and international export, re-export or transfer (export) laws. Diversion contrary to U.S. and international law is strictly prohibited. + +===================================================================================== +"Copyright 2007-2010 Baptiste Lepilleur and The JsonCpp Authors +Distributed under MIT license, or public domain if desired and +recognized in your jurisdiction. +See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE" +"Copyright 2007-2011 Baptiste Lepilleur and The JsonCpp Authors +Copyright (C) 2016 InfoTeCS JSC. All rights reserved. +Distributed under MIT license, or public domain if desired and +recognized in your jurisdiction. +See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE" +"Copyright 2011 Baptiste Lepilleur and The JsonCpp Authors +Distributed under MIT license, or public domain if desired and +recognized in your jurisdiction. +See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE" +license : 'Public Domain', +"Copyright (c) 2017 The Khronos Group Inc. + +Licensed under the Apache License, Version 2.0 (the ""License""); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an ""AS IS"" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License." +"Copyright (c) 2017-2021, The Khronos Group Inc. + +SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, Version 2.0 (the ""License""); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an ""AS IS"" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License." +"Copyright (c) 2020 The Khronos Group Inc. +SPDX-License-Identifier: Apache-2.0" +"Copyright 2000-2020 Kitware, Inc. and Contributors +All rights reserved. + +SPDX-License-Identifier: BSD-3-Clause + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + +Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +Neither the name of Kitware, Inc. nor the names of Contributors +may be used to endorse or promote products derived from this +software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +""AS IS"" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." +"Copyright (c) 2018-2019 Valve Corporation +Copyright (c) 2018-2019 LunarG, Inc. + +SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, Version 2.0 (the ""License""); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an ""AS IS"" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License." +"Copyright 2020 Collabora, Ltd. +SPDX-License-Identifier: BSL-1.0 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt)" +"Copyright (c) 2017 The Khronos Group Inc. + +SPDX-License-Identifier: Apache-2.0" +"Copyright Philippe Crassous 2011. +Copyright Sensics, Inc. 2016. + +SPDX-License-Identifier: BSL-1.0 + +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt)" +"SPDX-FileCopyrightText: Copyright 2007-2014, 2017 the original author or authors. +SPDX-License-Identifier: Apache-2.0" +"Copyright (c) 2018-2021, The Khronos Group Inc. + +SPDX-License-Identifier: Apache-2.0 OR MIT" +"@rem Copyright 2015 the original author or authors. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem +@rem Licensed under the Apache License, Version 2.0 (the ""License""); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an ""AS IS"" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem" +"SPDX-FileCopyrightText: Copyright 2010 the original author or authors. +SPDX-License-Identifier: Apache-2.0" +"Copyright 2020-2021, Collabora, Ltd. +SPDX-License-Identifier: BSL-1.0 +Author: Ryan Pavlik " +"Copyright 2020, Collabora, Ltd. +SPDX-License-Identifier: BSL-1.0 +Author: Ryan Pavlik " +"Copyright (c) 2017 The Khronos Group Inc. +Copyright (c) 2017 Valve Corporation +Copyright (c) 2017 LunarG, Inc. + +Licensed under the Apache License, Version 2.0 (the ""License""); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an ""AS IS"" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License." +"Copyright (c) 2017 The Khronos Group Inc. +Copyright (c) 2017 Valve Corporation +Copyright (c) 2017 LunarG, Inc. + +SPDX-License-Identifier: Apache-2.0 OR MIT" +"Copyright (c) 2020-2021 The Khronos Group Inc. + +SPDX-License-Identifier: Apache-2.0" +"Copyright 2020-2021, Collabora, Ltd. +SPDX-License-Identifier: BSL-1.0 +Author: Ryan Pavlik +Inline implementations: do not include on its own!" +"Copyright 2010 Baptiste Lepilleur and The JsonCpp Authors +Distributed under MIT license, or public domain if desired and +recognized in your jurisdiction. +See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE" +"Copyright (c) 2017-2021, The Khronos Group Inc. +Copyright (c) 2017-2019 Valve Corporation +Copyright (c) 2017-2019 LunarG, Inc. +Copyright (c) 2019 Collabora, Ltd. + +SPDX-License-Identifier: Apache-2.0 OR MIT" +"Copyright (c) 2017-2021, The Khronos Group Inc. +Copyright (c) 2017 Valve Corporation +Copyright (c) 2017 LunarG, Inc. + +SPDX-License-Identifier: Apache-2.0 OR MIT" +"Copyright (c) 2020 The Khronos Group Inc. +SPDX-License-Identifier: Apache-2.0 +>" +"Copyright (c) 2017-2021, The Khronos Group Inc. +Copyright (c) 2017-2019 Valve Corporation +Copyright (c) 2017-2019 LunarG, Inc. + +SPDX-License-Identifier: Apache-2.0 OR MIT" +"Copyright (c) 2020-2021, The Khronos Group Inc. +Copyright (c) 2020-2021, Collabora, Ltd. + +SPDX-License-Identifier: Apache-2.0 OR MIT" +"Copyright 2015 the original author or authors. + +SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, Version 2.0 (the ""License""); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an ""AS IS"" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License." +"Copyright (c) 2017-2021, The Khronos Group Inc. + +SPDX-License-Identifier: Apache-2.0" +"Copyright (c) 2017-2021, The Khronos Group Inc. + +SPDX-License-Identifier: Apache-2.0 OR MIT" +"Copyright (c) 2020-2021 The Khronos Group Inc. +SPDX-License-Identifier: Apache-2.0" +"Copyright (c) 2017 The Khronos Group Inc. +Copyright (c) 2016 Oculus VR, LLC. + +SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, Version 2.0 (the ""License""); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an ""AS IS"" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License." +"Copyright (c) 2017 The Khronos Group Inc. + +SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, Version 2.0 (the ""License""); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an ""AS IS"" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License." +"Copyright (c) 2019-2021, The Khronos Group Inc. + +SPDX-License-Identifier: Apache-2.0 OR MIT" +"[Copyright (c) 2017-2021, The Khronos Group Inc. +Copyright (c) 2017-2019 Valve Corporation +Copyright (c) 2017-2019 LunarG, Inc. +SPDX-License-Identifier: Apache-2.0 OR MIT +******* THIS FILE IS GENERATED - DO NOT EDIT ********* +See loader_source_generator.py for modifications]" +"Copyright (c) 2017-2021, The Khronos Group Inc. +Copyright (c) 2017-2019 Valve Corporation +Copyright (c) 2017-2019 LunarG, Inc. + +SPDX-License-Identifier: Apache-2.0 + +Licensed under the Apache License, Version 2.0 (the ""License""); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an ""AS IS"" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License." +url = "http://www.apache.org/licenses/LICENSE-2.0.txt" +"[Copyright (c) 2017-2021, The Khronos Group Inc. +Copyright (c) 2017-2019 Valve Corporation +Copyright (c) 2017-2019 LunarG, Inc. +SPDX-License-Identifier: Apache-2.0 OR MIT +==================================================================================================== +Copyright (c) 2016 Mitchell Dowd + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +==================================================================================================== diff --git a/godotopenxrlynx/libs/lynx_openxr_sdk/arm64-v8a/abi.json b/godotopenxrlynx/libs/lynx_openxr_sdk/arm64-v8a/abi.json index 8271b598..30b37081 100644 --- a/godotopenxrlynx/libs/lynx_openxr_sdk/arm64-v8a/abi.json +++ b/godotopenxrlynx/libs/lynx_openxr_sdk/arm64-v8a/abi.json @@ -3,4 +3,4 @@ "api": 24, "ndk": 21, "stl": "c++_shared" -} \ No newline at end of file +} diff --git a/godotopenxrlynx/src/main/AndroidManifest.xml b/godotopenxrlynx/src/main/AndroidManifest.xml index 83ade431..b8816382 100644 --- a/godotopenxrlynx/src/main/AndroidManifest.xml +++ b/godotopenxrlynx/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ - + diff --git a/godotopenxrmeta/LICENSE.txt b/godotopenxrmeta/LICENSE.txt index 6516fa3b..c2c569e9 100644 --- a/godotopenxrmeta/LICENSE.txt +++ b/godotopenxrmeta/LICENSE.txt @@ -1,3 +1,3 @@ Copyright © Facebook Technologies, LLC and its affiliates. All rights reserved. -Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at https://developer.oculus.com/licenses/oculussdk/ \ No newline at end of file +Your use of this SDK or tool is subject to the Oculus SDK License Agreement, available at https://developer.oculus.com/licenses/oculussdk/ diff --git a/hooks/README.md b/hooks/README.md new file mode 100644 index 00000000..6ec90fcc --- /dev/null +++ b/hooks/README.md @@ -0,0 +1,18 @@ +# Git hooks for Godot Engine + +This folder contains git hooks meant to be installed locally by Godot Engine +contributors to make sure they comply with our requirements. + +## List of hooks + +- Pre-commit hook for clang-format: Applies clang-format to the staged files + before accepting a commit; blocks the commit and generates a patch if the + style is not respected. + Should work on Linux and macOS. You may need to edit the file if your + clang-format binary is not in the $PATH, or if you want to enable colored + output with pygmentize. + +## Installation + +Copy all the files from this folder into your .git/hooks folder, and make sure +the hooks and helper scripts are executable. diff --git a/hooks/canonicalize_filename.sh b/hooks/canonicalize_filename.sh new file mode 100644 index 00000000..5eecabf5 --- /dev/null +++ b/hooks/canonicalize_filename.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# Provide the canonicalize filename (physical filename with out any symlinks) +# like the GNU version readlink with the -f option regardless of the version of +# readlink (GNU or BSD). + +# This file is part of a set of unofficial pre-commit hooks available +# at github. +# Link: https://github.com/githubbrowser/Pre-commit-hooks +# Contact: David Martin, david.martin.mailbox@googlemail.com + +########################################################### +# There should be no need to change anything below this line. + +# Canonicalize by recursively following every symlink in every component of the +# specified filename. This should reproduce the results of the GNU version of +# readlink with the -f option. +# +# Reference: http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac +canonicalize_filename () { + local target_file="$1" + local physical_directory="" + local result="" + + # Need to restore the working directory after work. + local working_dir="`pwd`" + + cd -- "$(dirname -- "$target_file")" + target_file="$(basename -- "$target_file")" + + # Iterate down a (possible) chain of symlinks + while [ -L "$target_file" ] + do + target_file="$(readlink -- "$target_file")" + cd -- "$(dirname -- "$target_file")" + target_file="$(basename -- "$target_file")" + done + + # Compute the canonicalized name by finding the physical path + # for the directory we're in and appending the target file. + physical_directory="`pwd -P`" + result="$physical_directory/$target_file" + + # restore the working directory after work. + cd -- "$working_dir" + + echo "$result" +} diff --git a/hooks/pre-commit b/hooks/pre-commit new file mode 100644 index 00000000..fc50ed70 --- /dev/null +++ b/hooks/pre-commit @@ -0,0 +1,50 @@ +#!/bin/sh +# Git pre-commit hook that runs multiple hooks specified in $HOOKS. +# Make sure this script is executable. Bypass hooks with git commit --no-verify. + +# This file is part of a set of unofficial pre-commit hooks available +# at github. +# Link: https://github.com/githubbrowser/Pre-commit-hooks +# Contact: David Martin, david.martin.mailbox@googlemail.com + + +########################################################### +# CONFIGURATION: +# pre-commit hooks to be executed. They should be in the same .git/hooks/ folder +# as this script. Hooks should return 0 if successful and nonzero to cancel the +# commit. They are executed in the order in which they are listed. +#HOOKS="pre-commit-compile pre-commit-uncrustify" +HOOKS="pre-commit-clang-format" +########################################################### +# There should be no need to change anything below this line. + +. "$(dirname -- "$0")/canonicalize_filename.sh" + +# exit on error +set -e + +# Absolute path to this script, e.g. /home/user/bin/foo.sh +SCRIPT="$(canonicalize_filename "$0")" + +# Absolute path this script is in, thus /home/user/bin +SCRIPTPATH="$(dirname -- "$SCRIPT")" + + +for hook in $HOOKS +do + echo "Running hook: $hook" + # run hook if it exists + # if it returns with nonzero exit with 1 and thus abort the commit + if [ -f "$SCRIPTPATH/$hook" ]; then + "$SCRIPTPATH/$hook" + if [ $? != 0 ]; then + exit 1 + fi + else + echo "Error: file $hook not found." + echo "Aborting commit. Make sure the hook is in $SCRIPTPATH and executable." + echo "You can disable it by removing it from the list in $SCRIPT." + echo "You can skip all pre-commit hooks with --no-verify (not recommended)." + exit 1 + fi +done diff --git a/hooks/pre-commit-clang-format b/hooks/pre-commit-clang-format new file mode 100644 index 00000000..c5e025e7 --- /dev/null +++ b/hooks/pre-commit-clang-format @@ -0,0 +1,150 @@ +#!/usr/bin/env bash + +# git pre-commit hook that runs a clang-format stylecheck. +# Features: +# - abort commit when commit does not comply with the style guidelines +# - create a patch of the proposed style changes +# Modifications for clang-format by rene.milk@wwu.de + +# This file is part of a set of unofficial pre-commit hooks available +# at github. +# Link: https://github.com/githubbrowser/Pre-commit-hooks +# Contact: David Martin, david.martin.mailbox@googlemail.com + +# Some quality of life modifications made for Godot Engine. + +################################################################## +# SETTINGS +# Set path to clang-format binary +# CLANG_FORMAT="/usr/bin/clang-format" +CLANG_FORMAT=`which clang-format` + +# Remove any older patches from previous commits. Set to true or false. +# DELETE_OLD_PATCHES=false +DELETE_OLD_PATCHES=false + +# Only parse files with the extensions in FILE_EXTS. Set to true or false. +# If false every changed file in the commit will be parsed with clang-format. +# If true only files matching one of the extensions are parsed with clang-format. +# PARSE_EXTS=true +PARSE_EXTS=true + +# File types to parse. Only effective when PARSE_EXTS is true. +# FILE_EXTS=".c .h .cpp .hpp" +FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc .java .glsl" + +# Use pygmentize instead of cat to parse diff with highlighting. +# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac) +# READER="pygmentize -l diff" +READER=cat + +################################################################## +# There should be no need to change anything below this line. + +. "$(dirname -- "$0")/canonicalize_filename.sh" + +# exit on error +set -e + +# check whether the given file matches any of the set extensions +matches_extension() { + local filename=$(basename "$1") + local extension=".${filename##*.}" + local ext + + for ext in $FILE_EXTS; do [[ "$ext" == "$extension" ]] && return 0; done + + return 1 +} + +# necessary check for initial commit +if git rev-parse --verify HEAD >/dev/null 2>&1 ; then + against=HEAD +else + # Initial commit: diff against an empty tree object + against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 +fi + +if [ ! -x "$CLANG_FORMAT" ] ; then + printf "Error: clang-format executable not found.\n" + printf "Set the correct path in $(canonicalize_filename "$0").\n" + exit 1 +fi + +# create a random filename to store our generated patch +prefix="pre-commit-clang-format" +suffix="$(date +%s)" +patch="/tmp/$prefix-$suffix.patch" + +# clean up any older clang-format patches +$DELETE_OLD_PATCHES && rm -f /tmp/$prefix*.patch + +# create one patch containing all changes to the files +git diff-index --cached --diff-filter=ACMR --name-only $against -- | while read file; +do + # ignore thirdparty files + if grep -q "thirdparty" <<< $file; then + continue; + fi + if grep -q "openxr_loader" <<< $file; then + continue; + fi + + # ignore file if we do check for file extensions and the file + # does not match any of the extensions specified in $FILE_EXTS + if $PARSE_EXTS && ! matches_extension "$file"; then + continue; + fi + + # clang-format our sourcefile, create a patch with diff and append it to our $patch + # The sed call is necessary to transform the patch from + # --- $file timestamp + # +++ - timestamp + # to both lines working on the same file and having a/ and b/ prefix. + # Else it can not be applied with 'git apply'. + "$CLANG_FORMAT" -style=file "$file" | \ + diff -u "$file" - | \ + sed -e "1s|--- |--- a/|" -e "2s|+++ -|+++ b/$file|" >> "$patch" +done + +# if no patch has been generated all is ok, clean up the file stub and exit +if [ ! -s "$patch" ] ; then + printf "Files in this commit comply with the clang-format rules.\n" + rm -f "$patch" + exit 0 +fi + +# a patch has been created, notify the user and exit +printf "\nThe following differences were found between the code to commit " +printf "and the clang-format rules:\n\n" +$READER "$patch" +printf "\n" + +# Allows us to read user input below, assigns stdin to keyboard +exec < /dev/tty + +while true; do + read -p "Do you want to apply that patch (Y - Apply, N - Do not apply, S - Apply and stage files)? [Y/N/S] " yn + case $yn in + [Yy] ) git apply $patch; + printf "The patch was applied. You can now stage the changes and commit again.\n\n"; + break + ;; + [Nn] ) printf "\nYou can apply these changes with:\n git apply $patch\n"; + printf "(may need to be called from the root directory of your repository)\n"; + printf "Aborting commit. Apply changes and commit again or skip checking with"; + printf " --no-verify (not recommended).\n\n"; + break + ;; + [Ss] ) git apply $patch; + git diff-index --cached --diff-filter=ACMR --name-only $against -- | while read file; + do git add $file; + done + printf "The patch was applied and the changed files staged. You can now commit.\n\n"; + break + ;; + * ) echo "Please answer yes or no." + ;; + esac +done +exit 1 # we don't commit in any case