diff options
34 files changed, 290 insertions, 82 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/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/os/os.cpp b/core/os/os.cpp index ff17cdb508..4accd65bab 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; 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..3e27597e74 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; } 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/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/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 56e593e34b..288328c7ed 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -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; 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/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/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..f44b11ff63 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]; 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/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/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/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; } }; |