diff options
82 files changed, 1059 insertions, 281 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 7de1c7e6b9..b47e611a51 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -453,6 +453,11 @@ int _OS::get_power_percent_left() { return OS::get_singleton()->get_power_percent_left(); } +bool _OS::has_feature(const String &p_feature) const { + + return OS::get_singleton()->has_feature(p_feature); +} + /* enum Weekday { DAY_SUNDAY, @@ -863,6 +868,10 @@ void _OS::hide_virtual_keyboard() { OS::get_singleton()->hide_virtual_keyboard(); } +int _OS::get_virtual_keyboard_height() { + return OS::get_singleton()->get_virtual_keyboard_height(); +} + void _OS::print_all_resources(const String &p_to_file) { OS::get_singleton()->print_all_resources(p_to_file); @@ -1070,6 +1079,7 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("has_virtual_keyboard"), &_OS::has_virtual_keyboard); ClassDB::bind_method(D_METHOD("show_virtual_keyboard", "existing_text"), &_OS::show_virtual_keyboard, DEFVAL("")); ClassDB::bind_method(D_METHOD("hide_virtual_keyboard"), &_OS::hide_virtual_keyboard); + ClassDB::bind_method(D_METHOD("get_virtual_keyboard_height"), &_OS::get_virtual_keyboard_height); ClassDB::bind_method(D_METHOD("print_resources_in_use", "short"), &_OS::print_resources_in_use, DEFVAL(false)); ClassDB::bind_method(D_METHOD("print_all_resources", "tofile"), &_OS::print_all_resources, DEFVAL("")); @@ -1105,6 +1115,8 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("set_use_vsync", "enable"), &_OS::set_use_vsync); ClassDB::bind_method(D_METHOD("is_vsync_enabled"), &_OS::is_vsync_enabled); + ClassDB::bind_method(D_METHOD("has_feature", "tag_name"), &_OS::has_feature); + ClassDB::bind_method(D_METHOD("get_power_state"), &_OS::get_power_state); ClassDB::bind_method(D_METHOD("get_power_seconds_left"), &_OS::get_power_seconds_left); ClassDB::bind_method(D_METHOD("get_power_percent_left"), &_OS::get_power_percent_left); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 6f3606dcc3..7f8c734e36 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -204,6 +204,7 @@ public: bool has_virtual_keyboard() const; void show_virtual_keyboard(const String &p_existing_text = ""); void hide_virtual_keyboard(); + int get_virtual_keyboard_height(); void print_resources_in_use(bool p_short = false); void print_all_resources(const String &p_to_file); @@ -317,6 +318,8 @@ public: int get_power_seconds_left(); int get_power_percent_left(); + bool has_feature(const String &p_feature) const; + static _OS *get_singleton() { return singleton; } _OS(); diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index dd56db9bf9..b8c0a2b616 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -297,7 +297,7 @@ Error HTTPClient::poll() { case StreamPeerTCP::STATUS_CONNECTED: { if (ssl) { Ref<StreamPeerSSL> ssl = StreamPeerSSL::create(); - Error err = ssl->connect_to_stream(tcp_connection, true, ssl_verify_host ? conn_host : String()); + Error err = ssl->connect_to_stream(tcp_connection, ssl_verify_host, ssl_verify_host ? conn_host : String()); if (err != OK) { close(); status = STATUS_SSL_HANDSHAKE_ERROR; diff --git a/core/io/logger.cpp b/core/io/logger.cpp index 7ea5f06d7e..b94007d316 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -177,11 +177,14 @@ void RotatedFileLogger::logv(const char *p_format, va_list p_list, bool p_err) { const int static_buf_size = 512; char static_buf[static_buf_size]; char *buf = static_buf; + va_list list_copy; + va_copy(list_copy, p_list); int len = vsnprintf(buf, static_buf_size, p_format, p_list); if (len >= static_buf_size) { buf = (char *)Memory::alloc_static(len + 1); - vsnprintf(buf, len + 1, p_format, p_list); + vsnprintf(buf, len + 1, p_format, list_copy); } + va_end(list_copy); file->store_buffer((uint8_t *)buf, len); if (len >= static_buf_size) { Memory::free_static(buf); diff --git a/core/io/resource_import.cpp b/core/io/resource_import.cpp index bc7ea47762..401d704222 100644 --- a/core/io/resource_import.cpp +++ b/core/io/resource_import.cpp @@ -77,7 +77,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy if (assign != String()) { if (!path_found && assign.begins_with("path.") && r_path_and_type.path == String()) { String feature = assign.get_slicec('.', 1); - if (OS::get_singleton()->check_feature_support(feature)) { + if (OS::get_singleton()->has_feature(feature)) { r_path_and_type.path = value; path_found = true; //first match must have priority } diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 89cb4a22c2..ed0d491679 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -492,7 +492,7 @@ void ResourceLoader::reload_translation_remaps() { void ResourceLoader::load_translation_remaps() { - if (!ProjectSettings::get_singleton()->has("locale/translation_remaps")) + if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) return; Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); diff --git a/core/os/os.cpp b/core/os/os.cpp index ff17cdb508..eb5d5be33d 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -193,6 +193,10 @@ void OS::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_scr void OS::hide_virtual_keyboard() { } +int OS::get_virtual_keyboard_height() const { + return 0; +} + void OS::print_all_resources(String p_to_file) { ERR_FAIL_COND(p_to_file != "" && _OSPRF); @@ -494,7 +498,7 @@ int OS::get_power_percent_left() { return -1; } -bool OS::check_feature_support(const String &p_feature) { +bool OS::has_feature(const String &p_feature) { if (p_feature == get_name()) return true; @@ -506,6 +510,13 @@ bool OS::check_feature_support(const String &p_feature) { return true; #endif + if (sizeof(void *) == 8 && p_feature == "64") { + return true; + } + if (sizeof(void *) == 4 && p_feature == "32") { + return true; + } + if (_check_internal_feature_support(p_feature)) return true; @@ -530,7 +541,7 @@ OS::OS() { _render_thread_mode = RENDER_THREAD_SAFE; - _allow_hidpi = true; + _allow_hidpi = false; _stack_bottom = (void *)(&stack_bottom); _logger = NULL; diff --git a/core/os/os.h b/core/os/os.h index 5de07be005..6fcfd71332 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -315,6 +315,9 @@ public: virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2()); virtual void hide_virtual_keyboard(); + // returns height of the currently shown virtual keyboard (0 if keyboard is hidden) + virtual int get_virtual_keyboard_height() const; + virtual void set_cursor_shape(CursorShape p_shape) = 0; virtual bool get_swap_ok_cancel() { return false; } @@ -427,7 +430,7 @@ public: virtual int get_power_seconds_left(); virtual int get_power_percent_left(); - bool check_feature_support(const String &p_feature); + bool has_feature(const String &p_feature); /** * Returns the stack bottom of the main thread of the application. diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 14ebe87dc5..ff2be87b07 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -152,7 +152,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) { bool override_valid = false; for (int i = 1; i < s.size(); i++) { String feature = s[i].strip_edges(); - if (OS::get_singleton()->check_feature_support(feature) || custom_features.has(feature)) { + if (OS::get_singleton()->has_feature(feature) || custom_features.has(feature)) { override_valid = true; break; } @@ -420,7 +420,7 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack) { return OK; } -bool ProjectSettings::has(String p_var) const { +bool ProjectSettings::has_setting(String p_var) const { _THREAD_SAFE_METHOD_ @@ -800,7 +800,7 @@ Error ProjectSettings::save_custom(const String &p_path, const CustomMap &p_cust Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) { Variant ret; - if (ProjectSettings::get_singleton()->has(p_var)) { + if (ProjectSettings::get_singleton()->has_setting(p_var)) { ret = ProjectSettings::get_singleton()->get(p_var); } else { ProjectSettings::get_singleton()->set(p_var, p_default); @@ -907,9 +907,19 @@ Variant ProjectSettings::property_get_revert(const String &p_name) { return props[p_name].initial; } +void ProjectSettings::set_setting(const String &p_setting, const Variant &p_value) { + set(p_setting, p_value); +} + +Variant ProjectSettings::get_setting(const String &p_setting) const { + return get(p_setting); +} + void ProjectSettings::_bind_methods() { - ClassDB::bind_method(D_METHOD("has", "name"), &ProjectSettings::has); + ClassDB::bind_method(D_METHOD("has_setting", "name"), &ProjectSettings::has_setting); + ClassDB::bind_method(D_METHOD("set_setting", "name", "value"), &ProjectSettings::set_setting); + ClassDB::bind_method(D_METHOD("get_setting", "name"), &ProjectSettings::get_setting); ClassDB::bind_method(D_METHOD("set_order", "name", "position"), &ProjectSettings::set_order); ClassDB::bind_method(D_METHOD("get_order", "name"), &ProjectSettings::get_order); ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value"), &ProjectSettings::set_initial_value); diff --git a/core/project_settings.h b/core/project_settings.h index 718ab2a011..ea6034dc84 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -119,7 +119,10 @@ protected: static void _bind_methods(); public: - bool has(String p_var) const; + void set_setting(const String &p_setting, const Variant &p_value); + Variant get_setting(const String &p_setting) const; + + bool has_setting(String p_var) const; String localize_path(const String &p_path) const; String globalize_path(const String &p_path) const; diff --git a/core/translation.cpp b/core/translation.cpp index f1f9c72b85..27e3b202d0 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -1052,7 +1052,7 @@ TranslationServer *TranslationServer::singleton = NULL; bool TranslationServer::_load_translations(const String &p_from) { - if (ProjectSettings::get_singleton()->has(p_from)) { + if (ProjectSettings::get_singleton()->has_setting(p_from)) { PoolVector<String> translations = ProjectSettings::get_singleton()->get(p_from); int tcount = translations.size(); diff --git a/doc/classes/ARVRAnchor.xml b/doc/classes/ARVRAnchor.xml index 4ff39390b2..6e11034073 100644 --- a/doc/classes/ARVRAnchor.xml +++ b/doc/classes/ARVRAnchor.xml @@ -34,6 +34,13 @@ Returns true if the anchor is being tracked and false if no anchor with this id is currently known. </description> </method> + <method name="get_plane" qualifiers="const"> + <return type="Plane"> + </return> + <description> + Returns a plane aligned with our anchor, handy for intersection testing + </description> + </method> <method name="get_size" qualifiers="const"> <return type="Vector3"> </return> diff --git a/doc/classes/ARVRInterface.xml b/doc/classes/ARVRInterface.xml index fad9571628..1c2e761b57 100644 --- a/doc/classes/ARVRInterface.xml +++ b/doc/classes/ARVRInterface.xml @@ -12,6 +12,20 @@ <demos> </demos> <methods> + <method name="get_anchor_detection_is_enabled" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns true if achor detection is enabled (AR only). + </description> + </method> + <method name="get_capabilities" qualifiers="const"> + <return type="int"> + </return> + <description> + Returns a combination of flags providing information about the capabilities of this interface. + </description> + </method> <method name="get_name" qualifiers="const"> <return type="String"> </return> @@ -26,11 +40,11 @@ Returns the resolution at which we should render our intermediate results before things like lens distortion are applied by the VR platform. </description> </method> - <method name="hmd_is_present"> - <return type="bool"> + <method name="get_tracking_status" qualifiers="const"> + <return type="int" enum="ARVRInterface.Tracking_status"> </return> <description> - Returns true if an HMD is available for this interface. + 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. </description> </method> <method name="initialize"> @@ -51,34 +65,45 @@ Returns true if this interface is active. </description> </method> - <method name="is_installed"> + <method name="is_primary"> <return type="bool"> </return> <description> - Returns true if this interface has been installed. Say your game is designed to work with OpenVR so you are using the OpenVR interface but the user hasn't installed SteamVR, this would return false. + Returns true if this interface is currently the primary interface (the interface responsible for showing the output). </description> </method> - <method name="is_primary"> + <method name="is_stereo"> <return type="bool"> </return> <description> - Returns true if this interface is currently the primary interface (the interface responsible for showing the output). + Returns true if the current output of this interface is in stereo. </description> </method> - <method name="set_is_primary"> + <method name="set_anchor_detection_is_enabled"> <return type="void"> </return> <argument index="0" name="enable" type="bool"> </argument> <description> - Set this interface to the primary interface (unset the old one). + Enables anchor detection, this is used on AR interfaces and enables the extra logic that will detect planes, features, objects, etc. and adds/modifies anchor points. </description> </method> - <method name="supports_hmd"> - <return type="bool"> + <method name="set_is_initialized"> + <return type="void"> + </return> + <argument index="0" name="initialized" type="bool"> + </argument> + <description> + Initialise/uninitilise this interface (same effect as calling intialize/uninitialize). + </description> + </method> + <method name="set_is_primary"> + <return type="void"> </return> + <argument index="0" name="enable" type="bool"> + </argument> <description> - Returns true if this interface supports HMDs and by extension uses stereo scopic rendering. + Set this interface to the primary interface (unset the old one). </description> </method> <method name="uninitialize"> @@ -90,10 +115,32 @@ </method> </methods> <members> - <member name="primary" type="bool" setter="set_is_primary" getter="is_primary"> + <member name="ar_is_anchor_detection_enabled" type="bool" setter="set_anchor_detection_is_enabled" getter="get_anchor_detection_is_enabled"> + On an AR interface, is our anchor detection enabled? + </member> + <member name="interface_is_initialized" type="bool" setter="set_is_initialized" getter="is_initialized"> + Has this interface been initialized? + </member> + <member name="interface_is_primary" type="bool" setter="set_is_primary" getter="is_primary"> + Is this our primary interface? </member> </members> <constants> + <constant name="ARVR_NONE" value="0"> + No ARVR capabilities. + </constant> + <constant name="ARVR_MONO" value="1"> + This interface can work with normal rendering output (non-HMD based AR). + </constant> + <constant name="ARVR_STEREO" value="2"> + This interface supports stereoscopic rendering. + </constant> + <constant name="ARVR_AR" value="4"> + This interface support AR (video background and real world tracking). + </constant> + <constant name="ARVR_EXTERNAL" value="8"> + 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 get_recommended_render_targetsize. Using a seperate viewport node frees up the main viewport for other purposes. + </constant> <constant name="EYE_MONO" value="0"> Mono output, this is mostly used internally when retrieving positioning information for our camera node or when stereo scopic rendering is not supported. </constant> @@ -103,5 +150,20 @@ <constant name="EYE_RIGHT" value="2"> Right eye output, this is mostly used internally when rendering the image for the right eye and obtaining positioning and projection information. </constant> + <constant name="ARVR_NORMAL_TRACKING" value="0"> + Tracking is behaving as expected. + </constant> + <constant name="ARVR_EXCESSIVE_MOTION" value="1"> + Tracking is hindered by excessive motion, player is moving faster then tracking can keep up. + </constant> + <constant name="ARVR_INSUFFICIENT_FEATURES" value="2"> + Tracking is hindered by insufficient features, it's too dark (for camera based tracking), player is blocked, etc. + </constant> + <constant name="ARVR_UNKNOWN_TRACKING" value="3"> + We don't know the status of the tracking or this interface does not provide feedback. + </constant> + <constant name="ARVR_NOT_TRACKING" value="4"> + Tracking is not functional (camera not plugged in or obscured, lighthouses turned off, etc.) + </constant> </constants> </class> diff --git a/doc/classes/ARVRScriptInterface.xml b/doc/classes/ARVRScriptInterface.xml index 54415539e0..182147a015 100644 --- a/doc/classes/ARVRScriptInterface.xml +++ b/doc/classes/ARVRScriptInterface.xml @@ -29,6 +29,20 @@ Outputs a finished render buffer to the AR/VR device for the given eye. </description> </method> + <method name="get_anchor_detection_is_enabled" qualifiers="virtual"> + <return type="bool"> + </return> + <description> + Returns true if achor detection is enabled (AR only). + </description> + </method> + <method name="get_capabilities" qualifiers="virtual"> + <return type="int"> + </return> + <description> + Returns a combination of flags providing information about the capabilities of this interface. + </description> + </method> <method name="get_recommended_render_targetsize" qualifiers="virtual"> <return type="Vector2"> </return> @@ -36,6 +50,13 @@ Returns the size at which we should render our scene to get optimal quality on the output device. </description> </method> + <method name="get_tracking_status" qualifiers="virtual"> + <return type="int"> + </return> + <description> + 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. + </description> + </method> <method name="get_transform_for_eye" qualifiers="virtual"> <return type="Transform"> </return> @@ -47,13 +68,6 @@ Get the location and orientation transform used when rendering a specific eye. </description> </method> - <method name="hmd_is_present" qualifiers="virtual"> - <return type="bool"> - </return> - <description> - Return true is an HMD is available. - </description> - </method> <method name="initialize" qualifiers="virtual"> <return type="bool"> </return> @@ -68,13 +82,6 @@ Returns true if this interface has been initialized and is active. </description> </method> - <method name="is_installed" qualifiers="virtual"> - <return type="bool"> - </return> - <description> - Returns true if the required middleware is installed. - </description> - </method> <method name="is_stereo" qualifiers="virtual"> <return type="bool"> </return> @@ -89,11 +96,13 @@ Gets called before rendering each frame so tracking data gets updated in time. </description> </method> - <method name="supports_hmd" qualifiers="virtual"> - <return type="bool"> + <method name="set_anchor_detection_is_enabled" qualifiers="virtual"> + <return type="void"> </return> + <argument index="0" name="enabled" type="bool"> + </argument> <description> - Returns true if this interface supports HMDs. + Enables anchor detection, this is used on AR interfaces and enables the extra logic that will detect planes, features, objects, etc. and adds/modifies anchor points. </description> </method> <method name="uninitialize" qualifiers="virtual"> diff --git a/doc/classes/ARVRServer.xml b/doc/classes/ARVRServer.xml index 282f25bec9..6a7262bd14 100644 --- a/doc/classes/ARVRServer.xml +++ b/doc/classes/ARVRServer.xml @@ -20,6 +20,22 @@ Mostly exposed for GDNative based interfaces, this is called to register an available interface with the AR/VR server. </description> </method> + <method name="center_on_hmd"> + <return type="void"> + </return> + <argument index="0" name="ignore_tilt" type="bool"> + </argument> + <argument index="1" name="keep_height" type="bool"> + </argument> + <description> + This is a really important function to understand correctly. AR and VR platforms all handle positioning slightly differently. + For platforms that do not offer spatial tracking our origin point (0,0,0) is the location of our HMD but you have little control over the direction the player is facing in the real world. + For platforms that do offer spatial tracking our origin point depends very much on the system. For OpenVR our origin point is usually the center of the tracking space, on the ground. For other platforms its often the location of the tracking camera. + This method allows you to center our tracker on the location of the HMD, it will take the current location of the HMD and use that to adjust all our tracking data in essence realigning the real world to your players current position in your game world. + For this method to produce usable results tracking information should be available and this often takes a few frames after starting your game. + You should call this method after a few seconds have passed, when the user requests a realignment of the display holding a designated button on a controller for a short period of time, and when implementing a teleport mechanism. + </description> + </method> <method name="find_interface" qualifiers="const"> <return type="ARVRInterface"> </return> @@ -84,22 +100,6 @@ Removes a registered interface, again exposed mostly for GDNative based interfaces. </description> </method> - <method name="request_reference_frame"> - <return type="void"> - </return> - <argument index="0" name="ignore_tilt" type="bool"> - </argument> - <argument index="1" name="keep_height" type="bool"> - </argument> - <description> - This is a really important function to understand correctly. AR and VR platforms all handle positioning slightly differently. - For platforms that do not offer spatial tracking our origin point (0,0,0) is the location of our HMD but you have little control over the direction the player is facing in the real world. - For platforms that do offer spatial tracking our origin point depends very much on the system. For OpenVR our origin point is usually the center of the tracking space, on the ground. For other platforms its often the location of the tracking camera. - This method allows you to create a reference frame, it will take the current location of the HMD and use that to adjust all our tracking data in essence realigning the real world to your players current position in your game world. - For this method to produce usable results tracking information should be available and this often takes a few frames after starting your game. - You should call this method after a few seconds have passed, when the user requests a realignment of the display holding a designated button on a controller for a short period of time, and when implementing a teleport mechanism. - </description> - </method> <method name="set_primary_interface"> <return type="void"> </return> diff --git a/doc/classes/RegEx.xml b/doc/classes/RegEx.xml index 626f8f1a93..4577672c72 100644 --- a/doc/classes/RegEx.xml +++ b/doc/classes/RegEx.xml @@ -5,7 +5,7 @@ </brief_description> <description> Class for finding text patterns in a string using regular expressions. It can not perform replacements. Regular expressions are a way to define patterns of text to be searched. Details on writing patterns are too long to explain here but the Internet is full of tutorials and detailed explanations. - Once created, the RegEx object needs to be compiled with the pattern before it can be used. The pattern must be escaped first for gdscript before it is escaped for the expression. For example: + Once created, the RegEx object needs to be compiled with the search pattern before it can be used. The search pattern must be escaped first for gdscript before it is escaped for the expression. For example: [code]var exp = RegEx.new()[/code] [code]exp.compile("\\d+")[/code] would be read by RegEx as [code]\d+[/code] @@ -47,7 +47,7 @@ <argument index="0" name="pattern" type="String"> </argument> <description> - Compiles and assign the regular expression pattern to use. + Compiles and assign the search pattern to use. </description> </method> <method name="get_group_count" qualifiers="const"> @@ -68,14 +68,14 @@ <return type="String"> </return> <description> - Returns the expression used to compile the code. + Returns the search pattern used to compile the code. </description> </method> <method name="is_valid" qualifiers="const"> <return type="bool"> </return> <description> - Returns whether this object has a valid regular expression assigned. + Returns whether this object has a valid search pattern assigned. </description> </method> <method name="search" qualifiers="const"> @@ -88,7 +88,7 @@ <argument index="2" name="end" type="int" default="-1"> </argument> <description> - Searches the text for the compiled pattern. Returns a [RegExMatch] container of the first matching reult if found, otherwise null. The region to search within can be specified without modifying where the start and end anchor would be. + Searches the text for the compiled pattern. Returns a [RegExMatch] container of the first matching result if found, otherwise null. The region to search within can be specified without modifying where the start and end anchor would be. </description> </method> <method name="sub" qualifiers="const"> diff --git a/doc/classes/RegExMatch.xml b/doc/classes/RegExMatch.xml index 9e021ed6c8..abf2e383d5 100644 --- a/doc/classes/RegExMatch.xml +++ b/doc/classes/RegExMatch.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="RegExMatch" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> <brief_description> + Contains the results of a regex search. </brief_description> <description> + Contains the results of a regex search. [method RegEx.search] returns an instance of [code]RegExMatch[/code] if it finds the search pattern in the [source] string. </description> <tutorials> </tutorials> @@ -15,7 +17,7 @@ <argument index="0" name="name" type="Variant" default="0"> </argument> <description> - Returns the end position of the match in the string. An integer can be specified for numeric groups or a string for named groups. Returns -1 if that group wasn't found or doesn't exist. Defaults to 0 (whole pattern). + Returns the end position of the match in the [source] string. An integer can be specified for numeric groups or a string for named groups. Returns -1 if that group wasn't found or doesn't exist. Defaults to 0 (whole pattern). </description> </method> <method name="get_group_count" qualifiers="const"> @@ -38,7 +40,7 @@ <argument index="0" name="name" type="Variant" default="0"> </argument> <description> - Returns the starting position of the match in the string. An integer can be specified for numeric groups or a string for named groups. Returns -1 if that group wasn't found or doesn't exist. Defaults to 0 (whole pattern). + Returns the starting position of the match in the [source] string. An integer can be specified for numeric groups or a string for named groups. Returns -1 if that group wasn't found or doesn't exist. Defaults to 0 (whole pattern). </description> </method> <method name="get_string" qualifiers="const"> @@ -47,19 +49,21 @@ <argument index="0" name="name" type="Variant" default="0"> </argument> <description> - Returns the result of the match in the string. An integer can be specified for numeric groups or a string for named groups. Returns -1 if that group wasn't found or doesn't exist. Defaults to 0 (whole pattern). + Returns the result of the match in the [source] string. An integer can be specified for numeric groups or a string for named groups. Returns -1 if that group wasn't found or doesn't exist. Defaults to 0 (whole pattern). </description> </method> <method name="get_strings" qualifiers="const"> <return type="Array"> </return> <description> + Returns an [Array] of the matches in the [source] string. </description> </method> <method name="get_subject" qualifiers="const"> <return type="String"> </return> <description> + Returns the [source] string used with the search pattern to find this matching result. </description> </method> </methods> diff --git a/doc/classes/VideoPlayer.xml b/doc/classes/VideoPlayer.xml index 57e417974e..bac7d1e3b0 100644 --- a/doc/classes/VideoPlayer.xml +++ b/doc/classes/VideoPlayer.xml @@ -156,6 +156,15 @@ Set the video stream for this player. </description> </method> + <method name="set_stream_position"> + <return type="void"> + </return> + <argument index="0" name="position" type="float"> + </argument> + <description> + Set the current position of the stream, in seconds. + </description> + </method> <method name="set_volume"> <return type="void"> </return> diff --git a/doc/tools/doc_status.py b/doc/tools/doc_status.py index 75e18bbe81..6b936899d8 100644 --- a/doc/tools/doc_status.py +++ b/doc/tools/doc_status.py @@ -23,6 +23,7 @@ flags = { 'o': True, 'i': False, 'a': True, + 'e': False, } flag_descriptions = { 'c': 'Toggle colors when outputting.', @@ -35,6 +36,7 @@ flag_descriptions = { 'o': 'Toggle overall column.', 'i': 'Toggle collapse of class items columns.', 'a': 'Toggle showing all items.', + 'e': 'Toggle hiding empty items.', } long_flags = { 'colors': 'c', @@ -64,6 +66,8 @@ long_flags = { 'collapse': 'i', 'all': 'a', + + 'empty': 'e', } table_columns = ['name', 'brief_description', 'description', 'methods', 'constants', 'members', 'signals'] table_column_names = ['Name', 'Brief Desc.', 'Desc.', 'Methods', 'Constants', 'Members', 'Signals'] @@ -192,6 +196,14 @@ class ClassStatus: ok = ok and self.progresses[k].is_ok() return ok + def is_empty(self): + sum = 0 + for k in self.progresses: + if self.progresses[k].is_ok(): + continue + sum += self.progresses[k].total + return sum < 1 + def make_output(self): output = {} output['name'] = color('name', self.name) @@ -396,6 +408,9 @@ for cn in filtered_classes: if (flags['b'] and status.is_ok()) or (flags['g'] and not status.is_ok()) or (not flags['a']): continue + if flags['e'] and status.is_empty(): + continue + out = status.make_output() row = [] for column in table_columns: diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index ae41a936c6..44a9909bd7 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -2473,7 +2473,7 @@ void RasterizerStorageGLES3::_update_material(Material *material) { glGenBuffers(1, &material->ubo_id); glBindBuffer(GL_UNIFORM_BUFFER, material->ubo_id); - glBufferData(GL_UNIFORM_BUFFER, material->shader->ubo_size, NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_UNIFORM_BUFFER, material->shader->ubo_size, NULL, GL_STATIC_DRAW); glBindBuffer(GL_UNIFORM_BUFFER, 0); material->ubo_size = material->shader->ubo_size; } @@ -3768,7 +3768,7 @@ void RasterizerStorageGLES3::multimesh_allocate(RID p_multimesh, int p_instances glGenBuffers(1, &multimesh->buffer); glBindBuffer(GL_ARRAY_BUFFER, multimesh->buffer); - glBufferData(GL_ARRAY_BUFFER, multimesh->data.size() * sizeof(float), NULL, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, multimesh->data.size() * sizeof(float), NULL, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); } @@ -5215,7 +5215,7 @@ void RasterizerStorageGLES3::particles_set_amount(RID p_particles, int p_amount) glBindVertexArray(particles->particle_vaos[i]); glBindBuffer(GL_ARRAY_BUFFER, particles->particle_buffers[i]); - glBufferData(GL_ARRAY_BUFFER, floats * sizeof(float), data, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, floats * sizeof(float), data, GL_STATIC_DRAW); for (int i = 0; i < 6; i++) { glEnableVertexAttribArray(i); @@ -6198,7 +6198,7 @@ void RasterizerStorageGLES3::_render_target_allocate(RenderTarget *rt) { rt->buffers.effects_active = true; } - if (!rt->flags[RENDER_TARGET_NO_SAMPLING]) { + if (!rt->flags[RENDER_TARGET_NO_SAMPLING] && rt->width >= 2 && rt->height >= 2) { for (int i = 0; i < 2; i++) { @@ -6511,7 +6511,7 @@ void RasterizerStorageGLES3::canvas_light_occluder_set_polylines(RID p_occluder, if (!co->vertex_id) { glGenBuffers(1, &co->vertex_id); glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id); - glBufferData(GL_ARRAY_BUFFER, lc * 6 * sizeof(real_t), vw.ptr(), GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, lc * 6 * sizeof(real_t), vw.ptr(), GL_STATIC_DRAW); } else { glBindBuffer(GL_ARRAY_BUFFER, co->vertex_id); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index ca68d84abd..520bf480fd 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -83,7 +83,7 @@ void CreateDialog::popup_create(bool p_dontclear) { _update_favorite_list(); // Restore valid window bounds or pop up at default size. - if (EditorSettings::get_singleton()->has("interface/dialogs/create_new_node_bounds")) { + if (EditorSettings::get_singleton()->has_setting("interface/dialogs/create_new_node_bounds")) { popup(EditorSettings::get_singleton()->get("interface/dialogs/create_new_node_bounds")); } else { popup_centered_ratio(); diff --git a/editor/editor_autoload_settings.cpp b/editor/editor_autoload_settings.cpp index efa9572bf5..ae7ed7ce61 100644 --- a/editor/editor_autoload_settings.cpp +++ b/editor/editor_autoload_settings.cpp @@ -117,7 +117,7 @@ void EditorAutoloadSettings::_autoload_add() { undo_redo->create_action(TTR("Add AutoLoad")); undo_redo->add_do_property(ProjectSettings::get_singleton(), name, "*" + path); - if (ProjectSettings::get_singleton()->has(name)) { + if (ProjectSettings::get_singleton()->has_setting(name)) { undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name)); } else { undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, Variant()); @@ -169,7 +169,7 @@ void EditorAutoloadSettings::_autoload_edited() { return; } - if (ProjectSettings::get_singleton()->has("autoload/" + name)) { + if (ProjectSettings::get_singleton()->has_setting("autoload/" + name)) { ti->set_text(0, old_name); EditorNode::get_singleton()->show_warning(vformat(TTR("Autoload '%s' already exists!"), name)); return; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index db12998dd2..bc20a99809 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -1141,6 +1141,12 @@ void EditorExportPlatformPC::get_preset_features(const Ref<EditorExportPreset> & if (p_preset->get("texture_format/etc2")) { r_features->push_back("etc2"); } + + if (p_preset->get("binary_format/64_bits")) { + r_features->push_back("64"); + } else { + r_features->push_back("32"); + } } void EditorExportPlatformPC::get_export_options(List<ExportOption> *r_options) { diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 481f2a8179..4ae786391b 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1383,7 +1383,7 @@ void EditorFileSystem::_reimport_file(const String &p_file) { } } - if (load_default && ProjectSettings::get_singleton()->has("importer_defaults/" + importer->get_importer_name())) { + if (load_default && ProjectSettings::get_singleton()->has_setting("importer_defaults/" + importer->get_importer_name())) { //use defaults if exist Dictionary d = ProjectSettings::get_singleton()->get("importer_defaults/" + importer->get_importer_name()); List<Variant> v; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index a04ded7b5b..4e0ad38320 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -5613,7 +5613,7 @@ EditorNode::EditorNode() { { _initializing_addons = true; Vector<String> addons; - if (ProjectSettings::get_singleton()->has("editor_plugins/enabled")) { + if (ProjectSettings::get_singleton()->has_setting("editor_plugins/enabled")) { addons = ProjectSettings::get_singleton()->get("editor_plugins/enabled"); } diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 1b6b66c198..84b0917c78 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -195,7 +195,17 @@ void EditorSettings::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::ARRAY, "shortcuts", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR)); //do not edit } -bool EditorSettings::has(String p_var) const { +void EditorSettings::set_setting(const String &p_setting, const Variant &p_value) { + _THREAD_SAFE_METHOD_ + set(p_setting, p_value); +} + +Variant EditorSettings::get_setting(const String &p_setting) const { + _THREAD_SAFE_METHOD_ + return get(p_setting); +} + +bool EditorSettings::has_setting(String p_var) const { _THREAD_SAFE_METHOD_ @@ -218,7 +228,7 @@ void EditorSettings::raise_order(const String &p_name) { Variant _EDITOR_DEF(const String &p_var, const Variant &p_default) { - if (EditorSettings::get_singleton()->has(p_var)) + if (EditorSettings::get_singleton()->has_setting(p_var)) return EditorSettings::get_singleton()->get(p_var); EditorSettings::get_singleton()->set(p_var, p_default); EditorSettings::get_singleton()->set_initial_value(p_var, p_default); @@ -228,7 +238,7 @@ Variant _EDITOR_DEF(const String &p_var, const Variant &p_default) { Variant _EDITOR_GET(const String &p_var) { - ERR_FAIL_COND_V(!EditorSettings::get_singleton()->has(p_var), Variant()) + ERR_FAIL_COND_V(!EditorSettings::get_singleton()->has_setting(p_var), Variant()) return EditorSettings::get_singleton()->get(p_var); } @@ -471,8 +481,8 @@ void EditorSettings::setup_network() { IP::get_singleton()->get_local_addresses(&local_ip); String lip = "127.0.0.1"; String hint; - String current = has("network/debug/remote_host") ? get("network/debug/remote_host") : ""; - int port = has("network/debug/remote_port") ? (int)get("network/debug/remote_port") : 6007; + String current = has_setting("network/debug/remote_host") ? get("network/debug/remote_host") : ""; + int port = has_setting("network/debug/remote_port") ? (int)get("network/debug/remote_port") : 6007; for (List<IP_Address>::Element *E = local_ip.front(); E; E = E->next()) { @@ -989,7 +999,7 @@ void EditorSettings::load_text_editor_theme() { String val = cf->get_value("color_theme", key); // don't load if it's not already there! - if (has("text_editor/highlighting/" + key)) { + if (has_setting("text_editor/highlighting/" + key)) { // make sure it is actually a color if (val.is_valid_html_color() && key.find("color") >= 0) { @@ -1194,6 +1204,10 @@ void EditorSettings::set_initial_value(const StringName &p_name, const Variant & void EditorSettings::_bind_methods() { + ClassDB::bind_method(D_METHOD("has_setting", "name"), &EditorSettings::has_setting); + ClassDB::bind_method(D_METHOD("set_setting", "name", "value"), &EditorSettings::set_setting); + ClassDB::bind_method(D_METHOD("get_setting", "name"), &EditorSettings::get_setting); + ClassDB::bind_method(D_METHOD("erase", "property"), &EditorSettings::erase); ClassDB::bind_method(D_METHOD("get_settings_path"), &EditorSettings::get_settings_path); ClassDB::bind_method(D_METHOD("get_project_settings_path"), &EditorSettings::get_project_settings_path); @@ -1211,6 +1225,8 @@ void EditorSettings::_bind_methods() { ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value"), &EditorSettings::set_initial_value); + ClassDB::bind_method(D_METHOD("set_favorite_dirs", "dirs"), &EditorSettings::set_favorite_dirs); + ADD_SIGNAL(MethodInfo("settings_changed")); } diff --git a/editor/editor_settings.h b/editor/editor_settings.h index 19cf367d57..c5d2670650 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -129,7 +129,11 @@ public: void set_manually(const StringName &p_name, const Variant &p_value, bool p_emit_signal = false) { _set(p_name, p_value, p_emit_signal); } - bool has(String p_var) const; + + void set_setting(const String &p_setting, const Variant &p_value); + Variant get_setting(const String &p_setting) const; + + bool has_setting(String p_var) const; static EditorSettings *get_singleton(); void erase(String p_var); String get_settings_path() const; diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 112e3abcb5..77fd6d883a 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -137,7 +137,7 @@ void ImportDock::set_edit_path(const String &p_path) { preset->get_popup()->add_separator(); preset->get_popup()->add_item(vformat(TTR("Set as Default for '%s'"), params->importer->get_visible_name()), ITEM_SET_AS_DEFAULT); - if (ProjectSettings::get_singleton()->has("importer_defaults/" + params->importer->get_importer_name())) { + if (ProjectSettings::get_singleton()->has_setting("importer_defaults/" + params->importer->get_importer_name())) { preset->get_popup()->add_item(TTR("Load Default"), ITEM_LOAD_DEFAULT); preset->get_popup()->add_separator(); preset->get_popup()->add_item(vformat(TTR("Clear Default for '%s'"), params->importer->get_visible_name()), ITEM_CLEAR_DEFAULT); @@ -281,7 +281,7 @@ void ImportDock::_preset_selected(int p_idx) { } break; case ITEM_LOAD_DEFAULT: { - ERR_FAIL_COND(!ProjectSettings::get_singleton()->has("importer_defaults/" + params->importer->get_importer_name())); + ERR_FAIL_COND(!ProjectSettings::get_singleton()->has_setting("importer_defaults/" + params->importer->get_importer_name())); Dictionary d = ProjectSettings::get_singleton()->get("importer_defaults/" + params->importer->get_importer_name()); List<Variant> v; diff --git a/editor/project_export.cpp b/editor/project_export.cpp index fafd6805ca..e5b6f8e406 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -71,7 +71,7 @@ void ProjectExportDialog::popup_export() { _update_presets(); // Restore valid window bounds or pop up at default size. - if (EditorSettings::get_singleton()->has("interface/dialogs/export_bounds")) { + if (EditorSettings::get_singleton()->has_setting("interface/dialogs/export_bounds")) { popup(EditorSettings::get_singleton()->get("interface/dialogs/export_bounds")); } else { popup_centered_ratio(); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 1a767dad05..1fb3fb2ed1 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -506,7 +506,7 @@ public: if (current->setup(project_path->get_text(), "")) { set_message(TTR("Couldn't get project.godot in the project path."), MESSAGE_ERROR); - } else if (current->has("application/config/name")) { + } else if (current->has_setting("application/config/name")) { project_name->set_text(current->get("application/config/name")); } project_name->grab_focus(); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 56e593e34b..91ef9e36f3 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -146,7 +146,7 @@ void ProjectSettingsEditor::_action_edited() { String action_prop = "input/" + new_name; - if (ProjectSettings::get_singleton()->has(action_prop)) { + if (ProjectSettings::get_singleton()->has_setting(action_prop)) { ti->set_text(0, old_name); add_at = "input/" + old_name; @@ -707,7 +707,7 @@ void ProjectSettingsEditor::_update_actions() { void ProjectSettingsEditor::popup_project_settings() { // Restore valid window bounds or pop up at default size. - if (EditorSettings::get_singleton()->has("interface/dialogs/project_settings_bounds")) { + if (EditorSettings::get_singleton()->has_setting("interface/dialogs/project_settings_bounds")) { popup(EditorSettings::get_singleton()->get("interface/dialogs/project_settings_bounds")); } else { popup_centered_ratio(); @@ -753,7 +753,7 @@ void ProjectSettingsEditor::_item_add() { undo_redo->add_do_property(ProjectSettings::get_singleton(), name, value); - if (ProjectSettings::get_singleton()->has(name)) { + if (ProjectSettings::get_singleton()->has_setting(name)) { undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, ProjectSettings::get_singleton()->get(name)); } else { undo_redo->add_undo_property(ProjectSettings::get_singleton(), name, Variant()); @@ -782,7 +782,7 @@ void ProjectSettingsEditor::_item_del() { String property = globals_editor->get_current_section().plus_file(path); - if (!ProjectSettings::get_singleton()->has(property)) { + if (!ProjectSettings::get_singleton()->has_setting(property)) { EditorNode::get_singleton()->show_warning(TTR("No property '" + property + "' exists.")); return; } @@ -823,7 +823,7 @@ void ProjectSettingsEditor::_action_check(String p_action) { action_add->set_disabled(true); return; } - if (ProjectSettings::get_singleton()->has("input/" + p_action)) { + if (ProjectSettings::get_singleton()->has_setting("input/" + p_action)) { action_add->set_text(TTR("Already existing")); action_add->set_disabled(true); return; @@ -907,6 +907,8 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() { presets.insert("pvrtc"); presets.insert("debug"); presets.insert("release"); + presets.insert("32"); + presets.insert("64"); for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { List<String> p; @@ -963,7 +965,7 @@ void ProjectSettingsEditor::_copy_to_platform(int p_which) { String new_path = property + "." + feature; undo_redo->add_do_method(ProjectSettings::get_singleton(), "set", new_path, value); - if (ProjectSettings::get_singleton()->has(new_path)) { + if (ProjectSettings::get_singleton()->has_setting(new_path)) { undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set", new_path, ProjectSettings::get_singleton()->get(new_path)); } @@ -1040,7 +1042,7 @@ void ProjectSettingsEditor::_translation_res_add(const String &p_path) { Variant prev; Dictionary remaps; - if (ProjectSettings::get_singleton()->has("locale/translation_remaps")) { + if (ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) { remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); prev = remaps; } @@ -1066,7 +1068,7 @@ void ProjectSettingsEditor::_translation_res_option_file_open() { } void ProjectSettingsEditor::_translation_res_option_add(const String &p_path) { - ERR_FAIL_COND(!ProjectSettings::get_singleton()->has("locale/translation_remaps")); + ERR_FAIL_COND(!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")); Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); @@ -1103,7 +1105,7 @@ void ProjectSettingsEditor::_translation_res_option_changed() { if (updating_translations) return; - if (!ProjectSettings::get_singleton()->has("locale/translation_remaps")) + if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) return; Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); @@ -1145,7 +1147,7 @@ void ProjectSettingsEditor::_translation_res_delete(Object *p_item, int p_column if (updating_translations) return; - if (!ProjectSettings::get_singleton()->has("locale/translation_remaps")) + if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) return; Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); @@ -1172,7 +1174,7 @@ void ProjectSettingsEditor::_translation_res_option_delete(Object *p_item, int p if (updating_translations) return; - if (!ProjectSettings::get_singleton()->has("locale/translation_remaps")) + if (!ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) return; Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); @@ -1213,7 +1215,7 @@ void ProjectSettingsEditor::_update_translations() { translation_list->clear(); TreeItem *root = translation_list->create_item(NULL); translation_list->set_hide_root(true); - if (ProjectSettings::get_singleton()->has("locale/translations")) { + if (ProjectSettings::get_singleton()->has_setting("locale/translations")) { PoolStringArray translations = ProjectSettings::get_singleton()->get("locale/translations"); for (int i = 0; i < translations.size(); i++) { @@ -1251,7 +1253,7 @@ void ProjectSettingsEditor::_update_translations() { langnames += names[i]; } - if (ProjectSettings::get_singleton()->has("locale/translation_remaps")) { + if (ProjectSettings::get_singleton()->has_setting("locale/translation_remaps")) { Dictionary remaps = ProjectSettings::get_singleton()->get("locale/translation_remaps"); List<Variant> rk; diff --git a/editor/settings_config_dialog.cpp b/editor/settings_config_dialog.cpp index 5f6ffcb14e..86979a1174 100644 --- a/editor/settings_config_dialog.cpp +++ b/editor/settings_config_dialog.cpp @@ -93,7 +93,7 @@ void EditorSettingsDialog::popup_edit_settings() { _update_shortcuts(); // Restore valid window bounds or pop up at default size. - if (EditorSettings::get_singleton()->has("interface/dialogs/editor_settings_bounds")) { + if (EditorSettings::get_singleton()->has_setting("interface/dialogs/editor_settings_bounds")) { popup(EditorSettings::get_singleton()->get("interface/dialogs/editor_settings_bounds")); } else { popup_centered_ratio(0.7); diff --git a/main/main.cpp b/main/main.cpp index 48df37ac63..e06f423bfc 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -726,7 +726,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph #ifdef TOOLS_ENABLED - if (main_args.size() == 0 && (!ProjectSettings::get_singleton()->has("application/run/main_loop_type")) && (!ProjectSettings::get_singleton()->has("application/run/main_scene") || String(ProjectSettings::get_singleton()->get("application/run/main_scene")) == "")) + if (main_args.size() == 0 && (!ProjectSettings::get_singleton()->has_setting("application/run/main_loop_type")) && (!ProjectSettings::get_singleton()->has_setting("application/run/main_scene") || String(ProjectSettings::get_singleton()->get("application/run/main_scene")) == "")) use_custom_res = false; //project manager (run without arguments) #endif @@ -739,21 +739,21 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph //if (video_driver == "") // useless for now, so removing // video_driver = GLOBAL_DEF("display/driver/name", Variant((const char *)OS::get_singleton()->get_video_driver_name(0))); - if (!force_res && use_custom_res && globals->has("display/window/size/width")) + if (!force_res && use_custom_res && globals->has_setting("display/window/size/width")) video_mode.width = globals->get("display/window/size/width"); - if (!force_res && use_custom_res && globals->has("display/window/size/height")) + if (!force_res && use_custom_res && globals->has_setting("display/window/size/height")) video_mode.height = globals->get("display/window/size/height"); - if (!editor && ((globals->has("display/window/dpi/allow_hidpi") && !globals->get("display/window/dpi/allow_hidpi")) || force_lowdpi)) { + if (!editor && ((globals->has_setting("display/window/dpi/allow_hidpi") && !globals->get("display/window/dpi/allow_hidpi")) || force_lowdpi)) { OS::get_singleton()->_allow_hidpi = false; } - if (use_custom_res && globals->has("display/window/size/fullscreen")) + if (use_custom_res && globals->has_setting("display/window/size/fullscreen")) video_mode.fullscreen = globals->get("display/window/size/fullscreen"); - if (use_custom_res && globals->has("display/window/size/resizable")) + if (use_custom_res && globals->has_setting("display/window/size/resizable")) video_mode.resizable = globals->get("display/window/size/resizable"); - if (use_custom_res && globals->has("display/window/size/borderless")) + if (use_custom_res && globals->has_setting("display/window/size/borderless")) video_mode.borderless_window = globals->get("display/window/size/borderless"); - if (!force_res && use_custom_res && globals->has("display/window/size/test_width") && globals->has("display/window/size/test_height")) { + if (!force_res && use_custom_res && globals->has_setting("display/window/size/test_width") && globals->has_setting("display/window/size/test_height")) { int tw = globals->get("display/window/size/test_width"); int th = globals->get("display/window/size/test_height"); if (tw > 0 && th > 0) { @@ -774,6 +774,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation", 2); GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation.mobile", 3); + if (editor) { + OS::get_singleton()->_allow_hidpi = true; //editors always in hidpi + } Engine::get_singleton()->_pixel_snap = GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false); OS::get_singleton()->_keep_screen_on = GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true); if (rtm == -1) { diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub index 31178be973..be0975b53c 100644 --- a/modules/gdnative/SCsub +++ b/modules/gdnative/SCsub @@ -10,7 +10,6 @@ gdn_env.add_source_files(env.modules_sources, "register_types.cpp") gdn_env.add_source_files(env.modules_sources, "gdnative/*.cpp") gdn_env.add_source_files(env.modules_sources, "nativescript/*.cpp") -gdn_env.Append(CPPFLAGS=['-DGDAPI_BUILT_IN']) gdn_env.Append(CPPPATH=['#modules/gdnative/include/']) def _spaced(e): @@ -25,11 +24,15 @@ def _build_gdnative_api_struct_header(api): '#include <gdnative/gdnative.h>', '#include <nativescript/godot_nativescript.h>', '', + '#define GDNATIVE_API_INIT(options) do { extern const godot_gdnative_api_struct *_gdnative_wrapper_api_struct; _gdnative_wrapper_api_struct = options->api_struct; } while (0)', + '', '#ifdef __cplusplus', 'extern "C" {', '#endif', '', - 'typedef struct godot_gdnative_api_struct {' + 'typedef struct godot_gdnative_api_struct {', + '\tvoid *next;', + '\tconst char *version;', ] for funcname, funcdef in api['api'].items(): @@ -54,7 +57,10 @@ def _build_gdnative_api_struct_source(api): '', '#include <gdnative_api_struct.gen.h>', '', - 'extern const godot_gdnative_api_struct api_struct = {' + 'const char *_gdnative_api_version = "%s";' % api['version'], + 'extern const godot_gdnative_api_struct api_struct = {', + '\tNULL,', + '\t_gdnative_api_version,', ] for funcname in api['api'].keys(): @@ -81,7 +87,68 @@ _, gensource = gdn_env.Command(['include/gdnative_api_struct.gen.h', 'gdnative_a 'gdnative_api.json', build_gdnative_api_struct) gdn_env.add_source_files(env.modules_sources, [gensource]) -if "platform" in env and env["platform"] in ["x11", "iphone"]: - env.Append(LINKFLAGS=["-rdynamic"]) - env.use_ptrcall = True + + +def _build_gdnative_wrapper_code(api): + out = [ + '/* THIS FILE IS GENERATED DO NOT EDIT */', + '', + '#include <gdnative/gdnative.h>', + '#include <nativescript/godot_nativescript.h>', + '', + '#include <gdnative_api_struct.gen.h>', + '', + 'godot_gdnative_api_struct *_gdnative_wrapper_api_struct = 0;', + '', + '#ifdef __cplusplus', + 'extern "C" {', + '#endif', + '' + ] + + for funcname, funcdef in api['api'].items(): + args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) + out.append('%s %s(%s) {' % (_spaced(funcdef['return_type']), funcname, args)) + + args = ', '.join(['%s' % n for t, n in funcdef['arguments']]) + + return_line = '\treturn ' if funcdef['return_type'] != 'void' else '\t' + return_line += '_gdnative_wrapper_api_struct->' + funcname + '(' + args + ');' + + out.append(return_line) + out.append('}') + out.append('') + + out += [ + '#ifdef __cplusplus', + '}', + '#endif' + ] + + return '\n'.join(out) + + +def build_gdnative_wrapper_code(target, source, env): + import json + with open(source[0].path, 'r') as fd: +#Keep the json ordered + api = json.load(fd) + + wrapper_file = target[0] + with open(wrapper_file.path, 'w') as fd: + fd.write(_build_gdnative_wrapper_code(api)) + + + +if ARGUMENTS.get('gdnative_wrapper', False): + #build wrapper code + gdn_env.Command('gdnative_wrapper_code.gen.cpp', 'gdnative_api.json', build_gdnative_wrapper_code) + + gd_wrapper_env = env.Clone() + gd_wrapper_env.Append(CPPPATH=['#modules/gdnative/include/']) + + # I think this doesn't work on MSVC yet... + gd_wrapper_env.Append(CCFLAGS=['-fPIC']) + + gd_wrapper_env.Library("#bin/gdnative_wrapper_code", ["#modules/gdnative/gdnative_wrapper_code.gen.cpp"]) diff --git a/modules/gdnative/gd_native_library_editor.cpp b/modules/gdnative/gd_native_library_editor.cpp index cc2c2b69a6..c37b7f473d 100644 --- a/modules/gdnative/gd_native_library_editor.cpp +++ b/modules/gdnative/gd_native_library_editor.cpp @@ -72,7 +72,7 @@ void GDNativeLibraryEditor::_update_libraries() { libraries->create_item(); //rppt Vector<String> enabled_paths; - if (ProjectSettings::get_singleton()->has("gdnative/singletons")) { + if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) { enabled_paths = ProjectSettings::get_singleton()->get("gdnative/singletons"); } Set<String> enabled_list; @@ -100,7 +100,7 @@ void GDNativeLibraryEditor::_item_edited() { String path = item->get_metadata(0); Vector<String> enabled_paths; - if (ProjectSettings::get_singleton()->has("gdnative/singletons")) { + if (ProjectSettings::get_singleton()->has_setting("gdnative/singletons")) { enabled_paths = ProjectSettings::get_singleton()->get("gdnative/singletons"); } diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 9e66f6952b..8b6593c9c3 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -3334,7 +3334,7 @@ "arguments": [ ["godot_variant *", "p_self"], ["const godot_string *", "p_method"], - ["const godot_variant *", "*p_args"], + ["const godot_variant **", "p_args"], ["const godot_int", "p_argcount"], ["godot_variant_call_error *", "r_error"] ] @@ -3889,7 +3889,7 @@ "return_type": "double", "arguments": [ ["const wchar_t *", "p_str"], - ["const wchar_t *", "*r_end"] + ["const wchar_t **", "r_end"] ] }, "godot_string_get_slice_count": { @@ -4390,7 +4390,7 @@ "arguments": [ ["godot_method_bind *", "p_method_bind"], ["godot_object *", "p_instance"], - ["const void *", "*p_args"], + ["const void **", "p_args"], ["void *", "p_ret"] ] }, @@ -4399,7 +4399,7 @@ "arguments": [ ["godot_method_bind *", "p_method_bind"], ["godot_object *", "p_instance"], - ["const godot_variant *", "*p_args"], + ["const godot_variant **", "p_args"], ["const int", "p_arg_count"], ["godot_variant_call_error *", "p_call_error"] ] diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h index 9134f1c581..008968a5e5 100644 --- a/modules/gdnative/include/gdnative/gdnative.h +++ b/modules/gdnative/include/gdnative/gdnative.h @@ -34,18 +34,9 @@ extern "C" { #endif -#ifdef GDAPI_BUILT_IN -#define GDAPI_EXPORT -#endif - #ifdef _WIN32 -#if defined(GDAPI_EXPORT) -#define GDCALLINGCONV -#define GDAPI __declspec(dllexport) GDCALLINGCONV -#else #define GDCALLINGCONV -#define GDAPI __declspec(dllimport) GDCALLINGCONV -#endif +#define GDAPI GDCALLINGCONV #elif defined(__APPLE__) #include "TargetConditionals.h" #if TARGET_OS_IPHONE diff --git a/modules/gdnative/include/nativescript/godot_nativescript.h b/modules/gdnative/include/nativescript/godot_nativescript.h index 5095b7a83e..8baff0fff9 100644 --- a/modules/gdnative/include/nativescript/godot_nativescript.h +++ b/modules/gdnative/include/nativescript/godot_nativescript.h @@ -36,42 +36,6 @@ extern "C" { #endif -#ifdef GDAPI_BUILT_IN -#define GDAPI_EXPORT -#endif - -#ifdef _WIN32 -#if defined(GDAPI_EXPORT) -#define GDCALLINGCONV -#define GDAPI __declspec(dllexport) GDCALLINGCONV -#else -#define GDCALLINGCONV -#define GDAPI __declspec(dllimport) GDCALLINGCONV -#endif -#elif defined(__APPLE__) -#include "TargetConditionals.h" -#if TARGET_OS_IPHONE -#define GDCALLINGCONV __attribute__((visibility("default"))) -#define GDAPI GDCALLINGCONV -#elif TARGET_OS_MAC -#define GDCALLINGCONV __attribute__((sysv_abi)) -#define GDAPI GDCALLINGCONV -#endif -#else -#define GDCALLINGCONV __attribute__((sysv_abi, visibility("default"))) -#define GDAPI GDCALLINGCONV -#endif - -// This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!! -#ifdef _WIN32 -#define GDN_EXPORT __declspec(dllexport) -#else -#define GDN_EXPORT -#endif - -#include <stdbool.h> -#include <stdint.h> - typedef enum { GODOT_METHOD_RPC_MODE_DISABLED, GODOT_METHOD_RPC_MODE_REMOTE, diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gd_function.cpp index 9df2823c35..ce503b62f2 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gd_function.cpp @@ -1578,7 +1578,7 @@ void GDFunctionState::_bind_methods() { ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDFunctionState::is_valid, DEFVAL(false)); ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDFunctionState::_signal_callback, MethodInfo("_signal_callback")); - ADD_SIGNAL(MethodInfo("completed", PropertyInfo(Variant::NIL, "result"))); + ADD_SIGNAL(MethodInfo("completed", PropertyInfo(Variant::NIL, "result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT))); } GDFunctionState::GDFunctionState() { diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index 4f7545a11d..4e8b67e4e8 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -769,6 +769,8 @@ void GridMap::_bind_methods() { ClassDB::bind_method(D_METHOD("clear"), &GridMap::clear); + ClassDB::bind_method(D_METHOD("get_used_cells"), &GridMap::get_used_cells); + ClassDB::bind_method(D_METHOD("get_meshes"), &GridMap::get_meshes); BIND_CONSTANT(INVALID_CELL_ITEM); @@ -807,6 +809,19 @@ float GridMap::get_cell_scale() const { return cell_scale; } +Array GridMap::get_used_cells() const { + + Array a; + a.resize(cell_map.size()); + int i = 0; + for (Map<IndexKey, Cell>::Element *E = cell_map.front(); E; E = E->next()) { + Vector3 p(E->key().x, E->key().y, E->key().z); + a[i++] = p; + } + + return a; +} + Array GridMap::get_meshes() { if (theme.is_null()) diff --git a/modules/gridmap/grid_map.h b/modules/gridmap/grid_map.h index eb1b215696..296956ff5d 100644 --- a/modules/gridmap/grid_map.h +++ b/modules/gridmap/grid_map.h @@ -223,6 +223,8 @@ public: void set_cell_scale(float p_scale); float get_cell_scale() const; + Array get_used_cells() const; + Array get_meshes(); void clear(); diff --git a/modules/mobile_vr/config.py b/modules/mobile_vr/config.py index d0156b1b77..cf96c66125 100644 --- a/modules/mobile_vr/config.py +++ b/modules/mobile_vr/config.py @@ -3,4 +3,10 @@ def can_build(platform): return True def configure(env): - pass
\ No newline at end of file + pass + +def get_doc_classes(): + return ["MobileVRInterface"] + +def get_doc_path(): + return "doc_classes" diff --git a/modules/mobile_vr/doc_classes/MobileVRInterface.xml b/modules/mobile_vr/doc_classes/MobileVRInterface.xml new file mode 100644 index 0000000000..c945a99a9a --- /dev/null +++ b/modules/mobile_vr/doc_classes/MobileVRInterface.xml @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="MobileVRInterface" inherits="ARVRInterface" category="Core" version="3.0.alpha.custom_build"> + <brief_description> + Generic mobile VR implementation + </brief_description> + <description> + This is a generic mobile VR implementation where you need to provide details about the phone and HMD used. It does not rely on any existing framework. This is the most basic interface we have. For the best effect you do need a mobile phone with a gyroscope and accelerometer. + Note that even though there is no positional tracking the camera will assume the headset is at a height of 1.85 meters. + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + <method name="get_display_to_lens" qualifiers="const"> + <return type="float"> + </return> + <description> + Returns the distance between the display and the lens. + </description> + </method> + <method name="get_display_width" qualifiers="const"> + <return type="float"> + </return> + <description> + Return the width of the LCD screen of the device. + </description> + </method> + <method name="get_iod" qualifiers="const"> + <return type="float"> + </return> + <description> + Returns the interocular distance. + </description> + </method> + <method name="get_k1" qualifiers="const"> + <return type="float"> + </return> + <description> + Returns the k1 lens constant. + </description> + </method> + <method name="get_k2" qualifiers="const"> + <return type="float"> + </return> + <description> + Retuns the k2 lens constant + </description> + </method> + <method name="get_oversample" qualifiers="const"> + <return type="float"> + </return> + <description> + Returns the oversampling setting. + </description> + </method> + <method name="set_display_to_lens"> + <return type="void"> + </return> + <argument index="0" name="display_to_lens" type="float"> + </argument> + <description> + Sets the distance between display and the lens. + </description> + </method> + <method name="set_display_width"> + <return type="void"> + </return> + <argument index="0" name="display_width" type="float"> + </argument> + <description> + Sets the width of the LCD screen of the device. + </description> + </method> + <method name="set_iod"> + <return type="void"> + </return> + <argument index="0" name="iod" type="float"> + </argument> + <description> + Sets the interocular distance. + </description> + </method> + <method name="set_k1"> + <return type="void"> + </return> + <argument index="0" name="k" type="float"> + </argument> + <description> + Sets the k1 lens constant. + </description> + </method> + <method name="set_k2"> + <return type="void"> + </return> + <argument index="0" name="k" type="float"> + </argument> + <description> + Sets the k2 lens constant. + </description> + </method> + <method name="set_oversample"> + <return type="void"> + </return> + <argument index="0" name="oversample" type="float"> + </argument> + <description> + Sets the oversampling setting. + </description> + </method> + </methods> + <members> + <member name="display_to_lens" type="float" setter="set_display_to_lens" getter="get_display_to_lens"> + The distance between the display and the lenses inside of the device in centimeters. + </member> + <member name="display_width" type="float" setter="set_display_width" getter="get_display_width"> + The width of the display in centimeters. + </member> + <member name="iod" type="float" setter="set_iod" getter="get_iod"> + The interocular distance, also known as the interpupillary distance. The distance between the pupils of the left and right eye. + </member> + <member name="k1" type="float" setter="set_k1" getter="get_k1"> + The k1 lens factor is one of the two constants that define the strength of the lens used and directly influences the lens distortion effect. + </member> + <member name="k2" type="float" setter="set_k2" getter="get_k2"> + The k2 lens factor, see k1. + </member> + <member name="oversample" type="float" setter="set_oversample" getter="get_oversample"> + The oversample setting. Because of the lens distortion we have to render our buffers at a higher resolution then the screen can natively handle. A value between 1.5 and 2.0 often provides good results but at the cost of performance. + </member> + </members> + <constants> + </constants> +</class> diff --git a/modules/mobile_vr/mobile_interface.cpp b/modules/mobile_vr/mobile_interface.cpp index f5c9bccaba..eb87bb2cf0 100644 --- a/modules/mobile_vr/mobile_interface.cpp +++ b/modules/mobile_vr/mobile_interface.cpp @@ -37,6 +37,10 @@ StringName MobileVRInterface::get_name() const { return "Native mobile"; }; +int MobileVRInterface::get_capabilities() const { + return ARVRInterface::ARVR_STEREO; +}; + Vector3 MobileVRInterface::scale_magneto(const Vector3 &p_magnetometer) { // Our magnetometer doesn't give us nice clean data. // Well it may on Mac OS X because we're getting a calibrated value in the current implementation but Android we're getting raw data. @@ -166,6 +170,8 @@ void MobileVRInterface::set_position_from_sensors() { rotate.rotate(orientation.get_axis(1), gyro.y * delta_time); rotate.rotate(orientation.get_axis(2), gyro.z * delta_time); orientation = rotate * orientation; + + tracking_state = ARVRInterface::ARVR_NORMAL_TRACKING; }; ///@TODO improve this, the magnetometer is very fidgity sometimes flipping the axis for no apparent reason (probably a bug on my part) @@ -176,6 +182,8 @@ void MobileVRInterface::set_position_from_sensors() { Quat acc_mag_quat(combine_acc_mag(grav, magneto)); transform_quat = transform_quat.slerp(acc_mag_quat, 0.1); orientation = Basis(transform_quat); + + tracking_state = ARVRInterface::ARVR_NORMAL_TRACKING; } else if (has_grav) { // use gravity vector to make sure down is down... // transform gravity into our world space @@ -273,21 +281,6 @@ real_t MobileVRInterface::get_k2() const { return k2; }; -bool MobileVRInterface::is_installed() { - // we don't have any middle ware here, if we have our interface, we can use it - return true; -}; - -bool MobileVRInterface::hmd_is_present() { - // our device is our HMD - return true; -}; - -bool MobileVRInterface::supports_hmd() { - // our device is our HMD - return true; -}; - bool MobileVRInterface::is_stereo() { // needs stereo... return true; @@ -461,11 +454,11 @@ MobileVRInterface::MobileVRInterface() { // Just set some defaults for these. At some point we need to look at adding a lookup table for common device + headset combos and/or support reading cardboard QR codes eye_height = 1.85; intraocular_dist = 6.0; - display_width = 13.0; + display_width = 14.5; display_to_lens = 4.0; oversample = 1.5; - k1 = 0.22; - k2 = 0.23; + k1 = 0.215; + k2 = 0.215; last_ticks = 0; // create our shader stuff diff --git a/modules/mobile_vr/mobile_interface.h b/modules/mobile_vr/mobile_interface.h index dfe3cd200e..6a5e01c163 100644 --- a/modules/mobile_vr/mobile_interface.h +++ b/modules/mobile_vr/mobile_interface.h @@ -131,10 +131,7 @@ public: real_t get_k2() const; virtual StringName get_name() const; - - virtual bool is_installed(); - virtual bool hmd_is_present(); - virtual bool supports_hmd(); + virtual int get_capabilities() const; virtual bool is_initialized(); virtual bool initialize(); diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 67b4e67e2b..5301ea72b4 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -50,6 +50,21 @@ #define CACHED_STRING_NAME(m_var) (CSharpLanguage::get_singleton()->string_names.m_var) +static bool _create_project_solution_if_needed() { + + String sln_path = GodotSharpDirs::get_project_sln_path(); + String csproj_path = GodotSharpDirs::get_project_csproj_path(); + + if (!FileAccess::exists(sln_path) || !FileAccess::exists(csproj_path)) { + // A solution does not yet exist, create a new one + + CRASH_COND(GodotSharpEditor::get_singleton() == NULL); + return GodotSharpEditor::get_singleton()->call("_create_project_solution"); + } + + return true; +} + CSharpLanguage *CSharpLanguage::singleton = NULL; String CSharpLanguage::get_name() const { @@ -1359,7 +1374,18 @@ Ref<CSharpScript> CSharpScript::create_for_managed_type(GDMonoClass *p_class) { bool CSharpScript::can_instance() const { - // TODO does the second condition even make sense? +#ifdef TOOLS_ENABLED + if (Engine::get_singleton()->is_editor_hint()) { + if (_create_project_solution_if_needed()) { + CSharpProject::add_item(GodotSharpDirs::get_project_csproj_path(), + "Compile", + ProjectSettings::get_singleton()->globalize_path(get_path())); + } else { + ERR_PRINTS("Cannot add " + get_path() + " to the C# project because it could not be created."); + } + } +#endif + return valid || (!tool && !ScriptServer::is_scripting_enabled()); } @@ -1545,6 +1571,18 @@ Error CSharpScript::reload(bool p_keep_state) { if (project_assembly) { script_class = project_assembly->get_object_derived_class(name); + + if (!script_class) { + ERR_PRINTS("Cannot find class " + name + " for script " + get_path()); + } +#ifdef DEBUG_ENABLED + else if (OS::get_singleton()->is_stdout_verbose()) { + OS::get_singleton()->print(String("Found class " + script_class->get_namespace() + "." + + script_class->get_name() + " for script " + get_path() + "\n") + .utf8()); + } +#endif + valid = script_class != NULL; if (script_class) { @@ -1791,21 +1829,12 @@ Error ResourceFormatSaverCSharpScript::save(const String &p_path, const RES &p_r if (!FileAccess::exists(p_path)) { // The file does not yet exists, let's assume the user just created this script - String sln_path = GodotSharpDirs::get_project_sln_path(); - String csproj_path = GodotSharpDirs::get_project_csproj_path(); - - if (!FileAccess::exists(sln_path) || !FileAccess::exists(csproj_path)) { - // A solution does not yet exist, create a new one - - CRASH_COND(GodotSharpEditor::get_singleton() == NULL); - GodotSharpEditor::get_singleton()->call("_create_project_solution"); - } - - // Add the file to the C# project - if (FileAccess::exists(csproj_path)) { - CSharpProject::add_item(csproj_path, "Compile", ProjectSettings::get_singleton()->globalize_path(p_path)); + if (_create_project_solution_if_needed()) { + CSharpProject::add_item(GodotSharpDirs::get_project_csproj_path(), + "Compile", + ProjectSettings::get_singleton()->globalize_path(p_path)); } else { - ERR_PRINT("C# project not found!"); + ERR_PRINTS("Cannot add " + p_path + " to the C# project because it could not be created."); } } #endif diff --git a/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs b/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs index 256e64ddde..329b6d2008 100644 --- a/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs +++ b/modules/mono/editor/GodotSharpTools/Build/BuildSystem.cs @@ -19,7 +19,15 @@ namespace GodotSharpTools.Build private static string MSBuildPath { - get { return godot_icall_BuildInstance_get_MSBuildPath(); } + get + { + string ret = godot_icall_BuildInstance_get_MSBuildPath(); + + if (ret == null) + throw new FileNotFoundException("Cannot find the MSBuild executable."); + + return ret; + } } private string solution; diff --git a/modules/mono/editor/GodotSharpTools/Project/ProjectExtensions.cs b/modules/mono/editor/GodotSharpTools/Project/ProjectExtensions.cs index 6a97731539..f00ec5a2ad 100644 --- a/modules/mono/editor/GodotSharpTools/Project/ProjectExtensions.cs +++ b/modules/mono/editor/GodotSharpTools/Project/ProjectExtensions.cs @@ -27,12 +27,15 @@ namespace GodotSharpTools.Project return false; } - public static void AddItemChecked(this ProjectRootElement root, string itemType, string include) + public static bool AddItemChecked(this ProjectRootElement root, string itemType, string include) { if (!root.HasItem(itemType, include)) { root.AddItem(itemType, include); + return true; } + + return false; } public static Guid GetGuid(this ProjectRootElement root) diff --git a/modules/mono/editor/GodotSharpTools/Project/ProjectUtils.cs b/modules/mono/editor/GodotSharpTools/Project/ProjectUtils.cs index a50b4fb064..6889ea715f 100644 --- a/modules/mono/editor/GodotSharpTools/Project/ProjectUtils.cs +++ b/modules/mono/editor/GodotSharpTools/Project/ProjectUtils.cs @@ -10,8 +10,8 @@ namespace GodotSharpTools.Project { var dir = Directory.GetParent(projectPath).FullName; var root = ProjectRootElement.Open(projectPath); - root.AddItemChecked(itemType, include.RelativeToPath(dir).Replace("/", "\\")); - root.Save(); + if (root.AddItemChecked(itemType, include.RelativeToPath(dir).Replace("/", "\\"))) + root.Save(); } } } diff --git a/modules/mono/editor/godotsharp_builds.cpp b/modules/mono/editor/godotsharp_builds.cpp index e7d9c83421..b7e3fb0a32 100644 --- a/modules/mono/editor/godotsharp_builds.cpp +++ b/modules/mono/editor/godotsharp_builds.cpp @@ -29,13 +29,14 @@ /*************************************************************************/ #include "godotsharp_builds.h" +#include "main/main.h" + #include "../godotsharp_dirs.h" #include "../mono_gd/gd_mono_class.h" #include "../mono_gd/gd_mono_marshal.h" #include "../utils/path_utils.h" #include "bindings_generator.h" #include "godotsharp_editor.h" -#include "main/main.h" void godot_icall_BuildInstance_ExitCallback(MonoString *p_solution, MonoString *p_config, int p_exit_code) { @@ -44,11 +45,37 @@ void godot_icall_BuildInstance_ExitCallback(MonoString *p_solution, MonoString * GodotSharpBuilds::get_singleton()->build_exit_callback(MonoBuildInfo(solution, config), p_exit_code); } +#ifdef UNIX_ENABLED +String _find_build_engine_on_unix(const String &p_name) { + String ret = path_which(p_name); + + if (ret.length()) + return ret; + + const char *locations[] = { +#ifdef OSX_ENABLED + "/Library/Frameworks/Mono.framework/Versions/Current/bin/", +#endif + "/opt/novell/mono/bin/" + }; + + for (int i = 0; i < sizeof(locations) / sizeof(char); i++) { + String location = locations[i]; + + if (FileAccess::exists(location + p_name)) { + return location; + } + } + + return String(); +} +#endif + MonoString *godot_icall_BuildInstance_get_MSBuildPath() { GodotSharpBuilds::BuildTool build_tool = GodotSharpBuilds::BuildTool(int(EditorSettings::get_singleton()->get("mono/builds/build_tool"))); -#ifdef WINDOWS_ENABLED +#if defined(WINDOWS_ENABLED) switch (build_tool) { case GodotSharpBuilds::MSBUILD: { static String msbuild_tools_path = MonoRegUtils::find_msbuild_tools_path(); @@ -84,14 +111,25 @@ MonoString *godot_icall_BuildInstance_get_MSBuildPath() { ERR_EXPLAIN("You don't deserve to live"); CRASH_NOW(); } -#else - static bool msbuild_found = path_which("msbuild").length(); - - if (build_tool != GodotSharpBuilds::XBUILD && !msbuild_found) { - WARN_PRINT("Cannot find msbuild ('mono/builds/build_tool')."); +#elif defined(UNIX_ENABLED) + static String msbuild_path = _find_build_engine_on_unix("msbuild"); + static String xbuild_path = _find_build_engine_on_unix("xbuild"); + + if (build_tool != GodotSharpBuilds::XBUILD) { + if (msbuild_path.empty()) { + WARN_PRINT("Cannot find msbuild ('mono/builds/build_tool')."); + return NULL; + } + } else { + if (xbuild_path.empty()) { + WARN_PRINT("Cannot find xbuild ('mono/builds/build_tool')."); + return NULL; + } } - return GDMonoMarshal::mono_string_from_godot(build_tool != GodotSharpBuilds::XBUILD ? "msbuild" : "xbuild"); + return GDMonoMarshal::mono_string_from_godot(build_tool != GodotSharpBuilds::XBUILD ? msbuild_path : xbuild_path); +#else + return NULL; #endif } @@ -314,8 +352,8 @@ GodotSharpBuilds::GodotSharpBuilds() { // Build tool settings EditorSettings *ed_settings = EditorSettings::get_singleton(); - if (!ed_settings->has("mono/builds/build_tool")) { - ed_settings->set("mono/builds/build_tool", MSBUILD); + if (!ed_settings->has_setting("mono/builds/build_tool")) { + ed_settings->set_setting("mono/builds/build_tool", MSBUILD); } ed_settings->add_property_hint(PropertyInfo(Variant::INT, "mono/builds/build_tool", PROPERTY_HINT_ENUM, "MSBuild (System),MSBuild (Mono),xbuild")); } diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp index 5aaf029495..30e7653256 100644 --- a/modules/mono/editor/godotsharp_editor.cpp +++ b/modules/mono/editor/godotsharp_editor.cpp @@ -237,8 +237,8 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) { // External editor settings EditorSettings *ed_settings = EditorSettings::get_singleton(); - if (!ed_settings->has("mono/editor/external_editor")) { - ed_settings->set("mono/editor/external_editor", EDITOR_NONE); + if (!ed_settings->has_setting("mono/editor/external_editor")) { + ed_settings->set_setting("mono/editor/external_editor", EDITOR_NONE); } ed_settings->add_property_hint(PropertyInfo(Variant::INT, "mono/editor/external_editor", PROPERTY_HINT_ENUM, "None,MonoDevelop,Visual Studio,Visual Studio Code")); } diff --git a/modules/mono/mono_gd/gd_mono.cpp b/modules/mono/mono_gd/gd_mono.cpp index 77f01842bb..d0b5b12d4b 100644 --- a/modules/mono/mono_gd/gd_mono.cpp +++ b/modules/mono/mono_gd/gd_mono.cpp @@ -31,6 +31,7 @@ #include <mono/metadata/mono-config.h> #include <mono/metadata/mono-debug.h> +#include <mono/metadata/mono-gc.h> #include "os/dir_access.h" #include "os/file_access.h" @@ -272,7 +273,7 @@ bool GDMono::_load_assembly(const String &p_name, GDMonoAssembly **r_assembly) { if (OS::get_singleton()->is_stdout_verbose()) OS::get_singleton()->print((String() + "Mono: Loading assembly " + p_name + "...\n").utf8()); - MonoImageOpenStatus status; + MonoImageOpenStatus status = MONO_IMAGE_OK; MonoAssemblyName *aname = mono_assembly_name_new(p_name.utf8()); MonoAssembly *assembly = mono_assembly_load_full(aname, NULL, &status, false); mono_assembly_name_free(aname); @@ -438,10 +439,14 @@ Error GDMono::_unload_scripts_domain() { if (mono_domain_get() != root_domain) mono_domain_set(root_domain, true); + mono_gc_collect(mono_gc_max_generation()); + finalizing_scripts_domain = true; mono_domain_finalize(scripts_domain, 2000); finalizing_scripts_domain = false; + mono_gc_collect(mono_gc_max_generation()); + _domain_assemblies_cleanup(mono_domain_get_id(scripts_domain)); api_assembly = NULL; diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index d96dfebe6c..5a34fc3cd9 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -1109,7 +1109,7 @@ void VisualScriptConstant::_bind_methods() { } ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, argt), "set_constant_type", "get_constant_type"); - ADD_PROPERTY(PropertyInfo(Variant::NIL, "value"), "set_constant_value", "get_constant_value"); + ADD_PROPERTY(PropertyInfo(Variant::NIL, "value", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT), "set_constant_value", "get_constant_value"); } class VisualScriptNodeInstanceConstant : public VisualScriptNodeInstance { diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index e3615e2298..9fe1f291d6 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -871,7 +871,7 @@ class EditorExportAndroid : public EditorExportPlatform { String lang = str.substr(str.find_last("-") + 1, str.length()).replace("-", "_"); String prop = "application/config/name_" + lang; - if (ProjectSettings::get_singleton()->has(prop)) { + if (ProjectSettings::get_singleton()->has_setting(prop)) { str = ProjectSettings::get_singleton()->get(prop); } else { str = get_project_name(package_name); diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 53a90e4cfe..053dfa631a 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -277,6 +277,21 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC edittext.setView(mView); io.setEdit(edittext); + final Godot godot = this; + mView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + Point fullSize = new Point(); + godot.getWindowManager().getDefaultDisplay().getSize(fullSize); + Rect gameSize = new Rect(); + godot.mView.getWindowVisibleDisplayFrame(gameSize); + + final int keyboardHeight = fullSize.y - gameSize.bottom; + Log.d("GODOT", "setVirtualKeyboardHeight: " + keyboardHeight); + GodotLib.setVirtualKeyboardHeight(keyboardHeight); + } + }); + // Ad layout adLayout = new RelativeLayout(this); adLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); diff --git a/platform/android/java/src/org/godotengine/godot/GodotLib.java b/platform/android/java/src/org/godotengine/godot/GodotLib.java index 47a690140f..e0ed4cd38c 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/src/org/godotengine/godot/GodotLib.java @@ -69,4 +69,6 @@ public class GodotLib { public static native void callobject(int p_ID, String p_method, Object[] p_params); public static native void calldeferred(int p_ID, String p_method, Object[] p_params); + public static native void setVirtualKeyboardHeight(int p_height); + } diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 509d1bf123..6819a7e20f 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -754,6 +754,18 @@ static void _alert(const String &p_message, const String &p_title) { env->CallVoidMethod(_godot_instance, _alertDialog, jStrMessage, jStrTitle); } +// volatile because it can be changed from non-main thread and we need to +// ensure the change is immediately visible to other threads. +static volatile int virtual_keyboard_height; + +static int _get_vk_height() { + return virtual_keyboard_height; +} + +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHeight(JNIEnv *env, jobject obj, jint p_height) { + virtual_keyboard_height = p_height; +} + JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *env, jobject obj, jobject activity, jboolean p_need_reload_hook, jobject p_asset_manager, jboolean p_use_apk_expansion) { __android_log_print(ANDROID_LOG_INFO, "godot", "**INIT EVENT! - %p\n", env); @@ -824,7 +836,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en AudioDriverAndroid::setup(gob); } - os_android = new OS_Android(_gfx_init_func, env, _open_uri, _get_data_dir, _get_locale, _get_model, _get_screen_dpi, _show_vk, _hide_vk, _set_screen_orient, _get_unique_id, _get_system_dir, _play_video, _is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, _alert, p_use_apk_expansion); + os_android = new OS_Android(_gfx_init_func, env, _open_uri, _get_data_dir, _get_locale, _get_model, _get_screen_dpi, _show_vk, _hide_vk, _get_vk_height, _set_screen_orient, _get_unique_id, _get_system_dir, _play_video, _is_video_playing, _pause_video, _stop_video, _set_keep_screen_on, _alert, p_use_apk_expansion); os_android->set_need_reload_hooks(p_need_reload_hook); char wd[500]; @@ -841,7 +853,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_initialize(JNIEnv *en static void _initialize_java_modules() { - if (!ProjectSettings::get_singleton()->has("android/modules")) { + if (!ProjectSettings::get_singleton()->has_setting("android/modules")) { print_line("ANDROID MODULES: Nothing to load, aborting"); return; } diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h index ec8ae9a0a6..0aa2489813 100644 --- a/platform/android/java_glue.h +++ b/platform/android/java_glue.h @@ -59,6 +59,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_method(JNIEnv *env, j JNIEXPORT jstring JNICALL Java_org_godotengine_godot_GodotLib_getGlobal(JNIEnv *env, jobject obj, jstring path); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_callobject(JNIEnv *env, jobject p_obj, jint ID, jstring method, jobjectArray params); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_calldeferred(JNIEnv *env, jobject p_obj, jint ID, jstring method, jobjectArray params); +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setVirtualKeyboardHeight(JNIEnv *env, jobject obj, jint p_height); } #endif diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 0eb14f6af3..473a093077 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -519,6 +519,15 @@ bool OS_Android::has_virtual_keyboard() const { return true; } +int OS_Android::get_virtual_keyboard_height() const { + if (get_virtual_keyboard_height_func) { + return get_virtual_keyboard_height_func(); + } + + ERR_PRINT("Cannot obtain virtual keyboard height."); + return 0; +} + void OS_Android::show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect) { if (show_virtual_keyboard_func) { @@ -704,7 +713,7 @@ bool OS_Android::_check_internal_feature_support(const String &p_feature) { return p_feature == "mobile" || p_feature == "etc" || p_feature == "etc2"; //TODO support etc2 only if GLES3 driver is selected } -OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion) { +OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, VirtualKeyboardHeightFunc p_vk_height_func, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion) { use_apk_expansion = p_use_apk_expansion; default_videomode.width = 800; @@ -734,6 +743,7 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURI show_virtual_keyboard_func = p_show_vk; hide_virtual_keyboard_func = p_hide_vk; + get_virtual_keyboard_height_func = p_vk_height_func; set_screen_orientation_func = p_screen_orient; set_keep_screen_on_func = p_set_keep_screen_on_func; diff --git a/platform/android/os_android.h b/platform/android/os_android.h index a614bb8067..0c78c198a8 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -67,6 +67,7 @@ typedef void (*VideoPauseFunc)(); typedef void (*VideoStopFunc)(); typedef void (*SetKeepScreenOnFunc)(bool p_enabled); typedef void (*AlertFunc)(const String &, const String &); +typedef int (*VirtualKeyboardHeightFunc)(); class OS_Android : public OS_Unix { public: @@ -126,6 +127,7 @@ private: GetScreenDPIFunc get_screen_dpi_func; ShowVirtualKeyboardFunc show_virtual_keyboard_func; HideVirtualKeyboardFunc hide_virtual_keyboard_func; + VirtualKeyboardHeightFunc get_virtual_keyboard_height_func; SetScreenOrientationFunc set_screen_orientation_func; GetUniqueIDFunc get_unique_id_func; GetSystemDirFunc get_system_dir_func; @@ -201,6 +203,7 @@ public: virtual bool has_virtual_keyboard() const; virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2()); virtual void hide_virtual_keyboard(); + virtual int get_virtual_keyboard_height() const; void set_opengl_extensions(const char *p_gl_extensions); void set_display_size(Size2 p_size); @@ -240,7 +243,7 @@ public: void joy_connection_changed(int p_device, bool p_connected, String p_name); virtual bool _check_internal_feature_support(const String &p_feature); - OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion); + OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetDataDirFunc p_get_data_dir_func, GetLocaleFunc p_get_locale_func, GetModelFunc p_get_model_func, GetScreenDPIFunc p_get_screen_dpi_func, ShowVirtualKeyboardFunc p_show_vk, HideVirtualKeyboardFunc p_hide_vk, VirtualKeyboardHeightFunc p_vk_height_func, SetScreenOrientationFunc p_screen_orient, GetUniqueIDFunc p_get_unique_id, GetSystemDirFunc p_get_sdir_func, VideoPlayFunc p_video_play_func, VideoIsPlayingFunc p_video_is_playing_func, VideoPauseFunc p_video_pause_func, VideoStopFunc p_video_stop_func, SetKeepScreenOnFunc p_set_keep_screen_on_func, AlertFunc p_alert_func, bool p_use_apk_expansion); ~OS_Android(); }; diff --git a/platform/iphone/gl_view.h b/platform/iphone/gl_view.h index a9fd8d5711..f7309396c6 100644 --- a/platform/iphone/gl_view.h +++ b/platform/iphone/gl_view.h @@ -100,6 +100,8 @@ - (void)destroyFramebuffer; - (void)audioRouteChangeListenerCallback:(NSNotification *)notification; +- (void)keyboardOnScreen:(NSNotification *)notification; +- (void)keyboardHidden:(NSNotification *)notification; @property NSTimeInterval animationInterval; @property(nonatomic, assign) BOOL useCADisplayLink; diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index 3e206c3a2c..02da706cc5 100644 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -63,6 +63,7 @@ void _pause_video(); void _focus_out_video(); void _unpause_video(); void _stop_video(); +CGFloat _points_to_pixels(CGFloat); void _show_keyboard(String p_existing) { keyboard_text = p_existing; @@ -174,6 +175,19 @@ void _stop_video() { video_playing = false; } +CGFloat _points_to_pixels(CGFloat points) { + float pixelPerInch; + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + pixelPerInch = 132; + } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { + pixelPerInch = 163; + } else { + pixelPerInch = 160; + } + CGFloat pointsPerInch = 72.0; + return (points / pointsPerInch * pixelPerInch); +} + @implementation GLView @synthesize animationInterval; @@ -537,6 +551,20 @@ static void clear_touches() { [self resignFirstResponder]; }; +- (void)keyboardOnScreen:(NSNotification *)notification { + NSDictionary *info = notification.userInfo; + NSValue *value = info[UIKeyboardFrameEndUserInfoKey]; + + CGRect rawFrame = [value CGRectValue]; + CGRect keyboardFrame = [self convertRect:rawFrame fromView:nil]; + + OSIPhone::get_singleton()->set_virtual_keyboard_height(_points_to_pixels(keyboardFrame.size.height)); +} + +- (void)keyboardHidden:(NSNotification *)notification { + OSIPhone::get_singleton()->set_virtual_keyboard_height(0); +} + - (void)deleteBackward { if (keyboard_text.length()) keyboard_text.erase(keyboard_text.length() - 1, 1); @@ -606,6 +634,18 @@ static void clear_touches() { name:AVAudioSessionRouteChangeNotification object:nil]; + printf("******** adding observer for keyboard show/hide\n"); + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(keyboardOnScreen:) + name:UIKeyboardDidShowNotification + object:nil]; + [[NSNotificationCenter defaultCenter] + addObserver:self + selector:@selector(keyboardHidden:) + name:UIKeyboardDidHideNotification + object:nil]; + //self.autoresizesSubviews = YES; //[self setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth]; diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 5009f7d8ae..219e93facf 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -463,6 +463,14 @@ void OSIPhone::hide_virtual_keyboard() { _hide_keyboard(); }; +void OSIPhone::set_virtual_keyboard_height(int p_height) { + virtual_keyboard_height = p_height; +} + +int OSIPhone::get_virtual_keyboard_height() const { + return virtual_keyboard_height; +} + Error OSIPhone::shell_open(String p_uri) { return _shell_open(p_uri); }; @@ -576,6 +584,7 @@ OSIPhone::OSIPhone(int width, int height) { vm.resizable = false; set_video_mode(vm); event_count = 0; + virtual_keyboard_height = 0; _set_logger(memnew(SyslogLogger)); }; diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index 11f4eed5e7..cf2396e87b 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -124,6 +124,8 @@ private: InputDefault *input; + int virtual_keyboard_height; + public: bool iterate(); @@ -133,6 +135,7 @@ public: void mouse_move(int p_idx, int p_prev_x, int p_prev_y, int p_x, int p_y, bool p_use_as_mouse); void touches_cancelled(); void key(uint32_t p_key, bool p_pressed); + void set_virtual_keyboard_height(int p_height); int set_base_framebuffer(int p_fb); @@ -168,6 +171,7 @@ public: virtual bool has_virtual_keyboard() const; virtual void show_virtual_keyboard(const String &p_existing_text, const Rect2 &p_screen_rect = Rect2()); virtual void hide_virtual_keyboard(); + virtual int get_virtual_keyboard_height() const; virtual void set_cursor_shape(CursorShape p_shape); diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 2ec76fe0dd..0fd21d62ee 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -97,6 +97,16 @@ void EditorExportPlatformOSX::get_preset_features(const Ref<EditorExportPreset> if (p_preset->get("texture_format/etc2")) { r_features->push_back("etc2"); } + + int bits = p_preset->get("application/bits_mode"); + + if (bits == 0 || bits == 1) { + r_features->push_back("64"); + } + + if (bits == 0 || bits == 2) { + r_features->push_back("32"); + } } void EditorExportPlatformOSX::get_export_options(List<ExportOption> *r_options) { diff --git a/scene/3d/arvr_nodes.cpp b/scene/3d/arvr_nodes.cpp index 147d3bf115..c6b6c02129 100644 --- a/scene/3d/arvr_nodes.cpp +++ b/scene/3d/arvr_nodes.cpp @@ -67,6 +67,105 @@ String ARVRCamera::get_configuration_warning() const { return String(); }; +Vector3 ARVRCamera::project_local_ray_normal(const Point2 &p_pos) const { + // get our ARVRServer + ARVRServer *arvr_server = ARVRServer::get_singleton(); + ERR_FAIL_NULL_V(arvr_server, Vector3()); + + Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface(); + ERR_FAIL_COND_V(arvr_interface.is_null(), Vector3()); + + if (!is_inside_tree()) { + ERR_EXPLAIN("Camera is not inside scene."); + ERR_FAIL_COND_V(!is_inside_tree(), Vector3()); + }; + + Size2 viewport_size = get_viewport()->get_camera_rect_size(); + Vector2 cpos = get_viewport()->get_camera_coords(p_pos); + Vector3 ray; + + CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); + float screen_w, screen_h; + cm.get_viewport_size(screen_w, screen_h); + ray = Vector3(((cpos.x / viewport_size.width) * 2.0 - 1.0) * screen_w, ((1.0 - (cpos.y / viewport_size.height)) * 2.0 - 1.0) * screen_h, -get_znear()).normalized(); + + return ray; +}; + +Point2 ARVRCamera::unproject_position(const Vector3 &p_pos) const { + // get our ARVRServer + ARVRServer *arvr_server = ARVRServer::get_singleton(); + ERR_FAIL_NULL_V(arvr_server, Vector2()); + + Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface(); + ERR_FAIL_COND_V(arvr_interface.is_null(), Vector2()); + + if (!is_inside_tree()) { + ERR_EXPLAIN("Camera is not inside scene."); + ERR_FAIL_COND_V(!is_inside_tree(), Vector2()); + }; + + Size2 viewport_size = get_viewport()->get_visible_rect().size; + + CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); + + Plane p(get_camera_transform().xform_inv(p_pos), 1.0); + + p = cm.xform4(p); + p.normal /= p.d; + + Point2 res; + res.x = (p.normal.x * 0.5 + 0.5) * viewport_size.x; + res.y = (-p.normal.y * 0.5 + 0.5) * viewport_size.y; + + return res; +}; + +Vector3 ARVRCamera::project_position(const Point2 &p_point) const { + // get our ARVRServer + ARVRServer *arvr_server = ARVRServer::get_singleton(); + ERR_FAIL_NULL_V(arvr_server, Vector3()); + + Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface(); + ERR_FAIL_COND_V(arvr_interface.is_null(), Vector3()); + + if (!is_inside_tree()) { + ERR_EXPLAIN("Camera is not inside scene."); + ERR_FAIL_COND_V(!is_inside_tree(), Vector3()); + }; + + Size2 viewport_size = get_viewport()->get_visible_rect().size; + + CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); + + Size2 vp_size; + cm.get_viewport_size(vp_size.x, vp_size.y); + + Vector2 point; + point.x = (p_point.x / viewport_size.x) * 2.0 - 1.0; + point.y = (1.0 - (p_point.y / viewport_size.y)) * 2.0 - 1.0; + point *= vp_size; + + Vector3 p(point.x, point.y, -get_znear()); + + return get_camera_transform().xform(p); +}; + +Vector<Plane> ARVRCamera::get_frustum() const { + // get our ARVRServer + ARVRServer *arvr_server = ARVRServer::get_singleton(); + ERR_FAIL_NULL_V(arvr_server, Vector<Plane>()); + + Ref<ARVRInterface> arvr_interface = arvr_server->get_primary_interface(); + ERR_FAIL_COND_V(arvr_interface.is_null(), Vector<Plane>()); + + ERR_FAIL_COND_V(!is_inside_world(), Vector<Plane>()); + + Size2 viewport_size = get_viewport()->get_visible_rect().size; + CameraMatrix cm = arvr_interface->get_projection_for_eye(ARVRInterface::EYE_MONO, viewport_size.aspect(), get_znear(), get_zfar()); + return cm.get_projection_planes(get_camera_transform()); +}; + ARVRCamera::ARVRCamera(){ // nothing to do here yet for now.. }; @@ -297,6 +396,8 @@ void ARVRAnchor::_bind_methods() { ClassDB::bind_method(D_METHOD("get_is_active"), &ARVRAnchor::get_is_active); ClassDB::bind_method(D_METHOD("get_size"), &ARVRAnchor::get_size); + + ClassDB::bind_method(D_METHOD("get_plane"), &ARVRAnchor::get_plane); }; void ARVRAnchor::set_anchor_id(int p_anchor_id) { @@ -346,6 +447,15 @@ String ARVRAnchor::get_configuration_warning() const { return String(); }; +Plane ARVRAnchor::get_plane() const { + Vector3 location = get_translation(); + Basis orientation = get_transform().basis; + + Plane plane(location, orientation.get_axis(1).normalized()); + + return plane; +}; + ARVRAnchor::ARVRAnchor() { anchor_id = 0; is_active = true; diff --git a/scene/3d/arvr_nodes.h b/scene/3d/arvr_nodes.h index 5269ec0248..e0ccfab58b 100644 --- a/scene/3d/arvr_nodes.h +++ b/scene/3d/arvr_nodes.h @@ -52,6 +52,11 @@ protected: public: String get_configuration_warning() const; + virtual Vector3 project_local_ray_normal(const Point2 &p_pos) const; + virtual Point2 unproject_position(const Vector3 &p_pos) const; + virtual Vector3 project_position(const Point2 &p_point) const; + virtual Vector<Plane> get_frustum() const; + ARVRCamera(); ~ARVRCamera(); }; @@ -118,6 +123,8 @@ public: bool get_is_active() const; Vector3 get_size() const; + Plane get_plane() const; + String get_configuration_warning() const; ARVRAnchor(); diff --git a/scene/3d/camera.h b/scene/3d/camera.h index 3a725eaf66..73c6844c1a 100644 --- a/scene/3d/camera.h +++ b/scene/3d/camera.h @@ -127,16 +127,16 @@ public: virtual Transform get_camera_transform() const; Vector3 project_ray_normal(const Point2 &p_pos) const; - Vector3 project_ray_origin(const Point2 &p_pos) const; + virtual Vector3 project_ray_origin(const Point2 &p_pos) const; Vector3 project_local_ray_normal(const Point2 &p_pos) const; - Point2 unproject_position(const Vector3 &p_pos) const; + virtual Point2 unproject_position(const Vector3 &p_pos) const; bool is_position_behind(const Vector3 &p_pos) const; - Vector3 project_position(const Point2 &p_point) const; + virtual Vector3 project_position(const Point2 &p_point) const; void set_cull_mask(uint32_t p_layers); uint32_t get_cull_mask() const; - Vector<Plane> get_frustum() const; + virtual Vector<Plane> get_frustum() const; void set_environment(const Ref<Environment> &p_environment); Ref<Environment> get_environment() const; diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 66364d40f9..9d55a82824 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -1486,8 +1486,8 @@ GIProbe::GIProbe() { subdiv = SUBDIV_128; dynamic_range = 4; energy = 1.0; - bias = 0.0; - normal_bias = 0.8; + bias = 1.5; + normal_bias = 0.0; propagation = 1.0; extents = Vector3(10, 10, 10); color_scan_cell_width = 4; diff --git a/scene/gui/file_dialog.cpp b/scene/gui/file_dialog.cpp index 87a232e766..320dad9301 100644 --- a/scene/gui/file_dialog.cpp +++ b/scene/gui/file_dialog.cpp @@ -115,6 +115,7 @@ Vector<String> FileDialog::get_selected_files() const { void FileDialog::update_dir() { dir->set_text(dir_access->get_current_dir()); + drives->select(dir_access->get_current_drive()); } void FileDialog::_dir_entered(String p_dir) { diff --git a/scene/gui/rich_text_label.cpp b/scene/gui/rich_text_label.cpp index d9287e6f63..c2ce2a633e 100644 --- a/scene/gui/rich_text_label.cpp +++ b/scene/gui/rich_text_label.cpp @@ -1949,7 +1949,7 @@ void RichTextLabel::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "visible_characters", PROPERTY_HINT_RANGE, "-1,128000,1"), "set_visible_characters", "get_visible_characters"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "percent_visible", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_percent_visible", "get_percent_visible"); - ADD_SIGNAL(MethodInfo("meta_clicked", PropertyInfo(Variant::NIL, "meta"))); + ADD_SIGNAL(MethodInfo("meta_clicked", PropertyInfo(Variant::NIL, "meta", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT))); BIND_ENUM_CONSTANT(ALIGN_LEFT); BIND_ENUM_CONSTANT(ALIGN_CENTER); diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 816556af30..190ccd50d5 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -285,6 +285,12 @@ float VideoPlayer::get_stream_position() const { return playback->get_playback_position(); }; +void VideoPlayer::set_stream_position(float p_position) { + + if (playback.is_valid()) + playback->seek(p_position); +} + Ref<Texture> VideoPlayer::get_video_texture() { if (playback.is_valid()) @@ -327,6 +333,7 @@ void VideoPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_stream_name"), &VideoPlayer::get_stream_name); + ClassDB::bind_method(D_METHOD("set_stream_position", "position"), &VideoPlayer::set_stream_position); ClassDB::bind_method(D_METHOD("get_stream_position"), &VideoPlayer::get_stream_position); ClassDB::bind_method(D_METHOD("set_autoplay", "enabled"), &VideoPlayer::set_autoplay); diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index bea10907bb..f04e90365f 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -93,6 +93,7 @@ public: String get_stream_name() const; float get_stream_position() const; + void set_stream_position(float p_position); void set_autoplay(bool p_enable); bool has_autoplay() const; diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index b9dfbd6bb0..a85a0fb9f7 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -222,13 +222,18 @@ void register_scene_types() { String font_path = GLOBAL_DEF("gui/theme/custom_font", ""); ProjectSettings::get_singleton()->set_custom_property_info("gui/theme/custom_font", PropertyInfo(Variant::STRING, "gui/theme/custom_font", PROPERTY_HINT_FILE, "*.tres,*.res,*.font", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED)); + bool has_theme = false; if (theme_path != String()) { Ref<Theme> theme = ResourceLoader::load(theme_path); if (theme.is_valid()) { Theme::set_default(theme); + has_theme = true; + } else { + ERR_PRINTS("Error loading custom theme '" + theme_path + "'"); } - } else { + } + if (!has_theme) { Ref<Font> font; if (font_path != String()) { font = ResourceLoader::load(font_path); diff --git a/servers/arvr/arvr_interface.cpp b/servers/arvr/arvr_interface.cpp index 0705df17b1..55707def7c 100644 --- a/servers/arvr/arvr_interface.cpp +++ b/servers/arvr/arvr_interface.cpp @@ -31,29 +31,49 @@ void ARVRInterface::_bind_methods() { ClassDB::bind_method(D_METHOD("get_name"), &ARVRInterface::get_name); + ClassDB::bind_method(D_METHOD("get_capabilities"), &ARVRInterface::get_capabilities); ClassDB::bind_method(D_METHOD("is_primary"), &ARVRInterface::is_primary); ClassDB::bind_method(D_METHOD("set_is_primary", "enable"), &ARVRInterface::set_is_primary); - ClassDB::bind_method(D_METHOD("is_installed"), &ARVRInterface::is_installed); - ClassDB::bind_method(D_METHOD("hmd_is_present"), &ARVRInterface::hmd_is_present); - ClassDB::bind_method(D_METHOD("supports_hmd"), &ARVRInterface::supports_hmd); ClassDB::bind_method(D_METHOD("is_initialized"), &ARVRInterface::is_initialized); + ClassDB::bind_method(D_METHOD("set_is_initialized", "initialized"), &ARVRInterface::set_is_initialized); ClassDB::bind_method(D_METHOD("initialize"), &ARVRInterface::initialize); ClassDB::bind_method(D_METHOD("uninitialize"), &ARVRInterface::uninitialize); + ClassDB::bind_method(D_METHOD("get_tracking_status"), &ARVRInterface::get_tracking_status); + ClassDB::bind_method(D_METHOD("get_recommended_render_targetsize"), &ARVRInterface::get_recommended_render_targetsize); + ClassDB::bind_method(D_METHOD("is_stereo"), &ARVRInterface::is_stereo); + + ADD_GROUP("Interface", "interface_"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interface_is_primary"), "set_is_primary", "is_primary"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "interface_is_initialized"), "set_is_initialized", "is_initialized"); + + // we don't have any properties specific to VR yet.... - // These are now purely used internally, we may expose them again if we expose CameraMatrix through Variant but reduz is not a fan for good reasons :) - // ClassDB::bind_method(D_METHOD("get_transform_for_eye", "eye", "cam_transform"), &ARVRInterface::get_transform_for_eye); - // ClassDB::bind_method(D_METHOD("get_projection_for_eye", "eye"), &ARVRInterface::get_projection_for_eye); - // ClassDB::bind_method(D_METHOD("commit_for_eye", "node:viewport"), &ARVRInterface::commit_for_eye); + // but we do have properties specific to AR.... + ClassDB::bind_method(D_METHOD("get_anchor_detection_is_enabled"), &ARVRInterface::get_anchor_detection_is_enabled); + ClassDB::bind_method(D_METHOD("set_anchor_detection_is_enabled", "enable"), &ARVRInterface::set_anchor_detection_is_enabled); - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "primary"), "set_is_primary", "is_primary"); + ADD_GROUP("AR", "ar_"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ar_is_anchor_detection_enabled"), "set_anchor_detection_is_enabled", "get_anchor_detection_is_enabled"); + + BIND_ENUM_CONSTANT(ARVR_NONE); + BIND_ENUM_CONSTANT(ARVR_MONO); + BIND_ENUM_CONSTANT(ARVR_STEREO); + BIND_ENUM_CONSTANT(ARVR_AR); + BIND_ENUM_CONSTANT(ARVR_EXTERNAL); BIND_ENUM_CONSTANT(EYE_MONO); BIND_ENUM_CONSTANT(EYE_LEFT); BIND_ENUM_CONSTANT(EYE_RIGHT); + + BIND_ENUM_CONSTANT(ARVR_NORMAL_TRACKING); + BIND_ENUM_CONSTANT(ARVR_EXCESSIVE_MOTION); + BIND_ENUM_CONSTANT(ARVR_INSUFFICIENT_FEATURES); + BIND_ENUM_CONSTANT(ARVR_UNKNOWN_TRACKING); + BIND_ENUM_CONSTANT(ARVR_NOT_TRACKING); }; StringName ARVRInterface::get_name() const { @@ -73,10 +93,40 @@ void ARVRInterface::set_is_primary(bool p_is_primary) { if (p_is_primary) { ERR_FAIL_COND(!is_initialized()); - ERR_FAIL_COND(!supports_hmd()); arvr_server->set_primary_interface(this); } else { arvr_server->clear_primary_interface_if(this); }; }; + +void ARVRInterface::set_is_initialized(bool p_initialized) { + if (p_initialized) { + if (!is_initialized()) { + initialize(); + }; + } else { + if (is_initialized()) { + uninitialize(); + }; + }; +}; + +ARVRInterface::Tracking_status ARVRInterface::get_tracking_status() const { + return tracking_state; +}; + +ARVRInterface::ARVRInterface() { + tracking_state = ARVR_UNKNOWN_TRACKING; +}; + +ARVRInterface::~ARVRInterface(){}; + +/** these will only be implemented on AR interfaces, so we want dummies for VR **/ +bool ARVRInterface::get_anchor_detection_is_enabled() const { + return false; +}; + +void ARVRInterface::set_anchor_detection_is_enabled(bool p_enable){ + // don't do anything here, this needs to be implemented on AR interface to enable/disable things like plane detection etc. +}; diff --git a/servers/arvr/arvr_interface.h b/servers/arvr/arvr_interface.h index d4fb383bbc..880f6e4595 100644 --- a/servers/arvr/arvr_interface.h +++ b/servers/arvr/arvr_interface.h @@ -50,31 +50,59 @@ class ARVRInterface : public Reference { GDCLASS(ARVRInterface, Reference); -protected: - _THREAD_SAFE_CLASS_ - - static void _bind_methods(); - public: + enum Capabilities { /* purely meta data, provides some info about what this interface supports */ + ARVR_NONE = 0, /* no capabilities */ + ARVR_MONO = 1, /* can be used with mono output */ + ARVR_STEREO = 2, /* can be used with stereo output */ + ARVR_AR = 4, /* offers a camera feed for AR */ + ARVR_EXTERNAL = 8 /* renders to external device */ + }; + enum Eyes { EYE_MONO, /* my son says we should call this EYE_CYCLOPS */ EYE_LEFT, EYE_RIGHT }; + enum Tracking_status { /* tracking status currently based on AR but we can start doing more with this for VR as well */ + ARVR_NORMAL_TRACKING, + ARVR_EXCESSIVE_MOTION, + ARVR_INSUFFICIENT_FEATURES, + ARVR_UNKNOWN_TRACKING, + ARVR_NOT_TRACKING + }; + +protected: + _THREAD_SAFE_CLASS_ + + Tracking_status tracking_state; + static void _bind_methods(); + +public: + /** general interface information **/ virtual StringName get_name() const; + virtual int get_capabilities() const = 0; bool is_primary(); void set_is_primary(bool p_is_primary); - virtual bool is_installed() = 0; /* returns true if the middle ware related to this interface has been installed */ - virtual bool hmd_is_present() = 0; /* returns true if our HMD is connected */ - virtual bool supports_hmd() = 0; /* returns true is this interface handles output to an HMD or only handles positioning */ - virtual bool is_initialized() = 0; /* returns true if we've initialized this interface */ + void set_is_initialized(bool p_initialized); /* helper function, will call initialize or uninitialize */ virtual bool initialize() = 0; /* initialize this interface, if this has an HMD it becomes the primary interface */ virtual void uninitialize() = 0; /* deinitialize this interface */ + Tracking_status get_tracking_status() const; /* get the status of our current tracking */ + + /** specific to VR **/ + // nothing yet + + /** specific to AR **/ + virtual bool get_anchor_detection_is_enabled() const; + virtual void set_anchor_detection_is_enabled(bool p_enable); + + /** rendering and internal **/ + virtual Size2 get_recommended_render_targetsize() = 0; /* returns the recommended render target size per eye for this device */ virtual bool is_stereo() = 0; /* returns true if this interface requires stereo rendering (for VR HMDs) or mono rendering (for mobile AR) */ virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform) = 0; /* get each eyes camera transform, also implement EYE_MONO */ @@ -82,8 +110,13 @@ public: virtual void commit_for_eye(ARVRInterface::Eyes p_eye, RID p_render_target, const Rect2 &p_screen_rect) = 0; /* output the left or right eye */ virtual void process() = 0; + + ARVRInterface(); + ~ARVRInterface(); }; +VARIANT_ENUM_CAST(ARVRInterface::Capabilities); VARIANT_ENUM_CAST(ARVRInterface::Eyes); +VARIANT_ENUM_CAST(ARVRInterface::Tracking_status); #endif diff --git a/servers/arvr/arvr_script_interface.cpp b/servers/arvr/arvr_script_interface.cpp index 16e607920e..2755605a14 100644 --- a/servers/arvr/arvr_script_interface.cpp +++ b/servers/arvr/arvr_script_interface.cpp @@ -23,20 +23,26 @@ StringName ARVRScriptInterface::get_name() const { } } -bool ARVRScriptInterface::is_installed() { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("is_installed")), false); - return get_script_instance()->call("is_installed"); -} +int ARVRScriptInterface::get_capabilities() const { + ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_capabilities")), ARVRInterface::ARVR_NONE); + return get_script_instance()->call("get_capabilities"); +}; -bool ARVRScriptInterface::hmd_is_present() { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("hmd_is_present")), false); - return get_script_instance()->call("hmd_is_present"); +ARVRInterface::Tracking_status ARVRScriptInterface::get_tracking_status() const { + ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_tracking_status")), ARVRInterface::ARVR_NOT_TRACKING); + int status = get_script_instance()->call("get_tracking_status"); + return (ARVRInterface::Tracking_status)status; } -bool ARVRScriptInterface::supports_hmd() { - ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("supports_hmd")), false); - return get_script_instance()->call("supports_hmd"); -} +bool ARVRScriptInterface::get_anchor_detection_is_enabled() const { + ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("get_anchor_detection_is_enabled")), false); + return get_script_instance()->call("get_anchor_detection_is_enabled"); +}; + +void ARVRScriptInterface::set_anchor_detection_is_enabled(bool p_enable) { + ERR_FAIL_COND(!(get_script_instance() && get_script_instance()->has_method("set_anchor_detection_is_enabled"))); + get_script_instance()->call("set_anchor_detection_is_enabled"); +}; bool ARVRScriptInterface::is_stereo() { ERR_FAIL_COND_V(!(get_script_instance() && get_script_instance()->has_method("is_stereo")), false); @@ -110,14 +116,17 @@ void ARVRScriptInterface::process() { } void ARVRScriptInterface::_bind_methods() { - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "is_installed")); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "hmd_is_present")); - ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "supports_hmd")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "get_capabilities")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "is_initialized")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "initialize")); ClassDB::add_virtual_method(get_class_static(), MethodInfo("uninitialize")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::INT, "get_tracking_status")); + + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "get_anchor_detection_is_enabled")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo("set_anchor_detection_is_enabled", PropertyInfo(Variant::BOOL, "enabled"))); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "is_stereo")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::VECTOR2, "get_recommended_render_targetsize")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::TRANSFORM, "get_transform_for_eye", PropertyInfo(Variant::INT, "eye"), PropertyInfo(Variant::TRANSFORM, "cam_transform"))); diff --git a/servers/arvr/arvr_script_interface.h b/servers/arvr/arvr_script_interface.h index 04ca33901a..b1393b4fdb 100644 --- a/servers/arvr/arvr_script_interface.h +++ b/servers/arvr/arvr_script_interface.h @@ -16,19 +16,24 @@ protected: static void _bind_methods(); public: + /** general interface information **/ ARVRScriptInterface(); ~ARVRScriptInterface(); virtual StringName get_name() const; - - virtual bool is_installed(); - virtual bool hmd_is_present(); - virtual bool supports_hmd(); + virtual int get_capabilities() const; virtual bool is_initialized(); virtual bool initialize(); virtual void uninitialize(); + ARVRInterface::Tracking_status get_tracking_status() const; /* get the status of our current tracking */ + + /** specific to AR **/ + virtual bool get_anchor_detection_is_enabled() const; + virtual void set_anchor_detection_is_enabled(bool p_enable); + + /** rendering and internal **/ virtual Size2 get_recommended_render_targetsize(); virtual bool is_stereo(); virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform); diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp index 5d8cf20c92..aa879f8aed 100644 --- a/servers/arvr_server.cpp +++ b/servers/arvr_server.cpp @@ -43,7 +43,7 @@ void ARVRServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_world_scale"), &ARVRServer::get_world_scale); ClassDB::bind_method(D_METHOD("set_world_scale"), &ARVRServer::set_world_scale); ClassDB::bind_method(D_METHOD("get_reference_frame"), &ARVRServer::get_reference_frame); - ClassDB::bind_method(D_METHOD("request_reference_frame", "ignore_tilt", "keep_height"), &ARVRServer::request_reference_frame); + ClassDB::bind_method(D_METHOD("center_on_hmd", "ignore_tilt", "keep_height"), &ARVRServer::center_on_hmd); ADD_PROPERTY(PropertyInfo(Variant::REAL, "world_scale"), "set_world_scale", "get_world_scale"); @@ -98,7 +98,7 @@ Transform ARVRServer::get_reference_frame() const { return reference_frame; }; -void ARVRServer::request_reference_frame(bool p_ignore_tilt, bool p_keep_height) { +void ARVRServer::center_on_hmd(bool p_ignore_tilt, bool p_keep_height) { if (primary_interface != NULL) { // clear our current reference frame or we'll end up double adjusting it reference_frame = Transform(); diff --git a/servers/arvr_server.h b/servers/arvr_server.h index 2645637ad5..948895cb27 100644 --- a/servers/arvr_server.h +++ b/servers/arvr_server.h @@ -117,14 +117,17 @@ public: void set_world_origin(const Transform p_world_origin); /* - Requesting a reference frame results in a matrix being calculated that ensures the HMD is positioned to 0,0,0 facing 0,0,-1 (need to verify this direction) + center_on_hmd calculates a new reference frame. This ensures the HMD is positioned to 0,0,0 facing 0,0,-1 (need to verify this direction) in the virtual world. + You can ignore the tilt of the device ensuring you're looking straight forward even if the player is looking down or sideways. + You can chose to keep the height the tracking provides which is important for room scale capable tracking. + Note: this should not be used in AR and should be ignored by an AR based interface as it would throw what you're looking at in the real world and in the virtual world out of sync */ Transform get_reference_frame() const; - void request_reference_frame(bool p_ignore_tilt, bool p_keep_height); + void center_on_hmd(bool p_ignore_tilt, bool p_keep_height); /* Interfaces are objects that 'glue' Godot to an AR or VR SDK such as the Oculus SDK, OpenVR, OpenHMD, etc. diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 9fb4dc524d..e49baf0763 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -2348,7 +2348,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) { RID rid = E->key(); const InstanceGIProbeData::LightCache &lc = E->get(); - if (!probe_data->dynamic.light_cache_changes.has(rid) || !(probe_data->dynamic.light_cache_changes[rid] == lc)) { + if ((!probe_data->dynamic.light_cache_changes.has(rid) || !(probe_data->dynamic.light_cache_changes[rid] == lc)) && lc.visible) { //erase light data _bake_gi_probe_light(header, cells, local_data, leaves, leaf_count, lc, -1); @@ -2361,7 +2361,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) { RID rid = E->key(); const InstanceGIProbeData::LightCache &lc = E->get(); - if (!probe_data->dynamic.light_cache.has(rid) || !(probe_data->dynamic.light_cache[rid] == lc)) { + if ((!probe_data->dynamic.light_cache.has(rid) || !(probe_data->dynamic.light_cache[rid] == lc)) && lc.visible) { //add light data _bake_gi_probe_light(header, cells, local_data, leaves, leaf_count, lc, 1); @@ -2568,6 +2568,7 @@ bool VisualServerScene::_check_gi_probe(Instance *p_gi_probe) { lc.spot_angle = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_SPOT_ANGLE); lc.spot_attenuation = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_SPOT_ATTENUATION); lc.transform = probe_data->dynamic.light_to_cell_xform * E->get()->transform; + lc.visible = E->get()->visible; if (!probe_data->dynamic.light_cache.has(E->get()->self) || !(probe_data->dynamic.light_cache[E->get()->self] == lc)) { all_equal = false; @@ -2587,6 +2588,7 @@ bool VisualServerScene::_check_gi_probe(Instance *p_gi_probe) { lc.spot_angle = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_SPOT_ANGLE); lc.spot_attenuation = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_SPOT_ATTENUATION); lc.transform = probe_data->dynamic.light_to_cell_xform * E->get()->transform; + lc.visible = E->get()->visible; if (!probe_data->dynamic.light_cache.has(E->get()->self) || !(probe_data->dynamic.light_cache[E->get()->self] == lc)) { all_equal = false; diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h index ac771030cf..d30a2108a5 100644 --- a/servers/visual/visual_server_scene.h +++ b/servers/visual/visual_server_scene.h @@ -359,6 +359,7 @@ public: float attenuation; float spot_angle; float spot_attenuation; + bool visible; bool operator==(const LightCache &p_cache) { @@ -369,7 +370,8 @@ public: radius == p_cache.radius && attenuation == p_cache.attenuation && spot_angle == p_cache.spot_angle && - spot_attenuation == p_cache.spot_attenuation); + spot_attenuation == p_cache.spot_attenuation && + visible == p_cache.visible); } LightCache() { @@ -380,6 +382,7 @@ public: attenuation = 1.0; spot_angle = 1.0; spot_attenuation = 1.0; + visible = true; } }; |