3131#ifndef ARKIT_INTERFACE_H
3232#define ARKIT_INTERFACE_H
3333
34- #include " servers/camera/camera_feed.h"
34+ #include " core/version.h"
35+
36+ #if VERSION_MAJOR == 4
3537#include " servers/xr/xr_interface.h"
3638#include " servers/xr/xr_positional_tracker.h"
3739
40+ typedef XRInterface GodotBaseARInterface;
41+ typedef XRPositionalTracker GodotARTracker;
42+
43+ typedef Vector<uint8_t > GodotUInt8Vector;
44+
45+ #define GODOT_ARKIT_OVERRIDE override
46+ #else
47+ #include " servers/arvr/arvr_interface.h"
48+ #include " servers/arvr/arvr_positional_tracker.h"
49+
50+ typedef ARVRInterface GodotBaseARInterface;
51+ typedef ARVRPositionalTracker GodotARTracker;
52+
53+ typedef PoolVector<uint8_t > GodotUInt8Vector;
54+
55+ #define GODOT_ARKIT_OVERRIDE
56+ #endif
57+
58+ #include " servers/camera/camera_feed.h"
59+
3860/* *
3961 @author Bastiaan Olij <[email protected] > 4062
4567class ARKitShader ;
4668
4769#ifdef __OBJC__
48-
49- typedef ARAnchor GodotARAnchor;
50-
70+ typedef NSObject GodotARAnchor;
5171#else
52-
5372typedef void GodotARAnchor;
5473#endif
5574
56- class ARKitInterface : public XRInterface {
57- GDCLASS (ARKitInterface, XRInterface );
75+ class ARKitInterface : public GodotBaseARInterface {
76+ GDCLASS (ARKitInterface, GodotBaseARInterface );
5877
5978private:
6079 bool initialized;
@@ -71,18 +90,18 @@ class ARKitInterface : public XRInterface {
7190 Ref<CameraFeed> feed;
7291 size_t image_width[2 ];
7392 size_t image_height[2 ];
74- Vector< uint8_t > img_data[2 ];
93+ GodotUInt8Vector img_data[2 ];
7594
7695 struct anchor_map {
77- XRPositionalTracker *tracker;
96+ GodotARTracker *tracker;
7897 unsigned char uuid[16 ];
7998 };
8099
81100 // /@TODO should use memory map object from Godot?
82101 unsigned int num_anchors;
83102 unsigned int max_anchors;
84103 anchor_map *anchors;
85- XRPositionalTracker *get_anchor_for_uuid (const unsigned char *p_uuid);
104+ GodotARTracker *get_anchor_for_uuid (const unsigned char *p_uuid);
86105 void remove_anchor_for_uuid (const unsigned char *p_uuid);
87106 void remove_all_anchors ();
88107
@@ -93,9 +112,9 @@ class ARKitInterface : public XRInterface {
93112 void start_session ();
94113 void stop_session ();
95114
96- bool get_anchor_detection_is_enabled () const override ;
97- void set_anchor_detection_is_enabled (bool p_enable) override ;
98- virtual int get_camera_feed_id () override ;
115+ bool get_anchor_detection_is_enabled () const GODOT_ARKIT_OVERRIDE ;
116+ void set_anchor_detection_is_enabled (bool p_enable) GODOT_ARKIT_OVERRIDE ;
117+ virtual int get_camera_feed_id () GODOT_ARKIT_OVERRIDE ;
99118
100119 bool get_light_estimation_is_enabled () const ;
101120 void set_light_estimation_is_enabled (bool p_enable);
@@ -106,22 +125,22 @@ class ARKitInterface : public XRInterface {
106125 /* while Godot has its own raycast logic this takes ARKits camera into account and hits on any ARAnchor */
107126 Array raycast (Vector2 p_screen_coord);
108127
109- virtual void notification (int p_what) override ;
128+ virtual void notification (int p_what) GODOT_ARKIT_OVERRIDE ;
110129
111- virtual StringName get_name () const override ;
112- virtual int get_capabilities () const override ;
130+ virtual StringName get_name () const GODOT_ARKIT_OVERRIDE ;
131+ virtual int get_capabilities () const GODOT_ARKIT_OVERRIDE ;
113132
114- virtual bool is_initialized () const override ;
115- virtual bool initialize () override ;
116- virtual void uninitialize () override ;
133+ virtual bool is_initialized () const GODOT_ARKIT_OVERRIDE ;
134+ virtual bool initialize () GODOT_ARKIT_OVERRIDE ;
135+ virtual void uninitialize () GODOT_ARKIT_OVERRIDE ;
117136
118- virtual Size2 get_render_targetsize () override ;
119- virtual bool is_stereo () override ;
120- virtual Transform get_transform_for_eye (XRInterface ::Eyes p_eye, const Transform &p_cam_transform) override ;
121- virtual CameraMatrix get_projection_for_eye (XRInterface ::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) override ;
122- virtual void commit_for_eye (XRInterface ::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) override ;
137+ virtual Size2 get_render_targetsize () GODOT_ARKIT_OVERRIDE ;
138+ virtual bool is_stereo () GODOT_ARKIT_OVERRIDE ;
139+ virtual Transform get_transform_for_eye (GodotBaseARInterface ::Eyes p_eye, const Transform &p_cam_transform) GODOT_ARKIT_OVERRIDE ;
140+ virtual CameraMatrix get_projection_for_eye (GodotBaseARInterface ::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) GODOT_ARKIT_OVERRIDE ;
141+ virtual void commit_for_eye (GodotBaseARInterface ::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) GODOT_ARKIT_OVERRIDE ;
123142
124- virtual void process () override ;
143+ virtual void process () GODOT_ARKIT_OVERRIDE ;
125144
126145 // called by delegate (void * because C++ and Obj-C don't always mix, should really change all platform/iphone/*.cpp files to .mm)
127146 void _add_or_update_anchor (GodotARAnchor *p_anchor);
0 commit comments