Skip to content

Commit

Permalink
Add export option to support scene API and request if in manifest
Browse files Browse the repository at this point in the history
  • Loading branch information
Mauricio Narvaez authored and maunvz committed Jan 18, 2024
1 parent a4920ec commit baa01ff
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
21 changes: 21 additions & 0 deletions godotopenxrmeta/src/main/cpp/export/meta_export_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ MetaEditorExportPlugin::MetaEditorExportPlugin() {
false,
false
);
_use_scene_api_option = _generate_export_option(
"meta_xr_features/use_scene_api",
"",
Variant::Type::BOOL,
PROPERTY_HINT_NONE,
"",
PROPERTY_USAGE_DEFAULT,
false,
false
);
_support_quest_1_option = _generate_export_option(
"meta_xr_features/quest_1_support",
"",
Expand Down Expand Up @@ -160,6 +170,7 @@ TypedArray<Dictionary> MetaEditorExportPlugin::_get_export_options(const Ref<Edi
export_options.append(_hand_tracking_frequency_option);
export_options.append(_passthrough_option);
export_options.append(_use_anchor_api_option);
export_options.append(_use_scene_api_option);
export_options.append(_support_quest_1_option);
export_options.append(_support_quest_2_option);
export_options.append(_support_quest_3_option);
Expand Down Expand Up @@ -238,6 +249,10 @@ String MetaEditorExportPlugin::_get_export_option_warning(const Ref<EditorExport
if (!openxr_enabled && _get_bool_option(option)) {
return "\"Use anchor API\" is only valid when \"XR Mode\" is \"OpenXR\".\n";
}
} else if (option == "meta_xr_features/use_scene_api") {
if (!openxr_enabled && _get_bool_option(option)) {
return "\"Use scene API\" is only valid when \"XR Mode\" is \"OpenXR\".\n";
}
}

return OpenXREditorExportPlugin::_get_export_option_warning(platform, option);
Expand Down Expand Up @@ -287,6 +302,12 @@ String MetaEditorExportPlugin::_get_android_manifest_element_contents(const Ref<
contents += " <uses-permission android:name=\"com.oculus.permission.USE_ANCHOR_API\" />\n";
}

// Check for scene api
bool use_scene_api = _get_bool_option("meta_xr_features/use_scene_api");
if (use_scene_api) {
contents += " <uses-permission android:name=\"com.oculus.permission.USE_SCENE\" />\n";
}

return contents;
}

Expand Down
1 change: 1 addition & 0 deletions godotopenxrmeta/src/main/cpp/export/meta_export_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class MetaEditorExportPlugin : public OpenXREditorExportPlugin {
Dictionary _hand_tracking_frequency_option;
Dictionary _passthrough_option;
Dictionary _use_anchor_api_option;
Dictionary _use_scene_api_option;
Dictionary _support_quest_1_option;
Dictionary _support_quest_2_option;
Dictionary _support_quest_3_option;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ class GodotOpenXRMeta(godot: Godot?) : GodotPlugin(godot) {
private val TAG = GodotOpenXRMeta::class.java.simpleName

private const val EYE_TRACKING_PERMISSION = "com.oculus.permission.EYE_TRACKING"
private const val SCENE_PERMISSION = "com.oculus.permission.USE_SCENE"

init {
try {
Expand All @@ -67,6 +68,10 @@ class GodotOpenXRMeta(godot: Godot?) : GodotPlugin(godot) {
Log.d(TAG, "Requesting permission '${EYE_TRACKING_PERMISSION}'")
PermissionsUtil.requestPermission(EYE_TRACKING_PERMISSION, activity)
}
// Request the scene API permission if it's included in the manifest
if (PermissionsUtil.hasManifestPermission(activity, SCENE_PERMISSION)) {
PermissionsUtil.requestPermission(SCENE_PERMISSION, activity)
}
return null
}

Expand Down

0 comments on commit baa01ff

Please sign in to comment.