1
0
mirror of https://github.com/godotengine/godot.git synced 2026-01-05 19:31:35 +00:00

iOS: Refactoring

Enabled ARC for iOS.
Weakify/Strongify macros for objc blocks.
Removed old version checks.
Specific types for ObjC++ modules to exclude unneeded bridging.
Separate DeviceMetrics class for device specific data.
Replaced old/deprecated functionality.
This commit is contained in:
Sergey Minakov
2020-10-01 22:18:39 +03:00
parent 19f72beebb
commit 3cd1cb53a0
24 changed files with 323 additions and 353 deletions

View File

@@ -44,6 +44,15 @@
// forward declaration for some needed objects
class ARKitShader;
#ifdef __OBJC__
typedef ARAnchor GodotARAnchor;
#else
typedef void GodotARAnchor;
#endif
class ARKitInterface : public XRInterface {
GDCLASS(ARKitInterface, XRInterface);
@@ -115,8 +124,8 @@ public:
virtual void process() override;
// called by delegate (void * because C++ and Obj-C don't always mix, should really change all platform/iphone/*.cpp files to .mm)
void _add_or_update_anchor(void *p_anchor);
void _remove_anchor(void *p_anchor);
void _add_or_update_anchor(GodotARAnchor *p_anchor);
void _remove_anchor(GodotARAnchor *p_anchor);
ARKitInterface();
~ARKitInterface();

View File

@@ -306,12 +306,10 @@ void ARKitInterface::uninitialize() {
remove_all_anchors();
if (@available(iOS 11.0, *)) {
[ar_session release];
ar_session = NULL;
ar_session = nil;
}
[ar_delegate release];
ar_delegate = NULL;
ar_delegate = nil;
initialized = false;
session_was_started = false;
}
@@ -687,7 +685,7 @@ void ARKitInterface::process() {
}
}
void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
void ARKitInterface::_add_or_update_anchor(GodotARAnchor *p_anchor) {
// _THREAD_SAFE_METHOD_
if (@available(iOS 11.0, *)) {
@@ -749,7 +747,7 @@ void ARKitInterface::_add_or_update_anchor(void *p_anchor) {
}
}
void ARKitInterface::_remove_anchor(void *p_anchor) {
void ARKitInterface::_remove_anchor(GodotARAnchor *p_anchor) {
// _THREAD_SAFE_METHOD_
if (@available(iOS 11.0, *)) {
@@ -768,7 +766,7 @@ ARKitInterface::ARKitInterface() {
plane_detection_is_enabled = false;
light_estimation_is_enabled = false;
if (@available(iOS 11.0, *)) {
ar_session = NULL;
ar_session = nil;
}
z_near = 0.01;
z_far = 1000.0;