Skip to content

Commit c5f62fa

Browse files
authored
Merge pull request #52003 from BastiaanOlij/xr_interface_extension
Adding GDExtension support to XRInterface
2 parents f6f5e0f + 86ff7f8 commit c5f62fa

28 files changed

+495
-1009
lines changed

doc/classes/XRInterface.xml

+18-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<class name="XRInterface" inherits="RefCounted" version="4.0">
33
<brief_description>
4-
Base class for an AR/VR interface implementation.
4+
Base class for an XR interface implementation.
55
</brief_description>
66
<description>
77
This class needs to be implemented to make an AR or VR platform available to Godot and these should be implemented as C++ modules or GDNative modules (note that for GDNative the subclass XRScriptInterface should be used). Part of the interface is exposed to GDScript so you can detect, enable and configure an AR or VR platform.
@@ -26,17 +26,17 @@
2626
<method name="get_name" qualifiers="const">
2727
<return type="StringName" />
2828
<description>
29-
Returns the name of this interface (OpenVR, OpenHMD, ARKit, etc).
29+
Returns the name of this interface (OpenXR, OpenVR, OpenHMD, ARKit, etc).
3030
</description>
3131
</method>
32-
<method name="get_render_targetsize">
32+
<method name="get_render_target_size">
3333
<return type="Vector2" />
3434
<description>
3535
Returns the resolution at which we should render our intermediate results before things like lens distortion are applied by the VR platform.
3636
</description>
3737
</method>
3838
<method name="get_tracking_status" qualifiers="const">
39-
<return type="int" enum="XRInterface.Tracking_status" />
39+
<return type="int" enum="XRInterface.TrackingStatus" />
4040
<description>
4141
If supported, returns the status of our tracking. This will allow you to provide feedback to the user whether there are issues with positional tracking.
4242
</description>
@@ -52,11 +52,17 @@
5252
<description>
5353
Call this to initialize this interface. The first interface that is initialized is identified as the primary interface and it will be used for rendering output.
5454
After initializing the interface you want to use you then need to enable the AR/VR mode of a viewport and rendering should commence.
55-
[b]Note:[/b] You must enable the AR/VR mode on the main viewport for any device that uses the main output of Godot, such as for mobile VR.
55+
[b]Note:[/b] You must enable the XR mode on the main viewport for any device that uses the main output of Godot, such as for mobile VR.
5656
If you do this for a platform that handles its own output (such as OpenVR) Godot will show just one eye without distortion on screen. Alternatively, you can add a separate viewport node to your scene and enable AR/VR on that viewport. It will be used to output to the HMD, leaving you free to do anything you like in the main window, such as using a separate camera as a spectator camera or rendering something completely different.
5757
While currently not used, you can activate additional interfaces. You may wish to do this if you want to track controllers from other platforms. However, at this point in time only one interface can render to an HMD.
5858
</description>
5959
</method>
60+
<method name="is_initialized" qualifiers="const">
61+
<return type="bool" />
62+
<description>
63+
Is [code]true[/code] if this interface has been initialised.
64+
</description>
65+
</method>
6066
<method name="uninitialize">
6167
<return type="void" />
6268
<description>
@@ -68,10 +74,7 @@
6874
<member name="ar_is_anchor_detection_enabled" type="bool" setter="set_anchor_detection_is_enabled" getter="get_anchor_detection_is_enabled" default="false">
6975
On an AR interface, [code]true[/code] if anchor detection is enabled.
7076
</member>
71-
<member name="interface_is_initialized" type="bool" setter="set_is_initialized" getter="is_initialized" default="false">
72-
[code]true[/code] if this interface been initialized.
73-
</member>
74-
<member name="interface_is_primary" type="bool" setter="set_is_primary" getter="is_primary" default="false">
77+
<member name="interface_is_primary" type="bool" setter="set_primary" getter="is_primary" default="false">
7578
[code]true[/code] if this is the primary interface.
7679
</member>
7780
</members>
@@ -89,7 +92,7 @@
8992
This interface supports AR (video background and real world tracking).
9093
</constant>
9194
<constant name="XR_EXTERNAL" value="8" enum="Capabilities">
92-
This interface outputs to an external device. If the main viewport is used, the on screen output is an unmodified buffer of either the left or right eye (stretched if the viewport size is not changed to the same aspect ratio of [method get_render_targetsize]). Using a separate viewport node frees up the main viewport for other purposes.
95+
This interface outputs to an external device. If the main viewport is used, the on screen output is an unmodified buffer of either the left or right eye (stretched if the viewport size is not changed to the same aspect ratio of [method get_render_target_size]). Using a separate viewport node frees up the main viewport for other purposes.
9396
</constant>
9497
<constant name="EYE_MONO" value="0" enum="Eyes">
9598
Mono output, this is mostly used internally when retrieving positioning information for our camera node or when stereo scopic rendering is not supported.
@@ -100,19 +103,19 @@
100103
<constant name="EYE_RIGHT" value="2" enum="Eyes">
101104
Right eye output, this is mostly used internally when rendering the image for the right eye and obtaining positioning and projection information.
102105
</constant>
103-
<constant name="XR_NORMAL_TRACKING" value="0" enum="Tracking_status">
106+
<constant name="XR_NORMAL_TRACKING" value="0" enum="TrackingStatus">
104107
Tracking is behaving as expected.
105108
</constant>
106-
<constant name="XR_EXCESSIVE_MOTION" value="1" enum="Tracking_status">
109+
<constant name="XR_EXCESSIVE_MOTION" value="1" enum="TrackingStatus">
107110
Tracking is hindered by excessive motion (the player is moving faster than tracking can keep up).
108111
</constant>
109-
<constant name="XR_INSUFFICIENT_FEATURES" value="2" enum="Tracking_status">
112+
<constant name="XR_INSUFFICIENT_FEATURES" value="2" enum="TrackingStatus">
110113
Tracking is hindered by insufficient features, it's too dark (for camera-based tracking), player is blocked, etc.
111114
</constant>
112-
<constant name="XR_UNKNOWN_TRACKING" value="3" enum="Tracking_status">
115+
<constant name="XR_UNKNOWN_TRACKING" value="3" enum="TrackingStatus">
113116
We don't know the status of the tracking or this interface does not provide feedback.
114117
</constant>
115-
<constant name="XR_NOT_TRACKING" value="4" enum="Tracking_status">
118+
<constant name="XR_NOT_TRACKING" value="4" enum="TrackingStatus">
116119
Tracking is not functional (camera not plugged in or obscured, lighthouses turned off, etc.).
117120
</constant>
118121
</constants>

doc/classes/XRInterfaceExtension.xml

+126
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<class name="XRInterfaceExtension" inherits="XRInterface" version="4.0">
3+
<brief_description>
4+
Base class for XR interface extensions (plugins).
5+
</brief_description>
6+
<description>
7+
External XR interface plugins should inherit from this class.
8+
</description>
9+
<tutorials>
10+
</tutorials>
11+
<methods>
12+
<method name="_commit_views" qualifiers="virtual">
13+
<return type="void" />
14+
<argument index="0" name="" type="RID" />
15+
<argument index="1" name="" type="Rect2" />
16+
<description>
17+
</description>
18+
</method>
19+
<method name="_get_anchor_detection_is_enabled" qualifiers="virtual const">
20+
<return type="bool" />
21+
<description>
22+
</description>
23+
</method>
24+
<method name="_get_camera_feed_id" qualifiers="virtual const">
25+
<return type="int" />
26+
<description>
27+
</description>
28+
</method>
29+
<method name="_get_camera_transform" qualifiers="virtual">
30+
<return type="Transform3D" />
31+
<description>
32+
</description>
33+
</method>
34+
<method name="_get_capabilities" qualifiers="virtual const">
35+
<return type="int" />
36+
<description>
37+
</description>
38+
</method>
39+
<method name="_get_name" qualifiers="virtual const">
40+
<return type="StringName" />
41+
<description>
42+
</description>
43+
</method>
44+
<method name="_get_projection_for_view" qualifiers="virtual">
45+
<return type="PackedFloat64Array" />
46+
<argument index="0" name="view" type="int" />
47+
<argument index="1" name="aspect" type="float" />
48+
<argument index="2" name="z_near" type="float" />
49+
<argument index="3" name="z_far" type="float" />
50+
<description>
51+
</description>
52+
</method>
53+
<method name="_get_render_target_size" qualifiers="virtual">
54+
<return type="Vector2" />
55+
<description>
56+
</description>
57+
</method>
58+
<method name="_get_tracking_status" qualifiers="virtual const">
59+
<return type="int" />
60+
<description>
61+
</description>
62+
</method>
63+
<method name="_get_transform_for_view" qualifiers="virtual">
64+
<return type="Transform3D" />
65+
<argument index="0" name="view" type="int" />
66+
<argument index="1" name="cam_transform" type="Transform3D" />
67+
<description>
68+
</description>
69+
</method>
70+
<method name="_get_view_count" qualifiers="virtual">
71+
<return type="int" />
72+
<description>
73+
</description>
74+
</method>
75+
<method name="_initialize" qualifiers="virtual">
76+
<return type="bool" />
77+
<description>
78+
</description>
79+
</method>
80+
<method name="_is_initialized" qualifiers="virtual const">
81+
<return type="bool" />
82+
<description>
83+
</description>
84+
</method>
85+
<method name="_notification" qualifiers="virtual">
86+
<return type="void" />
87+
<argument index="0" name="what" type="int" />
88+
<description>
89+
</description>
90+
</method>
91+
<method name="_process" qualifiers="virtual">
92+
<return type="void" />
93+
<description>
94+
</description>
95+
</method>
96+
<method name="_set_anchor_detection_is_enabled" qualifiers="virtual">
97+
<return type="void" />
98+
<argument index="0" name="enabled" type="bool" />
99+
<description>
100+
</description>
101+
</method>
102+
<method name="_uninitialize" qualifiers="virtual">
103+
<return type="void" />
104+
<description>
105+
</description>
106+
</method>
107+
<method name="add_blit">
108+
<return type="void" />
109+
<argument index="0" name="render_target" type="RID" />
110+
<argument index="1" name="rect" type="Rect2i" />
111+
<argument index="2" name="use_layer" type="bool" />
112+
<argument index="3" name="layer" type="int" />
113+
<argument index="4" name="apply_lens_distortion" type="bool" />
114+
<argument index="5" name="eye_center" type="Vector2" />
115+
<argument index="6" name="k1" type="float" />
116+
<argument index="7" name="k2" type="float" />
117+
<argument index="8" name="upscale" type="float" />
118+
<argument index="9" name="aspect_ratio" type="float" />
119+
<description>
120+
Blits our render results to screen optionally applying lens distortion. This can only be called while processing [code]_commit_views[/code].
121+
</description>
122+
</method>
123+
</methods>
124+
<constants>
125+
</constants>
126+
</class>

doc/classes/XRServer.xml

-7
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@
3737
You should call this method after a few seconds have passed. For instance, when the user requests a realignment of the display holding a designated button on a controller for a short period of time, or when implementing a teleport mechanism.
3838
</description>
3939
</method>
40-
<method name="clear_primary_interface_if">
41-
<return type="void" />
42-
<argument index="0" name="interface" type="XRInterface" />
43-
<description>
44-
Clears our current primary interface if it is set to the provided interface.
45-
</description>
46-
</method>
4740
<method name="find_interface" qualifiers="const">
4841
<return type="XRInterface" />
4942
<argument index="0" name="name" type="String" />

modules/gdnative/config.py

-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ def configure(env):
88

99
def get_doc_classes():
1010
return [
11-
"XRInterfaceGDNative",
1211
"GDNative",
1312
"GDNativeLibrary",
1413
"MultiplayerPeerGDNative",

modules/gdnative/doc_classes/GDNativeLibrary.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
An external library containing functions or script classes to use in Godot.
55
</brief_description>
66
<description>
7-
A GDNative library can implement [NativeScript]s, global functions to call with the [GDNative] class, or low-level engine extensions through interfaces such as [XRInterfaceGDNative]. The library must be compiled for each platform and architecture that the project will run on.
7+
A GDNative library can implement [NativeScript]s, global functions to call with the [GDNative] class, or low-level engine extensions through interfaces such as XRInterfaceGDNative. The library must be compiled for each platform and architecture that the project will run on.
88
</description>
99
<tutorials>
1010
<link title="GDNative C example">https://docs.godotengine.org/en/latest/tutorials/plugins/gdnative/gdnative-c-example.html</link>

modules/gdnative/doc_classes/XRInterfaceGDNative.xml

-15
This file was deleted.

0 commit comments

Comments
 (0)