Skip to content

Commit 8d8041b

Browse files
committed
Merge pull request #107391 from BastiaanOlij/openxr_spatial_entities_ext
OpenXR: Add support for spatial entities extension
2 parents ef4863a + eeac570 commit 8d8041b

File tree

54 files changed

+7550
-17
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+7550
-17
lines changed

doc/classes/ProjectSettings.xml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3466,6 +3466,44 @@
34663466
If [code]true[/code] we enable the render model extension if available.
34673467
[b]Note:[/b] This relates to the core OpenXR render model extension and has no relation to any vendor render model extensions.
34683468
</member>
3469+
<member name="xr/openxr/extensions/spatial_entity/april_tag_dict" type="int" setter="" getter="" default="&quot;3&quot;">
3470+
The April Tag marker types the built-in marker tracking is set to recognize (if April Tag marker tracking is available and enabled).
3471+
</member>
3472+
<member name="xr/openxr/extensions/spatial_entity/aruco_dict" type="int" setter="" getter="" default="&quot;15&quot;">
3473+
The ArUco marker types the built-in marker tracking is set to recognize (if ArUco marker tracking is available and enabled).
3474+
</member>
3475+
<member name="xr/openxr/extensions/spatial_entity/enable_builtin_anchor_detection" type="bool" setter="" getter="" default="false">
3476+
If [code]true[/code], we enable the built-in logic for handling anchors. Godot will query (persistent) anchors and manage [OpenXRAnchorTracker] instances for you. If disabled you'll need to create your own spatial and persistence context and perform your own discovery queries.
3477+
[b]Note:[/b] This functionality requires that spatial anchors are supported and enabled.
3478+
</member>
3479+
<member name="xr/openxr/extensions/spatial_entity/enable_builtin_marker_tracking" type="bool" setter="" getter="" default="false">
3480+
If [code]true[/code], we enable the built-in logic for handling marker tracking. Godot will query markers and manage [OpenXRMarkerTracker] instances for you. If disabled you'll need to create your own spatial context and perform your own discovery queries.
3481+
[b]Note:[/b] This functionality requires that marker tracking is supported and enabled.
3482+
</member>
3483+
<member name="xr/openxr/extensions/spatial_entity/enable_builtin_plane_detection" type="bool" setter="" getter="" default="false">
3484+
If [code]true[/code], we enable the built-in logic for handling plane detection. Godot will query detected planes (walls, floors, ceilings, etc.) and manage [OpenXRPlaneTracker] instances for you. If disabled you'll need to create your own spatial context and perform your own discovery queries.
3485+
[b]Note:[/b] This functionality requires that plane tracking is supported and enabled.
3486+
</member>
3487+
<member name="xr/openxr/extensions/spatial_entity/enable_marker_tracking" type="bool" setter="" getter="" default="false">
3488+
If [code]true[/code], support for the marker tracking extension is requested. If supported, you will be able to query information about markers detected by the XR runtime, e.g. QR codes, aruca markers and april tags.
3489+
[b]Note:[/b] This requires that the OpenXR spatial entities and marker tracking extensions are supported by the XR runtime. If not supported this setting will be ignored. [member xr/openxr/extensions/spatial_entity/enabled] must be enabled for this setting to be used.
3490+
</member>
3491+
<member name="xr/openxr/extensions/spatial_entity/enable_persistent_anchors" type="bool" setter="" getter="" default="false">
3492+
If [code]true[/code], support for the persistent anchors extension is requested. If supported, you will be able to store spatial anchors and they will be restored on application startup.
3493+
[b]Note:[/b] This requires that the OpenXR spatial entities, spatial anchors, and spatial persistence extensions are supported by the XR runtime. If not supported this setting will be ignored. [member xr/openxr/extensions/spatial_entity/enabled] and [member xr/openxr/extensions/spatial_entity/enable_spatial_anchors] must be enabled for this setting to be used.
3494+
</member>
3495+
<member name="xr/openxr/extensions/spatial_entity/enable_plane_tracking" type="bool" setter="" getter="" default="false">
3496+
If [code]true[/code], support for the plane tracking extension is requested. If supported, you will be able to query information about planes detected by the XR runtime, e.g. walls, floors, etc.
3497+
[b]Note:[/b] This requires that the OpenXR spatial entities and plane tracking extensions are supported by the XR runtime. If not supported this setting will be ignored. [member xr/openxr/extensions/spatial_entity/enabled] must be enabled for this setting to be used.
3498+
</member>
3499+
<member name="xr/openxr/extensions/spatial_entity/enable_spatial_anchors" type="bool" setter="" getter="" default="false">
3500+
If [code]true[/code], support for the spatial anchors extension is requested. If supported, you will be able to register anchor locations in the real world that the XR runtime will adjust as needed and/or potentially share with other headsets.
3501+
[b]Note:[/b] This requires that the OpenXR spatial entities and spatial anchors extensions are supported by the XR runtime. If not supported this setting will be ignored. [member xr/openxr/extensions/spatial_entity/enabled] must be enabled for this setting to be used.
3502+
</member>
3503+
<member name="xr/openxr/extensions/spatial_entity/enabled" type="bool" setter="" getter="" default="false">
3504+
If [code]true[/code], support for the spatial entity extension is requested. If supported, you will be able to access spatial information about the real environment around you. What information is available is dependent on additional extensions.
3505+
[b]Note:[/b] This requires that the OpenXR spatial entities extension is supported by the XR runtime. If not supported this setting will be ignored.
3506+
</member>
34693507
<member name="xr/openxr/form_factor" type="int" setter="" getter="" default="&quot;0&quot;">
34703508
Specify whether OpenXR should be configured for an HMD or a hand held device.
34713509
</member>

main/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,6 +2805,16 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph
28052805
GLOBAL_DEF_BASIC("xr/openxr/extensions/hand_tracking_unobstructed_data_source", false); // XR_HAND_TRACKING_DATA_SOURCE_UNOBSTRUCTED_EXT
28062806
GLOBAL_DEF_BASIC("xr/openxr/extensions/hand_tracking_controller_data_source", false); // XR_HAND_TRACKING_DATA_SOURCE_CONTROLLER_EXT
28072807
GLOBAL_DEF_RST_BASIC("xr/openxr/extensions/hand_interaction_profile", false);
2808+
GLOBAL_DEF_BASIC("xr/openxr/extensions/spatial_entity/enabled", false);
2809+
GLOBAL_DEF_BASIC("xr/openxr/extensions/spatial_entity/enable_spatial_anchors", false);
2810+
GLOBAL_DEF_BASIC("xr/openxr/extensions/spatial_entity/enable_persistent_anchors", false);
2811+
GLOBAL_DEF_BASIC("xr/openxr/extensions/spatial_entity/enable_builtin_anchor_detection", false);
2812+
GLOBAL_DEF_BASIC("xr/openxr/extensions/spatial_entity/enable_plane_tracking", false);
2813+
GLOBAL_DEF_BASIC("xr/openxr/extensions/spatial_entity/enable_builtin_plane_detection", false);
2814+
GLOBAL_DEF_BASIC("xr/openxr/extensions/spatial_entity/enable_marker_tracking", false);
2815+
GLOBAL_DEF_BASIC("xr/openxr/extensions/spatial_entity/enable_builtin_marker_tracking", false);
2816+
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/extensions/spatial_entity/aruco_dict", PROPERTY_HINT_ENUM, "4x4 50 IDs,4x4 100 IDs,4x4 250 IDs,4x4 1000 IDs,5x5 50 IDs,5x5 100 IDs,5x5 250 IDs,5x5 1000 IDs,6x6 50 IDs,6x6 100 IDs,6x6 250 IDs,6x6 1000 IDs,7x7 50 IDs,7x7 100 IDs,7x7 250 IDs,7x7 1000 IDs"), "15");
2817+
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "xr/openxr/extensions/spatial_entity/april_tag_dict", PROPERTY_HINT_ENUM, "4x4H5,5x5H9,6x6H10,6x6H11"), "3");
28082818
GLOBAL_DEF_RST_BASIC("xr/openxr/extensions/eye_gaze_interaction", false);
28092819
GLOBAL_DEF_BASIC("xr/openxr/extensions/render_model", false);
28102820

modules/openxr/config.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,36 @@ def get_doc_classes():
4343
"OpenXRRenderModelExtension",
4444
"OpenXRRenderModel",
4545
"OpenXRRenderModelManager",
46+
"OpenXRStructureBase",
47+
"OpenXRSpatialEntityExtension",
48+
"OpenXRSpatialEntityTracker",
49+
"OpenXRAnchorTracker",
50+
"OpenXRPlaneTracker",
51+
"OpenXRMarkerTracker",
52+
"OpenXRSpatialCapabilityConfigurationBaseHeader",
53+
"OpenXRSpatialCapabilityConfigurationAnchor",
54+
"OpenXRSpatialCapabilityConfigurationQrCode",
55+
"OpenXRSpatialCapabilityConfigurationMicroQrCode",
56+
"OpenXRSpatialCapabilityConfigurationAruco",
57+
"OpenXRSpatialCapabilityConfigurationAprilTag",
58+
"OpenXRSpatialContextPersistenceConfig",
59+
"OpenXRSpatialCapabilityConfigurationPlaneTracking",
60+
"OpenXRSpatialComponentData",
61+
"OpenXRSpatialComponentBounded2DList",
62+
"OpenXRSpatialComponentBounded3DList",
63+
"OpenXRSpatialComponentParentList",
64+
"OpenXRSpatialComponentMesh2DList",
65+
"OpenXRSpatialComponentMesh3DList",
66+
"OpenXRSpatialComponentPlaneAlignmentList",
67+
"OpenXRSpatialComponentPolygon2DList",
68+
"OpenXRSpatialComponentPlaneSemanticLabelList",
69+
"OpenXRSpatialComponentMarkerList",
70+
"OpenXRSpatialQueryResultData",
71+
"OpenXRSpatialComponentAnchorList",
72+
"OpenXRSpatialComponentPersistenceList",
73+
"OpenXRSpatialAnchorCapability",
74+
"OpenXRSpatialPlaneTrackingCapability",
75+
"OpenXRSpatialMarkerTrackingCapability",
4676
]
4777

4878

modules/openxr/doc_classes/OpenXRAPIExtension.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
<method name="get_system_id">
141141
<return type="int" />
142142
<description>
143-
Returns the id of the system, which is an [url=https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrSystemId.html]XrSystemId[/url] cast to an integer.
143+
Returns the ID of the system, which is an [url=https://registry.khronos.org/OpenXR/specs/1.0/man/html/XrSystemId.html]XrSystemId[/url] cast to an integer.
144144
</description>
145145
</method>
146146
<method name="insert_debug_label">
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="OpenXRAnchorTracker" inherits="OpenXRSpatialEntityTracker" experimental="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
3+
<brief_description>
4+
Positional tracker for our spatial entity anchor extension.
5+
</brief_description>
6+
<description>
7+
Positional tracker for our OpenXR spatial entity anchor extension, it tracks a user defined location in real space and maps it to our virtual space.
8+
</description>
9+
<tutorials>
10+
</tutorials>
11+
<methods>
12+
<method name="has_uuid" qualifiers="const">
13+
<return type="bool" />
14+
<description>
15+
Returns [code]true[/code] if a non-zero UUID is set.
16+
</description>
17+
</method>
18+
</methods>
19+
<members>
20+
<member name="uuid" type="String" setter="set_uuid" getter="get_uuid" default="&quot;&quot;">
21+
The UUID provided for persistent anchors.
22+
</member>
23+
</members>
24+
<signals>
25+
<signal name="uuid_changed">
26+
<description>
27+
Emitted when the UUID for this anchor was changed.
28+
</description>
29+
</signal>
30+
</signals>
31+
</class>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="OpenXRMarkerTracker" inherits="OpenXRSpatialEntityTracker" experimental="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
3+
<brief_description>
4+
Spatial entity tracker for our spatial entity marker tracking extension.
5+
</brief_description>
6+
<description>
7+
Spatial entity tracker for our OpenXR spatial entity marker tracking extension. These trackers identify entities in our real space detected by a visual marker such as a QRCode or Aruco code, and map their location to our virtual space.
8+
</description>
9+
<tutorials>
10+
</tutorials>
11+
<methods>
12+
<method name="get_marker_data" qualifiers="const">
13+
<return type="Variant" />
14+
<description>
15+
Returns the marker data for this marker. This can return a [String] or [PackedByteArray]. Only applicable to QR Code based markers.
16+
</description>
17+
</method>
18+
<method name="set_marker_data">
19+
<return type="void" />
20+
<param index="0" name="marker_data" type="Variant" />
21+
<description>
22+
Sets the marker data for this marker.
23+
[b]Note:[/b] This should only be set by marker discovery logic.
24+
</description>
25+
</method>
26+
</methods>
27+
<members>
28+
<member name="bounds_size" type="Vector2" setter="set_bounds_size" getter="get_bounds_size" default="Vector2(0, 0)">
29+
The bounds size for this marker.
30+
</member>
31+
<member name="marker_id" type="int" setter="set_marker_id" getter="get_marker_id" default="0">
32+
The marker ID for this marker, this is only returned for Aruco and April Tag markers. Call [method get_marker_data] for QRCode markers.
33+
</member>
34+
<member name="marker_type" type="int" setter="set_marker_type" getter="get_marker_type" enum="OpenXRSpatialComponentMarkerList.MarkerType" default="0">
35+
The type of marker.
36+
</member>
37+
</members>
38+
</class>
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="OpenXRPlaneTracker" inherits="OpenXRSpatialEntityTracker" experimental="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../doc/class.xsd">
3+
<brief_description>
4+
Spatial entity tracker for our spatial entity plane tracking extension.
5+
</brief_description>
6+
<description>
7+
Spatial entity tracker for our OpenXR spatial entity plane tracking extension. These trackers identify entities in our real space such as walls, floors, tables, etc. and map their location to our virtual space.
8+
</description>
9+
<tutorials>
10+
</tutorials>
11+
<methods>
12+
<method name="clear_mesh_data">
13+
<return type="void" />
14+
<description>
15+
Clears the mesh data for this tracker. You should only call this if you are handling your own discovery logic.
16+
</description>
17+
</method>
18+
<method name="get_mesh">
19+
<return type="Mesh" />
20+
<description>
21+
Gets a mesh created from either the mesh data or from our bounding size for this plane.
22+
</description>
23+
</method>
24+
<method name="get_mesh_offset" qualifiers="const">
25+
<return type="Transform3D" />
26+
<description>
27+
Gets the transform by which to offset the mesh and collision shape from our pose to display these correctly.
28+
</description>
29+
</method>
30+
<method name="get_shape">
31+
<return type="Shape3D" />
32+
<param index="0" name="thickness" type="float" default="0.01" />
33+
<description>
34+
Gets a collision shape built either from the mesh data or from our bounding size for this plane.
35+
</description>
36+
</method>
37+
<method name="set_mesh_data">
38+
<return type="void" />
39+
<param index="0" name="origin" type="Transform3D" />
40+
<param index="1" name="vertices" type="PackedVector2Array" />
41+
<param index="2" name="indices" type="PackedInt32Array" default="PackedInt32Array()" />
42+
<description>
43+
Sets the mesh data for this plane. You should only call this if you are handling your own discovery logic.
44+
</description>
45+
</method>
46+
</methods>
47+
<members>
48+
<member name="bounds_size" type="Vector2" setter="set_bounds_size" getter="get_bounds_size" default="Vector2(0, 0)">
49+
The bounding size of the plane. This is a 2D size.
50+
</member>
51+
<member name="plane_alignment" type="int" setter="set_plane_alignment" getter="get_plane_alignment" enum="OpenXRSpatialComponentPlaneAlignmentList.PlaneAlignment" default="0">
52+
The main alignment in space of this plane.
53+
</member>
54+
<member name="plane_label" type="String" setter="set_plane_label" getter="get_plane_label" default="&quot;&quot;">
55+
The semantic label for this plane.
56+
</member>
57+
</members>
58+
<signals>
59+
<signal name="mesh_changed">
60+
<description>
61+
Emitted when our mesh data has changed the mesh instance and collision needs to be updated.
62+
</description>
63+
</signal>
64+
</signals>
65+
</class>

0 commit comments

Comments
 (0)