Skip to content

Commit 34ce735

Browse files
committed
Migrate modules to plugins.
Support both Godot 4.0 and Godot 3.2.4 with plugin support. gamecenter plugin impl simplify library name inappstore migration icloud migration camera migration migrate arkit
1 parent 0af9e1f commit 34ce735

21 files changed

+376
-147
lines changed

SConstruct

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,8 @@ sources.append(Glob(env['plugin'] + '/*.mm'))
162162
sources.append(Glob(env['plugin'] + '/*.m'))
163163

164164
# lib<plugin>.<arch>-<simulator|iphone>.<release|debug|release_debug>.a
165-
library_name = env['plugin'] + "." + env["arch"] + "-" + ("simulator" if env["simulator"] else "iphone") + "." + env["target"] + ".a"
165+
library_platform = env["arch"] + "-" + ("simulator" if env["simulator"] else "iphone")
166+
library_name = env['plugin'] + "." + library_platform + "." + env["target"] + ".a"
166167
library = env.StaticLibrary(target=env['target_path'] + library_name, source=sources)
167168

168169
Default(library)

arkit/arkit_interface.h

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,32 @@
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
@@ -45,16 +67,13 @@
4567
class ARKitShader;
4668

4769
#ifdef __OBJC__
48-
49-
typedef ARAnchor GodotARAnchor;
50-
70+
typedef NSObject GodotARAnchor;
5171
#else
52-
5372
typedef void GodotARAnchor;
5473
#endif
5574

56-
class ARKitInterface : public XRInterface {
57-
GDCLASS(ARKitInterface, XRInterface);
75+
class ARKitInterface : public GodotBaseARInterface {
76+
GDCLASS(ARKitInterface, GodotBaseARInterface);
5877

5978
private:
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

Comments
 (0)