diff options
993 files changed, 18060 insertions, 13753 deletions
diff --git a/.gitignore b/.gitignore index b347b348a5..0de1e682a0 100644 --- a/.gitignore +++ b/.gitignore @@ -88,6 +88,9 @@ bld/ [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* +# Hints for improving IntelliSense, created together with VS project +cpp.hint + #NUNIT *.VisualState.xml TestResult.xml diff --git a/.travis.yml b/.travis.yml index 409c870e79..974ef93d3f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,12 +20,12 @@ matrix: #- env: GODOT_TARGET=windows TOOLS=yes # os: linux # compiler: gcc + - env: GODOT_TARGET=android TOOLS=no + os: linux + compiler: gcc - env: GODOT_TARGET=osx TOOLS=yes os: osx compiler: clang - #- env: GODOT_TARGET=android TOOLS=no - # os: osx - # compiler: clang #- env: GODOT_TARGET=iphone TOOLS=no # os: osx # compiler: clang @@ -61,15 +61,29 @@ addons: # For style checks. - clang-format-3.9 +install: + - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$GODOT_TARGET" = "android" ]; then + misc/travis/android-tools-linux.sh; + fi + - if [ "$TRAVIS_OS_NAME" = "osx" ]; then + misc/travis/scons-local-osx.sh; + misc/travis/ccache-osx.sh; + fi + - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$GODOT_TARGET" = "android" ]; then + misc/travis/android-tools-osx.sh; + fi + before_script: + - if [ "$TRAVIS_OS_NAME" = "linux" ]; then + export CCACHE="/usr/bin/ccache"; + fi - if [ "$TRAVIS_OS_NAME" = "osx" ]; then - brew update; brew install scons ccache; + export CCACHE="/usr/local/bin/ccache"; export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi - - if [ "$TRAVIS_OS_NAME" = "osx" ] && [ "$GODOT_TARGET" = "android" ]; then - brew update; brew install -v android-sdk; - brew install -v android-ndk | grep -v "inflating:" | grep -v "creating:"; - export ANDROID_HOME=/usr/local/opt/android-sdk; export ANDROID_NDK_ROOT=/usr/local/opt/android-ndk; + - if [ "$GODOT_TARGET" = "android" ]; then + export ANDROID_HOME=$TRAVIS_BUILD_DIR/godot-dev/build-tools/android-sdk; + export ANDROID_NDK_ROOT=$TRAVIS_BUILD_DIR/godot-dev/build-tools/android-ndk; fi script: @@ -78,3 +92,10 @@ script: else scons -j2 CC=$CC CXX=$CXX platform=$GODOT_TARGET TOOLS=$TOOLS verbose=yes progress=no; fi + +after_success: + - if [ "$STATIC_CHECKS" != "yes" ] && [ $(command -v ccache) ]; then + which ccache; + ccache --version | grep "ccache version"; + ccache -s; + fi; diff --git a/SConstruct b/SConstruct index 9d536e0d16..856994ef15 100644 --- a/SConstruct +++ b/SConstruct @@ -1,4 +1,3 @@ - #!/usr/bin/env python EnsureSConsVersion(0, 98, 1) @@ -23,6 +22,7 @@ platform_flags = {} # flags for each platform active_platforms = [] active_platform_ids = [] platform_exporters = [] +platform_apis = [] global_defaults = [] for x in glob.glob("platform/*"): @@ -35,6 +35,8 @@ for x in glob.glob("platform/*"): if (os.path.exists(x + "/export/export.cpp")): platform_exporters.append(x[9:]) + if (os.path.exists(x + "/api/api.cpp")): + platform_apis.append(x[9:]) if (os.path.exists(x + "/globals/global_defaults.cpp")): global_defaults.append(x[9:]) if (detect.is_active()): @@ -216,6 +218,7 @@ env_base.Append(CPPPATH=['#core', '#core/math', '#editor', '#drivers', '#']) # configure ENV for platform env_base.platform_exporters = platform_exporters +env_base.platform_apis = platform_apis """ sys.path.append("./platform/"+env_base["platform"]) @@ -271,9 +274,12 @@ if selected_platform in platform_list: if len(pieces) > 0: basename = pieces[0] basename = basename.replace('\\\\', '/') - env.vs_srcs = env.vs_srcs + [basename + ".cpp"] - env.vs_incs = env.vs_incs + [basename + ".h"] - # print basename + if os.path.isfile(basename + ".h"): + env.vs_incs = env.vs_incs + [basename + ".h"] + if os.path.isfile(basename + ".c"): + env.vs_srcs = env.vs_srcs + [basename + ".c"] + elif os.path.isfile(basename + ".cpp"): + env.vs_srcs = env.vs_srcs + [basename + ".cpp"] env.AddToVSProject = AddToVSProject env.extra_suffix = "" @@ -367,7 +373,7 @@ if selected_platform in platform_list: sys.modules.pop('detect') env.module_list = [] - env.doc_class_path={} + env.doc_class_path = {} for x in module_list: if not env['module_' + x + '_enabled']: @@ -383,11 +389,10 @@ if selected_platform in platform_list: doc_classes = config.get_doc_classes() doc_path = config.get_doc_path() for c in doc_classes: - env.doc_class_path[c]="modules/"+x+"/"+doc_path + env.doc_class_path[c] = "modules/" + x + "/" + doc_path except: pass - sys.path.remove(tmppath) sys.modules.pop('config') @@ -437,6 +442,7 @@ if selected_platform in platform_list: SConscript("editor/SCsub") SConscript("drivers/SCsub") + SConscript("platform/SCsub") SConscript("modules/SCsub") SConscript("main/SCsub") @@ -446,6 +452,7 @@ if selected_platform in platform_list: if env['vsproj']: env['CPPPATH'] = [Dir(path) for path in env['CPPPATH']] methods.generate_vs_project(env, GetOption("num_jobs")) + methods.generate_cpp_hint_file("cpp.hint") # Check for the existence of headers conf = Configure(env) diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index c369f4bffe..999befaf67 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -888,9 +888,9 @@ void _OS::dump_resources_to_file(const String &p_file) { OS::get_singleton()->dump_resources_to_file(p_file.utf8().get_data()); } -String _OS::get_data_dir() const { +String _OS::get_user_data_dir() const { - return OS::get_singleton()->get_data_dir(); + return OS::get_singleton()->get_user_data_dir(); }; Error _OS::native_video_play(String p_path, float p_volume, String p_audio_track, String p_subtitle_track) { @@ -1088,7 +1088,7 @@ void _OS::_bind_methods() { ClassDB::bind_method(D_METHOD("get_static_memory_peak_usage"), &_OS::get_static_memory_peak_usage); ClassDB::bind_method(D_METHOD("get_dynamic_memory_usage"), &_OS::get_dynamic_memory_usage); - ClassDB::bind_method(D_METHOD("get_data_dir"), &_OS::get_data_dir); + ClassDB::bind_method(D_METHOD("get_user_data_dir"), &_OS::get_user_data_dir); ClassDB::bind_method(D_METHOD("get_system_dir", "dir"), &_OS::get_system_dir); ClassDB::bind_method(D_METHOD("get_unique_id"), &_OS::get_unique_id); @@ -2592,6 +2592,16 @@ bool _Engine::is_in_physics_frame() const { return Engine::get_singleton()->is_in_physics_frame(); } +bool _Engine::has_singleton(const String &p_name) const { + + return Engine::get_singleton()->has_singleton(p_name); +} + +Object *_Engine::get_singleton_object(const String &p_name) const { + + return Engine::get_singleton()->get_singleton_object(p_name); +} + void _Engine::set_editor_hint(bool p_enabled) { Engine::get_singleton()->set_editor_hint(p_enabled); @@ -2621,6 +2631,9 @@ void _Engine::_bind_methods() { ClassDB::bind_method(D_METHOD("is_in_physics_frame"), &_Engine::is_in_physics_frame); + ClassDB::bind_method(D_METHOD("has_singleton", "name"), &_Engine::has_singleton); + ClassDB::bind_method(D_METHOD("get_singleton", "name"), &_Engine::get_singleton_object); + ClassDB::bind_method(D_METHOD("set_editor_hint", "enabled"), &_Engine::set_editor_hint); ClassDB::bind_method(D_METHOD("is_editor_hint"), &_Engine::is_editor_hint); } diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index bbbb40d926..8163b08d76 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -297,7 +297,7 @@ public: String get_system_dir(SystemDir p_dir) const; - String get_data_dir() const; + String get_user_data_dir() const; void alert(const String &p_alert, const String &p_title = "ALERT!"); @@ -670,6 +670,9 @@ public: bool is_in_physics_frame() const; + bool has_singleton(const String &p_name) const; + Object *get_singleton_object(const String &p_name) const; + void set_editor_hint(bool p_enabled); bool is_editor_hint() const; diff --git a/core/dictionary.cpp b/core/dictionary.cpp index 1b431f9ec9..48e65c734f 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -61,7 +61,7 @@ Variant &Dictionary::operator[](const Variant &p_key) { const Variant &Dictionary::operator[](const Variant &p_key) const { - return ((const OrderedHashMap<Variant, Variant, _DictionaryVariantHash> *)&_p->variant_map)->operator[](p_key); + return _p->variant_map[p_key]; } const Variant *Dictionary::getptr(const Variant &p_key) const { diff --git a/core/engine.cpp b/core/engine.cpp index c609ae9520..53c7a73b43 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -84,22 +84,47 @@ Dictionary Engine::get_version_info() const { #else dict["patch"] = 0; #endif - dict["status"] = _MKSTR(VERSION_STATUS); - dict["revision"] = _MKSTR(VERSION_REVISION); + dict["status"] = VERSION_STATUS; + dict["build"] = VERSION_BUILD; dict["year"] = VERSION_YEAR; - String hash = String(VERSION_HASH); + String hash = VERSION_HASH; dict["hash"] = hash.length() == 0 ? String("unknown") : hash; String stringver = String(dict["major"]) + "." + String(dict["minor"]); if ((int)dict["patch"] != 0) stringver += "." + String(dict["patch"]); - stringver += "-" + String(dict["status"]) + " (" + String(dict["revision"]) + ")"; + stringver += "-" + String(dict["status"]) + " (" + String(dict["build"]) + ")"; dict["string"] = stringver; return dict; } +void Engine::add_singleton(const Singleton &p_singleton) { + + singletons.push_back(p_singleton); + singleton_ptrs[p_singleton.name] = p_singleton.ptr; +} + +Object *Engine::get_singleton_object(const String &p_name) const { + + const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name); + ERR_EXPLAIN("Failed to retrieve non-existent singleton '" + p_name + "'"); + ERR_FAIL_COND_V(!E, NULL); + return E->get(); +}; + +bool Engine::has_singleton(const String &p_name) const { + + return singleton_ptrs.has(p_name); +}; + +void Engine::get_singletons(List<Singleton> *p_singletons) { + + for (List<Singleton>::Element *E = singletons.front(); E; E = E->next()) + p_singletons->push_back(E->get()); +} + Engine *Engine::singleton = NULL; Engine *Engine::get_singleton() { diff --git a/core/engine.h b/core/engine.h index 3b4979582f..4a573c1539 100644 --- a/core/engine.h +++ b/core/engine.h @@ -37,6 +37,17 @@ class Engine { +public: + struct Singleton { + StringName name; + Object *ptr; + Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL) + : name(p_name), + ptr(p_ptr) { + } + }; + +private: friend class Main; uint64_t frames_drawn; @@ -54,6 +65,9 @@ class Engine { uint64_t _idle_frames; bool _in_physics; + List<Singleton> singletons; + Map<StringName, Object *> singleton_ptrs; + bool editor_hint; static Engine *singleton; @@ -83,6 +97,11 @@ public: void set_frame_delay(uint32_t p_msec); uint32_t get_frame_delay() const; + void add_singleton(const Singleton &p_singleton); + void get_singletons(List<Singleton> *p_singletons); + bool has_singleton(const String &p_name) const; + Object *get_singleton_object(const String &p_name) const; + _FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; } #ifdef TOOLS_ENABLED diff --git a/core/global_constants.cpp b/core/global_constants.cpp index 8bddeae69a..48101c8cf1 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -435,6 +435,8 @@ void register_global_constants() { BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_5); BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_6); BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_7); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_8); + BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_9); BIND_GLOBAL_ENUM_CONSTANT(JOY_AXIS_MAX); BIND_GLOBAL_ENUM_CONSTANT(JOY_ANALOG_LX); @@ -555,7 +557,7 @@ void register_global_constants() { BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM2D", Variant::TRANSFORM2D); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_PLANE", Variant::PLANE); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_QUAT", Variant::QUAT); // 10 - BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_RECT3", Variant::RECT3); + BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_AABB", Variant::AABB); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_BASIS", Variant::BASIS); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_TRANSFORM", Variant::TRANSFORM); BIND_GLOBAL_ENUM_CONSTANT_CUSTOM("TYPE_COLOR", Variant::COLOR); diff --git a/core/helper/math_fieldwise.cpp b/core/helper/math_fieldwise.cpp index 228611f8b3..2cd8a4f392 100644 --- a/core/helper/math_fieldwise.cpp +++ b/core/helper/math_fieldwise.cpp @@ -46,8 +46,8 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const switch (p_source.get_type()) { - /* clang-format makes a mess of this macro usage */ - /* clang-format off */ + /* clang-format makes a mess of this macro usage */ + /* clang-format off */ case Variant::VECTOR2: { @@ -106,9 +106,9 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const return target; } - case Variant::RECT3: { + case Variant::AABB: { - SETUP_TYPE(Rect3) + SETUP_TYPE(AABB) /**/ TRY_TRANSFER_FIELD("px", position.x) else TRY_TRANSFER_FIELD("py", position.y) diff --git a/core/image.cpp b/core/image.cpp index 42684e7ea7..422c0e407b 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -757,22 +757,24 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) { _copy_internals_from(dst); } -void Image::crop(int p_width, int p_height) { +void Image::crop_from_point(int p_x, int p_y, int p_width, int p_height) { if (!_can_modify(format)) { ERR_EXPLAIN("Cannot crop in indexed, compressed or custom image formats."); ERR_FAIL(); } + ERR_FAIL_COND(p_x < 0); + ERR_FAIL_COND(p_y < 0); ERR_FAIL_COND(p_width <= 0); ERR_FAIL_COND(p_height <= 0); - ERR_FAIL_COND(p_width > MAX_WIDTH); - ERR_FAIL_COND(p_height > MAX_HEIGHT); + ERR_FAIL_COND(p_x + p_width > MAX_WIDTH); + ERR_FAIL_COND(p_y + p_height > MAX_HEIGHT); /* to save memory, cropping should be done in-place, however, since this function will most likely either not be used much, or in critical areas, for now it wont, because it's a waste of time. */ - if (p_width == width && p_height == height) + if (p_width == width && p_height == height && p_x == 0 && p_y == 0) return; uint8_t pdata[16]; //largest is 16 @@ -784,9 +786,11 @@ void Image::crop(int p_width, int p_height) { PoolVector<uint8_t>::Read r = data.read(); PoolVector<uint8_t>::Write w = dst.data.write(); - for (int y = 0; y < p_height; y++) { + int m_h = p_y + p_height; + int m_w = p_x + p_width; + for (int y = p_y; y < m_h; y++) { - for (int x = 0; x < p_width; x++) { + for (int x = p_x; x < m_w; x++) { if ((x >= width || y >= height)) { for (uint32_t i = 0; i < pixel_size; i++) @@ -795,7 +799,7 @@ void Image::crop(int p_width, int p_height) { _get_pixelb(x, y, pixel_size, r.ptr(), pdata); } - dst._put_pixelb(x, y, pixel_size, w.ptr(), pdata); + dst._put_pixelb(x - p_x, y - p_y, pixel_size, w.ptr(), pdata); } } } @@ -805,6 +809,11 @@ void Image::crop(int p_width, int p_height) { _copy_internals_from(dst); } +void Image::crop(int p_width, int p_height) { + + crop_from_point(0, 0, p_width, p_height); +} + void Image::flip_y() { if (!_can_modify(format)) { diff --git a/core/image.h b/core/image.h index 27df65a898..24693aa706 100644 --- a/core/image.h +++ b/core/image.h @@ -207,6 +207,7 @@ public: /** * Crop the image to a specific size, if larger, then the image is filled by black */ + void crop_from_point(int p_x, int p_y, int p_width, int p_height); void crop(int p_width, int p_height); void flip_x(); diff --git a/core/io/http_client.cpp b/core/io/http_client.cpp index 46d52384e5..5097898314 100644 --- a/core/io/http_client.cpp +++ b/core/io/http_client.cpp @@ -30,6 +30,7 @@ #include "http_client.h" #include "io/stream_peer_ssl.h" +#ifndef JAVASCRIPT_ENABLED Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) { close(); @@ -405,38 +406,6 @@ Error HTTPClient::poll() { return OK; } -Dictionary HTTPClient::_get_response_headers_as_dictionary() { - - List<String> rh; - get_response_headers(&rh); - Dictionary ret; - for (const List<String>::Element *E = rh.front(); E; E = E->next()) { - String s = E->get(); - int sp = s.find(":"); - if (sp == -1) - continue; - String key = s.substr(0, sp).strip_edges(); - String value = s.substr(sp + 1, s.length()).strip_edges(); - ret[key] = value; - } - - return ret; -} - -PoolStringArray HTTPClient::_get_response_headers() { - - List<String> rh; - get_response_headers(&rh); - PoolStringArray ret; - ret.resize(rh.size()); - int idx = 0; - for (const List<String>::Element *E = rh.front(); E; E = E->next()) { - ret.set(idx++, E->get()); - } - - return ret; -} - int HTTPClient::get_response_body_length() const { return body_size; @@ -612,6 +581,74 @@ Error HTTPClient::_get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received } } +void HTTPClient::set_read_chunk_size(int p_size) { + ERR_FAIL_COND(p_size < 256 || p_size > (1 << 24)); + read_chunk_size = p_size; +} + +HTTPClient::HTTPClient() { + + tcp_connection = StreamPeerTCP::create_ref(); + resolving = IP::RESOLVER_INVALID_ID; + status = STATUS_DISCONNECTED; + conn_port = 80; + body_size = 0; + chunked = false; + body_left = 0; + chunk_left = 0; + response_num = 0; + ssl = false; + blocking = false; + read_chunk_size = 4096; +} + +HTTPClient::~HTTPClient() { +} + +#endif // #ifndef JAVASCRIPT_ENABLED + +String HTTPClient::query_string_from_dict(const Dictionary &p_dict) { + String query = ""; + Array keys = p_dict.keys(); + for (int i = 0; i < keys.size(); ++i) { + query += "&" + String(keys[i]).http_escape() + "=" + String(p_dict[keys[i]]).http_escape(); + } + query.erase(0, 1); + return query; +} + +Dictionary HTTPClient::_get_response_headers_as_dictionary() { + + List<String> rh; + get_response_headers(&rh); + Dictionary ret; + for (const List<String>::Element *E = rh.front(); E; E = E->next()) { + String s = E->get(); + int sp = s.find(":"); + if (sp == -1) + continue; + String key = s.substr(0, sp).strip_edges(); + String value = s.substr(sp + 1, s.length()).strip_edges(); + ret[key] = value; + } + + return ret; +} + +PoolStringArray HTTPClient::_get_response_headers() { + + List<String> rh; + get_response_headers(&rh); + PoolStringArray ret; + ret.resize(rh.size()); + int idx = 0; + for (const List<String>::Element *E = rh.front(); E; E = E->next()) { + ret.set(idx++, E->get()); + } + + return ret; +} + void HTTPClient::_bind_methods() { ClassDB::bind_method(D_METHOD("connect_to_host", "host", "port", "use_ssl", "verify_host"), &HTTPClient::connect_to_host, DEFVAL(false), DEFVAL(true)); @@ -717,37 +754,3 @@ void HTTPClient::_bind_methods() { BIND_ENUM_CONSTANT(RESPONSE_INSUFFICIENT_STORAGE); BIND_ENUM_CONSTANT(RESPONSE_NOT_EXTENDED); } - -void HTTPClient::set_read_chunk_size(int p_size) { - ERR_FAIL_COND(p_size < 256 || p_size > (1 << 24)); - read_chunk_size = p_size; -} - -String HTTPClient::query_string_from_dict(const Dictionary &p_dict) { - String query = ""; - Array keys = p_dict.keys(); - for (int i = 0; i < keys.size(); ++i) { - query += "&" + String(keys[i]).http_escape() + "=" + String(p_dict[keys[i]]).http_escape(); - } - query.erase(0, 1); - return query; -} - -HTTPClient::HTTPClient() { - - tcp_connection = StreamPeerTCP::create_ref(); - resolving = IP::RESOLVER_INVALID_ID; - status = STATUS_DISCONNECTED; - conn_port = 80; - body_size = 0; - chunked = false; - body_left = 0; - chunk_left = 0; - response_num = 0; - ssl = false; - blocking = false; - read_chunk_size = 4096; -} - -HTTPClient::~HTTPClient() { -} diff --git a/core/io/http_client.h b/core/io/http_client.h index f8a3349e6e..db5dd115bd 100644 --- a/core/io/http_client.h +++ b/core/io/http_client.h @@ -131,6 +131,7 @@ public: }; private: +#ifndef JAVASCRIPT_ENABLED Status status; IP::ResolverID resolving; int conn_port; @@ -152,13 +153,18 @@ private: int response_num; Vector<String> response_headers; + int read_chunk_size; + + Error _get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received); + +#else +#include "platform/javascript/http_client.h.inc" +#endif - static void _bind_methods(); PoolStringArray _get_response_headers(); Dictionary _get_response_headers_as_dictionary(); - int read_chunk_size; - Error _get_http_data(uint8_t *p_buffer, int p_bytes, int &r_received); + static void _bind_methods(); public: //Error connect_and_get(const String& p_url,bool p_verify_host=true); //connects to a full url and perform request diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index d388a622de..1d9d2dd959 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -159,7 +159,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int r_variant = str; } break; - // math types + // math types case Variant::VECTOR2: { @@ -245,10 +245,10 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int (*r_len) += 4 * 4; } break; - case Variant::RECT3: { + case Variant::AABB: { ERR_FAIL_COND_V(len < (int)4 * 6, ERR_INVALID_DATA); - Rect3 val; + AABB val; val.position.x = decode_float(&buf[0]); val.position.y = decode_float(&buf[4]); val.position.z = decode_float(&buf[8]); @@ -967,7 +967,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo _encode_string(p_variant, buf, r_len); } break; - // math types + // math types case Variant::VECTOR2: { @@ -1045,10 +1045,10 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo r_len += 4 * 4; } break; - case Variant::RECT3: { + case Variant::AABB: { if (buf) { - Rect3 aabb = p_variant; + AABB aabb = p_variant; encode_float(aabb.position.x, &buf[0]); encode_float(aabb.position.y, &buf[4]); encode_float(aabb.position.z, &buf[8]); diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 03c3c5f615..8dc396c362 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -52,7 +52,7 @@ enum { VARIANT_VECTOR3 = 12, VARIANT_PLANE = 13, VARIANT_QUAT = 14, - VARIANT_RECT3 = 15, + VARIANT_AABB = 15, VARIANT_MATRIX3 = 16, VARIANT_TRANSFORM = 17, VARIANT_MATRIX32 = 18, @@ -196,9 +196,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) { r_v = v; } break; - case VARIANT_RECT3: { + case VARIANT_AABB: { - Rect3 v; + AABB v; v.position.x = f->get_real(); v.position.y = f->get_real(); v.position.z = f->get_real(); @@ -1374,10 +1374,10 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant &p_property, f->store_real(val.w); } break; - case Variant::RECT3: { + case Variant::AABB: { - f->store_32(VARIANT_RECT3); - Rect3 val = p_property; + f->store_32(VARIANT_AABB); + AABB val = p_property; f->store_real(val.position.x); f->store_real(val.position.y); f->store_real(val.position.z); diff --git a/core/math/rect3.cpp b/core/math/aabb.cpp index 6f01000f61..737a42b337 100644 --- a/core/math/rect3.cpp +++ b/core/math/aabb.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* rect3.cpp */ +/* aabb.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,25 +27,25 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "rect3.h" +#include "aabb.h" #include "print_string.h" -real_t Rect3::get_area() const { +real_t AABB::get_area() const { return size.x * size.y * size.z; } -bool Rect3::operator==(const Rect3 &p_rval) const { +bool AABB::operator==(const AABB &p_rval) const { return ((position == p_rval.position) && (size == p_rval.size)); } -bool Rect3::operator!=(const Rect3 &p_rval) const { +bool AABB::operator!=(const AABB &p_rval) const { return ((position != p_rval.position) || (size != p_rval.size)); } -void Rect3::merge_with(const Rect3 &p_aabb) { +void AABB::merge_with(const AABB &p_aabb) { Vector3 beg_1, beg_2; Vector3 end_1, end_2; @@ -68,7 +68,7 @@ void Rect3::merge_with(const Rect3 &p_aabb) { size = max - min; } -Rect3 Rect3::intersection(const Rect3 &p_aabb) const { +AABB AABB::intersection(const AABB &p_aabb) const { Vector3 src_min = position; Vector3 src_max = position + size; @@ -78,7 +78,7 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const { Vector3 min, max; if (src_min.x > dst_max.x || src_max.x < dst_min.x) - return Rect3(); + return AABB(); else { min.x = (src_min.x > dst_min.x) ? src_min.x : dst_min.x; @@ -86,7 +86,7 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const { } if (src_min.y > dst_max.y || src_max.y < dst_min.y) - return Rect3(); + return AABB(); else { min.y = (src_min.y > dst_min.y) ? src_min.y : dst_min.y; @@ -94,17 +94,17 @@ Rect3 Rect3::intersection(const Rect3 &p_aabb) const { } if (src_min.z > dst_max.z || src_max.z < dst_min.z) - return Rect3(); + return AABB(); else { min.z = (src_min.z > dst_min.z) ? src_min.z : dst_min.z; max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z; } - return Rect3(min, max - min); + return AABB(min, max - min); } -bool Rect3::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const { +bool AABB::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip, Vector3 *r_normal) const { Vector3 c1, c2; Vector3 end = position + size; @@ -147,7 +147,7 @@ bool Rect3::intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 return true; } -bool Rect3::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip, Vector3 *r_normal) const { +bool AABB::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip, Vector3 *r_normal) const { real_t min = 0, max = 1; int axis = 0; @@ -205,7 +205,7 @@ bool Rect3::intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vecto return true; } -bool Rect3::intersects_plane(const Plane &p_plane) const { +bool AABB::intersects_plane(const Plane &p_plane) const { Vector3 points[8] = { Vector3(position.x, position.y, position.z), @@ -232,7 +232,7 @@ bool Rect3::intersects_plane(const Plane &p_plane) const { return under && over; } -Vector3 Rect3::get_longest_axis() const { +Vector3 AABB::get_longest_axis() const { Vector3 axis(1, 0, 0); real_t max_size = size.x; @@ -249,7 +249,7 @@ Vector3 Rect3::get_longest_axis() const { return axis; } -int Rect3::get_longest_axis_index() const { +int AABB::get_longest_axis_index() const { int axis = 0; real_t max_size = size.x; @@ -267,7 +267,7 @@ int Rect3::get_longest_axis_index() const { return axis; } -Vector3 Rect3::get_shortest_axis() const { +Vector3 AABB::get_shortest_axis() const { Vector3 axis(1, 0, 0); real_t max_size = size.x; @@ -284,7 +284,7 @@ Vector3 Rect3::get_shortest_axis() const { return axis; } -int Rect3::get_shortest_axis_index() const { +int AABB::get_shortest_axis_index() const { int axis = 0; real_t max_size = size.x; @@ -302,25 +302,25 @@ int Rect3::get_shortest_axis_index() const { return axis; } -Rect3 Rect3::merge(const Rect3 &p_with) const { +AABB AABB::merge(const AABB &p_with) const { - Rect3 aabb = *this; + AABB aabb = *this; aabb.merge_with(p_with); return aabb; } -Rect3 Rect3::expand(const Vector3 &p_vector) const { - Rect3 aabb = *this; +AABB AABB::expand(const Vector3 &p_vector) const { + AABB aabb = *this; aabb.expand_to(p_vector); return aabb; } -Rect3 Rect3::grow(real_t p_by) const { +AABB AABB::grow(real_t p_by) const { - Rect3 aabb = *this; + AABB aabb = *this; aabb.grow_by(p_by); return aabb; } -void Rect3::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const { +void AABB::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const { ERR_FAIL_INDEX(p_edge, 12); switch (p_edge) { @@ -394,7 +394,7 @@ void Rect3::get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const { } } -Rect3::operator String() const { +AABB::operator String() const { return String() + position + " - " + size; } diff --git a/core/math/rect3.h b/core/math/aabb.h index c3a2f5fbfb..c60213496a 100644 --- a/core/math/rect3.h +++ b/core/math/aabb.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* rect3.h */ +/* aabb.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -39,7 +39,7 @@ * This is implemented by a point (position) and the box size */ -class Rect3 { +class AABB { public: Vector3 position; Vector3 size; @@ -60,16 +60,16 @@ public: const Vector3 &get_size() const { return size; } void set_size(const Vector3 &p_size) { size = p_size; } - bool operator==(const Rect3 &p_rval) const; - bool operator!=(const Rect3 &p_rval) const; + bool operator==(const AABB &p_rval) const; + bool operator!=(const AABB &p_rval) const; - _FORCE_INLINE_ bool intersects(const Rect3 &p_aabb) const; /// Both AABBs overlap - _FORCE_INLINE_ bool intersects_inclusive(const Rect3 &p_aabb) const; /// Both AABBs (or their faces) overlap - _FORCE_INLINE_ bool encloses(const Rect3 &p_aabb) const; /// p_aabb is completely inside this + _FORCE_INLINE_ bool intersects(const AABB &p_aabb) const; /// Both AABBs overlap + _FORCE_INLINE_ bool intersects_inclusive(const AABB &p_aabb) const; /// Both AABBs (or their faces) overlap + _FORCE_INLINE_ bool encloses(const AABB &p_aabb) const; /// p_aabb is completely inside this - Rect3 merge(const Rect3 &p_with) const; - void merge_with(const Rect3 &p_aabb); ///merge with another AABB - Rect3 intersection(const Rect3 &p_aabb) const; ///get box where two intersect, empty if no intersection occurs + AABB merge(const AABB &p_with) const; + void merge_with(const AABB &p_aabb); ///merge with another AABB + AABB intersection(const AABB &p_aabb) const; ///get box where two intersect, empty if no intersection occurs bool intersects_segment(const Vector3 &p_from, const Vector3 &p_to, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const; bool intersects_ray(const Vector3 &p_from, const Vector3 &p_dir, Vector3 *r_clip = NULL, Vector3 *r_normal = NULL) const; _FORCE_INLINE_ bool smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const; @@ -88,26 +88,26 @@ public: int get_shortest_axis_index() const; _FORCE_INLINE_ real_t get_shortest_axis_size() const; - Rect3 grow(real_t p_by) const; + AABB grow(real_t p_by) const; _FORCE_INLINE_ void grow_by(real_t p_amount); void get_edge(int p_edge, Vector3 &r_from, Vector3 &r_to) const; _FORCE_INLINE_ Vector3 get_endpoint(int p_point) const; - Rect3 expand(const Vector3 &p_vector) const; + AABB expand(const Vector3 &p_vector) const; _FORCE_INLINE_ void project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const; _FORCE_INLINE_ void expand_to(const Vector3 &p_vector); /** expand to contain a point if necessary */ operator String() const; - _FORCE_INLINE_ Rect3() {} - inline Rect3(const Vector3 &p_pos, const Vector3 &p_size) + _FORCE_INLINE_ AABB() {} + inline AABB(const Vector3 &p_pos, const Vector3 &p_size) : position(p_pos), size(p_size) { } }; -inline bool Rect3::intersects(const Rect3 &p_aabb) const { +inline bool AABB::intersects(const AABB &p_aabb) const { if (position.x >= (p_aabb.position.x + p_aabb.size.x)) return false; @@ -125,7 +125,7 @@ inline bool Rect3::intersects(const Rect3 &p_aabb) const { return true; } -inline bool Rect3::intersects_inclusive(const Rect3 &p_aabb) const { +inline bool AABB::intersects_inclusive(const AABB &p_aabb) const { if (position.x > (p_aabb.position.x + p_aabb.size.x)) return false; @@ -143,7 +143,7 @@ inline bool Rect3::intersects_inclusive(const Rect3 &p_aabb) const { return true; } -inline bool Rect3::encloses(const Rect3 &p_aabb) const { +inline bool AABB::encloses(const AABB &p_aabb) const { Vector3 src_min = position; Vector3 src_max = position + size; @@ -159,7 +159,7 @@ inline bool Rect3::encloses(const Rect3 &p_aabb) const { (src_max.z > dst_max.z)); } -Vector3 Rect3::get_support(const Vector3 &p_normal) const { +Vector3 AABB::get_support(const Vector3 &p_normal) const { Vector3 half_extents = size * 0.5; Vector3 ofs = position + half_extents; @@ -171,7 +171,7 @@ Vector3 Rect3::get_support(const Vector3 &p_normal) const { ofs; } -Vector3 Rect3::get_endpoint(int p_point) const { +Vector3 AABB::get_endpoint(int p_point) const { switch (p_point) { case 0: return Vector3(position.x, position.y, position.z); @@ -187,7 +187,7 @@ Vector3 Rect3::get_endpoint(int p_point) const { ERR_FAIL_V(Vector3()); } -bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const { +bool AABB::intersects_convex_shape(const Plane *p_planes, int p_plane_count) const { Vector3 half_extents = size * 0.5; Vector3 ofs = position + half_extents; @@ -206,7 +206,7 @@ bool Rect3::intersects_convex_shape(const Plane *p_planes, int p_plane_count) co return true; } -bool Rect3::has_point(const Vector3 &p_point) const { +bool AABB::has_point(const Vector3 &p_point) const { if (p_point.x < position.x) return false; @@ -224,7 +224,7 @@ bool Rect3::has_point(const Vector3 &p_point) const { return true; } -inline void Rect3::expand_to(const Vector3 &p_vector) { +inline void AABB::expand_to(const Vector3 &p_vector) { Vector3 begin = position; Vector3 end = position + size; @@ -247,7 +247,7 @@ inline void Rect3::expand_to(const Vector3 &p_vector) { size = end - begin; } -void Rect3::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const { +void AABB::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t &r_max) const { Vector3 half_extents(size.x * 0.5, size.y * 0.5, size.z * 0.5); Vector3 center(position.x + half_extents.x, position.y + half_extents.y, position.z + half_extents.z); @@ -258,7 +258,7 @@ void Rect3::project_range_in_plane(const Plane &p_plane, real_t &r_min, real_t & r_max = distance + length; } -inline real_t Rect3::get_longest_axis_size() const { +inline real_t AABB::get_longest_axis_size() const { real_t max_size = size.x; @@ -273,7 +273,7 @@ inline real_t Rect3::get_longest_axis_size() const { return max_size; } -inline real_t Rect3::get_shortest_axis_size() const { +inline real_t AABB::get_shortest_axis_size() const { real_t max_size = size.x; @@ -288,7 +288,7 @@ inline real_t Rect3::get_shortest_axis_size() const { return max_size; } -bool Rect3::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const { +bool AABB::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, real_t t0, real_t t1) const { real_t divx = 1.0 / p_dir.x; real_t divy = 1.0 / p_dir.y; @@ -332,7 +332,7 @@ bool Rect3::smits_intersect_ray(const Vector3 &p_from, const Vector3 &p_dir, rea return ((tmin < t1) && (tmax > t0)); } -void Rect3::grow_by(real_t p_amount) { +void AABB::grow_by(real_t p_amount) { position.x -= p_amount; position.y -= p_amount; diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp index be950568cf..bdc040160f 100644 --- a/core/math/bsp_tree.cpp +++ b/core/math/bsp_tree.cpp @@ -31,7 +31,7 @@ #include "error_macros.h" #include "print_string.h" -void BSP_Tree::from_aabb(const Rect3 &p_aabb) { +void BSP_Tree::from_aabb(const AABB &p_aabb) { planes.clear(); @@ -67,7 +67,7 @@ Vector<Plane> BSP_Tree::get_planes() const { return planes; } -Rect3 BSP_Tree::get_aabb() const { +AABB BSP_Tree::get_aabb() const { return aabb; } @@ -577,7 +577,7 @@ BSP_Tree::BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius) { error_radius = p_error_radius; } -BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius) +BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius) : nodes(p_nodes), planes(p_planes), aabb(p_aabb), diff --git a/core/math/bsp_tree.h b/core/math/bsp_tree.h index 2e762ba4de..f64a13ce39 100644 --- a/core/math/bsp_tree.h +++ b/core/math/bsp_tree.h @@ -30,11 +30,11 @@ #ifndef BSP_TREE_H #define BSP_TREE_H +#include "aabb.h" #include "dvector.h" #include "face3.h" #include "method_ptrcall.h" #include "plane.h" -#include "rect3.h" #include "variant.h" #include "vector.h" /** @@ -64,7 +64,7 @@ private: Vector<Node> nodes; Vector<Plane> planes; - Rect3 aabb; + AABB aabb; real_t error_radius; int _get_points_inside(int p_node, const Vector3 *p_points, int *p_indices, const Vector3 &p_center, const Vector3 &p_half_extents, int p_indices_count) const; @@ -76,7 +76,7 @@ public: bool is_empty() const { return nodes.size() == 0; } Vector<Node> get_nodes() const; Vector<Plane> get_planes() const; - Rect3 get_aabb() const; + AABB get_aabb() const; bool point_is_inside(const Vector3 &p_point) const; int get_points_inside(const Vector3 *p_points, int p_point_count) const; @@ -85,12 +85,12 @@ public: operator Variant() const; - void from_aabb(const Rect3 &p_aabb); + void from_aabb(const AABB &p_aabb); BSP_Tree(); BSP_Tree(const Variant &p_variant); BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius = 0); - BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const Rect3 &p_aabb, real_t p_error_radius = 0); + BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius = 0); ~BSP_Tree(); }; diff --git a/core/math/camera_matrix.cpp b/core/math/camera_matrix.cpp index 2c587762e8..c5f1d57441 100644 --- a/core/math/camera_matrix.cpp +++ b/core/math/camera_matrix.cpp @@ -596,7 +596,7 @@ void CameraMatrix::make_scale(const Vector3 &p_scale) { matrix[2][2] = p_scale.z; } -void CameraMatrix::scale_translate_to_fit(const Rect3 &p_aabb) { +void CameraMatrix::scale_translate_to_fit(const AABB &p_aabb) { Vector3 min = p_aabb.position; Vector3 max = p_aabb.position + p_aabb.size; diff --git a/core/math/camera_matrix.h b/core/math/camera_matrix.h index 3145d73356..15d6b8128e 100644 --- a/core/math/camera_matrix.h +++ b/core/math/camera_matrix.h @@ -86,7 +86,7 @@ struct CameraMatrix { operator String() const; - void scale_translate_to_fit(const Rect3 &p_aabb); + void scale_translate_to_fit(const AABB &p_aabb); void make_scale(const Vector3 &p_scale); int get_pixels_per_meter(int p_for_pixel_width) const; operator Transform() const; diff --git a/core/math/face3.cpp b/core/math/face3.cpp index e1b172e491..070ce77db4 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -189,13 +189,13 @@ ClockDirection Face3::get_clock_dir() const { return (normal.dot(vertex[0]) >= 0) ? CLOCKWISE : COUNTERCLOCKWISE; } -bool Face3::intersects_aabb(const Rect3 &p_aabb) const { +bool Face3::intersects_aabb(const AABB &p_aabb) const { /** TEST PLANE **/ if (!p_aabb.intersects_plane(get_plane())) return false; -/** TEST FACE AXIS */ + /** TEST FACE AXIS */ #define TEST_AXIS(m_ax) \ { \ diff --git a/core/math/face3.h b/core/math/face3.h index 8e4a25fb7a..561fa31238 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -30,8 +30,8 @@ #ifndef FACE3_H #define FACE3_H +#include "aabb.h" #include "plane.h" -#include "rect3.h" #include "transform.h" #include "vector3.h" @@ -76,16 +76,16 @@ public: void get_support(const Vector3 &p_normal, const Transform &p_transform, Vector3 *p_vertices, int *p_count, int p_max) const; void project_range(const Vector3 &p_normal, const Transform &p_transform, real_t &r_min, real_t &r_max) const; - Rect3 get_aabb() const { + AABB get_aabb() const { - Rect3 aabb(vertex[0], Vector3()); + AABB aabb(vertex[0], Vector3()); aabb.expand_to(vertex[1]); aabb.expand_to(vertex[2]); return aabb; } - bool intersects_aabb(const Rect3 &p_aabb) const; - _FORCE_INLINE_ bool intersects_aabb2(const Rect3 &p_aabb) const; + bool intersects_aabb(const AABB &p_aabb) const; + _FORCE_INLINE_ bool intersects_aabb2(const AABB &p_aabb) const; operator String() const; inline Face3() {} @@ -96,7 +96,7 @@ public: } }; -bool Face3::intersects_aabb2(const Rect3 &p_aabb) const { +bool Face3::intersects_aabb2(const AABB &p_aabb) const { Vector3 perp = (vertex[0] - vertex[2]).cross(vertex[0] - vertex[1]); @@ -256,6 +256,6 @@ bool Face3::intersects_aabb2(const Rect3 &p_aabb) const { return true; } -//this sucks... + //this sucks... #endif // FACE3_H diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index 7c8fb6f17d..39bd34f03c 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -300,7 +300,7 @@ enum _CellFlags { static inline void _plot_face(uint8_t ***p_cell_status, int x, int y, int z, int len_x, int len_y, int len_z, const Vector3 &voxelsize, const Face3 &p_face) { - Rect3 aabb(Vector3(x, y, z), Vector3(len_x, len_y, len_z)); + AABB aabb(Vector3(x, y, z), Vector3(len_x, len_y, len_z)); aabb.position = aabb.position * voxelsize; aabb.size = aabb.size * voxelsize; @@ -575,7 +575,7 @@ PoolVector<Face3> Geometry::wrap_geometry(PoolVector<Face3> p_array, real_t *p_e PoolVector<Face3>::Read facesr = p_array.read(); const Face3 *faces = facesr.ptr(); - Rect3 global_aabb; + AABB global_aabb; for (int i = 0; i < face_count; i++) { diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index 7715e5d6e5..bc0b3717ed 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -39,6 +39,7 @@ #include <math.h> #define Math_PI 3.14159265358979323846 +#define Math_TAU 6.28318530717958647692 #define Math_SQRT12 0.7071067811865475244008443621048490 #define Math_LN2 0.693147180559945309417 #define Math_INF INFINITY @@ -271,7 +272,7 @@ public: #elif defined(_MSC_VER) && _MSC_VER < 1800 __asm fld a __asm fistp b - /*#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) +/*#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) // use AT&T inline assembly style, document that // we use memory as output (=m) and input (m) __asm__ __volatile__ ( diff --git a/core/math/octree.h b/core/math/octree.h index 95a67943fd..6acd4c5f75 100644 --- a/core/math/octree.h +++ b/core/math/octree.h @@ -30,10 +30,10 @@ #ifndef OCTREE_H #define OCTREE_H +#include "aabb.h" #include "list.h" #include "map.h" #include "print_string.h" -#include "rect3.h" #include "variant.h" #include "vector3.h" @@ -106,7 +106,7 @@ private: struct Octant { // cached for FAST plane check - Rect3 aabb; + AABB aabb; uint64_t last_pass; Octant *parent; @@ -152,8 +152,8 @@ private: OctreeElementID _id; Octant *common_parent; - Rect3 aabb; - Rect3 container_aabb; + AABB aabb; + AABB container_aabb; List<PairData *, AL> pair_list; @@ -334,7 +334,7 @@ private: } void _insert_element(Element *p_element, Octant *p_octant); - void _ensure_valid_root(const Rect3 &p_aabb); + void _ensure_valid_root(const AABB &p_aabb); bool _remove_element_from_octant(Element *p_element, Octant *p_octant, Octant *p_limit = NULL); void _remove_element(Element *p_element); void _pair_element(Element *p_element, Octant *p_octant); @@ -351,7 +351,7 @@ private: }; void _cull_convex(Octant *p_octant, _CullConvexData *p_cull); - void _cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask); + void _cull_aabb(Octant *p_octant, const AABB &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask); void _cull_segment(Octant *p_octant, const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask); void _cull_point(Octant *p_octant, const Vector3 &p_point, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask); @@ -370,8 +370,8 @@ private: } public: - OctreeElementID create(T *p_userdata, const Rect3 &p_aabb = Rect3(), int p_subindex = 0, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1); - void move(OctreeElementID p_id, const Rect3 &p_aabb); + OctreeElementID create(T *p_userdata, const AABB &p_aabb = AABB(), int p_subindex = 0, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1); + void move(OctreeElementID p_id, const AABB &p_aabb); void set_pairable(OctreeElementID p_id, bool p_pairable = false, uint32_t p_pairable_type = 0, uint32_t pairable_mask = 1); void erase(OctreeElementID p_id); @@ -380,7 +380,7 @@ public: int get_subindex(OctreeElementID p_id) const; int cull_convex(const Vector<Plane> &p_convex, T **p_result_array, int p_result_max, uint32_t p_mask = 0xFFFFFFFF); - int cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF); + int cull_aabb(const AABB &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF); int cull_segment(const Vector3 &p_from, const Vector3 &p_to, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF); int cull_point(const Vector3 &p_point, T **p_result_array, int p_result_max, int *p_subindex_array = NULL, uint32_t p_mask = 0xFFFFFFFF); @@ -479,7 +479,7 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct } else { /* check againt AABB where child should be */ - Rect3 aabb = p_octant->aabb; + AABB aabb = p_octant->aabb; aabb.size *= 0.5; if (i & 1) @@ -535,12 +535,12 @@ void Octree<T, use_pairs, AL>::_insert_element(Element *p_element, Octant *p_oct } template <class T, bool use_pairs, class AL> -void Octree<T, use_pairs, AL>::_ensure_valid_root(const Rect3 &p_aabb) { +void Octree<T, use_pairs, AL>::_ensure_valid_root(const AABB &p_aabb) { if (!root) { // octre is empty - Rect3 base(Vector3(), Vector3(1.0, 1.0, 1.0) * unit_size); + AABB base(Vector3(), Vector3(1.0, 1.0, 1.0) * unit_size); while (!base.encloses(p_aabb)) { @@ -563,7 +563,7 @@ void Octree<T, use_pairs, AL>::_ensure_valid_root(const Rect3 &p_aabb) { } else { - Rect3 base = root->aabb; + AABB base = root->aabb; while (!base.encloses(p_aabb)) { @@ -793,7 +793,7 @@ void Octree<T, use_pairs, AL>::_remove_element(Element *p_element) { } template <class T, bool use_pairs, class AL> -OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const Rect3 &p_aabb, int p_subindex, bool p_pairable, uint32_t p_pairable_type, uint32_t p_pairable_mask) { +OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const AABB &p_aabb, int p_subindex, bool p_pairable, uint32_t p_pairable_type, uint32_t p_pairable_mask) { // check for AABB validity #ifdef DEBUG_ENABLED @@ -833,7 +833,7 @@ OctreeElementID Octree<T, use_pairs, AL>::create(T *p_userdata, const Rect3 &p_a } template <class T, bool use_pairs, class AL> -void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) { +void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const AABB &p_aabb) { #ifdef DEBUG_ENABLED // check for AABB validity @@ -859,7 +859,7 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) { if (old_has_surf) { _remove_element(&e); // removing e.common_parent = NULL; - e.aabb = Rect3(); + e.aabb = AABB(); _optimize(); } else { _ensure_valid_root(p_aabb); // inserting @@ -886,7 +886,7 @@ void Octree<T, use_pairs, AL>::move(OctreeElementID p_id, const Rect3 &p_aabb) { return; } - Rect3 combined = e.aabb; + AABB combined = e.aabb; combined.merge_with(p_aabb); _ensure_valid_root(combined); @@ -1072,7 +1072,7 @@ void Octree<T, use_pairs, AL>::_cull_convex(Octant *p_octant, _CullConvexData *p } template <class T, bool use_pairs, class AL> -void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const Rect3 &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) { +void Octree<T, use_pairs, AL>::_cull_aabb(Octant *p_octant, const AABB &p_aabb, T **p_result_array, int *p_result_idx, int p_result_max, int *p_subindex_array, uint32_t p_mask) { if (*p_result_idx == p_result_max) return; //pointless @@ -1313,7 +1313,7 @@ int Octree<T, use_pairs, AL>::cull_convex(const Vector<Plane> &p_convex, T **p_r } template <class T, bool use_pairs, class AL> -int Octree<T, use_pairs, AL>::cull_aabb(const Rect3 &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) { +int Octree<T, use_pairs, AL>::cull_aabb(const AABB &p_aabb, T **p_result_array, int p_result_max, int *p_subindex_array, uint32_t p_mask) { if (!root) return 0; diff --git a/core/math/quick_hull.cpp b/core/math/quick_hull.cpp index e0137b6921..946d9f6b79 100644 --- a/core/math/quick_hull.cpp +++ b/core/math/quick_hull.cpp @@ -38,7 +38,7 @@ Error QuickHull::build(const Vector<Vector3> &p_points, Geometry::MeshData &r_me /* CREATE AABB VOLUME */ - Rect3 aabb; + AABB aabb; for (int i = 0; i < p_points.size(); i++) { if (i == 0) { diff --git a/core/math/quick_hull.h b/core/math/quick_hull.h index 47ed22615b..f014d0decc 100644 --- a/core/math/quick_hull.h +++ b/core/math/quick_hull.h @@ -30,9 +30,9 @@ #ifndef QUICK_HULL_H #define QUICK_HULL_H +#include "aabb.h" #include "geometry.h" #include "list.h" -#include "rect3.h" #include "set.h" class QuickHull { diff --git a/core/math/transform.h b/core/math/transform.h index 566bf482a9..4d91869121 100644 --- a/core/math/transform.h +++ b/core/math/transform.h @@ -30,9 +30,9 @@ #ifndef TRANSFORM_H #define TRANSFORM_H +#include "aabb.h" #include "matrix3.h" #include "plane.h" -#include "rect3.h" /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -80,8 +80,8 @@ public: _FORCE_INLINE_ Plane xform(const Plane &p_plane) const; _FORCE_INLINE_ Plane xform_inv(const Plane &p_plane) const; - _FORCE_INLINE_ Rect3 xform(const Rect3 &p_aabb) const; - _FORCE_INLINE_ Rect3 xform_inv(const Rect3 &p_aabb) const; + _FORCE_INLINE_ AABB xform(const AABB &p_aabb) const; + _FORCE_INLINE_ AABB xform_inv(const AABB &p_aabb) const; void operator*=(const Transform &p_transform); Transform operator*(const Transform &p_transform) const; @@ -153,14 +153,14 @@ _FORCE_INLINE_ Plane Transform::xform_inv(const Plane &p_plane) const { return Plane(normal, d); } -_FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const { +_FORCE_INLINE_ AABB Transform::xform(const AABB &p_aabb) const { /* define vertices */ Vector3 x = basis.get_axis(0) * p_aabb.size.x; Vector3 y = basis.get_axis(1) * p_aabb.size.y; Vector3 z = basis.get_axis(2) * p_aabb.size.z; Vector3 pos = xform(p_aabb.position); //could be even further optimized - Rect3 new_aabb; + AABB new_aabb; new_aabb.position = pos; new_aabb.expand_to(pos + x); new_aabb.expand_to(pos + y); @@ -172,7 +172,7 @@ _FORCE_INLINE_ Rect3 Transform::xform(const Rect3 &p_aabb) const { return new_aabb; } -_FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const { +_FORCE_INLINE_ AABB Transform::xform_inv(const AABB &p_aabb) const { /* define vertices */ Vector3 vertices[8] = { @@ -186,7 +186,7 @@ _FORCE_INLINE_ Rect3 Transform::xform_inv(const Rect3 &p_aabb) const { Vector3(p_aabb.position.x, p_aabb.position.y, p_aabb.position.z) }; - Rect3 ret; + AABB ret; ret.position = xform_inv(vertices[0]); diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp index 3b246cb183..5f57c7c26a 100644 --- a/core/math/triangle_mesh.cpp +++ b/core/math/triangle_mesh.cpp @@ -44,7 +44,7 @@ int TriangleMesh::_create_bvh(BVH *p_bvh, BVH **p_bb, int p_from, int p_size, in return -1; } - Rect3 aabb; + AABB aabb; aabb = p_bb[p_from]->aabb; for (int i = 1; i < p_size; i++) { @@ -166,7 +166,7 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) { valid = true; } -Vector3 TriangleMesh::get_area_normal(const Rect3 &p_aabb) const { +Vector3 TriangleMesh::get_area_normal(const AABB &p_aabb) const { uint32_t *stack = (uint32_t *)alloca(sizeof(int) * max_depth); diff --git a/core/math/triangle_mesh.h b/core/math/triangle_mesh.h index 2bf67fffcb..4bd9fecf37 100644 --- a/core/math/triangle_mesh.h +++ b/core/math/triangle_mesh.h @@ -47,7 +47,7 @@ class TriangleMesh : public Reference { struct BVH { - Rect3 aabb; + AABB aabb; Vector3 center; //used for sorting int left; int right; @@ -88,7 +88,7 @@ public: bool is_valid() const; bool intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_point, Vector3 &r_normal) const; bool intersect_ray(const Vector3 &p_begin, const Vector3 &p_dir, Vector3 &r_point, Vector3 &r_normal) const; - Vector3 get_area_normal(const Rect3 &p_aabb) const; + Vector3 get_area_normal(const AABB &p_aabb) const; PoolVector<Face3> get_faces() const; void create(const PoolVector<Vector3> &p_faces); diff --git a/core/method_ptrcall.h b/core/method_ptrcall.h index 2875eb912f..d819dfbc27 100644 --- a/core/method_ptrcall.h +++ b/core/method_ptrcall.h @@ -119,7 +119,7 @@ MAKE_PTRARG_BY_REFERENCE(Vector3); MAKE_PTRARG(Transform2D); MAKE_PTRARG_BY_REFERENCE(Plane); MAKE_PTRARG(Quat); -MAKE_PTRARG_BY_REFERENCE(Rect3); +MAKE_PTRARG_BY_REFERENCE(AABB); MAKE_PTRARG_BY_REFERENCE(Basis); MAKE_PTRARG_BY_REFERENCE(Transform); MAKE_PTRARG_BY_REFERENCE(Color); diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 0875f78478..35e4443f2a 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -38,7 +38,7 @@ String DirAccess::_get_root_path() const { switch (_access_type) { case ACCESS_RESOURCES: return ProjectSettings::get_singleton()->get_resource_path(); - case ACCESS_USERDATA: return OS::get_singleton()->get_data_dir(); + case ACCESS_USERDATA: return OS::get_singleton()->get_user_data_dir(); default: return ""; } @@ -217,7 +217,7 @@ String DirAccess::fix_path(String p_path) const { if (p_path.begins_with("user://")) { - String data_dir = OS::get_singleton()->get_data_dir(); + String data_dir = OS::get_singleton()->get_user_data_dir(); if (data_dir != "") { return p_path.replace_first("user:/", data_dir); diff --git a/core/os/file_access.cpp b/core/os/file_access.cpp index fcb3b58fed..5fdd2b9135 100644 --- a/core/os/file_access.cpp +++ b/core/os/file_access.cpp @@ -152,7 +152,7 @@ String FileAccess::fix_path(const String &p_path) const { if (r_path.begins_with("user://")) { - String data_dir = OS::get_singleton()->get_data_dir(); + String data_dir = OS::get_singleton()->get_user_data_dir(); if (data_dir != "") { return r_path.replace("user:/", data_dir); diff --git a/core/os/input_event.h b/core/os/input_event.h index f2c8cc802d..de3c0232ff 100644 --- a/core/os/input_event.h +++ b/core/os/input_event.h @@ -122,7 +122,9 @@ enum JoystickList { JOY_AXIS_5 = 5, JOY_AXIS_6 = 6, JOY_AXIS_7 = 7, - JOY_AXIS_MAX = 8, + JOY_AXIS_8 = 8, + JOY_AXIS_9 = 9, + JOY_AXIS_MAX = 10, JOY_ANALOG_LX = JOY_AXIS_0, JOY_ANALOG_LY = JOY_AXIS_1, diff --git a/core/os/os.cpp b/core/os/os.cpp index eb5d5be33d..65d0b2e05d 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -33,6 +33,7 @@ #include "input.h" #include "os/file_access.h" #include "project_settings.h" +#include "version_generated.gen.h" #include <stdarg.h> @@ -262,16 +263,7 @@ String OS::get_locale() const { return "en"; } -String OS::get_resource_dir() const { - - return ProjectSettings::get_singleton()->get_resource_path(); -} - -String OS::get_system_dir(SystemDir p_dir) const { - - return "."; -} - +// Helper function used by OS_Unix and OS_Windows String OS::get_safe_application_name() const { String an = ProjectSettings::get_singleton()->get("application/config/name"); Vector<String> invalid_char = String("\\ / : * ? \" < > |").split(" "); @@ -281,11 +273,51 @@ String OS::get_safe_application_name() const { return an; } -String OS::get_data_dir() const { +// Path to data, config, cache, etc. OS-specific folders + +// Get properly capitalized engine name for system paths +String OS::get_godot_dir_name() const { + + // Default to lowercase, so only override when different case is needed + return String(VERSION_SHORT_NAME).to_lower(); +} + +// OS equivalent of XDG_DATA_HOME +String OS::get_data_path() const { + + return "."; +} + +// OS equivalent of XDG_CONFIG_HOME +String OS::get_config_path() const { + + return "."; +} + +// OS equivalent of XDG_CACHE_HOME +String OS::get_cache_path() const { + + return "."; +} + +// OS specific path for user:// +String OS::get_user_data_dir() const { return "."; }; +// Absolute path to res:// +String OS::get_resource_dir() const { + + return ProjectSettings::get_singleton()->get_resource_path(); +} + +// Access system-specific dirs like Documents, Downloads, etc. +String OS::get_system_dir(SystemDir p_dir) const { + + return "."; +} + Error OS::shell_open(String p_uri) { return ERR_UNAVAILABLE; }; @@ -374,9 +406,9 @@ OS::ScreenOrientation OS::get_screen_orientation() const { return (OS::ScreenOrientation)_orientation; } -void OS::_ensure_data_dir() { +void OS::_ensure_user_data_dir() { - String dd = get_data_dir(); + String dd = get_user_data_dir(); DirAccess *da = DirAccess::open(dd); if (da) { memdelete(da); diff --git a/core/os/os.h b/core/os/os.h index f5e479ac0b..474cb60627 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -109,8 +109,6 @@ protected: virtual int get_video_driver_count() const = 0; virtual const char *get_video_driver_name(int p_driver) const = 0; - virtual VideoMode get_default_video_mode() const = 0; - virtual int get_audio_driver_count() const = 0; virtual const char *get_audio_driver_name(int p_driver) const = 0; @@ -126,7 +124,7 @@ protected: virtual void set_cmdline(const char *p_execpath, const List<String> &p_args); - void _ensure_data_dir(); + void _ensure_user_data_dir(); virtual bool _check_internal_feature_support(const String &p_feature) = 0; public: @@ -202,7 +200,6 @@ public: virtual void set_low_processor_usage_mode(bool p_enabled); virtual bool is_in_low_processor_usage_mode() const; - virtual String get_installed_templates_path() const { return ""; } virtual String get_executable_path() const; virtual Error execute(const String &p_path, const List<String> &p_arguments, bool p_blocking, ProcessID *r_child_id = NULL, String *r_pipe = NULL, int *r_exitcode = NULL, bool read_stderr = false) = 0; virtual Error kill(const ProcessID &p_pid) = 0; @@ -336,10 +333,14 @@ public: virtual String get_locale() const; String get_safe_application_name() const; - virtual String get_data_dir() const; - virtual String get_resource_dir() const; + virtual String get_godot_dir_name() const; - virtual Error move_to_trash(const String &p_path) { return FAILED; } + virtual String get_data_path() const; + virtual String get_config_path() const; + virtual String get_cache_path() const; + + virtual String get_user_data_dir() const; + virtual String get_resource_dir() const; enum SystemDir { SYSTEM_DIR_DESKTOP, @@ -354,6 +355,8 @@ public: virtual String get_system_dir(SystemDir p_dir) const; + virtual Error move_to_trash(const String &p_path) { return FAILED; } + virtual void set_no_window_mode(bool p_enable); virtual bool is_no_window_mode_enabled() const; diff --git a/core/packed_data_container.cpp b/core/packed_data_container.cpp index ad8438e416..3748df12f7 100644 --- a/core/packed_data_container.cpp +++ b/core/packed_data_container.cpp @@ -234,7 +234,7 @@ uint32_t PackedDataContainer::_pack(const Variant &p_data, Vector<uint8_t> &tmpd case Variant::TRANSFORM2D: case Variant::PLANE: case Variant::QUAT: - case Variant::RECT3: + case Variant::AABB: case Variant::BASIS: case Variant::TRANSFORM: case Variant::POOL_BYTE_ARRAY: diff --git a/core/print_string.cpp b/core/print_string.cpp index 92a04cbf0b..520fb3daec 100644 --- a/core/print_string.cpp +++ b/core/print_string.cpp @@ -82,7 +82,25 @@ void print_line(String p_string) { PrintHandlerList *l = print_handler_list; while (l) { - l->printfunc(l->userdata, p_string); + l->printfunc(l->userdata, p_string, false); + l = l->next; + } + + _global_unlock(); +} + +void print_error(String p_string) { + + if (!_print_error_enabled) + return; + + OS::get_singleton()->printerr("%s\n", p_string.utf8().get_data()); + + _global_lock(); + PrintHandlerList *l = print_handler_list; + while (l) { + + l->printfunc(l->userdata, p_string, true); l = l->next; } diff --git a/core/print_string.h b/core/print_string.h index 9f8420c31a..6b68380b9d 100644 --- a/core/print_string.h +++ b/core/print_string.h @@ -34,7 +34,7 @@ extern void (*_print_func)(String); -typedef void (*PrintHandlerFunc)(void *, const String &p_string); +typedef void (*PrintHandlerFunc)(void *, const String &p_string, bool p_error); struct PrintHandlerList { @@ -56,5 +56,6 @@ void remove_print_handler(PrintHandlerList *p_handler); extern bool _print_line_enabled; extern bool _print_error_enabled; extern void print_line(String p_string); +extern void print_error(String p_string); #endif diff --git a/core/project_settings.cpp b/core/project_settings.cpp index 2e4fc26784..361464ee1f 100644 --- a/core/project_settings.cpp +++ b/core/project_settings.cpp @@ -116,7 +116,7 @@ String ProjectSettings::globalize_path(const String &p_path) const { return p_path.replace("res://", ""); } else if (p_path.begins_with("user://")) { - String data_dir = OS::get_singleton()->get_data_dir(); + String data_dir = OS::get_singleton()->get_user_data_dir(); if (data_dir != "") { return p_path.replace("user:/", data_dir); @@ -776,32 +776,6 @@ Variant _GLOBAL_DEF(const String &p_var, const Variant &p_default) { return ret; } -void ProjectSettings::add_singleton(const Singleton &p_singleton) { - - singletons.push_back(p_singleton); - singleton_ptrs[p_singleton.name] = p_singleton.ptr; -} - -Object *ProjectSettings::get_singleton_object(const String &p_name) const { - - const Map<StringName, Object *>::Element *E = singleton_ptrs.find(p_name); - if (!E) - return NULL; - else - return E->get(); -}; - -bool ProjectSettings::has_singleton(const String &p_name) const { - - return get_singleton_object(p_name) != NULL; -}; - -void ProjectSettings::get_singletons(List<Singleton> *p_singletons) { - - for (List<Singleton>::Element *E = singletons.front(); E; E = E->next()) - p_singletons->push_back(E->get()); -} - Vector<String> ProjectSettings::get_optimizer_presets() const { List<PropertyInfo> pi; @@ -893,8 +867,6 @@ void ProjectSettings::_bind_methods() { ClassDB::bind_method(D_METHOD("localize_path", "path"), &ProjectSettings::localize_path); ClassDB::bind_method(D_METHOD("globalize_path", "path"), &ProjectSettings::globalize_path); ClassDB::bind_method(D_METHOD("save"), &ProjectSettings::save); - ClassDB::bind_method(D_METHOD("has_singleton", "name"), &ProjectSettings::has_singleton); - ClassDB::bind_method(D_METHOD("get_singleton", "name"), &ProjectSettings::get_singleton_object); ClassDB::bind_method(D_METHOD("load_resource_pack", "pack"), &ProjectSettings::_load_resource_pack); ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ProjectSettings::property_can_revert); ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &ProjectSettings::property_get_revert); diff --git a/core/project_settings.h b/core/project_settings.h index f75cad815f..1c4078cebb 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -45,14 +45,6 @@ class ProjectSettings : public Object { public: typedef Map<String, Variant> CustomMap; - struct Singleton { - StringName name; - Object *ptr; - Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL) - : name(p_name), - ptr(p_ptr) { - } - }; enum { //properties that are not for built in values begin from this value, so builtin ones are displayed first NO_BUILTIN_ORDER_BASE = 1 << 16 @@ -106,9 +98,6 @@ protected: Error _save_settings_text(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String()); Error _save_settings_binary(const String &p_file, const Map<String, List<String> > &props, const CustomMap &p_custom = CustomMap(), const String &p_custom_features = String()); - List<Singleton> singletons; - Map<StringName, Object *> singleton_ptrs; - Error _save_custom_bnd(const String &p_file); bool _load_resource_pack(const String &p_pack); @@ -145,17 +134,11 @@ public: Error save(); void set_custom_property_info(const String &p_prop, const PropertyInfo &p_info); - void add_singleton(const Singleton &p_singleton); - void get_singletons(List<Singleton> *p_singletons); - - bool has_singleton(const String &p_name) const; - Vector<String> get_optimizer_presets() const; List<String> get_input_presets() const { return input_presets; } void set_disable_feature_overrides(bool p_disable); - Object *get_singleton_object(const String &p_name) const; void register_global_defaults(); diff --git a/core/register_core_types.cpp b/core/register_core_types.cpp index c6d7cd44e8..baaf738b42 100644 --- a/core/register_core_types.cpp +++ b/core/register_core_types.cpp @@ -34,6 +34,7 @@ #include "compressed_translation.h" #include "core/io/xml_parser.h" #include "core_string_names.h" +#include "engine.h" #include "func_ref.h" #include "geometry.h" #include "input_map.h" @@ -203,19 +204,19 @@ void register_core_singletons() { ClassDB::register_class<InputMap>(); ClassDB::register_class<_JSON>(); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ProjectSettings", ProjectSettings::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("IP", IP::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Geometry", _Geometry::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ResourceLoader", _ResourceLoader::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ResourceSaver", _ResourceSaver::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("OS", _OS::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Engine", _Engine::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ClassDB", _classdb)); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Marshalls", _Marshalls::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("TranslationServer", TranslationServer::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Input", Input::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("InputMap", InputMap::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("JSON", _JSON::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("ProjectSettings", ProjectSettings::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("IP", IP::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("Geometry", _Geometry::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceLoader", _ResourceLoader::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("ResourceSaver", _ResourceSaver::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("OS", _OS::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("Engine", _Engine::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("ClassDB", _classdb)); + Engine::get_singleton()->add_singleton(Engine::Singleton("Marshalls", _Marshalls::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("TranslationServer", TranslationServer::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("Input", Input::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("InputMap", InputMap::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("JSON", _JSON::get_singleton())); } void unregister_core_types() { diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 2feb068ecb..5655a4d5e4 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "script_debugger_remote.h" +#include "engine.h" #include "io/ip.h" #include "io/marshalls.h" #include "os/input.h" @@ -831,7 +832,7 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_ mutex->unlock(); } -void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string) { +void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string, bool p_error) { ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)p_this; @@ -939,7 +940,7 @@ ScriptDebuggerRemote::ScriptDebuggerRemote() tcp_client(StreamPeerTCP::create_ref()), packet_peer_stream(Ref<PacketPeerStream>(memnew(PacketPeerStream))), last_perf_time(0), - performance(ProjectSettings::get_singleton()->get_singleton_object("Performance")), + performance(Engine::get_singleton()->get_singleton_object("Performance")), requested_quit(false), mutex(Mutex::create()), max_cps(GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second")), diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index 22137d1350..90d2daf1f8 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -94,7 +94,7 @@ class ScriptDebuggerRemote : public ScriptDebugger { uint64_t msec_count; bool locking; //hack to avoid a deadloop - static void _print_handler(void *p_this, const String &p_string); + static void _print_handler(void *p_this, const String &p_string, bool p_error); PrintHandlerList phl; diff --git a/core/translation.cpp b/core/translation.cpp index 058db956e5..7e4d4feb89 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -966,7 +966,7 @@ Vector<String> TranslationServer::get_all_locale_names() { const char **ptr = locale_names; while (*ptr) { - locales.push_back(*ptr); + locales.push_back(String::utf8(*ptr)); ptr++; } @@ -1168,6 +1168,6 @@ TranslationServer::TranslationServer() for (int i = 0; locale_list[i]; ++i) { - locale_name_map.insert(locale_list[i], locale_names[i]); + locale_name_map.insert(locale_list[i], String::utf8(locale_names[i])); } } diff --git a/core/type_info.h b/core/type_info.h index 9fb80af0eb..24d96c51e8 100644 --- a/core/type_info.h +++ b/core/type_info.h @@ -82,7 +82,7 @@ MAKE_TYPE_INFO(Vector3, Variant::VECTOR3) MAKE_TYPE_INFO(Transform2D, Variant::TRANSFORM2D) MAKE_TYPE_INFO(Plane, Variant::PLANE) MAKE_TYPE_INFO(Quat, Variant::QUAT) -MAKE_TYPE_INFO(Rect3, Variant::RECT3) +MAKE_TYPE_INFO(AABB, Variant::AABB) MAKE_TYPE_INFO(Basis, Variant::BASIS) MAKE_TYPE_INFO(Transform, Variant::TRANSFORM) MAKE_TYPE_INFO(Color, Variant::COLOR) diff --git a/core/ustring.cpp b/core/ustring.cpp index 415494ddc8..7c3a784c5b 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -564,7 +564,7 @@ void String::erase(int p_pos, int p_chars) { String String::capitalize() const { - String aux = this->replace("_", " ").to_lower(); + String aux = this->camelcase_to_underscore(true).replace("_", " ").strip_edges(); String cap; for (int i = 0; i < aux.get_slice_count(" "); i++) { diff --git a/core/variant.cpp b/core/variant.cpp index f70e4a5218..1dca494492 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -66,7 +66,7 @@ String Variant::get_type_name(Variant::Type p_type) { return "String"; } break; - // math types + // math types case VECTOR2: { @@ -94,9 +94,9 @@ String Variant::get_type_name(Variant::Type p_type) { } break;*/ - case RECT3: { + case AABB: { - return "Rect3"; + return "AABB"; } break; case QUAT: { @@ -722,7 +722,7 @@ bool Variant::is_zero() const { } break; - // math types + // math types case VECTOR2: { @@ -754,9 +754,9 @@ bool Variant::is_zero() const { } break;*/ - case RECT3: { + case AABB: { - return *_data._rect3 == Rect3(); + return *_data._aabb == ::AABB(); } break; case QUAT: { @@ -931,7 +931,7 @@ void Variant::reference(const Variant &p_variant) { memnew_placement(_data._mem, String(*reinterpret_cast<const String *>(p_variant._data._mem))); } break; - // math types + // math types case VECTOR2: { @@ -954,9 +954,9 @@ void Variant::reference(const Variant &p_variant) { memnew_placement(_data._mem, Plane(*reinterpret_cast<const Plane *>(p_variant._data._mem))); } break; - case RECT3: { + case AABB: { - _data._rect3 = memnew(Rect3(*p_variant._data._rect3)); + _data._aabb = memnew(::AABB(*p_variant._data._aabb)); } break; case QUAT: { @@ -1079,9 +1079,9 @@ void Variant::clear() { memdelete(_data._transform2d); } break; - case RECT3: { + case AABB: { - memdelete(_data._rect3); + memdelete(_data._aabb); } break; case BASIS: { @@ -1426,7 +1426,7 @@ Variant::operator String() const { case PLANE: return operator Plane(); //case QUAT: - case RECT3: return operator Rect3(); + case AABB: return operator ::AABB(); case QUAT: return "(" + operator Quat() + ")"; case BASIS: { @@ -1617,12 +1617,12 @@ Variant::operator Plane() const { else return Plane(); } -Variant::operator Rect3() const { +Variant::operator ::AABB() const { - if (type == RECT3) - return *_data._rect3; + if (type == AABB) + return *_data._aabb; else - return Rect3(); + return ::AABB(); } Variant::operator Basis() const { @@ -2188,10 +2188,10 @@ Variant::Variant(const Plane &p_plane) { type = PLANE; memnew_placement(_data._mem, Plane(p_plane)); } -Variant::Variant(const Rect3 &p_aabb) { +Variant::Variant(const ::AABB &p_aabb) { - type = RECT3; - _data._rect3 = memnew(Rect3(p_aabb)); + type = AABB; + _data._aabb = memnew(::AABB(p_aabb)); } Variant::Variant(const Basis &p_matrix) { @@ -2501,7 +2501,7 @@ void Variant::operator=(const Variant &p_variant) { *reinterpret_cast<String *>(_data._mem) = *reinterpret_cast<const String *>(p_variant._data._mem); } break; - // math types + // math types case VECTOR2: { @@ -2524,9 +2524,9 @@ void Variant::operator=(const Variant &p_variant) { *reinterpret_cast<Plane *>(_data._mem) = *reinterpret_cast<const Plane *>(p_variant._data._mem); } break; - case RECT3: { + case AABB: { - *_data._rect3 = *(p_variant._data._rect3); + *_data._aabb = *(p_variant._data._aabb); } break; case QUAT: { @@ -2641,7 +2641,7 @@ uint32_t Variant::hash() const { return reinterpret_cast<const String *>(_data._mem)->hash(); } break; - // math types + // math types case VECTOR2: { @@ -2686,13 +2686,13 @@ uint32_t Variant::hash() const { } break;*/ - case RECT3: { + case AABB: { uint32_t hash = 5831; for (int i = 0; i < 3; i++) { - hash = hash_djb2_one_float(_data._rect3->position[i], hash); - hash = hash_djb2_one_float(_data._rect3->size[i], hash); + hash = hash_djb2_one_float(_data._aabb->position[i], hash); + hash = hash_djb2_one_float(_data._aabb->size[i], hash); } return hash; @@ -2952,9 +2952,9 @@ bool Variant::hash_compare(const Variant &p_variant) const { (hash_compare_scalar(l->d, r->d)); } break; - case RECT3: { - const Rect3 *l = _data._rect3; - const Rect3 *r = p_variant._data._rect3; + case AABB: { + const ::AABB *l = _data._aabb; + const ::AABB *r = p_variant._data._aabb; return (hash_compare_vector3(l->position, r->position) && (hash_compare_vector3(l->size, r->size))); diff --git a/core/variant.h b/core/variant.h index 45066af401..8ba4d576cf 100644 --- a/core/variant.h +++ b/core/variant.h @@ -34,6 +34,7 @@ @author Juan Linietsky <reduzio@gmail.com> */ +#include "aabb.h" #include "array.h" #include "color.h" #include "dictionary.h" @@ -45,7 +46,6 @@ #include "node_path.h" #include "plane.h" #include "quat.h" -#include "rect3.h" #include "ref_ptr.h" #include "rid.h" #include "transform.h" @@ -89,7 +89,7 @@ public: TRANSFORM2D, PLANE, QUAT, // 10 - RECT3, + AABB, BASIS, TRANSFORM, @@ -136,7 +136,7 @@ private: int64_t _int; double _real; Transform2D *_transform2d; - Rect3 *_rect3; + ::AABB *_aabb; Basis *_basis; Transform *_transform; RefPtr *_resource; @@ -184,7 +184,7 @@ public: operator Rect2() const; operator Vector3() const; operator Plane() const; - operator Rect3() const; + operator ::AABB() const; operator Quat() const; operator Basis() const; operator Transform() const; @@ -253,7 +253,7 @@ public: Variant(const Rect2 &p_rect2); Variant(const Vector3 &p_vector3); Variant(const Plane &p_plane); - Variant(const Rect3 &p_aabb); + Variant(const ::AABB &p_aabb); Variant(const Quat &p_quat); Variant(const Basis &p_transform); Variant(const Transform2D &p_transform); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 05f0478003..9e6aaeb911 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -655,26 +655,26 @@ struct _VariantCall { #define VCALL_PTR5R(m_type, m_method) \ static void _call_##m_type##_##m_method(Variant &r_ret, Variant &p_self, const Variant **p_args) { r_ret = reinterpret_cast<m_type *>(p_self._data._ptr)->m_method(*p_args[0], *p_args[1], *p_args[2], *p_args[3], *p_args[4]); } - VCALL_PTR0R(Rect3, get_area); - VCALL_PTR0R(Rect3, has_no_area); - VCALL_PTR0R(Rect3, has_no_surface); - VCALL_PTR1R(Rect3, intersects); - VCALL_PTR1R(Rect3, encloses); - VCALL_PTR1R(Rect3, merge); - VCALL_PTR1R(Rect3, intersection); - VCALL_PTR1R(Rect3, intersects_plane); - VCALL_PTR2R(Rect3, intersects_segment); - VCALL_PTR1R(Rect3, has_point); - VCALL_PTR1R(Rect3, get_support); - VCALL_PTR0R(Rect3, get_longest_axis); - VCALL_PTR0R(Rect3, get_longest_axis_index); - VCALL_PTR0R(Rect3, get_longest_axis_size); - VCALL_PTR0R(Rect3, get_shortest_axis); - VCALL_PTR0R(Rect3, get_shortest_axis_index); - VCALL_PTR0R(Rect3, get_shortest_axis_size); - VCALL_PTR1R(Rect3, expand); - VCALL_PTR1R(Rect3, grow); - VCALL_PTR1R(Rect3, get_endpoint); + VCALL_PTR0R(AABB, get_area); + VCALL_PTR0R(AABB, has_no_area); + VCALL_PTR0R(AABB, has_no_surface); + VCALL_PTR1R(AABB, intersects); + VCALL_PTR1R(AABB, encloses); + VCALL_PTR1R(AABB, merge); + VCALL_PTR1R(AABB, intersection); + VCALL_PTR1R(AABB, intersects_plane); + VCALL_PTR2R(AABB, intersects_segment); + VCALL_PTR1R(AABB, has_point); + VCALL_PTR1R(AABB, get_support); + VCALL_PTR0R(AABB, get_longest_axis); + VCALL_PTR0R(AABB, get_longest_axis_index); + VCALL_PTR0R(AABB, get_longest_axis_size); + VCALL_PTR0R(AABB, get_shortest_axis); + VCALL_PTR0R(AABB, get_shortest_axis_index); + VCALL_PTR0R(AABB, get_shortest_axis_size); + VCALL_PTR1R(AABB, expand); + VCALL_PTR1R(AABB, grow); + VCALL_PTR1R(AABB, get_endpoint); VCALL_PTR0R(Transform2D, inverse); VCALL_PTR0R(Transform2D, affine_inverse); @@ -755,7 +755,7 @@ struct _VariantCall { case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Vector3()); return; case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Plane()); return; - case Variant::RECT3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator Rect3()); return; + case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform(p_args[0]->operator ::AABB()); return; default: r_ret = Variant(); } } @@ -766,7 +766,7 @@ struct _VariantCall { case Variant::VECTOR3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Vector3()); return; case Variant::PLANE: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Plane()); return; - case Variant::RECT3: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator Rect3()); return; + case Variant::AABB: r_ret = reinterpret_cast<Transform *>(p_self._data._ptr)->xform_inv(p_args[0]->operator ::AABB()); return; default: r_ret = Variant(); } } @@ -878,9 +878,9 @@ struct _VariantCall { r_ret = Color::hex(*p_args[0]); } - static void Rect3_init1(Variant &r_ret, const Variant **p_args) { + static void AABB_init1(Variant &r_ret, const Variant **p_args) { - r_ret = Rect3(*p_args[0], *p_args[1]); + r_ret = ::AABB(*p_args[0], *p_args[1]); } static void Basis_init1(Variant &r_ret, const Variant **p_args) { @@ -1058,8 +1058,8 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i case TRANSFORM2D: return Transform2D(); case PLANE: return Plane(); case QUAT: return Quat(); - case RECT3: - return Rect3(); // 10 + case AABB: + return ::AABB(); // 10 case BASIS: return Basis(); case TRANSFORM: return Transform(); @@ -1138,8 +1138,8 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i case VECTOR3: return (Vector3(*p_args[0])); case PLANE: return (Plane(*p_args[0])); case QUAT: return (Quat(*p_args[0])); - case RECT3: - return (Rect3(*p_args[0])); // 10 + case AABB: + return (::AABB(*p_args[0])); // 10 case BASIS: return (Basis(p_args[0]->operator Basis())); case TRANSFORM: return (Transform(p_args[0]->operator Transform())); @@ -1707,26 +1707,26 @@ void register_variant_methods() { //pointerbased - ADDFUNC0R(RECT3, REAL, Rect3, get_area, varray()); - ADDFUNC0R(RECT3, BOOL, Rect3, has_no_area, varray()); - ADDFUNC0R(RECT3, BOOL, Rect3, has_no_surface, varray()); - ADDFUNC1R(RECT3, BOOL, Rect3, intersects, RECT3, "with", varray()); - ADDFUNC1R(RECT3, BOOL, Rect3, encloses, RECT3, "with", varray()); - ADDFUNC1R(RECT3, RECT3, Rect3, merge, RECT3, "with", varray()); - ADDFUNC1R(RECT3, RECT3, Rect3, intersection, RECT3, "with", varray()); - ADDFUNC1R(RECT3, BOOL, Rect3, intersects_plane, PLANE, "plane", varray()); - ADDFUNC2R(RECT3, BOOL, Rect3, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray()); - ADDFUNC1R(RECT3, BOOL, Rect3, has_point, VECTOR3, "point", varray()); - ADDFUNC1R(RECT3, VECTOR3, Rect3, get_support, VECTOR3, "dir", varray()); - ADDFUNC0R(RECT3, VECTOR3, Rect3, get_longest_axis, varray()); - ADDFUNC0R(RECT3, INT, Rect3, get_longest_axis_index, varray()); - ADDFUNC0R(RECT3, REAL, Rect3, get_longest_axis_size, varray()); - ADDFUNC0R(RECT3, VECTOR3, Rect3, get_shortest_axis, varray()); - ADDFUNC0R(RECT3, INT, Rect3, get_shortest_axis_index, varray()); - ADDFUNC0R(RECT3, REAL, Rect3, get_shortest_axis_size, varray()); - ADDFUNC1R(RECT3, RECT3, Rect3, expand, VECTOR3, "to_point", varray()); - ADDFUNC1R(RECT3, RECT3, Rect3, grow, REAL, "by", varray()); - ADDFUNC1R(RECT3, VECTOR3, Rect3, get_endpoint, INT, "idx", varray()); + ADDFUNC0R(AABB, REAL, AABB, get_area, varray()); + ADDFUNC0R(AABB, BOOL, AABB, has_no_area, varray()); + ADDFUNC0R(AABB, BOOL, AABB, has_no_surface, varray()); + ADDFUNC1R(AABB, BOOL, AABB, intersects, AABB, "with", varray()); + ADDFUNC1R(AABB, BOOL, AABB, encloses, AABB, "with", varray()); + ADDFUNC1R(AABB, AABB, AABB, merge, AABB, "with", varray()); + ADDFUNC1R(AABB, AABB, AABB, intersection, AABB, "with", varray()); + ADDFUNC1R(AABB, BOOL, AABB, intersects_plane, PLANE, "plane", varray()); + ADDFUNC2R(AABB, BOOL, AABB, intersects_segment, VECTOR3, "from", VECTOR3, "to", varray()); + ADDFUNC1R(AABB, BOOL, AABB, has_point, VECTOR3, "point", varray()); + ADDFUNC1R(AABB, VECTOR3, AABB, get_support, VECTOR3, "dir", varray()); + ADDFUNC0R(AABB, VECTOR3, AABB, get_longest_axis, varray()); + ADDFUNC0R(AABB, INT, AABB, get_longest_axis_index, varray()); + ADDFUNC0R(AABB, REAL, AABB, get_longest_axis_size, varray()); + ADDFUNC0R(AABB, VECTOR3, AABB, get_shortest_axis, varray()); + ADDFUNC0R(AABB, INT, AABB, get_shortest_axis_index, varray()); + ADDFUNC0R(AABB, REAL, AABB, get_shortest_axis_size, varray()); + ADDFUNC1R(AABB, AABB, AABB, expand, VECTOR3, "to_point", varray()); + ADDFUNC1R(AABB, AABB, AABB, grow, REAL, "by", varray()); + ADDFUNC1R(AABB, VECTOR3, AABB, get_endpoint, INT, "idx", varray()); ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, inverse, varray()); ADDFUNC0R(TRANSFORM2D, TRANSFORM2D, Transform2D, affine_inverse, varray()); @@ -1791,7 +1791,7 @@ void register_variant_methods() { _VariantCall::add_constructor(_VariantCall::Color_init1, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL, "a", Variant::REAL); _VariantCall::add_constructor(_VariantCall::Color_init2, Variant::COLOR, "r", Variant::REAL, "g", Variant::REAL, "b", Variant::REAL); - _VariantCall::add_constructor(_VariantCall::Rect3_init1, Variant::RECT3, "position", Variant::VECTOR3, "size", Variant::VECTOR3); + _VariantCall::add_constructor(_VariantCall::AABB_init1, Variant::AABB, "position", Variant::VECTOR3, "size", Variant::VECTOR3); _VariantCall::add_constructor(_VariantCall::Basis_init1, Variant::BASIS, "x_axis", Variant::VECTOR3, "y_axis", Variant::VECTOR3, "z_axis", Variant::VECTOR3); _VariantCall::add_constructor(_VariantCall::Basis_init2, Variant::BASIS, "axis", Variant::VECTOR3, "phi", Variant::REAL); diff --git a/core/variant_op.cpp b/core/variant_op.cpp index 6362090902..c793d70ed8 100644 --- a/core/variant_op.cpp +++ b/core/variant_op.cpp @@ -48,7 +48,7 @@ CASE_TYPE(PREFIX, OP, TRANSFORM2D) \ CASE_TYPE(PREFIX, OP, PLANE) \ CASE_TYPE(PREFIX, OP, QUAT) \ - CASE_TYPE(PREFIX, OP, RECT3) \ + CASE_TYPE(PREFIX, OP, AABB) \ CASE_TYPE(PREFIX, OP, BASIS) \ CASE_TYPE(PREFIX, OP, TRANSFORM) \ CASE_TYPE(PREFIX, OP, COLOR) \ @@ -81,7 +81,7 @@ TYPE(PREFIX, OP, TRANSFORM2D), \ TYPE(PREFIX, OP, PLANE), \ TYPE(PREFIX, OP, QUAT), \ - TYPE(PREFIX, OP, RECT3), \ + TYPE(PREFIX, OP, AABB), \ TYPE(PREFIX, OP, BASIS), \ TYPE(PREFIX, OP, TRANSFORM), \ TYPE(PREFIX, OP, COLOR), \ @@ -465,7 +465,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, VECTOR3, ==, Vector3); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, PLANE, ==, Plane); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, QUAT, ==, Quat); - DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, RECT3, ==, _rect3); + DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, AABB, ==, _aabb); DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, BASIS, ==, _basis); DEFAULT_OP_PTRREF_NULL(math, OP_EQUAL, TRANSFORM, ==, _transform); DEFAULT_OP_LOCALMEM_NULL(math, OP_EQUAL, COLOR, ==, Color); @@ -555,7 +555,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, VECTOR3, !=, Vector3); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, PLANE, !=, Plane); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, QUAT, !=, Quat); - DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, RECT3, !=, _rect3); + DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, AABB, !=, _aabb); DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, BASIS, !=, _basis); DEFAULT_OP_PTRREF_NULL(math, OP_NOT_EQUAL, TRANSFORM, !=, _transform); DEFAULT_OP_LOCALMEM_NULL(math, OP_NOT_EQUAL, COLOR, !=, Color); @@ -629,7 +629,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_LESS, TRANSFORM2D) CASE_TYPE(math, OP_LESS, PLANE) CASE_TYPE(math, OP_LESS, QUAT) - CASE_TYPE(math, OP_LESS, RECT3) + CASE_TYPE(math, OP_LESS, AABB) CASE_TYPE(math, OP_LESS, BASIS) CASE_TYPE(math, OP_LESS, TRANSFORM) CASE_TYPE(math, OP_LESS, COLOR) @@ -658,7 +658,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM2D) CASE_TYPE(math, OP_LESS_EQUAL, PLANE) CASE_TYPE(math, OP_LESS_EQUAL, QUAT) - CASE_TYPE(math, OP_LESS_EQUAL, RECT3) + CASE_TYPE(math, OP_LESS_EQUAL, AABB) CASE_TYPE(math, OP_LESS_EQUAL, BASIS) CASE_TYPE(math, OP_LESS_EQUAL, TRANSFORM) CASE_TYPE(math, OP_LESS_EQUAL, COLOR) @@ -733,7 +733,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_GREATER, TRANSFORM2D) CASE_TYPE(math, OP_GREATER, PLANE) CASE_TYPE(math, OP_GREATER, QUAT) - CASE_TYPE(math, OP_GREATER, RECT3) + CASE_TYPE(math, OP_GREATER, AABB) CASE_TYPE(math, OP_GREATER, BASIS) CASE_TYPE(math, OP_GREATER, TRANSFORM) CASE_TYPE(math, OP_GREATER, COLOR) @@ -762,7 +762,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM2D) CASE_TYPE(math, OP_GREATER_EQUAL, PLANE) CASE_TYPE(math, OP_GREATER_EQUAL, QUAT) - CASE_TYPE(math, OP_GREATER_EQUAL, RECT3) + CASE_TYPE(math, OP_GREATER_EQUAL, AABB) CASE_TYPE(math, OP_GREATER_EQUAL, BASIS) CASE_TYPE(math, OP_GREATER_EQUAL, TRANSFORM) CASE_TYPE(math, OP_GREATER_EQUAL, COLOR) @@ -818,7 +818,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_ADD, RECT2) CASE_TYPE(math, OP_ADD, TRANSFORM2D) CASE_TYPE(math, OP_ADD, PLANE) - CASE_TYPE(math, OP_ADD, RECT3) + CASE_TYPE(math, OP_ADD, AABB) CASE_TYPE(math, OP_ADD, BASIS) CASE_TYPE(math, OP_ADD, TRANSFORM) CASE_TYPE(math, OP_ADD, NODE_PATH) @@ -842,7 +842,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_SUBTRACT, RECT2) CASE_TYPE(math, OP_SUBTRACT, TRANSFORM2D) CASE_TYPE(math, OP_SUBTRACT, PLANE) - CASE_TYPE(math, OP_SUBTRACT, RECT3) + CASE_TYPE(math, OP_SUBTRACT, AABB) CASE_TYPE(math, OP_SUBTRACT, BASIS) CASE_TYPE(math, OP_SUBTRACT, TRANSFORM) CASE_TYPE(math, OP_SUBTRACT, NODE_PATH) @@ -923,7 +923,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_MULTIPLY, STRING) CASE_TYPE(math, OP_MULTIPLY, RECT2) CASE_TYPE(math, OP_MULTIPLY, PLANE) - CASE_TYPE(math, OP_MULTIPLY, RECT3) + CASE_TYPE(math, OP_MULTIPLY, AABB) CASE_TYPE(math, OP_MULTIPLY, NODE_PATH) CASE_TYPE(math, OP_MULTIPLY, _RID) CASE_TYPE(math, OP_MULTIPLY, OBJECT) @@ -964,7 +964,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_DIVIDE, RECT2) CASE_TYPE(math, OP_DIVIDE, TRANSFORM2D) CASE_TYPE(math, OP_DIVIDE, PLANE) - CASE_TYPE(math, OP_DIVIDE, RECT3) + CASE_TYPE(math, OP_DIVIDE, AABB) CASE_TYPE(math, OP_DIVIDE, BASIS) CASE_TYPE(math, OP_DIVIDE, TRANSFORM) CASE_TYPE(math, OP_DIVIDE, NODE_PATH) @@ -995,7 +995,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_POSITIVE, STRING) CASE_TYPE(math, OP_POSITIVE, RECT2) CASE_TYPE(math, OP_POSITIVE, TRANSFORM2D) - CASE_TYPE(math, OP_POSITIVE, RECT3) + CASE_TYPE(math, OP_POSITIVE, AABB) CASE_TYPE(math, OP_POSITIVE, BASIS) CASE_TYPE(math, OP_POSITIVE, TRANSFORM) CASE_TYPE(math, OP_POSITIVE, COLOR) @@ -1029,7 +1029,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_NEGATE, STRING) CASE_TYPE(math, OP_NEGATE, RECT2) CASE_TYPE(math, OP_NEGATE, TRANSFORM2D) - CASE_TYPE(math, OP_NEGATE, RECT3) + CASE_TYPE(math, OP_NEGATE, AABB) CASE_TYPE(math, OP_NEGATE, BASIS) CASE_TYPE(math, OP_NEGATE, TRANSFORM) CASE_TYPE(math, OP_NEGATE, NODE_PATH) @@ -1088,7 +1088,7 @@ void Variant::evaluate(const Operator &p_op, const Variant &p_a, CASE_TYPE(math, OP_MODULE, TRANSFORM2D) CASE_TYPE(math, OP_MODULE, PLANE) CASE_TYPE(math, OP_MODULE, QUAT) - CASE_TYPE(math, OP_MODULE, RECT3) + CASE_TYPE(math, OP_MODULE, AABB) CASE_TYPE(math, OP_MODULE, BASIS) CASE_TYPE(math, OP_MODULE, TRANSFORM) CASE_TYPE(math, OP_MODULE, COLOR) @@ -1384,10 +1384,10 @@ void Variant::set_named(const StringName &p_index, const Variant &p_value, bool } } break; // 10 - case RECT3: { + case AABB: { if (p_value.type == Variant::VECTOR3) { - Rect3 *v = _data._rect3; + ::AABB *v = _data._aabb; //scalar name if (p_index == CoreStringNames::singleton->position) { v->position = *reinterpret_cast<const Vector3 *>(p_value._data._mem); @@ -1609,9 +1609,9 @@ Variant Variant::get_named(const StringName &p_index, bool *r_valid) const { } } break; // 10 - case RECT3: { + case AABB: { - const Rect3 *v = _data._rect3; + const ::AABB *v = _data._aabb; //scalar name if (p_index == CoreStringNames::singleton->position) { return v->position; @@ -1982,7 +1982,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) } } break; // 10 - case RECT3: { + case AABB: { if (p_value.type != Variant::VECTOR3) return; @@ -1991,7 +1991,7 @@ void Variant::set(const Variant &p_index, const Variant &p_value, bool *r_valid) //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); - Rect3 *v = _data._rect3; + ::AABB *v = _data._aabb; if (*str == "position") { valid = true; v->position = p_value; @@ -2400,13 +2400,13 @@ Variant Variant::get(const Variant &p_index, bool *r_valid) const { } } break; // 10 - case RECT3: { + case AABB: { if (p_index.get_type() == Variant::STRING) { //scalar name const String *str = reinterpret_cast<const String *>(p_index._data._mem); - const Rect3 *v = _data._rect3; + const ::AABB *v = _data._aabb; if (*str == "position") { valid = true; return v->position; @@ -2835,7 +2835,7 @@ void Variant::get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::REAL, "w")); } break; // 10 - case RECT3: { + case AABB: { p_list->push_back(PropertyInfo(Variant::VECTOR3, "position")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "size")); p_list->push_back(PropertyInfo(Variant::VECTOR3, "end")); @@ -3457,10 +3457,10 @@ void Variant::blend(const Variant &a, const Variant &b, float c, Variant &r_dst) r_dst = *reinterpret_cast<const Vector3 *>(a._data._mem) + *reinterpret_cast<const Vector3 *>(b._data._mem) * c; } return; - case RECT3: { - const Rect3 *ra = reinterpret_cast<const Rect3 *>(a._data._mem); - const Rect3 *rb = reinterpret_cast<const Rect3 *>(b._data._mem); - r_dst = Rect3(ra->position + rb->position * c, ra->size + rb->size * c); + case AABB: { + const ::AABB *ra = reinterpret_cast<const ::AABB *>(a._data._mem); + const ::AABB *rb = reinterpret_cast<const ::AABB *>(b._data._mem); + r_dst = ::AABB(ra->position + rb->position * c, ra->size + rb->size * c); } return; case QUAT: { @@ -3591,8 +3591,8 @@ void Variant::interpolate(const Variant &a, const Variant &b, float c, Variant & r_dst = reinterpret_cast<const Quat *>(a._data._mem)->slerp(*reinterpret_cast<const Quat *>(b._data._mem), c); } return; - case RECT3: { - r_dst = Rect3(a._data._rect3->position.linear_interpolate(b._data._rect3->position, c), a._data._rect3->size.linear_interpolate(b._data._rect3->size, c)); + case AABB: { + r_dst = ::AABB(a._data._aabb->position.linear_interpolate(b._data._aabb->position, c), a._data._aabb->size.linear_interpolate(b._data._aabb->size, c)); } return; case BASIS: { diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index d60d10cd3a..1552b62c64 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -595,7 +595,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, value = Quat(args[0], args[1], args[2], args[3]); return OK; - } else if (id == "Rect3" || id == "AABB") { + } else if (id == "AABB") { Vector<float> args; Error err = _parse_construct<float>(p_stream, args, line, r_err_str); @@ -606,7 +606,7 @@ Error VariantParser::parse_value(Token &token, Variant &value, Stream *p_stream, r_err_str = "Expected 6 arguments for constructor"; } - value = Rect3(Vector3(args[0], args[1], args[2]), Vector3(args[3], args[4], args[5])); + value = AABB(Vector3(args[0], args[1], args[2]), Vector3(args[3], args[4], args[5])); return OK; } else if (id == "Basis" || id == "Matrix3") { //compatibility @@ -1634,10 +1634,10 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str p_store_string_func(p_store_string_ud, "Plane( " + rtosfix(p.normal.x) + ", " + rtosfix(p.normal.y) + ", " + rtosfix(p.normal.z) + ", " + rtosfix(p.d) + " )"); } break; - case Variant::RECT3: { + case Variant::AABB: { - Rect3 aabb = p_variant; - p_store_string_func(p_store_string_ud, "Rect3( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + " )"); + AABB aabb = p_variant; + p_store_string_func(p_store_string_ud, "AABB( " + rtosfix(aabb.position.x) + ", " + rtosfix(aabb.position.y) + ", " + rtosfix(aabb.position.z) + ", " + rtosfix(aabb.size.x) + ", " + rtosfix(aabb.size.y) + ", " + rtosfix(aabb.size.z) + " )"); } break; case Variant::QUAT: { diff --git a/core/version.h b/core/version.h index 7d2c47df6a..b217d82c5d 100644 --- a/core/version.h +++ b/core/version.h @@ -30,8 +30,8 @@ #include "version_generated.gen.h" #ifdef VERSION_PATCH -#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION) VERSION_MODULE_CONFIG +#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH) "." VERSION_STATUS "." VERSION_BUILD VERSION_MODULE_CONFIG #else -#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_STATUS) "." _MKSTR(VERSION_REVISION) VERSION_MODULE_CONFIG +#define VERSION_MKSTRING "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." VERSION_STATUS "." VERSION_BUILD VERSION_MODULE_CONFIG #endif // VERSION_PATCH -#define VERSION_FULL_NAME "" _MKSTR(VERSION_NAME) " v" VERSION_MKSTRING +#define VERSION_FULL_NAME "" VERSION_NAME " v" VERSION_MKSTRING diff --git a/doc/classes/@GDScript.xml b/doc/classes/@GDScript.xml index 9c1d9a1aa2..49ec412ba0 100644 --- a/doc/classes/@GDScript.xml +++ b/doc/classes/@GDScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="@GDScript" category="Core" version="3.0.alpha.custom_build"> +<class name="@GDScript" category="Core" version="3.0-alpha"> <brief_description> Built-in GDScript functions. </brief_description> @@ -196,7 +196,7 @@ <argument index="1" name="type" type="int"> </argument> <description> - Converts from a type to another in the best way possible. The [code]type[/code] parameter uses the enum TYPE_* in [@Global Scope]. + Converts from a type to another in the best way possible. The [code]type[/code] parameter uses the enum TYPE_* in [@GlobalScope]. [codeblock] a = Vector2(1, 0) # prints 1 @@ -984,7 +984,7 @@ <argument index="0" name="what" type="Variant"> </argument> <description> - Returns the internal type of the given Variant object, using the TYPE_* enum in [@Global Scope]. + Returns the internal type of the given Variant object, using the TYPE_* enum in [@GlobalScope]. [codeblock] p = parse_json('["a", "b", "c"]') if typeof(p) == TYPE_ARRAY: @@ -1103,21 +1103,24 @@ </description> </method> <method name="yield"> - <return type="GDFunctionState"> + <return type="GDScriptFunctionState"> </return> <argument index="0" name="object" type="Object"> </argument> <argument index="1" name="signal" type="String"> </argument> <description> - Stops the function execution and returns the current state. Call [method GDFunctionState.resume] on the state to resume execution. This invalidates the state. + Stops the function execution and returns the current state. Call [method GDScriptFunctionState.resume] on the state to resume execution. This invalidates the state. Returns anything that was passed to the resume function call. If passed an object and a signal, the execution is resumed when the object's signal is emitted. </description> </method> </methods> <constants> <constant name="PI" value="3.141593" enum=""> - Constant that represents how many times the diameter of a circumference fits around its perimeter. + Constant that represents how many times the diameter of a circle fits around its perimeter. + </constant> + <constant name="TAU" value="6.283185" enum=""> + The circle constant, the circumference of the unit circle. </constant> <constant name="INF" value="inf" enum=""> A positive infinity. (For negative infinity, use -INF). diff --git a/doc/classes/@Global Scope.xml b/doc/classes/@GlobalScope.xml index 20f323bb4f..d9bdf0e3cf 100644 --- a/doc/classes/@Global Scope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="@Global Scope" category="Core" version="3.0.alpha.custom_build"> +<class name="@GlobalScope" category="Core" version="3.0-alpha"> <brief_description> Global scope constants and variables. </brief_description> @@ -44,6 +44,8 @@ <member name="JSON" type="JSON" setter="" getter=""> [JSON] singleton </member> + <member name="JavaScript" type="JavaScript" setter="" getter=""> + </member> <member name="Marshalls" type="Reference" setter="" getter=""> [Marshalls] singleton </member> @@ -1038,7 +1040,11 @@ <constant name="JOY_AXIS_7" value="7"> Joypad Right Trigger Analog Axis </constant> - <constant name="JOY_AXIS_MAX" value="8"> + <constant name="JOY_AXIS_8" value="8"> + </constant> + <constant name="JOY_AXIS_9" value="9"> + </constant> + <constant name="JOY_AXIS_MAX" value="10"> </constant> <constant name="JOY_ANALOG_LX" value="0"> Joypad Left Stick Horizontal Axis @@ -1328,8 +1334,8 @@ <constant name="TYPE_QUAT" value="10"> Variable is of type [Quat]. </constant> - <constant name="TYPE_RECT3" value="11"> - Variable is of type [Rect3]. + <constant name="TYPE_AABB" value="11"> + Variable is of type [AABB]. </constant> <constant name="TYPE_BASIS" value="12"> Variable is of type [Basis]. diff --git a/doc/classes/@NativeScript.xml b/doc/classes/@NativeScript.xml index 03e6416b19..a9dfc4538a 100644 --- a/doc/classes/@NativeScript.xml +++ b/doc/classes/@NativeScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="@NativeScript" category="Core" version="3.0.alpha.custom_build"> +<class name="@NativeScript" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/@VisualScript.xml b/doc/classes/@VisualScript.xml index fe40bc45e9..0e6205c040 100644 --- a/doc/classes/@VisualScript.xml +++ b/doc/classes/@VisualScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="@VisualScript" category="Core" version="3.0.alpha.custom_build"> +<class name="@VisualScript" category="Core" version="3.0-alpha"> <brief_description> Built-in visual script functions. </brief_description> diff --git a/doc/classes/Rect3.xml b/doc/classes/AABB.xml index a56dac57c7..494dcb8fce 100644 --- a/doc/classes/Rect3.xml +++ b/doc/classes/AABB.xml @@ -1,18 +1,18 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Rect3" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="AABB" category="Built-In Types" version="3.0-alpha"> <brief_description> Axis-Aligned Bounding Box. </brief_description> <description> - Rect3 consists of a position, a size, and several utility functions. It is typically used for fast overlap tests. + AABB consists of a position, a size, and several utility functions. It is typically used for fast overlap tests. </description> <tutorials> </tutorials> <demos> </demos> <methods> - <method name="Rect3"> - <return type="Rect3"> + <method name="AABB"> + <return type="AABB"> </return> <argument index="0" name="position" type="Vector3"> </argument> @@ -25,26 +25,26 @@ <method name="encloses"> <return type="bool"> </return> - <argument index="0" name="with" type="Rect3"> + <argument index="0" name="with" type="AABB"> </argument> <description> - Returns [code]true[/code] if this [code]Rect3[/code] completely encloses another one. + Returns [code]true[/code] if this [code]AABB[/code] completely encloses another one. </description> </method> <method name="expand"> - <return type="Rect3"> + <return type="AABB"> </return> <argument index="0" name="to_point" type="Vector3"> </argument> <description> - Returns this [code]Rect3[/code] expanded to include a given point. + Returns this [code]AABB[/code] expanded to include a given point. </description> </method> <method name="get_area"> <return type="float"> </return> <description> - Gets the area of the [code]Rect3[/code]. + Gets the area of the [code]AABB[/code]. </description> </method> <method name="get_endpoint"> @@ -53,49 +53,49 @@ <argument index="0" name="idx" type="int"> </argument> <description> - Gets the position of the 8 endpoints of the [code]Rect3[/code] in space. + Gets the position of the 8 endpoints of the [code]AABB[/code] in space. </description> </method> <method name="get_longest_axis"> <return type="Vector3"> </return> <description> - Returns the normalized longest axis of the [code]Rect3[/code]. + Returns the normalized longest axis of the [code]AABB[/code]. </description> </method> <method name="get_longest_axis_index"> <return type="int"> </return> <description> - Returns the index of the longest axis of the [code]Rect3[/code] (according to [Vector3]::AXIS* enum). + Returns the index of the longest axis of the [code]AABB[/code] (according to [Vector3]::AXIS* enum). </description> </method> <method name="get_longest_axis_size"> <return type="float"> </return> <description> - Returns the scalar length of the longest axis of the [code]Rect3[/code]. + Returns the scalar length of the longest axis of the [code]AABB[/code]. </description> </method> <method name="get_shortest_axis"> <return type="Vector3"> </return> <description> - Returns the normalized shortest axis of the [code]Rect3[/code]. + Returns the normalized shortest axis of the [code]AABB[/code]. </description> </method> <method name="get_shortest_axis_index"> <return type="int"> </return> <description> - Returns the index of the shortest axis of the [code]Rect3[/code] (according to [Vector3]::AXIS* enum). + Returns the index of the shortest axis of the [code]AABB[/code] (according to [Vector3]::AXIS* enum). </description> </method> <method name="get_shortest_axis_size"> <return type="float"> </return> <description> - Returns the scalar length of the shortest axis of the [code]Rect3[/code]. + Returns the scalar length of the shortest axis of the [code]AABB[/code]. </description> </method> <method name="get_support"> @@ -108,26 +108,26 @@ </description> </method> <method name="grow"> - <return type="Rect3"> + <return type="AABB"> </return> <argument index="0" name="by" type="float"> </argument> <description> - Returns a copy of the [code]Rect3[/code] grown a given amount of units towards all the sides. + Returns a copy of the [code]AABB[/code] grown a given amount of units towards all the sides. </description> </method> <method name="has_no_area"> <return type="bool"> </return> <description> - Returns [code]true[/code] if the [code]Rect3[/code] is flat or empty. + Returns [code]true[/code] if the [code]AABB[/code] is flat or empty. </description> </method> <method name="has_no_surface"> <return type="bool"> </return> <description> - Returns [code]true[/code] if the [code]Rect3[/code] is empty. + Returns [code]true[/code] if the [code]AABB[/code] is empty. </description> </method> <method name="has_point"> @@ -136,25 +136,25 @@ <argument index="0" name="point" type="Vector3"> </argument> <description> - Returns [code]true[/code] if the [code]Rect3[/code] contains a point. + Returns [code]true[/code] if the [code]AABB[/code] contains a point. </description> </method> <method name="intersection"> - <return type="Rect3"> + <return type="AABB"> </return> - <argument index="0" name="with" type="Rect3"> + <argument index="0" name="with" type="AABB"> </argument> <description> - Returns the intersection between two [code]Rect3[/code]. An empty Rect3 (size 0,0,0) is returned on failure. + Returns the intersection between two [code]AABB[/code]. An empty AABB (size 0,0,0) is returned on failure. </description> </method> <method name="intersects"> <return type="bool"> </return> - <argument index="0" name="with" type="Rect3"> + <argument index="0" name="with" type="AABB"> </argument> <description> - Returns [code]true[/code] if the [code]Rect3[/code] overlaps with another. + Returns [code]true[/code] if the [code]AABB[/code] overlaps with another. </description> </method> <method name="intersects_plane"> @@ -163,7 +163,7 @@ <argument index="0" name="plane" type="Plane"> </argument> <description> - Returns [code]true[/code] if the [code]Rect3[/code] is on both sides of a plane. + Returns [code]true[/code] if the [code]AABB[/code] is on both sides of a plane. </description> </method> <method name="intersects_segment"> @@ -174,16 +174,16 @@ <argument index="1" name="to" type="Vector3"> </argument> <description> - Returns [code]true[/code] if the [code]Rect3[/code] intersects the line segment between [code]from[/code] and [code]to[/code]. + Returns [code]true[/code] if the [code]AABB[/code] intersects the line segment between [code]from[/code] and [code]to[/code]. </description> </method> <method name="merge"> - <return type="Rect3"> + <return type="AABB"> </return> - <argument index="0" name="with" type="Rect3"> + <argument index="0" name="with" type="AABB"> </argument> <description> - Returns a larger Rect3 that contains this Rect3 and [code]with[/code]. + Returns a larger AABB that contains this AABB and [code]with[/code]. </description> </method> </methods> diff --git a/doc/classes/ARVRAnchor.xml b/doc/classes/ARVRAnchor.xml index ecd882cdb0..8bb12609b0 100644 --- a/doc/classes/ARVRAnchor.xml +++ b/doc/classes/ARVRAnchor.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVRAnchor" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="ARVRAnchor" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Anchor point in AR Space </brief_description> diff --git a/doc/classes/ARVRCamera.xml b/doc/classes/ARVRCamera.xml index e6817d3417..0d9886618d 100644 --- a/doc/classes/ARVRCamera.xml +++ b/doc/classes/ARVRCamera.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVRCamera" inherits="Camera" category="Core" version="3.0.alpha.custom_build"> +<class name="ARVRCamera" inherits="Camera" category="Core" version="3.0-alpha"> <brief_description> A camera node with a few overrules for AR/VR applied such as location tracking. </brief_description> diff --git a/doc/classes/ARVRController.xml b/doc/classes/ARVRController.xml index af1deda2f0..8af483132b 100644 --- a/doc/classes/ARVRController.xml +++ b/doc/classes/ARVRController.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVRController" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="ARVRController" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> A spatial node representing a spatially tracked controller. </brief_description> @@ -57,6 +57,12 @@ Returns the ID of the joystick object bound to this. Every controller tracked by the ARVR Server that has buttons and axis will also be registered as a joystick within Godot. This means that all the normal joystick tracking and input mapping will work for buttons and axis found on the AR/VR controllers. This ID is purely offered as information so you can link up the controller with its joystick entry. </description> </method> + <method name="get_rumble" qualifiers="const"> + <return type="float"> + </return> + <description> + </description> + </method> <method name="is_button_pressed" qualifiers="const"> <return type="int"> </return> @@ -75,11 +81,21 @@ Changes the id that identifies the controller bound to this node. The first controller that the ARVR Server detects will have id 1, the second id 2, the third id 3, etc. When a controller is turned off that slot is freed ensuring that controllers will keep the same id while it is turned on even when controllers with lower ids are turned off. </description> </method> + <method name="set_rumble"> + <return type="void"> + </return> + <argument index="0" name="rumble" type="float"> + </argument> + <description> + </description> + </method> </methods> <members> <member name="controller_id" type="int" setter="set_controller_id" getter="get_controller_id"> The controller's id. The first controller that the [ARVRServer] detects will have id 1, the second id 2, the third id 3, etc. When a controller is turned off, it's slot is freed. This ensures controllers will keep the same id even when controllers with lower ids are turned off. </member> + <member name="rumble" type="float" setter="set_rumble" getter="get_rumble"> + </member> </members> <signals> <signal name="button_pressed"> diff --git a/doc/classes/ARVRInterface.xml b/doc/classes/ARVRInterface.xml index 9aed6c96ef..e9f8857ec8 100644 --- a/doc/classes/ARVRInterface.xml +++ b/doc/classes/ARVRInterface.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVRInterface" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="ARVRInterface" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Base class for ARVR interface implementation. </brief_description> @@ -33,7 +33,7 @@ Returns the name of this interface (OpenVR, OpenHMD, ARKit, etc). </description> </method> - <method name="get_recommended_render_targetsize"> + <method name="get_render_targetsize"> <return type="Vector2"> </return> <description> @@ -139,7 +139,7 @@ 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. + 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_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. diff --git a/doc/classes/ARVROrigin.xml b/doc/classes/ARVROrigin.xml index 226a69dea4..8ad3793c80 100644 --- a/doc/classes/ARVROrigin.xml +++ b/doc/classes/ARVROrigin.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVROrigin" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="ARVROrigin" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Our origin point in AR/VR. </brief_description> diff --git a/doc/classes/ARVRPositionalTracker.xml b/doc/classes/ARVRPositionalTracker.xml index 686ac1db77..2a2c6aa843 100644 --- a/doc/classes/ARVRPositionalTracker.xml +++ b/doc/classes/ARVRPositionalTracker.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVRPositionalTracker" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="ARVRPositionalTracker" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> A tracked object </brief_description> @@ -48,6 +48,12 @@ Returns the position of the controller adjusted by world scale. </description> </method> + <method name="get_rumble" qualifiers="const"> + <return type="float"> + </return> + <description> + </description> + </method> <method name="get_tracks_orientation" qualifiers="const"> <return type="bool"> </return> @@ -78,7 +84,19 @@ Type of tracker. </description> </method> + <method name="set_rumble"> + <return type="void"> + </return> + <argument index="0" name="rumble" type="float"> + </argument> + <description> + </description> + </method> </methods> + <members> + <member name="rumble" type="float" setter="set_rumble" getter="get_rumble"> + </member> + </members> <constants> <constant name="TRACKER_HAND_UNKNOWN" value="0"> The hand this tracker is held in is unknown or not applicable. diff --git a/doc/classes/ARVRServer.xml b/doc/classes/ARVRServer.xml index bb7ac2c052..bee95ea072 100644 --- a/doc/classes/ARVRServer.xml +++ b/doc/classes/ARVRServer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVRServer" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="ARVRServer" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> This is our AR/VR Server. </brief_description> @@ -11,15 +11,6 @@ <demos> </demos> <methods> - <method name="add_interface"> - <return type="void"> - </return> - <argument index="0" name="interface" type="ARVRInterface"> - </argument> - <description> - 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> @@ -61,6 +52,13 @@ Get the number of interfaces currently registered with the AR/VR server. If you're game supports multiple AR/VR platforms you can look throught the available interface and either present the user with a selection or simply try an initialize each interface and use the first one that returns true. </description> </method> + <method name="get_interfaces" qualifiers="const"> + <return type="Array"> + </return> + <description> + Returns a list of available interfaces with both id and name of the interface. + </description> + </method> <method name="get_reference_frame" qualifiers="const"> <return type="Transform"> </return> @@ -91,15 +89,6 @@ Returns our world scale (see ARVROrigin for more information). </description> </method> - <method name="remove_interface"> - <return type="void"> - </return> - <argument index="0" name="interface" type="ARVRInterface"> - </argument> - <description> - Removes a registered interface, again exposed mostly for GDNative based interfaces. - </description> - </method> <method name="set_primary_interface"> <return type="void"> </return> diff --git a/doc/classes/AStar.xml b/doc/classes/AStar.xml index 10ca3035fb..ceb3c907a6 100644 --- a/doc/classes/AStar.xml +++ b/doc/classes/AStar.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AStar" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="AStar" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> AStar class representation that uses vectors as edges. </brief_description> @@ -168,6 +168,28 @@ If you change the 2nd point's weight to 3, then the result will be [code][1, 4, 3][/code] instead, because now even though the distance is longer, it's "easier" to get through point 4 than through point 2. </description> </method> + <method name="get_point_connections"> + <return type="PoolIntArray"> + </return> + <argument index="0" name="arg0" type="int"> + </argument> + <description> + Returns an array with the ids of the points that form the connect with the given point. + [codeblock] + var as = AStar.new() + + as.add_point(1, Vector3(0,0,0)) + as.add_point(2, Vector3(0,1,0)) + as.add_point(3, Vector3(1,1,0)) + as.add_point(4, Vector3(2,0,0)) + + as.connect_points(1, 2, true) + as.connect_points(1, 3, true) + + var neighbors = as.get_point_connections(1) # returns [2, 3] + [/codeblock] + </description> + </method> <method name="get_point_path"> <return type="PoolVector3Array"> </return> @@ -243,28 +265,6 @@ Sets the [code]weight_scale[/code] for the point with the given id. </description> </method> - <method name="get_point_connections"> - <return type="PoolIntArray"> - </return> - <argument index="0" name="id" type="int"> - </argument> - <description> - Returns an array with the ids of the points that form the connect with the given point. - [codeblock] - var as = AStar.new() - - as.add_point(1, Vector3(0,0,0)) - as.add_point(2, Vector3(0,1,0)) - as.add_point(3, Vector3(1,1,0)) - as.add_point(4, Vector3(2,0,0)) - - as.connect_points(1, 2, true) - as.connect_points(1, 3, true) - - var neighbors = as.get_point_connections(1) # returns [2, 3] - [/codeblock] - </description> - </method> </methods> <constants> </constants> diff --git a/doc/classes/AcceptDialog.xml b/doc/classes/AcceptDialog.xml index f87a40b8aa..2292d54756 100644 --- a/doc/classes/AcceptDialog.xml +++ b/doc/classes/AcceptDialog.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AcceptDialog" inherits="WindowDialog" category="Core" version="3.0.alpha.custom_build"> +<class name="AcceptDialog" inherits="WindowDialog" category="Core" version="3.0-alpha"> <brief_description> Base dialog for user notification. </brief_description> diff --git a/doc/classes/AnimatedSprite.xml b/doc/classes/AnimatedSprite.xml index dce7bf283a..984eb47f12 100644 --- a/doc/classes/AnimatedSprite.xml +++ b/doc/classes/AnimatedSprite.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AnimatedSprite" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="AnimatedSprite" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Sprite node that can use multiple textures for animation. </brief_description> diff --git a/doc/classes/AnimatedSprite3D.xml b/doc/classes/AnimatedSprite3D.xml index b0bb7bb6ab..0d8e2fc433 100644 --- a/doc/classes/AnimatedSprite3D.xml +++ b/doc/classes/AnimatedSprite3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AnimatedSprite3D" inherits="SpriteBase3D" category="Core" version="3.0.alpha.custom_build"> +<class name="AnimatedSprite3D" inherits="SpriteBase3D" category="Core" version="3.0-alpha"> <brief_description> 2D sprite node in 3D world, that can use multiple 2D textures for animation. </brief_description> diff --git a/doc/classes/Animation.xml b/doc/classes/Animation.xml index d853345268..677976f1d3 100644 --- a/doc/classes/Animation.xml +++ b/doc/classes/Animation.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Animation" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Animation" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Contains data used to animate everything in the engine. </brief_description> diff --git a/doc/classes/AnimationPlayer.xml b/doc/classes/AnimationPlayer.xml index 82eb291f27..f0a1f7f634 100644 --- a/doc/classes/AnimationPlayer.xml +++ b/doc/classes/AnimationPlayer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AnimationPlayer" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="AnimationPlayer" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Container and player of [Animation] resources. </brief_description> diff --git a/doc/classes/AnimationTreePlayer.xml b/doc/classes/AnimationTreePlayer.xml index b92e59b902..413606dbaa 100644 --- a/doc/classes/AnimationTreePlayer.xml +++ b/doc/classes/AnimationTreePlayer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AnimationTreePlayer" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="AnimationTreePlayer" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Animation Player that uses a node graph for the blending. </brief_description> diff --git a/doc/classes/Area.xml b/doc/classes/Area.xml index febced0a8e..85afa24214 100644 --- a/doc/classes/Area.xml +++ b/doc/classes/Area.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Area" inherits="CollisionObject" category="Core" version="3.0.alpha.custom_build"> +<class name="Area" inherits="CollisionObject" category="Core" version="3.0-alpha"> <brief_description> General purpose area node for detection and 3D physics influence. </brief_description> diff --git a/doc/classes/Area2D.xml b/doc/classes/Area2D.xml index 6bc6e36dfc..5869e2238e 100644 --- a/doc/classes/Area2D.xml +++ b/doc/classes/Area2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Area2D" inherits="CollisionObject2D" category="Core" version="3.0.alpha.custom_build"> +<class name="Area2D" inherits="CollisionObject2D" category="Core" version="3.0-alpha"> <brief_description> 2D area for detection and 2D physics influence. </brief_description> diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index 7c1d72333b..203c60e644 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Array" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Array" category="Built-In Types" version="3.0-alpha"> <brief_description> Generic array datatype. </brief_description> @@ -82,6 +82,8 @@ </description> </method> <method name="back"> + <return type="var"> + </return> <description> Returns the last element of the array if the array is not empty (size>0). </description> @@ -142,6 +144,8 @@ </description> </method> <method name="front"> + <return type="var"> + </return> <description> Returns the first element of the array if the array is not empty (size>0). </description> @@ -183,11 +187,15 @@ </description> </method> <method name="pop_back"> + <return type="var"> + </return> <description> Remove the last element of the array. </description> </method> <method name="pop_front"> + <return type="var"> + </return> <description> Remove the first element of the array. </description> diff --git a/doc/classes/ArrayMesh.xml b/doc/classes/ArrayMesh.xml index c9996c1a0f..6c9b191371 100644 --- a/doc/classes/ArrayMesh.xml +++ b/doc/classes/ArrayMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ArrayMesh" inherits="Mesh" category="Core" version="3.0.alpha.custom_build"> +<class name="ArrayMesh" inherits="Mesh" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> @@ -66,7 +66,7 @@ </description> </method> <method name="get_custom_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> @@ -95,7 +95,7 @@ <method name="set_custom_aabb"> <return type="void"> </return> - <argument index="0" name="aabb" type="Rect3"> + <argument index="0" name="aabb" type="AABB"> </argument> <description> </description> @@ -199,6 +199,18 @@ Set a [Material] for a given surface. Surface will be rendered using this material. </description> </method> + <method name="surface_update_region"> + <return type="void"> + </return> + <argument index="0" name="surf_idx" type="int"> + </argument> + <argument index="1" name="offset" type="int"> + </argument> + <argument index="2" name="data" type="PoolByteArray"> + </argument> + <description> + </description> + </method> </methods> <constants> <constant name="NO_INDEX_ARRAY" value="-1" enum=""> diff --git a/doc/classes/AtlasTexture.xml b/doc/classes/AtlasTexture.xml index 179f78f16f..7cb934889e 100644 --- a/doc/classes/AtlasTexture.xml +++ b/doc/classes/AtlasTexture.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AtlasTexture" inherits="Texture" category="Core" version="3.0.alpha.custom_build"> +<class name="AtlasTexture" inherits="Texture" category="Core" version="3.0-alpha"> <brief_description> Packs multiple small textures in a single, bigger one. Helps to optimize video memory costs and render calls. </brief_description> @@ -30,6 +30,12 @@ <description> </description> </method> + <method name="has_filter_clip" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> <method name="set_atlas"> <return type="void"> </return> @@ -38,6 +44,14 @@ <description> </description> </method> + <method name="set_filter_clip"> + <return type="void"> + </return> + <argument index="0" name="enable" type="bool"> + </argument> + <description> + </description> + </method> <method name="set_margin"> <return type="void"> </return> @@ -59,6 +73,8 @@ <member name="atlas" type="Texture" setter="set_atlas" getter="get_atlas"> The texture that contains the atlas. Can be any [Texture] subtype. </member> + <member name="filter_clip" type="bool" setter="set_filter_clip" getter="has_filter_clip"> + </member> <member name="margin" type="Rect2" setter="set_margin" getter="get_margin"> The margin around the region. The [Rect2]'s 'size' parameter ('w' and 'h' in the editor) resizes the texture so it fits within the margin. </member> diff --git a/doc/classes/AudioBusLayout.xml b/doc/classes/AudioBusLayout.xml index 045c6c2bf9..c539c7500b 100644 --- a/doc/classes/AudioBusLayout.xml +++ b/doc/classes/AudioBusLayout.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioBusLayout" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioBusLayout" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Stores information about the audiobusses. </brief_description> diff --git a/doc/classes/AudioEffect.xml b/doc/classes/AudioEffect.xml index 627d243f25..804cba82fe 100644 --- a/doc/classes/AudioEffect.xml +++ b/doc/classes/AudioEffect.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffect" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffect" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Audio Effect For Audio. </brief_description> diff --git a/doc/classes/AudioEffectAmplify.xml b/doc/classes/AudioEffectAmplify.xml index 35d7991833..0149e03de4 100644 --- a/doc/classes/AudioEffectAmplify.xml +++ b/doc/classes/AudioEffectAmplify.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectAmplify" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectAmplify" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Adds a Amplify audio effect to an Audio bus. Increases or decreases the volume of the selected audio bus. diff --git a/doc/classes/AudioEffectBandLimitFilter.xml b/doc/classes/AudioEffectBandLimitFilter.xml index d4b251fc8e..f83cf8ba72 100644 --- a/doc/classes/AudioEffectBandLimitFilter.xml +++ b/doc/classes/AudioEffectBandLimitFilter.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectBandLimitFilter" inherits="AudioEffectFilter" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectBandLimitFilter" inherits="AudioEffectFilter" category="Core" version="3.0-alpha"> <brief_description> Adds a band limit filter to the Audio Bus. </brief_description> diff --git a/doc/classes/AudioEffectBandPassFilter.xml b/doc/classes/AudioEffectBandPassFilter.xml index b5c6ae3c20..e922d3e821 100644 --- a/doc/classes/AudioEffectBandPassFilter.xml +++ b/doc/classes/AudioEffectBandPassFilter.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectBandPassFilter" inherits="AudioEffectFilter" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectBandPassFilter" inherits="AudioEffectFilter" category="Core" version="3.0-alpha"> <brief_description> Adds a band pass filter to the Audio Bus. </brief_description> diff --git a/doc/classes/AudioEffectChorus.xml b/doc/classes/AudioEffectChorus.xml index b9f27678ec..40bac419d6 100644 --- a/doc/classes/AudioEffectChorus.xml +++ b/doc/classes/AudioEffectChorus.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectChorus" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectChorus" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Adds a chorus audio effect. </brief_description> diff --git a/doc/classes/AudioEffectCompressor.xml b/doc/classes/AudioEffectCompressor.xml index 9d7e25dbf2..ae877f145a 100644 --- a/doc/classes/AudioEffectCompressor.xml +++ b/doc/classes/AudioEffectCompressor.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectCompressor" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectCompressor" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Adds a Compressor audio effect to an Audio bus. Reduces sounds that exceed a certain threshold level, smooths out the dynamics and increases the overall volume. diff --git a/doc/classes/AudioEffectDelay.xml b/doc/classes/AudioEffectDelay.xml index 9dc61883ab..a9251b6cf0 100644 --- a/doc/classes/AudioEffectDelay.xml +++ b/doc/classes/AudioEffectDelay.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectDelay" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectDelay" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Adds a Delay audio effect to an Audio bus. Plays input signal back after a period of time. Two tap delay and feedback options. diff --git a/doc/classes/AudioEffectDistortion.xml b/doc/classes/AudioEffectDistortion.xml index 8b970e675e..25df71d5f5 100644 --- a/doc/classes/AudioEffectDistortion.xml +++ b/doc/classes/AudioEffectDistortion.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectDistortion" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectDistortion" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Adds a Distortion audio effect to an Audio bus. Modify the sound to make it dirty. diff --git a/doc/classes/AudioEffectEQ.xml b/doc/classes/AudioEffectEQ.xml index 246f6b882e..f8b4d426f4 100644 --- a/doc/classes/AudioEffectEQ.xml +++ b/doc/classes/AudioEffectEQ.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectEQ" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectEQ" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Base class for audio equalizers. Gives you control over frequencies. Use it to create a custom equalizer if [AudioEffectEQ6], [AudioEffectEQ10] or [AudioEffectEQ21] don't fit your needs. diff --git a/doc/classes/AudioEffectEQ10.xml b/doc/classes/AudioEffectEQ10.xml index 7a29f4cc0b..95801ef40c 100644 --- a/doc/classes/AudioEffectEQ10.xml +++ b/doc/classes/AudioEffectEQ10.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectEQ10" inherits="AudioEffectEQ" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectEQ10" inherits="AudioEffectEQ" category="Core" version="3.0-alpha"> <brief_description> Adds a 10-band equalizer audio effect to an Audio bus. Gives you control over frequencies from 31 Hz to 16000 Hz. Each frequency can be modulated between -60/+24 dB. diff --git a/doc/classes/AudioEffectEQ21.xml b/doc/classes/AudioEffectEQ21.xml index 327f5a291a..b62e0458f7 100644 --- a/doc/classes/AudioEffectEQ21.xml +++ b/doc/classes/AudioEffectEQ21.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectEQ21" inherits="AudioEffectEQ" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectEQ21" inherits="AudioEffectEQ" category="Core" version="3.0-alpha"> <brief_description> Adds a 21-band equalizer audio effect to an Audio bus. Gives you control over frequencies from 22 Hz to 22000 Hz. Each frequency can be modulated between -60/+24 dB. diff --git a/doc/classes/AudioEffectEQ6.xml b/doc/classes/AudioEffectEQ6.xml index bc05535041..f679ccede4 100644 --- a/doc/classes/AudioEffectEQ6.xml +++ b/doc/classes/AudioEffectEQ6.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectEQ6" inherits="AudioEffectEQ" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectEQ6" inherits="AudioEffectEQ" category="Core" version="3.0-alpha"> <brief_description> Adds a 6-band equalizer audio effect to an Audio bus. Gives you control over frequencies from 32 Hz to 10000 Hz. Each frequency can be modulated between -60/+24 dB. diff --git a/doc/classes/AudioEffectFilter.xml b/doc/classes/AudioEffectFilter.xml index 82d572b81b..244c07a6da 100644 --- a/doc/classes/AudioEffectFilter.xml +++ b/doc/classes/AudioEffectFilter.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectFilter" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectFilter" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Adds a filter to the Audio Bus. </brief_description> diff --git a/doc/classes/AudioEffectHighPassFilter.xml b/doc/classes/AudioEffectHighPassFilter.xml index c5e24af510..4718d4d4a5 100644 --- a/doc/classes/AudioEffectHighPassFilter.xml +++ b/doc/classes/AudioEffectHighPassFilter.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectHighPassFilter" inherits="AudioEffectFilter" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectHighPassFilter" inherits="AudioEffectFilter" category="Core" version="3.0-alpha"> <brief_description> Adds a high pass filter to the Audio Bus. </brief_description> diff --git a/doc/classes/AudioEffectHighShelfFilter.xml b/doc/classes/AudioEffectHighShelfFilter.xml index a2504d6808..62ff3d9366 100644 --- a/doc/classes/AudioEffectHighShelfFilter.xml +++ b/doc/classes/AudioEffectHighShelfFilter.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectHighShelfFilter" inherits="AudioEffectFilter" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectHighShelfFilter" inherits="AudioEffectFilter" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/AudioEffectLimiter.xml b/doc/classes/AudioEffectLimiter.xml index 5209f290b1..ebed589829 100644 --- a/doc/classes/AudioEffectLimiter.xml +++ b/doc/classes/AudioEffectLimiter.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectLimiter" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectLimiter" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Adds a soft clip Limiter audio effect to an Audio bus. </brief_description> diff --git a/doc/classes/AudioEffectLowPassFilter.xml b/doc/classes/AudioEffectLowPassFilter.xml index f102dda03e..9f9ecc98b1 100644 --- a/doc/classes/AudioEffectLowPassFilter.xml +++ b/doc/classes/AudioEffectLowPassFilter.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectLowPassFilter" inherits="AudioEffectFilter" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectLowPassFilter" inherits="AudioEffectFilter" category="Core" version="3.0-alpha"> <brief_description> Adds a low pass filter to the Audio Bus. </brief_description> diff --git a/doc/classes/AudioEffectLowShelfFilter.xml b/doc/classes/AudioEffectLowShelfFilter.xml index 8cf1a63c81..c74d1bc479 100644 --- a/doc/classes/AudioEffectLowShelfFilter.xml +++ b/doc/classes/AudioEffectLowShelfFilter.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectLowShelfFilter" inherits="AudioEffectFilter" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectLowShelfFilter" inherits="AudioEffectFilter" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/AudioEffectNotchFilter.xml b/doc/classes/AudioEffectNotchFilter.xml index 8ec9a4bc7c..6407fc8431 100644 --- a/doc/classes/AudioEffectNotchFilter.xml +++ b/doc/classes/AudioEffectNotchFilter.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectNotchFilter" inherits="AudioEffectFilter" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectNotchFilter" inherits="AudioEffectFilter" category="Core" version="3.0-alpha"> <brief_description> Adds a notch filter to the Audio Bus. </brief_description> diff --git a/doc/classes/AudioEffectPanner.xml b/doc/classes/AudioEffectPanner.xml index 56b39a36c6..46be7c1696 100644 --- a/doc/classes/AudioEffectPanner.xml +++ b/doc/classes/AudioEffectPanner.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectPanner" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectPanner" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Adds a Panner audio effect to an Audio bus. Pans sound left or right. </brief_description> diff --git a/doc/classes/AudioEffectPhaser.xml b/doc/classes/AudioEffectPhaser.xml index bd9067471b..f413366fc7 100644 --- a/doc/classes/AudioEffectPhaser.xml +++ b/doc/classes/AudioEffectPhaser.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectPhaser" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectPhaser" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Adds a Phaser audio effect to an Audio bus. Combines the original signal with a copy that is slightly out of phase with the original. diff --git a/doc/classes/AudioEffectPitchShift.xml b/doc/classes/AudioEffectPitchShift.xml index edcb54e09e..490aacbc8e 100644 --- a/doc/classes/AudioEffectPitchShift.xml +++ b/doc/classes/AudioEffectPitchShift.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectPitchShift" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectPitchShift" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Adds a Pitch shift audio effect to an Audio bus. Raises or lowers the pitch of original sound. diff --git a/doc/classes/AudioEffectReverb.xml b/doc/classes/AudioEffectReverb.xml index f399f9f07a..e0567a48c7 100644 --- a/doc/classes/AudioEffectReverb.xml +++ b/doc/classes/AudioEffectReverb.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectReverb" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectReverb" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> Adds a Reverb audio effect to an Audio bus. Simulates the sound of acoustic environments such as rooms, concert halls, caverns, or an open spaces. diff --git a/doc/classes/AudioEffectStereoEnhance.xml b/doc/classes/AudioEffectStereoEnhance.xml index 345d019d85..eb17056813 100644 --- a/doc/classes/AudioEffectStereoEnhance.xml +++ b/doc/classes/AudioEffectStereoEnhance.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioEffectStereoEnhance" inherits="AudioEffect" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioEffectStereoEnhance" inherits="AudioEffect" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/AudioServer.xml b/doc/classes/AudioServer.xml index f8320c23af..83a06bcd4d 100644 --- a/doc/classes/AudioServer.xml +++ b/doc/classes/AudioServer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioServer" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioServer" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Server interface for low level audio access. </brief_description> @@ -287,7 +287,7 @@ <argument index="1" name="send" type="String"> </argument> <description> - Connects the output of the bus at [code]bus_idx[/code] to the bus named [code]send[/send]. + Connects the output of the bus at [code]bus_idx[/code] to the bus named [code]send[/code]. </description> </method> <method name="set_bus_solo"> diff --git a/doc/classes/AudioStream.xml b/doc/classes/AudioStream.xml index b4a98b2d8c..67323c59c5 100644 --- a/doc/classes/AudioStream.xml +++ b/doc/classes/AudioStream.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioStream" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioStream" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Base class for audio streams. </brief_description> diff --git a/doc/classes/AudioStreamPlayback.xml b/doc/classes/AudioStreamPlayback.xml index f45beec42c..61393fbe29 100644 --- a/doc/classes/AudioStreamPlayback.xml +++ b/doc/classes/AudioStreamPlayback.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioStreamPlayback" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioStreamPlayback" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Meta class for playing back audio. </brief_description> diff --git a/doc/classes/AudioStreamPlayer.xml b/doc/classes/AudioStreamPlayer.xml index 1a9ad85565..55edbfb438 100644 --- a/doc/classes/AudioStreamPlayer.xml +++ b/doc/classes/AudioStreamPlayer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioStreamPlayer" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioStreamPlayer" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Plays back audio. </brief_description> diff --git a/doc/classes/AudioStreamPlayer2D.xml b/doc/classes/AudioStreamPlayer2D.xml index c6fd8ff54f..98ebeacc5f 100644 --- a/doc/classes/AudioStreamPlayer2D.xml +++ b/doc/classes/AudioStreamPlayer2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioStreamPlayer2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioStreamPlayer2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Plays audio in 2D. </brief_description> diff --git a/doc/classes/AudioStreamPlayer3D.xml b/doc/classes/AudioStreamPlayer3D.xml index 84f6792ef0..9c016a0173 100644 --- a/doc/classes/AudioStreamPlayer3D.xml +++ b/doc/classes/AudioStreamPlayer3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioStreamPlayer3D" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioStreamPlayer3D" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Plays 3D sound in 3D space </brief_description> diff --git a/doc/classes/AudioStreamRandomPitch.xml b/doc/classes/AudioStreamRandomPitch.xml index 1573a78d1f..56c7ee1998 100644 --- a/doc/classes/AudioStreamRandomPitch.xml +++ b/doc/classes/AudioStreamRandomPitch.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioStreamRandomPitch" inherits="AudioStream" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioStreamRandomPitch" inherits="AudioStream" category="Core" version="3.0-alpha"> <brief_description> Plays audio with random pitch tweaking. </brief_description> diff --git a/doc/classes/AudioStreamSample.xml b/doc/classes/AudioStreamSample.xml index 7f7414e4d3..3a0a171480 100644 --- a/doc/classes/AudioStreamSample.xml +++ b/doc/classes/AudioStreamSample.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioStreamSample" inherits="AudioStream" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioStreamSample" inherits="AudioStream" category="Core" version="3.0-alpha"> <brief_description> Plays audio. </brief_description> diff --git a/doc/classes/BackBufferCopy.xml b/doc/classes/BackBufferCopy.xml index 6c44430949..2b5a9aac20 100644 --- a/doc/classes/BackBufferCopy.xml +++ b/doc/classes/BackBufferCopy.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="BackBufferCopy" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="BackBufferCopy" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Copies a region of the screen (or the whole screen) to a buffer so it can be accessed with the texscreen() shader instruction. </brief_description> diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml index 1b6583a834..26939143b6 100644 --- a/doc/classes/BaseButton.xml +++ b/doc/classes/BaseButton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="BaseButton" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="BaseButton" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Base class for different kinds of buttons. </brief_description> diff --git a/doc/classes/Basis.xml b/doc/classes/Basis.xml index 7731647648..c8a28621ea 100644 --- a/doc/classes/Basis.xml +++ b/doc/classes/Basis.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Basis" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Basis" category="Built-In Types" version="3.0-alpha"> <brief_description> 3x3 matrix datatype. </brief_description> diff --git a/doc/classes/BitMap.xml b/doc/classes/BitMap.xml index 63e6a5f682..4de059d908 100644 --- a/doc/classes/BitMap.xml +++ b/doc/classes/BitMap.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="BitMap" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="BitMap" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Boolean matrix. </brief_description> diff --git a/doc/classes/BitmapFont.xml b/doc/classes/BitmapFont.xml index 43ce40562f..c013a474b2 100644 --- a/doc/classes/BitmapFont.xml +++ b/doc/classes/BitmapFont.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="BitmapFont" inherits="Font" category="Core" version="3.0.alpha.custom_build"> +<class name="BitmapFont" inherits="Font" category="Core" version="3.0-alpha"> <brief_description> Renders text using [code]*.fnt[/code] fonts. </brief_description> diff --git a/doc/classes/BoneAttachment.xml b/doc/classes/BoneAttachment.xml index 9297c0e1b1..8f33d7a73c 100644 --- a/doc/classes/BoneAttachment.xml +++ b/doc/classes/BoneAttachment.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="BoneAttachment" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="BoneAttachment" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> A node that will attach to a bone. </brief_description> diff --git a/doc/classes/BoxContainer.xml b/doc/classes/BoxContainer.xml index 0c70d919f3..a7465a959a 100644 --- a/doc/classes/BoxContainer.xml +++ b/doc/classes/BoxContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="BoxContainer" inherits="Container" category="Core" version="3.0.alpha.custom_build"> +<class name="BoxContainer" inherits="Container" category="Core" version="3.0-alpha"> <brief_description> Base class for box containers. </brief_description> diff --git a/doc/classes/BoxShape.xml b/doc/classes/BoxShape.xml index 4e8eb0ba6f..0f46442550 100644 --- a/doc/classes/BoxShape.xml +++ b/doc/classes/BoxShape.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="BoxShape" inherits="Shape" category="Core" version="3.0.alpha.custom_build"> +<class name="BoxShape" inherits="Shape" category="Core" version="3.0-alpha"> <brief_description> Box shape resource. </brief_description> diff --git a/doc/classes/Button.xml b/doc/classes/Button.xml index bb02e4266b..2964cc9efc 100644 --- a/doc/classes/Button.xml +++ b/doc/classes/Button.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Button" inherits="BaseButton" category="Core" version="3.0.alpha.custom_build"> +<class name="Button" inherits="BaseButton" category="Core" version="3.0-alpha"> <brief_description> Standard themed Button. </brief_description> diff --git a/doc/classes/ButtonGroup.xml b/doc/classes/ButtonGroup.xml index c2c999f9d8..ccc457f9e6 100644 --- a/doc/classes/ButtonGroup.xml +++ b/doc/classes/ButtonGroup.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ButtonGroup" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="ButtonGroup" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Group of Buttons. </brief_description> diff --git a/doc/classes/Camera.xml b/doc/classes/Camera.xml index aeebcf9c87..c840da9266 100644 --- a/doc/classes/Camera.xml +++ b/doc/classes/Camera.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Camera" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="Camera" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Camera node, displays from a point of view. </brief_description> diff --git a/doc/classes/Camera2D.xml b/doc/classes/Camera2D.xml index 352e270e77..8704624b2d 100644 --- a/doc/classes/Camera2D.xml +++ b/doc/classes/Camera2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Camera2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="Camera2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Camera node for 2D scenes. </brief_description> diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index 3682cc6d8f..bb3a9b3845 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CanvasItem" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="CanvasItem" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Base class of anything 2D. </brief_description> @@ -346,14 +346,14 @@ Get the global transform matrix of this item in relation to the canvas. </description> </method> - <method name="get_item_and_children_rect" qualifiers="const"> + <method name="edit_get_item_and_children_rect" qualifiers="const"> <return type="Rect2"> </return> <description> Get a [Rect2] with the boundaries of this item and its children. </description> </method> - <method name="get_item_rect" qualifiers="const"> + <method name="edit_get_rect" qualifiers="const"> <return type="Rect2"> </return> <description> diff --git a/doc/classes/CanvasItemMaterial.xml b/doc/classes/CanvasItemMaterial.xml index 2a6553bb6a..b9d2653a2f 100644 --- a/doc/classes/CanvasItemMaterial.xml +++ b/doc/classes/CanvasItemMaterial.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CanvasItemMaterial" inherits="Material" category="Core" version="3.0.alpha.custom_build"> +<class name="CanvasItemMaterial" inherits="Material" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/CanvasLayer.xml b/doc/classes/CanvasLayer.xml index c3f2e43892..139624bb1d 100644 --- a/doc/classes/CanvasLayer.xml +++ b/doc/classes/CanvasLayer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CanvasLayer" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="CanvasLayer" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Canvas drawing layer. </brief_description> @@ -38,7 +38,7 @@ Return the base rotation for this layer in radians (helper). </description> </method> - <method name="get_rotationd" qualifiers="const"> + <method name="get_rotation_degrees" qualifiers="const"> <return type="float"> </return> <description> @@ -101,7 +101,7 @@ Set the base rotation for this layer in radians (helper). </description> </method> - <method name="set_rotationd"> + <method name="set_rotation_degrees"> <return type="void"> </return> <argument index="0" name="degrees" type="float"> @@ -136,7 +136,7 @@ <member name="offset" type="Vector2" setter="set_offset" getter="get_offset"> The layer's base offset. </member> - <member name="rotation" type="float" setter="set_rotationd" getter="get_rotationd"> + <member name="rotation" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees"> The layer's rotation in degrees. </member> <member name="scale" type="Vector2" setter="set_scale" getter="get_scale"> diff --git a/doc/classes/CanvasModulate.xml b/doc/classes/CanvasModulate.xml index b4b20e29f9..3872d80236 100644 --- a/doc/classes/CanvasModulate.xml +++ b/doc/classes/CanvasModulate.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CanvasModulate" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="CanvasModulate" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Tint the entire canvas. </brief_description> diff --git a/doc/classes/CapsuleMesh.xml b/doc/classes/CapsuleMesh.xml index 13cdfa057d..497e795253 100644 --- a/doc/classes/CapsuleMesh.xml +++ b/doc/classes/CapsuleMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CapsuleMesh" inherits="PrimitiveMesh" category="Core" version="3.0.alpha.custom_build"> +<class name="CapsuleMesh" inherits="PrimitiveMesh" category="Core" version="3.0-alpha"> <brief_description> Class representing a capsule-shaped [PrimitiveMesh]. </brief_description> diff --git a/doc/classes/CapsuleShape.xml b/doc/classes/CapsuleShape.xml index db075a504c..f2d3528e4f 100644 --- a/doc/classes/CapsuleShape.xml +++ b/doc/classes/CapsuleShape.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CapsuleShape" inherits="Shape" category="Core" version="3.0.alpha.custom_build"> +<class name="CapsuleShape" inherits="Shape" category="Core" version="3.0-alpha"> <brief_description> Capsule shape for collisions. </brief_description> diff --git a/doc/classes/CapsuleShape2D.xml b/doc/classes/CapsuleShape2D.xml index 4fb5579436..b700388303 100644 --- a/doc/classes/CapsuleShape2D.xml +++ b/doc/classes/CapsuleShape2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CapsuleShape2D" inherits="Shape2D" category="Core" version="3.0.alpha.custom_build"> +<class name="CapsuleShape2D" inherits="Shape2D" category="Core" version="3.0-alpha"> <brief_description> Capsule shape for 2D collisions. </brief_description> diff --git a/doc/classes/CenterContainer.xml b/doc/classes/CenterContainer.xml index 2f81e7739f..9e88448e32 100644 --- a/doc/classes/CenterContainer.xml +++ b/doc/classes/CenterContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CenterContainer" inherits="Container" category="Core" version="3.0.alpha.custom_build"> +<class name="CenterContainer" inherits="Container" category="Core" version="3.0-alpha"> <brief_description> Keeps children controls centered. </brief_description> diff --git a/doc/classes/CheckBox.xml b/doc/classes/CheckBox.xml index 50b431e00c..fb9a67323b 100644 --- a/doc/classes/CheckBox.xml +++ b/doc/classes/CheckBox.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CheckBox" inherits="Button" category="Core" version="3.0.alpha.custom_build"> +<class name="CheckBox" inherits="Button" category="Core" version="3.0-alpha"> <brief_description> Binary choice user interface widget </brief_description> diff --git a/doc/classes/CheckButton.xml b/doc/classes/CheckButton.xml index bb4e6fc0cb..996b4238a1 100644 --- a/doc/classes/CheckButton.xml +++ b/doc/classes/CheckButton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CheckButton" inherits="Button" category="Core" version="3.0.alpha.custom_build"> +<class name="CheckButton" inherits="Button" category="Core" version="3.0-alpha"> <brief_description> Checkable button. </brief_description> diff --git a/doc/classes/CircleShape2D.xml b/doc/classes/CircleShape2D.xml index 1ed54f0705..e5158755fe 100644 --- a/doc/classes/CircleShape2D.xml +++ b/doc/classes/CircleShape2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CircleShape2D" inherits="Shape2D" category="Core" version="3.0.alpha.custom_build"> +<class name="CircleShape2D" inherits="Shape2D" category="Core" version="3.0-alpha"> <brief_description> Circular shape for 2D collisions. </brief_description> diff --git a/doc/classes/ClassDB.xml b/doc/classes/ClassDB.xml index 35cf819959..2fed2f8676 100644 --- a/doc/classes/ClassDB.xml +++ b/doc/classes/ClassDB.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ClassDB" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="ClassDB" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Class information repository. </brief_description> diff --git a/doc/classes/CollisionObject.xml b/doc/classes/CollisionObject.xml index 71b0c5fa7c..be047ad699 100644 --- a/doc/classes/CollisionObject.xml +++ b/doc/classes/CollisionObject.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CollisionObject" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="CollisionObject" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Base node for collision objects. </brief_description> diff --git a/doc/classes/CollisionObject2D.xml b/doc/classes/CollisionObject2D.xml index ec0554d51f..d10368229c 100644 --- a/doc/classes/CollisionObject2D.xml +++ b/doc/classes/CollisionObject2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CollisionObject2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="CollisionObject2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Base node for 2D collision objects. </brief_description> diff --git a/doc/classes/CollisionPolygon.xml b/doc/classes/CollisionPolygon.xml index c2496424d6..13a993e9f4 100644 --- a/doc/classes/CollisionPolygon.xml +++ b/doc/classes/CollisionPolygon.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CollisionPolygon" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="CollisionPolygon" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Editor-only class for defining a collision polygon in 3D space. </brief_description> diff --git a/doc/classes/CollisionPolygon2D.xml b/doc/classes/CollisionPolygon2D.xml index 7f30e8e83e..bc4d2a5b16 100644 --- a/doc/classes/CollisionPolygon2D.xml +++ b/doc/classes/CollisionPolygon2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CollisionPolygon2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="CollisionPolygon2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Defines a 2D collision polygon. </brief_description> diff --git a/doc/classes/CollisionShape.xml b/doc/classes/CollisionShape.xml index 6e98d2f979..3c9e252788 100644 --- a/doc/classes/CollisionShape.xml +++ b/doc/classes/CollisionShape.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CollisionShape" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="CollisionShape" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Node that represents collision shape data in 3D space. </brief_description> diff --git a/doc/classes/CollisionShape2D.xml b/doc/classes/CollisionShape2D.xml index cefa0c1c81..caf3f8d8be 100644 --- a/doc/classes/CollisionShape2D.xml +++ b/doc/classes/CollisionShape2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CollisionShape2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="CollisionShape2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Node that represents collision shape data in 2D space. </brief_description> diff --git a/doc/classes/Color.xml b/doc/classes/Color.xml index 4547771b63..479eb719d4 100644 --- a/doc/classes/Color.xml +++ b/doc/classes/Color.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Color" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Color" category="Built-In Types" version="3.0-alpha"> <brief_description> Color in RGBA format with some support for ARGB format. </brief_description> diff --git a/doc/classes/ColorPicker.xml b/doc/classes/ColorPicker.xml index 74c12cb9b2..b6aeb8d0e3 100644 --- a/doc/classes/ColorPicker.xml +++ b/doc/classes/ColorPicker.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ColorPicker" inherits="BoxContainer" category="Core" version="3.0.alpha.custom_build"> +<class name="ColorPicker" inherits="BoxContainer" category="Core" version="3.0-alpha"> <brief_description> Color picker control. </brief_description> diff --git a/doc/classes/ColorPickerButton.xml b/doc/classes/ColorPickerButton.xml index 7b54be36c9..24b37580d6 100644 --- a/doc/classes/ColorPickerButton.xml +++ b/doc/classes/ColorPickerButton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ColorPickerButton" inherits="Button" category="Core" version="3.0.alpha.custom_build"> +<class name="ColorPickerButton" inherits="Button" category="Core" version="3.0-alpha"> <brief_description> Button that pops out a [ColorPicker] </brief_description> diff --git a/doc/classes/ColorRect.xml b/doc/classes/ColorRect.xml index 6e70a1e8b7..4dbc4f010c 100644 --- a/doc/classes/ColorRect.xml +++ b/doc/classes/ColorRect.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ColorRect" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="ColorRect" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Colored rect for canvas. </brief_description> diff --git a/doc/classes/ConcavePolygonShape.xml b/doc/classes/ConcavePolygonShape.xml index 0b1cbf9c21..e586eb11c5 100644 --- a/doc/classes/ConcavePolygonShape.xml +++ b/doc/classes/ConcavePolygonShape.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ConcavePolygonShape" inherits="Shape" category="Core" version="3.0.alpha.custom_build"> +<class name="ConcavePolygonShape" inherits="Shape" category="Core" version="3.0-alpha"> <brief_description> Concave polygon shape. </brief_description> diff --git a/doc/classes/ConcavePolygonShape2D.xml b/doc/classes/ConcavePolygonShape2D.xml index be884fd08d..5d2dbb4596 100644 --- a/doc/classes/ConcavePolygonShape2D.xml +++ b/doc/classes/ConcavePolygonShape2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ConcavePolygonShape2D" inherits="Shape2D" category="Core" version="3.0.alpha.custom_build"> +<class name="ConcavePolygonShape2D" inherits="Shape2D" category="Core" version="3.0-alpha"> <brief_description> Concave polygon 2D shape resource for physics. </brief_description> diff --git a/doc/classes/ConeTwistJoint.xml b/doc/classes/ConeTwistJoint.xml index baf28c5a74..2f72b451f3 100644 --- a/doc/classes/ConeTwistJoint.xml +++ b/doc/classes/ConeTwistJoint.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ConeTwistJoint" inherits="Joint" category="Core" version="3.0.alpha.custom_build"> +<class name="ConeTwistJoint" inherits="Joint" category="Core" version="3.0-alpha"> <brief_description> A twist joint between two 3D bodies </brief_description> diff --git a/doc/classes/ConfigFile.xml b/doc/classes/ConfigFile.xml index 846a100f3c..ef668ca994 100644 --- a/doc/classes/ConfigFile.xml +++ b/doc/classes/ConfigFile.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ConfigFile" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="ConfigFile" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Helper class to handle INI-style files. </brief_description> @@ -95,7 +95,7 @@ <argument index="0" name="path" type="String"> </argument> <description> - Loads the config file specified as a parameter. The file's contents are parsed and loaded in the ConfigFile object which the method was called on. Returns one of the [code]OK[/code], [code]FAILED[/code] or [code]ERR_*[/code] constants listed in [@Global Scope]. If the load was successful, the return value is [code]OK[/code]. + Loads the config file specified as a parameter. The file's contents are parsed and loaded in the ConfigFile object which the method was called on. Returns one of the [code]OK[/code], [code]FAILED[/code] or [code]ERR_*[/code] constants listed in [@GlobalScope]. If the load was successful, the return value is [code]OK[/code]. </description> </method> <method name="save"> @@ -104,7 +104,7 @@ <argument index="0" name="path" type="String"> </argument> <description> - Saves the contents of the ConfigFile object to the file specified as a parameter. The output file uses an INI-style structure. Returns one of the [code]OK[/code], [code]FAILED[/code] or [code]ERR_*[/code] constants listed in [@Global Scope]. If the load was successful, the return value is [code]OK[/code]. + Saves the contents of the ConfigFile object to the file specified as a parameter. The output file uses an INI-style structure. Returns one of the [code]OK[/code], [code]FAILED[/code] or [code]ERR_*[/code] constants listed in [@GlobalScope]. If the load was successful, the return value is [code]OK[/code]. </description> </method> <method name="set_value"> diff --git a/doc/classes/ConfirmationDialog.xml b/doc/classes/ConfirmationDialog.xml index 84de287519..1bbb338c07 100644 --- a/doc/classes/ConfirmationDialog.xml +++ b/doc/classes/ConfirmationDialog.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ConfirmationDialog" inherits="AcceptDialog" category="Core" version="3.0.alpha.custom_build"> +<class name="ConfirmationDialog" inherits="AcceptDialog" category="Core" version="3.0-alpha"> <brief_description> Dialog for confirmation of actions. </brief_description> diff --git a/doc/classes/Container.xml b/doc/classes/Container.xml index f8555def37..5490c84bae 100644 --- a/doc/classes/Container.xml +++ b/doc/classes/Container.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Container" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="Container" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Base node for containers. </brief_description> diff --git a/doc/classes/Control.xml b/doc/classes/Control.xml index e3d29c2e93..57966fb74e 100644 --- a/doc/classes/Control.xml +++ b/doc/classes/Control.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Control" inherits="CanvasItem" category="Core" version="3.0.alpha.custom_build"> +<class name="Control" inherits="CanvasItem" category="Core" version="3.0-alpha"> <brief_description> All User Interface nodes inherit from Control. Features anchors and margins to adapt its position and size to its parent. </brief_description> @@ -60,7 +60,7 @@ <argument index="1" name="constant" type="int"> </argument> <description> - Overrides an integer constant in the [theme] resource the node uses. If the [code]constant[code] is invalid, Godot clears the override. See [member Theme.INVALID_CONSTANT] for more information. + Overrides an integer constant in the [Theme] resource the node uses. If the [code]constant[/code] is invalid, Godot clears the override. See [member Theme.INVALID_CONSTANT] for more information. </description> </method> <method name="add_font_override"> @@ -228,7 +228,14 @@ <argument index="0" name="margin" type="int" enum="Margin"> </argument> <description> - Return the forced neighbour for moving the input focus to. When pressing TAB or directional/joypad directions focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function. + Return the forced neighbour for moving the input focus to. When pressing directional/joypad directions, focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function. + </description> + </method> + <method name="get_focus_next" qualifiers="const"> + <return type="NodePath"> + </return> + <description> + Return the 'focus_next' for moving input focus to. When pressing TAB, focus is moved to the next control in the tree. However, the control to move to can be forced with this function. </description> </method> <method name="get_focus_owner" qualifiers="const"> @@ -238,6 +245,13 @@ Return which control is owning the keyboard focus, or null if no one. </description> </method> + <method name="get_focus_previous" qualifiers="const"> + <return type="NodePath"> + </return> + <description> + Return the 'focus_previous' for moving input focus to. When pressing Shift+TAB focus is moved to the previous control in the tree. However, the control to move to can be forced with this function. + </description> + </method> <method name="get_font" qualifiers="const"> <return type="Font"> </return> @@ -347,7 +361,7 @@ Return the rotation (in radians) </description> </method> - <method name="get_rotation_deg" qualifiers="const"> + <method name="get_rotation_degrees" qualifiers="const"> <return type="float"> </return> <description> @@ -676,7 +690,25 @@ <argument index="1" name="neighbour" type="NodePath"> </argument> <description> - Force a neighbour for moving the input focus to. When pressing TAB or directional/joypad directions focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function. + Force a neighbour for moving the input focus to. When pressing directional/joypad directions, focus is moved to the next control in that direction. However, the neighbour to move to can be forced with this function. + </description> + </method> + <method name="set_focus_next"> + <return type="void"> + </return> + <argument index="0" name="next" type="NodePath"> + </argument> + <description> + Force the 'focus_next' for moving input focus to. When pressing TAB, focus is moved to the next control in the tree. However, the control to move to can be forced with this function. + </description> + </method> + <method name="set_focus_previous"> + <return type="void"> + </return> + <argument index="0" name="previous" type="NodePath"> + </argument> + <description> + Force the 'focus_previous' for moving input focus to. When pressing Shift+TAB, focus is moved to the previous control in the tree. However, the control to move to can be forced with this function. </description> </method> <method name="set_global_position"> @@ -763,7 +795,7 @@ Set the rotation (in radians). </description> </method> - <method name="set_rotation_deg"> + <method name="set_rotation_degrees"> <return type="void"> </return> <argument index="0" name="degrees" type="float"> @@ -910,7 +942,7 @@ <member name="rect_position" type="Vector2" setter="set_position" getter="get_position"> The node's position, relative to its parent. It corresponds to the rectangle's top-left corner. The property is not affected by [member rect_pivot_offset]. </member> - <member name="rect_rotation" type="float" setter="set_rotation_deg" getter="get_rotation_deg"> + <member name="rect_rotation" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees"> The node's rotation around its pivot, in degrees. See [member rect_pivot_offset] to change the pivot's position. </member> <member name="rect_scale" type="Vector2" setter="set_scale" getter="get_scale"> diff --git a/doc/classes/ConvexPolygonShape.xml b/doc/classes/ConvexPolygonShape.xml index 822b99547e..0ea140148c 100644 --- a/doc/classes/ConvexPolygonShape.xml +++ b/doc/classes/ConvexPolygonShape.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ConvexPolygonShape" inherits="Shape" category="Core" version="3.0.alpha.custom_build"> +<class name="ConvexPolygonShape" inherits="Shape" category="Core" version="3.0-alpha"> <brief_description> Convex polygon shape for 3D physics. </brief_description> diff --git a/doc/classes/ConvexPolygonShape2D.xml b/doc/classes/ConvexPolygonShape2D.xml index cf1fdccc26..40507c6a6b 100644 --- a/doc/classes/ConvexPolygonShape2D.xml +++ b/doc/classes/ConvexPolygonShape2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ConvexPolygonShape2D" inherits="Shape2D" category="Core" version="3.0.alpha.custom_build"> +<class name="ConvexPolygonShape2D" inherits="Shape2D" category="Core" version="3.0-alpha"> <brief_description> Convex Polygon Shape for 2D physics. </brief_description> diff --git a/doc/classes/CubeMap.xml b/doc/classes/CubeMap.xml index b173bba3c6..9b0837306e 100644 --- a/doc/classes/CubeMap.xml +++ b/doc/classes/CubeMap.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CubeMap" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="CubeMap" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> A CubeMap is a 6 sided 3D texture. </brief_description> diff --git a/doc/classes/CubeMesh.xml b/doc/classes/CubeMesh.xml index 642f37c393..4a8ad104b7 100644 --- a/doc/classes/CubeMesh.xml +++ b/doc/classes/CubeMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CubeMesh" inherits="PrimitiveMesh" category="Core" version="3.0.alpha.custom_build"> +<class name="CubeMesh" inherits="PrimitiveMesh" category="Core" version="3.0-alpha"> <brief_description> Generate an axis-aligned cuboid [PrimitiveMesh]. </brief_description> diff --git a/doc/classes/Curve.xml b/doc/classes/Curve.xml index c89ab6fb9b..3741f51fad 100644 --- a/doc/classes/Curve.xml +++ b/doc/classes/Curve.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Curve" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Curve" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Curve2D.xml b/doc/classes/Curve2D.xml index 99ec2b7d94..0d9dfad643 100644 --- a/doc/classes/Curve2D.xml +++ b/doc/classes/Curve2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Curve2D" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Curve2D" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Describes a Bezier curve in 2D space. </brief_description> diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml index 02299753cf..35f8db0177 100644 --- a/doc/classes/Curve3D.xml +++ b/doc/classes/Curve3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Curve3D" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Curve3D" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Describes a Bezier curve in 3D space. </brief_description> diff --git a/doc/classes/CurveTexture.xml b/doc/classes/CurveTexture.xml index 8f8f60968a..61a6a2486f 100644 --- a/doc/classes/CurveTexture.xml +++ b/doc/classes/CurveTexture.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CurveTexture" inherits="Texture" category="Core" version="3.0.alpha.custom_build"> +<class name="CurveTexture" inherits="Texture" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/CylinderMesh.xml b/doc/classes/CylinderMesh.xml index 8399312dac..8398b52ee0 100644 --- a/doc/classes/CylinderMesh.xml +++ b/doc/classes/CylinderMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CylinderMesh" inherits="PrimitiveMesh" category="Core" version="3.0.alpha.custom_build"> +<class name="CylinderMesh" inherits="PrimitiveMesh" category="Core" version="3.0-alpha"> <brief_description> Class representing a cylindrical [PrimitiveMesh]. </brief_description> diff --git a/doc/classes/DampedSpringJoint2D.xml b/doc/classes/DampedSpringJoint2D.xml index 36c5564513..da7147933d 100644 --- a/doc/classes/DampedSpringJoint2D.xml +++ b/doc/classes/DampedSpringJoint2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="DampedSpringJoint2D" inherits="Joint2D" category="Core" version="3.0.alpha.custom_build"> +<class name="DampedSpringJoint2D" inherits="Joint2D" category="Core" version="3.0-alpha"> <brief_description> Damped spring constraint for 2D physics. </brief_description> diff --git a/doc/classes/Dictionary.xml b/doc/classes/Dictionary.xml index 4b37061af2..5664b2079b 100644 --- a/doc/classes/Dictionary.xml +++ b/doc/classes/Dictionary.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Dictionary" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Dictionary" category="Built-In Types" version="3.0-alpha"> <brief_description> Dictionary type. </brief_description> diff --git a/doc/classes/DirectionalLight.xml b/doc/classes/DirectionalLight.xml index 7de1791519..f0cc007339 100644 --- a/doc/classes/DirectionalLight.xml +++ b/doc/classes/DirectionalLight.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="DirectionalLight" inherits="Light" category="Core" version="3.0.alpha.custom_build"> +<class name="DirectionalLight" inherits="Light" category="Core" version="3.0-alpha"> <brief_description> Directional Light, such as the Sun or the Moon. </brief_description> diff --git a/doc/classes/Directory.xml b/doc/classes/Directory.xml index c3c4c7a8ac..b11e0629cd 100644 --- a/doc/classes/Directory.xml +++ b/doc/classes/Directory.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Directory" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="Directory" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Type used to handle the filesystem. </brief_description> @@ -34,7 +34,7 @@ </argument> <description> Change the currently opened directory to the one passed as an argument. The argument can be relative to the current directory (e.g. [code]newdir[/code] or [code]../newdir[/code]), or an absolute path (e.g. [code]/tmp/newdir[/code] or [code]res://somedir/newdir[/code]). - The method returns one of the error code constants defined in [@Global Scope] (OK or ERR_*). + The method returns one of the error code constants defined in [@GlobalScope] (OK or ERR_*). </description> </method> <method name="copy"> @@ -46,7 +46,7 @@ </argument> <description> Copy the [i]from[/i] file to the [i]to[/i] destination. Both arguments should be paths to files, either relative or absolute. If the destination file exists and is not access-protected, it will be overwritten. - Returns one of the error code constants defined in [@Global Scope] (OK, FAILED or ERR_*). + Returns one of the error code constants defined in [@GlobalScope] (OK, FAILED or ERR_*). </description> </method> <method name="current_is_dir" qualifiers="const"> @@ -146,7 +146,7 @@ </argument> <description> Create a directory. The argument can be relative to the current directory, or an absolute path. The target directory should be placed in an already existing directory (to create the full path recursively, see [method make_dir_recursive]). - The method returns one of the error code constants defined in [@Global Scope] (OK, FAILED or ERR_*). + The method returns one of the error code constants defined in [@GlobalScope] (OK, FAILED or ERR_*). </description> </method> <method name="make_dir_recursive"> @@ -156,7 +156,7 @@ </argument> <description> Create a target directory and all necessary intermediate directories in its path, by calling [method make_dir] recursively. The argument can be relative to the current directory, or an absolute path. - Return one of the error code constants defined in [@Global Scope] (OK, FAILED or ERR_*). + Return one of the error code constants defined in [@GlobalScope] (OK, FAILED or ERR_*). </description> </method> <method name="open"> @@ -166,7 +166,7 @@ </argument> <description> Open an existing directory of the filesystem. The [i]path[/i] argument can be within the project tree ([code]res://folder[/code]), the user directory ([code]user://folder[/code]) or an absolute path of the user filesystem (e.g. [code]/tmp/folder[/code] or [code]C:\tmp\folder[/code]). - The method returns one of the error code constants defined in [@Global Scope] (OK or ERR_*). + The method returns one of the error code constants defined in [@GlobalScope] (OK or ERR_*). </description> </method> <method name="remove"> @@ -176,7 +176,7 @@ </argument> <description> Delete the target file or an empty directory. The argument can be relative to the current directory, or an absolute path. If the target directory is not empty, the operation will fail. - Return one of the error code constants defined in [@Global Scope] (OK or FAILED). + Return one of the error code constants defined in [@GlobalScope] (OK or FAILED). </description> </method> <method name="rename"> @@ -188,7 +188,7 @@ </argument> <description> Rename (move) the [i]from[/i] file to the [i]to[/i] destination. Both arguments should be paths to files, either relative or absolute. If the destination file exists and is not access-protected, it will be overwritten. - Return one of the error code constants defined in [@Global Scope] (OK or FAILED). + Return one of the error code constants defined in [@GlobalScope] (OK or FAILED). </description> </method> </methods> diff --git a/doc/classes/DynamicFont.xml b/doc/classes/DynamicFont.xml index d7f08c85a1..9149e14a62 100644 --- a/doc/classes/DynamicFont.xml +++ b/doc/classes/DynamicFont.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="DynamicFont" inherits="Font" category="Core" version="3.0.alpha.custom_build"> +<class name="DynamicFont" inherits="Font" category="Core" version="3.0-alpha"> <brief_description> DynamicFont renders vector font files at runtime. </brief_description> diff --git a/doc/classes/DynamicFontData.xml b/doc/classes/DynamicFontData.xml index 9012b46e08..26529006cb 100644 --- a/doc/classes/DynamicFontData.xml +++ b/doc/classes/DynamicFontData.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="DynamicFontData" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="DynamicFontData" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Used with [DynamicFont] to describe the location of a font file. </brief_description> diff --git a/doc/classes/EditorExportPlugin.xml b/doc/classes/EditorExportPlugin.xml index b0ed24b767..a3bab32476 100644 --- a/doc/classes/EditorExportPlugin.xml +++ b/doc/classes/EditorExportPlugin.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorExportPlugin" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorExportPlugin" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/EditorFileDialog.xml b/doc/classes/EditorFileDialog.xml index 6ae893f189..f29d9fd4dd 100644 --- a/doc/classes/EditorFileDialog.xml +++ b/doc/classes/EditorFileDialog.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorFileDialog" inherits="ConfirmationDialog" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorFileDialog" inherits="ConfirmationDialog" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/EditorFileSystem.xml b/doc/classes/EditorFileSystem.xml index 6a2f811425..afec85184c 100644 --- a/doc/classes/EditorFileSystem.xml +++ b/doc/classes/EditorFileSystem.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorFileSystem" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorFileSystem" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Resource filesystem, as the editor sees it. </brief_description> diff --git a/doc/classes/EditorFileSystemDirectory.xml b/doc/classes/EditorFileSystemDirectory.xml index 7d284f864e..99bca09eb6 100644 --- a/doc/classes/EditorFileSystemDirectory.xml +++ b/doc/classes/EditorFileSystemDirectory.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorFileSystemDirectory" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorFileSystemDirectory" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> A diretory for the resource filesystem. </brief_description> diff --git a/doc/classes/EditorImportPlugin.xml b/doc/classes/EditorImportPlugin.xml index c276a8f661..9836fb2527 100644 --- a/doc/classes/EditorImportPlugin.xml +++ b/doc/classes/EditorImportPlugin.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorImportPlugin" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorImportPlugin" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Registers a custom resource importer in the editor. Use the class to parse any file and import it as a new resource type. </brief_description> diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml index 3a3fd43b15..0059804c00 100644 --- a/doc/classes/EditorInterface.xml +++ b/doc/classes/EditorInterface.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorInterface" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorInterface" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Editor interface and main components. </brief_description> @@ -127,7 +127,7 @@ <return type="int" enum="Error"> </return> <description> - Saves the scene. Returns either OK or ERR_CANT_CREATE. See [@Global Scope] constants. + Saves the scene. Returns either OK or ERR_CANT_CREATE. See [@GlobalScope] constants. </description> </method> <method name="save_scene_as"> diff --git a/doc/classes/EditorPlugin.xml b/doc/classes/EditorPlugin.xml index de79c3c85c..f9bdf1dcd5 100644 --- a/doc/classes/EditorPlugin.xml +++ b/doc/classes/EditorPlugin.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorPlugin" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorPlugin" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Used by the editor to extend its functionality. </brief_description> diff --git a/doc/classes/EditorResourceConversionPlugin.xml b/doc/classes/EditorResourceConversionPlugin.xml index e165ae376b..6fbb60ddf6 100644 --- a/doc/classes/EditorResourceConversionPlugin.xml +++ b/doc/classes/EditorResourceConversionPlugin.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorResourceConversionPlugin" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorResourceConversionPlugin" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/EditorResourcePreview.xml b/doc/classes/EditorResourcePreview.xml index 5174d9243b..44f60d4d2c 100644 --- a/doc/classes/EditorResourcePreview.xml +++ b/doc/classes/EditorResourcePreview.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorResourcePreview" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorResourcePreview" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Helper to generate previews of resources or files. </brief_description> diff --git a/doc/classes/EditorResourcePreviewGenerator.xml b/doc/classes/EditorResourcePreviewGenerator.xml index 231198516e..3de0dbc708 100644 --- a/doc/classes/EditorResourcePreviewGenerator.xml +++ b/doc/classes/EditorResourcePreviewGenerator.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorResourcePreviewGenerator" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorResourcePreviewGenerator" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Custom generator of previews. </brief_description> diff --git a/doc/classes/EditorScript.xml b/doc/classes/EditorScript.xml index 245dbc078d..1e46164fc6 100644 --- a/doc/classes/EditorScript.xml +++ b/doc/classes/EditorScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorScript" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorScript" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Base script that can be used to add extension functions to the editor. </brief_description> diff --git a/doc/classes/EditorSelection.xml b/doc/classes/EditorSelection.xml index a6dc60ee7b..999cb5e505 100644 --- a/doc/classes/EditorSelection.xml +++ b/doc/classes/EditorSelection.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorSelection" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorSelection" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Manages the SceneTree selection in the editor. </brief_description> diff --git a/doc/classes/EditorSettings.xml b/doc/classes/EditorSettings.xml index 17a4d2fe4b..e58516d461 100644 --- a/doc/classes/EditorSettings.xml +++ b/doc/classes/EditorSettings.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorSettings" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorSettings" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Object that holds the project-independent editor settings. </brief_description> @@ -23,7 +23,7 @@ <argument index="0" name="info" type="Dictionary"> </argument> <description> - Add a custom property info to a property. The dictionary must contain: name:[String](the name of the property) and type:[int](see TYPE_* in [@Global Scope]), and optionally hint:[int](see PROPERTY_HINT_* in [@Global Scope]), hint_string:[String]. + Add a custom property info to a property. The dictionary must contain: name:[String](the name of the property) and type:[int](see TYPE_* in [@GlobalScope]), and optionally hint:[int](see PROPERTY_HINT_* in [@GlobalScope]), hint_string:[String]. Example: [codeblock] editor_settings.set("category/property_name", 0) @@ -55,7 +55,7 @@ Get the list of favorite directories for this project. </description> </method> - <method name="get_project_settings_path" qualifiers="const"> + <method name="get_project_settings_dir" qualifiers="const"> <return type="String"> </return> <description> @@ -77,7 +77,7 @@ <description> </description> </method> - <method name="get_settings_path" qualifiers="const"> + <method name="get_settings_dir" qualifiers="const"> <return type="String"> </return> <description> diff --git a/doc/classes/EditorSpatialGizmo.xml b/doc/classes/EditorSpatialGizmo.xml index 545eadeed2..758024c99b 100644 --- a/doc/classes/EditorSpatialGizmo.xml +++ b/doc/classes/EditorSpatialGizmo.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EditorSpatialGizmo" inherits="SpatialGizmo" category="Core" version="3.0.alpha.custom_build"> +<class name="EditorSpatialGizmo" inherits="SpatialGizmo" category="Core" version="3.0-alpha"> <brief_description> Custom gizmo for editing Spatial objects. </brief_description> @@ -24,7 +24,7 @@ </return> <argument index="0" name="triangles" type="TriangleMesh"> </argument> - <argument index="1" name="bounds" type="Rect3"> + <argument index="1" name="bounds" type="AABB"> </argument> <description> Add collision triangles to the gizmo for picking. A [TriangleMesh] can be generated from a regular [Mesh] too. Call this function during [method redraw]. diff --git a/doc/classes/EncodedObjectAsID.xml b/doc/classes/EncodedObjectAsID.xml index 412e60bf99..41839e3d01 100644 --- a/doc/classes/EncodedObjectAsID.xml +++ b/doc/classes/EncodedObjectAsID.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="EncodedObjectAsID" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="EncodedObjectAsID" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Engine.xml b/doc/classes/Engine.xml index 083688b416..090e0d7910 100644 --- a/doc/classes/Engine.xml +++ b/doc/classes/Engine.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Engine" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="Engine" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Access to basic engine properties. </brief_description> @@ -39,6 +39,14 @@ Returns the main loop object (see [MainLoop] and [SceneTree]). </description> </method> + <method name="get_singleton" qualifiers="const"> + <return type="Object"> + </return> + <argument index="0" name="name" type="String"> + </argument> + <description> + </description> + </method> <method name="get_target_fps" qualifiers="const"> <return type="float"> </return> @@ -63,8 +71,16 @@ "minor" - Holds the minor version number as a String "patch" - Holds the patch version number as a String "status" - Holds the status (e.g. "beta", "rc1", "rc2", ... "stable") as a String - "revision" - Holds the revision (e.g. "custom-build") as a String - "string" - major + minor + patch + status + revision in a single String + "build" - Holds the build name (e.g. "custom-build") as a String + "string" - major + minor + patch + status + build in a single String + </description> + </method> + <method name="has_singleton" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="name" type="String"> + </argument> + <description> </description> </method> <method name="is_editor_hint" qualifiers="const"> diff --git a/doc/classes/Environment.xml b/doc/classes/Environment.xml index 4d40d5af9a..285caa8d0a 100644 --- a/doc/classes/Environment.xml +++ b/doc/classes/Environment.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Environment" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Environment" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Resource for environment nodes (like [WorldEnvironment]) that define multiple rendering options. </brief_description> diff --git a/doc/classes/File.xml b/doc/classes/File.xml index 6272d4105c..8ec56e9c48 100644 --- a/doc/classes/File.xml +++ b/doc/classes/File.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="File" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="File" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Type to handle file reading and writing operations. </brief_description> @@ -120,7 +120,7 @@ <return type="int" enum="Error"> </return> <description> - Returns the last error that happened when trying to perform operations. Compare with the [code]ERR_FILE_*[/code] constants from [@Global Scope]. + Returns the last error that happened when trying to perform operations. Compare with the [code]ERR_FILE_*[/code] constants from [@GlobalScope]. </description> </method> <method name="get_float" qualifiers="const"> diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index b3d131ca40..7dda486ac9 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="FileDialog" inherits="ConfirmationDialog" category="Core" version="3.0.alpha.custom_build"> +<class name="FileDialog" inherits="ConfirmationDialog" category="Core" version="3.0-alpha"> <brief_description> Dialog for selecting files or directories in the filesystem. </brief_description> diff --git a/doc/classes/Font.xml b/doc/classes/Font.xml index 2e2124cbd6..b83d66830f 100644 --- a/doc/classes/Font.xml +++ b/doc/classes/Font.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Font" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Font" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Internationalized font and text drawing support. </brief_description> diff --git a/doc/classes/FuncRef.xml b/doc/classes/FuncRef.xml index 987d750ced..65da5dd98f 100644 --- a/doc/classes/FuncRef.xml +++ b/doc/classes/FuncRef.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="FuncRef" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="FuncRef" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Reference to a function in an object. </brief_description> diff --git a/doc/classes/GIProbe.xml b/doc/classes/GIProbe.xml index 3f3d24aaaa..e445d94835 100644 --- a/doc/classes/GIProbe.xml +++ b/doc/classes/GIProbe.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GIProbe" inherits="VisualInstance" category="Core" version="3.0.alpha.custom_build"> +<class name="GIProbe" inherits="VisualInstance" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/GIProbeData.xml b/doc/classes/GIProbeData.xml index 6d47daf985..5d118be776 100644 --- a/doc/classes/GIProbeData.xml +++ b/doc/classes/GIProbeData.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GIProbeData" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="GIProbeData" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> @@ -16,7 +16,7 @@ </description> </method> <method name="get_bounds" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> @@ -86,7 +86,7 @@ <method name="set_bounds"> <return type="void"> </return> - <argument index="0" name="bounds" type="Rect3"> + <argument index="0" name="bounds" type="AABB"> </argument> <description> </description> @@ -167,7 +167,7 @@ <members> <member name="bias" type="float" setter="set_bias" getter="get_bias"> </member> - <member name="bounds" type="Rect3" setter="set_bounds" getter="get_bounds"> + <member name="bounds" type="AABB" setter="set_bounds" getter="get_bounds"> </member> <member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size"> </member> diff --git a/doc/classes/Generic6DOFJoint.xml b/doc/classes/Generic6DOFJoint.xml index 89ec1fd836..202e461652 100644 --- a/doc/classes/Generic6DOFJoint.xml +++ b/doc/classes/Generic6DOFJoint.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Generic6DOFJoint" inherits="Joint" category="Core" version="3.0.alpha.custom_build"> +<class name="Generic6DOFJoint" inherits="Joint" category="Core" version="3.0-alpha"> <brief_description> The generic 6 degrees of freedom joint can implement a variety of joint-types by locking certain axes' rotation or translation. </brief_description> diff --git a/doc/classes/Geometry.xml b/doc/classes/Geometry.xml index 1589a9a906..5da3ca0059 100644 --- a/doc/classes/Geometry.xml +++ b/doc/classes/Geometry.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Geometry" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="Geometry" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> @@ -50,6 +50,26 @@ Returns an array of [Plane]s closely bounding a faceted cylinder centered at the origin with radius [code]radius[/code] and height [code]height[/code]. The parameter [code]sides[/code] defines how many planes will be generated for the round part of the cylinder. The parameter [code]axis[/code] describes the axis along which the cylinder is oriented (0 for X, 1 for Y, 2 for Z). </description> </method> + <method name="clip_polygon"> + <return type="PoolVector3Array"> + </return> + <argument index="0" name="points" type="PoolVector3Array"> + </argument> + <argument index="1" name="plane" type="Plane"> + </argument> + <description> + Clips the polygon defined by the points in [code]points[/code] against the [code]plane[/code] and returns the points of the clipped polygon. + </description> + </method> + <method name="convex_hull_2d"> + <return type="PoolVector2Array"> + </return> + <argument index="0" name="points" type="PoolVector2Array"> + </argument> + <description> + Given an array of [Vector2]s, returns the convex hull as a list of points in counter-clockwise order. The last point is the same as the first one. + </description> + </method> <method name="get_closest_point_to_segment"> <return type="Vector3"> </return> @@ -280,26 +300,6 @@ Triangulates the polygon specified by the points in [code]polygon[/code]. Returns a [PoolIntArray] where each triangle consists of three consecutive point indices into [code]polygon[/code] (i.e. the returned array will have [code]n * 3[/code] elements, with [code]n[/code] being the number of found triangles). If the triangulation did not succeed, an empty [PoolIntArray] is returned. </description> </method> - <method name="convex_hull_2d"> - <return type="PoolVector2Array"> - </return> - <argument index="0" name="points" type="PoolVector2Array"> - </argument> - <description> - Given an array of [Vector2]s, returns the convex hull as a list of points in counter-clockwise order. The last point is the same as the first one. - </description> - </method> - <method name="clip_polygon"> - <return type="PoolVector3Array"> - </return> - <argument index="0" name="points" type="PoolVector3Array"> - </argument> - <argument index="1" name="plane" type="Plane"> - </argument> - <description> - Clips the polygon defined by the points in [code]points[/code] against the [code]plane[/code] and returns the points of the clipped polygon. - </description> - </method> </methods> <constants> </constants> diff --git a/doc/classes/GeometryInstance.xml b/doc/classes/GeometryInstance.xml index 57aec8be41..f21dbecd04 100644 --- a/doc/classes/GeometryInstance.xml +++ b/doc/classes/GeometryInstance.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GeometryInstance" inherits="VisualInstance" category="Core" version="3.0.alpha.custom_build"> +<class name="GeometryInstance" inherits="VisualInstance" category="Core" version="3.0-alpha"> <brief_description> Base node for geometry based visual instances. </brief_description> diff --git a/doc/classes/Gradient.xml b/doc/classes/Gradient.xml index e086ae86b1..d557ec11c5 100644 --- a/doc/classes/Gradient.xml +++ b/doc/classes/Gradient.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Gradient" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Gradient" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Color interpolator node. </brief_description> diff --git a/doc/classes/GradientTexture.xml b/doc/classes/GradientTexture.xml index eab8ea77af..88a776cb6a 100644 --- a/doc/classes/GradientTexture.xml +++ b/doc/classes/GradientTexture.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GradientTexture" inherits="Texture" category="Core" version="3.0.alpha.custom_build"> +<class name="GradientTexture" inherits="Texture" category="Core" version="3.0-alpha"> <brief_description> Gradient filled texture. </brief_description> diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml index 01d578be5e..a07809ce95 100644 --- a/doc/classes/GraphEdit.xml +++ b/doc/classes/GraphEdit.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GraphEdit" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="GraphEdit" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> GraphEdit is an area capable of showing various GraphNodes. It manages connection events between them. </brief_description> diff --git a/doc/classes/GraphNode.xml b/doc/classes/GraphNode.xml index e230390882..2ad0cc1182 100644 --- a/doc/classes/GraphNode.xml +++ b/doc/classes/GraphNode.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GraphNode" inherits="Container" category="Core" version="3.0.alpha.custom_build"> +<class name="GraphNode" inherits="Container" category="Core" version="3.0-alpha"> <brief_description> A GraphNode is a container with several input and output slots allowing connections between GraphNodes. Slots can have different, incompatible types. </brief_description> diff --git a/doc/classes/GridContainer.xml b/doc/classes/GridContainer.xml index 30976eff99..01bbed6ea7 100644 --- a/doc/classes/GridContainer.xml +++ b/doc/classes/GridContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GridContainer" inherits="Container" category="Core" version="3.0.alpha.custom_build"> +<class name="GridContainer" inherits="Container" category="Core" version="3.0-alpha"> <brief_description> Grid container used to arrange elements in a grid like layout </brief_description> diff --git a/doc/classes/GrooveJoint2D.xml b/doc/classes/GrooveJoint2D.xml index 412a4504c3..182bf5e8f1 100644 --- a/doc/classes/GrooveJoint2D.xml +++ b/doc/classes/GrooveJoint2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GrooveJoint2D" inherits="Joint2D" category="Core" version="3.0.alpha.custom_build"> +<class name="GrooveJoint2D" inherits="Joint2D" category="Core" version="3.0-alpha"> <brief_description> Groove constraint for 2D physics. </brief_description> diff --git a/doc/classes/HBoxContainer.xml b/doc/classes/HBoxContainer.xml index 2ffc2a8c57..6ee9a2c1f4 100644 --- a/doc/classes/HBoxContainer.xml +++ b/doc/classes/HBoxContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="HBoxContainer" inherits="BoxContainer" category="Core" version="3.0.alpha.custom_build"> +<class name="HBoxContainer" inherits="BoxContainer" category="Core" version="3.0-alpha"> <brief_description> Horizontal box container. </brief_description> diff --git a/doc/classes/HScrollBar.xml b/doc/classes/HScrollBar.xml index 188995527c..7fe26ec863 100644 --- a/doc/classes/HScrollBar.xml +++ b/doc/classes/HScrollBar.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="HScrollBar" inherits="ScrollBar" category="Core" version="3.0.alpha.custom_build"> +<class name="HScrollBar" inherits="ScrollBar" category="Core" version="3.0-alpha"> <brief_description> Horizontal scroll bar. </brief_description> diff --git a/doc/classes/HSeparator.xml b/doc/classes/HSeparator.xml index 351eee7ee6..487f83ec1d 100644 --- a/doc/classes/HSeparator.xml +++ b/doc/classes/HSeparator.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="HSeparator" inherits="Separator" category="Core" version="3.0.alpha.custom_build"> +<class name="HSeparator" inherits="Separator" category="Core" version="3.0-alpha"> <brief_description> Horizontal separator. </brief_description> diff --git a/doc/classes/HSlider.xml b/doc/classes/HSlider.xml index 25e62b90e3..b4a97425f3 100644 --- a/doc/classes/HSlider.xml +++ b/doc/classes/HSlider.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="HSlider" inherits="Slider" category="Core" version="3.0.alpha.custom_build"> +<class name="HSlider" inherits="Slider" category="Core" version="3.0-alpha"> <brief_description> Horizontal slider. </brief_description> diff --git a/doc/classes/HSplitContainer.xml b/doc/classes/HSplitContainer.xml index d7dc79a783..a107d30be7 100644 --- a/doc/classes/HSplitContainer.xml +++ b/doc/classes/HSplitContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="HSplitContainer" inherits="SplitContainer" category="Core" version="3.0.alpha.custom_build"> +<class name="HSplitContainer" inherits="SplitContainer" category="Core" version="3.0-alpha"> <brief_description> Horizontal split container. </brief_description> diff --git a/doc/classes/HTTPClient.xml b/doc/classes/HTTPClient.xml index f148545848..569c76ae0c 100644 --- a/doc/classes/HTTPClient.xml +++ b/doc/classes/HTTPClient.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="HTTPClient" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="HTTPClient" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Hyper-text transfer protocol client. </brief_description> diff --git a/doc/classes/HTTPRequest.xml b/doc/classes/HTTPRequest.xml index b780d29d0e..a1a84d2211 100644 --- a/doc/classes/HTTPRequest.xml +++ b/doc/classes/HTTPRequest.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="HTTPRequest" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="HTTPRequest" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> A Node with the ability to send HTTP requests. </brief_description> diff --git a/doc/classes/HingeJoint.xml b/doc/classes/HingeJoint.xml index d18e63f8a3..2d91549a66 100644 --- a/doc/classes/HingeJoint.xml +++ b/doc/classes/HingeJoint.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="HingeJoint" inherits="Joint" category="Core" version="3.0.alpha.custom_build"> +<class name="HingeJoint" inherits="Joint" category="Core" version="3.0-alpha"> <brief_description> A hinge between two 3D bodies. </brief_description> diff --git a/doc/classes/IP.xml b/doc/classes/IP.xml index fed7000df6..721cf07441 100644 --- a/doc/classes/IP.xml +++ b/doc/classes/IP.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="IP" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="IP" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> IP Protocol support functions. </brief_description> diff --git a/doc/classes/IP_Unix.xml b/doc/classes/IP_Unix.xml index d30ad795a8..bac7e374bb 100644 --- a/doc/classes/IP_Unix.xml +++ b/doc/classes/IP_Unix.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="IP_Unix" inherits="IP" category="Core" version="3.0.alpha.custom_build"> +<class name="IP_Unix" inherits="IP" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index 905a844094..b6eb26ce8c 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Image" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Image" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Image datatype. </brief_description> @@ -377,13 +377,13 @@ </argument> <description> Sets the [Color] of the pixel at [code](x, y)[/code] if the image is unlocked. Example: - [code] + [codeblock] var img = Image.new() img.lock() img.set_pixel(x, y, color) # Does not have an effect img.unlock() img.set_pixel(x, y, color) # Works - [/code]. + [/codeblock] </description> </method> <method name="shrink_x2"> diff --git a/doc/classes/ImageTexture.xml b/doc/classes/ImageTexture.xml index b392252399..d179794c1f 100644 --- a/doc/classes/ImageTexture.xml +++ b/doc/classes/ImageTexture.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ImageTexture" inherits="Texture" category="Core" version="3.0.alpha.custom_build"> +<class name="ImageTexture" inherits="Texture" category="Core" version="3.0-alpha"> <brief_description> A [Texture] based on an [Image]. </brief_description> diff --git a/doc/classes/ImmediateGeometry.xml b/doc/classes/ImmediateGeometry.xml index cd7074aeaf..7ad09c3fe9 100644 --- a/doc/classes/ImmediateGeometry.xml +++ b/doc/classes/ImmediateGeometry.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ImmediateGeometry" inherits="GeometryInstance" category="Core" version="3.0.alpha.custom_build"> +<class name="ImmediateGeometry" inherits="GeometryInstance" category="Core" version="3.0-alpha"> <brief_description> Draws simple geometry from code. </brief_description> diff --git a/doc/classes/Input.xml b/doc/classes/Input.xml index d2d01dacb4..114c8d2c59 100644 --- a/doc/classes/Input.xml +++ b/doc/classes/Input.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Input" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="Input" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> A Singleton that deals with inputs. </brief_description> @@ -75,7 +75,7 @@ <argument index="1" name="axis" type="int"> </argument> <description> - Returns the current value of the joypad axis at given index (see [code]JOY_*[/code] constants in [@Global Scope]) + Returns the current value of the joypad axis at given index (see [code]JOY_*[/code] constants in [@GlobalScope]) </description> </method> <method name="get_joy_axis_index_from_string"> @@ -209,7 +209,7 @@ <argument index="1" name="button" type="int"> </argument> <description> - Returns [code]true[/code] if you are pressing the joypad button. (see [code]JOY_*[/code] constants in [@Global Scope]) + Returns [code]true[/code] if you are pressing the joypad button. (see [code]JOY_*[/code] constants in [@GlobalScope]) </description> </method> <method name="is_joy_known"> @@ -218,7 +218,7 @@ <argument index="0" name="device" type="int"> </argument> <description> - Returns [code]true[/code] if the system knows the specified device. This means that it sets all button and axis indices exactly as defined in the [code]JOY_*[/code] constants (see [@Global Scope]). Unknown joypads are not expected to match these constants, but you can still retrieve events from them. + Returns [code]true[/code] if the system knows the specified device. This means that it sets all button and axis indices exactly as defined in the [code]JOY_*[/code] constants (see [@GlobalScope]). Unknown joypads are not expected to match these constants, but you can still retrieve events from them. </description> </method> <method name="is_key_pressed" qualifiers="const"> @@ -227,7 +227,7 @@ <argument index="0" name="scancode" type="int"> </argument> <description> - Returns [code]true[/code] if you are pressing the key. You can pass [code]KEY_*[/code], which are pre-defined constants listed in [@Global Scope]. + Returns [code]true[/code] if you are pressing the key. You can pass [code]KEY_*[/code], which are pre-defined constants listed in [@GlobalScope]. </description> </method> <method name="is_mouse_button_pressed" qualifiers="const"> @@ -236,7 +236,7 @@ <argument index="0" name="button" type="int"> </argument> <description> - Returns [code]true[/code] if you are pressing the mouse button. You can pass [code]BUTTON_*[/code], which are pre-defined constants listed in [@Global Scope]. + Returns [code]true[/code] if you are pressing the mouse button. You can pass [code]BUTTON_*[/code], which are pre-defined constants listed in [@GlobalScope]. </description> </method> <method name="joy_connection_changed"> diff --git a/doc/classes/InputDefault.xml b/doc/classes/InputDefault.xml index cb8ad6b823..9cbc993af1 100644 --- a/doc/classes/InputDefault.xml +++ b/doc/classes/InputDefault.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputDefault" inherits="Input" category="Core" version="3.0.alpha.custom_build"> +<class name="InputDefault" inherits="Input" category="Core" version="3.0-alpha"> <brief_description> Default implementation of the [Input] class. </brief_description> diff --git a/doc/classes/InputEvent.xml b/doc/classes/InputEvent.xml index c6abf2fee5..e4404fc258 100644 --- a/doc/classes/InputEvent.xml +++ b/doc/classes/InputEvent.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEvent" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="InputEvent" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Generic input event </brief_description> @@ -18,7 +18,7 @@ <argument index="0" name="event" type="InputEvent"> </argument> <description> - Returns [code]true[/code] if this event matches [code]event[event]. + Returns [code]true[/code] if this event matches [code]event[/code]. </description> </method> <method name="as_text" qualifiers="const"> diff --git a/doc/classes/InputEventAction.xml b/doc/classes/InputEventAction.xml index d97f1d4a2e..383f8360fb 100644 --- a/doc/classes/InputEventAction.xml +++ b/doc/classes/InputEventAction.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventAction" inherits="InputEvent" category="Core" version="3.0.alpha.custom_build"> +<class name="InputEventAction" inherits="InputEvent" category="Core" version="3.0-alpha"> <brief_description> Input event type for actions. </brief_description> <description> - Contains a generic action which can be targeted from several type of inputs. Actions can be created from the project settings menu [code]Project > Project Settings > Input Map[/Code]. See [method Node._input]. + Contains a generic action which can be targeted from several type of inputs. Actions can be created from the project settings menu [code]Project > Project Settings > Input Map[/code]. See [method Node._input]. </description> <tutorials> http://docs.godotengine.org/en/stable/learning/features/inputs/inputevent.html#actions diff --git a/doc/classes/InputEventJoypadButton.xml b/doc/classes/InputEventJoypadButton.xml index f13a1102b7..fecd65e6a2 100644 --- a/doc/classes/InputEventJoypadButton.xml +++ b/doc/classes/InputEventJoypadButton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventJoypadButton" inherits="InputEvent" category="Core" version="3.0.alpha.custom_build"> +<class name="InputEventJoypadButton" inherits="InputEvent" category="Core" version="3.0-alpha"> <brief_description> Input event for gamepad buttons. </brief_description> diff --git a/doc/classes/InputEventJoypadMotion.xml b/doc/classes/InputEventJoypadMotion.xml index a7c585a55d..a89c91fbe6 100644 --- a/doc/classes/InputEventJoypadMotion.xml +++ b/doc/classes/InputEventJoypadMotion.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventJoypadMotion" inherits="InputEvent" category="Core" version="3.0.alpha.custom_build"> +<class name="InputEventJoypadMotion" inherits="InputEvent" category="Core" version="3.0-alpha"> <brief_description> Input event type for gamepad joysticks and other motions. For buttons see [code]InputEventJoypadMotion[/code]. </brief_description> diff --git a/doc/classes/InputEventKey.xml b/doc/classes/InputEventKey.xml index 9565584a4f..440e1347f8 100644 --- a/doc/classes/InputEventKey.xml +++ b/doc/classes/InputEventKey.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventKey" inherits="InputEventWithModifiers" category="Core" version="3.0.alpha.custom_build"> +<class name="InputEventKey" inherits="InputEventWithModifiers" category="Core" version="3.0-alpha"> <brief_description> Input event type for keyboard events. </brief_description> diff --git a/doc/classes/InputEventMouse.xml b/doc/classes/InputEventMouse.xml index 38eec74ffa..24a771cef3 100644 --- a/doc/classes/InputEventMouse.xml +++ b/doc/classes/InputEventMouse.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventMouse" inherits="InputEventWithModifiers" category="Core" version="3.0.alpha.custom_build"> +<class name="InputEventMouse" inherits="InputEventWithModifiers" category="Core" version="3.0-alpha"> <brief_description> Base input event type for mouse events. </brief_description> @@ -57,7 +57,7 @@ </methods> <members> <member name="button_mask" type="int" setter="set_button_mask" getter="get_button_mask"> - Mouse button mask identifier, one of or a bitwise combination of the BUTTON_MASK_* constants in [@Global Scope]. + Mouse button mask identifier, one of or a bitwise combination of the BUTTON_MASK_* constants in [@GlobalScope]. </member> <member name="global_position" type="Vector2" setter="set_global_position" getter="get_global_position"> Mouse position relative to the current [Viewport] when used in [method Control._gui_input], otherwise is at 0,0. diff --git a/doc/classes/InputEventMouseButton.xml b/doc/classes/InputEventMouseButton.xml index afc0c331c8..ff7c1da34e 100644 --- a/doc/classes/InputEventMouseButton.xml +++ b/doc/classes/InputEventMouseButton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventMouseButton" inherits="InputEventMouse" category="Core" version="3.0.alpha.custom_build"> +<class name="InputEventMouseButton" inherits="InputEventMouse" category="Core" version="3.0-alpha"> <brief_description> Input event type for mouse button events. </brief_description> @@ -65,7 +65,7 @@ </methods> <members> <member name="button_index" type="int" setter="set_button_index" getter="get_button_index"> - Mouse button identifier, one of the BUTTON_* or BUTTON_WHEEL_* constants in [@Global Scope]. + Mouse button identifier, one of the BUTTON_* or BUTTON_WHEEL_* constants in [@GlobalScope]. </member> <member name="doubleclick" type="bool" setter="set_doubleclick" getter="is_doubleclick"> If [code]true[/code] the mouse button's state is a double-click. If [code]false[/code] the mouse button's state is released. diff --git a/doc/classes/InputEventMouseMotion.xml b/doc/classes/InputEventMouseMotion.xml index 5be82e1ffa..6c9165fea8 100644 --- a/doc/classes/InputEventMouseMotion.xml +++ b/doc/classes/InputEventMouseMotion.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventMouseMotion" inherits="InputEventMouse" category="Core" version="3.0.alpha.custom_build"> +<class name="InputEventMouseMotion" inherits="InputEventMouse" category="Core" version="3.0-alpha"> <brief_description> Input event type for mouse motion events. </brief_description> diff --git a/doc/classes/InputEventScreenDrag.xml b/doc/classes/InputEventScreenDrag.xml index 0c92ad5f70..a68f444a7c 100644 --- a/doc/classes/InputEventScreenDrag.xml +++ b/doc/classes/InputEventScreenDrag.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventScreenDrag" inherits="InputEvent" category="Core" version="3.0.alpha.custom_build"> +<class name="InputEventScreenDrag" inherits="InputEvent" category="Core" version="3.0-alpha"> <brief_description> Input event type for screen drag events. (only available on mobile devices) diff --git a/doc/classes/InputEventScreenTouch.xml b/doc/classes/InputEventScreenTouch.xml index 01ba9f1285..d0c7181e84 100644 --- a/doc/classes/InputEventScreenTouch.xml +++ b/doc/classes/InputEventScreenTouch.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventScreenTouch" inherits="InputEvent" category="Core" version="3.0.alpha.custom_build"> +<class name="InputEventScreenTouch" inherits="InputEvent" category="Core" version="3.0-alpha"> <brief_description> Input event type for screen touch events. (only available on mobile devices) diff --git a/doc/classes/InputEventWithModifiers.xml b/doc/classes/InputEventWithModifiers.xml index 46107a4ab8..8e5ffed149 100644 --- a/doc/classes/InputEventWithModifiers.xml +++ b/doc/classes/InputEventWithModifiers.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputEventWithModifiers" inherits="InputEvent" category="Core" version="3.0.alpha.custom_build"> +<class name="InputEventWithModifiers" inherits="InputEvent" category="Core" version="3.0-alpha"> <brief_description> Base class for keys events with modifiers. </brief_description> diff --git a/doc/classes/InputMap.xml b/doc/classes/InputMap.xml index 99b77dab36..d5a1d85def 100644 --- a/doc/classes/InputMap.xml +++ b/doc/classes/InputMap.xml @@ -1,10 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InputMap" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="InputMap" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Singleton that manages [InputEventAction]. </brief_description> <description> - Manages all [InputEventAction] which can be created/modified from the project settings menu [code]Project > Project Settings > Input Map[/Code] or in code with [method add_action] and [method action_add_event]. See [method Node._input]. + Manages all [InputEventAction] which can be created/modified from the project settings menu [code]Project > Project Settings > Input Map[/code] or in code with [method add_action] and [method action_add_event]. See [method Node._input]. </description> <tutorials> http://docs.godotengine.org/en/stable/learning/features/inputs/inputevent.html#inputmap diff --git a/doc/classes/InstancePlaceholder.xml b/doc/classes/InstancePlaceholder.xml index e962192f81..4105065cb6 100644 --- a/doc/classes/InstancePlaceholder.xml +++ b/doc/classes/InstancePlaceholder.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InstancePlaceholder" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="InstancePlaceholder" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Placeholder for the root [Node] of a [PackedScene]. </brief_description> diff --git a/doc/classes/InterpolatedCamera.xml b/doc/classes/InterpolatedCamera.xml index 5e5ce59a8b..bd532bec85 100644 --- a/doc/classes/InterpolatedCamera.xml +++ b/doc/classes/InterpolatedCamera.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="InterpolatedCamera" inherits="Camera" category="Core" version="3.0.alpha.custom_build"> +<class name="InterpolatedCamera" inherits="Camera" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index 37c1db51f5..950b43417b 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ItemList" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="ItemList" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Control that provides a list of selectable items (and/or icons) in a single column, or optionally in multiple columns. </brief_description> diff --git a/doc/classes/JSON.xml b/doc/classes/JSON.xml index 8bff140bb4..e945a580db 100644 --- a/doc/classes/JSON.xml +++ b/doc/classes/JSON.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="JSON" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="JSON" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Helper class for parsing JSON data. </brief_description> diff --git a/doc/classes/JSONParseResult.xml b/doc/classes/JSONParseResult.xml index 2d163c4a80..5bf9298f7a 100644 --- a/doc/classes/JSONParseResult.xml +++ b/doc/classes/JSONParseResult.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="JSONParseResult" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="JSONParseResult" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Data class wrapper for decoded JSON. </brief_description> @@ -70,13 +70,13 @@ </methods> <members> <member name="error" type="int" setter="set_error" getter="get_error" enum="Error"> - The error type if JSON source was not successfully parsed. See [@Global Scope]ERR_* constants. + The error type if JSON source was not successfully parsed. See [@GlobalScope]ERR_* constants. </member> <member name="error_line" type="int" setter="set_error_line" getter="get_error_line"> The line number where the error occurred if JSON source was not successfully parsed. </member> <member name="error_string" type="String" setter="set_error_string" getter="get_error_string"> - The error message if JSON source was not successfully parsed. See [@Global Scope]ERR_* constants. + The error message if JSON source was not successfully parsed. See [@GlobalScope]ERR_* constants. </member> <member name="result" type="Variant" setter="set_result" getter="get_result"> A [Variant] containing the parsed JSON. Use typeof() to check if it is what you expect. For example, if JSON source starts with braces [code]{}[/code] a [Dictionary] will be returned, if JSON source starts with array braces [code][][/code] an [Array] will be returned. diff --git a/doc/classes/JavaScript.xml b/doc/classes/JavaScript.xml new file mode 100644 index 0000000000..9dd386f08e --- /dev/null +++ b/doc/classes/JavaScript.xml @@ -0,0 +1,30 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="JavaScript" inherits="Object" category="Core" version="3.0-alpha"> + <brief_description> + Singleton that connects the engine with the browser's JavaScript context in HTML5 export. + </brief_description> + <description> + The JavaScript singleton is implemented only in HTML5 export. It's used to access the browser's JavaScript context. This allows interaction with embedding pages or calling third-party JavaScript APIs. + </description> + <tutorials> + http://docs.godotengine.org/en/stable/learning/workflow/export/exporting_for_web.html#calling-javascript-from-script + </tutorials> + <demos> + </demos> + <methods> + <method name="eval"> + <return type="Variant"> + </return> + <argument index="0" name="code" type="String"> + </argument> + <argument index="1" name="use_global_execution_context" type="bool" default="false"> + </argument> + <description> + Execute the string [code]code[/code] as JavaScript code within the browser window. This is a call to the actual global JavaScript function [code]eval()[/code]. + If [code]use_global_execution_context[/code] is [code]true[/code], the code will be evaluated in the global execution context. Otherwise, it is evaluated in the execution context of a function within the engine's runtime environment. + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/Joint.xml b/doc/classes/Joint.xml index 901f84fe5e..30ece8df1f 100644 --- a/doc/classes/Joint.xml +++ b/doc/classes/Joint.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Joint" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="Joint" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Base class for all 3D joints </brief_description> diff --git a/doc/classes/Joint2D.xml b/doc/classes/Joint2D.xml index b9caa7ef4b..df70a04f10 100644 --- a/doc/classes/Joint2D.xml +++ b/doc/classes/Joint2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Joint2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="Joint2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Base node for all joint constraints in 2D physics. </brief_description> diff --git a/doc/classes/KinematicBody.xml b/doc/classes/KinematicBody.xml index f80c00ed6d..a423974753 100644 --- a/doc/classes/KinematicBody.xml +++ b/doc/classes/KinematicBody.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="KinematicBody" inherits="PhysicsBody" category="Core" version="3.0.alpha.custom_build"> +<class name="KinematicBody" inherits="PhysicsBody" category="Core" version="3.0-alpha"> <brief_description> Kinematic body 3D node. </brief_description> @@ -32,7 +32,7 @@ <argument index="0" name="slide_idx" type="int"> </argument> <description> - Returns a [KinematicCollision], which contains information about a collision that occured during the last [method move_and_slide] call. Since the body can collide several times in a single call to [method move_and_slide], you must specify the index of the collision in the range 0 to ([method get_slide_count]()-1). + Returns a [KinematicCollision], which contains information about a collision that occured during the last [method move_and_slide] call. Since the body can collide several times in a single call to [method move_and_slide], you must specify the index of the collision in the range 0 to ([method get_slide_count] - 1). </description> </method> <method name="get_slide_count" qualifiers="const"> diff --git a/doc/classes/KinematicBody2D.xml b/doc/classes/KinematicBody2D.xml index 798fc4153c..7285c780e5 100644 --- a/doc/classes/KinematicBody2D.xml +++ b/doc/classes/KinematicBody2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="KinematicBody2D" inherits="PhysicsBody2D" category="Core" version="3.0.alpha.custom_build"> +<class name="KinematicBody2D" inherits="PhysicsBody2D" category="Core" version="3.0-alpha"> <brief_description> Kinematic body 2D node. </brief_description> @@ -32,7 +32,7 @@ <argument index="0" name="slide_idx" type="int"> </argument> <description> - Returns a [KinematicCollision2D], which contains information about a collision that occured during the last [method move_and_slide] call. Since the body can collide several times in a single call to [method move_and_slide], you must specify the index of the collision in the range 0 to ([method get_slide_count]()-1). + Returns a [KinematicCollision2D], which contains information about a collision that occured during the last [method move_and_slide] call. Since the body can collide several times in a single call to [method move_and_slide], you must specify the index of the collision in the range 0 to ([method get_slide_count] - 1). </description> </method> <method name="get_slide_count" qualifiers="const"> diff --git a/doc/classes/KinematicCollision.xml b/doc/classes/KinematicCollision.xml index b7269a646e..ce82004839 100644 --- a/doc/classes/KinematicCollision.xml +++ b/doc/classes/KinematicCollision.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="KinematicCollision" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="KinematicCollision" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Collision data for KinematicBody2D collisions. </brief_description> diff --git a/doc/classes/KinematicCollision2D.xml b/doc/classes/KinematicCollision2D.xml index 7a40a39292..e498dea7a5 100644 --- a/doc/classes/KinematicCollision2D.xml +++ b/doc/classes/KinematicCollision2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="KinematicCollision2D" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="KinematicCollision2D" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Collision data for KinematicBody2D collisions. </brief_description> diff --git a/doc/classes/Label.xml b/doc/classes/Label.xml index 1d1ce63a58..93d7b20491 100644 --- a/doc/classes/Label.xml +++ b/doc/classes/Label.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Label" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="Label" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Displays plain text in a line or wrapped inside a rectangle. For formatted text, use [RichTextLabel]. </brief_description> diff --git a/doc/classes/LargeTexture.xml b/doc/classes/LargeTexture.xml index f5416488f6..6ec3c80bca 100644 --- a/doc/classes/LargeTexture.xml +++ b/doc/classes/LargeTexture.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="LargeTexture" inherits="Texture" category="Core" version="3.0.alpha.custom_build"> +<class name="LargeTexture" inherits="Texture" category="Core" version="3.0-alpha"> <brief_description> A Texture capable of storing many smaller Textures with offsets. </brief_description> diff --git a/doc/classes/Light.xml b/doc/classes/Light.xml index fd3ecc7365..1c625d59e1 100644 --- a/doc/classes/Light.xml +++ b/doc/classes/Light.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Light" inherits="VisualInstance" category="Core" version="3.0.alpha.custom_build"> +<class name="Light" inherits="VisualInstance" category="Core" version="3.0-alpha"> <brief_description> Provides a base class for different kinds of light nodes. </brief_description> diff --git a/doc/classes/Light2D.xml b/doc/classes/Light2D.xml index 05054e06fd..285d302ba7 100644 --- a/doc/classes/Light2D.xml +++ b/doc/classes/Light2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Light2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="Light2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Casts light in a 2D environment. </brief_description> diff --git a/doc/classes/LightOccluder2D.xml b/doc/classes/LightOccluder2D.xml index babcf31c08..9a1b84158b 100644 --- a/doc/classes/LightOccluder2D.xml +++ b/doc/classes/LightOccluder2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="LightOccluder2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="LightOccluder2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Occludes light cast by a Light2D, casting shadows. </brief_description> diff --git a/doc/classes/Line2D.xml b/doc/classes/Line2D.xml index 3cca256a5d..7b76d94c95 100644 --- a/doc/classes/Line2D.xml +++ b/doc/classes/Line2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Line2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="Line2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> A 2D line. </brief_description> @@ -63,7 +63,7 @@ <argument index="0" name="i" type="int"> </argument> <description> - Returns point [code]i[code]'s position. + Returns point [code]i[/code]'s position. </description> </method> <method name="get_points" qualifiers="const"> diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index 850f724714..432f583566 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="LineEdit" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="LineEdit" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Control that provides single line string editing. </brief_description> @@ -114,6 +114,13 @@ Return the text in the [code]LineEdit[/code]. </description> </method> + <method name="is_context_menu_enabled"> + <return type="bool"> + </return> + <description> + Returns true if the context menu is enabled. + </description> + </method> <method name="is_editable" qualifiers="const"> <return type="bool"> </return> @@ -170,6 +177,15 @@ Set text alignment of the [code]LineEdit[/code]. </description> </method> + <method name="set_context_menu_enabled"> + <return type="void"> + </return> + <argument index="0" name="enable" type="bool"> + </argument> + <description> + Set the status of the context menu. When enabled, the context menu will appear when the [code]LineEdit[/code] is right clicked. + </description> + </method> <method name="set_cursor_position"> <return type="void"> </return> @@ -252,6 +268,9 @@ <member name="caret_blink_speed" type="float" setter="cursor_set_blink_speed" getter="cursor_get_blink_speed"> Duration (in seconds) of a caret's blinking cycle. </member> + <member name="context_menu_enabled" type="bool" setter="set_context_menu_enabled" getter="is_context_menu_enabled"> + If [code]true[/code] the context menu will appear when right clicked. + </member> <member name="editable" type="bool" setter="set_editable" getter="is_editable"> If [code]false[/code] existing text cannot be modified and new text cannot be added. </member> @@ -324,7 +343,9 @@ <constant name="MENU_UNDO" value="5"> Undoes the previous action. </constant> - <constant name="MENU_MAX" value="6"> + <constant name="MENU_REDO" value="6"> + </constant> + <constant name="MENU_MAX" value="7"> </constant> </constants> <theme_items> diff --git a/doc/classes/LineShape2D.xml b/doc/classes/LineShape2D.xml index 5596c48162..6ae6fad6f4 100644 --- a/doc/classes/LineShape2D.xml +++ b/doc/classes/LineShape2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="LineShape2D" inherits="Shape2D" category="Core" version="3.0.alpha.custom_build"> +<class name="LineShape2D" inherits="Shape2D" category="Core" version="3.0-alpha"> <brief_description> Line shape for 2D collisions. </brief_description> diff --git a/doc/classes/LinkButton.xml b/doc/classes/LinkButton.xml index 5e7f467684..d13a0d7be6 100644 --- a/doc/classes/LinkButton.xml +++ b/doc/classes/LinkButton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="LinkButton" inherits="BaseButton" category="Core" version="3.0.alpha.custom_build"> +<class name="LinkButton" inherits="BaseButton" category="Core" version="3.0-alpha"> <brief_description> Simple button used to represent a link to some resource </brief_description> diff --git a/doc/classes/Listener.xml b/doc/classes/Listener.xml index 176369cccb..742198acd0 100644 --- a/doc/classes/Listener.xml +++ b/doc/classes/Listener.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Listener" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="Listener" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/MainLoop.xml b/doc/classes/MainLoop.xml index f8343467af..048b13a7ca 100644 --- a/doc/classes/MainLoop.xml +++ b/doc/classes/MainLoop.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="MainLoop" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="MainLoop" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Main loop is the abstract main loop base class. </brief_description> diff --git a/doc/classes/MarginContainer.xml b/doc/classes/MarginContainer.xml index d4b9b01f63..1c748de229 100644 --- a/doc/classes/MarginContainer.xml +++ b/doc/classes/MarginContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="MarginContainer" inherits="Container" category="Core" version="3.0.alpha.custom_build"> +<class name="MarginContainer" inherits="Container" category="Core" version="3.0-alpha"> <brief_description> Simple margin container. </brief_description> diff --git a/doc/classes/Marshalls.xml b/doc/classes/Marshalls.xml index b443d03108..0e561ab374 100644 --- a/doc/classes/Marshalls.xml +++ b/doc/classes/Marshalls.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Marshalls" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="Marshalls" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Data transformation (marshalling) and encoding helpers. </brief_description> diff --git a/doc/classes/Material.xml b/doc/classes/Material.xml index 88b35ac6b5..87c2e51003 100644 --- a/doc/classes/Material.xml +++ b/doc/classes/Material.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Material" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Material" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Abstract base [Resource] for coloring and shading geometry. </brief_description> diff --git a/doc/classes/MenuButton.xml b/doc/classes/MenuButton.xml index f1ab74d00e..54be44d3d8 100644 --- a/doc/classes/MenuButton.xml +++ b/doc/classes/MenuButton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="MenuButton" inherits="Button" category="Core" version="3.0.alpha.custom_build"> +<class name="MenuButton" inherits="Button" category="Core" version="3.0-alpha"> <brief_description> Special button that brings up a [PopupMenu] when clicked. </brief_description> diff --git a/doc/classes/Mesh.xml b/doc/classes/Mesh.xml index 658265d242..733f76728c 100644 --- a/doc/classes/Mesh.xml +++ b/doc/classes/Mesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Mesh" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Mesh" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> A [Resource] that contains vertex-array based geometry. </brief_description> diff --git a/doc/classes/MeshDataTool.xml b/doc/classes/MeshDataTool.xml index 6088d30013..f433d7a753 100644 --- a/doc/classes/MeshDataTool.xml +++ b/doc/classes/MeshDataTool.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="MeshDataTool" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="MeshDataTool" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/MeshInstance.xml b/doc/classes/MeshInstance.xml index 56b446cac1..5bd6bedf7e 100644 --- a/doc/classes/MeshInstance.xml +++ b/doc/classes/MeshInstance.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="MeshInstance" inherits="GeometryInstance" category="Core" version="3.0.alpha.custom_build"> +<class name="MeshInstance" inherits="GeometryInstance" category="Core" version="3.0-alpha"> <brief_description> Node that instances meshes into a scenario. </brief_description> diff --git a/doc/classes/MeshLibrary.xml b/doc/classes/MeshLibrary.xml index 5636db23b5..54a8228d02 100644 --- a/doc/classes/MeshLibrary.xml +++ b/doc/classes/MeshLibrary.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="MeshLibrary" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="MeshLibrary" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Library of meshes. </brief_description> diff --git a/doc/classes/MultiMesh.xml b/doc/classes/MultiMesh.xml index 6df9689ada..b6a89d09f4 100644 --- a/doc/classes/MultiMesh.xml +++ b/doc/classes/MultiMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="MultiMesh" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="MultiMesh" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Provides high performance mesh instancing. </brief_description> @@ -7,7 +7,7 @@ MultiMesh provides low level mesh instancing. If the amount of [Mesh] instances needed goes from hundreds to thousands (and most need to be visible at close proximity) creating such a large amount of [MeshInstance] nodes may affect performance by using too much CPU or video memory. For this case a MultiMesh becomes very useful, as it can draw thousands of instances with little API overhead. As a drawback, if the instances are too far away of each other, performance may be reduced as every single instance will always rendered (they are spatially indexed as one, for the whole object). - Since instances may have any behavior, the Rect3 used for visibility must be provided by the user. + Since instances may have any behavior, the AABB used for visibility must be provided by the user. </description> <tutorials> </tutorials> @@ -15,10 +15,10 @@ </demos> <methods> <method name="get_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> - Return the visibility Rect3. + Return the visibility AABB. </description> </method> <method name="get_color_format" qualifiers="const"> diff --git a/doc/classes/MultiMeshInstance.xml b/doc/classes/MultiMeshInstance.xml index 06454e3cdc..11e22c2581 100644 --- a/doc/classes/MultiMeshInstance.xml +++ b/doc/classes/MultiMeshInstance.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="MultiMeshInstance" inherits="GeometryInstance" category="Core" version="3.0.alpha.custom_build"> +<class name="MultiMeshInstance" inherits="GeometryInstance" category="Core" version="3.0-alpha"> <brief_description> Node that instances a [MultiMesh]. </brief_description> diff --git a/doc/classes/Mutex.xml b/doc/classes/Mutex.xml index 3d0c8eb1df..d36dbb64c1 100644 --- a/doc/classes/Mutex.xml +++ b/doc/classes/Mutex.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Mutex" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="Mutex" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> A synchronization Mutex. </brief_description> diff --git a/doc/classes/Navigation.xml b/doc/classes/Navigation.xml index 3e063f6a82..c83e81b197 100644 --- a/doc/classes/Navigation.xml +++ b/doc/classes/Navigation.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Navigation" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="Navigation" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Navigation2D.xml b/doc/classes/Navigation2D.xml index ab10463a5d..ac2e0d88d8 100644 --- a/doc/classes/Navigation2D.xml +++ b/doc/classes/Navigation2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Navigation2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="Navigation2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/NavigationMesh.xml b/doc/classes/NavigationMesh.xml index 788fadfd77..dd49b0a593 100644 --- a/doc/classes/NavigationMesh.xml +++ b/doc/classes/NavigationMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NavigationMesh" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="NavigationMesh" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/NavigationMeshInstance.xml b/doc/classes/NavigationMeshInstance.xml index 6d3a81a939..1e8998009e 100644 --- a/doc/classes/NavigationMeshInstance.xml +++ b/doc/classes/NavigationMeshInstance.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NavigationMeshInstance" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="NavigationMeshInstance" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/NavigationPolygon.xml b/doc/classes/NavigationPolygon.xml index 07eb4afb8d..fd7238114e 100644 --- a/doc/classes/NavigationPolygon.xml +++ b/doc/classes/NavigationPolygon.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NavigationPolygon" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="NavigationPolygon" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/NavigationPolygonInstance.xml b/doc/classes/NavigationPolygonInstance.xml index a6d70d5b4b..ac56b03002 100644 --- a/doc/classes/NavigationPolygonInstance.xml +++ b/doc/classes/NavigationPolygonInstance.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NavigationPolygonInstance" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="NavigationPolygonInstance" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/NetworkedMultiplayerPeer.xml b/doc/classes/NetworkedMultiplayerPeer.xml index 3ac3895df2..4333c3d28a 100644 --- a/doc/classes/NetworkedMultiplayerPeer.xml +++ b/doc/classes/NetworkedMultiplayerPeer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NetworkedMultiplayerPeer" inherits="PacketPeer" category="Core" version="3.0.alpha.custom_build"> +<class name="NetworkedMultiplayerPeer" inherits="PacketPeer" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Nil.xml b/doc/classes/Nil.xml index de12ad1261..a4bd60d53e 100644 --- a/doc/classes/Nil.xml +++ b/doc/classes/Nil.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Nil" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Nil" category="Built-In Types" version="3.0-alpha"> <brief_description> </brief_description> <description> @@ -100,7 +100,7 @@ </description> </method> <method name="Nil"> - <argument index="0" name="from" type="Rect3"> + <argument index="0" name="from" type="AABB"> </argument> <description> </description> diff --git a/doc/classes/NinePatchRect.xml b/doc/classes/NinePatchRect.xml index c74f3c5a68..2c8bce52a0 100644 --- a/doc/classes/NinePatchRect.xml +++ b/doc/classes/NinePatchRect.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NinePatchRect" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="NinePatchRect" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Scalable texture-based frame that tiles the texture's centers and sides, but keeps the corners' original size. Perfect for panels and dialog boxes. </brief_description> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 7ec4bbb8b5..a103d0eba0 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Node" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="Node" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Base class for all the [i]scene[/i] elements. </brief_description> diff --git a/doc/classes/Node2D.xml b/doc/classes/Node2D.xml index 669a0fb9ff..195dd9265f 100644 --- a/doc/classes/Node2D.xml +++ b/doc/classes/Node2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Node2D" inherits="CanvasItem" category="Core" version="3.0.alpha.custom_build"> +<class name="Node2D" inherits="CanvasItem" category="Core" version="3.0-alpha"> <brief_description> A 2D game object, parent of all 2D related nodes. Has a position, rotation, scale and Z-index. </brief_description> @@ -52,7 +52,7 @@ Returns the node's global rotation in radians. </description> </method> - <method name="get_global_rotation_in_degrees" qualifiers="const"> + <method name="get_global_rotation_degrees" qualifiers="const"> <return type="float"> </return> <description> @@ -89,7 +89,7 @@ Returns the node's rotation in radians. </description> </method> - <method name="get_rotation_in_degrees" qualifiers="const"> + <method name="get_rotation_degrees" qualifiers="const"> <return type="float"> </return> <description> @@ -184,7 +184,7 @@ Sets the node's global rotation in radians. </description> </method> - <method name="set_global_rotation_in_degrees"> + <method name="set_global_rotation_degrees"> <return type="void"> </return> <argument index="0" name="degrees" type="float"> @@ -229,7 +229,7 @@ Sets the node's rotation in radians. </description> </method> - <method name="set_rotation_in_degrees"> + <method name="set_rotation_degrees"> <return type="void"> </return> <argument index="0" name="degrees" type="float"> @@ -309,7 +309,7 @@ <member name="global_rotation" type="float" setter="set_global_rotation" getter="get_global_rotation"> Global rotation in radians. </member> - <member name="global_rotation_deg" type="float" setter="set_global_rotation_in_degrees" getter="get_global_rotation_in_degrees"> + <member name="global_rotation_degrees" type="float" setter="set_global_rotation_degrees" getter="get_global_rotation_degrees"> Global rotation in degrees. </member> <member name="global_scale" type="Vector2" setter="set_global_scale" getter="get_global_scale"> @@ -324,7 +324,7 @@ <member name="rotation" type="float" setter="set_rotation" getter="get_rotation"> Rotation in radians, relative to the node's parent. </member> - <member name="rotation_deg" type="float" setter="set_rotation_in_degrees" getter="get_rotation_in_degrees"> + <member name="rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees"> Rotation in degrees, relative to the node's parent. </member> <member name="scale" type="Vector2" setter="set_scale" getter="get_scale"> diff --git a/doc/classes/NodePath.xml b/doc/classes/NodePath.xml index ba2145482f..c706864379 100644 --- a/doc/classes/NodePath.xml +++ b/doc/classes/NodePath.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NodePath" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="NodePath" category="Built-In Types" version="3.0-alpha"> <brief_description> Pre-parsed scene tree path. </brief_description> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 2629e6740d..8f82040eca 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="OS" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="OS" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Operating System functions. </brief_description> @@ -127,11 +127,11 @@ Returns the current screen index (0 padded). </description> </method> - <method name="get_data_dir" qualifiers="const"> + <method name="get_user_data_dir" qualifiers="const"> <return type="String"> </return> <description> - Returns the absolute directory path of user data path([user://]). + Returns the absolute directory path where user data is written ([code]user://[/code]). </description> </method> <method name="get_date" qualifiers="const"> @@ -376,7 +376,7 @@ <return type="String"> </return> <description> - Returns a unique string. + Returns a string that is unique to the device. Currently only works on Android and iOS. Returns empty string on other platforms. </description> </method> <method name="get_unix_time" qualifiers="const"> diff --git a/doc/classes/Object.xml b/doc/classes/Object.xml index d30ebfaef8..bea4c14a3c 100644 --- a/doc/classes/Object.xml +++ b/doc/classes/Object.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="Object" category="Core" version="3.0-alpha"> <brief_description> Base class for all non built-in types. </brief_description> @@ -21,20 +21,21 @@ <argument index="0" name="property" type="String"> </argument> <description> - Return a property, return null if the property does not exist. + Returns the given property. Returns [code]null[/code] if the [code]property[/code] does not exist. </description> </method> <method name="_get_property_list" qualifiers="virtual"> <return type="Array"> </return> <description> - Return the property list, array of dictionaries, dictionaries must contain: name:String, type:int (see TYPE_* enum in [@Global Scope]) and optionally: hint:int (see PROPERTY_HINT_* in [@Global Scope]), hint_string:String, usage:int (see PROPERTY_USAGE_* in [@Global Scope]). + Returns the object's property list as an [Array] of dictionaries. Dictionaries must contain: name:String, type:int (see TYPE_* enum in [@GlobalScope]) and optionally: hint:int (see PROPERTY_HINT_* in [@GlobalScope]), hint_string:String, usage:int (see PROPERTY_USAGE_* in [@GlobalScope]). </description> </method> <method name="_init" qualifiers="virtual"> <return type="void"> </return> <description> + The virtual method called upon initialization. </description> </method> <method name="_notification" qualifiers="virtual"> @@ -43,7 +44,7 @@ <argument index="0" name="what" type="int"> </argument> <description> - Notification request, the notification id is received. + Notify the object internally using an ID. </description> </method> <method name="_set" qualifiers="virtual"> @@ -54,7 +55,7 @@ <argument index="1" name="value" type="Variant"> </argument> <description> - Set a property. Return true if the property was found. + Sets a property. Returns [code]true[/code] if the [code]property[/code] exists. </description> </method> <method name="add_user_signal"> @@ -65,7 +66,7 @@ <argument index="1" name="arguments" type="Array" default="[ ]"> </argument> <description> - Add a user signal (can be added anytime). Arguments are optional, but can be added as an array of dictionaries, each containing "name" and "type" (from [@Global Scope] TYPE_*). + Adds a user-defined [code]signal[/code]. Arguments are optional, but can be added as an [Array] of dictionaries, each containing "name" and "type" (from [@GlobalScope] TYPE_*). </description> </method> <method name="call" qualifiers="vararg"> @@ -74,6 +75,7 @@ <argument index="0" name="method" type="String"> </argument> <description> + Calls the [code]method[/code] on the object and returns a result. Pass parameters as a comma separated list. </description> </method> <method name="call_deferred" qualifiers="vararg"> @@ -82,6 +84,7 @@ <argument index="0" name="method" type="String"> </argument> <description> + Calls the [code]method[/code] on the object during idle time and returns a result. Pass parameters as a comma separated list. </description> </method> <method name="callv"> @@ -92,13 +95,14 @@ <argument index="1" name="arg_array" type="Array"> </argument> <description> + Calls the [code]method[/code] on the object and returns a result. Pass parameters as an [Array]. </description> </method> <method name="can_translate_messages" qualifiers="const"> <return type="bool"> </return> <description> - Return true if this object can translate strings. + Returns [code]true[/code] if the object can translate strings. </description> </method> <method name="connect"> @@ -115,7 +119,7 @@ <argument index="4" name="flags" type="int" default="0"> </argument> <description> - Connect a signal to a method at a target (member function). Binds are optional and are passed as extra arguments to the call. Flags specify optional deferred or one shot connections, see enum CONNECT_*. A signal can only be connected once to a method, and it will throw an error if already connected. If you want to avoid this, use [method is_connected] to check. + Connects a [code]signal[/code] to a [code]method[/code] on a [code]target[/code] object. Pass optional [code]binds[/code] to the call. Use [code]flags[/code] to set deferred or one shot connections. See [code]CONNECT_*[/code] constants. A [code]signal[/code] can only be connected once to a [code]method[/code]. It will throw an error if already connected. To avoid this, first use [method is_connected] to check for existing connections. </description> </method> <method name="disconnect"> @@ -128,7 +132,7 @@ <argument index="2" name="method" type="String"> </argument> <description> - Disconnect a signal from a method. + Disconnects a [code]signal[/code] from a [code]method[/code] on the given [code]target[/code]. </description> </method> <method name="emit_signal" qualifiers="vararg"> @@ -137,12 +141,14 @@ <argument index="0" name="signal" type="String"> </argument> <description> + Emits the given [code]signal[/code]. </description> </method> <method name="free"> <return type="void"> </return> <description> + Deletes the object from memory. </description> </method> <method name="get" qualifiers="const"> @@ -151,21 +157,21 @@ <argument index="0" name="property" type="String"> </argument> <description> - Get a property from the object. + Returns a [Variant] for a [code]property[/code]. </description> </method> <method name="get_class" qualifiers="const"> <return type="String"> </return> <description> - Return the class of the object as a string. + Returns the object's class as a [String]. </description> </method> <method name="get_incoming_connections" qualifiers="const"> <return type="Array"> </return> <description> - Returns an [Array] of dictionaries with information about signals that are connected to this object. + Returns an [Array] of dictionaries with information about signals that are connected to the object. Inside each [Dictionary] there are 3 fields: - "source" is a reference to signal emitter. - "signal_name" is name of connected signal. @@ -176,7 +182,7 @@ <return type="int"> </return> <description> - Return the instance ID. All objects have a unique instance ID. + Returns the object's unique instance ID. </description> </method> <method name="get_meta" qualifiers="const"> @@ -185,34 +191,35 @@ <argument index="0" name="name" type="String"> </argument> <description> - Return a metadata from the object. + Returns the object's metadata for the given [code]name[/code]. </description> </method> <method name="get_meta_list" qualifiers="const"> <return type="PoolStringArray"> </return> <description> - Return the list of metadata in the object. + Returns the object's metadata as a [PoolStringArray]. </description> </method> <method name="get_method_list" qualifiers="const"> <return type="Array"> </return> <description> + Returns the object's methods and their signatures as an [Array]. </description> </method> <method name="get_property_list" qualifiers="const"> <return type="Array"> </return> <description> - Return the list of properties as an array of dictionaries, dictionaries contain: name:String, type:int (see TYPE_* enum in [@Global Scope]) and optionally: hint:int (see PROPERTY_HINT_* in [@Global Scope]), hint_string:String, usage:int (see PROPERTY_USAGE_* in [@Global Scope]). + Returns the list of properties as an [Array] of dictionaries. Dictionaries contain: name:String, type:int (see TYPE_* enum in [@GlobalScope]) and optionally: hint:int (see PROPERTY_HINT_* in [@GlobalScope]), hint_string:String, usage:int (see PROPERTY_USAGE_* in [@GlobalScope]). </description> </method> <method name="get_script" qualifiers="const"> <return type="Reference"> </return> <description> - Return the object script (or null if it doesn't have one). + Returns the object's [Script] or [code]null[/code] if one doesn't exist. </description> </method> <method name="get_signal_connection_list" qualifiers="const"> @@ -221,13 +228,14 @@ <argument index="0" name="signal" type="String"> </argument> <description> + Returns an [Array] of connections for the given [code]signal[/code]. </description> </method> <method name="get_signal_list" qualifiers="const"> <return type="Array"> </return> <description> - Return the list of signals as an array of dictionaries. + Returns the list of signals as an [Array] of dictionaries. </description> </method> <method name="has_meta" qualifiers="const"> @@ -236,7 +244,7 @@ <argument index="0" name="name" type="String"> </argument> <description> - Return true if a metadata is found with the requested name. + Returns [code]true[/code] if a metadata is found with the given [code]name[/code]. </description> </method> <method name="has_method" qualifiers="const"> @@ -245,6 +253,7 @@ <argument index="0" name="method" type="String"> </argument> <description> + Returns [code]true[/code] if the object contains the given [code]method[/code]. </description> </method> <method name="has_user_signal" qualifiers="const"> @@ -253,13 +262,14 @@ <argument index="0" name="signal" type="String"> </argument> <description> + Returns [code]true[/code] if the given user-defined [code]signal[/code] exists. </description> </method> <method name="is_blocking_signals" qualifiers="const"> <return type="bool"> </return> <description> - Return true if signal emission blocking is enabled. + Returns [code]true[/code] if signal emission blocking is enabled. </description> </method> <method name="is_class" qualifiers="const"> @@ -268,7 +278,7 @@ <argument index="0" name="type" type="String"> </argument> <description> - Check the class of the object against a string (including inheritance). + Returns [code]true[/code] if the object inherits from the given [code]type[/code]. </description> </method> <method name="is_connected" qualifiers="const"> @@ -281,13 +291,14 @@ <argument index="2" name="method" type="String"> </argument> <description> - Return true if a connection exists for a given signal and target/method. + Returns [code]true[/code] if a connection exists for a given [code]signal[/code], [code]target[/code], and [code]method[/code]. </description> </method> <method name="is_queued_for_deletion" qualifiers="const"> <return type="bool"> </return> <description> + Returns [code]true[/code] if the [code]queue_free[/code] method was called for the object. </description> </method> <method name="notification"> @@ -333,7 +344,7 @@ <argument index="0" name="enable" type="bool"> </argument> <description> - Define whether this object can translate strings (with calls to [method tr]). Default is true. + Define whether the object can translate strings (with calls to [method tr]). Default is true. </description> </method> <method name="set_meta"> diff --git a/doc/classes/OccluderPolygon2D.xml b/doc/classes/OccluderPolygon2D.xml index 7bc1f74762..e86aa999ad 100644 --- a/doc/classes/OccluderPolygon2D.xml +++ b/doc/classes/OccluderPolygon2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="OccluderPolygon2D" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="OccluderPolygon2D" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Defines a 2D polygon for LightOccluder2D. </brief_description> diff --git a/doc/classes/OmniLight.xml b/doc/classes/OmniLight.xml index cb8e756a4c..7c8b1d4756 100644 --- a/doc/classes/OmniLight.xml +++ b/doc/classes/OmniLight.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="OmniLight" inherits="Light" category="Core" version="3.0.alpha.custom_build"> +<class name="OmniLight" inherits="Light" category="Core" version="3.0-alpha"> <brief_description> OmniDirectional Light, such as a light bulb or a candle. </brief_description> diff --git a/doc/classes/OptionButton.xml b/doc/classes/OptionButton.xml index 08ea23f05a..e08b5cac16 100644 --- a/doc/classes/OptionButton.xml +++ b/doc/classes/OptionButton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="OptionButton" inherits="Button" category="Core" version="3.0.alpha.custom_build"> +<class name="OptionButton" inherits="Button" category="Core" version="3.0-alpha"> <brief_description> Button control that provides selectable options when pressed. </brief_description> diff --git a/doc/classes/PCKPacker.xml b/doc/classes/PCKPacker.xml index cf8efdf6be..4677c15b7b 100644 --- a/doc/classes/PCKPacker.xml +++ b/doc/classes/PCKPacker.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PCKPacker" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="PCKPacker" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PHashTranslation.xml b/doc/classes/PHashTranslation.xml index b25ddcbf22..c74cc8793f 100644 --- a/doc/classes/PHashTranslation.xml +++ b/doc/classes/PHashTranslation.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PHashTranslation" inherits="Translation" category="Core" version="3.0.alpha.custom_build"> +<class name="PHashTranslation" inherits="Translation" category="Core" version="3.0-alpha"> <brief_description> Optimized translation. </brief_description> diff --git a/doc/classes/PackedDataContainer.xml b/doc/classes/PackedDataContainer.xml index 660a39f210..6e660b983a 100644 --- a/doc/classes/PackedDataContainer.xml +++ b/doc/classes/PackedDataContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PackedDataContainer" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="PackedDataContainer" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PackedDataContainerRef.xml b/doc/classes/PackedDataContainerRef.xml index 413cd4468b..9d44307afe 100644 --- a/doc/classes/PackedDataContainerRef.xml +++ b/doc/classes/PackedDataContainerRef.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PackedDataContainerRef" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="PackedDataContainerRef" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PackedScene.xml b/doc/classes/PackedScene.xml index b40207229c..a226a2bc28 100644 --- a/doc/classes/PackedScene.xml +++ b/doc/classes/PackedScene.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PackedScene" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="PackedScene" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PacketPeer.xml b/doc/classes/PacketPeer.xml index bc15e5fc0c..b99d5dc5e9 100644 --- a/doc/classes/PacketPeer.xml +++ b/doc/classes/PacketPeer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PacketPeer" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="PacketPeer" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Abstraction and base class for packet-based protocols. </brief_description> diff --git a/doc/classes/PacketPeerStream.xml b/doc/classes/PacketPeerStream.xml index 531046a4ba..38e2d9c1a1 100644 --- a/doc/classes/PacketPeerStream.xml +++ b/doc/classes/PacketPeerStream.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PacketPeerStream" inherits="PacketPeer" category="Core" version="3.0.alpha.custom_build"> +<class name="PacketPeerStream" inherits="PacketPeer" category="Core" version="3.0-alpha"> <brief_description> Wrapper to use a PacketPeer over a StreamPeer. </brief_description> diff --git a/doc/classes/PacketPeerUDP.xml b/doc/classes/PacketPeerUDP.xml index 1d2241b580..758ad35365 100644 --- a/doc/classes/PacketPeerUDP.xml +++ b/doc/classes/PacketPeerUDP.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PacketPeerUDP" inherits="PacketPeer" category="Core" version="3.0.alpha.custom_build"> +<class name="PacketPeerUDP" inherits="PacketPeer" category="Core" version="3.0-alpha"> <brief_description> UDP packet peer. </brief_description> diff --git a/doc/classes/Panel.xml b/doc/classes/Panel.xml index 8a57659c0c..28a1e304aa 100644 --- a/doc/classes/Panel.xml +++ b/doc/classes/Panel.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Panel" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="Panel" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Provides an opaque background for [Control] children. </brief_description> diff --git a/doc/classes/PanelContainer.xml b/doc/classes/PanelContainer.xml index 29d5169b9e..415d71c8e7 100644 --- a/doc/classes/PanelContainer.xml +++ b/doc/classes/PanelContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PanelContainer" inherits="Container" category="Core" version="3.0.alpha.custom_build"> +<class name="PanelContainer" inherits="Container" category="Core" version="3.0-alpha"> <brief_description> Panel container type. </brief_description> diff --git a/doc/classes/PanoramaSky.xml b/doc/classes/PanoramaSky.xml index 81f358461e..7f24bb294b 100644 --- a/doc/classes/PanoramaSky.xml +++ b/doc/classes/PanoramaSky.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PanoramaSky" inherits="Sky" category="Core" version="3.0.alpha.custom_build"> +<class name="PanoramaSky" inherits="Sky" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/ParallaxBackground.xml b/doc/classes/ParallaxBackground.xml index 21b6150900..3186f6b972 100644 --- a/doc/classes/ParallaxBackground.xml +++ b/doc/classes/ParallaxBackground.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ParallaxBackground" inherits="CanvasLayer" category="Core" version="3.0.alpha.custom_build"> +<class name="ParallaxBackground" inherits="CanvasLayer" category="Core" version="3.0-alpha"> <brief_description> A node used to create a parallax scrolling background. </brief_description> diff --git a/doc/classes/ParallaxLayer.xml b/doc/classes/ParallaxLayer.xml index f1e6f9e046..784395b1ec 100644 --- a/doc/classes/ParallaxLayer.xml +++ b/doc/classes/ParallaxLayer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ParallaxLayer" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="ParallaxLayer" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> A parallax scrolling layer to be used with [ParallaxBackground]. </brief_description> diff --git a/doc/classes/Particles.xml b/doc/classes/Particles.xml index 1e89d2194c..9a9279b0a7 100644 --- a/doc/classes/Particles.xml +++ b/doc/classes/Particles.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Particles" inherits="GeometryInstance" category="Core" version="3.0.alpha.custom_build"> +<class name="Particles" inherits="GeometryInstance" category="Core" version="3.0-alpha"> <brief_description> 3D particle emitter. </brief_description> @@ -13,7 +13,7 @@ </demos> <methods> <method name="capture_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> @@ -105,7 +105,7 @@ </description> </method> <method name="get_visibility_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> @@ -247,7 +247,7 @@ <method name="set_visibility_aabb"> <return type="void"> </return> - <argument index="0" name="aabb" type="Rect3"> + <argument index="0" name="aabb" type="AABB"> </argument> <description> </description> @@ -300,7 +300,7 @@ <member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale"> Speed scaling ratio. Default value: [code]1[/code]. </member> - <member name="visibility_aabb" type="Rect3" setter="set_visibility_aabb" getter="get_visibility_aabb"> + <member name="visibility_aabb" type="AABB" setter="set_visibility_aabb" getter="get_visibility_aabb"> </member> </members> <constants> diff --git a/doc/classes/Particles2D.xml b/doc/classes/Particles2D.xml index cfc907b727..be69e03d56 100644 --- a/doc/classes/Particles2D.xml +++ b/doc/classes/Particles2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Particles2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="Particles2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> 2D particle emitter. </brief_description> diff --git a/doc/classes/ParticlesMaterial.xml b/doc/classes/ParticlesMaterial.xml index bebdc44b69..2428d1880d 100644 --- a/doc/classes/ParticlesMaterial.xml +++ b/doc/classes/ParticlesMaterial.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ParticlesMaterial" inherits="Material" category="Core" version="3.0.alpha.custom_build"> +<class name="ParticlesMaterial" inherits="Material" category="Core" version="3.0-alpha"> <brief_description> Particle properties for [Particles] and [Particles2D] nodes. </brief_description> diff --git a/doc/classes/Path.xml b/doc/classes/Path.xml index 97543418b9..8138a92dcc 100644 --- a/doc/classes/Path.xml +++ b/doc/classes/Path.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Path" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="Path" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Container for a [Curve3D]. </brief_description> diff --git a/doc/classes/Path2D.xml b/doc/classes/Path2D.xml index 722e0c1240..8172fc2c4b 100644 --- a/doc/classes/Path2D.xml +++ b/doc/classes/Path2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Path2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="Path2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Contains a [Curve2D] path for [PathFollow2D] nodes to follow. </brief_description> diff --git a/doc/classes/PathFollow.xml b/doc/classes/PathFollow.xml index 86f55a2aaf..bdf2a082e0 100644 --- a/doc/classes/PathFollow.xml +++ b/doc/classes/PathFollow.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PathFollow" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="PathFollow" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Point sampler for a [Path]. </brief_description> diff --git a/doc/classes/PathFollow2D.xml b/doc/classes/PathFollow2D.xml index 850b81c046..01137d01d0 100644 --- a/doc/classes/PathFollow2D.xml +++ b/doc/classes/PathFollow2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PathFollow2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="PathFollow2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Point sampler for a [Path2D]. </brief_description> diff --git a/doc/classes/Performance.xml b/doc/classes/Performance.xml index 82ee3531f1..daf1bd62ed 100644 --- a/doc/classes/Performance.xml +++ b/doc/classes/Performance.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Performance" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="Performance" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Exposes performance related data. </brief_description> diff --git a/doc/classes/Physics2DDirectBodyState.xml b/doc/classes/Physics2DDirectBodyState.xml index cc68aaab1f..40666d8330 100644 --- a/doc/classes/Physics2DDirectBodyState.xml +++ b/doc/classes/Physics2DDirectBodyState.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DDirectBodyState" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="Physics2DDirectBodyState" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Direct access object to a physics body in the [Physics2DServer]. </brief_description> diff --git a/doc/classes/Physics2DDirectBodyStateSW.xml b/doc/classes/Physics2DDirectBodyStateSW.xml index c2444d4795..865fb6a347 100644 --- a/doc/classes/Physics2DDirectBodyStateSW.xml +++ b/doc/classes/Physics2DDirectBodyStateSW.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DDirectBodyStateSW" inherits="Physics2DDirectBodyState" category="Core" version="3.0.alpha.custom_build"> +<class name="Physics2DDirectBodyStateSW" inherits="Physics2DDirectBodyState" category="Core" version="3.0-alpha"> <brief_description> Software implementation of [Physics2DDirectBodyState]. </brief_description> diff --git a/doc/classes/Physics2DDirectSpaceState.xml b/doc/classes/Physics2DDirectSpaceState.xml index b15d4dfd54..ca7dbab8b8 100644 --- a/doc/classes/Physics2DDirectSpaceState.xml +++ b/doc/classes/Physics2DDirectSpaceState.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DDirectSpaceState" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="Physics2DDirectSpaceState" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Direct access object to a space in the [Physics2DServer]. </brief_description> diff --git a/doc/classes/Physics2DServer.xml b/doc/classes/Physics2DServer.xml index 6e3381c200..f3115144fa 100644 --- a/doc/classes/Physics2DServer.xml +++ b/doc/classes/Physics2DServer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DServer" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="Physics2DServer" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Physics 2D Server. </brief_description> @@ -338,10 +338,6 @@ <method name="body_create"> <return type="RID"> </return> - <argument index="0" name="mode" type="int" enum="Physics2DServer.BodyMode" default="2"> - </argument> - <argument index="1" name="init_sleeping" type="bool" default="false"> - </argument> <description> Creates a physics body. The first parameter can be any value from constants BODY_MODE*, for the type of body created. Additionally, the body can be created in sleeping state to save processing time. </description> @@ -725,6 +721,30 @@ Returns whether a body can move from a given point in a given direction. Apart from the boolean return value, a [Physics2DTestMotionResult] can be passed to return additional information in. </description> </method> + <method name="capsule_shape_create"> + <return type="RID"> + </return> + <description> + </description> + </method> + <method name="circle_shape_create"> + <return type="RID"> + </return> + <description> + </description> + </method> + <method name="concave_polygon_shape_create"> + <return type="RID"> + </return> + <description> + </description> + </method> + <method name="convex_polygon_shape_create"> + <return type="RID"> + </return> + <description> + </description> + </method> <method name="damped_spring_joint_create"> <return type="RID"> </return> @@ -832,6 +852,12 @@ Sets a joint parameter. Parameters are explained in the JOINT_PARAM* constants. </description> </method> + <method name="line_shape_create"> + <return type="RID"> + </return> + <description> + </description> + </method> <method name="pin_joint_create"> <return type="RID"> </return> @@ -845,22 +871,31 @@ Creates a pin joint between two bodies. If not specified, the second body is assumed to be the joint itself. </description> </method> - <method name="set_active"> - <return type="void"> + <method name="ray_shape_create"> + <return type="RID"> </return> - <argument index="0" name="active" type="bool"> - </argument> <description> - Activates or deactivates the 2D physics engine. </description> </method> - <method name="shape_create"> + <method name="rectangle_shape_create"> <return type="RID"> </return> - <argument index="0" name="type" type="int" enum="Physics2DServer.ShapeType"> + <description> + </description> + </method> + <method name="segment_shape_create"> + <return type="RID"> + </return> + <description> + </description> + </method> + <method name="set_active"> + <return type="void"> + </return> + <argument index="0" name="active" type="bool"> </argument> <description> - Creates a shape of type SHAPE_*. Does not assign it to a body or an area. To do so, you must use [method area_set_shape] or [method body_set_shape]. + Activates or deactivates the 2D physics engine. </description> </method> <method name="shape_get_data" qualifiers="const"> diff --git a/doc/classes/Physics2DServerSW.xml b/doc/classes/Physics2DServerSW.xml index 67fd7a21d8..6764f1a4f6 100644 --- a/doc/classes/Physics2DServerSW.xml +++ b/doc/classes/Physics2DServerSW.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DServerSW" inherits="Physics2DServer" category="Core" version="3.0.alpha.custom_build"> +<class name="Physics2DServerSW" inherits="Physics2DServer" category="Core" version="3.0-alpha"> <brief_description> Software implementation of [Physics2DServer]. </brief_description> diff --git a/doc/classes/Physics2DShapeQueryParameters.xml b/doc/classes/Physics2DShapeQueryParameters.xml index 04fe12cc07..829aec7a25 100644 --- a/doc/classes/Physics2DShapeQueryParameters.xml +++ b/doc/classes/Physics2DShapeQueryParameters.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DShapeQueryParameters" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="Physics2DShapeQueryParameters" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Parameters to be sent to a 2D shape physics query. </brief_description> diff --git a/doc/classes/Physics2DShapeQueryResult.xml b/doc/classes/Physics2DShapeQueryResult.xml index 9786a6aa75..d5a29e79fa 100644 --- a/doc/classes/Physics2DShapeQueryResult.xml +++ b/doc/classes/Physics2DShapeQueryResult.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DShapeQueryResult" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="Physics2DShapeQueryResult" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Physics2DTestMotionResult.xml b/doc/classes/Physics2DTestMotionResult.xml index a71d58faa7..6bc4849184 100644 --- a/doc/classes/Physics2DTestMotionResult.xml +++ b/doc/classes/Physics2DTestMotionResult.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Physics2DTestMotionResult" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="Physics2DTestMotionResult" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PhysicsBody.xml b/doc/classes/PhysicsBody.xml index e75fbb8e2d..579a074731 100644 --- a/doc/classes/PhysicsBody.xml +++ b/doc/classes/PhysicsBody.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsBody" inherits="CollisionObject" category="Core" version="3.0.alpha.custom_build"> +<class name="PhysicsBody" inherits="CollisionObject" category="Core" version="3.0-alpha"> <brief_description> Base class for all objects affected by physics in 3D space. </brief_description> diff --git a/doc/classes/PhysicsBody2D.xml b/doc/classes/PhysicsBody2D.xml index 748506baa9..bf341692bf 100644 --- a/doc/classes/PhysicsBody2D.xml +++ b/doc/classes/PhysicsBody2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsBody2D" inherits="CollisionObject2D" category="Core" version="3.0.alpha.custom_build"> +<class name="PhysicsBody2D" inherits="CollisionObject2D" category="Core" version="3.0-alpha"> <brief_description> Base class for all objects affected by physics in 2D space. </brief_description> diff --git a/doc/classes/PhysicsDirectBodyState.xml b/doc/classes/PhysicsDirectBodyState.xml index 349b7e7c3f..33dafa29f6 100644 --- a/doc/classes/PhysicsDirectBodyState.xml +++ b/doc/classes/PhysicsDirectBodyState.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsDirectBodyState" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="PhysicsDirectBodyState" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PhysicsDirectBodyStateSW.xml b/doc/classes/PhysicsDirectBodyStateSW.xml deleted file mode 100644 index 6d283f307e..0000000000 --- a/doc/classes/PhysicsDirectBodyStateSW.xml +++ /dev/null @@ -1,15 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsDirectBodyStateSW" inherits="PhysicsDirectBodyState" category="Core" version="3.0.alpha.custom_build"> - <brief_description> - </brief_description> - <description> - </description> - <tutorials> - </tutorials> - <demos> - </demos> - <methods> - </methods> - <constants> - </constants> -</class> diff --git a/doc/classes/PhysicsDirectSpaceState.xml b/doc/classes/PhysicsDirectSpaceState.xml index 01307b92c7..b5765b6421 100644 --- a/doc/classes/PhysicsDirectSpaceState.xml +++ b/doc/classes/PhysicsDirectSpaceState.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsDirectSpaceState" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="PhysicsDirectSpaceState" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PhysicsServer.xml b/doc/classes/PhysicsServer.xml index b0f42b83a3..76dabd12ba 100644 --- a/doc/classes/PhysicsServer.xml +++ b/doc/classes/PhysicsServer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsServer" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="PhysicsServer" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Server interface for low level physics access. </brief_description> @@ -388,6 +388,14 @@ Returns the [PhysicsDirectBodyState] of the body. </description> </method> + <method name="body_get_kinematic_safe_margin" qualifiers="const"> + <return type="float"> + </return> + <argument index="0" name="body" type="RID"> + </argument> + <description> + </description> + </method> <method name="body_get_max_contacts_reported" qualifiers="const"> <return type="int"> </return> @@ -598,6 +606,16 @@ Sets the function used to calculate physics for an object, if that object allows it (see [method body_set_omit_force integration]). </description> </method> + <method name="body_set_kinematic_safe_margin"> + <return type="void"> + </return> + <argument index="0" name="body" type="RID"> + </argument> + <argument index="1" name="margin" type="float"> + </argument> + <description> + </description> + </method> <method name="body_set_max_contacts_reported"> <return type="void"> </return> @@ -1422,7 +1440,9 @@ <constant name="BODY_MODE_RIGID" value="2"> Constant for rigid bodies. </constant> - <constant name="BODY_MODE_CHARACTER" value="3"> + <constant name="BODY_MODE_SOFT" value="3"> + </constant> + <constant name="BODY_MODE_CHARACTER" value="4"> Constant for rigid bodies in character mode. In this mode, a body can not rotate, and only its linear velocity is affected by physics. </constant> <constant name="BODY_PARAM_BOUNCE" value="0"> diff --git a/doc/classes/PhysicsServerSW.xml b/doc/classes/PhysicsServerSW.xml deleted file mode 100644 index 53e1c0057e..0000000000 --- a/doc/classes/PhysicsServerSW.xml +++ /dev/null @@ -1,17 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsServerSW" inherits="PhysicsServer" category="Core" version="3.0.alpha.custom_build"> - <brief_description> - Software implementation of [PhysicsServer]. - </brief_description> - <description> - This class exposes no new methods or properties and should not be used, as [PhysicsServer] automatically selects the best implementation available. - </description> - <tutorials> - </tutorials> - <demos> - </demos> - <methods> - </methods> - <constants> - </constants> -</class> diff --git a/doc/classes/PhysicsShapeQueryParameters.xml b/doc/classes/PhysicsShapeQueryParameters.xml index f2e8b1986a..b9023194d7 100644 --- a/doc/classes/PhysicsShapeQueryParameters.xml +++ b/doc/classes/PhysicsShapeQueryParameters.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsShapeQueryParameters" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="PhysicsShapeQueryParameters" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PhysicsShapeQueryResult.xml b/doc/classes/PhysicsShapeQueryResult.xml index 4c4a283688..2e723e96df 100644 --- a/doc/classes/PhysicsShapeQueryResult.xml +++ b/doc/classes/PhysicsShapeQueryResult.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PhysicsShapeQueryResult" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="PhysicsShapeQueryResult" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Result of a shape query in Physics2DServer. </brief_description> diff --git a/doc/classes/PinJoint.xml b/doc/classes/PinJoint.xml index 1cc381b1b3..bcf69df816 100644 --- a/doc/classes/PinJoint.xml +++ b/doc/classes/PinJoint.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PinJoint" inherits="Joint" category="Core" version="3.0.alpha.custom_build"> +<class name="PinJoint" inherits="Joint" category="Core" version="3.0-alpha"> <brief_description> Pin Joint for 3D Shapes. </brief_description> diff --git a/doc/classes/PinJoint2D.xml b/doc/classes/PinJoint2D.xml index 009b0ec2f2..7f92567ae4 100644 --- a/doc/classes/PinJoint2D.xml +++ b/doc/classes/PinJoint2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PinJoint2D" inherits="Joint2D" category="Core" version="3.0.alpha.custom_build"> +<class name="PinJoint2D" inherits="Joint2D" category="Core" version="3.0-alpha"> <brief_description> Pin Joint for 2D Shapes. </brief_description> diff --git a/doc/classes/Plane.xml b/doc/classes/Plane.xml index 5c4eb984db..2fd02a56c6 100644 --- a/doc/classes/Plane.xml +++ b/doc/classes/Plane.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Plane" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Plane" category="Built-In Types" version="3.0-alpha"> <brief_description> Plane in hessian form. </brief_description> diff --git a/doc/classes/PlaneMesh.xml b/doc/classes/PlaneMesh.xml index 034bc391a6..93bc191e45 100644 --- a/doc/classes/PlaneMesh.xml +++ b/doc/classes/PlaneMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PlaneMesh" inherits="PrimitiveMesh" category="Core" version="3.0.alpha.custom_build"> +<class name="PlaneMesh" inherits="PrimitiveMesh" category="Core" version="3.0-alpha"> <brief_description> Class representing a planar [PrimitiveMesh]. </brief_description> diff --git a/doc/classes/PlaneShape.xml b/doc/classes/PlaneShape.xml index 7e7bde4db3..d394f781e3 100644 --- a/doc/classes/PlaneShape.xml +++ b/doc/classes/PlaneShape.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PlaneShape" inherits="Shape" category="Core" version="3.0.alpha.custom_build"> +<class name="PlaneShape" inherits="Shape" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Polygon2D.xml b/doc/classes/Polygon2D.xml index 23cb9bd91b..ccf60e4d49 100644 --- a/doc/classes/Polygon2D.xml +++ b/doc/classes/Polygon2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Polygon2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="Polygon2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> A 2D polygon. </brief_description> @@ -73,6 +73,12 @@ Return the rotation in radians of the texture polygon. </description> </method> + <method name="get_texture_rotation_degrees" qualifiers="const"> + <return type="float"> + </return> + <description> + </description> + </method> <method name="get_texture_scale" qualifiers="const"> <return type="Vector2"> </return> @@ -173,6 +179,14 @@ Set the amount of rotation of the polygon texture, [code]texture_rotation[/code] is specified in radians and clockwise rotation. </description> </method> + <method name="set_texture_rotation_degrees"> + <return type="void"> + </return> + <argument index="0" name="texture_rotation" type="float"> + </argument> + <description> + </description> + </method> <method name="set_texture_scale"> <return type="void"> </return> @@ -227,7 +241,7 @@ <member name="texture_offset" type="Vector2" setter="set_texture_offset" getter="get_texture_offset"> Amount to offset the polygon's [code]texture[/code]. If [code](0, 0)[/code] the texture's origin (its top-left corner) will be placed at the polygon's [code]position[/code]. </member> - <member name="texture_rotation" type="float" setter="_set_texture_rotationd" getter="_get_texture_rotationd"> + <member name="texture_rotation" type="float" setter="set_texture_rotation_degrees" getter="get_texture_rotation_degrees"> The texture's rotation in degrees. </member> <member name="texture_scale" type="Vector2" setter="set_texture_scale" getter="get_texture_scale"> diff --git a/doc/classes/PolygonPathFinder.xml b/doc/classes/PolygonPathFinder.xml index a0d1284a85..213d7c0981 100644 --- a/doc/classes/PolygonPathFinder.xml +++ b/doc/classes/PolygonPathFinder.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PolygonPathFinder" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="PolygonPathFinder" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PoolByteArray.xml b/doc/classes/PoolByteArray.xml index 9ef5390c5e..54efc24725 100644 --- a/doc/classes/PoolByteArray.xml +++ b/doc/classes/PoolByteArray.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolByteArray" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="PoolByteArray" category="Built-In Types" version="3.0-alpha"> <brief_description> Raw byte array. </brief_description> diff --git a/doc/classes/PoolColorArray.xml b/doc/classes/PoolColorArray.xml index 70503a67b9..f7cf389577 100644 --- a/doc/classes/PoolColorArray.xml +++ b/doc/classes/PoolColorArray.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolColorArray" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="PoolColorArray" category="Built-In Types" version="3.0-alpha"> <brief_description> Array of Colors </brief_description> diff --git a/doc/classes/PoolIntArray.xml b/doc/classes/PoolIntArray.xml index 5caa8add1e..53b2258c58 100644 --- a/doc/classes/PoolIntArray.xml +++ b/doc/classes/PoolIntArray.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolIntArray" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="PoolIntArray" category="Built-In Types" version="3.0-alpha"> <brief_description> Integer Array. </brief_description> diff --git a/doc/classes/PoolRealArray.xml b/doc/classes/PoolRealArray.xml index ee2740e92a..cc22c256e7 100644 --- a/doc/classes/PoolRealArray.xml +++ b/doc/classes/PoolRealArray.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolRealArray" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="PoolRealArray" category="Built-In Types" version="3.0-alpha"> <brief_description> Real Array. </brief_description> diff --git a/doc/classes/PoolStringArray.xml b/doc/classes/PoolStringArray.xml index ace4f732da..47928281cf 100644 --- a/doc/classes/PoolStringArray.xml +++ b/doc/classes/PoolStringArray.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolStringArray" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="PoolStringArray" category="Built-In Types" version="3.0-alpha"> <brief_description> String Array. </brief_description> diff --git a/doc/classes/PoolVector2Array.xml b/doc/classes/PoolVector2Array.xml index fbfdb11825..2ece5a6486 100644 --- a/doc/classes/PoolVector2Array.xml +++ b/doc/classes/PoolVector2Array.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolVector2Array" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="PoolVector2Array" category="Built-In Types" version="3.0-alpha"> <brief_description> An Array of Vector2. </brief_description> diff --git a/doc/classes/PoolVector3Array.xml b/doc/classes/PoolVector3Array.xml index e5e2924273..59f1c36a9e 100644 --- a/doc/classes/PoolVector3Array.xml +++ b/doc/classes/PoolVector3Array.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PoolVector3Array" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="PoolVector3Array" category="Built-In Types" version="3.0-alpha"> <brief_description> An Array of Vector3. </brief_description> diff --git a/doc/classes/Popup.xml b/doc/classes/Popup.xml index 7e87c9fcc0..7a93c32ea8 100644 --- a/doc/classes/Popup.xml +++ b/doc/classes/Popup.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Popup" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="Popup" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Base container control for popups and dialogs. </brief_description> diff --git a/doc/classes/PopupDialog.xml b/doc/classes/PopupDialog.xml index c51c5b6d21..82439e9d74 100644 --- a/doc/classes/PopupDialog.xml +++ b/doc/classes/PopupDialog.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PopupDialog" inherits="Popup" category="Core" version="3.0.alpha.custom_build"> +<class name="PopupDialog" inherits="Popup" category="Core" version="3.0-alpha"> <brief_description> Base class for Popup Dialogs. </brief_description> diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index 086eb8e34d..f3cd7df796 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PopupMenu" inherits="Popup" category="Core" version="3.0.alpha.custom_build"> +<class name="PopupMenu" inherits="Popup" category="Core" version="3.0-alpha"> <brief_description> PopupMenu displays a list of options. </brief_description> diff --git a/doc/classes/PopupPanel.xml b/doc/classes/PopupPanel.xml index f8060ab4f6..3878e345c9 100644 --- a/doc/classes/PopupPanel.xml +++ b/doc/classes/PopupPanel.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PopupPanel" inherits="Popup" category="Core" version="3.0.alpha.custom_build"> +<class name="PopupPanel" inherits="Popup" category="Core" version="3.0-alpha"> <brief_description> Class for displaying popups with a panel background. </brief_description> diff --git a/doc/classes/Position2D.xml b/doc/classes/Position2D.xml index ffb1c62d0f..6d282370d4 100644 --- a/doc/classes/Position2D.xml +++ b/doc/classes/Position2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Position2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="Position2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Generic 2D Position hint for editing. </brief_description> diff --git a/doc/classes/Position3D.xml b/doc/classes/Position3D.xml index a544e59ddc..cd4c1293ca 100644 --- a/doc/classes/Position3D.xml +++ b/doc/classes/Position3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Position3D" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="Position3D" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Generic 3D Position hint for editing </brief_description> diff --git a/doc/classes/PrimitiveMesh.xml b/doc/classes/PrimitiveMesh.xml index 34141edbe7..5c8d467927 100644 --- a/doc/classes/PrimitiveMesh.xml +++ b/doc/classes/PrimitiveMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PrimitiveMesh" inherits="Mesh" category="Core" version="3.0.alpha.custom_build"> +<class name="PrimitiveMesh" inherits="Mesh" category="Core" version="3.0-alpha"> <brief_description> Base class for all primitive meshes. Handles applying a [Material] to a primitive mesh. </brief_description> diff --git a/doc/classes/PrismMesh.xml b/doc/classes/PrismMesh.xml index 21fa67bc82..fa53717111 100644 --- a/doc/classes/PrismMesh.xml +++ b/doc/classes/PrismMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PrismMesh" inherits="PrimitiveMesh" category="Core" version="3.0.alpha.custom_build"> +<class name="PrismMesh" inherits="PrimitiveMesh" category="Core" version="3.0-alpha"> <brief_description> Class representing a prism-shaped [PrimitiveMesh]. </brief_description> diff --git a/doc/classes/ProceduralSky.xml b/doc/classes/ProceduralSky.xml index 032ce9def2..70e9388058 100644 --- a/doc/classes/ProceduralSky.xml +++ b/doc/classes/ProceduralSky.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ProceduralSky" inherits="Sky" category="Core" version="3.0.alpha.custom_build"> +<class name="ProceduralSky" inherits="Sky" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/ProgressBar.xml b/doc/classes/ProgressBar.xml index f6be04cc19..d72b28efc5 100644 --- a/doc/classes/ProgressBar.xml +++ b/doc/classes/ProgressBar.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ProgressBar" inherits="Range" category="Core" version="3.0.alpha.custom_build"> +<class name="ProgressBar" inherits="Range" category="Core" version="3.0-alpha"> <brief_description> General purpose progress bar. </brief_description> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index bdf2cc0062..6f670ded64 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ProjectSettings" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="ProjectSettings" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Contains global variables accessible from everywhere. </brief_description> @@ -17,7 +17,7 @@ <argument index="0" name="hint" type="Dictionary"> </argument> <description> - Add a custom property info to a property. The dictionary must contain: name:[String](the name of the property) and type:[int](see TYPE_* in [@Global Scope]), and optionally hint:[int](see PROPERTY_HINT_* in [@Global Scope]), hint_string:[String]. + Add a custom property info to a property. The dictionary must contain: name:[String](the name of the property) and type:[int](see TYPE_* in [@GlobalScope]), and optionally hint:[int](see PROPERTY_HINT_* in [@GlobalScope]), hint_string:[String]. Example: [codeblock] ProjectSettings.set("category/property_name", 0) @@ -59,14 +59,6 @@ <description> </description> </method> - <method name="get_singleton" qualifiers="const"> - <return type="Object"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <description> - </description> - </method> <method name="globalize_path" qualifiers="const"> <return type="String"> </return> @@ -85,14 +77,6 @@ Return true if a configuration value is present. </description> </method> - <method name="has_singleton" qualifiers="const"> - <return type="bool"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <description> - </description> - </method> <method name="load_resource_pack"> <return type="bool"> </return> diff --git a/doc/classes/ProximityGroup.xml b/doc/classes/ProximityGroup.xml index 9b4b564900..b05d5b95dd 100644 --- a/doc/classes/ProximityGroup.xml +++ b/doc/classes/ProximityGroup.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ProximityGroup" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="ProximityGroup" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> General purpose proximity-detection node. </brief_description> diff --git a/doc/classes/QuadMesh.xml b/doc/classes/QuadMesh.xml index b7c66b04de..807141a284 100644 --- a/doc/classes/QuadMesh.xml +++ b/doc/classes/QuadMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="QuadMesh" inherits="PrimitiveMesh" category="Core" version="3.0.alpha.custom_build"> +<class name="QuadMesh" inherits="PrimitiveMesh" category="Core" version="3.0-alpha"> <brief_description> Class representing a square mesh. </brief_description> @@ -11,7 +11,25 @@ <demos> </demos> <methods> + <method name="get_size" qualifiers="const"> + <return type="Vector2"> + </return> + <description> + </description> + </method> + <method name="set_size"> + <return type="void"> + </return> + <argument index="0" name="size" type="Vector2"> + </argument> + <description> + </description> + </method> </methods> + <members> + <member name="size" type="Vector2" setter="set_size" getter="get_size"> + </member> + </members> <constants> </constants> </class> diff --git a/doc/classes/Quat.xml b/doc/classes/Quat.xml index 056d7d10fa..1aa30075e4 100644 --- a/doc/classes/Quat.xml +++ b/doc/classes/Quat.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Quat" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Quat" category="Built-In Types" version="3.0-alpha"> <brief_description> Quaternion. </brief_description> diff --git a/doc/classes/RID.xml b/doc/classes/RID.xml index 89005b0d3b..831a4665c4 100644 --- a/doc/classes/RID.xml +++ b/doc/classes/RID.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RID" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="RID" category="Built-In Types" version="3.0-alpha"> <brief_description> Handle for a [Resource]'s unique ID. </brief_description> diff --git a/doc/classes/Range.xml b/doc/classes/Range.xml index cd75c2b658..d2ea59cbeb 100644 --- a/doc/classes/Range.xml +++ b/doc/classes/Range.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Range" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="Range" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Abstract base class for range-based controls. </brief_description> diff --git a/doc/classes/RayCast.xml b/doc/classes/RayCast.xml index 3f999f7fe2..d5f57c43c8 100644 --- a/doc/classes/RayCast.xml +++ b/doc/classes/RayCast.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RayCast" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="RayCast" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Query the closest object intersecting a ray. </brief_description> diff --git a/doc/classes/RayCast2D.xml b/doc/classes/RayCast2D.xml index 45a83f7ded..f5828da796 100644 --- a/doc/classes/RayCast2D.xml +++ b/doc/classes/RayCast2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RayCast2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="RayCast2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Query the closest object intersecting a ray. </brief_description> diff --git a/doc/classes/RayShape.xml b/doc/classes/RayShape.xml index d5d367a335..d4826141e8 100644 --- a/doc/classes/RayShape.xml +++ b/doc/classes/RayShape.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RayShape" inherits="Shape" category="Core" version="3.0.alpha.custom_build"> +<class name="RayShape" inherits="Shape" category="Core" version="3.0-alpha"> <brief_description> Ray shape for 3D collisions. </brief_description> diff --git a/doc/classes/RayShape2D.xml b/doc/classes/RayShape2D.xml index 4f6313a1d2..c9779a4307 100644 --- a/doc/classes/RayShape2D.xml +++ b/doc/classes/RayShape2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RayShape2D" inherits="Shape2D" category="Core" version="3.0.alpha.custom_build"> +<class name="RayShape2D" inherits="Shape2D" category="Core" version="3.0-alpha"> <brief_description> Ray shape for 2D collisions. </brief_description> diff --git a/doc/classes/Rect2.xml b/doc/classes/Rect2.xml index 5af8c82a7b..e0b8b6ec75 100644 --- a/doc/classes/Rect2.xml +++ b/doc/classes/Rect2.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Rect2" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Rect2" category="Built-In Types" version="3.0-alpha"> <brief_description> 2D Axis-aligned bounding box. </brief_description> diff --git a/doc/classes/RectangleShape2D.xml b/doc/classes/RectangleShape2D.xml index 7a1aec2021..b61344d86f 100644 --- a/doc/classes/RectangleShape2D.xml +++ b/doc/classes/RectangleShape2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RectangleShape2D" inherits="Shape2D" category="Core" version="3.0.alpha.custom_build"> +<class name="RectangleShape2D" inherits="Shape2D" category="Core" version="3.0-alpha"> <brief_description> Rectangle shape for 2D collisions. </brief_description> diff --git a/doc/classes/Reference.xml b/doc/classes/Reference.xml index 2531ea88ad..18bd51f675 100644 --- a/doc/classes/Reference.xml +++ b/doc/classes/Reference.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Reference" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="Reference" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Base class for anything that keeps a reference count. </brief_description> diff --git a/doc/classes/ReferenceRect.xml b/doc/classes/ReferenceRect.xml index e8de910cc8..75b513a147 100644 --- a/doc/classes/ReferenceRect.xml +++ b/doc/classes/ReferenceRect.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ReferenceRect" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="ReferenceRect" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Reference frame for GUI. </brief_description> diff --git a/doc/classes/ReflectionProbe.xml b/doc/classes/ReflectionProbe.xml index c3d95e5a62..1508323207 100644 --- a/doc/classes/ReflectionProbe.xml +++ b/doc/classes/ReflectionProbe.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ReflectionProbe" inherits="VisualInstance" category="Core" version="3.0.alpha.custom_build"> +<class name="ReflectionProbe" inherits="VisualInstance" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/RegEx.xml b/doc/classes/RegEx.xml deleted file mode 100644 index 4577672c72..0000000000 --- a/doc/classes/RegEx.xml +++ /dev/null @@ -1,114 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" ?> -<class name="RegEx" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> - <brief_description> - Simple regular expression matcher. - </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 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] - Similarly: - [code]exp.compile("\"(?:\\\\.|[^\"])*\"")[/code] - would be read as [code]"(?:\\.|[^"])*"[/code] - Currently supported features: - * Capturing [code]()[/code] and non-capturing [code](?:)[/code] groups - * Named capturing groups [code](?P<name>)[/code] - * Any character [code].[/code] - * Shorthand character classes [code]\w \W \s \S \d \D[/code] - * User-defined character classes such as [code][A-Za-z][/code] - * Simple quantifiers [code]?[/code], [code]*[/code] and [code]+[/code] - * Range quantifiers [code]{x,y}[/code] - * Lazy (non-greedy) quantifiers [code]*?[/code] - * Beginning [code]^[/code] and end [code]$[/code] anchors - * Alternation [code]|[/code] - * Backreferences [code]\1[/code], [code]\g{1}[/code], and [code]\g<name>[/code] - * POSIX character classes [code][[:alnum:]][/code] - * Lookahead [code](?=)[/code], [code](?!)[/code] and lookbehind [code](?<=)[/code], [code](?<!)[/code] - * ASCII [code]\xFF[/code] and Unicode [code]\uFFFF[/code] code points (in a style similar to Python) - * Word boundaries [code]\b[/code], [code]\B[/code] - </description> - <tutorials> - </tutorials> - <demos> - </demos> - <methods> - <method name="clear"> - <return type="void"> - </return> - <description> - This method resets the state of the object, as it was freshly created. Namely, it unassigns the regular expression of this object. - </description> - </method> - <method name="compile"> - <return type="int" enum="Error"> - </return> - <argument index="0" name="pattern" type="String"> - </argument> - <description> - Compiles and assign the search pattern to use. - </description> - </method> - <method name="get_group_count" qualifiers="const"> - <return type="int"> - </return> - <description> - Returns the number of numeric capturing groups. - </description> - </method> - <method name="get_names" qualifiers="const"> - <return type="Array"> - </return> - <description> - Returns an array of names of named capturing groups. - </description> - </method> - <method name="get_pattern" qualifiers="const"> - <return type="String"> - </return> - <description> - 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 search pattern assigned. - </description> - </method> - <method name="search" qualifiers="const"> - <return type="RegExMatch"> - </return> - <argument index="0" name="subject" type="String"> - </argument> - <argument index="1" name="offset" type="int" default="0"> - </argument> - <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 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"> - <return type="String"> - </return> - <argument index="0" name="subject" type="String"> - </argument> - <argument index="1" name="replacement" type="String"> - </argument> - <argument index="2" name="all" type="bool" default="false"> - </argument> - <argument index="3" name="offset" type="int" default="0"> - </argument> - <argument index="4" name="end" type="int" default="-1"> - </argument> - <description> - Searches the text for the compiled pattern and replaces it with the specified string. Escapes and backreferences such as [code]\1[/code] and [code]\g<name>[/code] expanded and resolved. By default only the first instance is replaced but it can be changed for all instances (global replacement). The region to search within can be specified without modifying where the start and end anchor would be. - </description> - </method> - </methods> - <constants> - </constants> -</class> diff --git a/doc/classes/RegExMatch.xml b/doc/classes/RegExMatch.xml deleted file mode 100644 index abf2e383d5..0000000000 --- a/doc/classes/RegExMatch.xml +++ /dev/null @@ -1,72 +0,0 @@ -<?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> - <demos> - </demos> - <methods> - <method name="get_end" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="Variant" default="0"> - </argument> - <description> - 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"> - <return type="int"> - </return> - <description> - Returns the number of numeric capturing groups. - </description> - </method> - <method name="get_names" qualifiers="const"> - <return type="Dictionary"> - </return> - <description> - Returns an array of names of named capturing groups. - </description> - </method> - <method name="get_start" qualifiers="const"> - <return type="int"> - </return> - <argument index="0" name="name" type="Variant" default="0"> - </argument> - <description> - 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"> - <return type="String"> - </return> - <argument index="0" name="name" type="Variant" default="0"> - </argument> - <description> - 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> - <constants> - </constants> -</class> diff --git a/doc/classes/RemoteTransform.xml b/doc/classes/RemoteTransform.xml index 67679bc9df..76caea1a94 100644 --- a/doc/classes/RemoteTransform.xml +++ b/doc/classes/RemoteTransform.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RemoteTransform" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="RemoteTransform" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> RemoteTransform mirrors the [Transform] of another [Spatial] derived Node in the scene. </brief_description> diff --git a/doc/classes/RemoteTransform2D.xml b/doc/classes/RemoteTransform2D.xml index eac7427f9f..d6dcde5742 100644 --- a/doc/classes/RemoteTransform2D.xml +++ b/doc/classes/RemoteTransform2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RemoteTransform2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="RemoteTransform2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> RemoteTransform2D mirrors the [Transform2D] of another [CanvasItem] derived Node in the scene. </brief_description> diff --git a/doc/classes/Resource.xml b/doc/classes/Resource.xml index 7767b26988..0044756003 100644 --- a/doc/classes/Resource.xml +++ b/doc/classes/Resource.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Resource" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="Resource" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Base class for all resources. </brief_description> diff --git a/doc/classes/ResourceImporter.xml b/doc/classes/ResourceImporter.xml index 419c4a84fb..b627438c89 100644 --- a/doc/classes/ResourceImporter.xml +++ b/doc/classes/ResourceImporter.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ResourceImporter" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="ResourceImporter" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/ResourceInteractiveLoader.xml b/doc/classes/ResourceInteractiveLoader.xml index d508b0a532..866347c0bb 100644 --- a/doc/classes/ResourceInteractiveLoader.xml +++ b/doc/classes/ResourceInteractiveLoader.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ResourceInteractiveLoader" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="ResourceInteractiveLoader" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Interactive Resource Loader. </brief_description> diff --git a/doc/classes/ResourceLoader.xml b/doc/classes/ResourceLoader.xml index 9fb3c71a5b..5940031a76 100644 --- a/doc/classes/ResourceLoader.xml +++ b/doc/classes/ResourceLoader.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ResourceLoader" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="ResourceLoader" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Resource Loader. </brief_description> diff --git a/doc/classes/ResourcePreloader.xml b/doc/classes/ResourcePreloader.xml index 35ebeb1760..f4c3334107 100644 --- a/doc/classes/ResourcePreloader.xml +++ b/doc/classes/ResourcePreloader.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ResourcePreloader" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="ResourcePreloader" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Resource Preloader Node. </brief_description> diff --git a/doc/classes/ResourceSaver.xml b/doc/classes/ResourceSaver.xml index de296776ad..af9c592ded 100644 --- a/doc/classes/ResourceSaver.xml +++ b/doc/classes/ResourceSaver.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ResourceSaver" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="ResourceSaver" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Resource Saving Interface. </brief_description> diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index c95ea11f5f..18e77ff5e3 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -1,10 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RichTextLabel" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="RichTextLabel" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Label that displays rich text. </brief_description> <description> - Label that displays rich text. Rich text can contain custom text, fonts, images and some basic formatting. It also adapts itself to given width/heights. + Rich text can contain custom text, fonts, images and some basic formatting. The label manages these as an internal tag stack. It also adapts itself to given width/heights. + Note that assignments to [member bbcode_text] clear the tag stack and reconstruct it from the property's contents. Any edits made to [member bbcode_text] will erase previous edits made from other manual sources such as [method append_bbcode] and the [code]push_*[/code] / [method pop] methods. </description> <tutorials> </tutorials> @@ -17,6 +18,7 @@ <argument index="0" name="image" type="Texture"> </argument> <description> + Adds an image's opening and closing tags to the tag stack. </description> </method> <method name="add_text"> @@ -25,6 +27,7 @@ <argument index="0" name="text" type="String"> </argument> <description> + Adds raw non-bbcode-parsed text to the tag stack. </description> </method> <method name="append_bbcode"> @@ -33,27 +36,28 @@ <argument index="0" name="bbcode" type="String"> </argument> <description> + Parses [code]bbcode[/code] and adds tags to the tag stack as needed. Returns the result of the parsing, [code]OK[/code] if successful. </description> </method> <method name="clear"> <return type="void"> </return> <description> - Clears the label's text. + Clears the tag stack and sets [member bbcode_text] to an empty string. </description> </method> <method name="get_bbcode" qualifiers="const"> <return type="String"> </return> <description> - Returns label's BBCode. + Returns the bbcode-parsed [member bbcode_text]. </description> </method> <method name="get_line_count" qualifiers="const"> <return type="int"> </return> <description> - Returns the number of lines in the text. + Returns the total number of newlines in the tag stack's text tags. Considers wrapped text as one line. </description> </method> <method name="get_percent_visible" qualifiers="const"> @@ -67,26 +71,28 @@ <return type="int"> </return> <description> + Returns the number of spaces associated with a single tab length. Does not affect "\t" in text tags, only indent tags. </description> </method> <method name="get_text"> <return type="String"> </return> <description> - Returns the label's text with the formatting removed. + Returns the raw content of [member bbcode_text]. </description> </method> <method name="get_total_character_count" qualifiers="const"> <return type="int"> </return> <description> - Returns the total number of characters. + Returns the total number of characters from text tags. Does not include bbcodes. </description> </method> <method name="get_v_scroll"> <return type="VScrollBar"> </return> <description> + Returns the vertical scrollbar. </description> </method> <method name="get_visible_characters" qualifiers="const"> @@ -106,6 +112,7 @@ <return type="bool"> </return> <description> + Returns [code]true[/code] if the label underlines meta tags such as [url]{text}[/url]. </description> </method> <method name="is_overriding_selected_font_color" qualifiers="const"> @@ -118,34 +125,34 @@ <return type="bool"> </return> <description> - Returns [code]true[/code] if active scrolling is enabled. + Returns [code]true[/code] if the scrollbar is visible. Does not block scrolling completely. See [method scroll_to_line]. </description> </method> <method name="is_scroll_following" qualifiers="const"> <return type="bool"> </return> <description> + Returns [code]true[/code] if the window scrolls down to display new content automatically. </description> </method> <method name="is_selection_enabled" qualifiers="const"> <return type="bool"> </return> <description> - Returns [code]true[/code] if the label's text can be selected. + Returns [code]true[/code] if the label allows text selection. </description> </method> <method name="is_using_bbcode" qualifiers="const"> <return type="bool"> </return> <description> - Returns [code]true[/code] if the label has BBCode. </description> </method> <method name="newline"> <return type="void"> </return> <description> - Adds a newline to the end of the rich text. + Adds a newline tag to the tag stack. </description> </method> <method name="parse_bbcode"> @@ -154,12 +161,14 @@ <argument index="0" name="bbcode" type="String"> </argument> <description> + The assignment version of [method append_bbcode]. Clears the tag stack and inserts the new content. Returns [code]OK[/code] if parses [code]bbcode[/code] successfully. </description> </method> <method name="pop"> <return type="void"> </return> <description> + Terminates the current tag. Use after [code]push_*[/code] methods to close bbcodes manually. Does not need to follow [code]add_*[/code] methods. </description> </method> <method name="push_align"> @@ -168,12 +177,14 @@ <argument index="0" name="align" type="int" enum="RichTextLabel.Align"> </argument> <description> + Adds a [code][right][/code] tag to the tag stack. </description> </method> <method name="push_cell"> <return type="void"> </return> <description> + Adds a [code][cell][/code] tag to the tag stack. Must be inside a [table] tag. See [method push_table] for details. </description> </method> <method name="push_color"> @@ -182,6 +193,7 @@ <argument index="0" name="color" type="Color"> </argument> <description> + Adds a [code][color][/code] tag to the tag stack. </description> </method> <method name="push_font"> @@ -190,6 +202,7 @@ <argument index="0" name="font" type="Font"> </argument> <description> + Adds a [code][font][/code] tag to the tag stack. Overrides default fonts for its duration. </description> </method> <method name="push_indent"> @@ -198,6 +211,7 @@ <argument index="0" name="level" type="int"> </argument> <description> + Adds an [code][indent][/code] tag to the tag stack. Multiplies "level" by current tab_size to determine new margin length. </description> </method> <method name="push_list"> @@ -206,6 +220,7 @@ <argument index="0" name="type" type="int" enum="RichTextLabel.ListType"> </argument> <description> + Adds a list tag to the tag stack. Similar to the bbcodes [code][ol][/code] or [code][ul][/code], but supports more list types. Not fully implemented! </description> </method> <method name="push_meta"> @@ -214,6 +229,7 @@ <argument index="0" name="data" type="Variant"> </argument> <description> + Adds a meta tag to the tag stack. Similar to the bbcode [code][url=something]{text}[/url][/code], but supports non-[String] metadata types. </description> </method> <method name="push_table"> @@ -222,12 +238,14 @@ <argument index="0" name="columns" type="int"> </argument> <description> + Adds a [code][table=columns][/code] tag to the tag stack. </description> </method> <method name="push_underline"> <return type="void"> </return> <description> + Adds a [code][u][/code] tag to the tag stack. </description> </method> <method name="remove_line"> @@ -236,6 +254,7 @@ <argument index="0" name="line" type="int"> </argument> <description> + Removes a line of content from the label. Returns [code]true[/code] if the line exists. </description> </method> <method name="scroll_to_line"> @@ -244,6 +263,7 @@ <argument index="0" name="line" type="int"> </argument> <description> + Scrolls the window's top line to match [code]line[/code]. </description> </method> <method name="set_bbcode"> @@ -261,6 +281,7 @@ <argument index="0" name="enable" type="bool"> </argument> <description> + If [code]true[/code] will underline meta tags such as the [url] bbcode. Default value: [code]true[/code]. </description> </method> <method name="set_override_selected_font_color"> @@ -286,6 +307,7 @@ <argument index="0" name="active" type="bool"> </argument> <description> + If [code]false[/code] the vertical scrollbar is hidden. Default value: [code]true[/code]. </description> </method> <method name="set_scroll_follow"> @@ -294,6 +316,7 @@ <argument index="0" name="follow" type="bool"> </argument> <description> + If [code]true[/code] the window scrolls to reveal new content. Default value: [code]false[/code]. </description> </method> <method name="set_selection_enabled"> @@ -311,6 +334,7 @@ <argument index="0" name="spaces" type="int"> </argument> <description> + Sets the current tab length in spaces. Use with [method push_indent] to redefine indent length. </description> </method> <method name="set_table_column_expand"> @@ -323,6 +347,9 @@ <argument index="2" name="ratio" type="int"> </argument> <description> + Edits the selected columns expansion options. If [code]expand[/code] is [code]true[/code], the column expands in proportion to its expansion ratio versus the other columns' ratios. + For example, 2 columns with ratios 3 and 4 plus 70 pixels in available width would expand 30 and 40 pixels, respectively. + Columns with a [code]false[/code] expand will not contribute to the total ratio. </description> </method> <method name="set_text"> @@ -331,6 +358,7 @@ <argument index="0" name="text" type="String"> </argument> <description> + Clears the tag stack and adds a raw text tag to the top of it. Does not parse bbcodes. Does not modify [member bbcode_text]. </description> </method> <method name="set_use_bbcode"> @@ -355,7 +383,7 @@ If [code]true[/code] the label uses BBCode formatting. Default value: [code]false[/code]. </member> <member name="bbcode_text" type="String" setter="set_bbcode" getter="get_bbcode"> - The label's text in BBCode format. + The label's text in BBCode format. Is not representative of manual modifications to the internal tag stack. Erases changes made by other methods when edited. </member> <member name="override_selected_font_color" type="bool" setter="set_override_selected_font_color" getter="is_overriding_selected_font_color"> If [code]true[/code] the label uses the custom font color. Default value: [code]false[/code]. @@ -372,6 +400,7 @@ <argument index="0" name="meta" type="Nil"> </argument> <description> + Triggered when the user clicks on content between [url] tags. If the meta is defined in text, e.g. [code][url={"data"="hi"}]hi[/url][/code], then the parameter for this signal will be a [String] type. If a particular type or an object is desired, the [method push_meta] method must be used to manually insert the data into the tag stack. </description> </signal> <signal name="meta_hover_started"> diff --git a/doc/classes/RigidBody.xml b/doc/classes/RigidBody.xml index f9488d2f7f..d40f7b4429 100644 --- a/doc/classes/RigidBody.xml +++ b/doc/classes/RigidBody.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RigidBody" inherits="PhysicsBody" category="Core" version="3.0.alpha.custom_build"> +<class name="RigidBody" inherits="PhysicsBody" category="Core" version="3.0-alpha"> <brief_description> Physics Body whose position is determined through physics simulation in 3D space. </brief_description> diff --git a/doc/classes/RigidBody2D.xml b/doc/classes/RigidBody2D.xml index e0ca6084e6..af8e59c83b 100644 --- a/doc/classes/RigidBody2D.xml +++ b/doc/classes/RigidBody2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="RigidBody2D" inherits="PhysicsBody2D" category="Core" version="3.0.alpha.custom_build"> +<class name="RigidBody2D" inherits="PhysicsBody2D" category="Core" version="3.0-alpha"> <brief_description> A body that is controlled by the 2D physics engine. </brief_description> diff --git a/doc/classes/SceneState.xml b/doc/classes/SceneState.xml index 967c3fbad6..61e08336db 100644 --- a/doc/classes/SceneState.xml +++ b/doc/classes/SceneState.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SceneState" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="SceneState" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/SceneTree.xml b/doc/classes/SceneTree.xml index f6a6ce36e3..7cfacc737d 100644 --- a/doc/classes/SceneTree.xml +++ b/doc/classes/SceneTree.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SceneTree" inherits="MainLoop" category="Core" version="3.0.alpha.custom_build"> +<class name="SceneTree" inherits="MainLoop" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/SceneTreeTimer.xml b/doc/classes/SceneTreeTimer.xml index 276c6857ae..6c540396e5 100644 --- a/doc/classes/SceneTreeTimer.xml +++ b/doc/classes/SceneTreeTimer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SceneTreeTimer" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="SceneTreeTimer" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Script.xml b/doc/classes/Script.xml index c13e009976..83e33c4764 100644 --- a/doc/classes/Script.xml +++ b/doc/classes/Script.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Script" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Script" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> A class stored as a resource. </brief_description> diff --git a/doc/classes/ScriptEditor.xml b/doc/classes/ScriptEditor.xml index e93a0eda0c..7a95f1276e 100644 --- a/doc/classes/ScriptEditor.xml +++ b/doc/classes/ScriptEditor.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ScriptEditor" inherits="PanelContainer" category="Core" version="3.0.alpha.custom_build"> +<class name="ScriptEditor" inherits="PanelContainer" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> @@ -9,6 +9,30 @@ <demos> </demos> <methods> + <method name="can_drop_data_fw" qualifiers="const"> + <return type="bool"> + </return> + <argument index="0" name="arg0" type="Vector2"> + </argument> + <argument index="1" name="arg1" type="Variant"> + </argument> + <argument index="2" name="arg2" type="Control"> + </argument> + <description> + </description> + </method> + <method name="drop_data_fw"> + <return type="void"> + </return> + <argument index="0" name="arg0" type="Vector2"> + </argument> + <argument index="1" name="arg1" type="Variant"> + </argument> + <argument index="2" name="arg2" type="Control"> + </argument> + <description> + </description> + </method> <method name="get_current_script"> <return type="Script"> </return> @@ -16,6 +40,16 @@ Returns a [Script] that is currently active in editor. </description> </method> + <method name="get_drag_data_fw"> + <return type="Variant"> + </return> + <argument index="0" name="arg0" type="Vector2"> + </argument> + <argument index="1" name="arg1" type="Control"> + </argument> + <description> + </description> + </method> <method name="get_open_scripts" qualifiers="const"> <return type="Array"> </return> diff --git a/doc/classes/ScrollBar.xml b/doc/classes/ScrollBar.xml index 7a10d3679e..312baf3bb6 100644 --- a/doc/classes/ScrollBar.xml +++ b/doc/classes/ScrollBar.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ScrollBar" inherits="Range" category="Core" version="3.0.alpha.custom_build"> +<class name="ScrollBar" inherits="Range" category="Core" version="3.0-alpha"> <brief_description> Base class for scroll bars. </brief_description> diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml index 1ae06bde70..51bd950cd9 100644 --- a/doc/classes/ScrollContainer.xml +++ b/doc/classes/ScrollContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ScrollContainer" inherits="Container" category="Core" version="3.0.alpha.custom_build"> +<class name="ScrollContainer" inherits="Container" category="Core" version="3.0-alpha"> <brief_description> A helper node for displaying scrollable elements (e.g. lists). </brief_description> diff --git a/doc/classes/SegmentShape2D.xml b/doc/classes/SegmentShape2D.xml index 3b7a747bcb..c59370018d 100644 --- a/doc/classes/SegmentShape2D.xml +++ b/doc/classes/SegmentShape2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SegmentShape2D" inherits="Shape2D" category="Core" version="3.0.alpha.custom_build"> +<class name="SegmentShape2D" inherits="Shape2D" category="Core" version="3.0-alpha"> <brief_description> Segment shape for 2D collisions. </brief_description> diff --git a/doc/classes/Semaphore.xml b/doc/classes/Semaphore.xml index c9c8ac0298..0f70ec1bd2 100644 --- a/doc/classes/Semaphore.xml +++ b/doc/classes/Semaphore.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Semaphore" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="Semaphore" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> A synchronization Semaphore. </brief_description> diff --git a/doc/classes/Separator.xml b/doc/classes/Separator.xml index 4bbabe58aa..8754eb566d 100644 --- a/doc/classes/Separator.xml +++ b/doc/classes/Separator.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Separator" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="Separator" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Base class for separators. </brief_description> diff --git a/doc/classes/Shader.xml b/doc/classes/Shader.xml index 75644c31ab..53b67c9d38 100644 --- a/doc/classes/Shader.xml +++ b/doc/classes/Shader.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Shader" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Shader" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> To be changed, ignore. </brief_description> diff --git a/doc/classes/ShaderMaterial.xml b/doc/classes/ShaderMaterial.xml index 8bd9f1039e..81dec0cc14 100644 --- a/doc/classes/ShaderMaterial.xml +++ b/doc/classes/ShaderMaterial.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ShaderMaterial" inherits="Material" category="Core" version="3.0.alpha.custom_build"> +<class name="ShaderMaterial" inherits="Material" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Shape.xml b/doc/classes/Shape.xml index 4d822a1705..df39988a35 100644 --- a/doc/classes/Shape.xml +++ b/doc/classes/Shape.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Shape" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Shape" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Base class for all 3D shape resources. </brief_description> diff --git a/doc/classes/Shape2D.xml b/doc/classes/Shape2D.xml index d5e2984ba0..fcc1ded4f7 100644 --- a/doc/classes/Shape2D.xml +++ b/doc/classes/Shape2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Shape2D" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Shape2D" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Base class for all 2D Shapes. </brief_description> diff --git a/doc/classes/ShortCut.xml b/doc/classes/ShortCut.xml index e8b3b962d3..b89c3a65bd 100644 --- a/doc/classes/ShortCut.xml +++ b/doc/classes/ShortCut.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ShortCut" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="ShortCut" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Skeleton.xml b/doc/classes/Skeleton.xml index b5be340b77..b32f8bf7f0 100644 --- a/doc/classes/Skeleton.xml +++ b/doc/classes/Skeleton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Skeleton" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="Skeleton" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Skeleton for characters and animated objects. </brief_description> diff --git a/doc/classes/Sky.xml b/doc/classes/Sky.xml index 3045167346..a2259df42a 100644 --- a/doc/classes/Sky.xml +++ b/doc/classes/Sky.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Sky" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Sky" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Slider.xml b/doc/classes/Slider.xml index b9b2b98549..649752a8a2 100644 --- a/doc/classes/Slider.xml +++ b/doc/classes/Slider.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Slider" inherits="Range" category="Core" version="3.0.alpha.custom_build"> +<class name="Slider" inherits="Range" category="Core" version="3.0-alpha"> <brief_description> Base class for GUI Sliders. </brief_description> diff --git a/doc/classes/SliderJoint.xml b/doc/classes/SliderJoint.xml index adea8658d1..69cdf79c53 100644 --- a/doc/classes/SliderJoint.xml +++ b/doc/classes/SliderJoint.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SliderJoint" inherits="Joint" category="Core" version="3.0.alpha.custom_build"> +<class name="SliderJoint" inherits="Joint" category="Core" version="3.0-alpha"> <brief_description> Piston kind of slider between two bodies in 3D. </brief_description> diff --git a/doc/classes/Spatial.xml b/doc/classes/Spatial.xml index 38e971b6bd..726654f91f 100644 --- a/doc/classes/Spatial.xml +++ b/doc/classes/Spatial.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Spatial" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="Spatial" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Most basic 3D game object, parent of all 3D related nodes. </brief_description> @@ -39,7 +39,7 @@ Returns the rotation (in radians). </description> </method> - <method name="get_rotation_deg" qualifiers="const"> + <method name="get_rotation_degrees" qualifiers="const"> <return type="Vector3"> </return> <description> @@ -267,16 +267,16 @@ <method name="set_rotation"> <return type="void"> </return> - <argument index="0" name="rotation_rad" type="Vector3"> + <argument index="0" name="radians" type="Vector3"> </argument> <description> Set the rotation (in radians). </description> </method> - <method name="set_rotation_deg"> + <method name="set_rotation_degrees"> <return type="void"> </return> - <argument index="0" name="rotation_deg" type="Vector3"> + <argument index="0" name="degrees" type="Vector3"> </argument> <description> Set the rotation (in degrees). @@ -365,7 +365,7 @@ <member name="rotation" type="Vector3" setter="set_rotation" getter="get_rotation"> Local euler rotation in radians of this node. </member> - <member name="rotation_deg" type="Vector3" setter="set_rotation_deg" getter="get_rotation_deg"> + <member name="rotation_degrees" type="Vector3" setter="set_rotation_degrees" getter="get_rotation_degrees"> Local euler rotation in degrees of this node. </member> <member name="scale" type="Vector3" setter="set_scale" getter="get_scale"> diff --git a/doc/classes/SpatialGizmo.xml b/doc/classes/SpatialGizmo.xml index 1612e80500..eaac74fe10 100644 --- a/doc/classes/SpatialGizmo.xml +++ b/doc/classes/SpatialGizmo.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpatialGizmo" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="SpatialGizmo" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/SpatialMaterial.xml b/doc/classes/SpatialMaterial.xml index db47875050..9f8b563373 100644 --- a/doc/classes/SpatialMaterial.xml +++ b/doc/classes/SpatialMaterial.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpatialMaterial" inherits="Material" category="Core" version="3.0.alpha.custom_build"> +<class name="SpatialMaterial" inherits="Material" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> @@ -135,6 +135,12 @@ <description> </description> </method> + <method name="get_emission_operator" qualifiers="const"> + <return type="int" enum="SpatialMaterial.EmissionOperator"> + </return> + <description> + </description> + </method> <method name="get_feature" qualifiers="const"> <return type="bool"> </return> @@ -523,6 +529,14 @@ <description> </description> </method> + <method name="set_emission_operator"> + <return type="void"> + </return> + <argument index="0" name="operator" type="int" enum="SpatialMaterial.EmissionOperator"> + </argument> + <description> + </description> + </method> <method name="set_feature"> <return type="void"> </return> @@ -843,6 +857,8 @@ </member> <member name="emission_energy" type="float" setter="set_emission_energy" getter="get_emission_energy"> </member> + <member name="emission_operator" type="int" setter="set_emission_operator" getter="get_emission_operator" enum="SpatialMaterial.EmissionOperator"> + </member> <member name="emission_texture" type="Texture" setter="set_texture" getter="get_texture"> </member> <member name="flags_fixed_size" type="bool" setter="set_flag" getter="get_flag"> @@ -1113,5 +1129,9 @@ </constant> <constant name="TEXTURE_CHANNEL_GRAYSCALE" value="4"> </constant> + <constant name="EMISSION_OP_ADD" value="0"> + </constant> + <constant name="EMISSION_OP_MULTIPLY" value="1"> + </constant> </constants> </class> diff --git a/doc/classes/SpatialVelocityTracker.xml b/doc/classes/SpatialVelocityTracker.xml index 95871c8cdc..62d3f02c89 100644 --- a/doc/classes/SpatialVelocityTracker.xml +++ b/doc/classes/SpatialVelocityTracker.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpatialVelocityTracker" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="SpatialVelocityTracker" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/SphereMesh.xml b/doc/classes/SphereMesh.xml index 0ae48cb7d7..42af9cd6b8 100644 --- a/doc/classes/SphereMesh.xml +++ b/doc/classes/SphereMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SphereMesh" inherits="PrimitiveMesh" category="Core" version="3.0.alpha.custom_build"> +<class name="SphereMesh" inherits="PrimitiveMesh" category="Core" version="3.0-alpha"> <brief_description> Class representing a spherical [PrimitiveMesh]. </brief_description> diff --git a/doc/classes/SphereShape.xml b/doc/classes/SphereShape.xml index 7c6174f4e4..28f96b0028 100644 --- a/doc/classes/SphereShape.xml +++ b/doc/classes/SphereShape.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SphereShape" inherits="Shape" category="Core" version="3.0.alpha.custom_build"> +<class name="SphereShape" inherits="Shape" category="Core" version="3.0-alpha"> <brief_description> Sphere shape for 3D collisions. </brief_description> diff --git a/doc/classes/SpinBox.xml b/doc/classes/SpinBox.xml index 31ef1865e9..e0c0a88148 100644 --- a/doc/classes/SpinBox.xml +++ b/doc/classes/SpinBox.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpinBox" inherits="Range" category="Core" version="3.0.alpha.custom_build"> +<class name="SpinBox" inherits="Range" category="Core" version="3.0-alpha"> <brief_description> Numerical input text field. </brief_description> diff --git a/doc/classes/SplitContainer.xml b/doc/classes/SplitContainer.xml index 861a483f6d..50ed6a5f64 100644 --- a/doc/classes/SplitContainer.xml +++ b/doc/classes/SplitContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SplitContainer" inherits="Container" category="Core" version="3.0.alpha.custom_build"> +<class name="SplitContainer" inherits="Container" category="Core" version="3.0-alpha"> <brief_description> Container for splitting and adjusting. </brief_description> diff --git a/doc/classes/SpotLight.xml b/doc/classes/SpotLight.xml index 430e7c4a26..ce58791171 100644 --- a/doc/classes/SpotLight.xml +++ b/doc/classes/SpotLight.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpotLight" inherits="Light" category="Core" version="3.0.alpha.custom_build"> +<class name="SpotLight" inherits="Light" category="Core" version="3.0-alpha"> <brief_description> Spotlight [Light], such as a reflector spotlight or a lantern. </brief_description> diff --git a/doc/classes/Sprite.xml b/doc/classes/Sprite.xml index 0cdc8f7099..7996adab51 100644 --- a/doc/classes/Sprite.xml +++ b/doc/classes/Sprite.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Sprite" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="Sprite" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> General purpose Sprite node. </brief_description> diff --git a/doc/classes/Sprite3D.xml b/doc/classes/Sprite3D.xml index e51616a071..5354d8c819 100644 --- a/doc/classes/Sprite3D.xml +++ b/doc/classes/Sprite3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Sprite3D" inherits="SpriteBase3D" category="Core" version="3.0.alpha.custom_build"> +<class name="Sprite3D" inherits="SpriteBase3D" category="Core" version="3.0-alpha"> <brief_description> 2D Sprite node in 3D world. </brief_description> diff --git a/doc/classes/SpriteBase3D.xml b/doc/classes/SpriteBase3D.xml index f6c3367704..69537cd884 100644 --- a/doc/classes/SpriteBase3D.xml +++ b/doc/classes/SpriteBase3D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpriteBase3D" inherits="GeometryInstance" category="Core" version="3.0.alpha.custom_build"> +<class name="SpriteBase3D" inherits="GeometryInstance" category="Core" version="3.0-alpha"> <brief_description> 2D Sprite node in 3D environment. </brief_description> diff --git a/doc/classes/SpriteFrames.xml b/doc/classes/SpriteFrames.xml index e46fdc80e0..336b155689 100644 --- a/doc/classes/SpriteFrames.xml +++ b/doc/classes/SpriteFrames.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SpriteFrames" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="SpriteFrames" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Sprite frame library for AnimatedSprite. </brief_description> diff --git a/doc/classes/StaticBody.xml b/doc/classes/StaticBody.xml index 6b5b007310..a008f0b99c 100644 --- a/doc/classes/StaticBody.xml +++ b/doc/classes/StaticBody.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StaticBody" inherits="PhysicsBody" category="Core" version="3.0.alpha.custom_build"> +<class name="StaticBody" inherits="PhysicsBody" category="Core" version="3.0-alpha"> <brief_description> Static body for 3D Physics. </brief_description> diff --git a/doc/classes/StaticBody2D.xml b/doc/classes/StaticBody2D.xml index cff41074b8..9f1f79ad59 100644 --- a/doc/classes/StaticBody2D.xml +++ b/doc/classes/StaticBody2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StaticBody2D" inherits="PhysicsBody2D" category="Core" version="3.0.alpha.custom_build"> +<class name="StaticBody2D" inherits="PhysicsBody2D" category="Core" version="3.0-alpha"> <brief_description> Static body for 2D Physics. </brief_description> diff --git a/doc/classes/StreamPeer.xml b/doc/classes/StreamPeer.xml index 077de3dc3c..4f92a524b1 100644 --- a/doc/classes/StreamPeer.xml +++ b/doc/classes/StreamPeer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StreamPeer" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="StreamPeer" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Abstraction and base class for stream-based protocols. </brief_description> diff --git a/doc/classes/StreamPeerBuffer.xml b/doc/classes/StreamPeerBuffer.xml index 141d46564c..5c67598285 100644 --- a/doc/classes/StreamPeerBuffer.xml +++ b/doc/classes/StreamPeerBuffer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StreamPeerBuffer" inherits="StreamPeer" category="Core" version="3.0.alpha.custom_build"> +<class name="StreamPeerBuffer" inherits="StreamPeer" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/StreamPeerSSL.xml b/doc/classes/StreamPeerSSL.xml index 5eb3f551f4..59d0e492e4 100644 --- a/doc/classes/StreamPeerSSL.xml +++ b/doc/classes/StreamPeerSSL.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StreamPeerSSL" inherits="StreamPeer" category="Core" version="3.0.alpha.custom_build"> +<class name="StreamPeerSSL" inherits="StreamPeer" category="Core" version="3.0-alpha"> <brief_description> SSL Stream peer. </brief_description> diff --git a/doc/classes/StreamPeerTCP.xml b/doc/classes/StreamPeerTCP.xml index 9b7cd91ea5..3df68d0926 100644 --- a/doc/classes/StreamPeerTCP.xml +++ b/doc/classes/StreamPeerTCP.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StreamPeerTCP" inherits="StreamPeer" category="Core" version="3.0.alpha.custom_build"> +<class name="StreamPeerTCP" inherits="StreamPeer" category="Core" version="3.0-alpha"> <brief_description> TCP Stream peer. </brief_description> diff --git a/doc/classes/StreamTexture.xml b/doc/classes/StreamTexture.xml index 6e6f2e8056..2a5ad36b25 100644 --- a/doc/classes/StreamTexture.xml +++ b/doc/classes/StreamTexture.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StreamTexture" inherits="Texture" category="Core" version="3.0.alpha.custom_build"> +<class name="StreamTexture" inherits="Texture" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index 546712f223..60c5e75dec 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="String" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="String" category="Built-In Types" version="3.0-alpha"> <brief_description> Built-in string class. </brief_description> @@ -95,10 +95,10 @@ <method name="String"> <return type="String"> </return> - <argument index="0" name="from" type="Rect3"> + <argument index="0" name="from" type="AABB"> </argument> <description> - Constructs a new String from the given [Rect3]. + Constructs a new String from the given [AABB]. </description> </method> <method name="String"> @@ -273,6 +273,12 @@ Performs a case-sensitive comparison to another string. Returns [code]-1[/code] if less than, [code]+1[/code] if greater than, or [code]0[/code] if equal. </description> </method> + <method name="dedent"> + <return type="String"> + </return> + <description> + </description> + </method> <method name="empty"> <return type="bool"> </return> diff --git a/doc/classes/StyleBox.xml b/doc/classes/StyleBox.xml index ab1ec1f997..c904522c7f 100644 --- a/doc/classes/StyleBox.xml +++ b/doc/classes/StyleBox.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StyleBox" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="StyleBox" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Base class for drawing stylized boxes for the UI. </brief_description> diff --git a/doc/classes/StyleBoxEmpty.xml b/doc/classes/StyleBoxEmpty.xml index f11959c41d..fd0e256e36 100644 --- a/doc/classes/StyleBoxEmpty.xml +++ b/doc/classes/StyleBoxEmpty.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StyleBoxEmpty" inherits="StyleBox" category="Core" version="3.0.alpha.custom_build"> +<class name="StyleBoxEmpty" inherits="StyleBox" category="Core" version="3.0-alpha"> <brief_description> Empty stylebox (does not display anything). </brief_description> diff --git a/doc/classes/StyleBoxFlat.xml b/doc/classes/StyleBoxFlat.xml index eb9f82af6c..ab1f733c5c 100644 --- a/doc/classes/StyleBoxFlat.xml +++ b/doc/classes/StyleBoxFlat.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StyleBoxFlat" inherits="StyleBox" category="Core" version="3.0.alpha.custom_build"> +<class name="StyleBoxFlat" inherits="StyleBox" category="Core" version="3.0-alpha"> <brief_description> Customizable Stylebox with a given set of parameters. (no texture required) </brief_description> diff --git a/doc/classes/StyleBoxLine.xml b/doc/classes/StyleBoxLine.xml new file mode 100644 index 0000000000..669d74416f --- /dev/null +++ b/doc/classes/StyleBoxLine.xml @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="StyleBoxLine" inherits="StyleBox" category="Core" version="3.0-alpha"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + <method name="get_color" qualifiers="const"> + <return type="Color"> + </return> + <description> + </description> + </method> + <method name="get_grow" qualifiers="const"> + <return type="float"> + </return> + <description> + </description> + </method> + <method name="get_thickness" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> + <method name="is_vertical" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="set_color"> + <return type="void"> + </return> + <argument index="0" name="color" type="Color"> + </argument> + <description> + </description> + </method> + <method name="set_grow"> + <return type="void"> + </return> + <argument index="0" name="grow" type="float"> + </argument> + <description> + </description> + </method> + <method name="set_thickness"> + <return type="void"> + </return> + <argument index="0" name="thickness" type="int"> + </argument> + <description> + </description> + </method> + <method name="set_vertical"> + <return type="void"> + </return> + <argument index="0" name="vertical" type="bool"> + </argument> + <description> + </description> + </method> + </methods> + <members> + <member name="color" type="Color" setter="set_color" getter="get_color"> + </member> + <member name="thickness" type="int" setter="set_thickness" getter="get_thickness"> + </member> + <member name="vertical" type="bool" setter="set_vertical" getter="is_vertical"> + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/StyleBoxTexture.xml b/doc/classes/StyleBoxTexture.xml index 458fdad99e..2b64b5d6bf 100644 --- a/doc/classes/StyleBoxTexture.xml +++ b/doc/classes/StyleBoxTexture.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="StyleBoxTexture" inherits="StyleBox" category="Core" version="3.0.alpha.custom_build"> +<class name="StyleBoxTexture" inherits="StyleBox" category="Core" version="3.0-alpha"> <brief_description> Texture Based 3x3 scale style. </brief_description> diff --git a/doc/classes/SurfaceTool.xml b/doc/classes/SurfaceTool.xml index 987a725977..93090d9d2e 100644 --- a/doc/classes/SurfaceTool.xml +++ b/doc/classes/SurfaceTool.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="SurfaceTool" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="SurfaceTool" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Helper tool to create geometry. </brief_description> diff --git a/doc/classes/TCP_Server.xml b/doc/classes/TCP_Server.xml index 97115619ad..20cdbe4231 100644 --- a/doc/classes/TCP_Server.xml +++ b/doc/classes/TCP_Server.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TCP_Server" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="TCP_Server" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> TCP Server. </brief_description> diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index a7dd86a459..4921690074 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TabContainer" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="TabContainer" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Tabbed Container. </brief_description> diff --git a/doc/classes/Tabs.xml b/doc/classes/Tabs.xml index d3893ab9a7..e007decf47 100644 --- a/doc/classes/Tabs.xml +++ b/doc/classes/Tabs.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Tabs" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="Tabs" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Tabs Control. </brief_description> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index 43e5158515..0e862a7903 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TextEdit" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="TextEdit" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Multiline text editing control. </brief_description> @@ -232,6 +232,13 @@ Insert a given text at the cursor position. </description> </method> + <method name="is_context_menu_enabled"> + <return type="bool"> + </return> + <description> + Returns true if the context menu is enabled. + </description> + </method> <method name="is_highlight_all_occurrences_enabled" qualifiers="const"> <return type="bool"> </return> @@ -251,6 +258,13 @@ <description> </description> </method> + <method name="is_readonly" qualifiers="const"> + <return type="bool"> + </return> + <description> + Return true if the text editor is in read-only mode (see [method set_readonly]). + </description> + </method> <method name="is_selection_active" qualifiers="const"> <return type="bool"> </return> @@ -337,6 +351,15 @@ Select all the text. </description> </method> + <method name="set_context_menu_enabled"> + <return type="void"> + </return> + <argument index="0" name="enable" type="bool"> + </argument> + <description> + Set the status of the context menu. When enabled, the context menu will appear when the [code]TextEdit[/code] is right clicked. + </description> + </method> <method name="set_highlight_all_occurrences"> <return type="void"> </return> @@ -447,18 +470,26 @@ </member> <member name="caret_block_mode" type="bool" setter="cursor_set_block_mode" getter="cursor_is_block_mode"> </member> + <member name="context_menu_enabled" type="bool" setter="set_context_menu_enabled" getter="is_context_menu_enabled"> + </member> <member name="highlight_all_occurrences" type="bool" setter="set_highlight_all_occurrences" getter="is_highlight_all_occurrences_enabled"> </member> <member name="highlight_current_line" type="bool" setter="set_highlight_current_line" getter="is_highlight_current_line_enabled"> </member> <member name="override_selected_font_color" type="bool" setter="set_override_selected_font_color" getter="is_overriding_selected_font_color"> </member> + <member name="readonly" type="bool" setter="set_readonly" getter="is_readonly"> + If [code]true[/code] read-only mode is enabled. Existing text cannot be modified and new text cannot be added. + </member> <member name="show_line_numbers" type="bool" setter="set_show_line_numbers" getter="is_show_line_numbers_enabled"> </member> <member name="smooth_scrolling" type="bool" setter="set_smooth_scroll_enable" getter="is_smooth_scroll_enabled"> </member> <member name="syntax_highlighting" type="bool" setter="set_syntax_coloring" getter="is_syntax_coloring_enabled"> </member> + <member name="text" type="String" setter="set_text" getter="get_text"> + String value of the [TextEdit]. + </member> <member name="v_scroll_speed" type="float" setter="set_v_scroll_speed" getter="get_v_scroll_speed"> </member> </members> diff --git a/doc/classes/Texture.xml b/doc/classes/Texture.xml index 93cba29d09..a856eb64ad 100644 --- a/doc/classes/Texture.xml +++ b/doc/classes/Texture.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Texture" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Texture" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Texture for 2D and 3D. </brief_description> diff --git a/doc/classes/TextureButton.xml b/doc/classes/TextureButton.xml index 8e51548c10..a6d935376a 100644 --- a/doc/classes/TextureButton.xml +++ b/doc/classes/TextureButton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TextureButton" inherits="BaseButton" category="Core" version="3.0.alpha.custom_build"> +<class name="TextureButton" inherits="BaseButton" category="Core" version="3.0-alpha"> <brief_description> Texture-based button. Supports Pressed, Hover, Disabled and Focused states. </brief_description> diff --git a/doc/classes/TextureProgress.xml b/doc/classes/TextureProgress.xml index f8165753c6..550c38920a 100644 --- a/doc/classes/TextureProgress.xml +++ b/doc/classes/TextureProgress.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TextureProgress" inherits="Range" category="Core" version="3.0.alpha.custom_build"> +<class name="TextureProgress" inherits="Range" category="Core" version="3.0-alpha"> <brief_description> Texture-based progress bar. Useful for loading screens and life or stamina bars. </brief_description> diff --git a/doc/classes/TextureRect.xml b/doc/classes/TextureRect.xml index af5626ae84..cef102e8ae 100644 --- a/doc/classes/TextureRect.xml +++ b/doc/classes/TextureRect.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TextureRect" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="TextureRect" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Draws a sprite or a texture inside a User Interface. The texture can tile or not. </brief_description> diff --git a/doc/classes/Theme.xml b/doc/classes/Theme.xml index 4dd45ac821..0a95a52e4f 100644 --- a/doc/classes/Theme.xml +++ b/doc/classes/Theme.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Theme" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Theme" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Theme for controls. </brief_description> diff --git a/doc/classes/Thread.xml b/doc/classes/Thread.xml index e2326ffe98..24bc4bb985 100644 --- a/doc/classes/Thread.xml +++ b/doc/classes/Thread.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Thread" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="Thread" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> A unit of execution in a process. </brief_description> diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml index c44fa500cd..c48f58f123 100644 --- a/doc/classes/TileMap.xml +++ b/doc/classes/TileMap.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TileMap" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="TileMap" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Node for 2D tile-based maps. </brief_description> @@ -59,6 +59,12 @@ Return true if tiles are to be centered in y coordinate (by default this is false and they are drawn from upper left cell corner). </description> </method> + <method name="get_clip_uv" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> <method name="get_collision_bounce" qualifiers="const"> <return type="float"> </return> @@ -298,6 +304,14 @@ Set tiles to be centered in y coordinate. (by default this is false and they are drawn from upper left cell corner). </description> </method> + <method name="set_clip_uv"> + <return type="void"> + </return> + <argument index="0" name="enable" type="bool"> + </argument> + <description> + </description> + </method> <method name="set_collision_bounce"> <return type="void"> </return> @@ -450,6 +464,8 @@ </method> </methods> <members> + <member name="cell_clip_uv" type="bool" setter="set_clip_uv" getter="get_clip_uv"> + </member> <member name="cell_custom_transform" type="Transform2D" setter="set_custom_transform" getter="get_custom_transform"> The custom [Transform2D] to be applied to the TileMap's cells. </member> diff --git a/doc/classes/TileSet.xml b/doc/classes/TileSet.xml index a858138144..a1063567f8 100644 --- a/doc/classes/TileSet.xml +++ b/doc/classes/TileSet.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TileSet" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="TileSet" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Tile library for tilemaps. </brief_description> diff --git a/doc/classes/Timer.xml b/doc/classes/Timer.xml index 035dec7980..8d834537a7 100644 --- a/doc/classes/Timer.xml +++ b/doc/classes/Timer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Timer" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="Timer" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> A countdown timer. </brief_description> diff --git a/doc/classes/ToolButton.xml b/doc/classes/ToolButton.xml index 7723dadb83..b541d00d2f 100644 --- a/doc/classes/ToolButton.xml +++ b/doc/classes/ToolButton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ToolButton" inherits="Button" category="Core" version="3.0.alpha.custom_build"> +<class name="ToolButton" inherits="Button" category="Core" version="3.0-alpha"> <brief_description> Flat button helper class. </brief_description> diff --git a/doc/classes/TouchScreenButton.xml b/doc/classes/TouchScreenButton.xml index 51cb7f86f2..283ead1b1b 100644 --- a/doc/classes/TouchScreenButton.xml +++ b/doc/classes/TouchScreenButton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TouchScreenButton" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="TouchScreenButton" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Button for touch screen devices. </brief_description> diff --git a/doc/classes/Transform.xml b/doc/classes/Transform.xml index cd80d568e7..9e1672e6f5 100644 --- a/doc/classes/Transform.xml +++ b/doc/classes/Transform.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Transform" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Transform" category="Built-In Types" version="3.0-alpha"> <brief_description> 3D Transformation. 3x4 matrix. </brief_description> diff --git a/doc/classes/Transform2D.xml b/doc/classes/Transform2D.xml index a9d71d7093..d17063b550 100644 --- a/doc/classes/Transform2D.xml +++ b/doc/classes/Transform2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Transform2D" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Transform2D" category="Built-In Types" version="3.0-alpha"> <brief_description> 2D Transformation. 3x2 matrix. </brief_description> diff --git a/doc/classes/Translation.xml b/doc/classes/Translation.xml index c0707d26b8..dc2609b3e1 100644 --- a/doc/classes/Translation.xml +++ b/doc/classes/Translation.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Translation" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="Translation" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Language Translation. </brief_description> diff --git a/doc/classes/TranslationServer.xml b/doc/classes/TranslationServer.xml index 1657541c19..8b50bf027b 100644 --- a/doc/classes/TranslationServer.xml +++ b/doc/classes/TranslationServer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TranslationServer" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="TranslationServer" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Server that manages all translations. Translations can be set to it and removed from it. </brief_description> diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index bf9245d23a..508a0ec194 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Tree" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="Tree" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Control to show a tree of items. </brief_description> diff --git a/doc/classes/TreeItem.xml b/doc/classes/TreeItem.xml index f0eb23b636..b463ef7bbb 100644 --- a/doc/classes/TreeItem.xml +++ b/doc/classes/TreeItem.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TreeItem" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="TreeItem" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Control for a single item inside a [Tree]. </brief_description> diff --git a/doc/classes/TriangleMesh.xml b/doc/classes/TriangleMesh.xml index 21b85c1d05..21a37913c8 100644 --- a/doc/classes/TriangleMesh.xml +++ b/doc/classes/TriangleMesh.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="TriangleMesh" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="TriangleMesh" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Tween.xml b/doc/classes/Tween.xml index b11498083b..822eee5838 100644 --- a/doc/classes/Tween.xml +++ b/doc/classes/Tween.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Tween" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="Tween" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Node useful for animations with unknown start and end points. </brief_description> diff --git a/doc/classes/UndoRedo.xml b/doc/classes/UndoRedo.xml index d450a8812e..718522aa57 100644 --- a/doc/classes/UndoRedo.xml +++ b/doc/classes/UndoRedo.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="UndoRedo" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="UndoRedo" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Helper to manage UndoRedo in the editor or custom tools. </brief_description> diff --git a/doc/classes/VBoxContainer.xml b/doc/classes/VBoxContainer.xml index de544ed031..b64b04437a 100644 --- a/doc/classes/VBoxContainer.xml +++ b/doc/classes/VBoxContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VBoxContainer" inherits="BoxContainer" category="Core" version="3.0.alpha.custom_build"> +<class name="VBoxContainer" inherits="BoxContainer" category="Core" version="3.0-alpha"> <brief_description> Vertical box container. </brief_description> diff --git a/doc/classes/VScrollBar.xml b/doc/classes/VScrollBar.xml index 4510ac1e2e..5e5ed6f211 100644 --- a/doc/classes/VScrollBar.xml +++ b/doc/classes/VScrollBar.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VScrollBar" inherits="ScrollBar" category="Core" version="3.0.alpha.custom_build"> +<class name="VScrollBar" inherits="ScrollBar" category="Core" version="3.0-alpha"> <brief_description> Vertical version of [ScrollBar], which goes from left (min) to right (max). </brief_description> diff --git a/doc/classes/VSeparator.xml b/doc/classes/VSeparator.xml index f98473a148..88c043f9ca 100644 --- a/doc/classes/VSeparator.xml +++ b/doc/classes/VSeparator.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VSeparator" inherits="Separator" category="Core" version="3.0.alpha.custom_build"> +<class name="VSeparator" inherits="Separator" category="Core" version="3.0-alpha"> <brief_description> Vertical version of [Separator]. </brief_description> diff --git a/doc/classes/VSlider.xml b/doc/classes/VSlider.xml index fa4fa34d54..bc0a3a25b6 100644 --- a/doc/classes/VSlider.xml +++ b/doc/classes/VSlider.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VSlider" inherits="Slider" category="Core" version="3.0.alpha.custom_build"> +<class name="VSlider" inherits="Slider" category="Core" version="3.0-alpha"> <brief_description> Vertical slider. </brief_description> diff --git a/doc/classes/VSplitContainer.xml b/doc/classes/VSplitContainer.xml index aac10841c3..e5a8981aaf 100644 --- a/doc/classes/VSplitContainer.xml +++ b/doc/classes/VSplitContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VSplitContainer" inherits="SplitContainer" category="Core" version="3.0.alpha.custom_build"> +<class name="VSplitContainer" inherits="SplitContainer" category="Core" version="3.0-alpha"> <brief_description> Vertical split container. </brief_description> diff --git a/doc/classes/Variant.xml b/doc/classes/Variant.xml index 914ef10036..14df6f050f 100644 --- a/doc/classes/Variant.xml +++ b/doc/classes/Variant.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Variant" category="Core" version="3.0.alpha.custom_build"> +<class name="Variant" category="Core" version="3.0-alpha"> <brief_description> The most important data type in Godot. </brief_description> diff --git a/doc/classes/Vector2.xml b/doc/classes/Vector2.xml index 510559327f..3afad1d6fa 100644 --- a/doc/classes/Vector2.xml +++ b/doc/classes/Vector2.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Vector2" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Vector2" category="Built-In Types" version="3.0-alpha"> <brief_description> Vector used for 2D Math. </brief_description> diff --git a/doc/classes/Vector3.xml b/doc/classes/Vector3.xml index a05bc5db9a..cec5970f06 100644 --- a/doc/classes/Vector3.xml +++ b/doc/classes/Vector3.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Vector3" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="Vector3" category="Built-In Types" version="3.0-alpha"> <brief_description> Vector class, which performs basic 3D vector math operations. </brief_description> diff --git a/doc/classes/VehicleBody.xml b/doc/classes/VehicleBody.xml index 48202665fb..f9f3590385 100644 --- a/doc/classes/VehicleBody.xml +++ b/doc/classes/VehicleBody.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VehicleBody" inherits="PhysicsBody" category="Core" version="3.0.alpha.custom_build"> +<class name="VehicleBody" inherits="PhysicsBody" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VehicleWheel.xml b/doc/classes/VehicleWheel.xml index b2e54e25bc..f04c33cc5a 100644 --- a/doc/classes/VehicleWheel.xml +++ b/doc/classes/VehicleWheel.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VehicleWheel" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="VehicleWheel" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VideoPlayer.xml b/doc/classes/VideoPlayer.xml index 5387ec30b3..340b162727 100644 --- a/doc/classes/VideoPlayer.xml +++ b/doc/classes/VideoPlayer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VideoPlayer" inherits="Control" category="Core" version="3.0.alpha.custom_build"> +<class name="VideoPlayer" inherits="Control" category="Core" version="3.0-alpha"> <brief_description> Control to play video files. </brief_description> @@ -25,6 +25,12 @@ Get the amount of milliseconds to store in buffer while playing. </description> </method> + <method name="get_bus" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> <method name="get_stream" qualifiers="const"> <return type="VideoStream"> </return> @@ -129,6 +135,14 @@ Set the amount of milliseconds to buffer during playback. </description> </method> + <method name="set_bus"> + <return type="void"> + </return> + <argument index="0" name="bus" type="String"> + </argument> + <description> + </description> + </method> <method name="set_expand"> <return type="void"> </return> @@ -196,6 +210,8 @@ </member> <member name="autoplay" type="bool" setter="set_autoplay" getter="has_autoplay"> </member> + <member name="bus" type="String" setter="set_bus" getter="get_bus"> + </member> <member name="expand" type="bool" setter="set_expand" getter="has_expand"> </member> <member name="paused" type="bool" setter="set_paused" getter="is_paused"> diff --git a/doc/classes/VideoStream.xml b/doc/classes/VideoStream.xml index c282cdfbd0..00607b0f0a 100644 --- a/doc/classes/VideoStream.xml +++ b/doc/classes/VideoStream.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VideoStream" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="VideoStream" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 28a7cb7c8e..9bd229ef26 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="Viewport" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="Viewport" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Creates a sub-view into the screen. </brief_description> diff --git a/doc/classes/ViewportContainer.xml b/doc/classes/ViewportContainer.xml index d4d42ad4fb..5a4c3af1f6 100644 --- a/doc/classes/ViewportContainer.xml +++ b/doc/classes/ViewportContainer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ViewportContainer" inherits="Container" category="Core" version="3.0.alpha.custom_build"> +<class name="ViewportContainer" inherits="Container" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> @@ -9,6 +9,12 @@ <demos> </demos> <methods> + <method name="get_stretch_shrink" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> <method name="is_stretch_enabled" qualifiers="const"> <return type="bool"> </return> @@ -23,10 +29,20 @@ <description> </description> </method> + <method name="set_stretch_shrink"> + <return type="void"> + </return> + <argument index="0" name="amount" type="int"> + </argument> + <description> + </description> + </method> </methods> <members> <member name="stretch" type="bool" setter="set_stretch" getter="is_stretch_enabled"> </member> + <member name="stretch_shrink" type="int" setter="set_stretch_shrink" getter="get_stretch_shrink"> + </member> </members> <constants> </constants> diff --git a/doc/classes/ViewportTexture.xml b/doc/classes/ViewportTexture.xml index f2515cbcc7..1eace840a8 100644 --- a/doc/classes/ViewportTexture.xml +++ b/doc/classes/ViewportTexture.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ViewportTexture" inherits="Texture" category="Core" version="3.0.alpha.custom_build"> +<class name="ViewportTexture" inherits="Texture" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisibilityEnabler.xml b/doc/classes/VisibilityEnabler.xml index 881ba91fad..95bcbd6816 100644 --- a/doc/classes/VisibilityEnabler.xml +++ b/doc/classes/VisibilityEnabler.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisibilityEnabler" inherits="VisibilityNotifier" category="Core" version="3.0.alpha.custom_build"> +<class name="VisibilityEnabler" inherits="VisibilityNotifier" category="Core" version="3.0-alpha"> <brief_description> Enable certain nodes only when visible. </brief_description> diff --git a/doc/classes/VisibilityEnabler2D.xml b/doc/classes/VisibilityEnabler2D.xml index b881de4f91..f23d54a544 100644 --- a/doc/classes/VisibilityEnabler2D.xml +++ b/doc/classes/VisibilityEnabler2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisibilityEnabler2D" inherits="VisibilityNotifier2D" category="Core" version="3.0.alpha.custom_build"> +<class name="VisibilityEnabler2D" inherits="VisibilityNotifier2D" category="Core" version="3.0-alpha"> <brief_description> Enable certain nodes only when visible. </brief_description> diff --git a/doc/classes/VisibilityNotifier.xml b/doc/classes/VisibilityNotifier.xml index 816523fc27..90f1974697 100644 --- a/doc/classes/VisibilityNotifier.xml +++ b/doc/classes/VisibilityNotifier.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisibilityNotifier" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="VisibilityNotifier" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Detects when the node is visible on screen. </brief_description> @@ -12,7 +12,7 @@ </demos> <methods> <method name="get_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> Returns the bounding box of the VisibilityNotifier. @@ -28,7 +28,7 @@ <method name="set_aabb"> <return type="void"> </return> - <argument index="0" name="rect" type="Rect3"> + <argument index="0" name="rect" type="AABB"> </argument> <description> Set the visibility bounding box of the VisibilityNotifier. @@ -36,7 +36,7 @@ </method> </methods> <members> - <member name="aabb" type="Rect3" setter="set_aabb" getter="get_aabb"> + <member name="aabb" type="AABB" setter="set_aabb" getter="get_aabb"> The VisibilityNotifier's bounding box. </member> </members> diff --git a/doc/classes/VisibilityNotifier2D.xml b/doc/classes/VisibilityNotifier2D.xml index 86227a0277..b8db14e583 100644 --- a/doc/classes/VisibilityNotifier2D.xml +++ b/doc/classes/VisibilityNotifier2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisibilityNotifier2D" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="VisibilityNotifier2D" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Detects when the node is visible on screen. </brief_description> diff --git a/doc/classes/VisualInstance.xml b/doc/classes/VisualInstance.xml index ed317882a8..7108eb13c5 100644 --- a/doc/classes/VisualInstance.xml +++ b/doc/classes/VisualInstance.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualInstance" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualInstance" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> @@ -10,7 +10,7 @@ </demos> <methods> <method name="get_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> @@ -22,7 +22,7 @@ </description> </method> <method name="get_transformed_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <description> </description> diff --git a/doc/classes/VisualServer.xml b/doc/classes/VisualServer.xml index 8e3cb8ee50..d716d99e5d 100644 --- a/doc/classes/VisualServer.xml +++ b/doc/classes/VisualServer.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualServer" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualServer" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> Server for anything visible. </brief_description> @@ -1035,7 +1035,7 @@ </description> </method> <method name="mesh_get_custom_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <argument index="0" name="mesh" type="RID"> </argument> @@ -1085,13 +1085,13 @@ </return> <argument index="0" name="mesh" type="RID"> </argument> - <argument index="1" name="aabb" type="Rect3"> + <argument index="1" name="aabb" type="AABB"> </argument> <description> </description> </method> <method name="mesh_surface_get_aabb" qualifiers="const"> - <return type="Rect3"> + <return type="AABB"> </return> <argument index="0" name="mesh" type="RID"> </argument> @@ -1791,6 +1791,12 @@ </description> </method> </methods> + <signals> + <signal name="frame_drawn_in_thread"> + <description> + </description> + </signal> + </signals> <constants> <constant name="NO_INDEX_ARRAY" value="-1" enum=""> </constant> diff --git a/doc/classes/WeakRef.xml b/doc/classes/WeakRef.xml index 23629881d3..00e5bdfd2c 100644 --- a/doc/classes/WeakRef.xml +++ b/doc/classes/WeakRef.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="WeakRef" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="WeakRef" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Holds an [Object], but does not contribute to the reference count if the object is a reference. </brief_description> diff --git a/doc/classes/WindowDialog.xml b/doc/classes/WindowDialog.xml index e57983c367..a6ebd45a76 100644 --- a/doc/classes/WindowDialog.xml +++ b/doc/classes/WindowDialog.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="WindowDialog" inherits="Popup" category="Core" version="3.0.alpha.custom_build"> +<class name="WindowDialog" inherits="Popup" category="Core" version="3.0-alpha"> <brief_description> Base class for window dialogs. </brief_description> diff --git a/doc/classes/World.xml b/doc/classes/World.xml index f4f5f5b756..6d243f26a5 100644 --- a/doc/classes/World.xml +++ b/doc/classes/World.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="World" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="World" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Class that has everything pertaining to a world. </brief_description> diff --git a/doc/classes/World2D.xml b/doc/classes/World2D.xml index d57117fef0..bf3cc9f24b 100644 --- a/doc/classes/World2D.xml +++ b/doc/classes/World2D.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="World2D" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="World2D" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> Class that has everything pertaining to a 2D world. </brief_description> diff --git a/doc/classes/WorldEnvironment.xml b/doc/classes/WorldEnvironment.xml index 561cd09f43..13922b4987 100644 --- a/doc/classes/WorldEnvironment.xml +++ b/doc/classes/WorldEnvironment.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="WorldEnvironment" inherits="Node" category="Core" version="3.0.alpha.custom_build"> +<class name="WorldEnvironment" inherits="Node" category="Core" version="3.0-alpha"> <brief_description> Sets environment properties for the entire scene </brief_description> diff --git a/doc/classes/XMLParser.xml b/doc/classes/XMLParser.xml index bb9599e273..5e7ba3b4bf 100644 --- a/doc/classes/XMLParser.xml +++ b/doc/classes/XMLParser.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="XMLParser" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="XMLParser" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> Low-level class for creating parsers for XML files. </brief_description> diff --git a/doc/classes/YSort.xml b/doc/classes/YSort.xml index 3c0c8b3d06..de4c8be11a 100644 --- a/doc/classes/YSort.xml +++ b/doc/classes/YSort.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="YSort" inherits="Node2D" category="Core" version="3.0.alpha.custom_build"> +<class name="YSort" inherits="Node2D" category="Core" version="3.0-alpha"> <brief_description> Sort all child nodes based on their Y positions. </brief_description> diff --git a/doc/classes/bool.xml b/doc/classes/bool.xml index 1d662ba946..f596180bcf 100644 --- a/doc/classes/bool.xml +++ b/doc/classes/bool.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="bool" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="bool" category="Built-In Types" version="3.0-alpha"> <brief_description> Boolean built-in type </brief_description> diff --git a/doc/classes/float.xml b/doc/classes/float.xml index 942aa4d55a..703ca55be8 100644 --- a/doc/classes/float.xml +++ b/doc/classes/float.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="float" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="float" category="Built-In Types" version="3.0-alpha"> <brief_description> Float built-in type </brief_description> diff --git a/doc/classes/int.xml b/doc/classes/int.xml index 7c2267ac9a..79a198b198 100644 --- a/doc/classes/int.xml +++ b/doc/classes/int.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="int" category="Built-In Types" version="3.0.alpha.custom_build"> +<class name="int" category="Built-In Types" version="3.0-alpha"> <brief_description> Integer built-in type. </brief_description> diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index dc015d781b..cd0108019b 100644 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -7,6 +7,7 @@ import os import xml.etree.ElementTree as ET input_list = [] +cur_file = "" for arg in sys.argv[1:]: if arg.endswith(os.sep): @@ -206,6 +207,7 @@ def rstize_text(text, cclass): elif cmd == '/code': tag_text = '``' inside_code = False + escape_post = True elif inside_code: tag_text = '[' + tag_text + ']' elif cmd.find('html') == 0: @@ -217,7 +219,10 @@ def rstize_text(text, cclass): param = tag_text[space_pos + 1:] if param.find('.') != -1: - (class_param, method_param) = param.split('.') + ss = param.split('.') + if len(ss) > 2: + sys.exit("Bad reference: '" + param + "' in file: " + cur_file) + (class_param, method_param) = ss tag_text = ':ref:`' + class_param + '.' + method_param + '<class_' + class_param + '_' + method_param + '>`' else: tag_text = ':ref:`' + param + '<class_' + cclass + "_" + param + '>`' @@ -519,8 +524,8 @@ for path in input_list: elif os.path.isfile(path) and path.endswith('.xml'): file_list.append(path) -for file in file_list: - tree = ET.parse(file) +for cur_file in file_list: + tree = ET.parse(cur_file) doc = tree.getroot() if 'version' not in doc.attrib: diff --git a/drivers/SCsub b/drivers/SCsub index 34d6254578..938927f3a9 100644 --- a/drivers/SCsub +++ b/drivers/SCsub @@ -34,7 +34,12 @@ if env['tools']: SConscript("convex_decomp/SCsub") if env['vsproj']: + import os + path = os.getcwd() + # Change directory so the path resolves correctly in the function call. + os.chdir("..") env.AddToVSProject(env.drivers_sources) + os.chdir(path) if env.split_drivers: env.split_lib("drivers") diff --git a/drivers/gl_context/context_gl.cpp b/drivers/gl_context/context_gl.cpp index a453eef227..1581512369 100644 --- a/drivers/gl_context/context_gl.cpp +++ b/drivers/gl_context/context_gl.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "context_gl.h" -#if defined(OPENGL_ENABLED) || defined(GLES2_ENABLED) +#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED) ContextGL *ContextGL::singleton = NULL; diff --git a/drivers/gl_context/context_gl.h b/drivers/gl_context/context_gl.h index 399657eb52..3496f2948c 100644 --- a/drivers/gl_context/context_gl.h +++ b/drivers/gl_context/context_gl.h @@ -30,7 +30,7 @@ #ifndef CONTEXT_GL_H #define CONTEXT_GL_H -#if defined(OPENGL_ENABLED) || defined(GLES2_ENABLED) +#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED) #include "typedefs.h" diff --git a/drivers/gles3/rasterizer_canvas_gles3.cpp b/drivers/gles3/rasterizer_canvas_gles3.cpp index 5d62d2f5a0..308a18aa9d 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_gles3.cpp @@ -149,13 +149,6 @@ void RasterizerCanvasGLES3::canvas_begin() { storage->frame.clear_request = false; } - /*canvas_shader.unbind(); - canvas_shader.set_custom_shader(0); - canvas_shader.set_conditional(CanvasShaderGLES2::USE_MODULATE,false); - canvas_shader.bind(); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXTURE, 0); - canvas_use_modulate=false;*/ - reset_canvas(); state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_TEXTURE_RECT, true); @@ -911,61 +904,6 @@ void RasterizerCanvasGLES3::_canvas_item_render_commands(Item *p_item, Item *cur } } -#if 0 -void RasterizerGLES2::_canvas_item_setup_shader_params(ShaderMaterial *material,Shader* shader) { - - if (canvas_shader.bind()) - rebind_texpixel_size=true; - - if (material->shader_version!=shader->version) { - //todo optimize uniforms - material->shader_version=shader->version; - } - - if (shader->has_texscreen && framebuffer.active) { - - int x = viewport.x; - int y = window_size.height-(viewport.height+viewport.y); - - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_MULT,Vector2(float(viewport.width)/framebuffer.width,float(viewport.height)/framebuffer.height)); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_CLAMP,Color(float(x)/framebuffer.width,float(y)/framebuffer.height,float(x+viewport.width)/framebuffer.width,float(y+viewport.height)/framebuffer.height)); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_TEX,max_texture_units-1); - glActiveTexture(GL_TEXTURE0+max_texture_units-1); - glBindTexture(GL_TEXTURE_2D,framebuffer.sample_color); - if (framebuffer.scale==1 && !canvas_texscreen_used) { -#ifdef GLEW_ENABLED - if (current_rt) { - glReadBuffer(GL_COLOR_ATTACHMENT0); - } else { - glReadBuffer(GL_BACK); - } -#endif - if (current_rt) { - glCopyTexSubImage2D(GL_TEXTURE_2D,0,viewport.x,viewport.y,viewport.x,viewport.y,viewport.width,viewport.height); - canvas_shader.set_uniform(CanvasShaderGLES2::TEXSCREEN_SCREEN_CLAMP,Color(float(x)/framebuffer.width,float(viewport.y)/framebuffer.height,float(x+viewport.width)/framebuffer.width,float(y+viewport.height)/framebuffer.height)); - //window_size.height-(viewport.height+viewport.y) - } else { - glCopyTexSubImage2D(GL_TEXTURE_2D,0,x,y,x,y,viewport.width,viewport.height); - } - - canvas_texscreen_used=true; - } - - glActiveTexture(GL_TEXTURE0); - - } - - if (shader->has_screen_uv) { - canvas_shader.set_uniform(CanvasShaderGLES2::SCREEN_UV_MULT,Vector2(1.0/viewport.width,1.0/viewport.height)); - } - - - uses_texpixel_size=shader->uses_texpixel_size; - -} - -#endif - void RasterizerCanvasGLES3::_copy_texscreen(const Rect2 &p_rect) { glDisable(GL_BLEND); @@ -1570,6 +1508,7 @@ void RasterizerCanvasGLES3::reset_canvas() { glDisable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); glDisable(GL_SCISSOR_TEST); + glDisable(GL_DITHER); glEnable(GL_BLEND); glBlendEquation(GL_FUNC_ADD); if (storage->frame.current_rt && storage->frame.current_rt->flags[RasterizerStorage::RENDER_TARGET_TRANSPARENT]) { diff --git a/drivers/gles3/rasterizer_gles3.cpp b/drivers/gles3/rasterizer_gles3.cpp index 72a3c3256b..ee61481a86 100644 --- a/drivers/gles3/rasterizer_gles3.cpp +++ b/drivers/gles3/rasterizer_gles3.cpp @@ -141,53 +141,48 @@ void RasterizerGLES3::initialize() { print_line("Using GLES3 video driver"); } -#ifdef GLEW_ENABLED - GLuint res = glewInit(); - ERR_FAIL_COND(res != GLEW_OK); - if (OS::get_singleton()->is_stdout_verbose()) { - print_line(String("GLES2: Using GLEW ") + (const char *)glewGetString(GLEW_VERSION)); +#ifdef GLAD_ENABLED + if (!gladLoadGL()) { + ERR_PRINT("Error initializing GLAD"); } - // Check for GL 2.1 compatibility, if not bail out - if (!glewIsSupported("GL_VERSION_3_0")) { - ERR_PRINT("Your system's graphic drivers seem not to support OpenGL 3.0+ / GLES 3.0, sorry :(\n" +// GLVersion seems to be used for both GL and GL ES, so we need different version checks for them +#ifdef OPENGL_ENABLED // OpenGL 3.3 Core Profile required + if (GLVersion.major < 3 && GLVersion.minor < 3) { +#else // OpenGL ES 3.0 + if (GLVersion.major < 3) { +#endif + ERR_PRINT("Your system's graphic drivers seem not to support OpenGL 3.3 / OpenGL ES 3.0, sorry :(\n" "Try a drivers update, buy a new GPU or try software rendering on Linux; Godot will now crash with a segmentation fault."); - OS::get_singleton()->alert("Your system's graphic drivers seem not to support OpenGL 3.0+ / GLES 3.0, sorry :(\n" + OS::get_singleton()->alert("Your system's graphic drivers seem not to support OpenGL 3.3 / OpenGL ES 3.0, sorry :(\n" "Godot Engine will self-destruct as soon as you acknowledge this error message.", - "Fatal error: Insufficient OpenGL / GLES drivers"); - // TODO: If it's even possible, we should stop the execution without segfault and memory leaks :) - } -#endif - -#ifdef GLAD_ENABLED - - if (!gladLoadGL()) { - ERR_PRINT("Error initializing GLAD"); + "Fatal error: Insufficient OpenGL / GLES driver support"); } #ifdef __APPLE__ // FIXME glDebugMessageCallbackARB does not seem to work on Mac OS X and opengl 3, this may be an issue with our opengl canvas.. #else - glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB); - glDebugMessageCallbackARB(_gl_debug_print, NULL); - glEnable(_EXT_DEBUG_OUTPUT); + if (OS::get_singleton()->is_stdout_verbose()) { + glEnable(_EXT_DEBUG_OUTPUT_SYNCHRONOUS_ARB); + glDebugMessageCallbackARB(_gl_debug_print, NULL); + glEnable(_EXT_DEBUG_OUTPUT); + } #endif -#endif +#endif // GLAD_ENABLED - /* glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_ERROR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); + /* // For debugging + glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_ERROR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_PORTABILITY_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_PERFORMANCE_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageControlARB(GL_DEBUG_SOURCE_API_ARB,GL_DEBUG_TYPE_OTHER_ARB,GL_DEBUG_SEVERITY_HIGH_ARB,0,NULL,GL_TRUE); glDebugMessageInsertARB( - GL_DEBUG_SOURCE_API_ARB, GL_DEBUG_TYPE_OTHER_ARB, 1, GL_DEBUG_SEVERITY_HIGH_ARB,5, "hello"); - -*/ + */ const GLubyte *renderer = glGetString(GL_RENDERER); print_line("OpenGL ES 3.0 Renderer: " + String((const char *)renderer)); diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 8ec988bec1..0c57e4e9cf 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1134,9 +1134,9 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m state.current_depth_draw = p_material->shader->spatial.depth_draw_mode; } - //glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); +//glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - /* +/* if (p_material->flags[VS::MATERIAL_FLAG_WIREFRAME]) glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); else @@ -4282,7 +4282,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const if (i > 0) { glEnable(GL_BLEND); } - _setup_directional_light(i, p_cam_transform.affine_inverse(), shadow_atlas != NULL); + _setup_directional_light(i, p_cam_transform.affine_inverse(), shadow_atlas != NULL && shadow_atlas->size > 0); _render_list(render_list.elements, render_list.element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, false, false, i > 0, shadow_atlas != NULL); } } @@ -4345,7 +4345,7 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const } else { for (int i = 0; i < state.directional_light_count; i++) { directional_light = directional_lights[i]; - _setup_directional_light(i, p_cam_transform.affine_inverse(), shadow_atlas != NULL); + _setup_directional_light(i, p_cam_transform.affine_inverse(), shadow_atlas != NULL && shadow_atlas->size > 0); _render_list(&render_list.elements[render_list.max_elements - render_list.alpha_element_count], render_list.alpha_element_count, p_cam_transform, p_cam_projection, env_radiance_tex, false, true, false, i > 0, shadow_atlas != NULL); } } diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 296d945cda..a41d84a2aa 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -2600,7 +2600,7 @@ RID RasterizerStorageGLES3::mesh_create() { return mesh_owner.make_rid(mesh); } -void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<Rect3> &p_bone_aabbs) { +void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) { PoolVector<uint8_t> array = p_array; @@ -2866,7 +2866,7 @@ void RasterizerStorageGLES3::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: glGenBuffers(1, &surface->vertex_id); glBindBuffer(GL_ARRAY_BUFFER, surface->vertex_id); - glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), GL_STATIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, array_size, vr.ptr(), p_format & VS::ARRAY_FLAG_USE_DYNAMIC_UPDATE ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind if (p_format & VS::ARRAY_FORMAT_INDEX) { @@ -3104,6 +3104,22 @@ VS::BlendShapeMode RasterizerStorageGLES3::mesh_get_blend_shape_mode(RID p_mesh) return mesh->blend_shape_mode; } +void RasterizerStorageGLES3::mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) { + + Mesh *mesh = mesh_owner.getornull(p_mesh); + ERR_FAIL_COND(!mesh); + ERR_FAIL_INDEX(p_surface, mesh->surfaces.size()); + + int total_size = p_data.size(); + ERR_FAIL_COND(p_offset + total_size > mesh->surfaces[p_surface]->array_byte_size); + + PoolVector<uint8_t>::Read r = p_data.read(); + + glBindBuffer(GL_ARRAY_BUFFER, mesh->surfaces[p_surface]->array_id); + glBufferSubData(GL_ARRAY_BUFFER, p_offset, total_size, r.ptr()); + glBindBuffer(GL_ARRAY_BUFFER, 0); //unbind +} + void RasterizerStorageGLES3::mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) { Mesh *mesh = mesh_owner.getornull(p_mesh); @@ -3224,11 +3240,11 @@ VS::PrimitiveType RasterizerStorageGLES3::mesh_surface_get_primitive_type(RID p_ return mesh->surfaces[p_surface]->primitive; } -Rect3 RasterizerStorageGLES3::mesh_surface_get_aabb(RID p_mesh, int p_surface) const { +AABB RasterizerStorageGLES3::mesh_surface_get_aabb(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, Rect3()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Rect3()); + ERR_FAIL_COND_V(!mesh, AABB()); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), AABB()); return mesh->surfaces[p_surface]->aabb; } @@ -3263,11 +3279,11 @@ Vector<PoolVector<uint8_t> > RasterizerStorageGLES3::mesh_surface_get_blend_shap return bsarr; } -Vector<Rect3> RasterizerStorageGLES3::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const { +Vector<AABB> RasterizerStorageGLES3::mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, Vector<Rect3>()); - ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<Rect3>()); + ERR_FAIL_COND_V(!mesh, Vector<AABB>()); + ERR_FAIL_INDEX_V(p_surface, mesh->surfaces.size(), Vector<AABB>()); return mesh->surfaces[p_surface]->skeleton_bone_aabb; } @@ -3321,7 +3337,7 @@ int RasterizerStorageGLES3::mesh_get_surface_count(RID p_mesh) const { return mesh->surfaces.size(); } -void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb) { +void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) { Mesh *mesh = mesh_owner.getornull(p_mesh); ERR_FAIL_COND(!mesh); @@ -3329,37 +3345,37 @@ void RasterizerStorageGLES3::mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aab mesh->custom_aabb = p_aabb; } -Rect3 RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const { +AABB RasterizerStorageGLES3::mesh_get_custom_aabb(RID p_mesh) const { const Mesh *mesh = mesh_owner.getornull(p_mesh); - ERR_FAIL_COND_V(!mesh, Rect3()); + ERR_FAIL_COND_V(!mesh, AABB()); return mesh->custom_aabb; } -Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { +AABB RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { Mesh *mesh = mesh_owner.get(p_mesh); - ERR_FAIL_COND_V(!mesh, Rect3()); + ERR_FAIL_COND_V(!mesh, AABB()); - if (mesh->custom_aabb != Rect3()) + if (mesh->custom_aabb != AABB()) return mesh->custom_aabb; Skeleton *sk = NULL; if (p_skeleton.is_valid()) sk = skeleton_owner.get(p_skeleton); - Rect3 aabb; + AABB aabb; if (sk && sk->size != 0) { for (int i = 0; i < mesh->surfaces.size(); i++) { - Rect3 laabb; + AABB laabb; if ((mesh->surfaces[i]->format & VS::ARRAY_FORMAT_BONES) && mesh->surfaces[i]->skeleton_bone_aabb.size()) { int bs = mesh->surfaces[i]->skeleton_bone_aabb.size(); - const Rect3 *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr(); + const AABB *skbones = mesh->surfaces[i]->skeleton_bone_aabb.ptr(); const bool *skused = mesh->surfaces[i]->skeleton_bone_used.ptr(); int sbs = sk->size; @@ -3385,7 +3401,7 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { mtx.basis[1].y = texture[base_ofs + 1]; mtx.origin.y = texture[base_ofs + 3]; - Rect3 baabb = mtx.xform(skbones[j]); + AABB baabb = mtx.xform(skbones[j]); if (first) { laabb = baabb; first = false; @@ -3418,7 +3434,7 @@ Rect3 RasterizerStorageGLES3::mesh_get_aabb(RID p_mesh, RID p_skeleton) const { mtx.basis[2].z = texture[base_ofs + 2]; mtx.origin.z = texture[base_ofs + 3]; - Rect3 baabb = mtx.xform(skbones[j]); + AABB baabb = mtx.xform(skbones[j]); if (first) { laabb = baabb; first = false; @@ -4012,10 +4028,10 @@ int RasterizerStorageGLES3::multimesh_get_visible_instances(RID p_multimesh) con return multimesh->visible_instances; } -Rect3 RasterizerStorageGLES3::multimesh_get_aabb(RID p_multimesh) const { +AABB RasterizerStorageGLES3::multimesh_get_aabb(RID p_multimesh) const { MultiMesh *multimesh = multimesh_owner.getornull(p_multimesh); - ERR_FAIL_COND_V(!multimesh, Rect3()); + ERR_FAIL_COND_V(!multimesh, AABB()); const_cast<RasterizerStorageGLES3 *>(this)->update_dirty_multimeshes(); //update pending AABBs @@ -4037,7 +4053,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { if (multimesh->size && multimesh->dirty_aabb) { - Rect3 mesh_aabb; + AABB mesh_aabb; if (multimesh->mesh.is_valid()) { mesh_aabb = mesh_get_aabb(multimesh->mesh, RID()); @@ -4049,7 +4065,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { int count = multimesh->data.size(); float *data = multimesh->data.ptr(); - Rect3 aabb; + AABB aabb; if (multimesh->transform_format == VS::MULTIMESH_TRANSFORM_2D) { @@ -4064,7 +4080,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { xform.basis[1][1] = dataptr[5]; xform.origin[1] = dataptr[7]; - Rect3 laabb = xform.xform(mesh_aabb); + AABB laabb = xform.xform(mesh_aabb); if (i == 0) aabb = laabb; else @@ -4090,7 +4106,7 @@ void RasterizerStorageGLES3::update_dirty_multimeshes() { xform.basis.elements[2][2] = dataptr[10]; xform.origin.z = dataptr[11]; - Rect3 laabb = xform.xform(mesh_aabb); + AABB laabb = xform.xform(mesh_aabb); if (i == 0) aabb = laabb; else @@ -4226,10 +4242,10 @@ void RasterizerStorageGLES3::immediate_clear(RID p_immediate) { im->instance_change_notify(); } -Rect3 RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const { +AABB RasterizerStorageGLES3::immediate_get_aabb(RID p_immediate) const { Immediate *im = immediate_owner.get(p_immediate); - ERR_FAIL_COND_V(!im, Rect3()); + ERR_FAIL_COND_V(!im, AABB()); return im->aabb; } @@ -4450,6 +4466,7 @@ RID RasterizerStorageGLES3::light_create(VS::LightType p_type) { light->type = p_type; light->param[VS::LIGHT_PARAM_ENERGY] = 1.0; + light->param[VS::LIGHT_PARAM_INDIRECT_ENERGY] = 1.0; light->param[VS::LIGHT_PARAM_SPECULAR] = 0.5; light->param[VS::LIGHT_PARAM_RANGE] = 1.0; light->param[VS::LIGHT_PARAM_SPOT_ANGLE] = 45; @@ -4678,10 +4695,10 @@ uint64_t RasterizerStorageGLES3::light_get_version(RID p_light) const { return light->version; } -Rect3 RasterizerStorageGLES3::light_get_aabb(RID p_light) const { +AABB RasterizerStorageGLES3::light_get_aabb(RID p_light) const { const Light *light = light_owner.getornull(p_light); - ERR_FAIL_COND_V(!light, Rect3()); + ERR_FAIL_COND_V(!light, AABB()); switch (light->type) { @@ -4689,22 +4706,22 @@ Rect3 RasterizerStorageGLES3::light_get_aabb(RID p_light) const { float len = light->param[VS::LIGHT_PARAM_RANGE]; float size = Math::tan(Math::deg2rad(light->param[VS::LIGHT_PARAM_SPOT_ANGLE])) * len; - return Rect3(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); + return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); } break; case VS::LIGHT_OMNI: { float r = light->param[VS::LIGHT_PARAM_RANGE]; - return Rect3(-Vector3(r, r, r), Vector3(r, r, r) * 2); + return AABB(-Vector3(r, r, r), Vector3(r, r, r) * 2); } break; case VS::LIGHT_DIRECTIONAL: { - return Rect3(); + return AABB(); } break; default: {} } - ERR_FAIL_V(Rect3()); - return Rect3(); + ERR_FAIL_V(AABB()); + return AABB(); } /* PROBE API */ @@ -4826,11 +4843,11 @@ void RasterizerStorageGLES3::reflection_probe_set_cull_mask(RID p_probe, uint32_ reflection_probe->instance_change_notify(); } -Rect3 RasterizerStorageGLES3::reflection_probe_get_aabb(RID p_probe) const { +AABB RasterizerStorageGLES3::reflection_probe_get_aabb(RID p_probe) const { const ReflectionProbe *reflection_probe = reflection_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!reflection_probe, Rect3()); + ERR_FAIL_COND_V(!reflection_probe, AABB()); - Rect3 aabb; + AABB aabb; aabb.position = -reflection_probe->extents; aabb.size = reflection_probe->extents * 2.0; @@ -4887,7 +4904,7 @@ RID RasterizerStorageGLES3::gi_probe_create() { GIProbe *gip = memnew(GIProbe); - gip->bounds = Rect3(Vector3(), Vector3(1, 1, 1)); + gip->bounds = AABB(Vector3(), Vector3(1, 1, 1)); gip->dynamic_range = 1.0; gip->energy = 1.0; gip->propagation = 1.0; @@ -4901,7 +4918,7 @@ RID RasterizerStorageGLES3::gi_probe_create() { return gi_probe_owner.make_rid(gip); } -void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds) { +void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) { GIProbe *gip = gi_probe_owner.getornull(p_probe); ERR_FAIL_COND(!gip); @@ -4910,10 +4927,10 @@ void RasterizerStorageGLES3::gi_probe_set_bounds(RID p_probe, const Rect3 &p_bou gip->version++; gip->instance_change_notify(); } -Rect3 RasterizerStorageGLES3::gi_probe_get_bounds(RID p_probe) const { +AABB RasterizerStorageGLES3::gi_probe_get_bounds(RID p_probe) const { const GIProbe *gip = gi_probe_owner.getornull(p_probe); - ERR_FAIL_COND_V(!gip, Rect3()); + ERR_FAIL_COND_V(!gip, AABB()); return gip->bounds; } @@ -5322,7 +5339,7 @@ void RasterizerStorageGLES3::_particles_update_histories(Particles *particles) { particles->clear = true; } -void RasterizerStorageGLES3::particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb) { +void RasterizerStorageGLES3::particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) { Particles *particles = particles_owner.getornull(p_particles); ERR_FAIL_COND(!particles); @@ -5413,15 +5430,15 @@ void RasterizerStorageGLES3::particles_request_process(RID p_particles) { } } -Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { +AABB RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { const Particles *particles = particles_owner.getornull(p_particles); - ERR_FAIL_COND_V(!particles, Rect3()); + ERR_FAIL_COND_V(!particles, AABB()); glBindBuffer(GL_ARRAY_BUFFER, particles->particle_buffers[0]); float *data = (float *)glMapBufferRange(GL_ARRAY_BUFFER, 0, particles->amount * 16 * 6, GL_MAP_READ_BIT); - Rect3 aabb; + AABB aabb; Transform inv = particles->emission_transform.affine_inverse(); @@ -5443,7 +5460,7 @@ Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { float longest_axis = 0; for (int i = 0; i < particles->draw_passes.size(); i++) { if (particles->draw_passes[i].is_valid()) { - Rect3 maabb = mesh_get_aabb(particles->draw_passes[i], RID()); + AABB maabb = mesh_get_aabb(particles->draw_passes[i], RID()); longest_axis = MAX(maabb.get_longest_axis_size(), longest_axis); } } @@ -5453,10 +5470,10 @@ Rect3 RasterizerStorageGLES3::particles_get_current_aabb(RID p_particles) { return aabb; } -Rect3 RasterizerStorageGLES3::particles_get_aabb(RID p_particles) const { +AABB RasterizerStorageGLES3::particles_get_aabb(RID p_particles) const { const Particles *particles = particles_owner.getornull(p_particles); - ERR_FAIL_COND_V(!particles, Rect3()); + ERR_FAIL_COND_V(!particles, AABB()); return particles->custom_aabb; } @@ -7011,14 +7028,22 @@ void RasterizerStorageGLES3::initialize() { glBindBuffer(GL_ARRAY_BUFFER, resources.quadie); { const float qv[16] = { - -1, -1, - 0, 0, - -1, 1, - 0, 1, - 1, 1, - 1, 1, - 1, -1, - 1, 0, + -1, + -1, + 0, + 0, + -1, + 1, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + -1, + 1, + 0, }; glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 16, qv, GL_STATIC_DRAW); diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 6abc22b643..8aa8235b42 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -592,7 +592,7 @@ public: GLuint instancing_array_wireframe_id; int index_wireframe_len; - Vector<Rect3> skeleton_bone_aabb; + Vector<AABB> skeleton_bone_aabb; Vector<bool> skeleton_bone_used; //bool packed; @@ -604,7 +604,7 @@ public: Vector<BlendShape> blend_shapes; - Rect3 aabb; + AABB aabb; int array_len; int index_array_len; @@ -659,7 +659,7 @@ public: Vector<Surface *> surfaces; int blend_shape_count; VS::BlendShapeMode blend_shape_mode; - Rect3 custom_aabb; + AABB custom_aabb; mutable uint64_t last_pass; SelfList<MultiMesh>::List multimeshes; @@ -684,7 +684,7 @@ public: virtual RID mesh_create(); - virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()); + virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()); virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount); virtual int mesh_get_blend_shape_count(RID p_mesh) const; @@ -692,6 +692,8 @@ public: virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode); virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const; + virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data); + virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material); virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const; @@ -704,17 +706,17 @@ public: virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const; virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const; - virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const; + virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const; virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const; - virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const; + virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const; virtual void mesh_remove_surface(RID p_mesh, int p_surface); virtual int mesh_get_surface_count(RID p_mesh) const; - virtual void mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb); - virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const; + virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb); + virtual AABB mesh_get_custom_aabb(RID p_mesh) const; - virtual Rect3 mesh_get_aabb(RID p_mesh, RID p_skeleton) const; + virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const; virtual void mesh_clear(RID p_mesh); void mesh_render_blend_shapes(Surface *s, float *p_weights); @@ -727,7 +729,7 @@ public: VS::MultimeshTransformFormat transform_format; VS::MultimeshColorFormat color_format; Vector<float> data; - Rect3 aabb; + AABB aabb; SelfList<MultiMesh> update_list; SelfList<MultiMesh> mesh_list; GLuint buffer; @@ -778,7 +780,7 @@ public: virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible); virtual int multimesh_get_visible_instances(RID p_multimesh) const; - virtual Rect3 multimesh_get_aabb(RID p_multimesh) const; + virtual AABB multimesh_get_aabb(RID p_multimesh) const; /* IMMEDIATE API */ @@ -799,7 +801,7 @@ public: List<Chunk> chunks; bool building; int mask; - Rect3 aabb; + AABB aabb; Immediate() { type = GEOMETRY_IMMEDIATE; @@ -828,7 +830,7 @@ public: virtual void immediate_clear(RID p_immediate); virtual void immediate_set_material(RID p_immediate, RID p_material); virtual RID immediate_get_material(RID p_immediate) const; - virtual Rect3 immediate_get_aabb(RID p_immediate) const; + virtual AABB immediate_get_aabb(RID p_immediate) const; /* SKELETON API */ @@ -916,7 +918,7 @@ public: virtual float light_get_param(RID p_light, VS::LightParam p_param); virtual Color light_get_color(RID p_light); - virtual Rect3 light_get_aabb(RID p_light) const; + virtual AABB light_get_aabb(RID p_light) const; virtual uint64_t light_get_version(RID p_light) const; /* PROBE API */ @@ -954,7 +956,7 @@ public: virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable); virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers); - virtual Rect3 reflection_probe_get_aabb(RID p_probe) const; + virtual AABB reflection_probe_get_aabb(RID p_probe) const; virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const; virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const; @@ -967,7 +969,7 @@ public: struct GIProbe : public Instantiable { - Rect3 bounds; + AABB bounds; Transform to_cell; float cell_size; @@ -988,8 +990,8 @@ public: virtual RID gi_probe_create(); - virtual void gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds); - virtual Rect3 gi_probe_get_bounds(RID p_probe) const; + virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds); + virtual AABB gi_probe_get_bounds(RID p_probe) const; virtual void gi_probe_set_cell_size(RID p_probe, float p_size); virtual float gi_probe_get_cell_size(RID p_probe) const; @@ -1056,7 +1058,7 @@ public: float explosiveness; float randomness; bool restart_request; - Rect3 custom_aabb; + AABB custom_aabb; bool use_local_coords; RID process_material; @@ -1111,7 +1113,7 @@ public: restart_request = false; - custom_aabb = Rect3(Vector3(-4, -4, -4), Vector3(8, 8, 8)); + custom_aabb = AABB(Vector3(-4, -4, -4), Vector3(8, 8, 8)); draw_order = VS::PARTICLES_DRAW_ORDER_INDEX; particle_buffers[0] = 0; @@ -1153,7 +1155,7 @@ public: virtual void particles_set_pre_process_time(RID p_particles, float p_time); virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio); virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio); - virtual void particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb); + virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb); virtual void particles_set_speed_scale(RID p_particles, float p_scale); virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable); virtual void particles_set_process_material(RID p_particles, RID p_material); @@ -1167,8 +1169,8 @@ public: virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh); virtual void particles_request_process(RID p_particles); - virtual Rect3 particles_get_current_aabb(RID p_particles); - virtual Rect3 particles_get_aabb(RID p_particles) const; + virtual AABB particles_get_current_aabb(RID p_particles); + virtual AABB particles_get_aabb(RID p_particles) const; virtual void _particles_update_histories(Particles *particles); diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index ad08c59de8..325df8e4f1 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -741,6 +741,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["SHADOW_COLOR"] = "#define SHADOW_COLOR_USED\n"; + actions[VS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; @@ -828,6 +829,9 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_TEXTURE"] = "#define SCREEN_TEXTURE_USED\n"; actions[VS::SHADER_SPATIAL].usage_defines["SCREEN_UV"] = "#define SCREEN_UV_USED\n"; + actions[VS::SHADER_SPATIAL].usage_defines["DIFFUSE_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + actions[VS::SHADER_SPATIAL].usage_defines["SPECULAR_LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + actions[VS::SHADER_SPATIAL].renames["SSS_STRENGTH"] = "sss_strength"; actions[VS::SHADER_SPATIAL].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl index 731d6968ce..4bbb18ce42 100644 --- a/drivers/gles3/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -381,8 +381,7 @@ void main() { if (clip_rect_uv) { - vec2 half_texpixel = color_texpixel_size * 0.5; - uv = clamp(uv,src_rect.xy+half_texpixel,src_rect.xy+abs(src_rect.zw)-color_texpixel_size); + uv = clamp(uv,src_rect.xy,src_rect.xy+abs(src_rect.zw)); } #endif diff --git a/drivers/unix/SCsub b/drivers/unix/SCsub index c560e1289f..ada8255580 100644 --- a/drivers/unix/SCsub +++ b/drivers/unix/SCsub @@ -2,16 +2,6 @@ Import('env') -g_set_p = '#ifdef UNIX_ENABLED\n' -g_set_p += '#include "os_unix.h"\n' -g_set_p += 'String OS_Unix::get_global_settings_path() const {\n' -g_set_p += '\treturn "' + env["unix_global_settings_path"] + '";\n' -g_set_p += '}\n' -g_set_p += '#endif' -f = open("os_unix_global_settings_path.gen.cpp", "w") -f.write(g_set_p) -f.close() - env.add_source_files(env.drivers_sources, "*.cpp") env["check_c_headers"] = [ [ "mntent.h", "HAVE_MNTENT" ] ] diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index 729abd57ef..ce0967af2c 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -454,32 +454,21 @@ int OS_Unix::get_processor_count() const { return sysconf(_SC_NPROCESSORS_CONF); } -String OS_Unix::get_data_dir() const { +String OS_Unix::get_user_data_dir() const { - String an = get_safe_application_name(); - if (an != "") { - - if (has_environment("HOME")) { - - bool use_godot = ProjectSettings::get_singleton()->get("application/config/use_shared_user_dir"); - if (use_godot) - return get_environment("HOME") + "/.godot/app_userdata/" + an; - else - return get_environment("HOME") + "/." + an; + String appname = get_safe_application_name(); + if (appname != "") { + bool use_godot_dir = ProjectSettings::get_singleton()->get("application/config/use_shared_user_dir"); + if (use_godot_dir) { + return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file(appname); + } else { + return get_data_path().plus_file(appname); } } return ProjectSettings::get_singleton()->get_resource_path(); } -String OS_Unix::get_installed_templates_path() const { - String p = get_global_settings_path(); - if (p != "") - return p + "/templates/"; - else - return ""; -} - String OS_Unix::get_executable_path() const { #ifdef __linux__ diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 87e73534c4..432f48408f 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -49,7 +49,6 @@ protected: //virtual int get_video_driver_count() const; //virtual const char * get_video_driver_name(int p_driver) const; - //virtual VideoMode get_default_video_mode() const; virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; @@ -63,8 +62,6 @@ protected: String stdin_buf; - String get_global_settings_path() const; - public: virtual void alert(const String &p_alert, const String &p_title = "ALERT!"); virtual String get_stdin_string(bool p_block); @@ -109,11 +106,8 @@ public: virtual void debug_break(); - virtual String get_installed_templates_path() const; virtual String get_executable_path() const; - virtual String get_data_dir() const; - - //virtual void run( MainLoop * p_main_loop ); + virtual String get_user_data_dir() const; }; class UnixTerminalLogger : public StdLogger { diff --git a/editor/SCsub b/editor/SCsub index 2b6494608b..75ec422bd5 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -21,11 +21,11 @@ def make_certs_header(target, source, env): g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _CERTS_RAW_H\n") g.write("#define _CERTS_RAW_H\n") - g.write("static const int _certs_compressed_size=" + str(len(buf)) + ";\n") - g.write("static const int _certs_uncompressed_size=" + str(decomp_size) + ";\n") - g.write("static const unsigned char _certs_compressed[]={\n") + g.write("static const int _certs_compressed_size = " + str(len(buf)) + ";\n") + g.write("static const int _certs_uncompressed_size = " + str(decomp_size) + ";\n") + g.write("static const unsigned char _certs_compressed[] = {\n") for i in range(len(buf)): - g.write(byte_to_str(buf[i]) + ",\n") + g.write("\t" + byte_to_str(buf[i]) + ",\n") g.write("};\n") g.write("#endif") @@ -39,9 +39,11 @@ def make_doc_header(target, source, env): docend = "" for s in source: src = s.srcnode().abspath + if not src.endswith(".xml"): + continue f = open_utf8(src, "r") content = f.read() - buf+=content + buf += content buf = encode_utf8(docbegin + buf + docend) decomp_size = len(buf) @@ -51,11 +53,11 @@ def make_doc_header(target, source, env): g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") g.write("#ifndef _DOC_DATA_RAW_H\n") g.write("#define _DOC_DATA_RAW_H\n") - g.write("static const int _doc_data_compressed_size=" + str(len(buf)) + ";\n") - g.write("static const int _doc_data_uncompressed_size=" + str(decomp_size) + ";\n") - g.write("static const unsigned char _doc_data_compressed[]={\n") + g.write("static const int _doc_data_compressed_size = " + str(len(buf)) + ";\n") + g.write("static const int _doc_data_uncompressed_size = " + str(decomp_size) + ";\n") + g.write("static const unsigned char _doc_data_compressed[] = {\n") for i in range(len(buf)): - g.write(byte_to_str(buf[i]) + ",\n") + g.write("\t" + byte_to_str(buf[i]) + ",\n") g.write("};\n") g.write("#endif") @@ -80,10 +82,10 @@ def make_fonts_header(target, source, env): name = os.path.splitext(os.path.basename(source[i].srcnode().abspath))[0] - g.write("static const int _font_" + name + "_size=" + str(len(buf)) + ";\n") - g.write("static const unsigned char _font_" + name + "[]={\n") + g.write("static const int _font_" + name + "_size = " + str(len(buf)) + ";\n") + g.write("static const unsigned char _font_" + name + "[] = {\n") for i in range(len(buf)): - g.write(byte_to_str(buf[i]) + ",\n") + g.write("\t" + byte_to_str(buf[i]) + ",\n") g.write("};\n") @@ -114,11 +116,9 @@ def make_translations_header(target, source, env): buf = zlib.compress(buf) name = os.path.splitext(os.path.basename(sorted_paths[i]))[0] - #g.write("static const int _translation_"+name+"_compressed_size="+str(len(buf))+";\n") - #g.write("static const int _translation_"+name+"_uncompressed_size="+str(decomp_size)+";\n") - g.write("static const unsigned char _translation_" + name + "_compressed[]={\n") + g.write("static const unsigned char _translation_" + name + "_compressed[] = {\n") for i in range(len(buf)): - g.write(byte_to_str(buf[i]) + ",\n") + g.write("\t" + byte_to_str(buf[i]) + ",\n") g.write("};\n") @@ -130,10 +130,10 @@ def make_translations_header(target, source, env): g.write("\tint uncomp_size;\n") g.write("\tconst unsigned char* data;\n") g.write("};\n\n") - g.write("static EditorTranslationList _editor_translations[]={\n") + g.write("static EditorTranslationList _editor_translations[] = {\n") for x in xl_names: - g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ",_translation_" + x[0] + "_compressed},\n") - g.write("\t{NULL,0,0,NULL}\n") + g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ", _translation_" + x[0] + "_compressed},\n") + g.write("\t{NULL, 0, 0, NULL}\n") g.write("};\n") g.write("#endif") @@ -390,13 +390,13 @@ def make_license_header(target, source, env): def _make_doc_data_class_path(to_path): g = open_utf8(os.path.join(to_path,"doc_data_class_path.gen.h"), "w") - g.write("static const int _doc_data_class_path_count="+str(len(env.doc_class_path))+";\n") + g.write("static const int _doc_data_class_path_count = " + str(len(env.doc_class_path)) + ";\n") g.write("struct _DocDataClassPath { const char* name; const char* path; };\n") - g.write("static const _DocDataClassPath _doc_data_class_paths["+str(len(env.doc_class_path)+1)+"]={\n"); - for c in env.doc_class_path: - g.write("{\""+c+"\",\""+env.doc_class_path[c]+"\"},\n") - g.write("{NULL,NULL}\n") + g.write("static const _DocDataClassPath _doc_data_class_paths[" + str(len(env.doc_class_path) + 1) + "] = {\n"); + for c in sorted(env.doc_class_path): + g.write("\t{\"" + c + "\", \"" + env.doc_class_path[c] + "\"},\n") + g.write("\t{NULL, NULL}\n") g.write("};\n") @@ -416,11 +416,22 @@ if env['tools']: # API documentation docs = [] - for f in os.listdir(os.path.join(env.Dir('#').abspath, "doc/classes")): - docs.append("#doc/classes/" + f) + doc_dirs = ["doc/classes"] + + for p in env.doc_class_path.values(): + if p not in doc_dirs: + doc_dirs.append(p) + + for d in doc_dirs: + try: + for f in os.listdir(os.path.join(env.Dir('#').abspath, d)): + docs.append("#" + os.path.join(d, f)) + except OSError: + pass _make_doc_data_class_path(os.path.join(env.Dir('#').abspath, "editor/doc")) + docs = sorted(docs) env.Depends("#editor/doc_data_compressed.gen.h", docs) env.Command("#editor/doc_data_compressed.gen.h", docs, make_doc_header) # Certificates diff --git a/editor/animation_editor.cpp b/editor/animation_editor.cpp index 54eb695178..7d877bdb8c 100644 --- a/editor/animation_editor.cpp +++ b/editor/animation_editor.cpp @@ -1368,7 +1368,7 @@ void AnimationKeyEditor::_track_editor_draw() { icon_ofs.x-=hsep; */ - track_ofs[0] = size.width - icon_ofs.x; + track_ofs[0] = size.width - icon_ofs.x + ofs.x; icon_ofs.x -= down_icon->get_width(); te->draw_texture(down_icon, icon_ofs - Size2(0, 4 * EDSCALE)); @@ -1380,7 +1380,7 @@ void AnimationKeyEditor::_track_editor_draw() { icon_ofs.x -= hsep; te->draw_line(Point2(icon_ofs.x, ofs.y + y), Point2(icon_ofs.x, ofs.y + y + h), sepcolor); - track_ofs[1] = size.width - icon_ofs.x; + track_ofs[1] = size.width - icon_ofs.x + ofs.x; icon_ofs.x -= down_icon->get_width(); te->draw_texture(down_icon, icon_ofs - Size2(0, 4 * EDSCALE)); @@ -1394,7 +1394,7 @@ void AnimationKeyEditor::_track_editor_draw() { icon_ofs.x -= hsep; te->draw_line(Point2(icon_ofs.x, ofs.y + y), Point2(icon_ofs.x, ofs.y + y + h), sepcolor); - track_ofs[2] = size.width - icon_ofs.x; + track_ofs[2] = size.width - icon_ofs.x + ofs.x; if (animation->track_get_type(idx) == Animation::TYPE_VALUE) { @@ -1415,13 +1415,12 @@ void AnimationKeyEditor::_track_editor_draw() { icon_ofs.x -= hsep; te->draw_line(Point2(icon_ofs.x, ofs.y + y), Point2(icon_ofs.x, ofs.y + y + h), sepcolor); - track_ofs[3] = size.width - icon_ofs.x; + track_ofs[3] = size.width - icon_ofs.x + ofs.x; icon_ofs.x -= hsep; icon_ofs.x -= add_key_icon->get_width(); te->draw_texture((mouse_over.over == MouseOver::OVER_ADD_KEY && mouse_over.track == idx) ? add_key_icon_hl : add_key_icon, icon_ofs); - - track_ofs[4] = size.width - icon_ofs.x; + track_ofs[4] = size.width - icon_ofs.x + ofs.x; //draw the keys; int tt = animation->track_get_type(idx); @@ -2080,7 +2079,7 @@ void AnimationKeyEditor::_track_editor_gui_input(const Ref<InputEvent> &p_input) return; } - if (mpos.x < name_limit) { + if (mpos.x < name_limit - (type_icon[0]->get_width() / 2.0)) { //name column // area @@ -3330,7 +3329,7 @@ int AnimationKeyEditor::_confirm_insert(InsertData p_id, int p_last_track) { h.type == Variant::VECTOR2 || h.type == Variant::RECT2 || h.type == Variant::VECTOR3 || - h.type == Variant::RECT3 || + h.type == Variant::AABB || h.type == Variant::QUAT || h.type == Variant::COLOR || h.type == Variant::TRANSFORM) { diff --git a/editor/code_editor.cpp b/editor/code_editor.cpp index 0100c221c4..c7012a0c14 100644 --- a/editor/code_editor.cpp +++ b/editor/code_editor.cpp @@ -56,6 +56,7 @@ void GotoLineDialog::ok_pressed() { if (get_line() < 1 || get_line() > text_editor->get_line_count()) return; + text_editor->unfold_line(get_line() - 1); text_editor->cursor_set_line(get_line() - 1); hide(); } @@ -139,6 +140,7 @@ bool FindReplaceBar::_search(uint32_t p_flags, int p_from_line, int p_from_col) if (found) { if (!preserve_cursor) { + text_edit->unfold_line(line); text_edit->cursor_set_line(line, false); text_edit->cursor_set_column(col + text.length(), false); text_edit->center_viewport_to_cursor(); @@ -167,6 +169,7 @@ void FindReplaceBar::_replace() { if (result_line != -1 && result_col != -1) { text_edit->begin_complex_operation(); + text_edit->unfold_line(result_line); text_edit->select(result_line, result_col, result_line, result_col + get_search_text().length()); text_edit->insert_text_at_cursor(get_replace_text()); @@ -214,6 +217,7 @@ void FindReplaceBar::_replace_all() { prev_match = Point2i(result_line, result_col + replace_text.length()); + text_edit->unfold_line(result_line); text_edit->select(result_line, result_col, result_line, match_to.y); if (selection_enabled && is_selection_only()) { @@ -751,6 +755,7 @@ bool FindReplaceDialog::_search() { if (found) { // print_line("found"); + text_edit->unfold_line(line); text_edit->cursor_set_line(line); if (is_backwards()) text_edit->cursor_set_column(col); @@ -1093,6 +1098,8 @@ void CodeTextEditor::update_editor_settings() { text_editor->cursor_set_blink_enabled(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink")); text_editor->cursor_set_blink_speed(EditorSettings::get_singleton()->get("text_editor/cursor/caret_blink_speed")); text_editor->set_draw_breakpoint_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/show_breakpoint_gutter")); + text_editor->set_hiding_enabled(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding")); + text_editor->set_draw_fold_gutter(EditorSettings::get_singleton()->get("text_editor/line_numbers/code_folding")); text_editor->cursor_set_block_mode(EditorSettings::get_singleton()->get("text_editor/cursor/block_caret")); text_editor->set_smooth_scroll_enabled(EditorSettings::get_singleton()->get("text_editor/open_scripts/smooth_scrolling")); text_editor->set_v_scroll_speed(EditorSettings::get_singleton()->get("text_editor/open_scripts/v_scroll_speed")); diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index b4c2ac95cc..cd60455f4f 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -209,7 +209,7 @@ void ConnectDialog::_add_bind() { case Variant::VECTOR3: value = Vector3(); break; case Variant::PLANE: value = Plane(); break; case Variant::QUAT: value = Quat(); break; - case Variant::RECT3: value = Rect3(); break; + case Variant::AABB: value = AABB(); break; case Variant::BASIS: value = Basis(); break; case Variant::TRANSFORM: value = Transform(); break; case Variant::COLOR: value = Color(); break; @@ -295,7 +295,7 @@ ConnectDialog::ConnectDialog() { type_list->add_item("Vector3", Variant::VECTOR3); type_list->add_item("Plane", Variant::PLANE); type_list->add_item("Quat", Variant::QUAT); - type_list->add_item("Rect3", Variant::RECT3); + type_list->add_item("AABB", Variant::AABB); type_list->add_item("Basis", Variant::BASIS); type_list->add_item("Transform", Variant::TRANSFORM); //type_list->add_separator(); diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index 95b4f7e982..c058d290bf 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -41,7 +41,7 @@ void CreateDialog::popup_create(bool p_dontclear) { recent->clear(); - FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_path().plus_file("create_recent." + base_type), FileAccess::READ); + FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::READ); if (f) { @@ -63,7 +63,7 @@ void CreateDialog::popup_create(bool p_dontclear) { favorites->clear(); - f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_path().plus_file("favorites." + base_type), FileAccess::READ); + f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites." + base_type), FileAccess::READ); favorite_list.clear(); @@ -97,6 +97,15 @@ void CreateDialog::popup_create(bool p_dontclear) { search_box->grab_focus(); _update_search(); + + bool enable_rl = EditorSettings::get_singleton()->get("docks/scene_tree/draw_relationship_lines"); + Color rl_color = EditorSettings::get_singleton()->get("docks/scene_tree/relationship_line_color"); + + if (enable_rl) { + search_options->add_constant_override("draw_relationship_lines", 1); + search_options->add_color_override("relationship_line_color", rl_color); + } else + search_options->add_constant_override("draw_relationship_lines", 0); } void CreateDialog::_text_changed(const String &p_newtext) { @@ -307,7 +316,7 @@ void CreateDialog::_confirmed() { if (!ti) return; - FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_path().plus_file("create_recent." + base_type), FileAccess::WRITE); + FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("create_recent." + base_type), FileAccess::WRITE); if (f) { f->store_line(get_selected_type()); @@ -467,7 +476,7 @@ void CreateDialog::_favorite_toggled() { void CreateDialog::_save_favorite_list() { - FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_path().plus_file("favorites." + base_type), FileAccess::WRITE); + FileAccess *f = FileAccess::open(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("favorites." + base_type), FileAccess::WRITE); if (f) { diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 057b2d827d..1f9884aa70 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "doc_data.h" +#include "engine.h" #include "global_constants.h" #include "io/compression.h" #include "io/marshalls.h" @@ -529,7 +530,7 @@ void DocData::generate(bool p_basic_types) { { - String cname = "@Global Scope"; + String cname = "@GlobalScope"; class_list[cname] = ClassDoc(); ClassDoc &c = class_list[cname]; c.name = cname; @@ -543,14 +544,14 @@ void DocData::generate(bool p_basic_types) { c.constants.push_back(cd); } - List<ProjectSettings::Singleton> singletons; - ProjectSettings::get_singleton()->get_singletons(&singletons); + List<Engine::Singleton> singletons; + Engine::get_singleton()->get_singletons(&singletons); //servers (this is kind of hackish) - for (List<ProjectSettings::Singleton>::Element *E = singletons.front(); E; E = E->next()) { + for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { PropertyDoc pd; - ProjectSettings::Singleton &s = E->get(); + Engine::Singleton &s = E->get(); pd.name = s.name; pd.type = s.ptr->get_class(); while (String(ClassDB::get_parent_class(pd.type)) != "Object") @@ -615,11 +616,6 @@ void DocData::generate(bool p_basic_types) { } } -static String _format_description(const String &string) { - - return string.dedent().strip_edges().replace("\n", "\n\n"); -} - static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> &methods) { String section = parser->get_node_name(); @@ -666,7 +662,7 @@ static Error _parse_methods(Ref<XMLParser> &parser, Vector<DocData::MethodDoc> & parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - method.description = _format_description(parser->get_node_data()); + method.description = parser->get_node_data(); } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == element) @@ -781,20 +777,20 @@ Error DocData::_load(Ref<XMLParser> parser) { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - c.brief_description = _format_description(parser->get_node_data()); + c.brief_description = parser->get_node_data(); } else if (name == "description") { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - c.description = _format_description(parser->get_node_data()); + c.description = parser->get_node_data(); } else if (name == "tutorials") { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - c.tutorials = parser->get_node_data().strip_edges(); + c.tutorials = parser->get_node_data(); } else if (name == "demos") { parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - c.demos = parser->get_node_data().strip_edges(); + c.demos = parser->get_node_data(); } else if (name == "methods") { Error err = _parse_methods(parser, c.methods); @@ -828,7 +824,7 @@ Error DocData::_load(Ref<XMLParser> parser) { prop.enumeration = parser->get_attribute_value("enum"); parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - prop.description = _format_description(parser->get_node_data()); + prop.description = parser->get_node_data(); c.properties.push_back(prop); } else { ERR_EXPLAIN("Invalid tag in doc file: " + name); @@ -857,7 +853,7 @@ Error DocData::_load(Ref<XMLParser> parser) { prop.type = parser->get_attribute_value("type"); parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - prop.description = parser->get_node_data().strip_edges(); + prop.description = parser->get_node_data(); c.theme_properties.push_back(prop); } else { ERR_EXPLAIN("Invalid tag in doc file: " + name); @@ -888,7 +884,7 @@ Error DocData::_load(Ref<XMLParser> parser) { } parser->read(); if (parser->get_node_type() == XMLParser::NODE_TEXT) - constant.description = parser->get_node_data().strip_edges(); + constant.description = parser->get_node_data(); c.constants.push_back(constant); } else { ERR_EXPLAIN("Invalid tag in doc file: " + name); @@ -915,6 +911,8 @@ Error DocData::_load(Ref<XMLParser> parser) { static void _write_string(FileAccess *f, int p_tablevel, const String &p_string) { + if (p_string == "") + return; String tab; for (int i = 0; i < p_tablevel; i++) tab += "\t"; @@ -953,24 +951,20 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri if (c.category == "") category = "Core"; header += " category=\"" + category + "\""; - header += " version=\"" + String(VERSION_MKSTRING) + "\""; + header += String(" version=\"") + itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + VERSION_STATUS + "\""; header += ">"; _write_string(f, 0, header); _write_string(f, 1, "<brief_description>"); - if (c.brief_description != "") - _write_string(f, 2, c.brief_description.xml_escape()); + _write_string(f, 2, c.brief_description.strip_edges().xml_escape()); _write_string(f, 1, "</brief_description>"); _write_string(f, 1, "<description>"); - if (c.description != "") - _write_string(f, 2, c.description.xml_escape()); + _write_string(f, 2, c.description.strip_edges().xml_escape()); _write_string(f, 1, "</description>"); _write_string(f, 1, "<tutorials>"); - if (c.tutorials != "") - _write_string(f, 2, c.tutorials.xml_escape()); + _write_string(f, 2, c.tutorials.strip_edges().xml_escape()); _write_string(f, 1, "</tutorials>"); _write_string(f, 1, "<demos>"); - if (c.demos != "") - _write_string(f, 2, c.demos.xml_escape()); + _write_string(f, 2, c.demos.strip_edges().xml_escape()); _write_string(f, 1, "</demos>"); _write_string(f, 1, "<methods>"); @@ -1014,8 +1008,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri } _write_string(f, 3, "<description>"); - if (m.description != "") - _write_string(f, 4, m.description.xml_escape()); + _write_string(f, 4, m.description.strip_edges().xml_escape()); _write_string(f, 3, "</description>"); _write_string(f, 2, "</method>"); @@ -1036,8 +1029,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri } PropertyDoc &p = c.properties[i]; _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + enum_text + ">"); - if (p.description != "") - _write_string(f, 3, p.description.xml_escape()); + _write_string(f, 3, p.description.strip_edges().xml_escape()); _write_string(f, 2, "</member>"); } _write_string(f, 1, "</members>"); @@ -1060,8 +1052,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri } _write_string(f, 3, "<description>"); - if (m.description != "") - _write_string(f, 4, m.description.xml_escape()); + _write_string(f, 4, m.description.strip_edges().xml_escape()); _write_string(f, 3, "</description>"); _write_string(f, 2, "</signal>"); @@ -1080,8 +1071,7 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri } else { _write_string(f, 2, "<constant name=\"" + k.name + "\" value=\"" + k.value + "\" enum=\"" + k.enumeration + "\">"); } - if (k.description != "") - _write_string(f, 3, k.description.xml_escape()); + _write_string(f, 3, k.description.strip_edges().xml_escape()); _write_string(f, 2, "</constant>"); } diff --git a/editor/doc/doc_dump.cpp b/editor/doc/doc_dump.cpp index 2ba7e3c779..9dd05d9d0f 100644 --- a/editor/doc/doc_dump.cpp +++ b/editor/doc/doc_dump.cpp @@ -82,8 +82,8 @@ void DocDump::dump(const String &p_file) { FileAccess *f = FileAccess::open(p_file, FileAccess::WRITE); _write_string(f, 0, "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"); + _write_string(f, 0, String("<doc version=\"") + itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + VERSION_STATUS + "\" name=\"Engine Types\">"); - _write_string(f, 0, "<doc version=\"" + String(VERSION_MKSTRING) + "\" name=\"Engine Types\">"); while (class_list.size()) { String name = class_list.front()->get(); @@ -182,7 +182,7 @@ void DocDump::dump(const String &p_file) { case Variant::VECTOR3: case Variant::PLANE: case Variant::QUAT: - case Variant::RECT3: + case Variant::AABB: case Variant::BASIS: case Variant::COLOR: case Variant::POOL_BYTE_ARRAY: diff --git a/editor/editor_about.cpp b/editor/editor_about.cpp index a48e6c9057..290cb1be42 100644 --- a/editor/editor_about.cpp +++ b/editor/editor_about.cpp @@ -117,7 +117,7 @@ EditorAbout::EditorAbout() { Label *about_text = memnew(Label); about_text->set_v_size_flags(Control::SIZE_SHRINK_CENTER); - about_text->set_text(VERSION_FULL_NAME + hash + String::utf8("\n\u00A9 2007-2017 Juan Linietsky, Ariel Manzur.\n\u00A9 2014-2017 ") + + about_text->set_text(VERSION_FULL_NAME + hash + String::utf8("\n\xc2\xa9 2007-2017 Juan Linietsky, Ariel Manzur.\n\xc2\xa9 2014-2017 ") + TTR("Godot Engine contributors") + "\n"); hbc->add_child(about_text); @@ -201,7 +201,7 @@ EditorAbout::EditorAbout() { for (int j = 0; j < about_tp_copyright_count[i]; j++) { text += "\n Files:\n " + String(about_tp_file[read_idx]).replace("\n", "\n ") + "\n"; - String copyright = String::utf8(" \u00A9 ") + String::utf8(about_tp_copyright[read_idx]).replace("\n", String::utf8("\n \u00A9 ")); + String copyright = String::utf8(" \xc2\xa9 ") + String::utf8(about_tp_copyright[read_idx]).replace("\n", String::utf8("\n \xc2\xa9 ")); text += copyright; long_text += copyright; String license = "\n License: " + String(about_tp_license[read_idx]) + "\n"; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index efe32b99ab..519bc33d42 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -336,33 +336,18 @@ Error EditorExportPlatform::_save_zip_file(void *p_userdata, const String &p_pat String EditorExportPlatform::find_export_template(String template_file_name, String *err) const { - String base_name = itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + _MKSTR(VERSION_STATUS) + "/" + template_file_name; - String user_file = EditorSettings::get_singleton()->get_settings_path() + "/templates/" + base_name; - String system_file = OS::get_singleton()->get_installed_templates_path(); - bool has_system_path = (system_file != ""); - system_file = system_file.plus_file(base_name); - - // Prefer user file - if (FileAccess::exists(user_file)) { - return user_file; - } + String current_version = itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + VERSION_STATUS + VERSION_MODULE_CONFIG; + String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(current_version).plus_file(template_file_name); - // Now check system file - if (has_system_path) { - if (FileAccess::exists(system_file)) { - return system_file; - } + if (FileAccess::exists(template_path)) { + return template_path; } // Not found if (err) { - *err += "No export template found at \"" + user_file + "\""; - if (has_system_path) - *err += "\n or \"" + system_file + "\"."; - else - *err += "."; + *err += "No export template found at \"" + template_path + "\"."; } - return String(); // not found + return String(); } bool EditorExportPlatform::exists_export_template(String template_file_name, String *err) const { @@ -692,7 +677,7 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & } String config_file = "project.binary"; - String engine_cfb = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmp" + config_file; + String engine_cfb = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp" + config_file); ProjectSettings::get_singleton()->save_custom(engine_cfb, custom_map, custom_list); Vector<uint8_t> data = FileAccess::get_file_as_array(engine_cfb); @@ -705,7 +690,7 @@ Error EditorExportPlatform::save_pack(const Ref<EditorExportPreset> &p_preset, c EditorProgress ep("savepack", TTR("Packing"), 102); - String tmppath = EditorSettings::get_singleton()->get_settings_path() + "/tmp/packtmp"; + String tmppath = EditorSettings::get_singleton()->get_cache_dir().plus_file("packtmp"); FileAccess *ftmp = FileAccess::open(tmppath, FileAccess::WRITE); ERR_FAIL_COND_V(!ftmp, ERR_CANT_CREATE) @@ -982,7 +967,7 @@ void EditorExport::remove_export_preset(int p_idx) { void EditorExport::add_export_plugin(const Ref<EditorExportPlugin> &p_plugin) { - if (export_plugins.find(p_plugin) == 1) { + if (export_plugins.find(p_plugin) == -1) { export_plugins.push_back(p_plugin); } } diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index a6fc8dcddf..8d5bad3346 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -188,7 +188,7 @@ void EditorFileSystem::_scan_filesystem() { String project = ProjectSettings::get_singleton()->get_resource_path(); - String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache3"); + String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("filesystem_cache3"); FileAccess *f = FileAccess::open(fscache, FileAccess::READ); if (f) { @@ -238,7 +238,7 @@ void EditorFileSystem::_scan_filesystem() { memdelete(f); } - String update_cache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_update3"); + String update_cache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("filesystem_update3"); if (FileAccess::exists(update_cache)) { { @@ -282,7 +282,7 @@ void EditorFileSystem::_scan_filesystem() { } void EditorFileSystem::_save_filesystem_cache() { - String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_cache3"); + String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("filesystem_cache3"); FileAccess *f = FileAccess::open(fscache, FileAccess::WRITE); _save_filesystem_cache(filesystem, f); @@ -821,8 +821,6 @@ void EditorFileSystem::_scan_fs_changes(EditorFileSystemDirectory *p_dir, const scan_actions.push_back(ia); } } - - EditorResourcePreview::get_singleton()->check_for_invalidation(p_dir->get_file_path(i)); } for (int i = 0; i < p_dir->subdirs.size(); i++) { @@ -915,7 +913,8 @@ void EditorFileSystem::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { - scan(); + call_deferred("scan"); //this should happen after every editor node entered the tree + } break; case NOTIFICATION_EXIT_TREE: { if (use_threads && thread) { @@ -1181,7 +1180,7 @@ EditorFileSystemDirectory *EditorFileSystem::get_filesystem_path(const String &p void EditorFileSystem::_save_late_updated_files() { //files that already existed, and were modified, need re-scanning for dependencies upon project restart. This is done via saving this special file - String fscache = EditorSettings::get_singleton()->get_project_settings_path().plus_file("filesystem_update3"); + String fscache = EditorSettings::get_singleton()->get_project_settings_dir().plus_file("filesystem_update3"); FileAccessRef f = FileAccess::open(fscache, FileAccess::WRITE); for (Set<String>::Element *E = late_update_files.front(); E; E = E->next()) { f->store_line(E->get()); @@ -1266,7 +1265,6 @@ void EditorFileSystem::update_file(const String &p_file) { fs->files[cpos]->deps = _get_dependencies(p_file); fs->files[cpos]->import_valid = ResourceLoader::is_import_valid(p_file); - EditorResourcePreview::get_singleton()->call_deferred("check_for_invalidation", p_file); call_deferred("emit_signal", "filesystem_changed"); //update later } @@ -1436,6 +1434,8 @@ void EditorFileSystem::_reimport_file(const String &p_file) { r->set_import_last_modified_time(0); } } + + EditorResourcePreview::get_singleton()->check_for_invalidation(p_file); } void EditorFileSystem::reimport_files(const Vector<String> &p_files) { diff --git a/editor/editor_fonts.cpp b/editor/editor_fonts.cpp index 05f9da03e1..7e20077fd6 100644 --- a/editor/editor_fonts.cpp +++ b/editor/editor_fonts.cpp @@ -122,20 +122,24 @@ void editor_register_fonts(Ref<Theme> p_theme) { dfmono->set_font_ptr(_font_Hack_Regular, _font_Hack_Regular_size); //dfd->set_force_autohinter(true); //just looks better..i think? - MAKE_DEFAULT_FONT(df, int(EditorSettings::get_singleton()->get("interface/editor/font_size")) * EDSCALE); + int default_font_size = int(EditorSettings::get_singleton()->get("interface/editor/font_size")) * EDSCALE; + MAKE_DEFAULT_FONT(df, default_font_size); p_theme->set_default_theme_font(df); + MAKE_DEFAULT_FONT(df_title, default_font_size + 2 * EDSCALE); + p_theme->set_font("title", "EditorFonts", df_title); + //Ref<BitmapFont> doc_font = make_font(_bi_font_doc_font_height,_bi_font_doc_font_ascent,0,_bi_font_doc_font_charcount,_bi_font_doc_font_characters,p_theme->get_icon("DocFont","EditorIcons")); //Ref<BitmapFont> doc_title_font = make_font(_bi_font_doc_title_font_height,_bi_font_doc_title_font_ascent,0,_bi_font_doc_title_font_charcount,_bi_font_doc_title_font_characters,p_theme->get_icon("DocTitleFont","EditorIcons")); //Ref<BitmapFont> doc_code_font = make_font(_bi_font_doc_code_font_height,_bi_font_doc_code_font_ascent,0,_bi_font_doc_code_font_charcount,_bi_font_doc_code_font_characters,p_theme->get_icon("DocCodeFont","EditorIcons")); - MAKE_DEFAULT_FONT(df_title, int(EDITOR_DEF("text_editor/help/help_title_font_size", 16)) * EDSCALE); + MAKE_DEFAULT_FONT(df_doc_title, int(EDITOR_DEF("text_editor/help/help_title_font_size", 16)) * EDSCALE); MAKE_DEFAULT_FONT(df_doc, int(EDITOR_DEF("text_editor/help/help_font_size", 14)) * EDSCALE); p_theme->set_font("doc", "EditorFonts", df_doc); - p_theme->set_font("doc_title", "EditorFonts", df_title); + p_theme->set_font("doc_title", "EditorFonts", df_doc_title); MAKE_DEFAULT_FONT(df_rulers, int(EDITOR_DEF("canvas_item_editor/rulers", 8)) * EDSCALE); p_theme->set_font("rulers", "EditorFonts", df_rulers); @@ -176,9 +180,4 @@ void editor_register_fonts(Ref<Theme> p_theme) { df_output_code->set_font_data(dfmono); MAKE_FALLBACKS(df_output_code); p_theme->set_font("status_source", "EditorFonts", df_output_code); - - //replace default theme - Ref<Texture> di; - Ref<StyleBox> ds; - fill_default_theme(p_theme, df, df_doc, di, ds, EDSCALE); } diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 03cd2c9b6b..cc7f1cac43 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -555,7 +555,7 @@ void EditorHelp::_class_desc_select(const String &p_select) { if (select.find(".") != -1) { class_name = select.get_slice(".", 0); } else { - class_name = "@Global Scope"; + class_name = "@GlobalScope"; } emit_signal("go_to_help", "class_enum:" + class_name + ":" + select); return; @@ -1478,9 +1478,10 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { Color font_color_hl = p_rt->get_color("headline_color", "EditorHelp"); Color link_color = p_rt->get_color("accent_color", "Editor").linear_interpolate(font_color_hl, 0.8); - String bbcode = p_bbcode.replace("\t", " ").replace("\r", " ").strip_edges(); + String bbcode = p_bbcode.dedent().replace("\t", "").replace("\r", "").strip_edges(); List<String> tag_stack; + bool code_tag = false; int pos = 0; while (pos < bbcode.length()) { @@ -1491,7 +1492,10 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { brk_pos = bbcode.length(); if (brk_pos > pos) { - p_rt->add_text(bbcode.substr(pos, brk_pos - pos)); + String text = bbcode.substr(pos, brk_pos - pos); + if (!code_tag) + text = text.replace("\n", "\n\n"); + p_rt->add_text(text); } if (brk_pos == bbcode.length()) @@ -1500,7 +1504,11 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { int brk_end = bbcode.find("]", brk_pos + 1); if (brk_end == -1) { - p_rt->add_text(bbcode.substr(brk_pos, bbcode.length() - brk_pos)); + + String text = bbcode.substr(brk_pos, bbcode.length() - brk_pos); + if (!code_tag) + text = text.replace("\n", "\n\n"); + p_rt->add_text(text); break; } @@ -1509,20 +1517,23 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { if (tag.begins_with("/")) { bool tag_ok = tag_stack.size() && tag_stack.front()->get() == tag.substr(1, tag.length()); - if (tag_stack.size()) { - } if (!tag_ok) { p_rt->add_text("["); - pos++; + pos = brk_pos + 1; continue; } tag_stack.pop_front(); pos = brk_end + 1; + code_tag = false; if (tag != "/img") p_rt->pop(); + } else if (code_tag) { + + p_rt->add_text("["); + pos = brk_pos + 1; } else if (tag.begins_with("method ")) { @@ -1559,6 +1570,7 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) { //use monospace font p_rt->push_font(doc_code_font); + code_tag = true; pos = brk_end + 1; tag_stack.push_front(tag); } else if (tag == "center") { diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 3513126a9b..7627fecc43 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -147,7 +147,7 @@ void EditorNode::_update_scene_tabs() { void EditorNode::_update_title() { String appname = ProjectSettings::get_singleton()->get("application/config/name"); - String title = appname.empty() ? String(VERSION_FULL_NAME) : String(_MKSTR(VERSION_NAME) + String(" - ") + appname); + String title = appname.empty() ? String(VERSION_FULL_NAME) : String(VERSION_NAME + String(" - ") + appname); String edited = editor_data.get_edited_scene_root() ? editor_data.get_edited_scene_root()->get_filename() : String(); if (!edited.empty()) title += " - " + String(edited.get_file()); @@ -284,9 +284,10 @@ void EditorNode::_notification(int p_what) { if (p_what == EditorSettings::NOTIFICATION_EDITOR_SETTINGS_CHANGED) { scene_tabs->set_tab_close_display_policy((bool(EDITOR_DEF("interface/editor/always_show_close_button_in_scene_tabs", false)) ? Tabs::CLOSE_BUTTON_SHOW_ALWAYS : Tabs::CLOSE_BUTTON_SHOW_ACTIVE_ONLY)); property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/editor/capitalize_properties", true))); - Ref<Theme> theme = create_editor_theme(theme_base->get_theme()); + Ref<Theme> theme = create_custom_theme(theme_base->get_theme()); theme_base->set_theme(theme); + gui_base->set_theme(theme); gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); play_button_panel->add_style_override("panel", gui_base->get_stylebox("PlayButtonPanel", "EditorStyles")); @@ -704,7 +705,7 @@ void EditorNode::_get_scene_metadata(const String &p_file) { if (!scene) return; - String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); + String path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); Ref<ConfigFile> cf; cf.instance(); @@ -738,7 +739,7 @@ void EditorNode::_set_scene_metadata(const String &p_file, int p_idx) { scene->set_meta("__editor_run_settings__", Variant()); //clear it (no point in keeping it) scene->set_meta("__editor_plugin_states__", Variant()); - String path = EditorSettings::get_singleton()->get_project_settings_path().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); + String path = EditorSettings::get_singleton()->get_project_settings_dir().plus_file(p_file.get_file() + "-editstate-" + p_file.md5_text() + ".cfg"); Ref<ConfigFile> cf; cf.instance(); @@ -871,7 +872,7 @@ void EditorNode::_find_node_types(Node *p_node, int &count_2d, int &count_3d) { _find_node_types(p_node->get_child(i), count_2d, count_3d); } -void EditorNode::_save_scene_with_preview(String p_file) { +void EditorNode::_save_scene_with_preview(String p_file, int p_idx) { EditorProgress save("save", TTR("Saving Scene"), 4); save.step(TTR("Analyzing"), 0); @@ -905,27 +906,33 @@ void EditorNode::_save_scene_with_preview(String p_file) { int preview_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); preview_size *= EDSCALE; - int width, height; - if (img->get_width() > preview_size && img->get_width() >= img->get_height()) { - width = preview_size; - height = img->get_height() * preview_size / img->get_width(); - } else if (img->get_height() > preview_size && img->get_height() >= img->get_width()) { + // consider a square region + int vp_size = MIN(img->get_width(), img->get_height()); + int x = (img->get_width() - vp_size) / 2; + int y = (img->get_height() - vp_size) / 2; - height = preview_size; - width = img->get_width() * preview_size / img->get_height(); + img->convert(Image::FORMAT_RGB8); + + if (vp_size < preview_size) { + // just square it. + img->crop_from_point(x, y, vp_size, vp_size); } else { + int ratio = vp_size / preview_size; + int size = preview_size * (ratio / 2); - width = img->get_width(); - height = img->get_height(); + x = (img->get_width() - size) / 2; + y = (img->get_height() - size) / 2; + + img->crop_from_point(x, y, size, size); + // We could get better pictures with better filters + img->resize(preview_size, preview_size, Image::INTERPOLATE_CUBIC); } - img->convert(Image::FORMAT_RGB8); - img->resize(width, height); img->flip_y(); //save thumbnail directly, as thumbnailer may not update due to actual scene not changing md5 - String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp"); + String temp_path = EditorSettings::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_file).md5_text(); cache_base = temp_path.plus_file("resthumb-" + cache_base); @@ -937,7 +944,7 @@ void EditorNode::_save_scene_with_preview(String p_file) { } save.step(TTR("Saving Scene"), 4); - _save_scene(p_file); + _save_scene(p_file, p_idx); EditorResourcePreview::get_singleton()->check_for_invalidation(p_file); } @@ -1095,10 +1102,7 @@ void EditorNode::_dialog_action(String p_file) { if (file->get_mode() == EditorFileDialog::MODE_SAVE_FILE) { _save_default_environment(); - if (scene_idx != editor_data.get_edited_scene()) - _save_scene(p_file, scene_idx); - else - _save_scene_with_preview(p_file); + _save_scene_with_preview(p_file, scene_idx); if (scene_idx != -1) _discard_changes(); @@ -1111,7 +1115,7 @@ void EditorNode::_dialog_action(String p_file) { _save_default_environment(); _save_scene_with_preview(p_file); - _run(true); + _run(false, p_file); } } break; @@ -1200,7 +1204,7 @@ void EditorNode::_dialog_action(String p_file) { Ref<ConfigFile> config; config.instance(); - Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts-3.cfg")); + Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err == ERR_CANT_OPEN) { config.instance(); // new config @@ -1211,7 +1215,7 @@ void EditorNode::_dialog_action(String p_file) { _save_docks_to_config(config, p_file); - config->save(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts-3.cfg")); + config->save(EditorSettings::get_singleton()->get_editor_layouts_config()); layout_dialog->hide(); _update_layouts_menu(); @@ -1228,7 +1232,7 @@ void EditorNode::_dialog_action(String p_file) { Ref<ConfigFile> config; config.instance(); - Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts-3.cfg")); + Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err != OK || !config->has_section(p_file)) { show_warning(TTR("Layout name not found!")); @@ -1242,7 +1246,7 @@ void EditorNode::_dialog_action(String p_file) { config->set_value(p_file, E->get(), Variant()); } - config->save(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts-3.cfg")); + config->save(EditorSettings::get_singleton()->get_editor_layouts_config()); layout_dialog->hide(); _update_layouts_menu(); @@ -1825,7 +1829,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { if (scene && scene->get_filename() != "") { if (scene_idx != editor_data.get_edited_scene()) - _save_scene(scene->get_filename(), scene_idx); + _save_scene_with_preview(scene->get_filename(), scene_idx); else _save_scene_with_preview(scene->get_filename()); @@ -1933,6 +1937,15 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { } break; case FILE_EXPORT_TILESET: { + //Make sure that the scene has a root before trying to convert to tileset + if (!editor_data.get_edited_scene_root()) { + current_option = -1; + accept->get_ok()->set_text(TTR("I see..")); + accept->set_text(TTR("This operation can't be done without a root node.")); + accept->popup_centered_minsize(); + break; + } + List<String> extensions; Ref<TileSet> ml(memnew(TileSet)); ResourceSaver::get_recognized_extensions(ml, &extensions); @@ -3254,11 +3267,11 @@ void EditorNode::register_editor_types() { ClassDB::register_class<EditorScript>(); ClassDB::register_class<EditorSelection>(); ClassDB::register_class<EditorFileDialog>(); - ClassDB::register_class<EditorSettings>(); + ClassDB::register_virtual_class<EditorSettings>(); ClassDB::register_class<EditorSpatialGizmo>(); - ClassDB::register_class<EditorResourcePreview>(); + ClassDB::register_virtual_class<EditorResourcePreview>(); ClassDB::register_class<EditorResourcePreviewGenerator>(); - ClassDB::register_class<EditorFileSystem>(); + ClassDB::register_virtual_class<EditorFileSystem>(); ClassDB::register_class<EditorFileSystemDirectory>(); ClassDB::register_virtual_class<ScriptEditor>(); ClassDB::register_virtual_class<EditorInterface>(); @@ -3266,7 +3279,7 @@ void EditorNode::register_editor_types() { ClassDB::register_class<EditorResourceConversionPlugin>(); // FIXME: Is this stuff obsolete, or should it be ported to new APIs? - //ClassDB::register_class<EditorScenePostImport>(); + ClassDB::register_class<EditorScenePostImport>(); //ClassDB::register_type<EditorImportExport>(); } @@ -3574,7 +3587,7 @@ void EditorNode::_save_docks() { _save_docks_to_config(config, "docks"); editor_data.get_plugin_window_layout(config); - config->save(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg")); + config->save(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); } void EditorNode::_save_docks_to_config(Ref<ConfigFile> p_layout, const String &p_section) { @@ -3636,7 +3649,7 @@ void EditorNode::_load_docks() { Ref<ConfigFile> config; config.instance(); - Error err = config->load(EditorSettings::get_singleton()->get_project_settings_path().plus_file("editor_layout.cfg")); + Error err = config->load(EditorSettings::get_singleton()->get_project_settings_dir().plus_file("editor_layout.cfg")); if (err != OK) { //no config if (overridden_default_layout >= 0) { @@ -3805,7 +3818,7 @@ void EditorNode::_update_layouts_menu() { Ref<ConfigFile> config; config.instance(); - Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts-3.cfg")); + Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err != OK) { return; //no config } @@ -3853,7 +3866,7 @@ void EditorNode::_layout_menu_option(int p_id) { Ref<ConfigFile> config; config.instance(); - Error err = config->load(EditorSettings::get_singleton()->get_settings_path().plus_file("editor_layouts-3.cfg")); + Error err = config->load(EditorSettings::get_singleton()->get_editor_layouts_config()); if (err != OK) { return; //no config } @@ -4217,72 +4230,71 @@ Variant EditorNode::drag_resource(const Ref<Resource> &p_res, Control *p_from) { return drag_data; } -Variant EditorNode::drag_files(const Vector<String> &p_files, Control *p_from) { - - VBoxContainer *files = memnew(VBoxContainer); - - int max_files = 6; - - for (int i = 0; i < MIN(max_files, p_files.size()); i++) { - - Label *label = memnew(Label); - label->set_text(p_files[i].get_file()); - files->add_child(label); +Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_paths, Control *p_from) { + bool has_folder = false; + bool has_file = false; + for (int i = 0; i < p_paths.size(); i++) { + bool is_folder = p_paths[i].ends_with("/"); + has_folder |= is_folder; + has_file |= !is_folder; } - if (p_files.size() > max_files) { - + int max_rows = 6; + int num_rows = p_paths.size() > max_rows ? max_rows - 1 : p_paths.size(); //Don't waste a row to say "1 more file" - list it instead. + VBoxContainer *vbox = memnew(VBoxContainer); + for (int i = 0; i < num_rows; i++) { + HBoxContainer *hbox = memnew(HBoxContainer); + TextureRect *icon = memnew(TextureRect); Label *label = memnew(Label); - label->set_text(vformat(TTR("%d more file(s)"), p_files.size() - max_files)); - files->add_child(label); - } - Dictionary drag_data; - drag_data["type"] = "files"; - drag_data["files"] = p_files; - drag_data["from"] = p_from; - p_from->set_drag_preview(files); //wait until it enters scene - - return drag_data; -} - -Variant EditorNode::drag_files_and_dirs(const Vector<String> &p_files, Control *p_from) { - - VBoxContainer *files = memnew(VBoxContainer); - - int max_files = 6; - - for (int i = 0; i < MIN(max_files, p_files.size()); i++) { - - Label *label = memnew(Label); - label->set_text(p_files[i].get_file()); - files->add_child(label); + if (p_paths[i].ends_with("/")) { + label->set_text(p_paths[i].substr(0, p_paths[i].length() - 1).get_file()); + icon->set_texture(gui_base->get_icon("Folder", "EditorIcons")); + } else { + label->set_text(p_paths[i].get_file()); + icon->set_texture(gui_base->get_icon("File", "EditorIcons")); + } + icon->set_size(Size2(16, 16)); + hbox->add_child(icon); + hbox->add_child(label); + vbox->add_child(hbox); } - if (p_files.size() > max_files) { - + if (p_paths.size() > num_rows) { Label *label = memnew(Label); - label->set_text(vformat(TTR("%d more file(s) or folder(s)"), p_files.size() - max_files)); - files->add_child(label); + if (has_file && has_folder) { + label->set_text(vformat(TTR("%d more files or folders"), p_paths.size() - num_rows)); + } else if (has_folder) { + label->set_text(vformat(TTR("%d more folders"), p_paths.size() - num_rows)); + } else { + label->set_text(vformat(TTR("%d more files"), p_paths.size() - num_rows)); + } + vbox->add_child(label); } + p_from->set_drag_preview(vbox); //wait until it enters scene + Dictionary drag_data; - drag_data["type"] = "files_and_dirs"; - drag_data["files"] = p_files; + drag_data["type"] = has_folder ? "files_and_dirs" : "files"; + drag_data["files"] = p_paths; drag_data["from"] = p_from; - - p_from->set_drag_preview(files); //wait until it enters scene - return drag_data; } void EditorNode::_dropped_files(const Vector<String> &p_files, int p_screen) { - /* - String cur_path = filesystem_dock->get_current_path(); - for(int i=0;i<EditorImportExport::get_singleton()->get_import_plugin_count();i++) { - EditorImportExport::get_singleton()->get_import_plugin(i)->import_from_drop(p_files,cur_path); + String to_path = ProjectSettings::get_singleton()->globalize_path(get_filesystem_dock()->get_current_path()); + DirAccessRef dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); + + for (int i = 0; i < p_files.size(); i++) { + + String from = p_files[i]; + if (!ResourceFormatImporter::get_singleton()->can_be_imported(from)) { + continue; + } + String to = to_path.plus_file(from.get_file()); + dir->copy(from, to); } - */ + EditorFileSystem::get_singleton()->scan_changes(); } void EditorNode::_file_access_close_error_notify(const String &p_str) { @@ -4553,6 +4565,11 @@ static Node *_resource_get_edited_scene() { return EditorNode::get_singleton()->get_edited_scene(); } +void EditorNode::_print_handler(void *p_this, const String &p_string, bool p_error) { + EditorNode *en = (EditorNode *)p_this; + en->log->add_message(p_string, p_error); +} + EditorNode::EditorNode() { Resource::_get_local_scene_func = _resource_get_edited_scene; @@ -4690,9 +4707,9 @@ EditorNode::EditorNode() { theme_base->add_child(gui_base); gui_base->set_anchors_and_margins_preset(Control::PRESET_WIDE); - Ref<Theme> theme = create_editor_theme(); + Ref<Theme> theme = create_custom_theme(); theme_base->set_theme(theme); - gui_base->set_theme(create_custom_theme()); + gui_base->set_theme(theme); gui_base->add_style_override("panel", gui_base->get_stylebox("Background", "EditorStyles")); resource_preview = memnew(EditorResourcePreview); @@ -4789,7 +4806,12 @@ EditorNode::EditorNode() { dock_tab_move_left->set_focus_mode(Control::FOCUS_NONE); dock_tab_move_left->connect("pressed", this, "_dock_move_left"); dock_hb->add_child(dock_tab_move_left); - dock_hb->add_spacer(); + + Label *dock_label = memnew(Label); + dock_label->set_text(TTR("Dock Position")); + dock_label->set_h_size_flags(Control::SIZE_EXPAND_FILL); + dock_hb->add_child(dock_label); + dock_tab_move_right = memnew(ToolButton); dock_tab_move_right->set_icon(theme->get_icon("Forward", "EditorIcons")); dock_tab_move_right->set_focus_mode(Control::FOCUS_NONE); @@ -5387,12 +5409,12 @@ EditorNode::EditorNode() { save_confirmation->connect("confirmed", this, "_menu_confirm_current"); save_confirmation->connect("custom_action", this, "_discard_changes"); - file_templates = memnew(FileDialog); + file_templates = memnew(EditorFileDialog); file_templates->set_title(TTR("Import Templates From ZIP File")); gui_base->add_child(file_templates); - file_templates->set_mode(FileDialog::MODE_OPEN_FILE); - file_templates->set_access(FileDialog::ACCESS_FILESYSTEM); + file_templates->set_mode(EditorFileDialog::MODE_OPEN_FILE); + file_templates->set_access(EditorFileDialog::ACCESS_FILESYSTEM); file_templates->clear_filters(); file_templates->add_filter("*.tpz ; Template Package"); @@ -5400,15 +5422,15 @@ EditorNode::EditorNode() { gui_base->add_child(file); file->set_current_dir("res://"); - file_export = memnew(FileDialog); - file_export->set_access(FileDialog::ACCESS_FILESYSTEM); + file_export = memnew(EditorFileDialog); + file_export->set_access(EditorFileDialog::ACCESS_FILESYSTEM); gui_base->add_child(file_export); file_export->set_title(TTR("Export Project")); file_export->connect("file_selected", this, "_dialog_action"); - file_export_lib = memnew(FileDialog); + file_export_lib = memnew(EditorFileDialog); file_export_lib->set_title(TTR("Export Library")); - file_export_lib->set_mode(FileDialog::MODE_SAVE_FILE); + file_export_lib->set_mode(EditorFileDialog::MODE_SAVE_FILE); file_export_lib->connect("file_selected", this, "_dialog_action"); file_export_lib_merge = memnew(CheckButton); file_export_lib_merge->set_text(TTR("Merge With Existing")); @@ -5421,10 +5443,10 @@ EditorNode::EditorNode() { file_export_password->set_editable(false); file_export->get_vbox()->add_margin_child(TTR("Password:"), file_export_password); - file_script = memnew(FileDialog); + file_script = memnew(EditorFileDialog); file_script->set_title(TTR("Open & Run a Script")); - file_script->set_access(FileDialog::ACCESS_FILESYSTEM); - file_script->set_mode(FileDialog::MODE_OPEN_FILE); + file_script->set_access(EditorFileDialog::ACCESS_FILESYSTEM); + file_script->set_mode(EditorFileDialog::MODE_OPEN_FILE); List<String> sexts; ResourceLoader::get_recognized_extensions_for_type("Script", &sexts); for (List<String>::Element *E = sexts.front(); E; E = E->next()) { @@ -5534,6 +5556,10 @@ EditorNode::EditorNode() { spatial_mat_convert.instance(); resource_conversion_plugins.push_back(spatial_mat_convert); + Ref<CanvasItemMaterialConversionPlugin> canvas_item_mat_convert; + canvas_item_mat_convert.instance(); + resource_conversion_plugins.push_back(canvas_item_mat_convert); + Ref<ParticlesMaterialConversionPlugin> particles_mat_convert; particles_mat_convert.instance(); resource_conversion_plugins.push_back(particles_mat_convert); @@ -5649,6 +5675,10 @@ EditorNode::EditorNode() { _dim_timer->connect("timeout", this, "_dim_timeout"); add_child(_dim_timer); + print_handler.printfunc = _print_handler; + print_handler.userdata = this; + add_print_handler(&print_handler); + ED_SHORTCUT("editor/editor_2d", TTR("Open 2D Editor"), KEY_F1); ED_SHORTCUT("editor/editor_3d", TTR("Open 3D Editor"), KEY_F2); ED_SHORTCUT("editor/editor_script", TTR("Open Script Editor"), KEY_F3); //hack neded for script editor F3 search to work :) Assign like this or don't use F3 @@ -5660,6 +5690,7 @@ EditorNode::EditorNode() { EditorNode::~EditorNode() { + remove_print_handler(&print_handler); memdelete(EditorHelp::get_doc_data()); memdelete(editor_selection); memdelete(editor_plugins_over); diff --git a/editor/editor_node.h b/editor/editor_node.h index 32d46e686b..54cb414835 100644 --- a/editor/editor_node.h +++ b/editor/editor_node.h @@ -30,6 +30,7 @@ #ifndef EDITOR_NODE_H #define EDITOR_NODE_H +#include "core/print_string.h" #include "editor/connections_dialog.h" #include "editor/create_dialog.h" #include "editor/editor_about.h" @@ -294,10 +295,10 @@ private: ProjectSettingsEditor *project_settings; EditorFileDialog *file; ExportTemplateManager *export_template_manager; - FileDialog *file_templates; - FileDialog *file_export; - FileDialog *file_export_lib; - FileDialog *file_script; + EditorFileDialog *file_templates; + EditorFileDialog *file_export; + EditorFileDialog *file_export_lib; + EditorFileDialog *file_script; CheckButton *file_export_lib_merge; LineEdit *file_export_password; String current_path; @@ -503,7 +504,7 @@ private: void _mark_unsaved_scenes(); void _find_node_types(Node *p_node, int &count_2d, int &count_3d); - void _save_scene_with_preview(String p_file); + void _save_scene_with_preview(String p_file, int p_idx = -1); Map<String, Set<String> > dependency_errors; @@ -610,6 +611,9 @@ private: Vector<Ref<EditorResourceConversionPlugin> > resource_conversion_plugins; + PrintHandlerList print_handler; + static void _print_handler(void *p_this, const String &p_string, bool p_error); + protected: void _notification(int p_what); static void _bind_methods(); @@ -765,8 +769,7 @@ public: void remove_bottom_panel_item(Control *p_item); Variant drag_resource(const Ref<Resource> &p_res, Control *p_from); - Variant drag_files(const Vector<String> &p_files, Control *p_from); - Variant drag_files_and_dirs(const Vector<String> &p_files, Control *p_from); + Variant drag_files_and_dirs(const Vector<String> &p_paths, Control *p_from); void add_tool_menu_item(const String &p_name, Object *p_handler, const String &p_callback, const Variant &p_ud = Variant()); void add_tool_submenu_item(const String &p_name, PopupMenu *p_submenu); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index c8abc1f9db..38e8b301b7 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -76,11 +76,11 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> //VS::get_singleton()->camera_set_perspective(camera,45,0.1,10); VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); - RID light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + RID light = VS::get_singleton()->directional_light_create(); RID light_instance = VS::get_singleton()->instance_create2(light, scenario); VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - RID light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + RID light2 = VS::get_singleton()->directional_light_create(); VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); //VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); RID light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); @@ -102,14 +102,14 @@ Vector<Ref<Texture> > EditorInterface::make_mesh_previews(const Vector<Ref<Mesh> textures.push_back(Ref<Texture>()); continue; } - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); print_line("aabb: " + aabb); Vector3 ofs = aabb.position + aabb.size * 0.5; aabb.position -= ofs; Transform xform; xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.25); xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.25) * xform.basis; - Rect3 rot_aabb = xform.xform(aabb); + AABB rot_aabb = xform.xform(aabb); print_line("rot_aabb: " + rot_aabb); float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5; if (m == 0) { @@ -455,7 +455,11 @@ void EditorPlugin::make_visible(bool p_visible) { void EditorPlugin::edit(Object *p_object) { if (get_script_instance() && get_script_instance()->has_method("edit")) { - get_script_instance()->call("edit", p_object); + if (p_object->is_class("Resource")) { + get_script_instance()->call("edit", Ref<Resource>(Object::cast_to<Resource>(p_object))); + } else { + get_script_instance()->call("edit", p_object); + } } } diff --git a/editor/editor_resource_preview.cpp b/editor/editor_resource_preview.cpp index f92962a4cb..467451cd2b 100644 --- a/editor/editor_resource_preview.cpp +++ b/editor/editor_resource_preview.cpp @@ -86,7 +86,6 @@ void EditorResourcePreview::_thread_func(void *ud) { void EditorResourcePreview::_preview_ready(const String &p_str, const Ref<Texture> &p_texture, ObjectID id, const StringName &p_func, const Variant &p_ud) { - //print_line("preview is ready"); preview_mutex->lock(); String path = p_str; @@ -121,7 +120,6 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem &p_item, c type = p_item.resource->get_class(); else type = ResourceLoader::get_resource_type(p_item.path); - //print_line("resource type is: "+type); if (type == "") return Ref<Texture>(); //could not guess type @@ -144,7 +142,6 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem &p_item, c if (!p_item.resource.is_valid()) { // cache the preview in case it's a resource on disk if (generated.is_valid()) { - //print_line("was generated"); int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); thumbnail_size *= EDSCALE; //wow it generated a preview... save cache @@ -164,15 +161,11 @@ Ref<Texture> EditorResourcePreview::_generate_preview(const QueueItem &p_item, c void EditorResourcePreview::_thread() { - //print_line("begin thread"); while (!exit) { - //print_line("wait for semaphore"); preview_sem->wait(); preview_mutex->lock(); - //print_line("blue team go"); - if (queue.size()) { QueueItem item = queue.front()->get(); @@ -189,12 +182,11 @@ void EditorResourcePreview::_thread() { preview_mutex->unlock(); } else { + preview_mutex->unlock(); Ref<ImageTexture> texture; - //print_line("pop from queue "+item.path); - int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); thumbnail_size *= EDSCALE; @@ -206,7 +198,7 @@ void EditorResourcePreview::_thread() { } else { - String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp"); + String temp_path = EditorSettings::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(item.path).md5_text(); cache_base = temp_path.plus_file("resthumb-" + cache_base); @@ -304,7 +296,6 @@ void EditorResourcePreview::queue_edited_resource_preview(const Ref<Resource> &p cache.erase(path_id); //erase if exists, since it will be regen - //print_line("send to thread "+p_path); QueueItem item; item.function = p_receiver_func; item.id = p_receiver->get_instance_id(); @@ -328,7 +319,6 @@ void EditorResourcePreview::queue_resource_preview(const String &p_path, Object return; } - //print_line("send to thread "+p_path); QueueItem item; item.function = p_receiver_func; item.id = p_receiver->get_instance_id(); diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index bc91fcdf04..d228dd2581 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -135,6 +135,7 @@ bool EditorSettings::_get(const StringName &p_name, Variant &r_ret) const { void EditorSettings::_initial_set(const StringName &p_name, const Variant &p_value) { set(p_name, p_value); props[p_name].initial = p_value; + props[p_name].initial_set = true; } struct _EVCSort { @@ -214,6 +215,14 @@ void EditorSettings::_add_property_info_bind(const Dictionary &p_info) { } // Default configs +bool EditorSettings::has_default_value(const String &p_setting) const { + + _THREAD_SAFE_METHOD_ + + if (!props.has(p_setting)) + return false; + return props[p_setting].initial_set; +} void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { @@ -325,6 +334,7 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) { _initial_set("text_editor/line_numbers/show_line_numbers", true); _initial_set("text_editor/line_numbers/line_numbers_zero_padded", false); _initial_set("text_editor/line_numbers/show_breakpoint_gutter", true); + _initial_set("text_editor/line_numbers/code_folding", true); _initial_set("text_editor/line_numbers/show_line_length_guideline", false); _initial_set("text_editor/line_numbers/line_length_guideline_column", 80); hints["text_editor/line_numbers/line_length_guideline_column"] = PropertyInfo(Variant::INT, "text_editor/line_numbers/line_length_guideline_column", PROPERTY_HINT_RANGE, "20, 160, 10"); @@ -630,10 +640,14 @@ void EditorSettings::create() { return; //pointless DirAccess *dir = NULL; - Variant meta; + String data_path; + String data_dir; String config_path; String config_dir; + String cache_path; + String cache_dir; + Ref<ConfigFile> extra_config = memnew(ConfigFile); String exe_path = OS::get_singleton()->get_executable_path().get_base_dir(); @@ -650,38 +664,50 @@ void EditorSettings::create() { memdelete(d); if (self_contained) { - // editor is self contained + + // editor is self contained, all in same folder + data_path = exe_path; + data_dir = data_path.plus_file("editor_data"); config_path = exe_path; - config_dir = "editor_data"; + config_dir = data_dir; + cache_path = exe_path; + cache_dir = data_dir.plus_file("cache"); } else { - if (OS::get_singleton()->has_environment("APPDATA")) { - // Most likely under windows, save here - config_path = OS::get_singleton()->get_environment("APPDATA"); - config_dir = String(_MKSTR(VERSION_SHORT_NAME)).capitalize(); - } else if (OS::get_singleton()->has_environment("HOME")) { - - config_path = OS::get_singleton()->get_environment("HOME"); - config_dir = "." + String(_MKSTR(VERSION_SHORT_NAME)).to_lower(); + // Typically XDG_DATA_HOME or %APPDATA% + data_path = OS::get_singleton()->get_data_path(); + data_dir = data_path.plus_file(OS::get_singleton()->get_godot_dir_name()); + // Can be different from data_path e.g. on Linux or macOS + config_path = OS::get_singleton()->get_config_path(); + config_dir = config_path.plus_file(OS::get_singleton()->get_godot_dir_name()); + // Can be different from above paths, otherwise a subfolder of data_dir + cache_path = OS::get_singleton()->get_cache_path(); + if (cache_path == data_path) { + cache_dir = data_dir.plus_file("cache"); + } else { + cache_dir = cache_path.plus_file(OS::get_singleton()->get_godot_dir_name()); } - }; + } ClassDB::register_class<EditorSettings>(); //otherwise it can't be unserialized + String config_file_path; - if (config_path != "") { + if (data_path != "" && config_path != "" && cache_path != "") { + + // Validate/create data dir and subdirectories dir = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - if (dir->change_dir(config_path) != OK) { - ERR_PRINT("Cannot find path for config directory!"); + if (dir->change_dir(data_path) != OK) { + ERR_PRINT("Cannot find path for data directory!"); memdelete(dir); goto fail; } - if (dir->change_dir(config_dir) != OK) { - dir->make_dir(config_dir); - if (dir->change_dir(config_dir) != OK) { - ERR_PRINT("Cannot create config directory!"); + if (dir->change_dir(data_dir) != OK) { + dir->make_dir(data_dir); + if (dir->change_dir(data_dir) != OK) { + ERR_PRINT("Cannot create data directory!"); memdelete(dir); goto fail; } @@ -690,10 +716,43 @@ void EditorSettings::create() { if (dir->change_dir("templates") != OK) { dir->make_dir("templates"); } else { - dir->change_dir(".."); } + // Validate/create cache dir + + if (dir->change_dir(cache_path) != OK) { + ERR_PRINT("Cannot find path for cache directory!"); + memdelete(dir); + goto fail; + } + + if (dir->change_dir(cache_dir) != OK) { + dir->make_dir(cache_dir); + if (dir->change_dir(cache_dir) != OK) { + ERR_PRINT("Cannot create cache directory!"); + memdelete(dir); + goto fail; + } + } + + // Validate/create config dir and subdirectories + + if (dir->change_dir(config_path) != OK) { + ERR_PRINT("Cannot find path for config directory!"); + memdelete(dir); + goto fail; + } + + if (dir->change_dir(config_dir) != OK) { + dir->make_dir(config_dir); + if (dir->change_dir(config_dir) != OK) { + ERR_PRINT("Cannot create config directory!"); + memdelete(dir); + goto fail; + } + } + if (dir->change_dir("text_editor_themes") != OK) { dir->make_dir("text_editor_themes"); } else { @@ -705,52 +764,40 @@ void EditorSettings::create() { } else { dir->change_dir(".."); } - _create_script_templates(dir->get_current_dir() + "/script_templates"); + _create_script_templates(dir->get_current_dir().plus_file("script_templates")); - if (dir->change_dir("tmp") != OK) { - dir->make_dir("tmp"); + if (dir->change_dir("projects") != OK) { + dir->make_dir("projects"); } else { - dir->change_dir(".."); } - if (dir->change_dir("config") != OK) { - dir->make_dir("config"); - } else { - - dir->change_dir(".."); - } + // Validate/create project-specific config dir - dir->change_dir("config"); + dir->change_dir("projects"); + String project_config_dir = ProjectSettings::get_singleton()->get_resource_path(); + if (project_config_dir.ends_with("/")) + project_config_dir = config_path.substr(0, project_config_dir.size() - 1); + project_config_dir = project_config_dir.get_file() + "-" + project_config_dir.md5_text(); - String pcp = ProjectSettings::get_singleton()->get_resource_path(); - if (pcp.ends_with("/")) - pcp = config_path.substr(0, pcp.size() - 1); - pcp = pcp.get_file() + "-" + pcp.md5_text(); - - if (dir->change_dir(pcp)) { - dir->make_dir(pcp); + if (dir->change_dir(project_config_dir) != OK) { + dir->make_dir(project_config_dir); } else { dir->change_dir(".."); } - dir->change_dir(".."); - // path at least is validated, so validate config file - - String config_file_name = "editor_settings-" + String(_MKSTR(VERSION_MAJOR)) + ".tres"; - config_file_path = config_path + "/" + config_dir + "/" + config_file_name; - - String open_path = config_file_path; + // Validate editor config file + String config_file_name = "editor_settings-" + itos(VERSION_MAJOR) + ".tres"; + config_file_path = config_dir.plus_file(config_file_name); if (!dir->file_exists(config_file_name)) { - goto fail; } memdelete(dir); - singleton = ResourceLoader::load(open_path, "EditorSettings"); + singleton = ResourceLoader::load(config_file_path, "EditorSettings"); if (singleton.is_null()) { WARN_PRINT("Could not open config file."); @@ -759,8 +806,10 @@ void EditorSettings::create() { singleton->save_changed_setting = true; singleton->config_file_path = config_file_path; - singleton->project_config_path = pcp; - singleton->settings_path = config_path + "/" + config_dir; + singleton->project_config_dir = project_config_dir; + singleton->settings_dir = config_dir; + singleton->data_dir = data_dir; + singleton->cache_dir = cache_dir; if (OS::get_singleton()->is_stdout_verbose()) { @@ -790,7 +839,9 @@ fail: singleton = Ref<EditorSettings>(memnew(EditorSettings)); singleton->save_changed_setting = true; singleton->config_file_path = config_file_path; - singleton->settings_path = config_path + "/" + config_dir; + singleton->settings_dir = config_dir; + singleton->data_dir = data_dir; + singleton->cache_dir = cache_dir; singleton->_load_defaults(extra_config); singleton->setup_language(); singleton->setup_network(); @@ -834,10 +885,10 @@ void EditorSettings::setup_network() { hint += ip; } - set("network/debug/remote_host", lip); + _initial_set("network/debug/remote_host", lip); add_property_hint(PropertyInfo(Variant::STRING, "network/debug/remote_host", PROPERTY_HINT_ENUM, hint)); - set("network/debug/remote_port", port); + _initial_set("network/debug/remote_port", port); add_property_hint(PropertyInfo(Variant::INT, "network/debug/remote_port", PROPERTY_HINT_RANGE, "1,65535,1")); } @@ -913,18 +964,23 @@ void EditorSettings::raise_order(const String &p_setting) { void EditorSettings::set_initial_value(const StringName &p_setting, const Variant &p_value) { - ERR_FAIL_COND(!props.has(p_setting)); + if (!props.has(p_setting)) + return; props[p_setting].initial = p_value; + props[p_setting].initial_set = true; } Variant _EDITOR_DEF(const String &p_setting, const Variant &p_default) { + Variant ret = p_default; if (EditorSettings::get_singleton()->has_setting(p_setting)) - return EditorSettings::get_singleton()->get(p_setting); - EditorSettings::get_singleton()->set(p_setting, p_default); - EditorSettings::get_singleton()->set_initial_value(p_setting, p_default); + ret = EditorSettings::get_singleton()->get(p_setting); + if (!EditorSettings::get_singleton()->has_default_value(p_setting)) { + EditorSettings::get_singleton()->set_initial_value(p_setting, p_default); + EditorSettings::get_singleton()->set(p_setting, p_default); + } - return p_default; + return ret; } Variant _EDITOR_GET(const String &p_setting) { @@ -956,21 +1012,52 @@ void EditorSettings::add_property_hint(const PropertyInfo &p_hint) { hints[p_hint.name] = p_hint; } -// Settings paths and saved metadata +// Data directories -String EditorSettings::get_settings_path() const { +String EditorSettings::get_data_dir() const { - return settings_path; + return data_dir; } -String EditorSettings::get_project_settings_path() const { +String EditorSettings::get_templates_dir() const { - return get_settings_path().plus_file("config").plus_file(project_config_path); + return get_data_dir().plus_file("templates"); } +// Config directories + +String EditorSettings::get_settings_dir() const { + + return settings_dir; +} + +String EditorSettings::get_project_settings_dir() const { + + return get_settings_dir().plus_file("projects").plus_file(project_config_dir); +} + +String EditorSettings::get_text_editor_themes_dir() const { + + return get_settings_dir().plus_file("text_editor_themes"); +} + +String EditorSettings::get_script_templates_dir() const { + + return get_settings_dir().plus_file("script_templates"); +} + +// Cache directory + +String EditorSettings::get_cache_dir() const { + + return cache_dir; +} + +// Metadata + void EditorSettings::set_project_metadata(const String &p_section, const String &p_key, Variant p_data) { Ref<ConfigFile> cf = memnew(ConfigFile); - String path = get_project_settings_path().plus_file("project_metadata.cfg"); + String path = get_project_settings_dir().plus_file("project_metadata.cfg"); cf->load(path); cf->set_value(p_section, p_key, p_data); cf->save(path); @@ -978,7 +1065,7 @@ void EditorSettings::set_project_metadata(const String &p_section, const String Variant EditorSettings::get_project_metadata(const String &p_section, const String &p_key, Variant p_default) { Ref<ConfigFile> cf = memnew(ConfigFile); - String path = get_project_settings_path().plus_file("project_metadata.cfg"); + String path = get_project_settings_dir().plus_file("project_metadata.cfg"); Error err = cf->load(path); if (err != OK) { return p_default; @@ -989,7 +1076,7 @@ Variant EditorSettings::get_project_metadata(const String &p_section, const Stri void EditorSettings::set_favorite_dirs(const Vector<String> &p_favorites_dirs) { favorite_dirs = p_favorites_dirs; - FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("favorite_dirs"), FileAccess::WRITE); + FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("favorite_dirs"), FileAccess::WRITE); if (f) { for (int i = 0; i < favorite_dirs.size(); i++) f->store_line(favorite_dirs[i]); @@ -1005,7 +1092,7 @@ Vector<String> EditorSettings::get_favorite_dirs() const { void EditorSettings::set_recent_dirs(const Vector<String> &p_recent_dirs) { recent_dirs = p_recent_dirs; - FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("recent_dirs"), FileAccess::WRITE); + FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("recent_dirs"), FileAccess::WRITE); if (f) { for (int i = 0; i < recent_dirs.size(); i++) f->store_line(recent_dirs[i]); @@ -1020,7 +1107,7 @@ Vector<String> EditorSettings::get_recent_dirs() const { void EditorSettings::load_favorites() { - FileAccess *f = FileAccess::open(get_project_settings_path().plus_file("favorite_dirs"), FileAccess::READ); + FileAccess *f = FileAccess::open(get_project_settings_dir().plus_file("favorite_dirs"), FileAccess::READ); if (f) { String line = f->get_line().strip_edges(); while (line != "") { @@ -1030,7 +1117,7 @@ void EditorSettings::load_favorites() { memdelete(f); } - f = FileAccess::open(get_project_settings_path().plus_file("recent_dirs"), FileAccess::READ); + f = FileAccess::open(get_project_settings_dir().plus_file("recent_dirs"), FileAccess::READ); if (f) { String line = f->get_line().strip_edges(); while (line != "") { @@ -1043,7 +1130,7 @@ void EditorSettings::load_favorites() { void EditorSettings::list_text_editor_themes() { String themes = "Adaptive,Default"; - DirAccess *d = DirAccess::open(get_settings_path().plus_file("text_editor_themes")); + DirAccess *d = DirAccess::open(get_text_editor_themes_dir()); if (d) { d->list_dir_begin(); String file = d->get_next(); @@ -1065,7 +1152,7 @@ void EditorSettings::load_text_editor_theme() { return; } - String theme_path = get_settings_path().plus_file("text_editor_themes").plus_file((String)get("text_editor/theme/color_theme") + ".tet"); + String theme_path = get_text_editor_themes_dir().plus_file((String)get("text_editor/theme/color_theme") + ".tet"); Ref<ConfigFile> cf = memnew(ConfigFile); Error err = cf->load(theme_path); @@ -1103,9 +1190,9 @@ bool EditorSettings::import_text_editor_theme(String p_file) { return false; } - DirAccess *d = DirAccess::open(get_settings_path().plus_file("text_editor_themes")); + DirAccess *d = DirAccess::open(get_text_editor_themes_dir()); if (d) { - d->copy(p_file, get_settings_path().plus_file("text_editor_themes").plus_file(p_file.get_file())); + d->copy(p_file, get_text_editor_themes_dir().plus_file(p_file.get_file())); memdelete(d); return true; } @@ -1120,7 +1207,7 @@ bool EditorSettings::save_text_editor_theme() { if (p_file.get_file().to_lower() == "default" || p_file.get_file().to_lower() == "adaptive") { return false; } - String theme_path = get_settings_path().plus_file("text_editor_themes").plus_file(p_file + ".tet"); + String theme_path = get_text_editor_themes_dir().plus_file(p_file + ".tet"); return _save_text_editor_theme(theme_path); } @@ -1138,7 +1225,7 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) { list_text_editor_themes(); String theme_name = p_file.substr(0, p_file.length() - 4).get_file(); - if (p_file.get_base_dir() == get_settings_path().plus_file("text_editor_themes")) { + if (p_file.get_base_dir() == get_text_editor_themes_dir()) { _initial_set("text_editor/theme/color_theme", theme_name); load_text_editor_theme(); } @@ -1150,7 +1237,7 @@ bool EditorSettings::save_text_editor_theme_as(String p_file) { Vector<String> EditorSettings::get_script_templates(const String &p_extension) { Vector<String> templates; - DirAccess *d = DirAccess::open(get_settings_path().plus_file("script_templates")); + DirAccess *d = DirAccess::open(get_script_templates_dir()); if (d) { d->list_dir_begin(); String file = d->get_next(); @@ -1166,6 +1253,11 @@ Vector<String> EditorSettings::get_script_templates(const String &p_extension) { return templates; } +String EditorSettings::get_editor_layouts_config() const { + + return get_settings_dir().plus_file("editor_layouts.cfg"); +} + // Shortcuts void EditorSettings::add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcut) { @@ -1272,8 +1364,8 @@ void EditorSettings::_bind_methods() { ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &EditorSettings::property_get_revert); ClassDB::bind_method(D_METHOD("add_property_info", "info"), &EditorSettings::_add_property_info_bind); - 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); + ClassDB::bind_method(D_METHOD("get_settings_dir"), &EditorSettings::get_settings_dir); + ClassDB::bind_method(D_METHOD("get_project_settings_dir"), &EditorSettings::get_project_settings_dir); ClassDB::bind_method(D_METHOD("set_favorite_dirs", "dirs"), &EditorSettings::set_favorite_dirs); ClassDB::bind_method(D_METHOD("get_favorite_dirs"), &EditorSettings::get_favorite_dirs); diff --git a/editor/editor_settings.h b/editor/editor_settings.h index a74be6494a..f11f4dfd43 100644 --- a/editor/editor_settings.h +++ b/editor/editor_settings.h @@ -66,11 +66,13 @@ private: int order; Variant variant; Variant initial; + bool initial_set; bool hide_from_editor; bool save; VariantContainer() { order = 0; hide_from_editor = false; + initial_set = false; save = false; } VariantContainer(const Variant &p_variant, int p_order) { @@ -91,9 +93,11 @@ private: Map<String, Ref<ShortCut> > shortcuts; String resource_path; + String settings_dir; + String data_dir; + String cache_dir; String config_file_path; - String settings_path; - String project_config_path; + String project_config_dir; Vector<String> favorite_dirs; Vector<String> recent_dirs; @@ -128,6 +132,7 @@ public: static void destroy(); void set_optimize_save(bool p_optimize); + bool has_default_value(const String &p_setting) const; void set_setting(const String &p_setting, const Variant &p_value); Variant get_setting(const String &p_setting) const; bool has_setting(const String &p_setting) const; @@ -144,8 +149,13 @@ public: void set_resource_clipboard(const Ref<Resource> &p_resource) { clipboard = p_resource; } Ref<Resource> get_resource_clipboard() const { return clipboard; } - String get_settings_path() const; - String get_project_settings_path() const; + String get_data_dir() const; + String get_templates_dir() const; + String get_settings_dir() const; + String get_project_settings_dir() const; + String get_text_editor_themes_dir() const; + String get_script_templates_dir() const; + String get_cache_dir() const; void set_project_metadata(const String &p_section, const String &p_key, Variant p_data); Variant get_project_metadata(const String &p_section, const String &p_key, Variant p_default); @@ -163,6 +173,7 @@ public: bool save_text_editor_theme_as(String p_file); Vector<String> get_script_templates(const String &p_extension); + String get_editor_layouts_config() const; void add_shortcut(const String &p_name, Ref<ShortCut> &p_shortcut); bool is_shortcut(const String &p_name, const Ref<InputEvent> &p_event) const; diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 29859a1a56..0f9f50095d 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -568,6 +568,11 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("modulate_arrow", "OptionButton", true); // CheckButton + theme->set_stylebox("normal", "CheckButton", style_menu); + theme->set_stylebox("pressed", "CheckButton", style_menu); + theme->set_stylebox("disabled", "CheckButton", style_menu); + theme->set_stylebox("hover", "CheckButton", style_menu); + theme->set_icon("on", "CheckButton", theme->get_icon("GuiToggleOn", "EditorIcons")); theme->set_icon("off", "CheckButton", theme->get_icon("GuiToggleOff", "EditorIcons")); @@ -577,7 +582,22 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color_disabled", "CheckButton", font_color_disabled); theme->set_color("icon_color_hover", "CheckButton", font_color_hl); + theme->set_constant("hseparation", "CheckButton", 4 * EDSCALE); + theme->set_constant("check_vadjust", "CheckButton", 0 * EDSCALE); + // Checkbox + Ref<StyleBoxFlat> sb_checkbox = style_menu->duplicate(); + // HACK, in reality, the checkbox draws the text over the icon by default, so the margin compensates that. + const int cb_w = theme->get_icon("GuiChecked", "EditorIcons")->get_width() + default_margin_size; + sb_checkbox->set_default_margin(MARGIN_LEFT, cb_w * EDSCALE); + sb_checkbox->set_default_margin(MARGIN_RIGHT, default_margin_size * EDSCALE); + sb_checkbox->set_default_margin(MARGIN_TOP, default_margin_size * EDSCALE); + sb_checkbox->set_default_margin(MARGIN_BOTTOM, default_margin_size * EDSCALE); + + theme->set_stylebox("normal", "CheckBox", sb_checkbox); + theme->set_stylebox("pressed", "CheckBox", sb_checkbox); + theme->set_stylebox("disabled", "CheckBox", sb_checkbox); + theme->set_stylebox("hover", "CheckBox", sb_checkbox); theme->set_icon("checked", "CheckBox", theme->get_icon("GuiChecked", "EditorIcons")); theme->set_icon("unchecked", "CheckBox", theme->get_icon("GuiUnchecked", "EditorIcons")); theme->set_icon("radio_checked", "CheckBox", theme->get_icon("GuiRadioChecked", "EditorIcons")); @@ -589,6 +609,9 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color_disabled", "CheckBox", font_color_disabled); theme->set_color("icon_color_hover", "CheckBox", font_color_hl); + theme->set_constant("hseparation", "CheckBox", 4 * EDSCALE); + theme->set_constant("check_vadjust", "CheckBox", 0 * EDSCALE); + // PopupMenu Ref<StyleBoxFlat> style_popup_menu = style_popup; theme->set_stylebox("panel", "PopupMenu", style_popup_menu); @@ -801,6 +824,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_constant("close_h_ofs", "WindowDialog", 22 * EDSCALE); theme->set_constant("close_v_ofs", "WindowDialog", 20 * EDSCALE); theme->set_constant("title_height", "WindowDialog", 24 * EDSCALE); + theme->set_font("title_font", "WindowDialog", theme->get_font("title", "EditorFonts")); // complex window, for now only Editor settings and Project settings Ref<StyleBoxFlat> style_complex_window = style_window->duplicate(); @@ -1043,12 +1067,14 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { return theme; } -Ref<Theme> create_custom_theme() { +Ref<Theme> create_custom_theme(const Ref<Theme> p_theme) { Ref<Theme> theme; String custom_theme = EditorSettings::get_singleton()->get("interface/theme/custom_theme"); if (custom_theme != "") { theme = ResourceLoader::load(custom_theme); + } else { + theme = create_editor_theme(p_theme); } String global_font = EditorSettings::get_singleton()->get("interface/editor/custom_font"); diff --git a/editor/editor_themes.h b/editor/editor_themes.h index a644c5936f..6f3b83e0b0 100644 --- a/editor/editor_themes.h +++ b/editor/editor_themes.h @@ -34,6 +34,6 @@ Ref<Theme> create_editor_theme(Ref<Theme> p_theme = NULL); -Ref<Theme> create_custom_theme(); +Ref<Theme> create_custom_theme(Ref<Theme> p_theme = NULL); #endif diff --git a/editor/export_template_manager.cpp b/editor/export_template_manager.cpp index 8641fc7667..d208bbe662 100644 --- a/editor/export_template_manager.cpp +++ b/editor/export_template_manager.cpp @@ -35,6 +35,7 @@ #include "io/zip_io.h" #include "os/dir_access.h" #include "version.h" + void ExportTemplateManager::_update_template_list() { while (current_hb->get_child_count()) { @@ -46,7 +47,7 @@ void ExportTemplateManager::_update_template_list() { } DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - Error err = d->change_dir(EditorSettings::get_singleton()->get_settings_path().plus_file("templates")); + Error err = d->change_dir(EditorSettings::get_singleton()->get_templates_dir()); d->list_dir_begin(); Set<String> templates; @@ -66,7 +67,7 @@ void ExportTemplateManager::_update_template_list() { memdelete(d); - String current_version = itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + _MKSTR(VERSION_STATUS) + VERSION_MODULE_CONFIG; + String current_version = itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR) + "-" + VERSION_STATUS + VERSION_MODULE_CONFIG; Label *current = memnew(Label); current->set_h_size_flags(SIZE_EXPAND_FILL); @@ -142,7 +143,7 @@ void ExportTemplateManager::_uninstall_template(const String &p_version) { void ExportTemplateManager::_uninstall_template_confirm() { DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); - Error err = d->change_dir(EditorSettings::get_singleton()->get_settings_path().plus_file("templates")); + Error err = d->change_dir(EditorSettings::get_singleton()->get_templates_dir()); ERR_FAIL_COND(err != OK); @@ -244,7 +245,7 @@ void ExportTemplateManager::_install_from_file(const String &p_file) { return; } - String template_path = EditorSettings::get_singleton()->get_settings_path().plus_file("templates").plus_file(version); + String template_path = EditorSettings::get_singleton()->get_templates_dir().plus_file(version); DirAccess *d = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); Error err = d->make_dir_recursive(template_path); @@ -393,7 +394,7 @@ void ExportTemplateManager::_http_download_templates_completed(int p_status, int if (p_code != 200) { template_list_state->set_text(TTR("Failed:") + " " + itos(p_code)); } else { - String path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("tmp_templates.tpz"); + String path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_templates.tpz"); FileAccess *f = FileAccess::open(path, FileAccess::WRITE); if (!f) { template_list_state->set_text(TTR("Can't write file.")); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 00cbd9bb72..533401b317 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -333,7 +333,7 @@ void FileSystemDock::navigate_to_path(const String &p_path) { } else if (dirAccess->dir_exists(p_path)) { path = p_path; } else { - ERR_EXPLAIN(TTR("Cannot navigate to '" + p_path + "' as it has not been found in the file system!")); + ERR_EXPLAIN(vformat(TTR("Cannot navigate to '%s' as it has not been found in the file system!"), p_path)); ERR_FAIL(); } @@ -1186,78 +1186,36 @@ void FileSystemDock::set_display_mode(int p_mode) { } Variant FileSystemDock::get_drag_data_fw(const Point2 &p_point, Control *p_from) { + bool is_favorite = false; + Vector<String> paths; if (p_from == tree) { - TreeItem *selected = tree->get_selected(); if (!selected) return Variant(); - String fpath = selected->get_metadata(0); - if (fpath == String()) + String folder = selected->get_metadata(0); + if (folder == String()) return Variant(); - if (!fpath.ends_with("/")) - fpath = fpath + "/"; - Vector<String> paths; - paths.push_back(fpath); - Dictionary d = EditorNode::get_singleton()->drag_files(paths, p_from); - - if (selected->get_parent() && tree->get_root()->get_children() == selected->get_parent()) { - //a favorite.. treat as such - d["type"] = "favorite"; - } - - return d; - } - - if (p_from == files) { - - List<int> seldirs; - List<int> selfiles; + paths.push_back(folder.ends_with("/") ? folder : (folder + "/")); + is_favorite = selected->get_parent() != NULL && tree->get_root()->get_children() == selected->get_parent(); + } else if (p_from == files) { for (int i = 0; i < files->get_item_count(); i++) { if (files->is_selected(i)) { - String fpath = files->get_item_metadata(i); - if (fpath.ends_with("/")) - seldirs.push_back(i); - else - selfiles.push_back(i); + paths.push_back(files->get_item_metadata(i)); } } + } - if (seldirs.empty() && selfiles.empty()) - return Variant(); - /* - if (seldirs.size() && selfiles.size()) - return Variant(); //can't really mix files and dirs (i think?) - yes you can, commenting - */ - - /*if (selfiles.size()==1) { - Ref<Resource> resource = ResourceLoader::load(files->get_item_metadata(selfiles.front()->get())); - if (resource.is_valid()) { - return EditorNode::get_singleton()->drag_resource(resource,p_from); - } - }*/ - - Vector<String> fnames; - if (selfiles.size() > 0 || seldirs.size() > 0) { - if (selfiles.size() > 0) { - for (List<int>::Element *E = selfiles.front(); E; E = E->next()) { - fnames.push_back(files->get_item_metadata(E->get())); - } - if (seldirs.size() == 0) - return EditorNode::get_singleton()->drag_files(fnames, p_from); - } + if (paths.empty()) + return Variant(); - for (List<int>::Element *E = seldirs.front(); E; E = E->next()) { - fnames.push_back(files->get_item_metadata(E->get())); - } - - return EditorNode::get_singleton()->drag_files_and_dirs(fnames, p_from); - } + Dictionary drag_data = EditorNode::get_singleton()->drag_files_and_dirs(paths, p_from); + if (is_favorite) { + drag_data["type"] = "favorite"; } - - return Variant(); + return drag_data; } bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { @@ -1288,36 +1246,25 @@ bool FileSystemDock::can_drop_data_fw(const Point2 &p_point, const Variant &p_da } if (drag_data.has("type") && String(drag_data["type"]) == "resource") { - return true; + String to_dir = _get_drag_target_folder(p_point, p_from); + return !to_dir.empty(); } if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) { + String to_dir = _get_drag_target_folder(p_point, p_from); + if (to_dir.empty()) + return false; + //Attempting to move a folder into itself will fail later + //Rather than bring up a message don't try to do it in the first place + to_dir = to_dir.ends_with("/") ? to_dir : (to_dir + "/"); Vector<String> fnames = drag_data["files"]; - - if (p_from == files) { - - int at_pos = files->get_item_at_position(p_point); - if (at_pos != -1) { - - String dir = files->get_item_metadata(at_pos); - if (dir.ends_with("/")) - return true; - } - } - - if (p_from == tree) { - - TreeItem *ti = tree->get_item_at_position(p_point); - if (!ti) - return false; - - String fpath = ti->get_metadata(0); - if (fpath == String()) + for (int i = 0; i < fnames.size(); ++i) { + if (fnames[i].ends_with("/") && to_dir.begins_with(fnames[i])) return false; - - return true; } + + return true; } return false; @@ -1393,66 +1340,16 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, if (drag_data.has("type") && String(drag_data["type"]) == "resource") { Ref<Resource> res = drag_data["resource"]; - - if (!res.is_valid()) { - return; - } - - if (p_from == tree) { - - TreeItem *ti = tree->get_item_at_position(p_point); - if (!ti) - return; - - String fpath = ti->get_metadata(0); - if (fpath == String()) - return; - - EditorNode::get_singleton()->save_resource_as(res, fpath); - return; - } - - if (p_from == files) { - String save_path = path; - - int at_pos = files->get_item_at_position(p_point); - if (at_pos != -1) { - String to_dir = files->get_item_metadata(at_pos); - if (to_dir.ends_with("/")) { - save_path = to_dir; - if (save_path != "res://") - save_path = save_path.substr(0, save_path.length() - 1); - } - } - - EditorNode::get_singleton()->save_resource_as(res, save_path); - return; + String to_dir = _get_drag_target_folder(p_point, p_from); + if (res.is_valid() && !to_dir.empty()) { + EditorNode::get_singleton()->push_item(res.ptr()); + EditorNode::get_singleton()->save_resource_as(res, to_dir); } } if (drag_data.has("type") && (String(drag_data["type"]) == "files" || String(drag_data["type"]) == "files_and_dirs")) { - - if (p_from == files || p_from == tree) { - - String to_dir; - - if (p_from == files) { - - int at_pos = files->get_item_at_position(p_point); - ERR_FAIL_COND(at_pos == -1); - to_dir = files->get_item_metadata(at_pos); - } else { - TreeItem *ti = tree->get_item_at_position(p_point); - if (!ti) - return; - to_dir = ti->get_metadata(0); - ERR_FAIL_COND(to_dir == String()); - } - - if (to_dir != "res://" && to_dir.ends_with("/")) { - to_dir = to_dir.substr(0, to_dir.length() - 1); - } - + String to_dir = _get_drag_target_folder(p_point, p_from); + if (!to_dir.empty()) { Vector<String> fnames = drag_data["files"]; to_move.clear(); for (int i = 0; i < fnames.size(); i++) { @@ -1463,6 +1360,25 @@ void FileSystemDock::drop_data_fw(const Point2 &p_point, const Variant &p_data, } } +String FileSystemDock::_get_drag_target_folder(const Point2 &p_point, Control *p_from) const { + if (p_from == files) { + int pos = files->get_item_at_position(p_point, true); + if (pos == -1) + return path; + + String target = files->get_item_metadata(pos); + return target.ends_with("/") ? target : path; + } + + if (p_from == tree) { + TreeItem *ti = tree->get_item_at_position(p_point); + if (ti && ti != tree->get_root()->get_children()) + return ti->get_metadata(0); + } + + return String(); +} + void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) { //Right clicking ".." should clear current selection @@ -1538,11 +1454,21 @@ void FileSystemDock::select_file(const String &p_file) { void FileSystemDock::_file_multi_selected(int p_index, bool p_selected) { - _file_selected(); + import_dock_needs_update = true; + call_deferred("_update_import_dock"); } void FileSystemDock::_file_selected() { + import_dock_needs_update = true; + _update_import_dock(); +} + +void FileSystemDock::_update_import_dock() { + + if (!import_dock_needs_update) + return; + //check import Vector<String> imports; String import_type; @@ -1582,6 +1508,8 @@ void FileSystemDock::_file_selected() { } else { EditorNode::get_singleton()->get_import_dock()->set_edit_multiple_paths(imports); } + + import_dock_needs_update = false; } void FileSystemDock::_bind_methods() { @@ -1618,6 +1546,7 @@ void FileSystemDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_preview_invalidated"), &FileSystemDock::_preview_invalidated); ClassDB::bind_method(D_METHOD("_file_selected"), &FileSystemDock::_file_selected); ClassDB::bind_method(D_METHOD("_file_multi_selected"), &FileSystemDock::_file_multi_selected); + ClassDB::bind_method(D_METHOD("_update_import_dock"), &FileSystemDock::_update_import_dock); ADD_SIGNAL(MethodInfo("instance", PropertyInfo(Variant::POOL_STRING_ARRAY, "files"))); ADD_SIGNAL(MethodInfo("open")); @@ -1789,6 +1718,7 @@ FileSystemDock::FileSystemDock(EditorNode *p_editor) { updating_tree = false; initialized = false; + import_dock_needs_update = false; history_pos = 0; history_max_size = 20; diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index 2cb0573a3d..d100de8b72 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -147,6 +147,7 @@ private: bool updating_tree; Tree *tree; //directories ItemList *files; + bool import_dock_needs_update; bool _create_tree(TreeItem *p_parent, EditorFileSystemDirectory *p_dir, Vector<String> &uncollapsed_paths); void _update_tree(bool keep_collapse_state); @@ -161,6 +162,7 @@ private: void _select_file(int p_idx); void _file_multi_selected(int p_index, bool p_selected); + void _update_import_dock(); void _file_selected(); void _dir_selected(); @@ -209,6 +211,7 @@ private: Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); + String _get_drag_target_folder(const Point2 &p_point, Control *p_from) const; void _preview_invalidated(const String &p_path); void _thumbnail_done(const String &p_path, const Ref<Texture> &p_preview, const Variant &p_udata); diff --git a/editor/icons/icon_GUI_toggle_off.svg b/editor/icons/icon_GUI_toggle_off.svg index 0d43b158b5..aea0f85f96 100644 --- a/editor/icons/icon_GUI_toggle_off.svg +++ b/editor/icons/icon_GUI_toggle_off.svg @@ -1,5 +1,5 @@ -<svg width="64" height="32" version="1.1" viewBox="0 0 64 31.999998" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1020.4)"> -<path transform="translate(0 1020.4)" d="m24 4.002c-6.6307 0-12 5.3654-12 11.996v0.003906c0 6.6307 5.3693 12 12 12h16c6.6307 0 12-5.3693 12-12v-0.003906c0-6.6307-5.3693-11.996-12-11.996h-16zm0 2h16c5.5573 0 10 4.4388 10 9.9961v0.003906c0 5.5573-4.4427 10-10 10h-16c-5.5573 0-10-4.4427-10-10v-0.003906c0-5.5573 4.4427-9.9961 10-9.9961zm7 4.9961a1.0001 1.0001 0 0 0 -1 1v8a1 1 0 0 0 1 1 1 1 0 0 0 1 -1v-3h2a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-2v-2h4a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-5zm9 0a1.0001 1.0001 0 0 0 -1 1v4 4a1 1 0 0 0 1 1 1 1 0 0 0 1 -1v-3h2a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-2v-2h4a1 1 0 0 0 1 -1 1 1 0 0 0 -1 -1h-5zm-17 0.003906c-2.7496 0-5 2.2504-5 5s2.2504 5 5 5 5-2.2504 5-5-2.2504-5-5-5zm0 2c1.6687 0 3 1.3313 3 3s-1.3313 3-3 3-3-1.3313-3-3 1.3313-3 3-3z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="filter-blend-mode:normal;filter-gaussianBlur-deviation:0;font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> +<svg width="42" height="26" version="1.1" viewBox="0 0 42 25.999998" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1026.4)"> +<path d="m13 1027.4c-6.6307 0-12 5.3663-12 11.998 0 6.6318 5.3693 12.002 12 12.002h16c6.6307 0 12-5.3702 12-12.002 0-6.6317-5.3693-11.998-12-11.998zm0 2.0003h16c5.5573 0 10 4.4395 10 9.9977 0 5.5583-4.4427 10.002-10 10.002h-16c-5.5573 0-10-4.4434-10-10.002 0-5.5582 4.4427-9.9977 10-9.9977zm7 4.9969a1.0001 1.0003 0 0 0 -1 1.0002v8.0013a1 1.0002 0 0 0 1 1.0002 1 1.0002 0 0 0 1 -1.0002v-3.0005h2a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0001h-2v-2.0003h4a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0002zm9 0a1.0001 1.0003 0 0 0 -1 1.0002v8.0013a1 1.0002 0 0 0 1 1.0002 1 1.0002 0 0 0 1 -1.0002v-3.0005h2a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0001h-2v-2.0003h4a1 1.0002 0 0 0 1 -1.0002 1 1.0002 0 0 0 -1 -1.0002zm-17 0c-2.7496 0-5 2.2508-5 5.0008 0 2.7501 2.2504 5.0009 5 5.0009s5-2.2508 5-5.0009c0-2.75-2.2504-5.0008-5-5.0008zm0 2.0004c1.6687 0 3 1.3315 3 3.0004 0 1.669-1.3313 3.0005-3 3.0005s-3-1.3315-3-3.0005c0-1.6689 1.3313-3.0004 3-3.0004z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> </g> </svg> diff --git a/editor/icons/icon_GUI_toggle_on.svg b/editor/icons/icon_GUI_toggle_on.svg index fd2b915fc3..c0a11810d4 100644 --- a/editor/icons/icon_GUI_toggle_on.svg +++ b/editor/icons/icon_GUI_toggle_on.svg @@ -1,5 +1,5 @@ -<svg width="64" height="32" version="1.1" viewBox="0 0 64 31.999998" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1020.4)"> -<path transform="translate(0 1020.4)" d="m24 4.002c-6.6307 0-12 5.3654-12 11.996 0 6.6307 5.3693 12 12 12h16c6.6307 0 12-5.3693 12-12 0-6.6307-5.3693-11.996-12-11.996h-16zm17 6.9961a1 1 0 0 1 1 1v8a1.0001 1.0001 0 0 1 -1.752 0.66211l-5.248-6v5.3379a1 1 0 0 1 -1 1 1 1 0 0 1 -1 -1v-8a1.0001 1.0001 0 0 1 1.752 -0.6582l5.248 6v-5.3418a1 1 0 0 1 1 -1zm-15 0.003906c2.7496 0 5 2.2504 5 5s-2.2504 5-5 5-5-2.2504-5-5 2.2504-5 5-5zm0 2c-1.6687 0-3 1.3313-3 3s1.3313 3 3 3 3-1.3313 3-3-1.3313-3-3-3z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-east-asian:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> +<svg width="42" height="26" version="1.1" viewBox="0 0 42 25.999998" xmlns="http://www.w3.org/2000/svg"> +<g transform="translate(0 -1026.4)"> +<path d="m13 1027.4c-6.6307 0-12 5.3662-12 11.998s5.3693 12.002 12 12.002h16c6.6307 0 12-5.3702 12-12.002s-5.3693-11.998-12-11.998zm17 6.9972a1 1.0002 0 0 1 1 1.0001v8.0014a1.0001 1.0003 0 0 1 -1.752 0.6623l-5.248-6.001v5.3387a1 1.0002 0 0 1 -1 1.0001 1 1.0002 0 0 1 -1 -1.0001v-8.0014a1.0001 1.0003 0 0 1 1.752 -0.6583l5.248 6.001v-5.3427a1 1.0002 0 0 1 1 -1.0001zm-15 0c2.7496 0 5 2.2507 5 5.0008s-2.2504 5.0008-5 5.0008-5-2.2507-5-5.0008 2.2504-5.0008 5-5.0008zm0 2.0003c-1.6687 0-3 1.3315-3 3.0005s1.3313 3.0005 3 3.0005 3-1.3315 3-3.0005-1.3313-3.0005-3-3.0005z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#e0e0e0" fill-opacity=".78431" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> </g> </svg> diff --git a/editor/icons/icon_texture_button.svg b/editor/icons/icon_texture_button.svg index 17f87ab861..19f5e8d5c9 100644 --- a/editor/icons/icon_texture_button.svg +++ b/editor/icons/icon_texture_button.svg @@ -1,7 +1,5 @@ <svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> <g transform="translate(0 -1036.4)"> -<path transform="translate(0 1036.4)" d="m1 3v8h14v-8h-1-12-1zm8 2h1v1h1v2h1v2h-2-2-2-2v-1h1v-1h1v-1h2v-1h1v-1z" fill="#a5efac"/> -<rect transform="scale(1,-1)" x="1" y="-1049.4" width="14" height="2.0001" fill="#a5efac"/> -<rect transform="scale(1,-1)" x="1" y="-1049.4" width="14" height="2.0001" fill-opacity=".078431"/> +<path transform="translate(0 1036.4)" d="m8 1v2h6v10h-4v2h6v-14h-8zm-5 1v3.1328l-1.4453-0.96484-1.1094 1.6641 3 2c0.3359 0.2239 0.77347 0.2239 1.1094 0l3-2-1.1094-1.6641-1.4453 0.96484v-3.1328h-2zm7 4v1h-1v1h-1v1h1v2h2 2v-2h-1v-2h-1v-1h-1zm-7.5 4c-0.831 0-1.5 0.669-1.5 1.5v0.5 1h-1v2h8v-2h-1v-1-0.5c0-0.831-0.669-1.5-1.5-1.5h-3z" fill="#a5efac"/> </g> </svg> diff --git a/editor/icons/icon_texture_rect.svg b/editor/icons/icon_texture_rect.svg index 86d24ac223..2dbbe7f247 100644 --- a/editor/icons/icon_texture_rect.svg +++ b/editor/icons/icon_texture_rect.svg @@ -1,6 +1,5 @@ <svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> <g transform="translate(0 -1036.4)"> -<rect x="2" y="1038.4" width="12" height="12" fill="none" stroke="#a5efac" stroke-linecap="round" stroke-width="2"/> -<path d="m9 1042.4v1h-1v1h-2v1h-1v1h-1v1h2 2 2 2v-2h-1v-2h-1v-1h-1z" fill="#a5efac"/> +<path transform="translate(0 1036.4)" d="m1 1v14h14v-14h-14zm2 2h10v10h-10v-10zm6 3v1h-1v1h-2v1h-1v1h-1v1h2 2 2 2v-2h-1v-2h-1v-1h-1z" color="#000000" color-rendering="auto" dominant-baseline="auto" fill="#a5efac" image-rendering="auto" shape-rendering="auto" solid-color="#000000" style="font-feature-settings:normal;font-variant-alternates:normal;font-variant-caps:normal;font-variant-ligatures:normal;font-variant-numeric:normal;font-variant-position:normal;isolation:auto;mix-blend-mode:normal;shape-padding:0;text-decoration-color:#000000;text-decoration-line:none;text-decoration-style:solid;text-indent:0;text-orientation:mixed;text-transform:none;white-space:normal"/> </g> </svg> diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 831eb74b66..397bb6ad68 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -1,5 +1,6 @@ #include "editor_scene_importer_gltf.h" #include "io/json.h" +#include "math_defs.h" #include "os/file_access.h" #include "os/os.h" #include "scene/3d/camera.h" @@ -1378,8 +1379,8 @@ Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) { state.nodes[skin_node]->skeleton_children.push_back(i); } - state.skins.push_back(skin); } + state.skins.push_back(skin); } print_line("total skins: " + itos(state.skins.size())); @@ -1419,7 +1420,8 @@ Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) { camera.perspective = true; if (d.has("perspective")) { Dictionary ppt = d["perspective"]; - camera.fov_size = ppt["yfov"]; + // GLTF spec is in radians, Godot's camera is in degrees. + camera.fov_size = (double)ppt["yfov"] * 180.0 / Math_PI; camera.zfar = ppt["zfar"]; camera.znear = ppt["znear"]; } else { diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 4541c77085..bd24aac99b 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -413,6 +413,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in for (List<Ref<Mesh> >::Element *E = meshes.front(); E; E = E->next()) { MeshInstance *mi = memnew(MeshInstance); + mi->set_mesh(E->get()); mi->set_name(E->get()->get_name()); scene->add_child(mi); mi->set_owner(scene); diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 660db9ac27..cbc21c9536 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -232,16 +232,26 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array } } - if (_teststr(name, "colonly")) { + if (_teststr(name, "colonly") || _teststr(name, "convcolonly")) { if (isroot) return p_node; MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); if (mi) { - Node *col = mi->create_trimesh_collision_node(); - ERR_FAIL_COND_V(!col, NULL); + Node *col; + + if (_teststr(name, "colonly")) { + col = mi->create_trimesh_collision_node(); + ERR_FAIL_COND_V(!col, NULL); + + col->set_name(_fixstr(name, "colonly")); + } else { + col = mi->create_convex_collision_node(); + ERR_FAIL_COND_V(!col, NULL); + + col->set_name(_fixstr(name, "convcolonly")); + } - col->set_name(_fixstr(name, "colonly")); Object::cast_to<Spatial>(col)->set_transform(mi->get_transform()); p_node->replace_by(col); memdelete(p_node); @@ -292,7 +302,7 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array // get mesh instance and bounding box MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); - Rect3 aabb = mi->get_aabb(); + AABB aabb = mi->get_aabb(); // create a new rigid body collision node RigidBody *rigid_body = memnew(RigidBody); @@ -328,15 +338,25 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array rb->add_child(colshape); colshape->set_owner(p_node->get_owner()); - } else if (_teststr(name, "col") && Object::cast_to<MeshInstance>(p_node)) { + } else if ((_teststr(name, "col") || (_teststr(name, "convcol"))) && Object::cast_to<MeshInstance>(p_node)) { MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); + Node *col; - mi->set_name(_fixstr(name, "col")); - Node *col = mi->create_trimesh_collision_node(); - ERR_FAIL_COND_V(!col, NULL); + if (_teststr(name, "col")) { + mi->set_name(_fixstr(name, "col")); + col = mi->create_trimesh_collision_node(); + ERR_FAIL_COND_V(!col, NULL); + + col->set_name("col"); + } else { + mi->set_name(_fixstr(name, "convcol")); + col = mi->create_convex_collision_node(); + ERR_FAIL_COND_V(!col, NULL); + + col->set_name("convcol"); + } - col->set_name("col"); p_node->add_child(col); StaticBody *sb = Object::cast_to<StaticBody>(col); @@ -527,26 +547,55 @@ Node *ResourceImporterScene::_fix_node(Node *p_node, Node *p_root, Map<Ref<Array #endif } else if (Object::cast_to<MeshInstance>(p_node)) { - //last attempt, maybe collision insde the mesh data + //last attempt, maybe collision inside the mesh data MeshInstance *mi = Object::cast_to<MeshInstance>(p_node); Ref<ArrayMesh> mesh = mi->get_mesh(); if (!mesh.is_null()) { - if (_teststr(mesh->get_name(), "col")) { - - mesh->set_name(_fixstr(mesh->get_name(), "col")); + if (_teststr(mesh->get_name(), "col") || _teststr(mesh->get_name(), "convcol")) { Ref<Shape> shape; + if (_teststr(mesh->get_name(), "col")) { + mesh->set_name(_fixstr(mesh->get_name(), "col")); + + if (collision_map.has(mesh)) { + shape = collision_map[mesh]; + + } else { + + shape = mesh->create_trimesh_shape(); + if (!shape.is_null()) + collision_map[mesh] = shape; + } + } else if (_teststr(mesh->get_name(), "convcol")) { + mesh->set_name(_fixstr(mesh->get_name(), "convcol")); + + if (collision_map.has(mesh)) { + shape = collision_map[mesh]; + + } else { + + shape = mesh->create_convex_shape(); + if (!shape.is_null()) + collision_map[mesh] = shape; + } + } - if (collision_map.has(mesh)) { - shape = collision_map[mesh]; + if (!shape.is_null()) { + StaticBody *col = memnew(StaticBody); + CollisionShape *cshape = memnew(CollisionShape); + cshape->set_shape(shape); + col->add_child(cshape); - } else { + col->set_transform(mi->get_transform()); + col->set_name(mi->get_name()); + p_node->replace_by(col); + memdelete(p_node); + p_node = col; - shape = mesh->create_trimesh_shape(); - if (!shape.is_null()) - collision_map[mesh] = shape; + cshape->set_name("shape"); + cshape->set_owner(p_node->get_owner()); } } } diff --git a/editor/import_dock.cpp b/editor/import_dock.cpp index 77fd6d883a..84d55b4d14 100644 --- a/editor/import_dock.cpp +++ b/editor/import_dock.cpp @@ -87,23 +87,7 @@ void ImportDock::set_edit_path(const String &p_path) { return; } - List<ResourceImporter::ImportOption> options; - params->importer->get_import_options(&options); - - params->properties.clear(); - params->values.clear(); - - for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { - - params->properties.push_back(E->get().option); - if (config->has_section_key("params", E->get().option.name)) { - params->values[E->get().option.name] = config->get_value("params", E->get().option.name); - } else { - params->values[E->get().option.name] = E->get().default_value; - } - } - - params->update(); + _update_options(config); List<Ref<ResourceImporter> > importers; ResourceFormatImporter::get_singleton()->get_importers_for_extension(p_path.get_extension(), &importers); @@ -125,6 +109,34 @@ void ImportDock::set_edit_path(const String &p_path) { } } + params->paths.clear(); + params->paths.push_back(p_path); + import->set_disabled(false); + import_as->set_disabled(false); + + imported->set_text(p_path.get_file()); +} + +void ImportDock::_update_options(const Ref<ConfigFile> &p_config) { + + List<ResourceImporter::ImportOption> options; + params->importer->get_import_options(&options); + + params->properties.clear(); + params->values.clear(); + + for (List<ResourceImporter::ImportOption>::Element *E = options.front(); E; E = E->next()) { + + params->properties.push_back(E->get().option); + if (p_config.is_valid() && p_config->has_section_key("params", E->get().option.name)) { + params->values[E->get().option.name] = p_config->get_value("params", E->get().option.name); + } else { + params->values[E->get().option.name] = E->get().default_value; + } + } + + params->update(); + preset->get_popup()->clear(); if (params->importer->get_preset_count() == 0) { @@ -142,13 +154,6 @@ void ImportDock::set_edit_path(const String &p_path) { preset->get_popup()->add_separator(); preset->get_popup()->add_item(vformat(TTR("Clear Default for '%s'"), params->importer->get_visible_name()), ITEM_CLEAR_DEFAULT); } - - params->paths.clear(); - params->paths.push_back(p_path); - import->set_disabled(false); - import_as->set_disabled(false); - - imported->set_text(p_path.get_file()); } void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { @@ -263,6 +268,24 @@ void ImportDock::set_edit_multiple_paths(const Vector<String> &p_paths) { imported->set_text(itos(p_paths.size()) + TTR(" Files")); } +void ImportDock::_importer_selected(int i_idx) { + String name = import_as->get_selected_metadata(); + Ref<ResourceImporter> importer = ResourceFormatImporter::get_singleton()->get_importer_by_name(name); + ERR_FAIL_COND(importer.is_null()); + + params->importer = importer; + + Ref<ConfigFile> config; + if (params->paths.size()) { + config.instance(); + Error err = config->load(params->paths[0] + ".import"); + if (err != OK) { + config.unref(); + } + } + _update_options(config); +} + void ImportDock::_preset_selected(int p_idx) { int item_id = preset->get_popup()->get_item_id(p_idx); @@ -336,6 +359,7 @@ void ImportDock::_reimport() { Error err = config->load(params->paths[i] + ".import"); ERR_CONTINUE(err != OK); + config->set_value("remap", "importer", params->importer->get_importer_name()); config->erase_section("params"); for (List<PropertyInfo>::Element *E = params->properties.front(); E; E = E->next()) { @@ -356,12 +380,18 @@ void ImportDock::_notification(int p_what) { imported->add_style_override("normal", get_stylebox("normal", "LineEdit")); } break; + + case NOTIFICATION_ENTER_TREE: { + + import_opts->edit(params); + } break; } } void ImportDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_reimport"), &ImportDock::_reimport); ClassDB::bind_method(D_METHOD("_preset_selected"), &ImportDock::_preset_selected); + ClassDB::bind_method(D_METHOD("_importer_selected"), &ImportDock::_importer_selected); } void ImportDock::initialize_import_options() const { @@ -379,6 +409,7 @@ ImportDock::ImportDock() { HBoxContainer *hb = memnew(HBoxContainer); add_margin_child(TTR("Import As:"), hb); import_as = memnew(OptionButton); + import_as->connect("item_selected", this, "_importer_selected"); hb->add_child(import_as); import_as->set_h_size_flags(SIZE_EXPAND_FILL); preset = memnew(MenuButton); diff --git a/editor/import_dock.h b/editor/import_dock.h index 029c458320..28c29e4b20 100644 --- a/editor/import_dock.h +++ b/editor/import_dock.h @@ -54,6 +54,8 @@ class ImportDock : public VBoxContainer { ImportDockParameters *params; void _preset_selected(int p_idx); + void _importer_selected(int i_idx); + void _update_options(const Ref<ConfigFile> &p_config = Ref<ConfigFile>()); void _reimport(); diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index f2f913d2b3..736e176ab8 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -563,6 +563,14 @@ void AbstractPolygon2DEditor::forward_draw_over_canvas(Control *p_canvas) { const Vector2 next_point = xform.xform(p2); vpc->draw_line(point, next_point, col, 2); } + } + + for (int i = 0; i < n_points; i++) { + + const Vertex vertex(j, i); + + const Vector2 p = (vertex == edited_point) ? edited_point.pos : (points[i] + offset); + const Vector2 point = xform.xform(p); Ref<Texture> handle = vertex == active_point ? selected_handle : default_handle; vpc->draw_texture(handle, point - handle->get_size() * 0.5); diff --git a/editor/plugins/asset_library_editor_plugin.cpp b/editor/plugins/asset_library_editor_plugin.cpp index cd53264437..b63352389e 100644 --- a/editor/plugins/asset_library_editor_plugin.cpp +++ b/editor/plugins/asset_library_editor_plugin.cpp @@ -33,6 +33,8 @@ #include "editor_settings.h" #include "io/json.h" +#include "version_generated.gen.h" + void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, const String &p_category, int p_category_id, const String &p_author, int p_author_id, int p_rating, const String &p_cost) { title->set_text(p_title); @@ -45,9 +47,9 @@ void EditorAssetLibraryItem::configure(const String &p_title, int p_asset_id, co for (int i = 0; i < 5; i++) { if (i < p_rating) - stars[i]->set_texture(get_icon("RatingStar", "EditorIcons")); + stars[i]->set_texture(get_icon("Favorites", "EditorIcons")); else - stars[i]->set_texture(get_icon("RatingNoStar", "EditorIcons")); + stars[i]->set_texture(get_icon("NonFavorite", "EditorIcons")); } } @@ -271,15 +273,15 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { HBoxContainer *hbox = memnew(HBoxContainer); vbox->add_child(hbox); - vbox->add_constant_override("separation", 15); + vbox->add_constant_override("separation", 15 * EDSCALE); VBoxContainer *desc_vbox = memnew(VBoxContainer); hbox->add_child(desc_vbox); - hbox->add_constant_override("separation", 15); + hbox->add_constant_override("separation", 15 * EDSCALE); item = memnew(EditorAssetLibraryItem); desc_vbox->add_child(item); - desc_vbox->set_custom_minimum_size(Size2(300, 0)); + desc_vbox->set_custom_minimum_size(Size2(300 * EDSCALE, 0)); desc_bg = memnew(PanelContainer); desc_vbox->add_child(desc_bg); @@ -290,12 +292,12 @@ EditorAssetLibraryItemDescription::EditorAssetLibraryItemDescription() { desc_bg->add_child(description); preview = memnew(TextureRect); - preview->set_custom_minimum_size(Size2(640, 345)); + preview->set_custom_minimum_size(Size2(640 * EDSCALE, 345 * EDSCALE)); hbox->add_child(preview); previews_bg = memnew(PanelContainer); vbox->add_child(previews_bg); - previews_bg->set_custom_minimum_size(Size2(0, 85)); + previews_bg->set_custom_minimum_size(Size2(0, 101 * EDSCALE)); previews = memnew(ScrollContainer); previews_bg->add_child(previews); @@ -443,7 +445,7 @@ void EditorAssetLibraryItemDownload::_install() { void EditorAssetLibraryItemDownload::_make_request() { download->cancel_request(); - download->set_download_file(EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("tmp_asset_" + itos(asset_id)) + ".zip"); + download->set_download_file(EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_asset_" + itos(asset_id)) + ".zip"); Error err = download->request(host); if (err != OK) { @@ -678,7 +680,7 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt PoolByteArray image_data = p_data; if (use_cache) { - String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); + String cache_filename_base = EditorSettings::get_singleton()->get_cache_dir().plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); FileAccess *file = FileAccess::open(cache_filename_base + ".data", FileAccess::READ); @@ -700,15 +702,28 @@ void EditorAssetLibrary::_image_update(bool use_cache, bool final, const PoolByt Ref<Image> image = Ref<Image>(memnew(Image(r.ptr(), len))); if (!image->empty()) { - float max_height = 10000; switch (image_queue[p_queue_id].image_type) { - case IMAGE_QUEUE_ICON: max_height = 80; break; - case IMAGE_QUEUE_THUMBNAIL: max_height = 80; break; - case IMAGE_QUEUE_SCREENSHOT: max_height = 345; break; - } - float scale_ratio = max_height / image->get_height(); - if (scale_ratio < 1) { - image->resize(image->get_width() * scale_ratio, image->get_height() * scale_ratio, Image::INTERPOLATE_CUBIC); + case IMAGE_QUEUE_ICON: + + image->resize(80 * EDSCALE, 80 * EDSCALE, Image::INTERPOLATE_CUBIC); + + break; + case IMAGE_QUEUE_THUMBNAIL: { + float max_height = 85 * EDSCALE; + + float scale_ratio = max_height / (image->get_height() * EDSCALE); + if (scale_ratio < 1) { + image->resize(image->get_width() * EDSCALE * scale_ratio, image->get_height() * EDSCALE * scale_ratio, Image::INTERPOLATE_CUBIC); + } + } break; + case IMAGE_QUEUE_SCREENSHOT: { + float max_height = 397 * EDSCALE; + + float scale_ratio = max_height / (image->get_height() * EDSCALE); + if (scale_ratio < 1) { + image->resize(image->get_width() * EDSCALE * scale_ratio, image->get_height() * EDSCALE * scale_ratio, Image::INTERPOLATE_CUBIC); + } + } break; } Ref<ImageTexture> tex; @@ -736,7 +751,7 @@ void EditorAssetLibrary::_image_request_completed(int p_status, int p_code, cons if (p_code != HTTPClient::RESPONSE_NOT_MODIFIED) { for (int i = 0; i < headers.size(); i++) { if (headers[i].findn("ETag:") == 0) { // Save etag - String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); + String cache_filename_base = EditorSettings::get_singleton()->get_cache_dir().plus_file("assetimage_" + image_queue[p_queue_id].image_url.md5_text()); String new_etag = headers[i].substr(headers[i].find(":") + 1, headers[i].length()).strip_edges(); FileAccess *file; @@ -784,7 +799,7 @@ void EditorAssetLibrary::_update_image_queue() { for (Map<int, ImageQueue>::Element *E = image_queue.front(); E; E = E->next()) { if (!E->get().active && current_images < max_images) { - String cache_filename_base = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp").plus_file("assetimage_" + E->get().image_url.md5_text()); + String cache_filename_base = EditorSettings::get_singleton()->get_cache_dir().plus_file("assetimage_" + E->get().image_url.md5_text()); Vector<String> headers; if (FileAccess::exists(cache_filename_base + ".etag") && FileAccess::exists(cache_filename_base + ".data")) { @@ -867,6 +882,8 @@ void EditorAssetLibrary::_search(int p_page) { } args += String() + "sort=" + sort_key[sort->get_selected()]; + args += "&godot_version=" + itos(VERSION_MAJOR) + "." + itos(VERSION_MINOR); + String support_list; for (int i = 0; i < SUPPORT_MAX; i++) { if (support->get_popup()->is_item_checked(i)) { @@ -1348,13 +1365,11 @@ EditorAssetLibrary::EditorAssetLibrary(bool p_templates_only) { search_hb2->add_child(memnew(Label(TTR("Site:") + " "))); repository = memnew(OptionButton); - // FIXME: Reenable me once GH-7147 is fixed. - /* repository->add_item("godotengine.org"); repository->set_item_metadata(0, "https://godotengine.org/asset-library/api"); - */ repository->add_item("localhost"); - repository->set_item_metadata(/*1*/ 0, "http://127.0.0.1/asset-library/api"); + repository->set_item_metadata(1, "http://127.0.0.1/asset-library/api"); + repository->connect("item_selected", this, "_repository_changed"); search_hb2->add_child(repository); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 3807c8961a..b6ba09fb58 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -176,9 +176,9 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) { for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { Node2D *n2d = Object::cast_to<Node2D>(E->get()); - if (n2d && n2d->edit_has_pivot()) { + if (n2d && n2d->_edit_use_pivot()) { - Vector2 offset = n2d->edit_get_pivot(); + Vector2 offset = n2d->_edit_get_pivot(); Vector2 gpos = n2d->get_global_position(); Vector2 local_mouse_pos = n2d->get_canvas_transform().affine_inverse().xform(mouse_pos); @@ -186,9 +186,9 @@ void CanvasItemEditor::_edit_set_pivot(const Vector2 &mouse_pos) { Vector2 motion_ofs = gpos - local_mouse_pos; undo_redo->add_do_method(n2d, "set_global_position", local_mouse_pos); - undo_redo->add_do_method(n2d, "edit_set_pivot", offset + n2d->get_global_transform().affine_inverse().basis_xform(motion_ofs)); + undo_redo->add_do_method(n2d, "_edit_set_pivot", offset + n2d->get_global_transform().affine_inverse().basis_xform(motion_ofs)); undo_redo->add_undo_method(n2d, "set_global_position", gpos); - undo_redo->add_undo_method(n2d, "edit_set_pivot", offset); + undo_redo->add_undo_method(n2d, "_edit_set_pivot", offset); for (int i = 0; i < n2d->get_child_count(); i++) { Node2D *n2dc = Object::cast_to<Node2D>(n2d->get_child(i)); if (!n2dc) @@ -249,8 +249,8 @@ void CanvasItemEditor::_snap_other_nodes(Point2 p_value, Point2 &r_current_snap, Transform2D ci_transform = canvas_item->get_global_transform_with_canvas(); Transform2D to_snap_transform = p_to_snap ? p_to_snap->get_global_transform_with_canvas() : Transform2D(); if (fmod(ci_transform.get_rotation() - to_snap_transform.get_rotation(), (real_t)360.0) == 0.0) { - Point2 begin = ci_transform.xform(canvas_item->get_item_rect().get_position()); - Point2 end = ci_transform.xform(canvas_item->get_item_rect().get_position() + canvas_item->get_item_rect().get_size()); + Point2 begin = ci_transform.xform(canvas_item->_edit_get_rect().get_position()); + Point2 end = ci_transform.xform(canvas_item->_edit_get_rect().get_position() + canvas_item->_edit_get_rect().get_size()); _snap_if_closer_point(p_value, begin, r_current_snap, r_snapped, ci_transform.get_rotation()); _snap_if_closer_point(p_value, end, r_current_snap, r_snapped, ci_transform.get_rotation()); @@ -282,8 +282,8 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, const end = p_canvas_item->get_global_transform_with_canvas().xform(_anchor_to_position(c, Point2(1, 1))); can_snap = true; } else if (const CanvasItem *parent_ci = Object::cast_to<CanvasItem>(p_canvas_item->get_parent())) { - begin = p_canvas_item->get_transform().affine_inverse().xform(parent_ci->get_item_rect().get_position()); - end = p_canvas_item->get_transform().affine_inverse().xform(parent_ci->get_item_rect().get_position() + parent_ci->get_item_rect().get_size()); + begin = p_canvas_item->get_transform().affine_inverse().xform(parent_ci->_edit_get_rect().get_position()); + end = p_canvas_item->get_transform().affine_inverse().xform(parent_ci->_edit_get_rect().get_position() + parent_ci->_edit_get_rect().get_size()); can_snap = true; } @@ -306,8 +306,8 @@ Point2 CanvasItemEditor::snap_point(Point2 p_target, unsigned int p_modes, const // Self sides (for anchors) if ((snap_active && snap_node_sides && (p_modes & SNAP_NODE_SIDES)) || (p_forced_modes & SNAP_NODE_SIDES)) { - begin = p_canvas_item->get_global_transform_with_canvas().xform(p_canvas_item->get_item_rect().get_position()); - end = p_canvas_item->get_global_transform_with_canvas().xform(p_canvas_item->get_item_rect().get_position() + p_canvas_item->get_item_rect().get_size()); + begin = p_canvas_item->get_global_transform_with_canvas().xform(p_canvas_item->_edit_get_rect().get_position()); + end = p_canvas_item->get_global_transform_with_canvas().xform(p_canvas_item->_edit_get_rect().get_position() + p_canvas_item->_edit_get_rect().get_size()); _snap_if_closer_point(p_target, begin, output, snapped, rotation); _snap_if_closer_point(p_target, end, output, snapped, rotation); } @@ -629,7 +629,7 @@ void CanvasItemEditor::_find_canvas_items_at_pos(const Point2 &p_pos, Node *p_no if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !Object::cast_to<CanvasLayer>(c)) { - Rect2 rect = c->get_item_rect(); + Rect2 rect = c->_edit_get_rect(); Point2 local_pos = (p_parent_xform * p_canvas_xform * c->get_transform()).affine_inverse().xform(p_pos); if (rect.has_point(local_pos)) { @@ -675,7 +675,7 @@ void CanvasItemEditor::_find_canvas_items_at_rect(const Rect2 &p_rect, Node *p_n if (c && c->is_visible_in_tree() && !c->has_meta("_edit_lock_") && !Object::cast_to<CanvasLayer>(c)) { - Rect2 rect = c->get_item_rect(); + Rect2 rect = c->_edit_get_rect(); Transform2D xform = p_parent_xform * p_canvas_xform * c->get_transform(); if (p_rect.has_point(xform.xform(rect.position)) && @@ -767,15 +767,15 @@ void CanvasItemEditor::_key_move(const Vector2 &p_dir, bool p_snap, KeyMoveMODE if (p_snap) drag *= grid_step * Math::pow(2.0, grid_step_multiplier); - undo_redo->add_undo_method(canvas_item, "edit_set_state", canvas_item->edit_get_state()); + undo_redo->add_undo_method(canvas_item, "_edit_set_state", canvas_item->_edit_get_state()); if (p_move_mode == MOVE_VIEW_BASE) { // drag = transform.affine_inverse().basis_xform(p_dir); // zoom sensitive drag = canvas_item->get_global_transform_with_canvas().affine_inverse().basis_xform(drag); - Rect2 local_rect = canvas_item->get_item_rect(); + Rect2 local_rect = canvas_item->_edit_get_rect(); local_rect.position += drag; - undo_redo->add_do_method(canvas_item, "edit_set_rect", local_rect); + undo_redo->add_do_method(canvas_item, "_edit_set_rect", local_rect); } else { // p_move_mode==MOVE_LOCAL_BASE || p_move_mode==MOVE_LOCAL_WITH_ROT @@ -816,7 +816,7 @@ Point2 CanvasItemEditor::_find_topleftmost_point() { if (canvas_item->get_viewport() != EditorNode::get_singleton()->get_scene_root()) continue; - Rect2 rect = canvas_item->get_item_rect(); + Rect2 rect = canvas_item->_edit_get_rect(); Transform2D xform = canvas_item->get_global_transform_with_canvas(); r2.expand_to(xform.xform(rect.position)); @@ -877,7 +877,7 @@ CanvasItemEditor::DragType CanvasItemEditor::_get_resize_handle_drag_type(const ERR_FAIL_COND_V(!canvas_item, DRAG_NONE); - Rect2 rect = canvas_item->get_item_rect(); + Rect2 rect = canvas_item->_edit_get_rect(); Transform2D xforml = canvas_item->get_global_transform_with_canvas(); Transform2D xform = transform * xforml; @@ -1011,14 +1011,14 @@ void CanvasItemEditor::_prepare_drag(const Point2 &p_click_pos) { if (!se) continue; - se->undo_state = canvas_item->edit_get_state(); + se->undo_state = canvas_item->_edit_get_state(); if (Object::cast_to<Node2D>(canvas_item)) - se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot(); + se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->_edit_get_pivot(); if (Object::cast_to<Control>(canvas_item)) se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); - se->pre_drag_rect = canvas_item->get_item_rect(); + se->pre_drag_rect = canvas_item->_edit_get_rect(); } if (selection.size() == 1 && Object::cast_to<Node2D>(selection[0]) && bone_ik_list.size() == 0) { @@ -1500,7 +1500,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { // Cancel a drag if (bone_ik_list.size()) { for (List<BoneIK>::Element *E = bone_ik_list.back(); E; E = E->prev()) { - E->get().node->edit_set_state(E->get().orig_state); + E->get().node->_edit_set_state(E->get().orig_state); } bone_ik_list.clear(); @@ -1519,9 +1519,9 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { if (!se) continue; - canvas_item->edit_set_state(se->undo_state); + canvas_item->_edit_set_state(se->undo_state); if (Object::cast_to<Node2D>(canvas_item)) - Object::cast_to<Node2D>(canvas_item)->edit_set_pivot(se->undo_pivot); + Object::cast_to<Node2D>(canvas_item)->_edit_set_pivot(se->undo_pivot); if (Object::cast_to<Control>(canvas_item)) Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot); } @@ -1574,8 +1574,8 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { for (List<BoneIK>::Element *E = bone_ik_list.back(); E; E = E->prev()) { - undo_redo->add_do_method(E->get().node, "edit_set_state", E->get().node->edit_get_state()); - undo_redo->add_undo_method(E->get().node, "edit_set_state", E->get().orig_state); + undo_redo->add_do_method(E->get().node, "_edit_set_state", E->get().node->_edit_get_state()); + undo_redo->add_undo_method(E->get().node, "_edit_set_state", E->get().orig_state); } undo_redo->add_do_method(viewport, "update"); @@ -1601,14 +1601,14 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { if (!se) continue; - Variant state = canvas_item->edit_get_state(); - undo_redo->add_do_method(canvas_item, "edit_set_state", state); - undo_redo->add_undo_method(canvas_item, "edit_set_state", se->undo_state); + Variant state = canvas_item->_edit_get_state(); + undo_redo->add_do_method(canvas_item, "_edit_set_state", state); + undo_redo->add_undo_method(canvas_item, "_edit_set_state", se->undo_state); { Node2D *pvt = Object::cast_to<Node2D>(canvas_item); - if (pvt && pvt->edit_has_pivot()) { - undo_redo->add_do_method(canvas_item, "edit_set_pivot", pvt->edit_get_pivot()); - undo_redo->add_undo_method(canvas_item, "edit_set_pivot", se->undo_pivot); + if (pvt && pvt->_edit_use_pivot()) { + undo_redo->add_do_method(canvas_item, "_edit_set_pivot", pvt->_edit_get_pivot()); + undo_redo->add_undo_method(canvas_item, "_edit_set_pivot", se->undo_pivot); } Control *cnt = Object::cast_to<Control>(canvas_item); @@ -1709,7 +1709,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { BoneIK bik; bik.node = b; bik.len = len; - bik.orig_state = b->edit_get_state(); + bik.orig_state = b->_edit_get_state(); bone_ik_list.push_back(bik); @@ -1741,13 +1741,13 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { if ((b->get_control() && tool == TOOL_SELECT) || tool == TOOL_ROTATE) { drag = DRAG_ROTATE; drag_from = transform.affine_inverse().xform(click); - se->undo_state = canvas_item->edit_get_state(); + se->undo_state = canvas_item->_edit_get_state(); if (Object::cast_to<Node2D>(canvas_item)) - se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot(); + se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->_edit_get_pivot(); if (Object::cast_to<Control>(canvas_item)) se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); - se->pre_drag_rect = canvas_item->get_item_rect(); + se->pre_drag_rect = canvas_item->_edit_get_rect(); return; } @@ -1764,13 +1764,13 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { drag = _get_resize_handle_drag_type(click, drag_point_from); if (drag != DRAG_NONE) { drag_from = transform.affine_inverse().xform(click); - se->undo_state = canvas_item->edit_get_state(); + se->undo_state = canvas_item->_edit_get_state(); if (Object::cast_to<Node2D>(canvas_item)) - se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->edit_get_pivot(); + se->undo_pivot = Object::cast_to<Node2D>(canvas_item)->_edit_get_pivot(); if (Object::cast_to<Control>(canvas_item)) se->undo_pivot = Object::cast_to<Control>(canvas_item)->get_pivot_offset(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); - se->pre_drag_rect = canvas_item->get_item_rect(); + se->pre_drag_rect = canvas_item->_edit_get_rect(); return; } @@ -1780,9 +1780,9 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { drag = _get_anchor_handle_drag_type(click, drag_point_from); if (drag != DRAG_NONE) { drag_from = transform.affine_inverse().xform(click); - se->undo_state = canvas_item->edit_get_state(); + se->undo_state = canvas_item->_edit_get_state(); se->pre_drag_xform = canvas_item->get_global_transform_with_canvas(); - se->pre_drag_rect = canvas_item->get_item_rect(); + se->pre_drag_rect = canvas_item->_edit_get_rect(); return; } } @@ -1890,9 +1890,9 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { bool dragging_bone = drag == DRAG_ALL && selection.size() == 1 && bone_ik_list.size(); if (!dragging_bone) { - canvas_item->edit_set_state(se->undo_state); //reset state and reapply + canvas_item->_edit_set_state(se->undo_state); //reset state and reapply if (Object::cast_to<Node2D>(canvas_item)) - Object::cast_to<Node2D>(canvas_item)->edit_set_pivot(se->undo_pivot); + Object::cast_to<Node2D>(canvas_item)->_edit_set_pivot(se->undo_pivot); if (Object::cast_to<Control>(canvas_item)) Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot); } @@ -2003,10 +2003,10 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { canvas_item->get_global_transform_with_canvas().affine_inverse().xform(dto) - canvas_item->get_global_transform_with_canvas().affine_inverse().xform(dfrom); - Rect2 local_rect = canvas_item->get_item_rect(); + Rect2 local_rect = canvas_item->_edit_get_rect(); Vector2 begin = local_rect.position; Vector2 end = local_rect.position + local_rect.size; - Vector2 minsize = canvas_item->edit_get_minimum_size(); + Vector2 minsize = canvas_item->_edit_get_minimum_size(); if (uniform) { // Keep the height/width ratio of the item @@ -2084,7 +2084,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { if (Object::cast_to<Node2D>(canvas_item)) { Node2D *n2d = Object::cast_to<Node2D>(canvas_item); - n2d->edit_set_pivot(se->undo_pivot + drag_vector); + n2d->_edit_set_pivot(se->undo_pivot + drag_vector); } if (Object::cast_to<Control>(canvas_item)) { Object::cast_to<Control>(canvas_item)->set_pivot_offset(se->undo_pivot + drag_vector); @@ -2103,7 +2103,7 @@ void CanvasItemEditor::_gui_input_viewport(const Ref<InputEvent> &p_event) { local_rect.position = begin; local_rect.size = end - begin; - canvas_item->edit_set_rect(local_rect); + canvas_item->_edit_set_rect(local_rect); } else { //ok, all that had to be done was done, now solve IK @@ -2454,7 +2454,7 @@ void CanvasItemEditor::_draw_selection() { if (!se) continue; - Rect2 rect = canvas_item->get_item_rect(); + Rect2 rect = canvas_item->_edit_get_rect(); if (show_helpers && drag != DRAG_NONE && drag != DRAG_PIVOT) { const Transform2D pre_drag_xform = transform * se->pre_drag_xform; @@ -2496,7 +2496,7 @@ void CanvasItemEditor::_draw_selection() { Node2D *node2d = Object::cast_to<Node2D>(canvas_item); if (node2d) { - if (node2d->edit_has_pivot()) { + if (node2d->_edit_use_pivot()) { viewport->draw_texture(pivot_icon, xform.get_origin() + (-pivot_icon->get_size() / 2).floor()); can_move_pivot = true; pivot_found = true; @@ -2868,7 +2868,7 @@ void CanvasItemEditor::_get_encompassing_rect(Node *p_node, Rect2 &r_rect, const CanvasItem *c = Object::cast_to<CanvasItem>(p_node); if (c && c->is_visible_in_tree()) { - Rect2 rect = c->get_item_rect(); + Rect2 rect = c->_edit_get_rect(); Transform2D xform = p_xform * c->get_transform(); r_rect.expand_to(xform.xform(rect.position)); r_rect.expand_to(xform.xform(rect.position + Point2(rect.size.x, 0))); @@ -2963,7 +2963,7 @@ void CanvasItemEditor::_notification(int p_what) { if (!se) continue; - Rect2 r = canvas_item->get_item_rect(); + Rect2 r = canvas_item->_edit_get_rect(); Transform2D xform = canvas_item->get_transform(); if (r != se->prev_rect || xform != se->prev_xform) { @@ -3623,7 +3623,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (key_pos) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "position", n2d->get_position(), existing); if (key_rot) - AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "rotation_deg", Math::rad2deg(n2d->get_rotation()), existing); + AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "rotation_degrees", Math::rad2deg(n2d->get_rotation()), existing); if (key_scale) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(n2d, "scale", n2d->get_scale(), existing); @@ -3654,7 +3654,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (key_pos) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "position", F->get()->get_position(), existing); if (key_rot) - AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "rotation_deg", Math::rad2deg(F->get()->get_rotation()), existing); + AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "rotation_degrees", Math::rad2deg(F->get()->get_rotation()), existing); if (key_scale) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(F->get(), "scale", F->get()->get_scale(), existing); } @@ -3668,7 +3668,7 @@ void CanvasItemEditor::_popup_callback(int p_op) { if (key_pos) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_position", ctrl->get_position(), existing); if (key_rot) - AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_rotation", ctrl->get_rotation_deg(), existing); + AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_rotation", ctrl->get_rotation_degrees(), existing); if (key_scale) AnimationPlayerEditor::singleton->get_key_editor()->insert_node_value_key(ctrl, "rect_size", ctrl->get_size(), existing); } @@ -3899,7 +3899,7 @@ void CanvasItemEditor::_focus_selection(int p_op) { //if (!canvas_item->is_visible_in_tree()) continue; ++count; - Rect2 item_rect = canvas_item->get_item_rect(); + Rect2 item_rect = canvas_item->_edit_get_rect(); Vector2 pos = canvas_item->get_global_transform().get_origin(); Vector2 scale = canvas_item->get_global_transform().get_scale(); @@ -4373,11 +4373,11 @@ void CanvasItemEditorViewport::_on_mouse_exit() { void CanvasItemEditorViewport::_on_select_type(Object *selected) { CheckBox *check = Object::cast_to<CheckBox>(selected); String type = check->get_text(); - selector_label->set_text(vformat(TTR("Add %s"), type)); + selector->set_title(vformat(TTR("Add %s"), type)); label->set_text(vformat(TTR("Adding %s..."), type)); } -void CanvasItemEditorViewport::_on_change_type() { +void CanvasItemEditorViewport::_on_change_type_confirmed() { if (!button_group->get_pressed_button()) return; @@ -4387,6 +4387,11 @@ void CanvasItemEditorViewport::_on_change_type() { selector->hide(); } +void CanvasItemEditorViewport::_on_change_type_closed() { + + _remove_preview(); +} + void CanvasItemEditorViewport::_create_preview(const Vector<String> &files) const { label->set_position(get_global_position() + Point2(14, 14) * EDSCALE); label_desc->set_position(label->get_position() + Point2(0, label->get_size().height)); @@ -4698,7 +4703,7 @@ void CanvasItemEditorViewport::drop_data(const Point2 &p_point, const Variant &p CheckBox *check = Object::cast_to<CheckBox>(btn_list[i]); check->set_pressed(check->get_text() == default_type); } - selector_label->set_text(vformat(TTR("Add %s"), default_type)); + selector->set_title(vformat(TTR("Add %s"), default_type)); selector->popup_centered_minsize(); } else { _perform_drop_data(); @@ -4721,7 +4726,8 @@ void CanvasItemEditorViewport::_notification(int p_what) { void CanvasItemEditorViewport::_bind_methods() { ClassDB::bind_method(D_METHOD("_on_select_type"), &CanvasItemEditorViewport::_on_select_type); - ClassDB::bind_method(D_METHOD("_on_change_type"), &CanvasItemEditorViewport::_on_change_type); + ClassDB::bind_method(D_METHOD("_on_change_type_confirmed"), &CanvasItemEditorViewport::_on_change_type_confirmed); + ClassDB::bind_method(D_METHOD("_on_change_type_closed"), &CanvasItemEditorViewport::_on_change_type_closed); ClassDB::bind_method(D_METHOD("_on_mouse_exit"), &CanvasItemEditorViewport::_on_mouse_exit); } @@ -4749,7 +4755,8 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte selector = memnew(AcceptDialog); editor->get_gui_base()->add_child(selector); selector->set_title(TTR("Change default type")); - selector->connect("confirmed", this, "_on_change_type"); + selector->connect("confirmed", this, "_on_change_type_confirmed"); + selector->connect("popup_hide", this, "_on_change_type_closed"); VBoxContainer *vbc = memnew(VBoxContainer); selector->add_child(vbc); @@ -4757,12 +4764,6 @@ CanvasItemEditorViewport::CanvasItemEditorViewport(EditorNode *p_node, CanvasIte vbc->set_v_size_flags(SIZE_EXPAND_FILL); vbc->set_custom_minimum_size(Size2(200, 260) * EDSCALE); - selector_label = memnew(Label); - vbc->add_child(selector_label); - selector_label->set_align(Label::ALIGN_CENTER); - selector_label->set_valign(Label::VALIGN_BOTTOM); - selector_label->set_custom_minimum_size(Size2(0, 30) * EDSCALE); - btn_group = memnew(VBoxContainer); vbc->add_child(btn_group); btn_group->set_h_size_flags(0); diff --git a/editor/plugins/canvas_item_editor_plugin.h b/editor/plugins/canvas_item_editor_plugin.h index 97e3b03569..457833e1a7 100644 --- a/editor/plugins/canvas_item_editor_plugin.h +++ b/editor/plugins/canvas_item_editor_plugin.h @@ -568,7 +568,8 @@ class CanvasItemEditorViewport : public Control { void _on_mouse_exit(); void _on_select_type(Object *selected); - void _on_change_type(); + void _on_change_type_confirmed(); + void _on_change_type_closed(); void _create_preview(const Vector<String> &files) const; void _remove_preview(); diff --git a/editor/plugins/collision_polygon_editor_plugin.cpp b/editor/plugins/collision_polygon_editor_plugin.cpp index 24c4813771..0818c8975e 100644 --- a/editor/plugins/collision_polygon_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_editor_plugin.cpp @@ -389,7 +389,7 @@ void CollisionPolygonEditor::_polygon_draw() { rect = rect.grow(1); - Rect3 r; + AABB r; r.position.x = rect.position.x; r.position.y = rect.position.y; r.position.z = depth; diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index c48a241e4d..ed04c90cc5 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -184,7 +184,7 @@ Ref<Texture> EditorPackedScenePreviewPlugin::generate(const RES &p_from) { Ref<Texture> EditorPackedScenePreviewPlugin::generate_from_path(const String &p_path) { - String temp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp"); + String temp_path = EditorSettings::get_singleton()->get_cache_dir(); String cache_base = ProjectSettings::get_singleton()->globalize_path(p_path).md5_text(); cache_base = temp_path.plus_file("resthumb-" + cache_base); @@ -278,11 +278,11 @@ EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { VS::get_singleton()->camera_set_transform(camera, Transform(Basis(), Vector3(0, 0, 3))); VS::get_singleton()->camera_set_perspective(camera, 45, 0.1, 10); - light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light = VS::get_singleton()->directional_light_create(); light_instance = VS::get_singleton()->instance_create2(light, scenario); VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light2 = VS::get_singleton()->directional_light_create(); VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); //VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); @@ -790,13 +790,13 @@ Ref<Texture> EditorMeshPreviewPlugin::generate(const RES &p_from) { VS::get_singleton()->instance_set_base(mesh_instance, mesh->get_rid()); - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); Vector3 ofs = aabb.position + aabb.size * 0.5; aabb.position -= ofs; Transform xform; xform.basis = Basis().rotated(Vector3(0, 1, 0), -Math_PI * 0.125); xform.basis = Basis().rotated(Vector3(1, 0, 0), Math_PI * 0.125) * xform.basis; - Rect3 rot_aabb = xform.xform(aabb); + AABB rot_aabb = xform.xform(aabb); float m = MAX(rot_aabb.size.x, rot_aabb.size.y) * 0.5; if (m == 0) return Ref<Texture>(); @@ -850,11 +850,11 @@ EditorMeshPreviewPlugin::EditorMeshPreviewPlugin() { //VS::get_singleton()->camera_set_perspective(camera,45,0.1,10); VS::get_singleton()->camera_set_orthogonal(camera, 1.0, 0.01, 1000.0); - light = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light = VS::get_singleton()->directional_light_create(); light_instance = VS::get_singleton()->instance_create2(light, scenario); VS::get_singleton()->instance_set_transform(light_instance, Transform().looking_at(Vector3(-1, -1, -1), Vector3(0, 1, 0))); - light2 = VS::get_singleton()->light_create(VS::LIGHT_DIRECTIONAL); + light2 = VS::get_singleton()->directional_light_create(); VS::get_singleton()->light_set_color(light2, Color(0.7, 0.7, 0.7)); //VS::get_singleton()->light_set_color(light2, VS::LIGHT_COLOR_SPECULAR, Color(0.0, 0.0, 0.0)); light_instance2 = VS::get_singleton()->instance_create2(light2, scenario); diff --git a/editor/plugins/material_editor_plugin.cpp b/editor/plugins/material_editor_plugin.cpp index bd4891ccb7..1fc112896d 100644 --- a/editor/plugins/material_editor_plugin.cpp +++ b/editor/plugins/material_editor_plugin.cpp @@ -503,3 +503,41 @@ Ref<Resource> ParticlesMaterialConversionPlugin::convert(const Ref<Resource> &p_ smat->set_render_priority(mat->get_render_priority()); return smat; } + +String CanvasItemMaterialConversionPlugin::converts_to() const { + + return "ShaderMaterial"; +} +bool CanvasItemMaterialConversionPlugin::handles(const Ref<Resource> &p_resource) const { + + Ref<CanvasItemMaterial> mat = p_resource; + return mat.is_valid(); +} +Ref<Resource> CanvasItemMaterialConversionPlugin::convert(const Ref<Resource> &p_resource) { + + Ref<CanvasItemMaterial> mat = p_resource; + ERR_FAIL_COND_V(!mat.is_valid(), Ref<Resource>()); + + Ref<ShaderMaterial> smat; + smat.instance(); + + Ref<Shader> shader; + shader.instance(); + + String code = VS::get_singleton()->shader_get_code(mat->get_shader_rid()); + + shader->set_code(code); + + smat->set_shader(shader); + + List<PropertyInfo> params; + VS::get_singleton()->shader_get_param_list(mat->get_shader_rid(), ¶ms); + + for (List<PropertyInfo>::Element *E = params.front(); E; E = E->next()) { + Variant value = VS::get_singleton()->material_get_param(mat->get_rid(), E->get().name); + smat->set_shader_param(E->get().name, value); + } + + smat->set_render_priority(mat->get_render_priority()); + return smat; +} diff --git a/editor/plugins/material_editor_plugin.h b/editor/plugins/material_editor_plugin.h index 52c73cb7d8..2cc24be33a 100644 --- a/editor/plugins/material_editor_plugin.h +++ b/editor/plugins/material_editor_plugin.h @@ -119,4 +119,12 @@ public: virtual Ref<Resource> convert(const Ref<Resource> &p_resource); }; +class CanvasItemMaterialConversionPlugin : public EditorResourceConversionPlugin { + GDCLASS(CanvasItemMaterialConversionPlugin, EditorResourceConversionPlugin) +public: + virtual String converts_to() const; + virtual bool handles(const Ref<Resource> &p_resource) const; + virtual Ref<Resource> convert(const Ref<Resource> &p_resource); +}; + #endif // MATERIAL_EDITOR_PLUGIN_H diff --git a/editor/plugins/mesh_editor_plugin.cpp b/editor/plugins/mesh_editor_plugin.cpp index 74618aecc2..60e8858b2d 100644 --- a/editor/plugins/mesh_editor_plugin.cpp +++ b/editor/plugins/mesh_editor_plugin.cpp @@ -95,7 +95,7 @@ void MeshEditor::edit(Ref<Mesh> p_mesh) { rot_y = 0; _update_rotation(); - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); print_line("aabb: " + aabb); Vector3 ofs = aabb.position + aabb.size * 0.5; float m = aabb.get_longest_axis_size(); diff --git a/editor/plugins/particles_editor_plugin.cpp b/editor/plugins/particles_editor_plugin.cpp index 10834b74ff..f4a9960087 100644 --- a/editor/plugins/particles_editor_plugin.cpp +++ b/editor/plugins/particles_editor_plugin.cpp @@ -153,15 +153,15 @@ void ParticlesEditor::_generate_aabb() { EditorProgress ep("gen_aabb", TTR("Generating AABB"), int(time)); - Rect3 rect; + AABB rect; while (running < time) { uint64_t ticks = OS::get_singleton()->get_ticks_usec(); ep.step("Generating..", int(running), true); OS::get_singleton()->delay_usec(1000); - Rect3 capture = node->capture_aabb(); - if (rect == Rect3()) + AABB capture = node->capture_aabb(); + if (rect == AABB()) rect = capture; else rect.merge_with(capture); @@ -247,7 +247,7 @@ void ParticlesEditor::_generate_emission_points() { PoolVector<Face3>::Read r = geometry.read(); - Rect3 aabb; + AABB aabb; for (int i = 0; i < gcount; i++) { diff --git a/editor/plugins/resource_preloader_editor_plugin.cpp b/editor/plugins/resource_preloader_editor_plugin.cpp index d421b3798b..3210af1433 100644 --- a/editor/plugins/resource_preloader_editor_plugin.cpp +++ b/editor/plugins/resource_preloader_editor_plugin.cpp @@ -43,7 +43,7 @@ void ResourcePreloaderEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { load->set_icon(get_icon("Folder", "EditorIcons")); - _delete->set_icon(get_icon("Del", "EditorIcons")); + _delete->set_icon(get_icon("Remove", "EditorIcons")); } if (p_what == NOTIFICATION_READY) { diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index a1183307fb..32ec9b2ba9 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -586,6 +586,32 @@ void ScriptEditor::_close_docs_tab() { } } +void ScriptEditor::_close_other_tabs() { + + int child_count = tab_container->get_child_count(); + int current_idx = tab_container->get_current_tab(); + for (int i = child_count - 1; i >= 0; i--) { + + if (i == current_idx) { + continue; + } + + tab_container->set_current_tab(i); + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(i)); + + if (se) { + + // Maybe there are unsaved changes + if (se->is_unsaved()) { + _ask_close_current_unsaved_tab(se); + continue; + } + } + + _close_current_tab(); + } +} + void ScriptEditor::_close_all_tabs() { int child_count = tab_container->get_child_count(); @@ -855,7 +881,7 @@ void ScriptEditor::_menu_option(int p_option) { file_dialog_option = FILE_SAVE_THEME_AS; file_dialog->clear_filters(); file_dialog->add_filter("*.tet"); - file_dialog->set_current_path(EditorSettings::get_singleton()->get_settings_path() + "/text_editor_themes/" + EditorSettings::get_singleton()->get("text_editor/theme/color_theme")); + file_dialog->set_current_path(EditorSettings::get_singleton()->get_text_editor_themes_dir().plus_file(EditorSettings::get_singleton()->get("text_editor/theme/color_theme"))); file_dialog->popup_centered_ratio(); file_dialog->set_title(TTR("Save Theme As..")); } break; @@ -865,20 +891,7 @@ void ScriptEditor::_menu_option(int p_option) { } break; case SEARCH_CLASSES: { - String current; - - if (tab_container->get_tab_count() > 0) { - EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(tab_container->get_current_tab())); - if (eh) { - current = eh->get_class(); - } - } - help_index->popup(); - - if (current != "") { - help_index->call_deferred("select_class", current); - } } break; case SEARCH_WEBSITE: { @@ -890,8 +903,13 @@ void ScriptEditor::_menu_option(int p_option) { _history_forward(); } break; case WINDOW_PREV: { + _history_back(); } break; + case WINDOW_SORT: { + _sort_list_on_update = true; + _update_script_names(); + } break; case DEBUG_SHOW: { if (debugger) { bool visible = debug_menu->get_popup()->is_item_checked(debug_menu->get_popup()->get_item_index(DEBUG_SHOW)); @@ -926,10 +944,6 @@ void ScriptEditor::_menu_option(int p_option) { if (current) { switch (p_option) { - case FILE_NEW: { - script_create_dialog->config("Node", ".gd"); - script_create_dialog->popup_centered(Size2(300, 300) * EDSCALE); - } break; case FILE_SAVE: { if (_test_script_times_on_disk()) @@ -1015,6 +1029,9 @@ void ScriptEditor::_menu_option(int p_option) { case CLOSE_DOCS: { _close_docs_tab(); } break; + case CLOSE_OTHER_TABS: { + _close_other_tabs(); + } break; case CLOSE_ALL: { _close_all_tabs(); } break; @@ -1041,26 +1058,22 @@ void ScriptEditor::_menu_option(int p_option) { debugger->debug_continue(); } break; - case WINDOW_MOVE_LEFT: { + case WINDOW_MOVE_UP: { if (tab_container->get_current_tab() > 0) { - tab_container->call_deferred("set_current_tab", tab_container->get_current_tab() - 1); - script_list->call_deferred("select", tab_container->get_current_tab() - 1); tab_container->move_child(current, tab_container->get_current_tab() - 1); + tab_container->set_current_tab(tab_container->get_current_tab() - 1); _update_script_names(); } } break; - case WINDOW_MOVE_RIGHT: { + case WINDOW_MOVE_DOWN: { if (tab_container->get_current_tab() < tab_container->get_child_count() - 1) { - tab_container->call_deferred("set_current_tab", tab_container->get_current_tab() + 1); - script_list->call_deferred("select", tab_container->get_current_tab() + 1); tab_container->move_child(current, tab_container->get_current_tab() + 1); + tab_container->set_current_tab(tab_container->get_current_tab() + 1); _update_script_names(); } - } break; - default: { if (p_option >= WINDOW_SELECT_BASE) { @@ -1077,6 +1090,11 @@ void ScriptEditor::_menu_option(int p_option) { switch (p_option) { + case SEARCH_CLASSES: { + + help_index->popup(); + help_index->call_deferred("select_class", help->get_class()); + } break; case HELP_SEARCH_FIND: { help->popup_search(); } break; @@ -1089,9 +1107,28 @@ void ScriptEditor::_menu_option(int p_option) { case CLOSE_DOCS: { _close_docs_tab(); } break; + case CLOSE_OTHER_TABS: { + _close_other_tabs(); + } break; case CLOSE_ALL: { _close_all_tabs(); } break; + case WINDOW_MOVE_UP: { + + if (tab_container->get_current_tab() > 0) { + tab_container->move_child(help, tab_container->get_current_tab() - 1); + tab_container->set_current_tab(tab_container->get_current_tab() - 1); + _update_script_names(); + } + } break; + case WINDOW_MOVE_DOWN: { + + if (tab_container->get_current_tab() < tab_container->get_child_count() - 1) { + tab_container->move_child(help, tab_container->get_current_tab() + 1); + tab_container->set_current_tab(tab_container->get_current_tab() + 1); + _update_script_names(); + } + } break; } } } @@ -1114,6 +1151,7 @@ void ScriptEditor::_notification(int p_what) { editor->connect("script_add_function_request", this, "_add_callback"); editor->connect("resource_saved", this, "_res_saved_callback"); script_list->connect("item_selected", this, "_script_selected"); + members_overview->connect("item_selected", this, "_members_overview_selected"); help_overview->connect("item_selected", this, "_help_overview_selected"); script_split->connect("dragged", this, "_script_split_dragged"); @@ -1361,6 +1399,7 @@ struct _ScriptEditorItemData { String tooltip; bool used; int category; + Node *ref; bool operator<(const _ScriptEditorItemData &id) const { @@ -1526,6 +1565,7 @@ void ScriptEditor::_update_script_names() { sd.index = i; sd.used = used.has(se->get_edited_script()); sd.category = 0; + sd.ref = se; switch (sort_by) { case SORT_BY_NAME: { @@ -1565,16 +1605,38 @@ void ScriptEditor::_update_script_names() { _ScriptEditorItemData sd; sd.icon = icon; sd.name = name; - sd.sort_key = name; + sd.sort_key = name.to_lower(); sd.tooltip = tooltip; sd.index = i; sd.used = false; sd.category = split_script_help ? 1 : 0; + sd.ref = eh; + sedata.push_back(sd); } } - sedata.sort(); + if (_sort_list_on_update && !sedata.empty()) { + sedata.sort(); + + // change actual order of tab_container so that the order can be rearranged by user + int cur_tab = tab_container->get_current_tab(); + int prev_tab = tab_container->get_previous_tab(); + int new_cur_tab = -1; + int new_prev_tab = -1; + for (int i = 0; i < sedata.size(); i++) { + tab_container->move_child(sedata[i].ref, i); + if (new_prev_tab == -1 && sedata[i].index == prev_tab) { + new_prev_tab = i; + } + if (new_cur_tab == -1 && sedata[i].index == cur_tab) { + new_cur_tab = i; + } + } + tab_container->call_deferred("set_current_tab", new_prev_tab); + tab_container->call_deferred("set_current_tab", new_cur_tab); + _sort_list_on_update = false; + } for (int i = 0; i < sedata.size(); i++) { @@ -1903,8 +1965,171 @@ void ScriptEditor::_script_split_dragged(float) { _save_layout(); } +Variant ScriptEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { + + // return Variant(); // return this if drag disabled + + Node *cur_node = tab_container->get_child(tab_container->get_current_tab()); + + HBoxContainer *drag_preview = memnew(HBoxContainer); + String preview_name = ""; + Ref<Texture> preview_icon; + + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(cur_node); + if (se) { + preview_name = se->get_name(); + preview_icon = se->get_icon(); + } + EditorHelp *eh = Object::cast_to<EditorHelp>(cur_node); + if (eh) { + preview_name = eh->get_class(); + preview_icon = get_icon("Help", "EditorIcons"); + } + + if (!preview_icon.is_null()) { + TextureRect *tf = memnew(TextureRect); + tf->set_texture(preview_icon); + drag_preview->add_child(tf); + } + Label *label = memnew(Label(preview_name)); + drag_preview->add_child(label); + set_drag_preview(drag_preview); + + Dictionary drag_data; + drag_data["type"] = "script_list_element"; // using a custom type because node caused problems when dragging to scene tree + drag_data["script_list_element"] = cur_node; + + return drag_data; +} + +bool ScriptEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { + + Dictionary d = p_data; + if (!d.has("type")) + return false; + + if (String(d["type"]) == "script_list_element") { + + Node *node = d["script_list_element"]; + + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node); + if (se) { + return true; + } + EditorHelp *eh = Object::cast_to<EditorHelp>(node); + if (eh) { + return true; + } + } + + if (String(d["type"]) == "nodes") { + + Array nodes = d["nodes"]; + if (nodes.size() == 0) + return false; + Node *node = get_node((nodes[0])); + + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node); + if (se) { + return true; + } + EditorHelp *eh = Object::cast_to<EditorHelp>(node); + if (eh) { + return true; + } + } + + if (String(d["type"]) == "files") { + + Vector<String> files = d["files"]; + + if (files.size() == 0) + return false; //weird + + for (int i = 0; i < files.size(); i++) { + String file = files[i]; + if (file == "" || !FileAccess::exists(file)) + continue; + Ref<Script> scr = ResourceLoader::load(file); + if (scr.is_valid()) { + return true; + } + } + return true; + } + + return false; +} + +void ScriptEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) { + + if (!can_drop_data_fw(p_point, p_data, p_from)) + return; + + Dictionary d = p_data; + if (!d.has("type")) + return; + + if (String(d["type"]) == "script_list_element") { + + Node *node = d["script_list_element"]; + + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node); + EditorHelp *eh = Object::cast_to<EditorHelp>(node); + if (se || eh) { + int new_index = script_list->get_item_at_position(p_point); + tab_container->move_child(node, new_index); + tab_container->set_current_tab(new_index); + _update_script_names(); + } + } + + if (String(d["type"]) == "nodes") { + + Array nodes = d["nodes"]; + if (nodes.size() == 0) + return; + Node *node = get_node(nodes[0]); + + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(node); + EditorHelp *eh = Object::cast_to<EditorHelp>(node); + if (se || eh) { + int new_index = script_list->get_item_at_position(p_point); + tab_container->move_child(node, new_index); + tab_container->set_current_tab(new_index); + _update_script_names(); + } + } + + if (String(d["type"]) == "files") { + + Vector<String> files = d["files"]; + + int new_index = script_list->get_item_at_position(p_point); + int num_tabs_before = tab_container->get_child_count(); + for (int i = 0; i < files.size(); i++) { + String file = files[i]; + if (file == "" || !FileAccess::exists(file)) + continue; + Ref<Script> scr = ResourceLoader::load(file); + if (scr.is_valid()) { + edit(scr); + if (tab_container->get_child_count() > num_tabs_before) { + tab_container->move_child(tab_container->get_child(tab_container->get_child_count() - 1), new_index); + num_tabs_before = tab_container->get_child_count(); + } else { + tab_container->move_child(tab_container->get_child(tab_container->get_current_tab()), new_index); + } + } + } + tab_container->set_current_tab(new_index); + _update_script_names(); + } +} + void ScriptEditor::_unhandled_input(const Ref<InputEvent> &p_event) { - if (p_event->is_pressed() || !is_visible_in_tree()) return; + if (!is_visible_in_tree() || !p_event->is_pressed() || p_event->is_echo()) + return; if (ED_IS_SHORTCUT("script_editor/next_script", p_event)) { int next_tab = script_list->get_current() + 1; next_tab %= script_list->get_item_count(); @@ -1917,6 +2142,64 @@ void ScriptEditor::_unhandled_input(const Ref<InputEvent> &p_event) { _go_to_tab(script_list->get_item_metadata(next_tab)); _update_script_names(); } + if (ED_IS_SHORTCUT("script_editor/window_move_up", p_event)) { + _menu_option(WINDOW_MOVE_UP); + } + if (ED_IS_SHORTCUT("script_editor/window_move_down", p_event)) { + _menu_option(WINDOW_MOVE_DOWN); + } +} + +void ScriptEditor::_script_list_gui_input(const Ref<InputEvent> &ev) { + + Ref<InputEventMouseButton> mb = ev; + if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) { + + _make_script_list_context_menu(); + } +} + +void ScriptEditor::_make_script_list_context_menu() { + + context_menu->clear(); + + int selected = tab_container->get_current_tab(); + if (selected < 0 || selected >= tab_container->get_child_count()) + return; + + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(selected)); + if (se) { + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/save"), FILE_SAVE); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/save_as"), FILE_SAVE_AS); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_file"), FILE_CLOSE); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_all"), CLOSE_ALL); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_other_tabs"), CLOSE_OTHER_TABS); + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_TOOL_RELOAD_SOFT); + + Ref<Script> scr = se->get_edited_script(); + if (!scr.is_null() && scr->is_tool()) { + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/run_file"), FILE_RUN); + } + } else { + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_file"), FILE_CLOSE); + } + + EditorHelp *eh = Object::cast_to<EditorHelp>(tab_container->get_child(selected)); + if (eh) { + // nothing + } + + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/window_move_up"), WINDOW_MOVE_UP); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/window_move_down"), WINDOW_MOVE_DOWN); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/window_sort"), WINDOW_SORT); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/toggle_scripts_panel"), TOGGLE_SCRIPTS_PANEL); + + context_menu->set_position(get_global_transform().xform(get_local_mouse_position())); + context_menu->set_size(Vector2(1, 1)); + context_menu->popup(); } void ScriptEditor::set_window_layout(Ref<ConfigFile> p_layout) { @@ -2210,6 +2493,7 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_close_discard_current_tab", &ScriptEditor::_close_discard_current_tab); ClassDB::bind_method("_close_docs_tab", &ScriptEditor::_close_docs_tab); ClassDB::bind_method("_close_all_tabs", &ScriptEditor::_close_all_tabs); + ClassDB::bind_method("_close_other_tabs", &ScriptEditor::_close_other_tabs); ClassDB::bind_method("_open_recent_script", &ScriptEditor::_open_recent_script); ClassDB::bind_method("_editor_play", &ScriptEditor::_editor_play); ClassDB::bind_method("_editor_pause", &ScriptEditor::_editor_pause); @@ -2243,9 +2527,14 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_history_back", &ScriptEditor::_history_back); ClassDB::bind_method("_live_auto_reload_running_scripts", &ScriptEditor::_live_auto_reload_running_scripts); ClassDB::bind_method("_unhandled_input", &ScriptEditor::_unhandled_input); + ClassDB::bind_method("_script_list_gui_input", &ScriptEditor::_script_list_gui_input); ClassDB::bind_method("_script_changed", &ScriptEditor::_script_changed); ClassDB::bind_method("_update_recent_scripts", &ScriptEditor::_update_recent_scripts); + ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &ScriptEditor::get_drag_data_fw); + ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &ScriptEditor::can_drop_data_fw); + ClassDB::bind_method(D_METHOD("drop_data_fw"), &ScriptEditor::drop_data_fw); + ClassDB::bind_method(D_METHOD("get_current_script"), &ScriptEditor::_get_current_script); ClassDB::bind_method(D_METHOD("get_open_scripts"), &ScriptEditor::_get_open_scripts); @@ -2286,6 +2575,14 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { script_list->set_v_size_flags(SIZE_EXPAND_FILL); script_split->set_split_offset(140); //list_split->set_split_offset(500); + _sort_list_on_update = true; + script_list->connect("gui_input", this, "_script_list_gui_input"); + script_list->set_allow_rmb_select(true); + script_list->set_drag_forwarding(this); + + context_menu = memnew(PopupMenu); + add_child(context_menu); + context_menu->connect("id_pressed", this, "_menu_option"); members_overview = memnew(ItemList); list_split->add_child(members_overview); @@ -2303,8 +2600,11 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { tab_container->set_h_size_flags(SIZE_EXPAND_FILL); - ED_SHORTCUT("script_editor/next_script", TTR("Next script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_GREATER); - ED_SHORTCUT("script_editor/prev_script", TTR("Previous script"), KEY_MASK_CMD | KEY_LESS); + ED_SHORTCUT("script_editor/window_sort", TTR("Sort")); + ED_SHORTCUT("script_editor/window_move_up", TTR("Move Up"), KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_UP); + ED_SHORTCUT("script_editor/window_move_down", TTR("Move Down"), KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_DOWN); + ED_SHORTCUT("script_editor/next_script", TTR("Next script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_PERIOD); // these should be KEY_GREATER and KEY_LESS but those don't work + ED_SHORTCUT("script_editor/prev_script", TTR("Previous script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_COLON); set_process_unhandled_input(true); file_menu = memnew(MenuButton); @@ -2339,6 +2639,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_docs", TTR("Close Docs")), CLOSE_DOCS); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_file", TTR("Close"), KEY_MASK_CMD | KEY_W), FILE_CLOSE); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_all", TTR("Close All")), CLOSE_ALL); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/close_other_tabs", TTR("Close Other Tabs")), CLOSE_OTHER_TABS); file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/run_file", TTR("Run"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_X), FILE_RUN); file_menu->get_popup()->add_separator(); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 03fc4da7ce..77ca4bc9d9 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -135,6 +135,7 @@ class ScriptEditor : public PanelContainer { FILE_CLOSE, CLOSE_DOCS, CLOSE_ALL, + CLOSE_OTHER_TABS, TOGGLE_SCRIPTS_PANEL, FILE_TOOL_RELOAD, FILE_TOOL_RELOAD_SOFT, @@ -150,10 +151,11 @@ class ScriptEditor : public PanelContainer { SEARCH_WEBSITE, HELP_SEARCH_FIND, HELP_SEARCH_FIND_NEXT, - WINDOW_MOVE_LEFT, - WINDOW_MOVE_RIGHT, + WINDOW_MOVE_UP, + WINDOW_MOVE_DOWN, WINDOW_NEXT, WINDOW_PREV, + WINDOW_SORT, WINDOW_SELECT_BASE = 100 }; @@ -173,6 +175,7 @@ class ScriptEditor : public PanelContainer { MenuButton *edit_menu; MenuButton *script_search_menu; MenuButton *debug_menu; + PopupMenu *context_menu; Timer *autosave_timer; uint64_t idle; @@ -249,6 +252,7 @@ class ScriptEditor : public PanelContainer { void _close_current_tab(); void _close_discard_current_tab(const String &p_str); void _close_docs_tab(); + void _close_other_tabs(); void _close_all_tabs(); void _ask_close_current_unsaved_tab(ScriptEditorBase *current); @@ -292,6 +296,7 @@ class ScriptEditor : public PanelContainer { void _update_members_overview_visibility(); void _update_members_overview(); void _update_script_names(); + bool _sort_list_on_update; void _members_overview_selected(int p_idx); void _script_selected(int p_idx); @@ -306,8 +311,15 @@ class ScriptEditor : public PanelContainer { void _script_split_dragged(float); + Variant get_drag_data_fw(const Point2 &p_point, Control *p_from); + bool can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const; + void drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from); + void _unhandled_input(const Ref<InputEvent> &p_event); + void _script_list_gui_input(const Ref<InputEvent> &ev); + void _make_script_list_context_menu(); + void _help_search(String p_text); void _help_index(String p_text); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index adf65c11e1..214f24b386 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -201,7 +201,7 @@ void ScriptTextEditor::_set_theme_for_script() { text_edit->add_keyword_color("Rect2", basetype_color); text_edit->add_keyword_color("Transform2D", basetype_color); text_edit->add_keyword_color("Vector3", basetype_color); - text_edit->add_keyword_color("Rect3", basetype_color); + text_edit->add_keyword_color("AABB", basetype_color); text_edit->add_keyword_color("Basis", basetype_color); text_edit->add_keyword_color("Plane", basetype_color); text_edit->add_keyword_color("Transform", basetype_color); @@ -518,7 +518,9 @@ void ScriptTextEditor::tag_saved_version() { } void ScriptTextEditor::goto_line(int p_line, bool p_with_error) { - code_editor->get_text_edit()->call_deferred("cursor_set_line", p_line); + TextEdit *tx = code_editor->get_text_edit(); + tx->unfold_line(p_line); + tx->call_deferred("cursor_set_line", p_line); } void ScriptTextEditor::ensure_focus() { @@ -712,15 +714,6 @@ void ScriptTextEditor::_breakpoint_toggled(int p_row) { ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(script->get_path(), p_row + 1, code_editor->get_text_edit()->is_line_set_as_breakpoint(p_row)); } -static void swap_lines(TextEdit *tx, int line1, int line2) { - String tmp = tx->get_line(line1); - String tmp2 = tx->get_line(line2); - tx->set_line(line2, tmp); - tx->set_line(line1, tmp2); - - tx->cursor_set_line(line2); -} - void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_column) { Node *base = get_tree()->get_edited_scene_root(); @@ -799,39 +792,41 @@ void ScriptTextEditor::_lookup_symbol(const String &p_symbol, int p_row, int p_c void ScriptTextEditor::_edit_option(int p_op) { + TextEdit *tx = code_editor->get_text_edit(); + switch (p_op) { case EDIT_UNDO: { - code_editor->get_text_edit()->undo(); - code_editor->get_text_edit()->call_deferred("grab_focus"); + + tx->undo(); + tx->call_deferred("grab_focus"); } break; case EDIT_REDO: { - code_editor->get_text_edit()->redo(); - code_editor->get_text_edit()->call_deferred("grab_focus"); + + tx->redo(); + tx->call_deferred("grab_focus"); } break; case EDIT_CUT: { - code_editor->get_text_edit()->cut(); - code_editor->get_text_edit()->call_deferred("grab_focus"); + tx->cut(); + tx->call_deferred("grab_focus"); } break; case EDIT_COPY: { - code_editor->get_text_edit()->copy(); - code_editor->get_text_edit()->call_deferred("grab_focus"); + tx->copy(); + tx->call_deferred("grab_focus"); } break; case EDIT_PASTE: { - code_editor->get_text_edit()->paste(); - code_editor->get_text_edit()->call_deferred("grab_focus"); + tx->paste(); + tx->call_deferred("grab_focus"); } break; case EDIT_SELECT_ALL: { - code_editor->get_text_edit()->select_all(); - code_editor->get_text_edit()->call_deferred("grab_focus"); - + tx->select_all(); + tx->call_deferred("grab_focus"); } break; case EDIT_MOVE_LINE_UP: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = script; if (scr.is_null()) return; @@ -850,7 +845,11 @@ void ScriptTextEditor::_edit_option(int p_op) { if (line_id == 0 || next_id < 0) return; - swap_lines(tx, line_id, next_id); + tx->unfold_line(line_id); + tx->unfold_line(next_id); + + tx->swap_lines(line_id, next_id); + tx->cursor_set_line(next_id); } int from_line_up = from_line > 0 ? from_line - 1 : from_line; int to_line_up = to_line > 0 ? to_line - 1 : to_line; @@ -862,15 +861,17 @@ void ScriptTextEditor::_edit_option(int p_op) { if (line_id == 0 || next_id < 0) return; - swap_lines(tx, line_id, next_id); + tx->unfold_line(line_id); + tx->unfold_line(next_id); + + tx->swap_lines(line_id, next_id); + tx->cursor_set_line(next_id); } tx->end_complex_operation(); tx->update(); - } break; case EDIT_MOVE_LINE_DOWN: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -889,7 +890,11 @@ void ScriptTextEditor::_edit_option(int p_op) { if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count()) return; - swap_lines(tx, line_id, next_id); + tx->unfold_line(line_id); + tx->unfold_line(next_id); + + tx->swap_lines(line_id, next_id); + tx->cursor_set_line(next_id); } int from_line_down = from_line < tx->get_line_count() ? from_line + 1 : from_line; int to_line_down = to_line < tx->get_line_count() ? to_line + 1 : to_line; @@ -901,7 +906,11 @@ void ScriptTextEditor::_edit_option(int p_op) { if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count()) return; - swap_lines(tx, line_id, next_id); + tx->unfold_line(line_id); + tx->unfold_line(next_id); + + tx->swap_lines(line_id, next_id); + tx->cursor_set_line(next_id); } tx->end_complex_operation(); tx->update(); @@ -909,7 +918,6 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case EDIT_INDENT_LEFT: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -934,11 +942,9 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->end_complex_operation(); tx->update(); //tx->deselect(); - } break; case EDIT_INDENT_RIGHT: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -955,11 +961,9 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->end_complex_operation(); tx->update(); //tx->deselect(); - } break; case EDIT_DELETE_LINE: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -968,13 +972,12 @@ void ScriptTextEditor::_edit_option(int p_op) { int line = tx->cursor_get_line(); tx->set_line(tx->cursor_get_line(), ""); tx->backspace_at_cursor(); + tx->unfold_line(line); tx->cursor_set_line(line); tx->end_complex_operation(); - } break; case EDIT_CLONE_DOWN: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -993,6 +996,7 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->begin_complex_operation(); for (int i = from_line; i <= to_line; i++) { + tx->unfold_line(i); if (i >= tx->get_line_count() - 1) { tx->set_line(i, tx->get_line(i) + "\n"); } @@ -1008,11 +1012,29 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->end_complex_operation(); tx->update(); + } break; + case EDIT_FOLD_LINE: { + + tx->fold_line(tx->cursor_get_line()); + tx->update(); + } break; + case EDIT_UNFOLD_LINE: { + + tx->unfold_line(tx->cursor_get_line()); + tx->update(); + } break; + case EDIT_FOLD_ALL_LINES: { + + tx->fold_all_lines(); + tx->update(); + } break; + case EDIT_UNFOLD_ALL_LINES: { + tx->unhide_all_lines(); + tx->update(); } break; case EDIT_TOGGLE_COMMENT: { - TextEdit *tx = code_editor->get_text_edit(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; @@ -1061,62 +1083,65 @@ void ScriptTextEditor::_edit_option(int p_op) { tx->end_complex_operation(); tx->update(); //tx->deselect(); - } break; case EDIT_COMPLETE: { - code_editor->get_text_edit()->query_code_comple(); - + tx->query_code_comple(); } break; case EDIT_AUTO_INDENT: { - TextEdit *te = code_editor->get_text_edit(); - String text = te->get_text(); + String text = tx->get_text(); Ref<Script> scr = get_edited_script(); if (scr.is_null()) return; - te->begin_complex_operation(); + tx->begin_complex_operation(); int begin, end; - if (te->is_selection_active()) { - begin = te->get_selection_from_line(); - end = te->get_selection_to_line(); + if (tx->is_selection_active()) { + begin = tx->get_selection_from_line(); + end = tx->get_selection_to_line(); // ignore if the cursor is not past the first column - if (te->get_selection_to_column() == 0) { + if (tx->get_selection_to_column() == 0) { end--; } } else { begin = 0; - end = te->get_line_count() - 1; + end = tx->get_line_count() - 1; } scr->get_language()->auto_indent_code(text, begin, end); Vector<String> lines = text.split("\n"); for (int i = begin; i <= end; ++i) { - te->set_line(i, lines[i]); + tx->set_line(i, lines[i]); } - te->end_complex_operation(); - + tx->end_complex_operation(); } break; case EDIT_TRIM_TRAILING_WHITESAPCE: { + trim_trailing_whitespace(); } break; case EDIT_CONVERT_INDENT_TO_SPACES: { + convert_indent_to_spaces(); } break; case EDIT_CONVERT_INDENT_TO_TABS: { + convert_indent_to_tabs(); } break; case EDIT_PICK_COLOR: { + color_panel->popup(); } break; case EDIT_TO_UPPERCASE: { + _convert_case(UPPER); } break; case EDIT_TO_LOWERCASE: { + _convert_case(LOWER); } break; case EDIT_CAPITALIZE: { + _convert_case(CAPITALIZE); } break; case SEARCH_FIND: { @@ -1141,41 +1166,47 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case SEARCH_GOTO_LINE: { - goto_line_dialog->popup_find_line(code_editor->get_text_edit()); + goto_line_dialog->popup_find_line(tx); } break; case DEBUG_TOGGLE_BREAKPOINT: { - int line = code_editor->get_text_edit()->cursor_get_line(); - bool dobreak = !code_editor->get_text_edit()->is_line_set_as_breakpoint(line); - code_editor->get_text_edit()->set_line_as_breakpoint(line, dobreak); + + int line = tx->cursor_get_line(); + bool dobreak = !tx->is_line_set_as_breakpoint(line); + tx->set_line_as_breakpoint(line, dobreak); ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(get_edited_script()->get_path(), line + 1, dobreak); } break; case DEBUG_REMOVE_ALL_BREAKPOINTS: { + List<int> bpoints; - code_editor->get_text_edit()->get_breakpoints(&bpoints); + tx->get_breakpoints(&bpoints); for (List<int>::Element *E = bpoints.front(); E; E = E->next()) { int line = E->get(); - bool dobreak = !code_editor->get_text_edit()->is_line_set_as_breakpoint(line); - code_editor->get_text_edit()->set_line_as_breakpoint(line, dobreak); + bool dobreak = !tx->is_line_set_as_breakpoint(line); + tx->set_line_as_breakpoint(line, dobreak); ScriptEditor::get_singleton()->get_debugger()->set_breakpoint(get_edited_script()->get_path(), line + 1, dobreak); } } case DEBUG_GOTO_NEXT_BREAKPOINT: { + List<int> bpoints; - code_editor->get_text_edit()->get_breakpoints(&bpoints); + tx->get_breakpoints(&bpoints); if (bpoints.size() <= 0) { return; } - int line = code_editor->get_text_edit()->cursor_get_line(); + int line = tx->cursor_get_line(); + // wrap around if (line >= bpoints[bpoints.size() - 1]) { - code_editor->get_text_edit()->cursor_set_line(bpoints[0]); + tx->unfold_line(bpoints[0]); + tx->cursor_set_line(bpoints[0]); } else { for (List<int>::Element *E = bpoints.front(); E; E = E->next()) { int bline = E->get(); if (bline > line) { - code_editor->get_text_edit()->cursor_set_line(bline); + tx->unfold_line(bline); + tx->cursor_set_line(bline); return; } } @@ -1183,21 +1214,24 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case DEBUG_GOTO_PREV_BREAKPOINT: { + List<int> bpoints; - code_editor->get_text_edit()->get_breakpoints(&bpoints); + tx->get_breakpoints(&bpoints); if (bpoints.size() <= 0) { return; } - int line = code_editor->get_text_edit()->cursor_get_line(); + int line = tx->cursor_get_line(); // wrap around if (line <= bpoints[0]) { - code_editor->get_text_edit()->cursor_set_line(bpoints[bpoints.size() - 1]); + tx->unfold_line(bpoints[bpoints.size() - 1]); + tx->cursor_set_line(bpoints[bpoints.size() - 1]); } else { for (List<int>::Element *E = bpoints.back(); E; E = E->prev()) { int bline = E->get(); if (bline < line) { - code_editor->get_text_edit()->cursor_set_line(bline); + tx->unfold_line(bline); + tx->cursor_set_line(bline); return; } } @@ -1206,9 +1240,10 @@ void ScriptTextEditor::_edit_option(int p_op) { } break; case HELP_CONTEXTUAL: { - String text = code_editor->get_text_edit()->get_selection_text(); + + String text = tx->get_selection_text(); if (text == "") - text = code_editor->get_text_edit()->get_word_under_cursor(); + text = tx->get_word_under_cursor(); if (text != "") { emit_signal("request_help_search", text); } @@ -1394,6 +1429,9 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { Vector2 mpos = mb->get_global_position() - tx->get_global_position(); bool have_selection = (tx->get_selection_text().length() > 0); bool have_color = (tx->get_word_at_pos(mpos) == "Color"); + int fold_state = 0; + bool can_fold = tx->can_fold(row); + bool is_folded = tx->is_folded(row); if (have_color) { String line = tx->get_line(row); @@ -1424,7 +1462,7 @@ void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { have_color = false; } } - _make_context_menu(have_selection, have_color); + _make_context_menu(have_selection, have_color, can_fold, is_folded); } } } @@ -1443,7 +1481,7 @@ void ScriptTextEditor::_color_changed(const Color &p_color) { code_editor->get_text_edit()->set_line(color_line, new_line); } -void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) { +void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p_can_fold, bool p_is_folded) { context_menu->clear(); if (p_selection) { @@ -1463,6 +1501,13 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color) { context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT); } + if (p_can_fold) { + // can fold + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/fold_line"), EDIT_FOLD_LINE); + } else if (p_is_folded) { + // can unfold + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_line"), EDIT_UNFOLD_LINE); + } if (p_color) { context_menu->add_separator(); context_menu->add_item(TTR("Pick Color"), EDIT_PICK_COLOR); @@ -1526,6 +1571,10 @@ ScriptTextEditor::ScriptTextEditor() { edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/delete_line"), EDIT_DELETE_LINE); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT); edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/clone_down"), EDIT_CLONE_DOWN); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/fold_line"), EDIT_FOLD_LINE); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/fold_all_lines"), EDIT_FOLD_ALL_LINES); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_line"), EDIT_UNFOLD_LINE); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/unfold_all_lines"), EDIT_UNFOLD_ALL_LINES); edit_menu->get_popup()->add_separator(); #ifdef OSX_ENABLED edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/complete_symbol"), EDIT_COMPLETE); @@ -1603,6 +1652,10 @@ void ScriptTextEditor::register_editor() { ED_SHORTCUT("script_text_editor/indent_right", TTR("Indent Right"), 0); ED_SHORTCUT("script_text_editor/toggle_comment", TTR("Toggle Comment"), KEY_MASK_CMD | KEY_K); ED_SHORTCUT("script_text_editor/clone_down", TTR("Clone Down"), KEY_MASK_CMD | KEY_B); + ED_SHORTCUT("script_text_editor/fold_line", TTR("Fold Line"), KEY_MASK_ALT | KEY_LEFT); + ED_SHORTCUT("script_text_editor/unfold_line", TTR("Unfold Line"), KEY_MASK_ALT | KEY_RIGHT); + ED_SHORTCUT("script_text_editor/fold_all_lines", TTR("Fold All Lines"), 0); + ED_SHORTCUT("script_text_editor/unfold_all_lines", TTR("Unfold All Lines"), 0); #ifdef OSX_ENABLED ED_SHORTCUT("script_text_editor/complete_symbol", TTR("Complete Symbol"), KEY_MASK_CTRL | KEY_SPACE); #else diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 83f3ea57c0..722015ef3e 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -91,6 +91,10 @@ class ScriptTextEditor : public ScriptEditorBase { EDIT_TO_UPPERCASE, EDIT_TO_LOWERCASE, EDIT_CAPITALIZE, + EDIT_FOLD_LINE, + EDIT_UNFOLD_LINE, + EDIT_FOLD_ALL_LINES, + EDIT_UNFOLD_ALL_LINES, SEARCH_FIND, SEARCH_FIND_NEXT, SEARCH_FIND_PREV, @@ -118,7 +122,7 @@ protected: static void _bind_methods(); void _edit_option(int p_op); - void _make_context_menu(bool p_selection, bool p_color); + void _make_context_menu(bool p_selection, bool p_color, bool p_can_fold, bool p_is_folded); void _text_edit_gui_input(const Ref<InputEvent> &ev); void _color_changed(const Color &p_color); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index f7dcc4b52d..49e4642049 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -248,6 +248,8 @@ void ShaderTextEditor::_validate_script() { if (err != OK) { String error_text = "error(" + itos(sl.get_error_line()) + "): " + sl.get_error_text(); set_error(error_text); + for (int i = 0; i < get_text_edit()->get_line_count(); i++) + get_text_edit()->set_line_as_marked(i, false); get_text_edit()->set_line_as_marked(sl.get_error_line() - 1, true); } else { @@ -269,55 +271,284 @@ ShaderTextEditor::ShaderTextEditor() { void ShaderEditor::_menu_option(int p_option) { - ShaderTextEditor *current = shader_editor; - switch (p_option) { case EDIT_UNDO: { - - current->get_text_edit()->undo(); + shader_editor->get_text_edit()->undo(); } break; case EDIT_REDO: { - current->get_text_edit()->redo(); - + shader_editor->get_text_edit()->redo(); } break; case EDIT_CUT: { - - current->get_text_edit()->cut(); + shader_editor->get_text_edit()->cut(); } break; case EDIT_COPY: { - current->get_text_edit()->copy(); - + shader_editor->get_text_edit()->copy(); } break; case EDIT_PASTE: { - current->get_text_edit()->paste(); - + shader_editor->get_text_edit()->paste(); } break; case EDIT_SELECT_ALL: { + shader_editor->get_text_edit()->select_all(); + } break; + case EDIT_MOVE_LINE_UP: { + + TextEdit *tx = shader_editor->get_text_edit(); + if (shader.is_null()) + return; + + tx->begin_complex_operation(); + if (tx->is_selection_active()) { + int from_line = tx->get_selection_from_line(); + int from_col = tx->get_selection_from_column(); + int to_line = tx->get_selection_to_line(); + int to_column = tx->get_selection_to_column(); + + for (int i = from_line; i <= to_line; i++) { + int line_id = i; + int next_id = i - 1; + + if (line_id == 0 || next_id < 0) + return; + + tx->swap_lines(line_id, next_id); + tx->cursor_set_line(next_id); + } + int from_line_up = from_line > 0 ? from_line - 1 : from_line; + int to_line_up = to_line > 0 ? to_line - 1 : to_line; + tx->select(from_line_up, from_col, to_line_up, to_column); + } else { + int line_id = tx->cursor_get_line(); + int next_id = line_id - 1; + + if (line_id == 0 || next_id < 0) + return; + + tx->swap_lines(line_id, next_id); + tx->cursor_set_line(next_id); + } + tx->end_complex_operation(); + tx->update(); + + } break; + case EDIT_MOVE_LINE_DOWN: { + + TextEdit *tx = shader_editor->get_text_edit(); + if (shader.is_null()) + return; + + tx->begin_complex_operation(); + if (tx->is_selection_active()) { + int from_line = tx->get_selection_from_line(); + int from_col = tx->get_selection_from_column(); + int to_line = tx->get_selection_to_line(); + int to_column = tx->get_selection_to_column(); + + for (int i = to_line; i >= from_line; i--) { + int line_id = i; + int next_id = i + 1; + + if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count()) + return; + + tx->swap_lines(line_id, next_id); + tx->cursor_set_line(next_id); + } + int from_line_down = from_line < tx->get_line_count() ? from_line + 1 : from_line; + int to_line_down = to_line < tx->get_line_count() ? to_line + 1 : to_line; + tx->select(from_line_down, from_col, to_line_down, to_column); + } else { + int line_id = tx->cursor_get_line(); + int next_id = line_id + 1; + + if (line_id == tx->get_line_count() - 1 || next_id > tx->get_line_count()) + return; + + tx->swap_lines(line_id, next_id); + tx->cursor_set_line(next_id); + } + tx->end_complex_operation(); + tx->update(); + + } break; + case EDIT_INDENT_LEFT: { + + TextEdit *tx = shader_editor->get_text_edit(); + if (shader.is_null()) + return; + + tx->begin_complex_operation(); + if (tx->is_selection_active()) { + tx->indent_selection_left(); + } else { + int begin = tx->cursor_get_line(); + String line_text = tx->get_line(begin); + // begins with tab + if (line_text.begins_with("\t")) { + line_text = line_text.substr(1, line_text.length()); + tx->set_line(begin, line_text); + } + // begins with 4 spaces + else if (line_text.begins_with(" ")) { + line_text = line_text.substr(4, line_text.length()); + tx->set_line(begin, line_text); + } + } + tx->end_complex_operation(); + tx->update(); + //tx->deselect(); + + } break; + case EDIT_INDENT_RIGHT: { + + TextEdit *tx = shader_editor->get_text_edit(); + if (shader.is_null()) + return; + + tx->begin_complex_operation(); + if (tx->is_selection_active()) { + tx->indent_selection_right(); + } else { + int begin = tx->cursor_get_line(); + String line_text = tx->get_line(begin); + line_text = '\t' + line_text; + tx->set_line(begin, line_text); + } + tx->end_complex_operation(); + tx->update(); + //tx->deselect(); + + } break; + case EDIT_DELETE_LINE: { - current->get_text_edit()->select_all(); + TextEdit *tx = shader_editor->get_text_edit(); + if (shader.is_null()) + return; + + tx->begin_complex_operation(); + int line = tx->cursor_get_line(); + tx->set_line(tx->cursor_get_line(), ""); + tx->backspace_at_cursor(); + tx->cursor_set_line(line); + tx->end_complex_operation(); } break; + case EDIT_CLONE_DOWN: { + + TextEdit *tx = shader_editor->get_text_edit(); + if (shader.is_null()) + return; + + int from_line = tx->cursor_get_line(); + int to_line = tx->cursor_get_line(); + int column = tx->cursor_get_column(); + + if (tx->is_selection_active()) { + from_line = tx->get_selection_from_line(); + to_line = tx->get_selection_to_line(); + column = tx->cursor_get_column(); + } + int next_line = to_line + 1; + + tx->begin_complex_operation(); + for (int i = from_line; i <= to_line; i++) { + + if (i >= tx->get_line_count() - 1) { + tx->set_line(i, tx->get_line(i) + "\n"); + } + String line_clone = tx->get_line(i); + tx->insert_at(line_clone, next_line); + next_line++; + } + + tx->cursor_set_column(column); + if (tx->is_selection_active()) { + tx->select(to_line + 1, tx->get_selection_from_column(), next_line - 1, tx->get_selection_to_column()); + } + + tx->end_complex_operation(); + tx->update(); + + } break; + case EDIT_TOGGLE_COMMENT: { + + TextEdit *tx = shader_editor->get_text_edit(); + if (shader.is_null()) + return; + + tx->begin_complex_operation(); + if (tx->is_selection_active()) { + int begin = tx->get_selection_from_line(); + int end = tx->get_selection_to_line(); + + // End of selection ends on the first column of the last line, ignore it. + if (tx->get_selection_to_column() == 0) + end -= 1; + + // Check if all lines in the selected block are commented + bool is_commented = true; + for (int i = begin; i <= end; i++) { + if (!tx->get_line(i).begins_with("//")) { + is_commented = false; + break; + } + } + for (int i = begin; i <= end; i++) { + String line_text = tx->get_line(i); + + if (line_text.strip_edges().empty()) { + line_text = "//"; + } else { + if (is_commented) { + line_text = line_text.substr(2, line_text.length()); + } else { + line_text = "//" + line_text; + } + } + tx->set_line(i, line_text); + } + } else { + int begin = tx->cursor_get_line(); + String line_text = tx->get_line(begin); + + if (line_text.begins_with("//")) + line_text = line_text.substr(2, line_text.length()); + else + line_text = "//" + line_text; + tx->set_line(begin, line_text); + } + tx->end_complex_operation(); + tx->update(); + //tx->deselect(); + + } break; + case EDIT_COMPLETE: { + + shader_editor->get_text_edit()->query_code_comple(); + } break; case SEARCH_FIND: { - current->get_find_replace_bar()->popup_search(); + shader_editor->get_find_replace_bar()->popup_search(); } break; case SEARCH_FIND_NEXT: { - current->get_find_replace_bar()->search_next(); + shader_editor->get_find_replace_bar()->search_next(); } break; case SEARCH_FIND_PREV: { - current->get_find_replace_bar()->search_prev(); + shader_editor->get_find_replace_bar()->search_prev(); } break; case SEARCH_REPLACE: { - current->get_find_replace_bar()->popup_replace(); + shader_editor->get_find_replace_bar()->popup_replace(); } break; case SEARCH_GOTO_LINE: { - goto_line_dialog->popup_find_line(current->get_text_edit()); + goto_line_dialog->popup_find_line(shader_editor->get_text_edit()); } break; } + if (p_option != SEARCH_FIND && p_option != SEARCH_REPLACE && p_option != SEARCH_GOTO_LINE) { + shader_editor->get_text_edit()->call_deferred("grab_focus"); + } } void ShaderEditor::_notification(int p_what) { @@ -325,10 +556,6 @@ void ShaderEditor::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { } if (p_what == NOTIFICATION_DRAW) { - - RID ci = get_canvas_item(); - Ref<StyleBox> style = get_stylebox("panel", "Panel"); - style->draw(ci, Rect2(Point2(), get_size())); } } @@ -360,6 +587,7 @@ void ShaderEditor::_editor_settings_changed() { void ShaderEditor::_bind_methods() { ClassDB::bind_method("_editor_settings_changed", &ShaderEditor::_editor_settings_changed); + ClassDB::bind_method("_text_edit_gui_input", &ShaderEditor::_text_edit_gui_input); ClassDB::bind_method("_menu_option", &ShaderEditor::_menu_option); ClassDB::bind_method("_params_changed", &ShaderEditor::_params_changed); @@ -413,49 +641,122 @@ void ShaderEditor::apply_shaders() { } } -ShaderEditor::ShaderEditor() { +void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { - HBoxContainer *hbc = memnew(HBoxContainer); + Ref<InputEventMouseButton> mb = ev; - add_child(hbc); + if (mb.is_valid()) { + + if (mb->get_button_index() == BUTTON_RIGHT && !mb->is_pressed()) { + + int col, row; + TextEdit *tx = shader_editor->get_text_edit(); + tx->_get_mouse_pos(mb->get_global_position() - tx->get_global_position(), row, col); + Vector2 mpos = mb->get_global_position() - tx->get_global_position(); + bool have_selection = (tx->get_selection_text().length() > 0); + _make_context_menu(have_selection); + } + } +} + +void ShaderEditor::_make_context_menu(bool p_selection) { + + context_menu->clear(); + if (p_selection) { + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut"), EDIT_CUT); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/copy"), EDIT_COPY); + } + + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/paste"), EDIT_PASTE); + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/select_all"), EDIT_SELECT_ALL); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO); + + context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left"), EDIT_INDENT_LEFT); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT); + + context_menu->set_position(get_global_transform().xform(get_local_mouse_position())); + context_menu->set_size(Vector2(1, 1)); + context_menu->popup(); +} + +ShaderEditor::ShaderEditor(EditorNode *p_node) { + + shader_editor = memnew(ShaderTextEditor); + shader_editor->set_v_size_flags(SIZE_EXPAND_FILL); + shader_editor->add_constant_override("separation", 0); + shader_editor->set_anchors_and_margins_preset(Control::PRESET_WIDE); + + shader_editor->connect("script_changed", this, "apply_shaders"); + EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed"); + + shader_editor->get_text_edit()->set_callhint_settings( + EditorSettings::get_singleton()->get("text_editor/completion/put_callhint_tooltip_below_current_line"), + EditorSettings::get_singleton()->get("text_editor/completion/callhint_tooltip_offset")); + + shader_editor->get_text_edit()->set_select_identifiers_on_hover(true); + shader_editor->get_text_edit()->set_context_menu_enabled(false); + shader_editor->get_text_edit()->connect("gui_input", this, "_text_edit_gui_input"); + + shader_editor->update_editor_settings(); + + context_menu = memnew(PopupMenu); + add_child(context_menu); + context_menu->connect("id_pressed", this, "_menu_option"); + + VBoxContainer *main_container = memnew(VBoxContainer); + HBoxContainer *hbc = memnew(HBoxContainer); edit_menu = memnew(MenuButton); - hbc->add_child(edit_menu); - edit_menu->set_position(Point2(5, -1)); + //edit_menu->set_position(Point2(5, -1)); edit_menu->set_text(TTR("Edit")); - edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/undo", TTR("Undo"), KEY_MASK_CMD | KEY_Z), EDIT_UNDO); - edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/redo", TTR("Redo"), KEY_MASK_CMD | KEY_Y), EDIT_REDO); + + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/redo"), EDIT_REDO); + edit_menu->get_popup()->add_separator(); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/cut"), EDIT_CUT); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/copy"), EDIT_COPY); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/paste"), EDIT_PASTE); + edit_menu->get_popup()->add_separator(); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/select_all"), EDIT_SELECT_ALL); edit_menu->get_popup()->add_separator(); - edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/cut", TTR("Cut"), KEY_MASK_CMD | KEY_X), EDIT_CUT); - edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/copy", TTR("Copy"), KEY_MASK_CMD | KEY_C), EDIT_COPY); - edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/paste", TTR("Paste"), KEY_MASK_CMD | KEY_V), EDIT_PASTE); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_up"), EDIT_MOVE_LINE_UP); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/move_down"), EDIT_MOVE_LINE_DOWN); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left"), EDIT_INDENT_LEFT); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/delete_line"), EDIT_DELETE_LINE); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/clone_down"), EDIT_CLONE_DOWN); edit_menu->get_popup()->add_separator(); - edit_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/select_all", TTR("Select All"), KEY_MASK_CMD | KEY_A), EDIT_SELECT_ALL); + edit_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/complete_symbol"), EDIT_COMPLETE); + edit_menu->get_popup()->connect("id_pressed", this, "_menu_option"); search_menu = memnew(MenuButton); - hbc->add_child(search_menu); - search_menu->set_position(Point2(38, -1)); + //search_menu->set_position(Point2(38, -1)); search_menu->set_text(TTR("Search")); - search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find", TTR("Find.."), KEY_MASK_CMD | KEY_F), SEARCH_FIND); - search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_next", TTR("Find Next"), KEY_F3), SEARCH_FIND_NEXT); - search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/find_previous", TTR("Find Previous"), KEY_MASK_SHIFT | KEY_F3), SEARCH_FIND_PREV); - search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/replace", TTR("Replace.."), KEY_MASK_CMD | KEY_R), SEARCH_REPLACE); + + search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find"), SEARCH_FIND); + search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_next"), SEARCH_FIND_NEXT); + search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/find_previous"), SEARCH_FIND_PREV); + search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/replace"), SEARCH_REPLACE); search_menu->get_popup()->add_separator(); - //search_menu->get_popup()->add_item("Locate Symbol..",SEARCH_LOCATE_SYMBOL,KEY_MASK_CMD|KEY_K); - search_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/goto_line", TTR("Goto Line.."), KEY_MASK_CMD | KEY_L), SEARCH_GOTO_LINE); + search_menu->get_popup()->add_shortcut(ED_GET_SHORTCUT("script_text_editor/goto_line"), SEARCH_GOTO_LINE); search_menu->get_popup()->connect("id_pressed", this, "_menu_option"); + add_child(main_container); + main_container->add_child(hbc); + hbc->add_child(search_menu); + hbc->add_child(edit_menu); + hbc->add_style_override("panel", p_node->get_gui_base()->get_stylebox("ScriptEditorPanel", "EditorStyles")); + main_container->add_child(shader_editor); + goto_line_dialog = memnew(GotoLineDialog); add_child(goto_line_dialog); - shader_editor = memnew(ShaderTextEditor); - add_child(shader_editor); - shader_editor->set_v_size_flags(SIZE_EXPAND_FILL); - - shader_editor->connect("script_changed", this, "apply_shaders"); - EditorSettings::get_singleton()->connect("settings_changed", this, "_editor_settings_changed"); - _editor_settings_changed(); } @@ -504,7 +805,7 @@ void ShaderEditorPlugin::apply_changes() { ShaderEditorPlugin::ShaderEditorPlugin(EditorNode *p_node) { editor = p_node; - shader_editor = memnew(ShaderEditor); + shader_editor = memnew(ShaderEditor(p_node)); shader_editor->set_custom_minimum_size(Size2(0, 300)); button = editor->add_bottom_panel_item(TTR("Shader"), shader_editor); diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index ab18784d9f..b191f5700f 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -33,6 +33,7 @@ #include "editor/code_editor.h" #include "editor/editor_plugin.h" #include "scene/gui/menu_button.h" +#include "scene/gui/panel_container.h" #include "scene/gui/tab_container.h" #include "scene/gui/text_edit.h" #include "scene/main/timer.h" @@ -61,9 +62,9 @@ public: ShaderTextEditor(); }; -class ShaderEditor : public VBoxContainer { +class ShaderEditor : public PanelContainer { - GDCLASS(ShaderEditor, VBoxContainer); + GDCLASS(ShaderEditor, PanelContainer); enum { @@ -73,6 +74,14 @@ class ShaderEditor : public VBoxContainer { EDIT_COPY, EDIT_PASTE, EDIT_SELECT_ALL, + EDIT_MOVE_LINE_UP, + EDIT_MOVE_LINE_DOWN, + EDIT_INDENT_LEFT, + EDIT_INDENT_RIGHT, + EDIT_DELETE_LINE, + EDIT_CLONE_DOWN, + EDIT_TOGGLE_COMMENT, + EDIT_COMPLETE, SEARCH_FIND, SEARCH_FIND_NEXT, SEARCH_FIND_PREV, @@ -84,6 +93,7 @@ class ShaderEditor : public VBoxContainer { MenuButton *edit_menu; MenuButton *search_menu; MenuButton *settings_menu; + PopupMenu *context_menu; uint64_t idle; GotoLineDialog *goto_line_dialog; @@ -100,6 +110,8 @@ class ShaderEditor : public VBoxContainer { protected: void _notification(int p_what); static void _bind_methods(); + void _make_context_menu(bool p_selection); + void _text_edit_gui_input(const Ref<InputEvent> &ev); public: void apply_shaders(); @@ -110,7 +122,7 @@ public: virtual Size2 get_minimum_size() const { return Size2(0, 200); } void save_external_data(); - ShaderEditor(); + ShaderEditor(EditorNode *p_node); }; class ShaderEditorPlugin : public EditorPlugin { diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 25ca2d731e..b3d3d5e13a 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -758,17 +758,49 @@ bool SpatialEditorViewport::_gizmo_select(const Vector2 &p_screenpos, bool p_hig } } + bool is_plane_scale = false; + // plane select + if (col_axis == -1) { + col_d = 1e20; + + for (int i = 0; i < 3; i++) { + + Vector3 ivec2 = gt.basis.get_axis((i + 1) % 3).normalized(); + Vector3 ivec3 = gt.basis.get_axis((i + 2) % 3).normalized(); + + Vector3 grabber_pos = gt.origin + (ivec2 + ivec3) * gs * (GIZMO_PLANE_SIZE + GIZMO_PLANE_DST); + + Vector3 r; + Plane plane(gt.origin, gt.basis.get_axis(i).normalized()); + + if (plane.intersects_ray(ray_pos, ray, &r)) { + + float dist = r.distance_to(grabber_pos); + if (dist < (gs * GIZMO_PLANE_SIZE)) { + + float d = ray_pos.distance_to(r); + if (d < col_d) { + col_d = d; + col_axis = i; + + is_plane_scale = true; + } + } + } + } + } + if (col_axis != -1) { if (p_highlight_only) { - spatial_editor->select_gizmo_highlight_axis(col_axis + 9); + spatial_editor->select_gizmo_highlight_axis(col_axis + (is_plane_scale ? 12 : 9)); } else { //handle scale _edit.mode = TRANSFORM_SCALE; _compute_edit(Point2(p_screenpos.x, p_screenpos.y)); - _edit.plane = TransformPlane(TRANSFORM_X_AXIS + col_axis); + _edit.plane = TransformPlane(TRANSFORM_X_AXIS + col_axis + (is_plane_scale ? 3 : 0)); } return true; } @@ -1255,7 +1287,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Vector3 motion_mask; Plane plane; - bool plane_mv; + bool plane_mv = false; switch (_edit.plane) { case TRANSFORM_VIEW: @@ -1274,6 +1306,21 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2); plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); break; + case TRANSFORM_YZ: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(1); + plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(0)); + plane_mv = true; + break; + case TRANSFORM_XZ: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(0); + plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(1)); + plane_mv = true; + break; + case TRANSFORM_XY: + motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0) + spatial_editor->get_gizmo_transform().basis.get_axis(1); + plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(2)); + plane_mv = true; + break; } Vector3 intersection; @@ -1285,12 +1332,21 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { break; Vector3 motion = intersection - click; - print_line(String(intersection) + " --- " + String(click)); - if (motion_mask != Vector3()) { + if (_edit.plane != TRANSFORM_VIEW) { - motion = motion_mask.dot(motion) * motion_mask; - } else { + if (!plane_mv) { + + motion = motion_mask.dot(motion) * motion_mask; + + } else { + // Alternative planar scaling mode + if (_get_key_modifier(m) != KEY_SHIFT) { + motion = motion_mask.dot(motion) * motion_mask; + } + } + + } else { float center_click_dist = click.distance_to(_edit.center); float center_inters_dist = intersection.distance_to(_edit.center); if (center_click_dist == 0) @@ -1302,12 +1358,19 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - bool local_coords = (spatial_editor->are_local_coords_enabled() && motion_mask != Vector3()); // Disable local transformation for TRANSFORM_VIEW + bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW float snap = 0; if (_edit.snap || spatial_editor->is_snap_enabled()) { snap = spatial_editor->get_scale_snap() / 100; + + Vector3 motion_snapped = motion; + motion_snapped.snap(Vector3(snap, snap, snap)); + set_message(TTR("Scaling: ") + motion_snapped); + + } else { + set_message(TTR("Scaling: ") + motion); } for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -1339,6 +1402,15 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { local_scale = original_local.basis.get_scale() * (local_motion + Vector3(1, 1, 1)); + // Prevent scaling to 0 it would break the gizmo + Basis check = original_local.basis; + check.scale(local_scale); + if (check.determinant() != 0) { + + // Apply scale + sp->set_scale(local_scale); + } + } else { if (_edit.snap || spatial_editor->is_snap_enabled()) { @@ -1348,12 +1420,8 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Transform r; r.basis.scale(motion + Vector3(1, 1, 1)); t = base * (r * (base.inverse() * original)); - } - // Apply scale - if (local_coords) { - sp->set_scale(local_scale); - } else { + // Apply scale sp->set_global_transform(t); } } @@ -1366,11 +1434,10 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Vector3 motion_mask; Plane plane; - bool plane_mv; + bool plane_mv = false; switch (_edit.plane) { case TRANSFORM_VIEW: - motion_mask = Vector3(0, 0, 0); plane = Plane(_edit.center, _get_camera_normal()); break; case TRANSFORM_X_AXIS: @@ -1386,17 +1453,14 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { plane = Plane(_edit.center, motion_mask.cross(motion_mask.cross(_get_camera_normal())).normalized()); break; case TRANSFORM_YZ: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(1); plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(0)); plane_mv = true; break; case TRANSFORM_XZ: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(2) + spatial_editor->get_gizmo_transform().basis.get_axis(0); plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(1)); plane_mv = true; break; case TRANSFORM_XY: - motion_mask = spatial_editor->get_gizmo_transform().basis.get_axis(0) + spatial_editor->get_gizmo_transform().basis.get_axis(1); plane = Plane(_edit.center, spatial_editor->get_gizmo_transform().basis.get_axis(2)); plane_mv = true; break; @@ -1410,55 +1474,27 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (!plane.intersects_ray(_edit.click_ray_pos, _edit.click_ray, &click)) break; - //_validate_selection(); Vector3 motion = intersection - click; - if (motion_mask != Vector3()) { - if (plane_mv) - motion *= motion_mask; - else + if (_edit.plane != TRANSFORM_VIEW) { + if (!plane_mv) { motion = motion_mask.dot(motion) * motion_mask; + } } - //set_message("Translating: "+motion); - List<Node *> &selection = editor_selection->get_selected_node_list(); - float snap = 0; + bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW + float snap = 0; if (_edit.snap || spatial_editor->is_snap_enabled()) { snap = spatial_editor->get_translate_snap(); - bool local_coords = spatial_editor->are_local_coords_enabled(); - - if (local_coords) { - bool multiple = false; - Spatial *node = NULL; - for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { - - Spatial *sp = Object::cast_to<Spatial>(E->get()); - if (!sp) { - continue; - } - if (node) { - multiple = true; - break; - } else { - node = sp; - } - } - if (multiple) { - motion.snap(Vector3(snap, snap, snap)); - } else { - Basis b = node->get_global_transform().basis.orthonormalized(); - Vector3 local_motion = b.inverse().xform(motion); - local_motion.snap(Vector3(snap, snap, snap)); - motion = b.xform(local_motion); - } - - } else { - motion.snap(Vector3(snap, snap, snap)); - } + Vector3 motion_snapped = motion; + motion_snapped.snap(Vector3(snap, snap, snap)); + set_message(TTR("Translating: ") + motion_snapped); + } else { + set_message(TTR("Translating: ") + motion); } for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -1473,10 +1509,34 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { continue; } - Transform t = se->original; + Transform original = se->original; + Transform t; + + if (local_coords) { + + if (_edit.snap || spatial_editor->is_snap_enabled()) { + Basis g = original.basis.orthonormalized(); + Vector3 local_motion = g.inverse().xform(motion); + local_motion.snap(Vector3(snap, snap, snap)); + + motion = g.xform(local_motion); + } + + } else { + + if (_edit.snap || spatial_editor->is_snap_enabled()) { + motion.snap(Vector3(snap, snap, snap)); + } + } + + // Apply translation + t = original; t.origin += motion; sp->set_global_transform(t); } + + surface->update(); + } break; case TRANSFORM_ROTATE: { @@ -1533,7 +1593,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { List<Node *> &selection = editor_selection->get_selected_node_list(); - bool local_coords = spatial_editor->are_local_coords_enabled(); + bool local_coords = (spatial_editor->are_local_coords_enabled() && _edit.plane != TRANSFORM_VIEW); // Disable local transformation for TRANSFORM_VIEW for (List<Node *>::Element *E = selection.front(); E; E = E->next()) { @@ -1552,10 +1612,12 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { Transform original_local = se->original_local; Basis rot = Basis(axis, angle); - t.basis = original_local.get_basis() * rot; + t.basis = original_local.get_basis().orthonormalized() * rot; t.origin = original_local.origin; + // Apply rotation sp->set_transform(t); + sp->set_scale(original_local.basis.get_scale()); // re-apply original scale } else { @@ -1566,6 +1628,7 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { r.basis.rotate(plane.normal, angle); t = base * r * base.inverse() * original; + // Apply rotation sp->set_global_transform(t); } } @@ -1803,6 +1866,11 @@ void SpatialEditorViewport::_sinput(const Ref<InputEvent> &p_event) { if (!k->is_pressed()) emit_signal("toggle_maximize_view", this); } } + + // freelook uses most of the useful shortcuts, like save, so its ok + // to consider freelook active as end of the line for future events. + if (freelook_active) + accept_event(); } void SpatialEditorViewport::set_freelook_active(bool active_now) { @@ -2001,7 +2069,7 @@ void SpatialEditorViewport::_notification(int p_what) { if (se->aabb.has_no_surface()) { - se->aabb = vi ? vi->get_aabb() : Rect3(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4)); + se->aabb = vi ? vi->get_aabb() : AABB(Vector3(-0.2, -0.2, -0.2), Vector3(0.4, 0.4, 0.4)); } Transform t = sp->get_global_transform(); @@ -2089,6 +2157,29 @@ void SpatialEditorViewport::_notification(int p_what) { } } + // FPS Counter. + bool show_fps = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_FPS)); + if (show_fps != fps->is_visible()) { + if (show_fps) + fps->show(); + else + fps->hide(); + } + + if (show_fps) { + String text; + const float temp_fps = Engine::get_singleton()->get_frames_per_second(); + text += TTR("FPS") + ": " + itos(temp_fps) + " (" + String::num(1000.0f / temp_fps, 2) + " ms)"; + + if (fps_label->get_text() != text || surface->get_size() != prev_size) { + fps_label->set_text(text); + Size2 ms = fps->get_size(); + Size2 size = surface->get_size(); + size.y = ms.y + 20; + fps->set_position(size - ms - Vector2(20, 0) * EDSCALE); + } + } + prev_size = surface->get_size(); } @@ -2099,6 +2190,7 @@ void SpatialEditorViewport::_notification(int p_what) { surface->connect("mouse_entered", this, "_smouseenter"); surface->connect("mouse_exited", this, "_smouseexit"); info->add_style_override("panel", get_stylebox("panel", "Panel")); + fps->add_style_override("panel", get_stylebox("panel", "Panel")); preview_camera->set_icon(get_icon("Camera", "EditorIcons")); _init_gizmo_instance(index); } @@ -2421,6 +2513,13 @@ void SpatialEditorViewport::_menu_option(int p_option) { view_menu->get_popup()->set_item_checked(idx, !current); } break; + case VIEW_FPS: { + + int idx = view_menu->get_popup()->get_item_index(VIEW_FPS); + bool current = view_menu->get_popup()->is_item_checked(idx); + view_menu->get_popup()->set_item_checked(idx, !current); + + } break; case VIEW_DISPLAY_NORMAL: { viewport->set_debug_draw(Viewport::DEBUG_DRAW_DISABLED); @@ -2506,6 +2605,14 @@ void SpatialEditorViewport::_init_gizmo_instance(int p_idx) { //VS::get_singleton()->instance_geometry_set_flag(scale_gizmo_instance[i],VS::INSTANCE_FLAG_DEPH_SCALE,true); VS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); VS::get_singleton()->instance_set_layer_mask(scale_gizmo_instance[i], layer); + + scale_plane_gizmo_instance[i] = VS::get_singleton()->instance_create(); + VS::get_singleton()->instance_set_base(scale_plane_gizmo_instance[i], spatial_editor->get_scale_plane_gizmo(i)->get_rid()); + VS::get_singleton()->instance_set_scenario(scale_plane_gizmo_instance[i], get_tree()->get_root()->get_world()->get_scenario()); + VS::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], false); + //VS::get_singleton()->instance_geometry_set_flag(scale_plane_gizmo_instance[i],VS::INSTANCE_FLAG_DEPH_SCALE,true); + VS::get_singleton()->instance_geometry_set_cast_shadows_setting(scale_plane_gizmo_instance[i], VS::SHADOW_CASTING_SETTING_OFF); + VS::get_singleton()->instance_set_layer_mask(scale_plane_gizmo_instance[i], layer); } } @@ -2516,6 +2623,7 @@ void SpatialEditorViewport::_finish_gizmo_instances() { VS::get_singleton()->free(move_plane_gizmo_instance[i]); VS::get_singleton()->free(rotate_gizmo_instance[i]); VS::get_singleton()->free(scale_gizmo_instance[i]); + VS::get_singleton()->free(scale_plane_gizmo_instance[i]); } } void SpatialEditorViewport::_toggle_camera_preview(bool p_activate) { @@ -2612,6 +2720,8 @@ void SpatialEditorViewport::update_transform_gizmo_view() { VisualServer::get_singleton()->instance_set_visible(rotate_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SELECT || spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_ROTATE)); VisualServer::get_singleton()->instance_set_transform(scale_gizmo_instance[i], xform); VisualServer::get_singleton()->instance_set_visible(scale_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE)); + VisualServer::get_singleton()->instance_set_transform(scale_plane_gizmo_instance[i], xform); + VisualServer::get_singleton()->instance_set_visible(scale_plane_gizmo_instance[i], spatial_editor->is_gizmo_visible() && (spatial_editor->get_tool_mode() == SpatialEditor::TOOL_MODE_SCALE)); } } @@ -2746,7 +2856,7 @@ void SpatialEditorViewport::focus_selection() { cursor.pos = center; } -void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, Rect3 *p_preview_bounds, AcceptDialog *p_accept) { +void SpatialEditorViewport::assign_pending_data_pointers(Spatial *p_preview_node, AABB *p_preview_bounds, AcceptDialog *p_accept) { preview_node = p_preview_node; preview_bounds = p_preview_bounds; accept = p_accept; @@ -2809,14 +2919,14 @@ Vector3 SpatialEditorViewport::_get_instance_position(const Point2 &p_pos) const return point + offset; } -Rect3 SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds) { - Rect3 bounds = p_bounds; +AABB SpatialEditorViewport::_calculate_spatial_bounds(const Spatial *p_parent, const AABB p_bounds) { + AABB bounds = p_bounds; for (int i = 0; i < p_parent->get_child_count(); i++) { Spatial *child = Object::cast_to<Spatial>(p_parent->get_child(i)); if (child) { MeshInstance *mesh_instance = Object::cast_to<MeshInstance>(child); if (mesh_instance) { - Rect3 mesh_instance_bounds = mesh_instance->get_aabb(); + AABB mesh_instance_bounds = mesh_instance->get_aabb(); mesh_instance_bounds.position += mesh_instance->get_global_transform().origin - p_parent->get_global_transform().origin; bounds.merge_with(mesh_instance_bounds); } @@ -2848,7 +2958,7 @@ void SpatialEditorViewport::_create_preview(const Vector<String> &files) const { editor->get_scene_root()->add_child(preview_node); } } - *preview_bounds = _calculate_spatial_bounds(preview_node, Rect3()); + *preview_bounds = _calculate_spatial_bounds(preview_node, AABB()); } void SpatialEditorViewport::_remove_preview() { @@ -2911,7 +3021,9 @@ bool SpatialEditorViewport::_create_instance(Node *parent, String &path, const P } } - instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path)); + if (scene != NULL) { + instanced_scene->set_filename(ProjectSettings::get_singleton()->localize_path(path)); + } editor_data->get_undo_redo().add_do_method(parent, "add_child", instanced_scene); editor_data->get_undo_redo().add_do_method(instanced_scene, "set_owner", editor->get_edited_scene()); @@ -3137,6 +3249,7 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_environment", TTR("View Environment")), VIEW_ENVIRONMENT); view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_gizmos", TTR("View Gizmos")), VIEW_GIZMOS); view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_information", TTR("View Information")), VIEW_INFORMATION); + view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_fps", TTR("View FPS")), VIEW_FPS); view_menu->get_popup()->set_item_checked(view_menu->get_popup()->get_item_index(VIEW_ENVIRONMENT), true); view_menu->get_popup()->add_separator(); view_menu->get_popup()->add_check_shortcut(ED_SHORTCUT("spatial_editor/view_half_resolution", TTR("Half Resolution")), VIEW_HALF_RESOLUTION); @@ -3179,6 +3292,14 @@ SpatialEditorViewport::SpatialEditorViewport(SpatialEditor *p_spatial_editor, Ed info->add_child(info_label); info->hide(); + // FPS Counter. + fps = memnew(PanelContainer); + fps->set_self_modulate(Color(1, 1, 1, 0.4)); + surface->add_child(fps); + fps_label = memnew(Label); + fps->add_child(fps_label); + fps->hide(); + accept = NULL; freelook_active = false; @@ -3516,13 +3637,14 @@ void SpatialEditor::select_gizmo_highlight_axis(int p_axis) { move_plane_gizmo[i]->surface_set_material(0, (i + 6) == p_axis ? gizmo_hl : plane_gizmo_color[i]); rotate_gizmo[i]->surface_set_material(0, (i + 3) == p_axis ? gizmo_hl : gizmo_color[i]); scale_gizmo[i]->surface_set_material(0, (i + 9) == p_axis ? gizmo_hl : gizmo_color[i]); + scale_plane_gizmo[i]->surface_set_material(0, (i + 12) == p_axis ? gizmo_hl : plane_gizmo_color[i]); } } void SpatialEditor::update_transform_gizmo() { List<Node *> &selection = editor_selection->get_selected_node_list(); - Rect3 center; + AABB center; bool first = true; Basis gizmo_basis; @@ -3583,7 +3705,7 @@ Object *SpatialEditor::_get_editor_data(Object *p_what) { void SpatialEditor::_generate_selection_box() { - Rect3 aabb(Vector3(), Vector3(1, 1, 1)); + AABB aabb(Vector3(), Vector3(1, 1, 1)); aabb.grow_by(aabb.get_longest_axis_size() / 20.0); Ref<SurfaceTool> st = memnew(SurfaceTool); @@ -4089,6 +4211,7 @@ void SpatialEditor::_init_indicators() { move_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); rotate_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); scale_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); + scale_plane_gizmo[i] = Ref<ArrayMesh>(memnew(ArrayMesh)); Ref<SpatialMaterial> mat = memnew(SpatialMaterial); mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); @@ -4284,6 +4407,49 @@ void SpatialEditor::_init_indicators() { surftool->set_material(mat); surftool->commit(scale_gizmo[i]); } + + // Plane Scale + { + Ref<SurfaceTool> surftool = memnew(SurfaceTool); + surftool->begin(Mesh::PRIMITIVE_TRIANGLES); + + Vector3 vec = ivec2 - ivec3; + Vector3 plane[4] = { + vec * GIZMO_PLANE_DST, + vec * GIZMO_PLANE_DST + ivec2 * GIZMO_PLANE_SIZE, + vec * (GIZMO_PLANE_DST + GIZMO_PLANE_SIZE), + vec * GIZMO_PLANE_DST - ivec3 * GIZMO_PLANE_SIZE + }; + + Basis ma(ivec, Math_PI / 2); + + Vector3 points[4] = { + ma.xform(plane[0]), + ma.xform(plane[1]), + ma.xform(plane[2]), + ma.xform(plane[3]), + }; + surftool->add_vertex(points[0]); + surftool->add_vertex(points[1]); + surftool->add_vertex(points[2]); + + surftool->add_vertex(points[0]); + surftool->add_vertex(points[2]); + surftool->add_vertex(points[3]); + + Ref<SpatialMaterial> plane_mat = memnew(SpatialMaterial); + plane_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); + plane_mat->set_on_top_of_alpha(); + plane_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + plane_mat->set_cull_mode(SpatialMaterial::CULL_DISABLED); + Color col; + col[i] = 1.0; + col.a = gizmo_alph; + plane_mat->set_albedo(col); + plane_gizmo_color[i] = plane_mat; // needed, so we can draw planes from both sides + surftool->set_material(plane_mat); + surftool->commit(scale_plane_gizmo[i]); + } } } @@ -4610,7 +4776,7 @@ SpatialEditor::SpatialEditor(EditorNode *p_editor) { // Drag and drop support; preview_node = memnew(Spatial); - preview_bounds = Rect3(); + preview_bounds = AABB(); ED_SHORTCUT("spatial_editor/bottom_view", TTR("Bottom View"), KEY_MASK_ALT + KEY_KP_7); ED_SHORTCUT("spatial_editor/top_view", TTR("Top View"), KEY_KP_7); diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index c2b698068f..c986e45f43 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -88,6 +88,7 @@ class SpatialEditorViewport : public Control { VIEW_AUDIO_DOPPLER, VIEW_GIZMOS, VIEW_INFORMATION, + VIEW_FPS, VIEW_DISPLAY_NORMAL, VIEW_DISPLAY_WIREFRAME, VIEW_DISPLAY_OVERDRAW, @@ -108,7 +109,7 @@ private: Size2 prev_size; Spatial *preview_node; - Rect3 *preview_bounds; + AABB *preview_bounds; Vector<String> selected_files; AcceptDialog *accept; @@ -138,6 +139,9 @@ private: PanelContainer *info; Label *info_label; + PanelContainer *fps; + Label *fps_label; + struct _RayResult { Spatial *item; @@ -255,7 +259,7 @@ private: real_t zoom_indicator_delay; - RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[3], scale_gizmo_instance[3]; + RID move_gizmo_instance[3], move_plane_gizmo_instance[3], rotate_gizmo_instance[3], scale_gizmo_instance[3], scale_plane_gizmo_instance[3]; String last_message; String message; @@ -287,7 +291,7 @@ private: Point2i _get_warped_mouse_motion(const Ref<InputEventMouseMotion> &p_ev_mouse_motion) const; Vector3 _get_instance_position(const Point2 &p_pos) const; - static Rect3 _calculate_spatial_bounds(const Spatial *p_parent, const Rect3 p_bounds); + static AABB _calculate_spatial_bounds(const Spatial *p_parent, const AABB p_bounds); void _create_preview(const Vector<String> &files) const; void _remove_preview(); bool _cyclical_dependency_exists(const String &p_target_scene_path, Node *p_desired_node); @@ -314,7 +318,7 @@ public: void assign_pending_data_pointers( Spatial *p_preview_node, - Rect3 *p_preview_bounds, + AABB *p_preview_bounds, AcceptDialog *p_accept); Viewport *get_viewport_node() { return viewport; } @@ -327,7 +331,7 @@ class SpatialEditorSelectedItem : public Object { GDCLASS(SpatialEditorSelectedItem, Object); public: - Rect3 aabb; + AABB aabb; Transform original; // original location when moving Transform original_local; Transform last_xform; // last transform @@ -418,7 +422,7 @@ private: bool grid_enable[3]; //should be always visible if true bool grid_enabled; - Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[3], scale_gizmo[3]; + Ref<ArrayMesh> move_gizmo[3], move_plane_gizmo[3], rotate_gizmo[3], scale_gizmo[3], scale_plane_gizmo[3]; Ref<SpatialMaterial> gizmo_color[3]; Ref<SpatialMaterial> plane_gizmo_color[3]; Ref<SpatialMaterial> gizmo_hl; @@ -435,7 +439,7 @@ private: // Scene drag and drop support Spatial *preview_node; - Rect3 preview_bounds; + AABB preview_bounds; /* struct Selected { @@ -571,6 +575,7 @@ public: Ref<ArrayMesh> get_move_plane_gizmo(int idx) const { return move_plane_gizmo[idx]; } Ref<ArrayMesh> get_rotate_gizmo(int idx) const { return rotate_gizmo[idx]; } Ref<ArrayMesh> get_scale_gizmo(int idx) const { return scale_gizmo[idx]; } + Ref<ArrayMesh> get_scale_plane_gizmo(int idx) const { return scale_plane_gizmo[idx]; } void update_transform_gizmo(); diff --git a/editor/plugins/texture_region_editor_plugin.cpp b/editor/plugins/texture_region_editor_plugin.cpp index 8870166dba..48aed0cf6c 100644 --- a/editor/plugins/texture_region_editor_plugin.cpp +++ b/editor/plugins/texture_region_editor_plugin.cpp @@ -860,6 +860,7 @@ TextureRegionEditor::TextureRegionEditor(EditorNode *p_editor) { hb_tools->add_child(separator); icon_zoom = memnew(TextureRect); + icon_zoom->set_stretch_mode(TextureRect::STRETCH_KEEP_ASPECT_CENTERED); hb_tools->add_child(icon_zoom); zoom_out = memnew(ToolButton); diff --git a/editor/plugins/theme_editor_plugin.cpp b/editor/plugins/theme_editor_plugin.cpp index 02ead3aee8..7f956b01ff 100644 --- a/editor/plugins/theme_editor_plugin.cpp +++ b/editor/plugins/theme_editor_plugin.cpp @@ -427,7 +427,9 @@ void ThemeEditor::_dialog_cbk() { void ThemeEditor::_theme_menu_cbk(int p_option) { - if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY) { + if (p_option == POPUP_CREATE_EMPTY || p_option == POPUP_CREATE_EDITOR_EMPTY || p_option == POPUP_IMPORT_EDITOR_THEME) { + + bool import = (p_option == POPUP_IMPORT_EDITOR_THEME); Ref<Theme> base_theme; @@ -449,21 +451,21 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { base_theme->get_icon_list(type, &icons); for (List<StringName>::Element *E = icons.front(); E; E = E->next()) { - theme->set_icon(E->get(), type, Ref<Texture>()); + theme->set_icon(E->get(), type, import ? base_theme->get_icon(E->get(), type) : Ref<Texture>()); } List<StringName> shaders; base_theme->get_shader_list(type, &shaders); for (List<StringName>::Element *E = shaders.front(); E; E = E->next()) { - theme->set_shader(E->get(), type, Ref<Shader>()); + theme->set_shader(E->get(), type, import ? base_theme->get_shader(E->get(), type) : Ref<Shader>()); } List<StringName> styleboxs; base_theme->get_stylebox_list(type, &styleboxs); for (List<StringName>::Element *E = styleboxs.front(); E; E = E->next()) { - theme->set_stylebox(E->get(), type, Ref<StyleBox>()); + theme->set_stylebox(E->get(), type, import ? base_theme->get_stylebox(E->get(), type) : Ref<StyleBox>()); } List<StringName> fonts; @@ -477,14 +479,14 @@ void ThemeEditor::_theme_menu_cbk(int p_option) { base_theme->get_color_list(type, &colors); for (List<StringName>::Element *E = colors.front(); E; E = E->next()) { - theme->set_color(E->get(), type, Color()); + theme->set_color(E->get(), type, import ? base_theme->get_color(E->get(), type) : Color()); } List<StringName> constants; base_theme->get_constant_list(type, &constants); for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { - theme->set_constant(E->get(), type, base_theme->get_constant(type, E->get())); + theme->set_constant(E->get(), type, base_theme->get_constant(E->get(), type)); } } } @@ -639,7 +641,7 @@ ThemeEditor::ThemeEditor() { theme_menu->get_popup()->add_separator(); theme_menu->get_popup()->add_item(TTR("Create Empty Template"), POPUP_CREATE_EMPTY); theme_menu->get_popup()->add_item(TTR("Create Empty Editor Template"), POPUP_CREATE_EDITOR_EMPTY); - + theme_menu->get_popup()->add_item(TTR("Create From Current Editor Theme"), POPUP_IMPORT_EDITOR_THEME); add_child(theme_menu); theme_menu->set_position(Vector2(3, 3) * EDSCALE); theme_menu->get_popup()->connect("id_pressed", this, "_theme_menu_cbk"); diff --git a/editor/plugins/theme_editor_plugin.h b/editor/plugins/theme_editor_plugin.h index 16b2da94d1..4d46282ba1 100644 --- a/editor/plugins/theme_editor_plugin.h +++ b/editor/plugins/theme_editor_plugin.h @@ -69,7 +69,8 @@ class ThemeEditor : public Control { POPUP_REMOVE, POPUP_CLASS_REMOVE, POPUP_CREATE_EMPTY, - POPUP_CREATE_EDITOR_EMPTY + POPUP_CREATE_EDITOR_EMPTY, + POPUP_IMPORT_EDITOR_THEME }; int popup_mode; diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 9235dafaa6..ffddd8a3a9 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -363,7 +363,7 @@ PoolVector<Vector2> TileMapEditor::_bucket_fill(const Point2i &p_start, bool era return PoolVector<Vector2>(); } - Rect2i r = node->get_item_rect(); + Rect2i r = node->_edit_get_rect(); r.position = r.position / node->get_cell_size(); r.size = r.size / node->get_cell_size(); @@ -973,7 +973,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Point2i pos = points[i]; - if (!paint_undo.has(over_tile)) { + if (!paint_undo.has(pos)) { paint_undo[pos] = _get_op_from_cell(pos); } @@ -993,7 +993,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { Point2i pos = points[i]; - if (!paint_undo.has(over_tile)) { + if (!paint_undo.has(pos)) { paint_undo[pos] = _get_op_from_cell(pos); } diff --git a/editor/project_export.cpp b/editor/project_export.cpp index eac5720b43..dda2851166 100644 --- a/editor/project_export.cpp +++ b/editor/project_export.cpp @@ -308,7 +308,7 @@ void ProjectExportDialog::_patch_button_pressed(Object *p_item, int p_column, in if (p_id == 0) { Vector<String> patches = current->get_patches(); ERR_FAIL_INDEX(patch_index, patches.size()); - patch_erase->set_text(vformat(TTR("Delete patch '" + patches[patch_index].get_file() + "' from list?"))); + patch_erase->set_text(vformat(TTR("Delete patch '%s' from list?"), patches[patch_index].get_file())); patch_erase->popup_centered_minsize(); } else { patch_dialog->popup_centered_ratio(); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 18416868ec..16b85121ef 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -233,7 +233,7 @@ private: fdialog->set_mode(FileDialog::MODE_OPEN_FILE); fdialog->clear_filters(); - fdialog->add_filter("project.godot ; " _MKSTR(VERSION_NAME) " Project"); + fdialog->add_filter("project.godot ; " VERSION_NAME " Project"); } else { fdialog->set_mode(FileDialog::MODE_OPEN_DIR); } @@ -284,7 +284,6 @@ private: } ProjectSettings *current = memnew(ProjectSettings); - current->add_singleton(ProjectSettings::Singleton("Current")); if (current->setup(dir, "")) { set_message(TTR("Couldn't get project.godot in project path."), MESSAGE_ERROR); @@ -503,7 +502,6 @@ public: name_container->show(); ProjectSettings *current = memnew(ProjectSettings); - current->add_singleton(ProjectSettings::Singleton("Current")); if (current->setup(project_path->get_text(), "")) { set_message(TTR("Couldn't get project.godot in the project path."), MESSAGE_ERROR); @@ -1053,7 +1051,7 @@ void ProjectManager::_load_recent_projects() { ec->set_custom_minimum_size(Size2(0, 1)); vb->add_child(ec); Label *title = memnew(Label(project_name)); - title->add_font_override("font", gui_base->get_font("large", "Fonts")); + title->add_font_override("font", gui_base->get_font("title", "EditorFonts")); title->add_color_override("font_color", font_color); title->set_clip_text(true); vb->add_child(title); @@ -1485,14 +1483,13 @@ ProjectManager::ProjectManager() { String cp; cp.push_back(0xA9); cp.push_back(0); - OS::get_singleton()->set_window_title(_MKSTR(VERSION_NAME) + String(" - ") + TTR("Project Manager") + " - " + cp + " 2008-2017 Juan Linietsky, Ariel Manzur & Godot Contributors"); + OS::get_singleton()->set_window_title(VERSION_NAME + String(" - ") + TTR("Project Manager") + " - " + cp + " 2008-2017 Juan Linietsky, Ariel Manzur & Godot Contributors"); HBoxContainer *top_hb = memnew(HBoxContainer); vb->add_child(top_hb); CenterContainer *ccl = memnew(CenterContainer); Label *l = memnew(Label); - l->set_text(_MKSTR(VERSION_NAME) + String(" - ") + TTR("Project Manager")); - l->add_font_override("font", gui_base->get_font("doc", "EditorFonts")); + l->set_text(VERSION_NAME + String(" - ") + TTR("Project Manager")); ccl->add_child(l); top_hb->add_child(ccl); top_hb->add_spacer(); @@ -1501,11 +1498,8 @@ ProjectManager::ProjectManager() { if (hash.length() != 0) hash = "." + hash.left(7); l->set_text("v" VERSION_MKSTRING "" + hash); - //l->add_font_override("font",get_font("bold","Fonts")); l->set_align(Label::ALIGN_CENTER); top_hb->add_child(l); - //vb->add_child(memnew(HSeparator)); - //vb->add_margin_child("\n",memnew(Control)); Control *center_box = memnew(Control); center_box->set_v_size_flags(SIZE_EXPAND_FILL); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index b21c176543..b07280a4cd 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -785,12 +785,12 @@ void ProjectSettingsEditor::_item_del() { String property = globals_editor->get_current_section().plus_file(path); if (!ProjectSettings::get_singleton()->has_setting(property)) { - EditorNode::get_singleton()->show_warning(TTR("No property '" + property + "' exists.")); + EditorNode::get_singleton()->show_warning(vformat(TTR("No property '%s' exists."), property)); return; } if (ProjectSettings::get_singleton()->get_order(property) < ProjectSettings::NO_BUILTIN_ORDER_BASE) { - EditorNode::get_singleton()->show_warning(TTR("Setting '" + property + "' is internal, and it can't be deleted.")); + EditorNode::get_singleton()->show_warning(vformat(TTR("Setting '%s' is internal, and it can't be deleted."), property)); return; } @@ -1318,7 +1318,7 @@ void ProjectSettingsEditor::_update_translations() { t->set_text(0, translations[i].replace_first("res://", "")); t->set_tooltip(0, translations[i]); t->set_metadata(0, i); - t->add_button(0, get_icon("Del", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); } } @@ -1436,7 +1436,7 @@ void ProjectSettingsEditor::_update_translations() { t->set_text(0, keys[i].replace_first("res://", "")); t->set_tooltip(0, keys[i]); t->set_metadata(0, keys[i]); - t->add_button(0, get_icon("Del", "EditorIcons"), 0, false, TTR("Remove")); + t->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); if (keys[i] == remap_selected) { t->select(0); translation_res_option_add_button->set_disabled(false); @@ -1454,7 +1454,7 @@ void ProjectSettingsEditor::_update_translations() { t2->set_text(0, path.replace_first("res://", "")); t2->set_tooltip(0, path); t2->set_metadata(0, j); - t2->add_button(0, get_icon("Del", "EditorIcons"), 0, false, TTR("Remove")); + t2->add_button(0, get_icon("Remove", "EditorIcons"), 0, false, TTR("Remove")); t2->set_cell_mode(1, TreeItem::CELL_MODE_RANGE); t2->set_text(1, langnames); t2->set_editable(1, true); @@ -1782,6 +1782,7 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { tab_container->add_child(translations); //remap for properly select language in popup translation_locales_idxs_remap = Vector<int>(); + translation_locales_list_created = false; { diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index f4d5530faa..5136c96cbf 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -755,7 +755,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: value_editor[3]->set_text(String::num(q.w)); } break; - case Variant::RECT3: { + case Variant::AABB: { field_names.push_back("px"); field_names.push_back("py"); @@ -765,7 +765,7 @@ bool CustomPropertyEditor::edit(Object *p_owner, const String &p_name, Variant:: field_names.push_back("sz"); config_value_editors(6, 3, 16, field_names); - Rect3 aabb = v; + AABB aabb = v; value_editor[0]->set_text(String::num(aabb.position.x)); value_editor[1]->set_text(String::num(aabb.position.y)); value_editor[2]->set_text(String::num(aabb.position.z)); @@ -1585,7 +1585,7 @@ void CustomPropertyEditor::_modified(String p_string) { _emit_changed_whole_or_field(); } break; - case Variant::RECT3: { + case Variant::AABB: { Vector3 pos; Vector3 size; @@ -1605,7 +1605,7 @@ void CustomPropertyEditor::_modified(String p_string) { size.y = value_editor[4]->get_text().to_double(); size.z = value_editor[5]->get_text().to_double(); } - v = Rect3(pos, size); + v = AABB(pos, size); _emit_changed_whole_or_field(); } break; @@ -1727,7 +1727,7 @@ void CustomPropertyEditor::_focus_enter() { case Variant::VECTOR3: case Variant::PLANE: case Variant::QUAT: - case Variant::RECT3: + case Variant::AABB: case Variant::TRANSFORM2D: case Variant::BASIS: case Variant::TRANSFORM: { @@ -1752,7 +1752,7 @@ void CustomPropertyEditor::_focus_exit() { case Variant::VECTOR3: case Variant::PLANE: case Variant::QUAT: - case Variant::RECT3: + case Variant::AABB: case Variant::TRANSFORM2D: case Variant::BASIS: case Variant::TRANSFORM: { @@ -2238,7 +2238,7 @@ void PropertyEditor::set_item_text(TreeItem *p_item, int p_type, const String &p case Variant::VECTOR3: case Variant::QUAT: case Variant::VECTOR2: - case Variant::RECT3: + case Variant::AABB: case Variant::RECT2: case Variant::TRANSFORM2D: case Variant::BASIS: @@ -3367,13 +3367,13 @@ void PropertyEditor::update_tree() { item->set_icon(0, get_icon("Plane", "EditorIcons")); } break; - case Variant::RECT3: { + case Variant::AABB: { item->set_cell_mode(1, TreeItem::CELL_MODE_CUSTOM); item->set_editable(1, true); - item->set_text(1, "Rect3"); + item->set_text(1, "AABB"); if (show_type_icons) - item->set_icon(0, get_icon("Rect3", "EditorIcons")); + item->set_icon(0, get_icon("AABB", "EditorIcons")); } break; case Variant::QUAT: { @@ -3714,7 +3714,7 @@ void PropertyEditor::_item_edited() { _edit_set(name, item->get_text(1), refresh_all); } } break; - // math types + // math types case Variant::VECTOR3: { @@ -3725,7 +3725,7 @@ void PropertyEditor::_item_edited() { case Variant::QUAT: { } break; - case Variant::RECT3: { + case Variant::AABB: { } break; case Variant::BASIS: { @@ -4258,7 +4258,7 @@ PropertyEditor::PropertyEditor() { use_filter = false; subsection_selectable = false; property_selectable = false; - show_type_icons = EDITOR_DEF("interface/editor/show_type_icons", false); + show_type_icons = false; // maybe one day will return. } PropertyEditor::~PropertyEditor() { diff --git a/editor/pvrtc_compress.cpp b/editor/pvrtc_compress.cpp index 13d74a6593..575ff40287 100644 --- a/editor/pvrtc_compress.cpp +++ b/editor/pvrtc_compress.cpp @@ -62,12 +62,12 @@ static void _compress_image(Image::CompressMode p_mode, Image *p_image) { } return; } - String spath = EditorSettings::get_singleton()->get_settings_path(); + String tmppath = EditorSettings::get_singleton()->get_cache_dir(); List<String> args; - String src_img = spath + "/" + "_tmp_src_img.png"; - String dst_img = spath + "/" + "_tmp_dst_img.pvr"; + String src_img = tmppath.plus_file("_tmp_src_img.png"); + String dst_img = tmppath.plus_file("_tmp_dst_img.pvr"); args.push_back("-i"); args.push_back(src_img); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 7438c7671e..f866a158f3 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -443,8 +443,8 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { List<Node *> owned; node->get_owned_by(node->get_owner(), &owned); - Map<Node *, Node *> duplimap; - Node *dup = _duplicate(node, duplimap); + Map<const Node *, Node *> duplimap; + Node *dup = node->duplicate_from_editor(duplimap); ERR_CONTINUE(!dup); @@ -533,10 +533,6 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) { if (p_confirm_override) { _delete_confirm(); - // hack, force 2d editor viewport to refresh after deletion - if (CanvasItemEditor *editor = CanvasItemEditor::get_singleton()) - editor->get_viewport_control()->update(); - } else { delete_dialog->set_text(TTR("Delete Node(s)?")); delete_dialog->popup_centered_minsize(); @@ -825,74 +821,6 @@ void SceneTreeDock::_node_renamed() { _node_selected(); } -Node *SceneTreeDock::_duplicate(Node *p_node, Map<Node *, Node *> &duplimap) { - - Node *node = NULL; - - if (p_node->get_filename() != "") { //an instance - - Ref<PackedScene> sd = ResourceLoader::load(p_node->get_filename()); - ERR_FAIL_COND_V(!sd.is_valid(), NULL); - node = sd->instance(PackedScene::GEN_EDIT_STATE_INSTANCE); - ERR_FAIL_COND_V(!node, NULL); - node->set_scene_instance_load_placeholder(p_node->get_scene_instance_load_placeholder()); - } else { - Object *obj = ClassDB::instance(p_node->get_class()); - ERR_FAIL_COND_V(!obj, NULL); - node = Object::cast_to<Node>(obj); - if (!node) - memdelete(obj); - ERR_FAIL_COND_V(!node, NULL); - } - - List<PropertyInfo> plist; - - p_node->get_property_list(&plist); - - for (List<PropertyInfo>::Element *E = plist.front(); E; E = E->next()) { - - if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) - continue; - String name = E->get().name; - Variant value = p_node->get(name); - // Duplicate dictionaries and arrays, mainly needed for __meta__ - if (value.get_type() == Variant::DICTIONARY) { - value = Dictionary(value).copy(); - } else if (value.get_type() == Variant::ARRAY) { - value = Array(value).duplicate(); - } - node->set(name, value); - } - - List<Node::GroupInfo> group_info; - p_node->get_groups(&group_info); - for (List<Node::GroupInfo>::Element *E = group_info.front(); E; E = E->next()) { - - if (E->get().persistent) - node->add_to_group(E->get().name, true); - } - - node->set_name(p_node->get_name()); - duplimap[p_node] = node; - - for (int i = 0; i < p_node->get_child_count(); i++) { - - Node *child = p_node->get_child(i); - if (p_node->get_owner() != child->get_owner()) - continue; //don't bother with not in-scene nodes. - - Node *dup = _duplicate(child, duplimap); - if (!dup) { - memdelete(node); - return NULL; - } - - node->add_child(dup); - } - - return node; -} - void SceneTreeDock::_set_owners(Node *p_owner, const Array &p_nodes) { for (int i = 0; i < p_nodes.size(); i++) { @@ -1300,6 +1228,7 @@ void SceneTreeDock::_delete_confirm() { editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", (Object *)NULL); editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", edited_scene); editor_data->get_undo_redo().add_undo_method(edited_scene, "set_owner", edited_scene->get_owner()); + editor_data->get_undo_redo().add_undo_method(scene_tree, "update_tree"); editor_data->get_undo_redo().add_undo_reference(edited_scene); } else { @@ -1345,6 +1274,12 @@ void SceneTreeDock::_delete_confirm() { } } editor_data->get_undo_redo().commit_action(); + + // hack, force 2d editor viewport to refresh after deletion + if (CanvasItemEditor *editor = CanvasItemEditor::get_singleton()) + editor->get_viewport_control()->update(); + + editor->push_item(NULL); } void SceneTreeDock::_selection_changed() { @@ -1412,6 +1347,7 @@ void SceneTreeDock::_create() { } else { editor_data->get_undo_redo().add_do_method(editor, "set_edited_scene", child); + editor_data->get_undo_redo().add_do_method(scene_tree, "update_tree"); editor_data->get_undo_redo().add_do_reference(child); editor_data->get_undo_redo().add_undo_method(editor, "set_edited_scene", (Object *)NULL); } @@ -1447,6 +1383,8 @@ void SceneTreeDock::_create() { for (List<PropertyInfo>::Element *E = pinfo.front(); E; E = E->next()) { if (!(E->get().usage & PROPERTY_USAGE_STORAGE)) continue; + if (E->get().name == "__meta__") + continue; newnode->set(E->get().name, n->get(E->get().name)); } @@ -1876,6 +1814,43 @@ void SceneTreeDock::open_script_dialog(Node *p_for_node) { _tool_selected(TOOL_ATTACH_SCRIPT); } +void SceneTreeDock::add_remote_tree_editor(Control *p_remote) { + ERR_FAIL_COND(remote_tree != NULL); + add_child(p_remote); + remote_tree = p_remote; + remote_tree->hide(); +} + +void SceneTreeDock::show_remote_tree() { + + button_hb->show(); + _remote_tree_selected(); +} + +void SceneTreeDock::hide_remote_tree() { + + button_hb->hide(); + _local_tree_selected(); +} + +void SceneTreeDock::_remote_tree_selected() { + + scene_tree->hide(); + if (remote_tree) + remote_tree->show(); + edit_remote->set_pressed(true); + edit_local->set_pressed(false); +} + +void SceneTreeDock::_local_tree_selected() { + + scene_tree->show(); + if (remote_tree) + remote_tree->hide(); + edit_remote->set_pressed(false); + edit_local->set_pressed(true); +} + void SceneTreeDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_tool_selected"), &SceneTreeDock::_tool_selected, DEFVAL(false)); @@ -1901,6 +1876,8 @@ void SceneTreeDock::_bind_methods() { ClassDB::bind_method(D_METHOD("_tree_rmb"), &SceneTreeDock::_tree_rmb); ClassDB::bind_method(D_METHOD("_filter_changed"), &SceneTreeDock::_filter_changed); ClassDB::bind_method(D_METHOD("_focus_node"), &SceneTreeDock::_focus_node); + ClassDB::bind_method(D_METHOD("_remote_tree_selected"), &SceneTreeDock::_remote_tree_selected); + ClassDB::bind_method(D_METHOD("_local_tree_selected"), &SceneTreeDock::_local_tree_selected); ClassDB::bind_method(D_METHOD("instance"), &SceneTreeDock::instance); } @@ -1971,7 +1948,28 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel button_clear_script = tb; tb->hide(); + button_hb = memnew(HBoxContainer); + vbc->add_child(button_hb); + + edit_remote = memnew(ToolButton); + button_hb->add_child(edit_remote); + edit_remote->set_h_size_flags(SIZE_EXPAND_FILL); + edit_remote->set_text(TTR("Remote")); + edit_remote->set_toggle_mode(true); + edit_remote->connect("pressed", this, "_remote_tree_selected"); + + edit_local = memnew(ToolButton); + button_hb->add_child(edit_local); + edit_local->set_h_size_flags(SIZE_EXPAND_FILL); + edit_local->set_text(TTR("Local")); + edit_local->set_toggle_mode(true); + edit_local->connect("pressed", this, "_local_tree_selected"); + + remote_tree = NULL; + button_hb->hide(); + scene_tree = memnew(SceneTreeEditor(false, true, true)); + vbc->add_child(scene_tree); scene_tree->set_v_size_flags(SIZE_EXPAND | SIZE_FILL); scene_tree->connect("rmb_pressed", this, "_tree_rmb"); diff --git a/editor/scene_tree_dock.h b/editor/scene_tree_dock.h index f61c67bb13..7848052241 100644 --- a/editor/scene_tree_dock.h +++ b/editor/scene_tree_dock.h @@ -95,7 +95,10 @@ class SceneTreeDock : public VBoxContainer { ToolButton *button_create_script; ToolButton *button_clear_script; + HBoxContainer *button_hb; + ToolButton *edit_local, *edit_remote; SceneTreeEditor *scene_tree; + Control *remote_tree; HBoxContainer *tool_hbc; void _tool_selected(int p_tool, bool p_confirm_override = false); @@ -127,7 +130,6 @@ class SceneTreeDock : public VBoxContainer { void _add_children_to_popup(Object *p_obj, int p_depth); - Node *_duplicate(Node *p_node, Map<Node *, Node *> &duplimap); void _node_reparent(NodePath p_path, bool p_keep_global_xform); void _do_reparent(Node *p_new_parent, int p_position_in_parent, Vector<Node *> p_nodes, bool p_keep_global_xform); @@ -174,6 +176,9 @@ class SceneTreeDock : public VBoxContainer { void _file_selected(String p_file); + void _remote_tree_selected(); + void _local_tree_selected(); + protected: void _notification(int p_what); static void _bind_methods(); @@ -194,6 +199,10 @@ public: SceneTreeEditor *get_tree_editor() { return scene_tree; } EditorData *get_editor_data() { return editor_data; } + void add_remote_tree_editor(Control *p_remote); + void show_remote_tree(); + void hide_remote_tree(); + void open_script_dialog(Node *p_for_node); SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSelection *p_editor_selection, EditorData &p_editor_data); }; diff --git a/editor/scene_tree_editor.cpp b/editor/scene_tree_editor.cpp index a6e0af05b2..c4b86c6b2b 100644 --- a/editor/scene_tree_editor.cpp +++ b/editor/scene_tree_editor.cpp @@ -354,7 +354,11 @@ void SceneTreeEditor::_update_visibility_color(Node *p_node, TreeItem *p_item) { void SceneTreeEditor::_node_script_changed(Node *p_node) { - _update_tree(); + if (tree_dirty) + return; + + MessageQueue::get_singleton()->push_call(this, "_update_tree"); + tree_dirty = true; /* changes the order :| TreeItem* item=p_node?_find(tree->get_root(),p_node->get_path()):NULL; diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index c19b80e649..3cab14b0c4 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -128,7 +128,7 @@ void ScriptCreateDialog::_template_changed(int p_template) { } String ext = ScriptServer::get_language(language_menu->get_selected())->get_extension(); String name = template_list[p_template - 1] + "." + ext; - script_template = EditorSettings::get_singleton()->get_settings_path() + "/script_templates/" + name; + script_template = EditorSettings::get_singleton()->get_script_templates_dir().plus_file(name); } void ScriptCreateDialog::ok_pressed() { @@ -703,9 +703,7 @@ ScriptCreateDialog::ScriptCreateDialog() { internal = memnew(CheckButton); internal->connect("pressed", this, "_built_in_pressed"); hb = memnew(HBoxContainer); - Control *empty = memnew(Control); hb->add_child(internal); - hb->add_child(empty); l = memnew(Label); l->set_text(TTR("Built-in Script")); l->set_align(Label::ALIGN_RIGHT); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 3f8d93d976..3ffc61cb45 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -149,7 +149,7 @@ void EditorSpatialGizmo::add_lines(const Vector<Vector3> &p_lines, const Ref<Mat md = MAX(0, p_lines[i].length()); } if (md) { - mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); + mesh->set_custom_aabb(AABB(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); } } @@ -196,7 +196,7 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, md = MAX(0, vs[i].length()); } if (md) { - mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); + mesh->set_custom_aabb(AABB(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); } } @@ -211,7 +211,7 @@ void EditorSpatialGizmo::add_unscaled_billboard(const Ref<Material> &p_material, instances.push_back(ins); } -void EditorSpatialGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const Rect3 &p_bounds) { +void EditorSpatialGizmo::add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const AABB &p_bounds) { collision_mesh = p_tmesh; collision_mesh_bounds = p_bounds; @@ -270,7 +270,7 @@ void EditorSpatialGizmo::add_handles(const Vector<Vector3> &p_handles, bool p_bi md = MAX(0, p_handles[i].length()); } if (md) { - mesh->set_custom_aabb(Rect3(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); + mesh->set_custom_aabb(AABB(Vector3(-md, -md, -md), Vector3(md, md, md) * 2.0)); } } @@ -1274,7 +1274,7 @@ void MeshInstanceSpatialGizmo::redraw() { Ref<TriangleMesh> tm = m->generate_triangle_mesh(); if (tm.is_valid()) { - Rect3 aabb; + AABB aabb; add_collision_triangles(tm, aabb); } } @@ -1336,7 +1336,7 @@ void SkeletonSpatialGizmo::redraw() { weights[0] = 1; - Rect3 aabb; + AABB aabb; Color bonecolor = Color(1.0, 0.4, 0.4, 0.3); Color rootcolor = Color(0.4, 1.0, 0.4, 0.1); @@ -1961,7 +1961,7 @@ void CollisionShapeSpatialGizmo::redraw() { Ref<BoxShape> bs = s; Vector<Vector3> lines; - Rect3 aabb; + AABB aabb; aabb.position = -bs->get_extents(); aabb.size = aabb.position * -2; @@ -2191,7 +2191,7 @@ void VisibilityNotifierGizmo::set_handle(int p_idx, Camera *p_camera, const Poin //gt.orthonormalize(); Transform gi = gt.affine_inverse(); - Rect3 aabb = notifier->get_aabb(); + AABB aabb = notifier->get_aabb(); Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -2234,7 +2234,7 @@ void VisibilityNotifierGizmo::redraw() { clear(); Vector<Vector3> lines; - Rect3 aabb = notifier->get_aabb(); + AABB aabb = notifier->get_aabb(); for (int i = 0; i < 12; i++) { Vector3 a, b; @@ -2293,7 +2293,7 @@ void ParticlesGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_poi bool move = p_idx >= 3; p_idx = p_idx % 3; - Rect3 aabb = particles->get_visibility_aabb(); + AABB aabb = particles->get_visibility_aabb(); Vector3 ray_from = p_camera->project_ray_origin(p_point); Vector3 ray_dir = p_camera->project_ray_normal(p_point); @@ -2347,7 +2347,7 @@ void ParticlesGizmo::redraw() { clear(); Vector<Vector3> lines; - Rect3 aabb = particles->get_visibility_aabb(); + AABB aabb = particles->get_visibility_aabb(); for (int i = 0; i < 12; i++) { Vector3 a, b; @@ -2420,7 +2420,7 @@ String ReflectionProbeGizmo::get_handle_name(int p_idx) const { } Variant ReflectionProbeGizmo::get_handle_value(int p_idx) const { - return Rect3(probe->get_extents(), probe->get_origin_offset()); + return AABB(probe->get_extents(), probe->get_origin_offset()); } void ReflectionProbeGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 &p_point) { @@ -2474,7 +2474,7 @@ void ReflectionProbeGizmo::set_handle(int p_idx, Camera *p_camera, const Point2 void ReflectionProbeGizmo::commit_handle(int p_idx, const Variant &p_restore, bool p_cancel) { - Rect3 restore = p_restore; + AABB restore = p_restore; if (p_cancel) { probe->set_extents(restore.position); @@ -2499,7 +2499,7 @@ void ReflectionProbeGizmo::redraw() { Vector<Vector3> internal_lines; Vector3 extents = probe->get_extents(); - Rect3 aabb; + AABB aabb; aabb.position = -extents; aabb.size = extents * 2; @@ -2641,7 +2641,7 @@ void GIProbeGizmo::redraw() { static const int subdivs[GIProbe::SUBDIV_MAX] = { 64, 128, 256, 512 }; - Rect3 aabb = Rect3(-extents, extents * 2); + AABB aabb = AABB(-extents, extents * 2); int subdiv = subdivs[probe->get_subdiv()]; float cell_size = aabb.get_longest_axis_size() / subdiv; diff --git a/editor/spatial_editor_gizmos.h b/editor/spatial_editor_gizmos.h index afe64c723c..751bad2b13 100644 --- a/editor/spatial_editor_gizmos.h +++ b/editor/spatial_editor_gizmos.h @@ -78,7 +78,7 @@ class EditorSpatialGizmo : public SpatialEditorGizmo { Vector<Vector3> collision_segments; Ref<TriangleMesh> collision_mesh; - Rect3 collision_mesh_bounds; + AABB collision_mesh_bounds; struct Handle { Vector3 pos; @@ -100,7 +100,7 @@ protected: void add_lines(const Vector<Vector3> &p_lines, const Ref<Material> &p_material, bool p_billboard = false); void add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard = false, const RID &p_skeleton = RID()); void add_collision_segments(const Vector<Vector3> &p_lines); - void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const Rect3 &p_bounds = Rect3()); + void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh, const AABB &p_bounds = AABB()); void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1); void add_handles(const Vector<Vector3> &p_handles, bool p_billboard = false, bool p_secondary = false); void add_solid_box(Ref<Material> &p_material, Vector3 size); diff --git a/main/main.cpp b/main/main.cpp index 5e8e52d3e5..c4bca94b44 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -35,6 +35,7 @@ #include "message_queue.h" #include "modules/register_module_types.h" #include "os/os.h" +#include "platform/register_platform_apis.h" #include "project_settings.h" #include "scene/register_scene_types.h" #include "script_debugger_local.h" @@ -176,7 +177,7 @@ static String get_full_version_string() { void Main::print_help(const char *p_binary) { - print_line(String(_MKSTR(VERSION_NAME)) + " v" + get_full_version_string() + " - https://godotengine.org"); + print_line(String(VERSION_NAME) + " v" + get_full_version_string() + " - https://godotengine.org"); OS::get_singleton()->print("(c) 2007-2017 Juan Linietsky, Ariel Manzur.\n"); OS::get_singleton()->print("(c) 2014-2017 Godot Engine contributors.\n"); OS::get_singleton()->print("\n"); @@ -294,7 +295,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph translation_server = memnew(TranslationServer); performance = memnew(Performance); ClassDB::register_class<Performance>(); - globals->add_singleton(ProjectSettings::Singleton("Performance", performance)); + engine->add_singleton(Engine::Singleton("Performance", performance)); GLOBAL_DEF("debug/settings/crash_handler/message", String("Please include this when reporting the bug on https://github.com/godotengine/godot/issues")); @@ -321,8 +322,6 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph I = args.front(); - video_mode = OS::get_singleton()->get_default_video_mode(); - String video_driver = ""; String audio_driver = ""; String game_path = "."; @@ -779,38 +778,41 @@ 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_setting("display/window/size/width")) - video_mode.width = globals->get("display/window/size/width"); - 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_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_setting("display/window/size/fullscreen")) - video_mode.fullscreen = globals->get("display/window/size/fullscreen"); - 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_setting("display/window/size/borderless")) - video_mode.borderless_window = globals->get("display/window/size/borderless"); - - 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) { - video_mode.width = tw; - video_mode.height = th; + GLOBAL_DEF("display/window/size/width", 1024); + GLOBAL_DEF("display/window/size/height", 600); + GLOBAL_DEF("display/window/size/resizable", true); + GLOBAL_DEF("display/window/size/borderless", false); + GLOBAL_DEF("display/window/size/fullscreen", false); + GLOBAL_DEF("display/window/size/test_width", 0); + GLOBAL_DEF("display/window/size/test_height", 0); + + if (use_custom_res) { + + if (!force_res) { + video_mode.width = GLOBAL_GET("display/window/size/width"); + video_mode.height = GLOBAL_GET("display/window/size/height"); + + if (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) { + video_mode.width = tw; + video_mode.height = th; + } + } } + + video_mode.resizable = GLOBAL_GET("display/window/size/resizable"); + video_mode.borderless_window = GLOBAL_GET("display/window/size/borderless"); + video_mode.fullscreen = GLOBAL_GET("display/window/size/fullscreen"); } - GLOBAL_DEF("display/window/size/width", video_mode.width); - GLOBAL_DEF("display/window/size/height", video_mode.height); - GLOBAL_DEF("display/window/dpi/allow_hidpi", false); - GLOBAL_DEF("display/window/size/fullscreen", video_mode.fullscreen); - GLOBAL_DEF("display/window/size/resizable", video_mode.resizable); - GLOBAL_DEF("display/window/size/borderless", video_mode.borderless_window); - use_vsync = GLOBAL_DEF("display/window/vsync/use_vsync", use_vsync); - GLOBAL_DEF("display/window/size/test_width", 0); - GLOBAL_DEF("display/window/size/test_height", 0); + if (!force_lowdpi) { + OS::get_singleton()->_allow_hidpi = GLOBAL_DEF("display/window/dpi/allow_hidpi", false); + } + + use_vsync = GLOBAL_DEF("display/window/vsync/use_vsync", true); + GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation", 2); GLOBAL_DEF("rendering/quality/intended_usage/framebuffer_allocation.mobile", 3); @@ -1107,6 +1109,7 @@ Error Main::setup2(Thread::ID p_main_tid_override) { MAIN_PRINT("Main: Load Modules, Physics, Drivers, Scripts"); + register_platform_apis(); register_module_types(); initialize_physics(); @@ -1824,6 +1827,7 @@ void Main::cleanup() { unregister_driver_types(); unregister_module_types(); + unregister_platform_apis(); unregister_scene_types(); unregister_server_types(); diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index bcf4278bde..b41b5f6452 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -35,10 +35,10 @@ #ifdef GDSCRIPT_ENABLED -#include "modules/gdscript/gd_compiler.h" -#include "modules/gdscript/gd_parser.h" -#include "modules/gdscript/gd_script.h" -#include "modules/gdscript/gd_tokenizer.h" +#include "modules/gdscript/gdscript.h" +#include "modules/gdscript/gdscript_compiler.h" +#include "modules/gdscript/gdscript_parser.h" +#include "modules/gdscript/gdscript_tokenizer.h" namespace TestGDScript { @@ -52,7 +52,7 @@ static void _print_indent(int p_ident, const String &p_text) { print_line(txt + p_text); } -static String _parser_extends(const GDParser::ClassNode *p_class) { +static String _parser_extends(const GDScriptParser::ClassNode *p_class) { String txt = "extends "; if (String(p_class->extends_file) != "") { @@ -72,29 +72,29 @@ static String _parser_extends(const GDParser::ClassNode *p_class) { return txt; } -static String _parser_expr(const GDParser::Node *p_expr) { +static String _parser_expr(const GDScriptParser::Node *p_expr) { String txt; switch (p_expr->type) { - case GDParser::Node::TYPE_IDENTIFIER: { + case GDScriptParser::Node::TYPE_IDENTIFIER: { - const GDParser::IdentifierNode *id_node = static_cast<const GDParser::IdentifierNode *>(p_expr); + const GDScriptParser::IdentifierNode *id_node = static_cast<const GDScriptParser::IdentifierNode *>(p_expr); txt = id_node->name; } break; - case GDParser::Node::TYPE_CONSTANT: { - const GDParser::ConstantNode *c_node = static_cast<const GDParser::ConstantNode *>(p_expr); + case GDScriptParser::Node::TYPE_CONSTANT: { + const GDScriptParser::ConstantNode *c_node = static_cast<const GDScriptParser::ConstantNode *>(p_expr); if (c_node->value.get_type() == Variant::STRING) txt = "\"" + String(c_node->value) + "\""; else txt = c_node->value; } break; - case GDParser::Node::TYPE_SELF: { + case GDScriptParser::Node::TYPE_SELF: { txt = "self"; } break; - case GDParser::Node::TYPE_ARRAY: { - const GDParser::ArrayNode *arr_node = static_cast<const GDParser::ArrayNode *>(p_expr); + case GDScriptParser::Node::TYPE_ARRAY: { + const GDScriptParser::ArrayNode *arr_node = static_cast<const GDScriptParser::ArrayNode *>(p_expr); txt += "["; for (int i = 0; i < arr_node->elements.size(); i++) { @@ -104,51 +104,51 @@ static String _parser_expr(const GDParser::Node *p_expr) { } txt += "]"; } break; - case GDParser::Node::TYPE_DICTIONARY: { - const GDParser::DictionaryNode *dict_node = static_cast<const GDParser::DictionaryNode *>(p_expr); + case GDScriptParser::Node::TYPE_DICTIONARY: { + const GDScriptParser::DictionaryNode *dict_node = static_cast<const GDScriptParser::DictionaryNode *>(p_expr); txt += "{"; for (int i = 0; i < dict_node->elements.size(); i++) { if (i > 0) txt += ", "; - const GDParser::DictionaryNode::Pair &p = dict_node->elements[i]; + const GDScriptParser::DictionaryNode::Pair &p = dict_node->elements[i]; txt += _parser_expr(p.key); txt += ":"; txt += _parser_expr(p.value); } txt += "}"; } break; - case GDParser::Node::TYPE_OPERATOR: { + case GDScriptParser::Node::TYPE_OPERATOR: { - const GDParser::OperatorNode *c_node = static_cast<const GDParser::OperatorNode *>(p_expr); + const GDScriptParser::OperatorNode *c_node = static_cast<const GDScriptParser::OperatorNode *>(p_expr); switch (c_node->op) { - case GDParser::OperatorNode::OP_PARENT_CALL: + case GDScriptParser::OperatorNode::OP_PARENT_CALL: txt += "."; - case GDParser::OperatorNode::OP_CALL: { + case GDScriptParser::OperatorNode::OP_CALL: { ERR_FAIL_COND_V(c_node->arguments.size() < 1, ""); String func_name; - const GDParser::Node *nfunc = c_node->arguments[0]; + const GDScriptParser::Node *nfunc = c_node->arguments[0]; int arg_ofs = 0; - if (nfunc->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) { + if (nfunc->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) { - const GDParser::BuiltInFunctionNode *bif_node = static_cast<const GDParser::BuiltInFunctionNode *>(nfunc); - func_name = GDFunctions::get_func_name(bif_node->function); + const GDScriptParser::BuiltInFunctionNode *bif_node = static_cast<const GDScriptParser::BuiltInFunctionNode *>(nfunc); + func_name = GDScriptFunctions::get_func_name(bif_node->function); arg_ofs = 1; - } else if (nfunc->type == GDParser::Node::TYPE_TYPE) { + } else if (nfunc->type == GDScriptParser::Node::TYPE_TYPE) { - const GDParser::TypeNode *t_node = static_cast<const GDParser::TypeNode *>(nfunc); + const GDScriptParser::TypeNode *t_node = static_cast<const GDScriptParser::TypeNode *>(nfunc); func_name = Variant::get_type_name(t_node->vtype); arg_ofs = 1; } else { ERR_FAIL_COND_V(c_node->arguments.size() < 2, ""); nfunc = c_node->arguments[1]; - ERR_FAIL_COND_V(nfunc->type != GDParser::Node::TYPE_IDENTIFIER, ""); + ERR_FAIL_COND_V(nfunc->type != GDScriptParser::Node::TYPE_IDENTIFIER, ""); - if (c_node->arguments[0]->type != GDParser::Node::TYPE_SELF) + if (c_node->arguments[0]->type != GDScriptParser::Node::TYPE_SELF) func_name = _parser_expr(c_node->arguments[0]) + "."; func_name += _parser_expr(nfunc); @@ -159,7 +159,7 @@ static String _parser_expr(const GDParser::Node *p_expr) { for (int i = arg_ofs; i < c_node->arguments.size(); i++) { - const GDParser::Node *arg = c_node->arguments[i]; + const GDScriptParser::Node *arg = c_node->arguments[i]; if (i > arg_ofs) txt += ", "; txt += _parser_expr(arg); @@ -168,7 +168,7 @@ static String _parser_expr(const GDParser::Node *p_expr) { txt += ")"; } break; - case GDParser::OperatorNode::OP_INDEX: { + case GDScriptParser::OperatorNode::OP_INDEX: { ERR_FAIL_COND_V(c_node->arguments.size() != 2, ""); @@ -176,125 +176,125 @@ static String _parser_expr(const GDParser::Node *p_expr) { txt = _parser_expr(c_node->arguments[0]) + "[" + _parser_expr(c_node->arguments[1]) + "]"; } break; - case GDParser::OperatorNode::OP_INDEX_NAMED: { + case GDScriptParser::OperatorNode::OP_INDEX_NAMED: { ERR_FAIL_COND_V(c_node->arguments.size() != 2, ""); txt = _parser_expr(c_node->arguments[0]) + "." + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_NEG: { + case GDScriptParser::OperatorNode::OP_NEG: { txt = "-" + _parser_expr(c_node->arguments[0]); } break; - case GDParser::OperatorNode::OP_NOT: { + case GDScriptParser::OperatorNode::OP_NOT: { txt = "not " + _parser_expr(c_node->arguments[0]); } break; - case GDParser::OperatorNode::OP_BIT_INVERT: { + case GDScriptParser::OperatorNode::OP_BIT_INVERT: { txt = "~" + _parser_expr(c_node->arguments[0]); } break; - case GDParser::OperatorNode::OP_PREINC: { + case GDScriptParser::OperatorNode::OP_PREINC: { } break; - case GDParser::OperatorNode::OP_PREDEC: { + case GDScriptParser::OperatorNode::OP_PREDEC: { } break; - case GDParser::OperatorNode::OP_INC: { + case GDScriptParser::OperatorNode::OP_INC: { } break; - case GDParser::OperatorNode::OP_DEC: { + case GDScriptParser::OperatorNode::OP_DEC: { } break; - case GDParser::OperatorNode::OP_IN: { + case GDScriptParser::OperatorNode::OP_IN: { txt = _parser_expr(c_node->arguments[0]) + " in " + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_EQUAL: { + case GDScriptParser::OperatorNode::OP_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + "==" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_NOT_EQUAL: { + case GDScriptParser::OperatorNode::OP_NOT_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + "!=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_LESS: { + case GDScriptParser::OperatorNode::OP_LESS: { txt = _parser_expr(c_node->arguments[0]) + "<" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_LESS_EQUAL: { + case GDScriptParser::OperatorNode::OP_LESS_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + "<=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_GREATER: { + case GDScriptParser::OperatorNode::OP_GREATER: { txt = _parser_expr(c_node->arguments[0]) + ">" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_GREATER_EQUAL: { + case GDScriptParser::OperatorNode::OP_GREATER_EQUAL: { txt = _parser_expr(c_node->arguments[0]) + ">=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_AND: { + case GDScriptParser::OperatorNode::OP_AND: { txt = _parser_expr(c_node->arguments[0]) + " and " + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_OR: { + case GDScriptParser::OperatorNode::OP_OR: { txt = _parser_expr(c_node->arguments[0]) + " or " + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ADD: { + case GDScriptParser::OperatorNode::OP_ADD: { txt = _parser_expr(c_node->arguments[0]) + "+" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_SUB: { + case GDScriptParser::OperatorNode::OP_SUB: { txt = _parser_expr(c_node->arguments[0]) + "-" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_MUL: { + case GDScriptParser::OperatorNode::OP_MUL: { txt = _parser_expr(c_node->arguments[0]) + "*" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_DIV: { + case GDScriptParser::OperatorNode::OP_DIV: { txt = _parser_expr(c_node->arguments[0]) + "/" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_MOD: { + case GDScriptParser::OperatorNode::OP_MOD: { txt = _parser_expr(c_node->arguments[0]) + "%" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_SHIFT_LEFT: { + case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: { txt = _parser_expr(c_node->arguments[0]) + "<<" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_SHIFT_RIGHT: { + case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: { txt = _parser_expr(c_node->arguments[0]) + ">>" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN: { + case GDScriptParser::OperatorNode::OP_ASSIGN: { txt = _parser_expr(c_node->arguments[0]) + "=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_ADD: { + case GDScriptParser::OperatorNode::OP_ASSIGN_ADD: { txt = _parser_expr(c_node->arguments[0]) + "+=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_SUB: { + case GDScriptParser::OperatorNode::OP_ASSIGN_SUB: { txt = _parser_expr(c_node->arguments[0]) + "-=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_MUL: { + case GDScriptParser::OperatorNode::OP_ASSIGN_MUL: { txt = _parser_expr(c_node->arguments[0]) + "*=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_DIV: { + case GDScriptParser::OperatorNode::OP_ASSIGN_DIV: { txt = _parser_expr(c_node->arguments[0]) + "/=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_MOD: { + case GDScriptParser::OperatorNode::OP_ASSIGN_MOD: { txt = _parser_expr(c_node->arguments[0]) + "%=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: { + case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: { txt = _parser_expr(c_node->arguments[0]) + "<<=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: { + case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: { txt = _parser_expr(c_node->arguments[0]) + ">>=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: { + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_AND: { txt = _parser_expr(c_node->arguments[0]) + "&=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: { + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_OR: { txt = _parser_expr(c_node->arguments[0]) + "|=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: { + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR: { txt = _parser_expr(c_node->arguments[0]) + "^=" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_BIT_AND: { + case GDScriptParser::OperatorNode::OP_BIT_AND: { txt = _parser_expr(c_node->arguments[0]) + "&" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_BIT_OR: { + case GDScriptParser::OperatorNode::OP_BIT_OR: { txt = _parser_expr(c_node->arguments[0]) + "|" + _parser_expr(c_node->arguments[1]); } break; - case GDParser::OperatorNode::OP_BIT_XOR: { + case GDScriptParser::OperatorNode::OP_BIT_XOR: { txt = _parser_expr(c_node->arguments[0]) + "^" + _parser_expr(c_node->arguments[1]); } break; default: {} } } break; - case GDParser::Node::TYPE_NEWLINE: { + case GDScriptParser::Node::TYPE_NEWLINE: { //skippie } break; @@ -310,20 +310,20 @@ static String _parser_expr(const GDParser::Node *p_expr) { //return "("+txt+")"; } -static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) { +static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_indent) { for (int i = 0; i < p_block->statements.size(); i++) { - const GDParser::Node *statement = p_block->statements[i]; + const GDScriptParser::Node *statement = p_block->statements[i]; switch (statement->type) { - case GDParser::Node::TYPE_CONTROL_FLOW: { + case GDScriptParser::Node::TYPE_CONTROL_FLOW: { - const GDParser::ControlFlowNode *cf_node = static_cast<const GDParser::ControlFlowNode *>(statement); + const GDScriptParser::ControlFlowNode *cf_node = static_cast<const GDScriptParser::ControlFlowNode *>(statement); switch (cf_node->cf_type) { - case GDParser::ControlFlowNode::CF_IF: { + case GDScriptParser::ControlFlowNode::CF_IF: { ERR_FAIL_COND(cf_node->arguments.size() != 1); String txt; @@ -339,7 +339,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) } } break; - case GDParser::ControlFlowNode::CF_FOR: { + case GDScriptParser::ControlFlowNode::CF_FOR: { ERR_FAIL_COND(cf_node->arguments.size() != 2); String txt; txt += "for "; @@ -352,7 +352,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) _parser_show_block(cf_node->body, p_indent + 1); } break; - case GDParser::ControlFlowNode::CF_WHILE: { + case GDScriptParser::ControlFlowNode::CF_WHILE: { ERR_FAIL_COND(cf_node->arguments.size() != 1); String txt; @@ -364,18 +364,18 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) _parser_show_block(cf_node->body, p_indent + 1); } break; - case GDParser::ControlFlowNode::CF_SWITCH: { + case GDScriptParser::ControlFlowNode::CF_SWITCH: { } break; - case GDParser::ControlFlowNode::CF_CONTINUE: { + case GDScriptParser::ControlFlowNode::CF_CONTINUE: { _print_indent(p_indent, "continue"); } break; - case GDParser::ControlFlowNode::CF_BREAK: { + case GDScriptParser::ControlFlowNode::CF_BREAK: { _print_indent(p_indent, "break"); } break; - case GDParser::ControlFlowNode::CF_RETURN: { + case GDScriptParser::ControlFlowNode::CF_RETURN: { if (cf_node->arguments.size()) _print_indent(p_indent, "return " + _parser_expr(cf_node->arguments[0])); @@ -385,9 +385,9 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) } } break; - case GDParser::Node::TYPE_LOCAL_VAR: { + case GDScriptParser::Node::TYPE_LOCAL_VAR: { - const GDParser::LocalVarNode *lv_node = static_cast<const GDParser::LocalVarNode *>(statement); + const GDScriptParser::LocalVarNode *lv_node = static_cast<const GDScriptParser::LocalVarNode *>(statement); _print_indent(p_indent, "var " + String(lv_node->name)); } break; default: { @@ -398,7 +398,7 @@ static void _parser_show_block(const GDParser::BlockNode *p_block, int p_indent) } } -static void _parser_show_function(const GDParser::FunctionNode *p_func, int p_indent, GDParser::BlockNode *p_initializer = NULL) { +static void _parser_show_function(const GDScriptParser::FunctionNode *p_func, int p_indent, GDScriptParser::BlockNode *p_initializer = NULL) { String txt; if (p_func->_static) @@ -434,7 +434,7 @@ static void _parser_show_function(const GDParser::FunctionNode *p_func, int p_in _parser_show_block(p_func->body, p_indent + 1); } -static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, const Vector<String> &p_code) { +static void _parser_show_class(const GDScriptParser::ClassNode *p_class, int p_indent, const Vector<String> &p_code) { if (p_indent == 0 && (String(p_class->extends_file) != "" || p_class->extends_class.size())) { @@ -444,7 +444,7 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, for (int i = 0; i < p_class->subclasses.size(); i++) { - const GDParser::ClassNode *subclass = p_class->subclasses[i]; + const GDScriptParser::ClassNode *subclass = p_class->subclasses[i]; String line = "class " + subclass->name; if (String(subclass->extends_file) != "" || subclass->extends_class.size()) line += " " + _parser_extends(subclass); @@ -456,13 +456,13 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, for (int i = 0; i < p_class->constant_expressions.size(); i++) { - const GDParser::ClassNode::Constant &constant = p_class->constant_expressions[i]; + const GDScriptParser::ClassNode::Constant &constant = p_class->constant_expressions[i]; _print_indent(p_indent, "const " + String(constant.identifier) + "=" + _parser_expr(constant.expression)); } for (int i = 0; i < p_class->variables.size(); i++) { - const GDParser::ClassNode::Member &m = p_class->variables[i]; + const GDScriptParser::ClassNode::Member &m = p_class->variables[i]; _print_indent(p_indent, "var " + String(m.identifier)); } @@ -487,27 +487,27 @@ static void _parser_show_class(const GDParser::ClassNode *p_class, int p_indent, print_line("\n"); } -static String _disassemble_addr(const Ref<GDScript> &p_script, const GDFunction &func, int p_addr) { +static String _disassemble_addr(const Ref<GDScript> &p_script, const GDScriptFunction &func, int p_addr) { - int addr = p_addr & GDFunction::ADDR_MASK; + int addr = p_addr & GDScriptFunction::ADDR_MASK; - switch (p_addr >> GDFunction::ADDR_BITS) { + switch (p_addr >> GDScriptFunction::ADDR_BITS) { - case GDFunction::ADDR_TYPE_SELF: { + case GDScriptFunction::ADDR_TYPE_SELF: { return "self"; } break; - case GDFunction::ADDR_TYPE_CLASS: { + case GDScriptFunction::ADDR_TYPE_CLASS: { return "class"; } break; - case GDFunction::ADDR_TYPE_MEMBER: { + case GDScriptFunction::ADDR_TYPE_MEMBER: { return "member(" + p_script->debug_get_member_by_index(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_CLASS_CONSTANT: { + case GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT: { return "class_const(" + func.get_global_name(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_LOCAL_CONSTANT: { + case GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT: { Variant v = func.get_constant(addr); String txt; @@ -517,19 +517,19 @@ static String _disassemble_addr(const Ref<GDScript> &p_script, const GDFunction txt = v; return "const(" + txt + ")"; } break; - case GDFunction::ADDR_TYPE_STACK: { + case GDScriptFunction::ADDR_TYPE_STACK: { return "stack(" + itos(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_STACK_VARIABLE: { + case GDScriptFunction::ADDR_TYPE_STACK_VARIABLE: { return "var_stack(" + itos(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_GLOBAL: { + case GDScriptFunction::ADDR_TYPE_GLOBAL: { return "global(" + func.get_global_name(addr) + ")"; } break; - case GDFunction::ADDR_TYPE_NIL: { + case GDScriptFunction::ADDR_TYPE_NIL: { return "nil"; } break; } @@ -539,11 +539,11 @@ static String _disassemble_addr(const Ref<GDScript> &p_script, const GDFunction static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String> &p_code) { - const Map<StringName, GDFunction *> &mf = p_class->debug_get_member_functions(); + const Map<StringName, GDScriptFunction *> &mf = p_class->debug_get_member_functions(); - for (const Map<StringName, GDFunction *>::Element *E = mf.front(); E; E = E->next()) { + for (const Map<StringName, GDScriptFunction *>::Element *E = mf.front(); E; E = E->next()) { - const GDFunction &func = *E->get(); + const GDScriptFunction &func = *E->get(); const int *code = func.get_code(); int codelen = func.get_code_size(); String defargs; @@ -568,7 +568,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String switch (code[ip]) { - case GDFunction::OPCODE_OPERATOR: { + case GDScriptFunction::OPCODE_OPERATOR: { int op = code[ip + 1]; txt += "op "; @@ -583,7 +583,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 5; } break; - case GDFunction::OPCODE_SET: { + case GDScriptFunction::OPCODE_SET: { txt += "set "; txt += DADDR(1); @@ -594,7 +594,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 4; } break; - case GDFunction::OPCODE_GET: { + case GDScriptFunction::OPCODE_GET: { txt += " get "; txt += DADDR(3); @@ -606,7 +606,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 4; } break; - case GDFunction::OPCODE_SET_NAMED: { + case GDScriptFunction::OPCODE_SET_NAMED: { txt += " set_named "; txt += DADDR(1); @@ -617,7 +617,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 4; } break; - case GDFunction::OPCODE_GET_NAMED: { + case GDScriptFunction::OPCODE_GET_NAMED: { txt += " get_named "; txt += DADDR(3); @@ -629,7 +629,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 4; } break; - case GDFunction::OPCODE_SET_MEMBER: { + case GDScriptFunction::OPCODE_SET_MEMBER: { txt += " set_member "; txt += "[\""; @@ -639,7 +639,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 3; } break; - case GDFunction::OPCODE_GET_MEMBER: { + case GDScriptFunction::OPCODE_GET_MEMBER: { txt += " get_member "; txt += DADDR(2); @@ -650,7 +650,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 3; } break; - case GDFunction::OPCODE_ASSIGN: { + case GDScriptFunction::OPCODE_ASSIGN: { txt += " assign "; txt += DADDR(1); @@ -659,7 +659,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 3; } break; - case GDFunction::OPCODE_ASSIGN_TRUE: { + case GDScriptFunction::OPCODE_ASSIGN_TRUE: { txt += " assign "; txt += DADDR(1); @@ -667,7 +667,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 2; } break; - case GDFunction::OPCODE_ASSIGN_FALSE: { + case GDScriptFunction::OPCODE_ASSIGN_FALSE: { txt += " assign "; txt += DADDR(1); @@ -675,7 +675,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 2; } break; - case GDFunction::OPCODE_CONSTRUCT: { + case GDScriptFunction::OPCODE_CONSTRUCT: { Variant::Type t = Variant::Type(code[ip + 1]); int argc = code[ip + 2]; @@ -696,7 +696,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 4 + argc; } break; - case GDFunction::OPCODE_CONSTRUCT_ARRAY: { + case GDScriptFunction::OPCODE_CONSTRUCT_ARRAY: { int argc = code[ip + 1]; txt += " make_array "; @@ -714,7 +714,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr += 3 + argc; } break; - case GDFunction::OPCODE_CONSTRUCT_DICTIONARY: { + case GDScriptFunction::OPCODE_CONSTRUCT_DICTIONARY: { int argc = code[ip + 1]; txt += " make_dict "; @@ -735,10 +735,10 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String } break; - case GDFunction::OPCODE_CALL: - case GDFunction::OPCODE_CALL_RETURN: { + case GDScriptFunction::OPCODE_CALL: + case GDScriptFunction::OPCODE_CALL_RETURN: { - bool ret = code[ip] == GDFunction::OPCODE_CALL_RETURN; + bool ret = code[ip] == GDScriptFunction::OPCODE_CALL_RETURN; if (ret) txt += " call-ret "; @@ -764,14 +764,14 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 5 + argc; } break; - case GDFunction::OPCODE_CALL_BUILT_IN: { + case GDScriptFunction::OPCODE_CALL_BUILT_IN: { txt += " call-built-in "; int argc = code[ip + 2]; txt += DADDR(3 + argc) + "="; - txt += GDFunctions::get_func_name(GDFunctions::Function(code[ip + 1])); + txt += GDScriptFunctions::get_func_name(GDScriptFunctions::Function(code[ip + 1])); txt += "("; for (int i = 0; i < argc; i++) { @@ -784,7 +784,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 4 + argc; } break; - case GDFunction::OPCODE_CALL_SELF_BASE: { + case GDScriptFunction::OPCODE_CALL_SELF_BASE: { txt += " call-self-base "; @@ -804,13 +804,13 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 4 + argc; } break; - case GDFunction::OPCODE_YIELD: { + case GDScriptFunction::OPCODE_YIELD: { txt += " yield "; incr = 1; } break; - case GDFunction::OPCODE_YIELD_SIGNAL: { + case GDScriptFunction::OPCODE_YIELD_SIGNAL: { txt += " yield_signal "; txt += DADDR(1); @@ -818,13 +818,13 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String txt += DADDR(2); incr = 3; } break; - case GDFunction::OPCODE_YIELD_RESUME: { + case GDScriptFunction::OPCODE_YIELD_RESUME: { txt += " yield resume: "; txt += DADDR(1); incr = 2; } break; - case GDFunction::OPCODE_JUMP: { + case GDScriptFunction::OPCODE_JUMP: { txt += " jump "; txt += itos(code[ip + 1]); @@ -832,7 +832,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 2; } break; - case GDFunction::OPCODE_JUMP_IF: { + case GDScriptFunction::OPCODE_JUMP_IF: { txt += " jump-if "; txt += DADDR(1); @@ -841,7 +841,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 3; } break; - case GDFunction::OPCODE_JUMP_IF_NOT: { + case GDScriptFunction::OPCODE_JUMP_IF_NOT: { txt += " jump-if-not "; txt += DADDR(1); @@ -850,12 +850,12 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 3; } break; - case GDFunction::OPCODE_JUMP_TO_DEF_ARGUMENT: { + case GDScriptFunction::OPCODE_JUMP_TO_DEF_ARGUMENT: { txt += " jump-to-default-argument "; incr = 1; } break; - case GDFunction::OPCODE_RETURN: { + case GDScriptFunction::OPCODE_RETURN: { txt += " return "; txt += DADDR(1); @@ -863,19 +863,19 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String incr = 2; } break; - case GDFunction::OPCODE_ITERATE_BEGIN: { + case GDScriptFunction::OPCODE_ITERATE_BEGIN: { txt += " for-init " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]); incr += 5; } break; - case GDFunction::OPCODE_ITERATE: { + case GDScriptFunction::OPCODE_ITERATE: { txt += " for-loop " + DADDR(4) + " in " + DADDR(2) + " counter " + DADDR(1) + " end " + itos(code[ip + 3]); incr += 5; } break; - case GDFunction::OPCODE_LINE: { + case GDScriptFunction::OPCODE_LINE: { int line = code[ip + 1] - 1; if (line >= 0 && line < p_code.size()) @@ -884,12 +884,12 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String txt = ""; incr += 2; } break; - case GDFunction::OPCODE_END: { + case GDScriptFunction::OPCODE_END: { txt += " end"; incr += 1; } break; - case GDFunction::OPCODE_ASSERT: { + case GDScriptFunction::OPCODE_ASSERT: { txt += " assert "; txt += DADDR(1); @@ -952,15 +952,15 @@ MainLoop *test(TestType p_type) { if (p_type == TEST_TOKENIZER) { - GDTokenizerText tk; + GDScriptTokenizerText tk; tk.set_code(code); int line = -1; - while (tk.get_token() != GDTokenizer::TK_EOF) { + while (tk.get_token() != GDScriptTokenizer::TK_EOF) { String text; - if (tk.get_token() == GDTokenizer::TK_IDENTIFIER) + if (tk.get_token() == GDScriptTokenizer::TK_IDENTIFIER) text = "'" + tk.get_token_identifier() + "' (identifier)"; - else if (tk.get_token() == GDTokenizer::TK_CONSTANT) { + else if (tk.get_token() == GDScriptTokenizer::TK_CONSTANT) { Variant c = tk.get_token_constant(); if (c.get_type() == Variant::STRING) text = "\"" + String(c) + "\""; @@ -968,12 +968,12 @@ MainLoop *test(TestType p_type) { text = c; text = text + " (" + Variant::get_type_name(c.get_type()) + " constant)"; - } else if (tk.get_token() == GDTokenizer::TK_ERROR) + } else if (tk.get_token() == GDScriptTokenizer::TK_ERROR) text = "ERROR: " + tk.get_token_error(); - else if (tk.get_token() == GDTokenizer::TK_NEWLINE) + else if (tk.get_token() == GDScriptTokenizer::TK_NEWLINE) text = "newline (" + itos(tk.get_token_line()) + ") + indent: " + itos(tk.get_token_line_indent()); - else if (tk.get_token() == GDTokenizer::TK_BUILT_IN_FUNC) - text = "'" + String(GDFunctions::get_func_name(tk.get_token_built_in_func())) + "' (built-in function)"; + else if (tk.get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC) + text = "'" + String(GDScriptFunctions::get_func_name(tk.get_token_built_in_func())) + "' (built-in function)"; else text = tk.get_token_name(tk.get_token()); @@ -995,7 +995,7 @@ MainLoop *test(TestType p_type) { if (p_type == TEST_PARSER) { - GDParser parser; + GDScriptParser parser; Error err = parser.parse(code); if (err) { print_line("Parse Error:\n" + itos(parser.get_error_line()) + ":" + itos(parser.get_error_column()) + ":" + parser.get_error()); @@ -1003,16 +1003,16 @@ MainLoop *test(TestType p_type) { return NULL; } - const GDParser::Node *root = parser.get_parse_tree(); - ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, NULL); - const GDParser::ClassNode *cnode = static_cast<const GDParser::ClassNode *>(root); + const GDScriptParser::Node *root = parser.get_parse_tree(); + ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, NULL); + const GDScriptParser::ClassNode *cnode = static_cast<const GDScriptParser::ClassNode *>(root); _parser_show_class(cnode, 0, lines); } if (p_type == TEST_COMPILER) { - GDParser parser; + GDScriptParser parser; Error err = parser.parse(code); if (err) { @@ -1023,7 +1023,7 @@ MainLoop *test(TestType p_type) { GDScript *script = memnew(GDScript); - GDCompiler gdc; + GDScriptCompiler gdc; err = gdc.compile(&parser, script); if (err) { @@ -1046,7 +1046,7 @@ MainLoop *test(TestType p_type) { } else if (p_type == TEST_BYTECODE) { - Vector<uint8_t> buf = GDTokenizerBuffer::parse_code_string(code); + Vector<uint8_t> buf = GDScriptTokenizerBuffer::parse_code_string(code); String dst = test.get_basename() + ".gdc"; FileAccess *fw = FileAccess::open(dst, FileAccess::WRITE); fw->store_buffer(buf.ptr(), buf.size()); diff --git a/main/tests/test_physics.cpp b/main/tests/test_physics.cpp index f149821928..1c50470544 100644 --- a/main/tests/test_physics.cpp +++ b/main/tests/test_physics.cpp @@ -299,7 +299,7 @@ public: VisualServer *vs = VisualServer::get_singleton(); /* LIGHT */ - RID lightaux = vs->light_create(VisualServer::LIGHT_DIRECTIONAL); + RID lightaux = vs->directional_light_create(); scenario = vs->scenario_create(); vs->light_set_shadow(lightaux, true); light = vs->instance_create2(lightaux, scenario); diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp index a746973799..7d596fbda3 100644 --- a/main/tests/test_physics_2d.cpp +++ b/main/tests/test_physics_2d.cpp @@ -86,7 +86,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_SEGMENT].image = vs->texture_create_from_image(image); - RID segment_shape = ps->shape_create(Physics2DServer::SHAPE_SEGMENT); + RID segment_shape = ps->segment_shape_create(); Rect2 sg(Point2(-16, 0), Point2(16, 0)); ps->shape_set_data(segment_shape, sg); @@ -113,7 +113,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_CIRCLE].image = vs->texture_create_from_image(image); - RID circle_shape = ps->shape_create(Physics2DServer::SHAPE_CIRCLE); + RID circle_shape = ps->circle_shape_create(); ps->shape_set_data(circle_shape, 16); body_shape_data[Physics2DServer::SHAPE_CIRCLE].shape = circle_shape; @@ -140,7 +140,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_RECTANGLE].image = vs->texture_create_from_image(image); - RID rectangle_shape = ps->shape_create(Physics2DServer::SHAPE_RECTANGLE); + RID rectangle_shape = ps->rectangle_shape_create(); ps->shape_set_data(rectangle_shape, Vector2(16, 16)); body_shape_data[Physics2DServer::SHAPE_RECTANGLE].shape = rectangle_shape; @@ -168,7 +168,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_CAPSULE].image = vs->texture_create_from_image(image); - RID capsule_shape = ps->shape_create(Physics2DServer::SHAPE_CAPSULE); + RID capsule_shape = ps->capsule_shape_create(); ps->shape_set_data(capsule_shape, Vector2(16, 32)); body_shape_data[Physics2DServer::SHAPE_CAPSULE].shape = capsule_shape; @@ -182,7 +182,7 @@ class TestPhysics2DMainLoop : public MainLoop { body_shape_data[Physics2DServer::SHAPE_CONVEX_POLYGON].image = vs->texture_create_from_image(image); - RID convex_polygon_shape = ps->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON); + RID convex_polygon_shape = ps->convex_polygon_shape_create(); PoolVector<Vector2> arr; Point2 sb(32, 32); @@ -277,10 +277,11 @@ protected: arr.push_back(p_normal); arr.push_back(p_d); - RID plane = ps->shape_create(Physics2DServer::SHAPE_LINE); + RID plane = ps->line_shape_create(); ps->shape_set_data(plane, arr); - RID plane_body = ps->body_create(Physics2DServer::BODY_MODE_STATIC); + RID plane_body = ps->body_create(); + ps->body_set_mode(plane_body, Physics2DServer::BODY_MODE_STATIC); ps->body_set_space(plane_body, space); ps->body_add_shape(plane_body, plane); } @@ -290,9 +291,10 @@ protected: Physics2DServer *ps = Physics2DServer::get_singleton(); VisualServer *vs = VisualServer::get_singleton(); - RID concave = ps->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON); + RID concave = ps->concave_polygon_shape_create(); ps->shape_set_data(concave, p_points); - RID body = ps->body_create(Physics2DServer::BODY_MODE_STATIC); + RID body = ps->body_create(); + ps->body_set_mode(body, Physics2DServer::BODY_MODE_STATIC); ps->body_set_space(body, space); ps->body_add_shape(body, concave); ps->body_set_state(body, Physics2DServer::BODY_STATE_TRANSFORM, p_xform); diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp index 1f6217928d..cbf1a57855 100644 --- a/main/tests/test_render.cpp +++ b/main/tests/test_render.cpp @@ -180,7 +180,7 @@ public: */ RID lightaux; - lightaux = vs->light_create(VisualServer::LIGHT_DIRECTIONAL); + lightaux = vs->directional_light_create(); //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) ); vs->light_set_color(lightaux, Color(1.0, 1.0, 1.0)); //vs->light_set_shadow( lightaux, true ); @@ -191,7 +191,7 @@ public: vs->instance_set_transform(light, lla); - lightaux = vs->light_create(VisualServer::LIGHT_OMNI); + lightaux = vs->omni_light_create(); //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) ); vs->light_set_color(lightaux, Color(1.0, 1.0, 0.0)); vs->light_set_param(lightaux, VisualServer::LIGHT_PARAM_RANGE, 4); diff --git a/methods.py b/methods.py index 2f3dac7e42..2be73f02d2 100644 --- a/methods.py +++ b/methods.py @@ -1150,26 +1150,26 @@ def build_gles3_headers(target, source, env): def add_module_version_string(self,s): - self.module_version_string+="."+s + self.module_version_string += "." + s def update_version(module_version_string=""): - rev = "custom_build" + build_name = "custom_build" + if (os.getenv("BUILD_NAME") != None): + build_name = os.getenv("BUILD_NAME") + print("Using custom build name: " + build_name) - if (os.getenv("BUILD_REVISION") != None): - rev = os.getenv("BUILD_REVISION") - print("Using custom revision: " + rev) import version f = open("core/version_generated.gen.h", "w") - f.write("#define VERSION_SHORT_NAME " + str(version.short_name) + "\n") - f.write("#define VERSION_NAME " + str(version.name) + "\n") + f.write("#define VERSION_SHORT_NAME \"" + str(version.short_name) + "\"\n") + f.write("#define VERSION_NAME \"" + str(version.name) + "\"\n") f.write("#define VERSION_MAJOR " + str(version.major) + "\n") f.write("#define VERSION_MINOR " + str(version.minor) + "\n") if (hasattr(version, 'patch')): f.write("#define VERSION_PATCH " + str(version.patch) + "\n") - f.write("#define VERSION_REVISION " + str(rev) + "\n") - f.write("#define VERSION_STATUS " + str(version.status) + "\n") + f.write("#define VERSION_STATUS \"" + str(version.status) + "\"\n") + f.write("#define VERSION_BUILD \"" + str(build_name) + "\"\n") f.write("#define VERSION_MODULE_CONFIG \"" + str(version.module_config) + module_version_string + "\"\n") import datetime f.write("#define VERSION_YEAR " + str(datetime.datetime.now().year) + "\n") @@ -1293,21 +1293,15 @@ def detect_modules(): // modules.cpp - THIS FILE IS GENERATED, DO NOT EDIT!!!!!!! #include "register_module_types.h" - """ + includes_cpp + """ void register_module_types() { - """ + register_cpp + """ - } void unregister_module_types() { - """ + unregister_cpp + """ - } - """ f = open("modules/register_module_types.gen.cpp", "w") @@ -1692,6 +1686,17 @@ def find_visual_c_batch_file(env): (host_platform, target_platform,req_target_platform) = get_host_target(env) return find_batch_file(env, version, host_platform, target_platform)[0] +def generate_cpp_hint_file(filename): + import os.path + if os.path.isfile(filename): + # Don't overwrite an existing hint file since the user may have customized it. + pass + else: + try: + fd = open(filename, "w") + fd.write("#define GDCLASS(m_class, m_inherits)\n") + except IOError: + print("Could not write cpp.hint file.") def generate_vs_project(env, num_jobs): batch_file = find_visual_c_batch_file(env) @@ -1718,9 +1723,9 @@ def generate_vs_project(env, num_jobs): # to double quote off the directory. However, the path ends # in a backslash, so we need to remove this, lest it escape the # last double quote off, confusing MSBuild - env['MSVSBUILDCOM'] = build_commandline('scons --directory="$(ProjectDir.TrimEnd(\'\\\'))" platform=windows target=$(Configuration) tools=!tools! -j' + str(num_jobs)) - env['MSVSREBUILDCOM'] = build_commandline('scons --directory="$(ProjectDir.TrimEnd(\'\\\'))" platform=windows target=$(Configuration) tools=!tools! vsproj=yes -j' + str(num_jobs)) - env['MSVSCLEANCOM'] = build_commandline('scons --directory="$(ProjectDir.TrimEnd(\'\\\'))" --clean platform=windows target=$(Configuration) tools=!tools! -j' + str(num_jobs)) + env['MSVSBUILDCOM'] = build_commandline('scons --directory="$(ProjectDir.TrimEnd(\'\\\'))" platform=windows progress=no target=$(Configuration) tools=!tools! -j' + str(num_jobs)) + env['MSVSREBUILDCOM'] = build_commandline('scons --directory="$(ProjectDir.TrimEnd(\'\\\'))" platform=windows progress=no target=$(Configuration) tools=!tools! vsproj=yes -j' + str(num_jobs)) + env['MSVSCLEANCOM'] = build_commandline('scons --directory="$(ProjectDir.TrimEnd(\'\\\'))" --clean platform=windows progress=no target=$(Configuration) tools=!tools! -j' + str(num_jobs)) # This version information (Win32, x64, Debug, Release, Release_Debug seems to be # required for Visual Studio to understand that it needs to generate an NMAKE diff --git a/misc/dist/html/default.html b/misc/dist/html/default.html index 9fae34f97e..0f78fc640e 100644 --- a/misc/dist/html/default.html +++ b/misc/dist/html/default.html @@ -225,12 +225,11 @@ $GODOT_HEAD_INCLUDE <script type="text/javascript" src="$GODOT_BASENAME.js"></script> <script type="text/javascript">//<![CDATA[ - var game = new Engine; + var engine = new Engine; (function() { const BASENAME = '$GODOT_BASENAME'; - const MEMORY_SIZE = $GODOT_TOTAL_MEMORY; const DEBUG_ENABLED = $GODOT_DEBUG_ENABLED; const INDETERMINATE_STATUS_STEP_MS = 100; @@ -246,8 +245,7 @@ $GODOT_HEAD_INCLUDE var indeterminiateStatusAnimationId = 0; setStatusMode('indeterminate'); - game.setCanvas(canvas); - game.setAsmjsMemorySize(MEMORY_SIZE); + engine.setCanvas(canvas); function setStatusMode(mode) { @@ -302,7 +300,7 @@ $GODOT_HEAD_INCLUDE }); }; - game.setProgressFunc((current, total) => { + engine.setProgressFunc((current, total) => { if (total > 0) { statusProgressInner.style.width = current/total * 100 + '%'; @@ -332,10 +330,6 @@ $GODOT_HEAD_INCLUDE outputRoot.style.display = 'block'; function print(text) { - if (arguments.length > 1) { - text = Array.prototype.slice.call(arguments).join(" "); - } - if (text.length <= 0) return; while (outputScroll.childElementCount >= OUTPUT_MSG_COUNT_MAX) { outputScroll.firstChild.remove(); } @@ -356,26 +350,31 @@ $GODOT_HEAD_INCLUDE }; function printError(text) { - print('**ERROR**' + ":", text); + if (!text.startsWith('**ERROR**: ')) { + text = '**ERROR**: ' + text; + } + print(text); } - game.setStdoutFunc(text => { + engine.setStdoutFunc(text => { print(text); console.log(text); }); - game.setStderrFunc(text => { + engine.setStderrFunc(text => { printError(text); console.warn(text); }); } - game.start(BASENAME + '.pck').then(() => { + engine.startGame(BASENAME + '.pck').then(() => { setStatusMode('hidden'); initializing = false; }, err => { - if (DEBUG_ENABLED) + if (DEBUG_ENABLED) { printError(err.message); + console.warn(err); + } setStatusNotice(err.message); setStatusMode('notice'); initializing = false; diff --git a/misc/travis/android-tools-linux.sh b/misc/travis/android-tools-linux.sh new file mode 100755 index 0000000000..04fb2eee21 --- /dev/null +++ b/misc/travis/android-tools-linux.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +# SDK +# https://dl.google.com/android/repository/sdk-tools-linux-3859397.zip +# SHA-256 444e22ce8ca0f67353bda4b85175ed3731cae3ffa695ca18119cbacef1c1bea0 +# latest version available here: https://developer.android.com/studio/index.html + +# NDK +# https://dl.google.com/android/repository/android-ndk-r15c-linux-x86_64.zip +# SHA-1 0bf02d4e8b85fd770fd7b9b2cdec57f9441f27a2 +# latest version available here: https://developer.android.com/ndk/downloads/index.html + +BASH_RC=~/.bashrc +GODOT_BUILD_TOOLS_PATH=./godot-dev/build-tools +mkdir -p $GODOT_BUILD_TOOLS_PATH +cd $GODOT_BUILD_TOOLS_PATH + +ANDROID_BASE_URL=http://dl.google.com/android/repository + +ANDROID_SDK_RELEASE=3859397 +ANDROID_SDK_DIR=android-sdk +ANDROID_SDK_FILENAME=sdk-tools-linux-$ANDROID_SDK_RELEASE.zip +ANDROID_SDK_URL=$ANDROID_BASE_URL/$ANDROID_SDK_FILENAME +ANDROID_SDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_SDK_DIR +ANDROID_SDK_SHA256=444e22ce8ca0f67353bda4b85175ed3731cae3ffa695ca18119cbacef1c1bea0 + +ANDROID_NDK_RELEASE=r15c +ANDROID_NDK_DIR=android-ndk +ANDROID_NDK_FILENAME=android-ndk-$ANDROID_NDK_RELEASE-linux-x86_64.zip +ANDROID_NDK_URL=$ANDROID_BASE_URL/$ANDROID_NDK_FILENAME +ANDROID_NDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_NDK_DIR +ANDROID_NDK_SHA1=0bf02d4e8b85fd770fd7b9b2cdec57f9441f27a2 + +echo +echo "Download and install Android development tools ..." +echo + +if [ ! -e $ANDROID_SDK_FILENAME ]; then + echo "Downloading: Android SDK ..." + curl -L -O $ANDROID_SDK_URL +else + echo $ANDROID_SDK_SHA1 $ANDROID_SDK_FILENAME > $ANDROID_SDK_FILENAME.sha1 + if [ $(shasum -a 256 < $ANDROID_SDK_FILENAME | awk '{print $1;}') != $ANDROID_SDK_SHA1 ]; then + echo "Downloading: Android SDK ..." + curl -L -O $ANDROID_SDK_URL + fi +fi + +if [ ! -d $ANDROID_SDK_DIR ]; then + echo "Extracting: Android SDK ..." + unzip -qq $ANDROID_SDK_FILENAME -d $ANDROID_SDK_DIR + echo +fi + +if [ ! -e $ANDROID_NDK_FILENAME ]; then + echo "Downloading: Android NDK ..." + curl -L -O $ANDROID_NDK_URL +else + echo $ANDROID_NDK_MD5 $ANDROID_NDK_FILENAME > $ANDROID_NDK_FILENAME.md5 + if [ $(shasum -a 1 < $ANDROID_NDK_FILENAME | awk '{print $1;}') != $ANDROID_NDK_SHA1 ]; then + echo "Downloading: Android NDK ..." + curl -L -O $ANDROID_NDK_URL + fi +fi + +if [ ! -d $ANDROID_NDK_DIR ]; then + echo "Extracting: Android NDK ..." + unzip -qq $ANDROID_NDK_FILENAME + mv android-ndk-$ANDROID_NDK_RELEASE $ANDROID_NDK_DIR + echo +fi + +echo "Installing: Android Tools ..." +#$ANDROID_SDK_DIR/tools/bin/sdkmanager --all +yes | $ANDROID_SDK_DIR/tools/bin/sdkmanager --licenses > /dev/null +$ANDROID_SDK_DIR/tools/bin/sdkmanager 'tools' > /dev/null +$ANDROID_SDK_DIR/tools/bin/sdkmanager 'platform-tools' > /dev/null +$ANDROID_SDK_DIR/tools/bin/sdkmanager 'build-tools;26.0.2' > /dev/null +echo + +EXPORT_VAL="export ANDROID_HOME=$ANDROID_SDK_PATH" +if ! grep -q "^$EXPORT_VAL" $BASH_RC; then + echo $EXPORT_VAL >> $BASH_RC +fi +#eval $EXPORT_VAL + +EXPORT_VAL="export ANDROID_NDK_ROOT=$ANDROID_NDK_PATH" +if ! grep -q "^$EXPORT_VAL" $BASH_RC; then + echo $EXPORT_VAL >> $BASH_RC +fi +#eval $EXPORT_VAL + +EXPORT_VAL="export PATH=$PATH:$ANDROID_SDK_PATH/tools" +if ! grep -q "^export PATH=.*$ANDROID_SDK_PATH/tools.*" $BASH_RC; then + echo $EXPORT_VAL >> $BASH_RC +fi +#eval $EXPORT_VAL + +EXPORT_VAL="export PATH=$PATH:$ANDROID_SDK_PATH/tools/bin" +if ! grep -q "^export PATH=.*$ANDROID_SDK_PATH/tools/bin.*" $BASH_RC; then + echo $EXPORT_VAL >> $BASH_RC +fi +#eval $EXPORT_VAL + +echo +echo "Done!" +echo diff --git a/misc/travis/android-tools-osx.sh b/misc/travis/android-tools-osx.sh new file mode 100755 index 0000000000..96125a3a3f --- /dev/null +++ b/misc/travis/android-tools-osx.sh @@ -0,0 +1,107 @@ +#!/bin/bash + +# SDK +# https://dl.google.com/android/repository/sdk-tools-darwin-3859397.zip +# SHA-256 4a81754a760fce88cba74d69c364b05b31c53d57b26f9f82355c61d5fe4b9df9 +# latest version available here: https://developer.android.com/studio/index.html + +# NDK +# https://dl.google.com/android/repository/android-ndk-r15c-darwin-x86_64.zip +# SHA-1 ea4b5d76475db84745aa8828000d009625fc1f98 +# latest version available here: https://developer.android.com/ndk/downloads/index.html + +BASH_RC=~/.bashrc +GODOT_BUILD_TOOLS_PATH=./godot-dev/build-tools +mkdir -p $GODOT_BUILD_TOOLS_PATH +cd $GODOT_BUILD_TOOLS_PATH + +ANDROID_BASE_URL=http://dl.google.com/android/repository + +ANDROID_SDK_RELEASE=3859397 +ANDROID_SDK_DIR=android-sdk +ANDROID_SDK_FILENAME=sdk-tools-darwin-$ANDROID_SDK_RELEASE.zip +ANDROID_SDK_URL=$ANDROID_BASE_URL/$ANDROID_SDK_FILENAME +ANDROID_SDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_SDK_DIR +ANDROID_SDK_SHA256=4a81754a760fce88cba74d69c364b05b31c53d57b26f9f82355c61d5fe4b9df9 + +ANDROID_NDK_RELEASE=r15c +ANDROID_NDK_DIR=android-ndk +ANDROID_NDK_FILENAME=android-ndk-$ANDROID_NDK_RELEASE-darwin-x86_64.zip +ANDROID_NDK_URL=$ANDROID_BASE_URL/$ANDROID_NDK_FILENAME +ANDROID_NDK_PATH=$GODOT_BUILD_TOOLS_PATH/$ANDROID_NDK_DIR +ANDROID_NDK_SHA1=ea4b5d76475db84745aa8828000d009625fc1f98 + +echo +echo "Download and install Android development tools ..." +echo + +if [ ! -e $ANDROID_SDK_FILENAME ]; then + echo "Downloading: Android SDK ..." + curl -L -O $ANDROID_SDK_URL +else + echo $ANDROID_SDK_SHA1 $ANDROID_SDK_FILENAME > $ANDROID_SDK_FILENAME.sha1 + if [ $(shasum -a 256 < $ANDROID_SDK_FILENAME | awk '{print $1;}') != $ANDROID_SDK_SHA1 ]; then + echo "Downloading: Android SDK ..." + curl -L -O $ANDROID_SDK_URL + fi +fi + +if [ ! -d $ANDROID_SDK_DIR ]; then + echo "Extracting: Android SDK ..." + mkdir -p $ANDROID_SDK_DIR && tar -xf $ANDROID_SDK_FILENAME -C $ANDROID_SDK_DIR + echo +fi + +if [ ! -e $ANDROID_NDK_FILENAME ]; then + echo "Downloading: Android NDK ..." + curl -L -O $ANDROID_NDK_URL +else + echo $ANDROID_NDK_MD5 $ANDROID_NDK_FILENAME > $ANDROID_NDK_FILENAME.md5 + if [ $(shasum -a 1 < $ANDROID_NDK_FILENAME | awk '{print $1;}') != $ANDROID_NDK_SHA1 ]; then + echo "Downloading: Android NDK ..." + curl -L -O $ANDROID_NDK_URL + fi +fi + +if [ ! -d $ANDROID_NDK_DIR ]; then + echo "Extracting: Android NDK ..." + tar -xf $ANDROID_NDK_FILENAME + mv android-ndk-$ANDROID_NDK_RELEASE $ANDROID_NDK_DIR + echo +fi + +echo "Installing: Android Tools ..." +#$ANDROID_SDK_DIR/tools/bin/sdkmanager --all +yes | $ANDROID_SDK_DIR/tools/bin/sdkmanager --licenses > /dev/null +$ANDROID_SDK_DIR/tools/bin/sdkmanager 'tools' > /dev/null +$ANDROID_SDK_DIR/tools/bin/sdkmanager 'platform-tools' > /dev/null +$ANDROID_SDK_DIR/tools/bin/sdkmanager 'build-tools;26.0.2' > /dev/null +echo + +EXPORT_VAL="export ANDROID_HOME=$ANDROID_SDK_PATH" +if ! grep -q "^$EXPORT_VAL" $BASH_RC; then + echo $EXPORT_VAL >> $BASH_RC +fi +#eval $EXPORT_VAL + +EXPORT_VAL="export ANDROID_NDK_ROOT=$ANDROID_NDK_PATH" +if ! grep -q "^$EXPORT_VAL" $BASH_RC; then + echo $EXPORT_VAL >> $BASH_RC +fi +#eval $EXPORT_VAL + +EXPORT_VAL="export PATH=$PATH:$ANDROID_SDK_PATH/tools" +if ! grep -q "^export PATH=.*$ANDROID_SDK_PATH/tools.*" $BASH_RC; then + echo $EXPORT_VAL >> $BASH_RC +fi +#eval $EXPORT_VAL + +EXPORT_VAL="export PATH=$PATH:$ANDROID_SDK_PATH/tools/bin" +if ! grep -q "^export PATH=.*$ANDROID_SDK_PATH/tools/bin.*" $BASH_RC; then + echo $EXPORT_VAL >> $BASH_RC +fi +#eval $EXPORT_VAL + +echo +echo "Done!" +echo diff --git a/misc/travis/ccache-osx.sh b/misc/travis/ccache-osx.sh new file mode 100755 index 0000000000..5ce7a80cbc --- /dev/null +++ b/misc/travis/ccache-osx.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +echo +echo "Download and install ccache ..." +echo + +echo "Downloading sources ..." +curl -L -O https://www.samba.org/ftp/ccache/ccache-3.3.4.tar.gz # latest version available here: https://ccache.samba.org/download.html + +echo "Extracting to build directory ..." +tar xzf ccache-3.3.4.tar.gz +cd ccache-3.3.4 + +echo "Compiling sources ..." +./configure --prefix=/usr/local --with-bundled-zlib > /dev/null +make + +echo "Installing ..." + +mkdir /usr/local/opt/ccache + +mkdir /usr/local/opt/ccache/bin +cp ccache /usr/local/opt/ccache/bin +ln -s /usr/local/opt/ccache/bin/ccache /usr/local/bin/ccache + +mkdir /usr/local/opt/ccache/libexec +links=( + clang + clang++ + cc + gcc gcc2 gcc3 gcc-3.3 gcc-4.0 gcc-4.2 gcc-4.3 gcc-4.4 gcc-4.5 gcc-4.6 gcc-4.7 gcc-4.8 gcc-4.9 gcc-5 gcc-6 gcc-7 + c++ c++3 c++-3.3 c++-4.0 c++-4.2 c++-4.3 c++-4.4 c++-4.5 c++-4.6 c++-4.7 c++-4.8 c++-4.9 c++-5 c++-6 c++-7 + g++ g++2 g++3 g++-3.3 g++-4.0 g++-4.2 g++-4.3 g++-4.4 g++-4.5 g++-4.6 g++-4.7 g++-4.8 g++-4.9 g++-5 g++-6 g++-7 +) +for link in "${links[@]}"; do + ln -s ../bin/ccache /usr/local/opt/ccache/libexec/$link +done +#/usr/local/bin/ccache -M 2G +cd $TRAVIS_BUILD_DIR + +echo +echo "Done!" +echo diff --git a/misc/travis/scons-local-osx.sh b/misc/travis/scons-local-osx.sh new file mode 100755 index 0000000000..d9d7d98b38 --- /dev/null +++ b/misc/travis/scons-local-osx.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +echo +echo "Download and install Scons local package ..." +echo + +echo "Downloading sources ..." +curl -L -O http://prdownloads.sourceforge.net/scons/scons-local-3.0.0.zip # latest version available here: http://scons.org/pages/download.html + +echo "Extracting to build directory ..." +unzip -qq -n scons-local-3.0.0.zip -d $TRAVIS_BUILD_DIR/scons-local + +echo "Installing symlinks ..." +ln -s $TRAVIS_BUILD_DIR/scons-local/scons.py /usr/local/bin/scons + +echo +echo "Done!" +echo diff --git a/modules/SCsub b/modules/SCsub index d1c0cdc05c..c1cf5a6c1a 100644 --- a/modules/SCsub +++ b/modules/SCsub @@ -9,7 +9,6 @@ Export('env_modules') env.modules_sources = [ "register_module_types.gen.cpp", ] -# env.add_source_files(env.modules_sources,"*.cpp") Export('env') for x in env.module_list: diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index 96875924a5..7f95d16ba6 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -635,6 +635,28 @@ float BulletPhysicsServer::body_get_param(RID p_body, BodyParameter p_param) con return body->get_param(p_param); } +void BulletPhysicsServer::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) { + RigidBodyBullet *body = rigid_body_owner.get(p_body); + ERR_FAIL_COND(!body); + + if (body->get_kinematic_utilities()) { + + body->get_kinematic_utilities()->setSafeMargin(p_margin); + } +} + +real_t BulletPhysicsServer::body_get_kinematic_safe_margin(RID p_body) const { + RigidBodyBullet *body = rigid_body_owner.get(p_body); + ERR_FAIL_COND_V(!body, 0); + + if (body->get_kinematic_utilities()) { + + return body->get_kinematic_utilities()->safe_margin; + } + + return 0; +} + void BulletPhysicsServer::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { RigidBodyBullet *body = rigid_body_owner.get(p_body); ERR_FAIL_COND(!body); @@ -797,12 +819,12 @@ PhysicsDirectBodyState *BulletPhysicsServer::body_get_direct_state(RID p_body) { return BulletPhysicsDirectBodyState::get_singleton(body); } -bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, float p_margin, MotionResult *r_result) { +bool BulletPhysicsServer::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, MotionResult *r_result) { RigidBodyBullet *body = rigid_body_owner.get(p_body); ERR_FAIL_COND_V(!body, false); ERR_FAIL_COND_V(!body->get_space(), false); - return body->get_space()->test_body_motion(body, p_from, p_motion, p_margin, r_result); + return body->get_space()->test_body_motion(body, p_from, p_motion, r_result); } RID BulletPhysicsServer::soft_body_create(bool p_init_sleeping) { diff --git a/modules/bullet/bullet_physics_server.h b/modules/bullet/bullet_physics_server.h index 04d9d89594..ad8137ee2f 100644 --- a/modules/bullet/bullet_physics_server.h +++ b/modules/bullet/bullet_physics_server.h @@ -210,6 +210,9 @@ public: virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value); virtual float body_get_param(RID p_body, BodyParameter p_param) const; + virtual void body_set_kinematic_safe_margin(RID p_body, real_t p_margin); + virtual real_t body_get_kinematic_safe_margin(RID p_body) const; + virtual void body_set_state(RID p_body, BodyState p_state, const Variant &p_variant); virtual Variant body_get_state(RID p_body, BodyState p_state) const; @@ -247,7 +250,7 @@ public: // this function only works on physics process, errors and returns null otherwise virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body); - virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, float p_margin = 0.001, MotionResult *r_result = NULL); + virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, MotionResult *r_result = NULL); /* SOFT BODY API */ diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp index 5739568d91..91a049b1f3 100644 --- a/modules/bullet/collision_object_bullet.cpp +++ b/modules/bullet/collision_object_bullet.cpp @@ -93,15 +93,19 @@ void CollisionObjectBullet::setupBulletCollisionObject(btCollisionObject *p_coll void CollisionObjectBullet::add_collision_exception(const CollisionObjectBullet *p_ignoreCollisionObject) { exceptions.insert(p_ignoreCollisionObject->get_self()); bt_collision_object->setIgnoreCollisionCheck(p_ignoreCollisionObject->bt_collision_object, true); + if (space) + space->get_broadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bt_collision_object->getBroadphaseHandle(), space->get_dispatcher()); } void CollisionObjectBullet::remove_collision_exception(const CollisionObjectBullet *p_ignoreCollisionObject) { exceptions.erase(p_ignoreCollisionObject->get_self()); bt_collision_object->setIgnoreCollisionCheck(p_ignoreCollisionObject->bt_collision_object, false); + if (space) + space->get_broadphase()->getOverlappingPairCache()->cleanProxyFromPairs(bt_collision_object->getBroadphaseHandle(), space->get_dispatcher()); } bool CollisionObjectBullet::has_collision_exception(const CollisionObjectBullet *p_otherCollisionObject) const { - return !bt_collision_object->checkCollideWithOverride(p_otherCollisionObject->bt_collision_object); + return !bt_collision_object->checkCollideWith(p_otherCollisionObject->bt_collision_object); } void CollisionObjectBullet::set_collision_enabled(bool p_enabled) { diff --git a/modules/bullet/config.py b/modules/bullet/config.py index b00ea18328..0a31c2e503 100644 --- a/modules/bullet/config.py +++ b/modules/bullet/config.py @@ -3,4 +3,12 @@ def can_build(platform): def configure(env): pass - + +def get_doc_classes(): + return [ + "BulletPhysicsDirectBodyState", + "BulletPhysicsServer", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml b/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml new file mode 100644 index 0000000000..831b346942 --- /dev/null +++ b/modules/bullet/doc_classes/BulletPhysicsDirectBodyState.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="BulletPhysicsDirectBodyState" inherits="PhysicsDirectBodyState" category="Core" version="3.0-alpha"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + </methods> + <constants> + </constants> +</class> diff --git a/modules/bullet/doc_classes/BulletPhysicsServer.xml b/modules/bullet/doc_classes/BulletPhysicsServer.xml new file mode 100644 index 0000000000..4b5c2e6d83 --- /dev/null +++ b/modules/bullet/doc_classes/BulletPhysicsServer.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="BulletPhysicsServer" inherits="PhysicsServer" category="Core" version="3.0-alpha"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + </methods> + <constants> + </constants> +</class> diff --git a/modules/bullet/godot_result_callbacks.cpp b/modules/bullet/godot_result_callbacks.cpp index 409d12f080..cbf30c8a2e 100644 --- a/modules/bullet/godot_result_callbacks.cpp +++ b/modules/bullet/godot_result_callbacks.cpp @@ -77,7 +77,7 @@ btScalar GodotAllConvexResultCallback::addSingleResult(btCollisionWorld::LocalCo PhysicsDirectSpaceState::ShapeResult &result = m_results[count]; - result.shape = convexResult.m_localShapeInfo->m_shapePart; + result.shape = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID result.rid = gObj->get_self(); result.collider_id = gObj->get_instance_id(); result.collider = 0 == result.collider_id ? NULL : ObjectDB::get_instance(result.collider_id); @@ -122,7 +122,7 @@ bool GodotClosestConvexResultCallback::needsCollision(btBroadphaseProxy *proxy0) btScalar GodotClosestConvexResultCallback::addSingleResult(btCollisionWorld::LocalConvexResult &convexResult, bool normalInWorldSpace) { btScalar res = btCollisionWorld::ClosestConvexResultCallback::addSingleResult(convexResult, normalInWorldSpace); - m_shapePart = convexResult.m_localShapeInfo->m_shapePart; + m_shapeId = convexResult.m_localShapeInfo->m_triangleIndex; // "m_triangleIndex" Is a odd name but contains the compound shape ID return res; } @@ -243,49 +243,20 @@ btScalar GodotRestInfoContactResultCallback::addSingleResult(btManifoldPoint &cp return cp.getDistance(); } -bool GodotRecoverAndClosestContactResultCallback::needsCollision(btBroadphaseProxy *proxy0) const { - const bool needs = GodotFilterCallback::test_collision_filters(m_collisionFilterGroup, m_collisionFilterMask, proxy0->m_collisionFilterGroup, proxy0->m_collisionFilterMask); - if (needs) { - btCollisionObject *btObj = static_cast<btCollisionObject *>(proxy0->m_clientObject); - CollisionObjectBullet *gObj = static_cast<CollisionObjectBullet *>(btObj->getUserPointer()); - if (gObj == m_self_object) { - return false; - } else { - if (m_ignore_areas && gObj->getType() == CollisionObjectBullet::TYPE_AREA) { - return false; - } else if (m_self_object->has_collision_exception(gObj)) { - return false; - } - } - return true; - } else { - return false; - } -} +void GodotDeepPenetrationContactResultCallback::addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorldOnB, btScalar depth) { -btScalar GodotRecoverAndClosestContactResultCallback::addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1) { - - if (cp.getDistance() < -MAX_PENETRATION_DEPTH) { - if (m_most_penetrated_distance > cp.getDistance()) { - m_most_penetrated_distance = cp.getDistance(); - - // take other object - btScalar sign(1); - if (m_self_object == colObj0Wrap->getCollisionObject()->getUserPointer()) { - m_pointCollisionObject = colObj1Wrap->getCollisionObject(); - m_other_compound_shape_index = cp.m_index1; - } else { - m_pointCollisionObject = colObj0Wrap->getCollisionObject(); - sign = -1; - m_other_compound_shape_index = cp.m_index0; - } + if (depth < 0) { + // Has penetration + if (m_most_penetrated_distance > depth) { - m_pointNormalWorld = cp.m_normalWorldOnB * sign; - m_pointWorld = cp.getPositionWorldOnB(); - m_penetration_distance = cp.getDistance(); + bool isSwapped = m_manifoldPtr->getBody0() != m_body0Wrap->getCollisionObject(); - m_recover_penetration -= cp.m_normalWorldOnB * sign * (cp.getDistance() + MAX_PENETRATION_DEPTH); + m_most_penetrated_distance = depth; + m_pointCollisionObject = (isSwapped ? m_body0Wrap : m_body1Wrap)->getCollisionObject(); + m_other_compound_shape_index = isSwapped ? m_index1 : m_index0; + m_pointNormalWorld = isSwapped ? normalOnBInWorld * -1 : normalOnBInWorld; + m_pointWorld = isSwapped ? (pointInWorldOnB + normalOnBInWorld * depth) : pointInWorldOnB; + m_penetration_distance = depth; } } - return 1; } diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h index d505bd0de1..ba5142676b 100644 --- a/modules/bullet/godot_result_callbacks.h +++ b/modules/bullet/godot_result_callbacks.h @@ -36,8 +36,6 @@ #include "btBulletDynamicsCommon.h" #include "servers/physics_server.h" -#define MAX_PENETRATION_DEPTH 0.005 - class RigidBodyBullet; /// This class is required to implement custom collision behaviour in the broadphase @@ -90,7 +88,7 @@ public: struct GodotClosestConvexResultCallback : public btCollisionWorld::ClosestConvexResultCallback { public: const Set<RID> *m_exclude; - int m_shapePart; + int m_shapeId; GodotClosestConvexResultCallback(const btVector3 &convexFromWorld, const btVector3 &convexToWorld, const Set<RID> *p_exclude) : btCollisionWorld::ClosestConvexResultCallback(convexFromWorld, convexToWorld), m_exclude(p_exclude) {} @@ -151,39 +149,31 @@ public: virtual btScalar addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1); }; -struct GodotRecoverAndClosestContactResultCallback : public btCollisionWorld::ContactResultCallback { -public: +struct GodotDeepPenetrationContactResultCallback : public btManifoldResult { btVector3 m_pointNormalWorld; btVector3 m_pointWorld; btScalar m_penetration_distance; int m_other_compound_shape_index; const btCollisionObject *m_pointCollisionObject; - const RigidBodyBullet *m_self_object; - bool m_ignore_areas; - btScalar m_most_penetrated_distance; - btVector3 m_recover_penetration; - - GodotRecoverAndClosestContactResultCallback() - : m_pointCollisionObject(NULL), m_penetration_distance(0), m_other_compound_shape_index(0), m_self_object(NULL), m_ignore_areas(true), m_most_penetrated_distance(1e20), m_recover_penetration(0, 0, 0) {} - GodotRecoverAndClosestContactResultCallback(const RigidBodyBullet *p_self_object, bool p_ignore_areas) - : m_pointCollisionObject(NULL), m_penetration_distance(0), m_other_compound_shape_index(0), m_self_object(p_self_object), m_ignore_areas(p_ignore_areas), m_most_penetrated_distance(9999999999), m_recover_penetration(0, 0, 0) {} + GodotDeepPenetrationContactResultCallback(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap) + : btManifoldResult(body0Wrap, body1Wrap), + m_pointCollisionObject(NULL), + m_penetration_distance(0), + m_other_compound_shape_index(0), + m_most_penetrated_distance(1e20) {} void reset() { m_pointCollisionObject = NULL; m_most_penetrated_distance = 1e20; - m_recover_penetration.setZero(); } bool hasHit() { return m_pointCollisionObject; } - virtual bool needsCollision(btBroadphaseProxy *proxy0) const; - - virtual btScalar addSingleResult(btManifoldPoint &cp, const btCollisionObjectWrapper *colObj0Wrap, int partId0, int index0, const btCollisionObjectWrapper *colObj1Wrap, int partId1, int index1); + virtual void addContactPoint(const btVector3 &normalOnBInWorld, const btVector3 &pointInWorld, btScalar depth); }; - #endif // GODOT_RESULT_CALLBACKS_H diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index 5d0513db76..98ae82bc5f 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -177,31 +177,21 @@ PhysicsDirectSpaceState *BulletPhysicsDirectBodyState::get_space_state() { } RigidBodyBullet::KinematicUtilities::KinematicUtilities(RigidBodyBullet *p_owner) - : m_owner(p_owner), m_margin(0.01) // Godot default margin 0.001 -{ - m_ghostObject = bulletnew(btPairCachingGhostObject); - - int clearedCurrentFlags = m_ghostObject->getCollisionFlags(); - clearedCurrentFlags &= ~(btCollisionObject::CF_KINEMATIC_OBJECT | btCollisionObject::CF_STATIC_OBJECT); - - m_ghostObject->setCollisionFlags(clearedCurrentFlags | btCollisionObject::CF_KINEMATIC_OBJECT); - m_ghostObject->setUserPointer(p_owner); - m_ghostObject->setUserIndex(TYPE_KINEMATIC_GHOST_BODY); - - resetDefShape(); + : owner(p_owner), + safe_margin(0.001) { } RigidBodyBullet::KinematicUtilities::~KinematicUtilities() { - just_delete_shapes(m_shapes.size()); // don't need to resize - bulletdelete(m_ghostObject); + just_delete_shapes(shapes.size()); // don't need to resize } -void RigidBodyBullet::KinematicUtilities::resetDefShape() { - m_ghostObject->setCollisionShape(BulletPhysicsServer::get_empty_shape()); +void RigidBodyBullet::KinematicUtilities::setSafeMargin(btScalar p_margin) { + safe_margin = p_margin; + copyAllOwnerShapes(); } void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() { - const Vector<CollisionObjectBullet::ShapeWrapper> &shapes_wrappers(m_owner->get_shapes_wrappers()); + const Vector<CollisionObjectBullet::ShapeWrapper> &shapes_wrappers(owner->get_shapes_wrappers()); const int shapes_count = shapes_wrappers.size(); just_delete_shapes(shapes_count); @@ -213,35 +203,35 @@ void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() { if (!shape_wrapper->active) { continue; } - m_shapes[i].transform = shape_wrapper->transform; + shapes[i].transform = shape_wrapper->transform; - btConvexShape *&kin_shape_ref = m_shapes[i].shape; + btConvexShape *&kin_shape_ref = shapes[i].shape; switch (shape_wrapper->shape->get_type()) { case PhysicsServer::SHAPE_SPHERE: { SphereShapeBullet *sphere = static_cast<SphereShapeBullet *>(shape_wrapper->shape); - kin_shape_ref = ShapeBullet::create_shape_sphere(sphere->get_radius() * m_owner->body_scale[0] + m_margin); + kin_shape_ref = ShapeBullet::create_shape_sphere(sphere->get_radius() * owner->body_scale[0] + safe_margin); break; } case PhysicsServer::SHAPE_BOX: { BoxShapeBullet *box = static_cast<BoxShapeBullet *>(shape_wrapper->shape); - kin_shape_ref = ShapeBullet::create_shape_box((box->get_half_extents() * m_owner->body_scale) + btVector3(m_margin, m_margin, m_margin)); + kin_shape_ref = ShapeBullet::create_shape_box((box->get_half_extents() * owner->body_scale) + btVector3(safe_margin, safe_margin, safe_margin)); break; } case PhysicsServer::SHAPE_CAPSULE: { CapsuleShapeBullet *capsule = static_cast<CapsuleShapeBullet *>(shape_wrapper->shape); - kin_shape_ref = ShapeBullet::create_shape_capsule(capsule->get_radius() * m_owner->body_scale[0] + m_margin, capsule->get_height() * m_owner->body_scale[1] + m_margin); + kin_shape_ref = ShapeBullet::create_shape_capsule(capsule->get_radius() * owner->body_scale[0] + safe_margin, capsule->get_height() * owner->body_scale[1] + safe_margin); break; } case PhysicsServer::SHAPE_CONVEX_POLYGON: { ConvexPolygonShapeBullet *godot_convex = static_cast<ConvexPolygonShapeBullet *>(shape_wrapper->shape); kin_shape_ref = ShapeBullet::create_shape_convex(godot_convex->vertices); - kin_shape_ref->setLocalScaling(m_owner->body_scale + btVector3(m_margin, m_margin, m_margin)); + kin_shape_ref->setLocalScaling(owner->body_scale + btVector3(safe_margin, safe_margin, safe_margin)); break; } case PhysicsServer::SHAPE_RAY: { RayShapeBullet *godot_ray = static_cast<RayShapeBullet *>(shape_wrapper->shape); - kin_shape_ref = ShapeBullet::create_shape_ray(godot_ray->length * m_owner->body_scale[1] + m_margin); + kin_shape_ref = ShapeBullet::create_shape_ray(godot_ray->length * owner->body_scale[1] + safe_margin); break; } default: @@ -252,12 +242,12 @@ void RigidBodyBullet::KinematicUtilities::copyAllOwnerShapes() { } void RigidBodyBullet::KinematicUtilities::just_delete_shapes(int new_size) { - for (int i = m_shapes.size() - 1; 0 <= i; --i) { - if (m_shapes[i].shape) { - bulletdelete(m_shapes[i].shape); + for (int i = shapes.size() - 1; 0 <= i; --i) { + if (shapes[i].shape) { + bulletdelete(shapes[i].shape); } } - m_shapes.resize(new_size); + shapes.resize(new_size); } RigidBodyBullet::RigidBodyBullet() diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h index 0cf3f9f605..ab3c3e58b2 100644 --- a/modules/bullet/rigid_body_bullet.h +++ b/modules/bullet/rigid_body_bullet.h @@ -162,17 +162,15 @@ public: }; struct KinematicUtilities { - RigidBodyBullet *m_owner; - btScalar m_margin; - btManifoldArray m_manifoldArray; ///keep track of the contact manifolds - class btPairCachingGhostObject *m_ghostObject; - Vector<KinematicShape> m_shapes; + RigidBodyBullet *owner; + btScalar safe_margin; + Vector<KinematicShape> shapes; KinematicUtilities(RigidBodyBullet *p_owner); ~KinematicUtilities(); + void setSafeMargin(btScalar p_margin); /// Used to set the default shape to ghost - void resetDefShape(); void copyAllOwnerShapes(); private: diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index af7f511fab..e4d049b00d 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -50,9 +50,6 @@ #include "ustring.h" #include <assert.h> -// test only -//#include "scene/3d/immediate_geometry.h" - BulletPhysicsDirectSpaceState::BulletPhysicsDirectSpaceState(SpaceBullet *p_space) : PhysicsDirectSpaceState(), space(p_space) {} @@ -118,12 +115,13 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); - btConvexShape *btConvex = dynamic_cast<btConvexShape *>(shape->create_bt_shape()); - if (!btConvex) { - bulletdelete(btConvex); + btCollisionShape *btShape = shape->create_bt_shape(); + if (!btShape->isConvex()) { + bulletdelete(btShape); ERR_PRINTS("The shape is not a convex shape, then is not supported: shape type: " + itos(shape->get_type())); return 0; } + btConvexShape *btConvex = static_cast<btConvexShape *>(btShape); btVector3 scale_with_margin; G_TO_B(p_xform.basis.get_scale(), scale_with_margin); @@ -150,12 +148,13 @@ int BulletPhysicsDirectSpaceState::intersect_shape(const RID &p_shape, const Tra bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transform &p_xform, const Vector3 &p_motion, float p_margin, float &p_closest_safe, float &p_closest_unsafe, const Set<RID> &p_exclude, uint32_t p_collision_layer, uint32_t p_object_type_mask, ShapeRestInfo *r_info) { ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); - btConvexShape *bt_convex_shape = dynamic_cast<btConvexShape *>(shape->create_bt_shape()); - if (!bt_convex_shape) { - bulletdelete(bt_convex_shape); + btCollisionShape *btShape = shape->create_bt_shape(); + if (!btShape->isConvex()) { + bulletdelete(btShape); ERR_PRINTS("The shape is not a convex shape, then is not supported: shape type: " + itos(shape->get_type())); return 0; } + btConvexShape *bt_convex_shape = static_cast<btConvexShape *>(btShape); btVector3 bt_motion; G_TO_B(p_motion, bt_motion); @@ -174,19 +173,21 @@ bool BulletPhysicsDirectSpaceState::cast_motion(const RID &p_shape, const Transf btResult.m_collisionFilterGroup = p_collision_layer; btResult.m_collisionFilterMask = p_object_type_mask; - space->dynamicsWorld->convexSweepTest(bt_convex_shape, bt_xform_from, bt_xform_to, btResult); + space->dynamicsWorld->convexSweepTest(bt_convex_shape, bt_xform_from, bt_xform_to, btResult, 0.002); - if (btResult.hasHit()) { - if (btCollisionObject::CO_RIGID_BODY == btResult.m_hitCollisionObject->getInternalType()) { - B_TO_G(static_cast<const btRigidBody *>(btResult.m_hitCollisionObject)->getVelocityInLocalPoint(btResult.m_hitPointWorld), r_info->linear_velocity); + if (r_info) { + if (btResult.hasHit()) { + if (btCollisionObject::CO_RIGID_BODY == btResult.m_hitCollisionObject->getInternalType()) { + B_TO_G(static_cast<const btRigidBody *>(btResult.m_hitCollisionObject)->getVelocityInLocalPoint(btResult.m_hitPointWorld), r_info->linear_velocity); + } + CollisionObjectBullet *collision_object = static_cast<CollisionObjectBullet *>(btResult.m_hitCollisionObject->getUserPointer()); + p_closest_safe = p_closest_unsafe = btResult.m_closestHitFraction; + B_TO_G(btResult.m_hitPointWorld, r_info->point); + B_TO_G(btResult.m_hitNormalWorld, r_info->normal); + r_info->rid = collision_object->get_self(); + r_info->collider_id = collision_object->get_instance_id(); + r_info->shape = btResult.m_shapeId; } - CollisionObjectBullet *collision_object = static_cast<CollisionObjectBullet *>(btResult.m_hitCollisionObject->getUserPointer()); - p_closest_safe = p_closest_unsafe = btResult.m_closestHitFraction; - B_TO_G(btResult.m_hitPointWorld, r_info->point); - B_TO_G(btResult.m_hitNormalWorld, r_info->normal); - r_info->rid = collision_object->get_self(); - r_info->collider_id = collision_object->get_instance_id(); - r_info->shape = btResult.m_shapePart; } bulletdelete(bt_convex_shape); @@ -200,12 +201,13 @@ bool BulletPhysicsDirectSpaceState::collide_shape(RID p_shape, const Transform & ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); - btConvexShape *btConvex = dynamic_cast<btConvexShape *>(shape->create_bt_shape()); - if (!btConvex) { - bulletdelete(btConvex); + btCollisionShape *btShape = shape->create_bt_shape(); + if (!btShape->isConvex()) { + bulletdelete(btShape); ERR_PRINTS("The shape is not a convex shape, then is not supported: shape type: " + itos(shape->get_type())); return 0; } + btConvexShape *btConvex = static_cast<btConvexShape *>(btShape); btVector3 scale_with_margin; G_TO_B(p_shape_xform.basis.get_scale(), scale_with_margin); @@ -234,12 +236,13 @@ bool BulletPhysicsDirectSpaceState::rest_info(RID p_shape, const Transform &p_sh ShapeBullet *shape = space->get_physics_server()->get_shape_owner()->get(p_shape); - btConvexShape *btConvex = dynamic_cast<btConvexShape *>(shape->create_bt_shape()); - if (!btConvex) { - bulletdelete(btConvex); + btCollisionShape *btShape = shape->create_bt_shape(); + if (!btShape->isConvex()) { + bulletdelete(btShape); ERR_PRINTS("The shape is not a convex shape, then is not supported: shape type: " + itos(shape->get_type())); return 0; } + btConvexShape *btConvex = static_cast<btConvexShape *>(btShape); btVector3 scale_with_margin; G_TO_B(p_shape_xform.basis.get_scale() + Vector3(p_margin, p_margin, p_margin), scale_with_margin); @@ -281,10 +284,6 @@ Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_ btVector3 bt_point; G_TO_B(p_point, bt_point); - btGjkEpaPenetrationDepthSolver gjk_epa_pen_solver; - btVoronoiSimplexSolver gjk_simplex_solver; - gjk_simplex_solver.setEqualVertexThreshold(0.); - btSphereShape point_shape(0.); btCollisionShape *shape; @@ -308,7 +307,7 @@ Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_ input.m_transformB = body_transform * child_transform; btPointCollector result; - btGjkPairDetector gjk_pair_detector(&point_shape, convex_shape, &gjk_simplex_solver, &gjk_epa_pen_solver); + btGjkPairDetector gjk_pair_detector(&point_shape, convex_shape, space->gjk_simplex_solver, space->gjk_epa_pen_solver); gjk_pair_detector.getClosestPoints(input, result, 0); if (out_distance > result.m_distance) { @@ -558,13 +557,10 @@ btScalar calculateGodotCombinedRestitution(const btCollisionObject *body0, const } void SpaceBullet::create_empty_world(bool p_create_soft_world) { - assert(NULL == broadphase); - assert(NULL == dispatcher); - assert(NULL == solver); - assert(NULL == collisionConfiguration); - assert(NULL == dynamicsWorld); - assert(NULL == ghostPairCallback); - assert(NULL == godotFilterCallback); + + gjk_epa_pen_solver = bulletnew(btGjkEpaPenetrationDepthSolver); + gjk_simplex_solver = bulletnew(btVoronoiSimplexSolver); + gjk_simplex_solver->setEqualVertexThreshold(0.f); void *world_mem; if (p_create_soft_world) { @@ -611,13 +607,6 @@ void SpaceBullet::create_empty_world(bool p_create_soft_world) { } void SpaceBullet::destroy_world() { - assert(NULL != broadphase); - assert(NULL != dispatcher); - assert(NULL != solver); - assert(NULL != collisionConfiguration); - assert(NULL != dynamicsWorld); - assert(NULL != ghostPairCallback); - assert(NULL != godotFilterCallback); /// The world elements (like: Collision Objects, Constraints, Shapes) are managed by godot @@ -637,14 +626,13 @@ void SpaceBullet::destroy_world() { bulletdelete(dispatcher); bulletdelete(collisionConfiguration); bulletdelete(soft_body_world_info); + bulletdelete(gjk_simplex_solver); + bulletdelete(gjk_epa_pen_solver); } void SpaceBullet::check_ghost_overlaps() { /// Algorith support variables - btGjkEpaPenetrationDepthSolver gjk_epa_pen_solver; - btVoronoiSimplexSolver gjk_simplex_solver; - gjk_simplex_solver.setEqualVertexThreshold(0.f); btConvexShape *other_body_shape; btConvexShape *area_shape; btGjkPairDetector::ClosestPointInput gjk_input; @@ -701,7 +689,7 @@ void SpaceBullet::check_ghost_overlaps() { gjk_input.m_transformB = otherObject->get_transform__bullet() * otherObject->get_compound_shape()->getChildTransform(z); btPointCollector result; - btGjkPairDetector gjk_pair_detector(area_shape, other_body_shape, &gjk_simplex_solver, &gjk_epa_pen_solver); + btGjkPairDetector gjk_pair_detector(area_shape, other_body_shape, gjk_simplex_solver, gjk_epa_pen_solver); gjk_pair_detector.getClosestPoints(gjk_input, result, 0); if (0 >= result.m_distance) { @@ -743,23 +731,11 @@ void SpaceBullet::check_body_collision() { const int numManifolds = dynamicsWorld->getDispatcher()->getNumManifolds(); for (int i = 0; i < numManifolds; ++i) { btPersistentManifold *contactManifold = dynamicsWorld->getDispatcher()->getManifoldByIndexInternal(i); - const btCollisionObject *obA = contactManifold->getBody0(); - const btCollisionObject *obB = contactManifold->getBody1(); - - if (btCollisionObject::CO_RIGID_BODY != obA->getInternalType() || btCollisionObject::CO_RIGID_BODY != obB->getInternalType()) { - // This checks is required to be sure the ghost object is skipped - // The ghost object "getUserPointer" return the BodyBullet owner so this check is required - continue; - } - - // Asserts all Godot objects are assigned - assert(NULL != obA->getUserPointer()); - assert(NULL != obB->getUserPointer()); // I know this static cast is a bit risky. But I'm checking its type just after it. // This allow me to avoid a lot of other cast and checks - RigidBodyBullet *bodyA = static_cast<RigidBodyBullet *>(obA->getUserPointer()); - RigidBodyBullet *bodyB = static_cast<RigidBodyBullet *>(obB->getUserPointer()); + RigidBodyBullet *bodyA = static_cast<RigidBodyBullet *>(contactManifold->getBody0()->getUserPointer()); + RigidBodyBullet *bodyB = static_cast<RigidBodyBullet *>(contactManifold->getBody1()->getUserPointer()); if (CollisionObjectBullet::TYPE_RIGID_BODY == bodyA->getType() && CollisionObjectBullet::TYPE_RIGID_BODY == bodyB->getType()) { if (!bodyA->can_add_collision() && !bodyB->can_add_collision()) { @@ -784,13 +760,13 @@ void SpaceBullet::check_body_collision() { if (bodyA->can_add_collision()) { B_TO_G(pt.getPositionWorldOnB(), collisionWorldPosition); /// pt.m_localPointB Doesn't report the exact point in local space - B_TO_G(pt.getPositionWorldOnB() - obB->getWorldTransform().getOrigin(), collisionLocalPosition); + B_TO_G(pt.getPositionWorldOnB() - contactManifold->getBody1()->getWorldTransform().getOrigin(), collisionLocalPosition); bodyA->add_collision_object(bodyB, collisionWorldPosition, collisionLocalPosition, normalOnB, pt.m_index1, pt.m_index0); } if (bodyB->can_add_collision()) { B_TO_G(pt.getPositionWorldOnA(), collisionWorldPosition); /// pt.m_localPointA Doesn't report the exact point in local space - B_TO_G(pt.getPositionWorldOnA() - obA->getWorldTransform().getOrigin(), collisionLocalPosition); + B_TO_G(pt.getPositionWorldOnA() - contactManifold->getBody0()->getWorldTransform().getOrigin(), collisionLocalPosition); bodyB->add_collision_object(bodyA, collisionWorldPosition, collisionLocalPosition, normalOnB * -1, pt.m_index0, pt.m_index1); } @@ -807,7 +783,8 @@ void SpaceBullet::check_body_collision() { void SpaceBullet::update_gravity() { btVector3 btGravity; G_TO_B(gravityDirection * gravityMagnitude, btGravity); - dynamicsWorld->setGravity(btGravity); + //dynamicsWorld->setGravity(btGravity); + dynamicsWorld->setGravity(btVector3(0, 0, 0)); if (soft_body_world_info) { soft_body_world_info->m_gravity = btGravity; } @@ -817,7 +794,12 @@ void SpaceBullet::update_gravity() { /// I'm leaving this here just for future tests. /// Debug motion and normal vector drawing #define debug_test_motion 0 +#define PERFORM_INITIAL_UNSTACK 1 + #if debug_test_motion + +#include "scene/3d/immediate_geometry.h" + static ImmediateGeometry *motionVec(NULL); static ImmediateGeometry *normalLine(NULL); static Ref<SpatialMaterial> red_mat; @@ -825,10 +807,10 @@ static Ref<SpatialMaterial> blue_mat; #endif #define IGNORE_AREAS_TRUE true -bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, real_t p_margin, PhysicsServer::MotionResult *r_result) { +bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, PhysicsServer::MotionResult *r_result) { #if debug_test_motion - /// Yes I know this is not good, but I've used it as fast debugging. + /// Yes I know this is not good, but I've used it as fast debugging hack. /// I'm leaving it here just for speedup the other eventual debugs if (!normalLine) { motionVec = memnew(ImmediateGeometry); @@ -866,43 +848,21 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f // } //} - btVector3 recover_initial_position; - recover_initial_position.setZero(); + btVector3 recover_initial_position(0, 0, 0); -/// I'm performing the unstack at the end of movement so I'm sure the player is unstacked even after the movement. -/// I've removed the initial unstack because this is useful just for the first tick since after the first -/// the real unstack is performed at the end of process. -/// However I'm leaving here the old code. -/// Note: It has a bug when two shapes touches something simultaneously the body is moved too much away (I'm not fixing it for the reason written above). -#define INITIAL_UNSTACK 0 -#if !INITIAL_UNSTACK btTransform body_safe_position; G_TO_B(p_from, body_safe_position); -//btTransform body_unsafe_positino; -//G_TO_B(p_from, body_unsafe_positino); -#else - btTransform body_safe_position; - btTransform body_unsafe_positino; - { /// Phase one - multi shapes depenetration using margin - G_TO_B(p_from, body_safe_position); - G_TO_B(p_from, body_unsafe_positino); - - // MAX_PENETRATION_DEPTH Is useful have the ghost a bit penetrated so I can detect the floor easily - recover_from_penetration(p_body, body_safe_position, MAX_PENETRATION_DEPTH, /* p_depenetration_speed */ 1, recover_initial_position); - /// Not required if I put p_depenetration_speed = 1 - //for(int t = 0; t<4; ++t){ - // if(!recover_from_penetration(p_body, body_safe_position, MAX_PENETRATION_DEPTH, /* p_depenetration_speed */0.2, recover_initial_position)){ - // break; - // } - //} + { /// Phase one - multi shapes depenetration using margin +#if PERFORM_INITIAL_UNSTACK + if (recover_from_penetration(p_body, body_safe_position, recover_initial_position)) { - // Add recover position to "From" and "To" transforms - body_safe_position.getOrigin() += recover_initial_position; - } + // Add recover position to "From" and "To" transforms + body_safe_position.getOrigin() += recover_initial_position; + } #endif + } - int shape_most_recovered(-1); btVector3 recovered_motion; G_TO_B(p_motion, recovered_motion); const int shape_count(p_body->get_shape_count()); @@ -924,133 +884,59 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f continue; } - btConvexShape *convex_shape_test(dynamic_cast<btConvexShape *>(p_body->get_bt_shape(shIndex))); - if (!convex_shape_test) { + if (!p_body->get_bt_shape(shIndex)->isConvex()) { // Skip no convex shape continue; } + btConvexShape *convex_shape_test(static_cast<btConvexShape *>(p_body->get_bt_shape(shIndex))); - btTransform shape_xform_from; - G_TO_B(p_body->get_shape_transform(shIndex), shape_xform_from); - //btTransform shape_xform_to(shape_xform_from); + btTransform shape_world_from; + G_TO_B(p_body->get_shape_transform(shIndex), shape_world_from); // Add local shape transform - shape_xform_from.getOrigin() += body_safe_position.getOrigin(); - shape_xform_from.getBasis() *= body_safe_position.getBasis(); + shape_world_from = body_safe_position * shape_world_from; - btTransform shape_xform_to(shape_xform_from); - //shape_xform_to.getOrigin() += body_unsafe_positino.getOrigin(); - //shape_xform_to.getBasis() *= body_unsafe_positino.getBasis(); - shape_xform_to.getOrigin() += recovered_motion; + btTransform shape_world_to(shape_world_from); + shape_world_to.getOrigin() += recovered_motion; - GodotKinClosestConvexResultCallback btResult(shape_xform_from.getOrigin(), shape_xform_to.getOrigin(), p_body, IGNORE_AREAS_TRUE); + GodotKinClosestConvexResultCallback btResult(shape_world_from.getOrigin(), shape_world_to.getOrigin(), p_body, IGNORE_AREAS_TRUE); btResult.m_collisionFilterGroup = p_body->get_collision_layer(); btResult.m_collisionFilterMask = p_body->get_collision_mask(); - dynamicsWorld->convexSweepTest(convex_shape_test, shape_xform_from, shape_xform_to, btResult); + dynamicsWorld->convexSweepTest(convex_shape_test, shape_world_from, shape_world_to, btResult, 0.002); if (btResult.hasHit()) { - //recovered_motion *= btResult.m_closestHitFraction; /// Since for each sweep test I fix the motion of new shapes in base the recover result, - /// if another shape will hit something it means that has a deepest recovering respect the previous shape - shape_most_recovered = shIndex; + /// if another shape will hit something it means that has a deepest penetration respect the previous shape + recovered_motion *= btResult.m_closestHitFraction; } } } - bool hasHit = false; - - { /// Phase three - contact test with margin + bool hasPenetration = false; - btGhostObject *ghost = p_body->get_kinematic_utilities()->m_ghostObject; + { /// Phase three - Recover + contact test with margin - GodotRecoverAndClosestContactResultCallback result_callabck; + RecoverResult r_recover_result; - if (false && 0 <= shape_most_recovered) { - result_callabck.m_self_object = p_body; - result_callabck.m_ignore_areas = IGNORE_AREAS_TRUE; - result_callabck.m_collisionFilterGroup = p_body->get_collision_layer(); - result_callabck.m_collisionFilterMask = p_body->get_collision_mask(); - - const RigidBodyBullet::KinematicShape &kin(p_body->get_kinematic_utilities()->m_shapes[shape_most_recovered]); - ghost->setCollisionShape(kin.shape); - ghost->setWorldTransform(body_safe_position); - - ghost->getWorldTransform().getOrigin() += recovered_motion; - ghost->getWorldTransform().getOrigin() += kin.transform.getOrigin(); - ghost->getWorldTransform().getBasis() *= kin.transform.getBasis(); - - dynamicsWorld->contactTest(ghost, result_callabck); - - recovered_motion += result_callabck.m_recover_penetration; // Required to avoid all kind of penetration - - } else { - // The sweep result does not return a penetrated shape, so I've to check all shapes - // Then return the most penetrated shape - - GodotRecoverAndClosestContactResultCallback iter_result_callabck(p_body, IGNORE_AREAS_TRUE); - iter_result_callabck.m_collisionFilterGroup = p_body->get_collision_layer(); - iter_result_callabck.m_collisionFilterMask = p_body->get_collision_mask(); - - btScalar max_penetration(99999999999); - for (int i = 0; i < shape_count; ++i) { - - const RigidBodyBullet::KinematicShape &kin(p_body->get_kinematic_utilities()->m_shapes[i]); - if (!kin.is_active()) { - continue; - } - - // reset callback each function - iter_result_callabck.reset(); - - ghost->setCollisionShape(kin.shape); - ghost->setWorldTransform(body_safe_position); - ghost->getWorldTransform().getOrigin() += recovered_motion; - ghost->getWorldTransform().getOrigin() += kin.transform.getOrigin(); - ghost->getWorldTransform().getBasis() *= kin.transform.getBasis(); - - dynamicsWorld->contactTest(ghost, iter_result_callabck); - - if (iter_result_callabck.hasHit()) { - if (max_penetration > iter_result_callabck.m_penetration_distance) { - max_penetration = iter_result_callabck.m_penetration_distance; - shape_most_recovered = i; - // This is more penetrated - result_callabck.m_pointCollisionObject = iter_result_callabck.m_pointCollisionObject; - result_callabck.m_pointNormalWorld = iter_result_callabck.m_pointNormalWorld; - result_callabck.m_pointWorld = iter_result_callabck.m_pointWorld; - result_callabck.m_penetration_distance = iter_result_callabck.m_penetration_distance; - result_callabck.m_other_compound_shape_index = iter_result_callabck.m_other_compound_shape_index; - - recovered_motion += iter_result_callabck.m_recover_penetration; // Required to avoid all kind of penetration - } - } - } - } - - hasHit = result_callabck.hasHit(); + hasPenetration = recover_from_penetration(p_body, body_safe_position, recovered_motion, &r_recover_result); if (r_result) { B_TO_G(recovered_motion + recover_initial_position, r_result->motion); - if (hasHit) { - - if (btCollisionObject::CO_RIGID_BODY != result_callabck.m_pointCollisionObject->getInternalType()) { - ERR_PRINT("The collision is not against a rigid body. Please check what's going on."); - goto EndExecution; - } - const btRigidBody *btRigid = static_cast<const btRigidBody *>(result_callabck.m_pointCollisionObject); + if (hasPenetration) { + const btRigidBody *btRigid = static_cast<const btRigidBody *>(r_recover_result.other_collision_object); CollisionObjectBullet *collisionObject = static_cast<CollisionObjectBullet *>(btRigid->getUserPointer()); r_result->remainder = p_motion - r_result->motion; // is the remaining movements - B_TO_G(result_callabck.m_pointWorld, r_result->collision_point); - B_TO_G(result_callabck.m_pointNormalWorld, r_result->collision_normal); - B_TO_G(btRigid->getVelocityInLocalPoint(result_callabck.m_pointWorld - btRigid->getWorldTransform().getOrigin()), r_result->collider_velocity); // It calculates velocity at point and assign it using special function Bullet_to_Godot + B_TO_G(r_recover_result.pointWorld, r_result->collision_point); + B_TO_G(r_recover_result.pointNormalWorld, r_result->collision_normal); + B_TO_G(btRigid->getVelocityInLocalPoint(r_recover_result.pointWorld - btRigid->getWorldTransform().getOrigin()), r_result->collider_velocity); // It calculates velocity at point and assign it using special function Bullet_to_Godot r_result->collider = collisionObject->get_self(); r_result->collider_id = collisionObject->get_instance_id(); - r_result->collider_shape = result_callabck.m_other_compound_shape_index; - r_result->collision_local_shape = shape_most_recovered; + r_result->collider_shape = r_recover_result.other_compound_shape_index; + r_result->collision_local_shape = r_recover_result.local_shape_most_recovered; //{ /// Add manifold point to manage collisions // btPersistentManifold* manifold = dynamicsWorld->getDispatcher()->getNewManifold(p_body->getBtBody(), btRigid); @@ -1079,85 +965,175 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f } } -EndExecution: - p_body->get_kinematic_utilities()->resetDefShape(); - return hasHit; + return hasPenetration; } -/// Note: It has a bug when two shapes touches something simultaneously the body is moved too much away -/// (I'm not fixing it because I don't use it). -bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_from, btScalar p_maxPenetrationDepth, btScalar p_depenetration_speed, btVector3 &out_recover_position) { +struct RecoverPenetrationBroadPhaseCallback : public btBroadphaseAabbCallback { +private: + const btCollisionObject *self_collision_object; + uint32_t collision_layer; + uint32_t collision_mask; - bool penetration = false; - btPairCachingGhostObject *ghost = p_body->get_kinematic_utilities()->m_ghostObject; +public: + Vector<btCollisionObject *> result_collision_objects; - for (int kinIndex = p_body->get_kinematic_utilities()->m_shapes.size() - 1; 0 <= kinIndex; --kinIndex) { - const RigidBodyBullet::KinematicShape &kin_shape(p_body->get_kinematic_utilities()->m_shapes[kinIndex]); - if (!kin_shape.is_active()) { - continue; +public: + RecoverPenetrationBroadPhaseCallback(const btCollisionObject *p_self_collision_object, uint32_t p_collision_layer, uint32_t p_collision_mask) + : self_collision_object(p_self_collision_object), + collision_layer(p_collision_layer), + collision_mask(p_collision_mask) {} + + virtual ~RecoverPenetrationBroadPhaseCallback() {} + + virtual bool process(const btBroadphaseProxy *proxy) { + + btCollisionObject *co = static_cast<btCollisionObject *>(proxy->m_clientObject); + if (co->getInternalType() <= btCollisionObject::CO_RIGID_BODY) { + if (self_collision_object != proxy->m_clientObject && GodotFilterCallback::test_collision_filters(collision_layer, collision_mask, proxy->m_collisionFilterGroup, proxy->m_collisionFilterMask)) { + result_collision_objects.push_back(co); + return true; + } } + return false; + } + + void reset() { + result_collision_objects.empty(); + } +}; - btConvexShape *convexShape = kin_shape.shape; - btTransform shape_xform(kin_shape.transform); +bool SpaceBullet::recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_body_position, btVector3 &r_recover_position, RecoverResult *r_recover_result) { - // from local to world - shape_xform.getOrigin() += p_from.getOrigin(); - shape_xform.getBasis() *= p_from.getBasis(); + RecoverPenetrationBroadPhaseCallback recover_broad_result(p_body->get_bt_collision_object(), p_body->get_collision_layer(), p_body->get_collision_mask()); - // Apply last recovery to avoid doubling the recovering - shape_xform.getOrigin() += out_recover_position; + btTransform body_shape_position; + btTransform body_shape_position_recovered; - ghost->setCollisionShape(convexShape); - ghost->setWorldTransform(shape_xform); + // Broad phase support + btVector3 minAabb, maxAabb; - btVector3 minAabb, maxAabb; - convexShape->getAabb(shape_xform, minAabb, maxAabb); - dynamicsWorld->getBroadphase()->setAabb(ghost->getBroadphaseHandle(), - minAabb, - maxAabb, - dynamicsWorld->getDispatcher()); + bool penetration = false; + + // For each shape + for (int kinIndex = p_body->get_kinematic_utilities()->shapes.size() - 1; 0 <= kinIndex; --kinIndex) { - dynamicsWorld->getDispatcher()->dispatchAllCollisionPairs(ghost->getOverlappingPairCache(), dynamicsWorld->getDispatchInfo(), dynamicsWorld->getDispatcher()); + recover_broad_result.reset(); - for (int i = 0; i < ghost->getOverlappingPairCache()->getNumOverlappingPairs(); ++i) { - p_body->get_kinematic_utilities()->m_manifoldArray.resize(0); + const RigidBodyBullet::KinematicShape &kin_shape(p_body->get_kinematic_utilities()->shapes[kinIndex]); + if (!kin_shape.is_active()) { + continue; + } - btBroadphasePair *collisionPair = &ghost->getOverlappingPairCache()->getOverlappingPairArray()[i]; + body_shape_position = p_body_position * kin_shape.transform; + body_shape_position_recovered = body_shape_position; + body_shape_position_recovered.getOrigin() += r_recover_position; - btCollisionObject *obj0 = static_cast<btCollisionObject *>(collisionPair->m_pProxy0->m_clientObject); - btCollisionObject *obj1 = static_cast<btCollisionObject *>(collisionPair->m_pProxy1->m_clientObject); + kin_shape.shape->getAabb(body_shape_position_recovered, minAabb, maxAabb); + dynamicsWorld->getBroadphase()->aabbTest(minAabb, maxAabb, recover_broad_result); - if ((obj0 && !obj0->hasContactResponse()) || (obj1 && !obj1->hasContactResponse())) + for (int i = recover_broad_result.result_collision_objects.size() - 1; 0 <= i; --i) { + btCollisionObject *otherObject = recover_broad_result.result_collision_objects[i]; + if (!p_body->get_bt_collision_object()->checkCollideWith(otherObject) || !otherObject->checkCollideWith(p_body->get_bt_collision_object())) continue; - // This is not required since the dispatched does all the job - //if (!needsCollision(obj0, obj1)) - // continue; + if (otherObject->getCollisionShape()->isCompound()) { - if (collisionPair->m_algorithm) - collisionPair->m_algorithm->getAllContactManifolds(p_body->get_kinematic_utilities()->m_manifoldArray); + // Each convex shape + btCompoundShape *cs = static_cast<btCompoundShape *>(otherObject->getCollisionShape()); + for (int x = cs->getNumChildShapes() - 1; 0 <= x; --x) { - for (int j = 0; j < p_body->get_kinematic_utilities()->m_manifoldArray.size(); ++j) { + if (cs->getChildShape(x)->isConvex()) { + if (RFP_convex_convex_test(kin_shape.shape, static_cast<const btConvexShape *>(cs->getChildShape(x)), otherObject, x, body_shape_position, otherObject->getWorldTransform() * cs->getChildTransform(x), r_recover_position, r_recover_result)) { - btPersistentManifold *manifold = p_body->get_kinematic_utilities()->m_manifoldArray[j]; - btScalar directionSign = manifold->getBody0() == ghost ? btScalar(-1.0) : btScalar(1.0); - for (int p = 0; p < manifold->getNumContacts(); ++p) { - const btManifoldPoint &pt = manifold->getContactPoint(p); + penetration = true; + } + } else { + if (RFP_convex_world_test(kin_shape.shape, cs->getChildShape(x), p_body->get_bt_collision_object(), otherObject, kinIndex, x, body_shape_position, otherObject->getWorldTransform() * cs->getChildTransform(x), r_recover_position, r_recover_result)) { - btScalar dist = pt.getDistance(); - if (dist < -p_maxPenetrationDepth) { - penetration = true; - out_recover_position += pt.m_normalWorldOnB * directionSign * (dist + p_maxPenetrationDepth) * p_depenetration_speed; - //print_line("penetrate distance: " + rtos(dist)); + penetration = true; + } } - //else { - // print_line("touching distance: " + rtos(dist)); - //} + } + } else if (otherObject->getCollisionShape()->isConvex()) { /// Execute GJK test against object shape + if (RFP_convex_convex_test(kin_shape.shape, static_cast<const btConvexShape *>(otherObject->getCollisionShape()), otherObject, 0, body_shape_position, otherObject->getWorldTransform(), r_recover_position, r_recover_result)) { + + penetration = true; + } + } else { + if (RFP_convex_world_test(kin_shape.shape, otherObject->getCollisionShape(), p_body->get_bt_collision_object(), otherObject, kinIndex, 0, body_shape_position, otherObject->getWorldTransform(), r_recover_position, r_recover_result)) { + + penetration = true; } } } } - p_body->get_kinematic_utilities()->resetDefShape(); return penetration; } + +bool SpaceBullet::RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btVector3 &r_recover_position, RecoverResult *r_recover_result) { + + // Initialize GJK input + btGjkPairDetector::ClosestPointInput gjk_input; + gjk_input.m_transformA = p_transformA; + gjk_input.m_transformA.getOrigin() += r_recover_position; + gjk_input.m_transformB = p_transformB; + + // Perform GJK test + btPointCollector result; + btGjkPairDetector gjk_pair_detector(p_shapeA, p_shapeB, gjk_simplex_solver, gjk_epa_pen_solver); + gjk_pair_detector.getClosestPoints(gjk_input, result, 0); + if (0 > result.m_distance) { + // Has penetration + r_recover_position += result.m_normalOnBInWorld * (result.m_distance * -1); + + if (r_recover_result) { + + r_recover_result->hasPenetration = true; + r_recover_result->other_collision_object = p_objectB; + r_recover_result->other_compound_shape_index = p_shapeId_B; + r_recover_result->penetration_distance = result.m_distance; + r_recover_result->pointNormalWorld = result.m_normalOnBInWorld; + r_recover_result->pointWorld = result.m_pointInWorld; + } + return true; + } + return false; +} + +bool SpaceBullet::RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btVector3 &r_recover_position, RecoverResult *r_recover_result) { + + /// Contact test + + btTransform p_recovered_transformA(p_transformA); + p_recovered_transformA.getOrigin() += r_recover_position; + + btCollisionObjectWrapper obA(NULL, p_shapeA, p_objectA, p_recovered_transformA, -1, p_shapeId_A); + btCollisionObjectWrapper obB(NULL, p_shapeB, p_objectB, p_transformB, -1, p_shapeId_B); + + btCollisionAlgorithm *algorithm = dispatcher->findAlgorithm(&obA, &obB, NULL, BT_CLOSEST_POINT_ALGORITHMS); + if (algorithm) { + GodotDeepPenetrationContactResultCallback contactPointResult(&obA, &obB); + //discrete collision detection query + algorithm->processCollision(&obA, &obB, dynamicsWorld->getDispatchInfo(), &contactPointResult); + + algorithm->~btCollisionAlgorithm(); + dispatcher->freeCollisionAlgorithm(algorithm); + + if (contactPointResult.hasHit()) { + r_recover_position += contactPointResult.m_pointNormalWorld * (contactPointResult.m_penetration_distance * -1); + + if (r_recover_result) { + + r_recover_result->hasPenetration = true; + r_recover_result->other_collision_object = p_objectB; + r_recover_result->other_compound_shape_index = p_shapeId_B; + r_recover_result->penetration_distance = contactPointResult.m_penetration_distance; + r_recover_result->pointNormalWorld = contactPointResult.m_pointNormalWorld; + r_recover_result->pointWorld = contactPointResult.m_pointWorld; + } + return true; + } + } + return false; +} diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h index cbbfdac1d7..9acac9a7d6 100644 --- a/modules/bullet/space_bullet.h +++ b/modules/bullet/space_bullet.h @@ -59,6 +59,7 @@ class CollisionObjectBullet; class RigidBodyBullet; class SpaceBullet; class SoftBodyBullet; +class btGjkEpaPenetrationDepthSolver; class BulletPhysicsDirectSpaceState : public PhysicsDirectSpaceState { GDCLASS(BulletPhysicsDirectSpaceState, PhysicsDirectSpaceState) @@ -93,6 +94,9 @@ private: GodotFilterCallback *godotFilterCallback; btSoftBodyWorldInfo *soft_body_world_info; + btGjkEpaPenetrationDepthSolver *gjk_epa_pen_solver; + btVoronoiSimplexSolver *gjk_simplex_solver; + BulletPhysicsDirectSpaceState *direct_access; Vector3 gravityDirection; real_t gravityMagnitude; @@ -109,6 +113,7 @@ public: void flush_queries(); void step(real_t p_delta_time); + _FORCE_INLINE_ btBroadphaseInterface *get_broadphase() { return broadphase; } _FORCE_INLINE_ btCollisionDispatcher *get_dispatcher() { return dispatcher; } _FORCE_INLINE_ btSoftBodyWorldInfo *get_soft_body_world_info() { return soft_body_world_info; } _FORCE_INLINE_ bool is_using_soft_world() { return soft_body_world_info; } @@ -163,7 +168,7 @@ public: void update_gravity(); - bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, real_t p_margin, PhysicsServer::MotionResult *r_result); + bool test_body_motion(RigidBodyBullet *p_body, const Transform &p_from, const Vector3 &p_motion, PhysicsServer::MotionResult *r_result); private: void create_empty_world(bool p_create_soft_world); @@ -171,6 +176,25 @@ private: void check_ghost_overlaps(); void check_body_collision(); - bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_from, btScalar p_maxPenetrationDepth, btScalar p_depenetration_speed, btVector3 &out_recover_position); + struct RecoverResult { + bool hasPenetration; + btVector3 pointNormalWorld; + btVector3 pointWorld; + btScalar penetration_distance; // Negative is penetration + int other_compound_shape_index; + const btCollisionObject *other_collision_object; + int local_shape_most_recovered; + + RecoverResult() + : hasPenetration(false) {} + }; + + bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_from, btVector3 &r_recover_position, RecoverResult *r_recover_result = NULL); + /// This is an API that recover a kinematic object from penetration + /// This allow only Convex Convex test and it always use GJK algorithm, With this API we don't benefit of Bullet special accelerated functions + bool RFP_convex_convex_test(const btConvexShape *p_shapeA, const btConvexShape *p_shapeB, btCollisionObject *p_objectB, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btVector3 &r_recover_position, RecoverResult *r_recover_result); + /// This is an API that recover a kinematic object from penetration + /// Using this we leave Bullet to select the best algorithm, For example GJK in case we have Convex Convex, or a Bullet accelerated algorithm + bool RFP_convex_world_test(const btConvexShape *p_shapeA, const btCollisionShape *p_shapeB, btCollisionObject *p_objectA, btCollisionObject *p_objectB, int p_shapeId_A, int p_shapeId_B, const btTransform &p_transformA, const btTransform &p_transformB, btVector3 &r_recover_position, RecoverResult *r_recover_result); }; #endif diff --git a/modules/dds/config.py b/modules/dds/config.py index fb920482f5..5f133eba90 100644 --- a/modules/dds/config.py +++ b/modules/dds/config.py @@ -1,7 +1,5 @@ - def can_build(platform): return True - def configure(env): pass diff --git a/modules/enet/config.py b/modules/enet/config.py index fb920482f5..8031fbb4b6 100644 --- a/modules/enet/config.py +++ b/modules/enet/config.py @@ -1,7 +1,13 @@ - def can_build(platform): return True - def configure(env): pass + +def get_doc_classes(): + return [ + "NetworkedMultiplayerENet", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/doc/classes/NetworkedMultiplayerENet.xml b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml index 02c919bd83..70ef6aef20 100644 --- a/doc/classes/NetworkedMultiplayerENet.xml +++ b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NetworkedMultiplayerENet" inherits="NetworkedMultiplayerPeer" category="Core" version="3.0.alpha.custom_build"> +<class name="NetworkedMultiplayerENet" inherits="NetworkedMultiplayerPeer" category="Core" version="3.0-alpha"> <brief_description> PacketPeer implementation using the ENet library. </brief_description> diff --git a/modules/enet/networked_multiplayer_enet.cpp b/modules/enet/networked_multiplayer_enet.cpp index c50886ad3c..1e18ec0d18 100644 --- a/modules/enet/networked_multiplayer_enet.cpp +++ b/modules/enet/networked_multiplayer_enet.cpp @@ -505,7 +505,7 @@ uint32_t NetworkedMultiplayerENet::_gen_unique_id() const { hash = hash_djb2_one_32( (uint32_t)OS::get_singleton()->get_unix_time(), hash); hash = hash_djb2_one_32( - (uint32_t)OS::get_singleton()->get_data_dir().hash64(), hash); + (uint32_t)OS::get_singleton()->get_user_data_dir().hash64(), hash); /* hash = hash_djb2_one_32( (uint32_t)OS::get_singleton()->get_unique_id().hash64(), hash ); diff --git a/modules/etc/config.py b/modules/etc/config.py index 7dc2cb59c1..395fc1bb02 100644 --- a/modules/etc/config.py +++ b/modules/etc/config.py @@ -1,8 +1,6 @@ - def can_build(platform): return True - def configure(env): # Tools only, disabled for non-tools # TODO: Find a cleaner way to achieve that diff --git a/modules/freetype/config.py b/modules/freetype/config.py index fb920482f5..5f133eba90 100644 --- a/modules/freetype/config.py +++ b/modules/freetype/config.py @@ -1,7 +1,5 @@ - def can_build(platform): return True - def configure(env): pass diff --git a/modules/gdnative/SCsub b/modules/gdnative/SCsub index a6ae143947..66b8d5cbdd 100644 --- a/modules/gdnative/SCsub +++ b/modules/gdnative/SCsub @@ -12,40 +12,94 @@ gdn_env.add_source_files(env.modules_sources, "nativescript/*.cpp") gdn_env.Append(CPPPATH=['#modules/gdnative/include/']) -SConscript("nativearvr/SCsub") +SConscript("arvr/SCsub") SConscript("pluginscript/SCsub") def _spaced(e): return e if e[-1] == '*' else e + ' ' def _build_gdnative_api_struct_header(api): + ext_wrappers = '' + + for name in api['extensions']: + ext_wrappers += ' extern const godot_gdnative_ext_' + name + '_api_struct *_gdnative_wrapper_' + name + '_api_struct;' + + ext_init = 'for (int i = 0; i < _gdnative_wrapper_api_struct->num_extensions; i++) { ' + ext_init += 'switch (_gdnative_wrapper_api_struct->extensions[i]->type) {' + + for name in api['extensions']: + ext_init += 'case GDNATIVE_EXT_' + api['extensions'][name]['type'] + ': ' + ext_init += '_gdnative_wrapper_' + name + '_api_struct = (' + 'godot_gdnative_ext_' + name + '_api_struct *) _gdnative_wrapper_api_struct->extensions[i]; break;' + + ext_init += '}' + out = [ '/* THIS FILE IS GENERATED DO NOT EDIT */', '#ifndef GODOT_GDNATIVE_API_STRUCT_H', '#define GODOT_GDNATIVE_API_STRUCT_H', '', '#include <gdnative/gdnative.h>', - '#include <nativearvr/godot_nativearvr.h>', + '#include <arvr/godot_arvr.h>', '#include <nativescript/godot_nativescript.h>', '#include <pluginscript/godot_pluginscript.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)', + '#define GDNATIVE_API_INIT(options) do { extern const godot_gdnative_api_struct *_gdnative_wrapper_api_struct;' + ext_wrappers + ' _gdnative_wrapper_api_struct = options->api_struct; ' + ext_init + ' } while (0)', '', '#ifdef __cplusplus', 'extern "C" {', '#endif', '', - 'typedef struct godot_gdnative_api_struct {', - '\tvoid *next;', - '\tconst char *version;', + 'typedef struct godot_gdnative_api_version {', + '\tunsigned int major;', + '\tunsigned int minor;', + '} godot_gdnative_api_version;', + '', + 'typedef struct godot_gdnative_api_struct godot_gdnative_api_struct;', + '', + 'struct godot_gdnative_api_struct {', + '\tunsigned int type;', + '\tgodot_gdnative_api_version version;', + '\tconst godot_gdnative_api_struct *next;', + '};', + '', + 'enum GDNATIVE_API_TYPES {', + '\tGDNATIVE_' + api['core']['type'] + ',' + ] + + for name in api['extensions']: + out += ['\tGDNATIVE_EXT_' + api['extensions'][name]['type'] + ','] + + out += ['};', ''] + + for name in api['extensions']: + out += [ + 'typedef struct godot_gdnative_ext_' + name + '_api_struct {', + '\tunsigned int type;', + '\tgodot_gdnative_api_version version;', + '\tconst godot_gdnative_api_struct *next;' + ] + + for funcdef in api['extensions'][name]['api']: + args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) + out.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args)) + + out += ['} godot_gdnative_ext_' + name + '_api_struct;', ''] + + out += [ + 'typedef struct godot_gdnative_core_api_struct {', + '\tunsigned int type;', + '\tgodot_gdnative_api_version version;', + '\tconst godot_gdnative_api_struct *next;', + '\tunsigned int num_extensions;', + '\tconst godot_gdnative_api_struct **extensions;', ] - for funcdef in api['api']: + for funcdef in api['core']['api']: args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) out.append('\t%s(*%s)(%s);' % (_spaced(funcdef['return_type']), funcdef['name'], args)) out += [ - '} godot_gdnative_api_struct;', + '} godot_gdnative_core_api_struct;', '', '#ifdef __cplusplus', '}', @@ -61,14 +115,39 @@ def _build_gdnative_api_struct_source(api): '/* THIS FILE IS GENERATED DO NOT EDIT */', '', '#include <gdnative_api_struct.gen.h>', - '', - 'const char *_gdnative_api_version = "%s";' % api['version'], - 'extern const godot_gdnative_api_struct api_struct = {', + '' + ] + + for name in api['extensions']: + out += [ + 'extern const godot_gdnative_ext_' + name + '_api_struct api_extension_' + name + '_struct = {', + '\tGDNATIVE_EXT_' + api['extensions'][name]['type'] + ',', + '\t{' + str(api['extensions'][name]['version']['major']) + ', ' + str(api['extensions'][name]['version']['minor']) + '},', + '\tNULL,' + ] + + for funcdef in api['extensions'][name]['api']: + out.append('\t%s,' % funcdef['name']) + + out += ['};\n'] + + out += ['', 'const godot_gdnative_api_struct *gdnative_extensions_pointers[] = {'] + + for name in api['extensions']: + out += ['\t(godot_gdnative_api_struct *)&api_extension_' + name + '_struct,'] + + out += ['};\n'] + + out += [ + 'extern const godot_gdnative_core_api_struct api_struct = {', + '\tGDNATIVE_' + api['core']['type'] + ',', + '\t{' + str(api['core']['version']['major']) + ', ' + str(api['core']['version']['minor']) + '},', '\tNULL,', - '\t_gdnative_api_version,', + '\t' + str(len(api['extensions'])) + ',', + '\tgdnative_extensions_pointers,', ] - for funcdef in api['api']: + for funcdef in api['core']['api']: out.append('\t%s,' % funcdef['name']) out.append('};\n') @@ -101,18 +180,23 @@ def _build_gdnative_wrapper_code(api): '#include <gdnative/gdnative.h>', '#include <nativescript/godot_nativescript.h>', '#include <pluginscript/godot_pluginscript.h>', + '#include <arvr/godot_arvr.h>', '', '#include <gdnative_api_struct.gen.h>', '', - 'godot_gdnative_api_struct *_gdnative_wrapper_api_struct = 0;', - '', '#ifdef __cplusplus', 'extern "C" {', '#endif', - '' + '', + 'godot_gdnative_core_api_struct *_gdnative_wrapper_api_struct = 0;', ] - for funcdef in api['api']: + for name in api['extensions']: + out.append('godot_gdnative_ext_' + name + '_api_struct *_gdnative_wrapper_' + name + '_api_struct;') + + out += [''] + + for funcdef in api['core']['api']: args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) out.append('%s%s(%s) {' % (_spaced(funcdef['return_type']), funcdef['name'], args)) @@ -125,6 +209,20 @@ def _build_gdnative_wrapper_code(api): out.append('}') out.append('') + for name in api['extensions']: + for funcdef in api['extensions'][name]['api']: + args = ', '.join(['%s%s' % (_spaced(t), n) for t, n in funcdef['arguments']]) + out.append('%s%s(%s) {' % (_spaced(funcdef['return_type']), funcdef['name'], 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_' + name + '_api_struct->' + funcdef['name'] + '(' + args + ');' + + out.append(return_line) + out.append('}') + out.append('') + out += [ '#ifdef __cplusplus', '}', diff --git a/modules/gdnative/nativearvr/SCsub b/modules/gdnative/arvr/SCsub index ecc5996108..ecc5996108 100644 --- a/modules/gdnative/nativearvr/SCsub +++ b/modules/gdnative/arvr/SCsub diff --git a/modules/gdnative/nativearvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp index e2a7019fa4..02f2ee7424 100644 --- a/modules/gdnative/nativearvr/arvr_interface_gdnative.cpp +++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp @@ -166,11 +166,11 @@ void ARVRInterfaceGDNative::uninitialize() { interface->uninitialize(data); } -Size2 ARVRInterfaceGDNative::get_recommended_render_targetsize() { +Size2 ARVRInterfaceGDNative::get_render_targetsize() { ERR_FAIL_COND_V(interface == NULL, Size2()); - godot_vector2 result = interface->get_recommended_render_targetsize(data); + godot_vector2 result = interface->get_render_targetsize(data); Vector2 *vec = (Vector2 *)&result; return *vec; diff --git a/modules/gdnative/nativearvr/arvr_interface_gdnative.h b/modules/gdnative/arvr/arvr_interface_gdnative.h index e45b51e070..96f7b580d5 100644 --- a/modules/gdnative/nativearvr/arvr_interface_gdnative.h +++ b/modules/gdnative/arvr/arvr_interface_gdnative.h @@ -68,7 +68,7 @@ public: virtual void set_anchor_detection_is_enabled(bool p_enable); /** rendering and internal **/ - virtual Size2 get_recommended_render_targetsize(); + virtual Size2 get_render_targetsize(); virtual bool is_stereo(); virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform); diff --git a/modules/gdnative/nativearvr/config.py b/modules/gdnative/arvr/config.py index 4d1bdfe4d1..4d1bdfe4d1 100644 --- a/modules/gdnative/nativearvr/config.py +++ b/modules/gdnative/arvr/config.py diff --git a/modules/gdnative/nativearvr/register_types.cpp b/modules/gdnative/arvr/register_types.cpp index c7d7847a21..139750a02d 100644 --- a/modules/gdnative/nativearvr/register_types.cpp +++ b/modules/gdnative/arvr/register_types.cpp @@ -31,9 +31,9 @@ #include "register_types.h" #include "arvr_interface_gdnative.h" -void register_nativearvr_types() { +void register_arvr_types() { ClassDB::register_class<ARVRInterfaceGDNative>(); } -void unregister_nativearvr_types() { +void unregister_arvr_types() { } diff --git a/modules/gdnative/nativearvr/register_types.h b/modules/gdnative/arvr/register_types.h index 5e7557c7e9..4918319926 100644 --- a/modules/gdnative/nativearvr/register_types.h +++ b/modules/gdnative/arvr/register_types.h @@ -28,5 +28,5 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -void register_nativearvr_types(); -void unregister_nativearvr_types(); +void register_arvr_types(); +void unregister_arvr_types(); diff --git a/modules/gdnative/config.py b/modules/gdnative/config.py index df3556249d..68148c4d87 100644 --- a/modules/gdnative/config.py +++ b/modules/gdnative/config.py @@ -1,4 +1,3 @@ - def can_build(platform): return True @@ -6,7 +5,13 @@ def configure(env): env.use_ptrcall = True def get_doc_classes(): - return ["GDNative", "GDNativeLibrary", "NativeScript", "ARVRInterfaceGDNative"] + return [ + "ARVRInterfaceGDNative", + "GDNative", + "GDNativeLibrary", + "NativeScript", + "PluginScript", + ] def get_doc_path(): - return "doc_classes" + return "doc_classes" diff --git a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml b/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml index 308a7d5946..10957a3394 100644 --- a/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml +++ b/modules/gdnative/doc_classes/ARVRInterfaceGDNative.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" category="Core" version="3.0.alpha.custom_build"> +<class name="ARVRInterfaceGDNative" inherits="ARVRInterface" category="Core" version="3.0-alpha"> <brief_description> GDNative wrapper for an ARVR interface </brief_description> diff --git a/modules/gdnative/doc_classes/GDNative.xml b/modules/gdnative/doc_classes/GDNative.xml index 83a1cf06f0..7a36d09aec 100644 --- a/modules/gdnative/doc_classes/GDNative.xml +++ b/modules/gdnative/doc_classes/GDNative.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GDNative" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="GDNative" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/modules/gdnative/doc_classes/GDNativeLibrary.xml b/modules/gdnative/doc_classes/GDNativeLibrary.xml index 361c89e6b3..e271665fd4 100644 --- a/modules/gdnative/doc_classes/GDNativeLibrary.xml +++ b/modules/gdnative/doc_classes/GDNativeLibrary.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GDNativeLibrary" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="GDNativeLibrary" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> @@ -9,37 +9,51 @@ <demos> </demos> <methods> - <method name="get_active_library_path" qualifiers="const"> + <method name="get_config_file"> + <return type="ConfigFile"> + </return> + <description> + </description> + </method> + <method name="get_current_dependencies" qualifiers="const"> + <return type="PoolStringArray"> + </return> + <description> + </description> + </method> + <method name="get_current_library_path" qualifiers="const"> <return type="String"> </return> <description> </description> </method> - <method name="get_library_path" qualifiers="const"> + <method name="get_symbol_prefix" qualifiers="const"> <return type="String"> </return> - <argument index="0" name="platform" type="String"> - </argument> <description> </description> </method> - <method name="is_singleton_gdnative" qualifiers="const"> + <method name="is_current_library_statically_linked" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="is_singleton" qualifiers="const"> <return type="bool"> </return> <description> </description> </method> - <method name="set_library_path"> + <method name="set_load_once"> <return type="void"> </return> - <argument index="0" name="platform" type="String"> - </argument> - <argument index="1" name="path" type="String"> + <argument index="0" name="load_once" type="bool"> </argument> <description> </description> </method> - <method name="set_singleton_gdnative"> + <method name="set_singleton"> <return type="void"> </return> <argument index="0" name="singleton" type="bool"> @@ -47,9 +61,27 @@ <description> </description> </method> + <method name="set_symbol_prefix"> + <return type="void"> + </return> + <argument index="0" name="symbol_prefix" type="String"> + </argument> + <description> + </description> + </method> + <method name="should_load_once" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> </methods> <members> - <member name="singleton_gdnative" type="bool" setter="set_singleton_gdnative" getter="is_singleton_gdnative"> + <member name="load_once" type="bool" setter="set_load_once" getter="should_load_once"> + </member> + <member name="singleton" type="bool" setter="set_singleton" getter="is_singleton"> + </member> + <member name="symbol_prefix" type="String" setter="set_symbol_prefix" getter="get_symbol_prefix"> </member> </members> <constants> diff --git a/modules/gdnative/doc_classes/NativeScript.xml b/modules/gdnative/doc_classes/NativeScript.xml index b040cfd966..eb4e13f748 100644 --- a/modules/gdnative/doc_classes/NativeScript.xml +++ b/modules/gdnative/doc_classes/NativeScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="NativeScript" inherits="Script" category="Core" version="3.0.alpha.custom_build"> +<class name="NativeScript" inherits="Script" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/PluginScript.xml b/modules/gdnative/doc_classes/PluginScript.xml index 334921016b..a5ab422d3c 100644 --- a/doc/classes/PluginScript.xml +++ b/modules/gdnative/doc_classes/PluginScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="PluginScript" inherits="Script" category="Core" version="3.0.alpha.custom_build"> +<class name="PluginScript" inherits="Script" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/modules/gdnative/gd_native_library_editor.cpp b/modules/gdnative/gd_native_library_editor.cpp index c37b7f473d..fda5dcdcad 100644 --- a/modules/gdnative/gd_native_library_editor.cpp +++ b/modules/gdnative/gd_native_library_editor.cpp @@ -44,7 +44,7 @@ void GDNativeLibraryEditor::_find_gdnative_singletons(EditorFileSystemDirectory } Ref<GDNativeLibrary> lib = ResourceLoader::load(p_dir->get_file_path(i)); - if (lib.is_valid() && lib->is_singleton_gdnative()) { + if (lib.is_valid() && lib->is_singleton()) { String path = p_dir->get_file_path(i); TreeItem *ti = libraries->create_item(libraries->get_root()); ti->set_text(0, path.get_file()); diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index 3fc04a5498..44d6dffc85 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -37,161 +37,56 @@ #include "scene/main/scene_tree.h" -const String init_symbol = "godot_gdnative_init"; -const String terminate_symbol = "godot_gdnative_terminate"; +const String init_symbol = "gdnative_init"; +const String terminate_symbol = "gdnative_terminate"; +const String default_symbol_prefix = "godot_"; // Defined in gdnative_api_struct.gen.cpp -extern const godot_gdnative_api_struct api_struct; - -String GDNativeLibrary::platform_names[NUM_PLATFORMS + 1] = { - "X11_32bit", - "X11_64bit", - "Windows_32bit", - "Windows_64bit", - "OSX", - - "Android", - - "iOS_32bit", - "iOS_64bit", - - "WebAssembly", - - "" -}; -String GDNativeLibrary::platform_lib_ext[NUM_PLATFORMS + 1] = { - "so", - "so", - "dll", - "dll", - "dylib", - - "so", - - "dylib", - "dylib", - - "wasm", - - "" -}; - -GDNativeLibrary::Platform GDNativeLibrary::current_platform = -#if defined(X11_ENABLED) - (sizeof(void *) == 8 ? X11_64BIT : X11_32BIT); -#elif defined(WINDOWS_ENABLED) - (sizeof(void *) == 8 ? WINDOWS_64BIT : WINDOWS_32BIT); -#elif defined(OSX_ENABLED) - OSX; -#elif defined(IPHONE_ENABLED) - (sizeof(void *) == 8 ? IOS_64BIT : IOS_32BIT); -#elif defined(ANDROID_ENABLED) - ANDROID; -#elif defined(JAVASCRIPT_ENABLED) - WASM; -#else - NUM_PLATFORMS; -#endif - -GDNativeLibrary::GDNativeLibrary() - : library_paths(), singleton_gdnative(false) { -} - -GDNativeLibrary::~GDNativeLibrary() { -} +extern const godot_gdnative_core_api_struct api_struct; -void GDNativeLibrary::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_library_path", "platform", "path"), &GDNativeLibrary::set_library_path); - ClassDB::bind_method(D_METHOD("get_library_path", "platform"), &GDNativeLibrary::get_library_path); - ClassDB::bind_method(D_METHOD("get_active_library_path"), &GDNativeLibrary::get_active_library_path); +Map<String, Vector<Ref<GDNative> > > *GDNativeLibrary::loaded_libraries = NULL; - ClassDB::bind_method(D_METHOD("is_singleton_gdnative"), &GDNativeLibrary::is_singleton_gdnative); - ClassDB::bind_method(D_METHOD("set_singleton_gdnative", "singleton"), &GDNativeLibrary::set_singleton_gdnative); +GDNativeLibrary::GDNativeLibrary() { + config_file.instance(); - ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "singleton_gdnative"), "set_singleton_gdnative", "is_singleton_gdnative"); -} + symbol_prefix = default_symbol_prefix; -bool GDNativeLibrary::_set(const StringName &p_name, const Variant &p_value) { - String name = p_name; - if (name.begins_with("platform/")) { - set_library_path(name.get_slice("/", 1), p_value); - return true; - } - return false; -} - -bool GDNativeLibrary::_get(const StringName &p_name, Variant &r_ret) const { - String name = p_name; - if (name.begins_with("platform/")) { - r_ret = get_library_path(name.get_slice("/", 1)); - return true; + if (GDNativeLibrary::loaded_libraries == NULL) { + GDNativeLibrary::loaded_libraries = memnew((Map<String, Vector<Ref<GDNative> > >)); } - return false; } -void GDNativeLibrary::_get_property_list(List<PropertyInfo> *p_list) const { - for (int i = 0; i < NUM_PLATFORMS; i++) { - p_list->push_back(PropertyInfo(Variant::STRING, - "platform/" + platform_names[i], - PROPERTY_HINT_FILE, - "*." + platform_lib_ext[i])); - } +GDNativeLibrary::~GDNativeLibrary() { } -void GDNativeLibrary::set_library_path(StringName p_platform, String p_path) { - int i; - for (i = 0; i <= NUM_PLATFORMS; i++) { - if (i == NUM_PLATFORMS) break; - if (platform_names[i] == p_platform) { - break; - } - } - - if (i == NUM_PLATFORMS) { - ERR_EXPLAIN(String("No such platform: ") + p_platform); - ERR_FAIL(); - } - - library_paths[i] = p_path; -} +void GDNativeLibrary::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_config_file"), &GDNativeLibrary::get_config_file); -String GDNativeLibrary::get_library_path(StringName p_platform) const { - int i; - for (i = 0; i <= NUM_PLATFORMS; i++) { - if (i == NUM_PLATFORMS) break; - if (platform_names[i] == p_platform) { - break; - } - } + ClassDB::bind_method(D_METHOD("get_current_library_path"), &GDNativeLibrary::get_current_library_path); + ClassDB::bind_method(D_METHOD("get_current_dependencies"), &GDNativeLibrary::get_current_dependencies); + ClassDB::bind_method(D_METHOD("is_current_library_statically_linked"), &GDNativeLibrary::is_current_library_statically_linked); - if (i == NUM_PLATFORMS) { - ERR_EXPLAIN(String("No such platform: ") + p_platform); - ERR_FAIL_V(""); - } + ClassDB::bind_method(D_METHOD("should_load_once"), &GDNativeLibrary::should_load_once); + ClassDB::bind_method(D_METHOD("is_singleton"), &GDNativeLibrary::is_singleton); + ClassDB::bind_method(D_METHOD("get_symbol_prefix"), &GDNativeLibrary::get_symbol_prefix); - return library_paths[i]; -} + ClassDB::bind_method(D_METHOD("set_load_once", "load_once"), &GDNativeLibrary::set_load_once); + ClassDB::bind_method(D_METHOD("set_singleton", "singleton"), &GDNativeLibrary::set_singleton); + ClassDB::bind_method(D_METHOD("set_symbol_prefix", "symbol_prefix"), &GDNativeLibrary::set_symbol_prefix); -String GDNativeLibrary::get_active_library_path() const { - if (GDNativeLibrary::current_platform != NUM_PLATFORMS) { - return library_paths[GDNativeLibrary::current_platform]; - } - return ""; + ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "load_once"), "set_load_once", "should_load_once"); + ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "singleton"), "set_singleton", "is_singleton"); + ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "symbol_prefix"), "set_symbol_prefix", "get_symbol_prefix"); } GDNative::GDNative() { native_handle = NULL; + initialized = false; } GDNative::~GDNative() { } -extern "C" void _api_anchor(); - -void GDNative::_compile_dummy_for_api() { - _api_anchor(); -} - void GDNative::_bind_methods() { ClassDB::bind_method(D_METHOD("set_library", "library"), &GDNative::set_library); ClassDB::bind_method(D_METHOD("get_library"), &GDNative::get_library); @@ -220,8 +115,8 @@ bool GDNative::initialize() { return false; } - String lib_path = library->get_active_library_path(); - if (lib_path.empty()) { + String lib_path = library->get_current_library_path(); + if (lib_path.empty() && !library->is_current_library_statically_linked()) { ERR_PRINT("No library set for this platform"); return false; } @@ -230,16 +125,34 @@ bool GDNative::initialize() { #else String path = ProjectSettings::get_singleton()->globalize_path(lib_path); #endif + + if (library->should_load_once()) { + if (GDNativeLibrary::loaded_libraries->has(lib_path)) { + // already loaded. Don't load again. + // copy some of the stuff instead + this->native_handle = (*GDNativeLibrary::loaded_libraries)[lib_path][0]->native_handle; + initialized = true; + return true; + } + } + Error err = OS::get_singleton()->open_dynamic_library(path, native_handle); - if (err != OK) { + if (err != OK && !library->is_current_library_statically_linked()) { return false; } void *library_init; - err = get_symbol(init_symbol, library_init); + + // we cheat here a little bit. you saw nothing + initialized = true; + + err = get_symbol(library->get_symbol_prefix() + init_symbol, library_init); + + initialized = false; if (err || !library_init) { - OS::get_singleton()->close_dynamic_library(native_handle); + if (!library->is_current_library_statically_linked()) + OS::get_singleton()->close_dynamic_library(native_handle); native_handle = NULL; ERR_PRINT("Failed to obtain godot_gdnative_init symbol"); return false; @@ -260,18 +173,42 @@ bool GDNative::initialize() { library_init_fpointer(&options); + initialized = true; + + if (library->should_load_once() && !GDNativeLibrary::loaded_libraries->has(lib_path)) { + Vector<Ref<GDNative> > gdnatives; + gdnatives.resize(1); + gdnatives[0] = Ref<GDNative>(this); + GDNativeLibrary::loaded_libraries->insert(lib_path, gdnatives); + } + return true; } bool GDNative::terminate() { - if (native_handle == NULL) { + if (!initialized) { ERR_PRINT("No valid library handle, can't terminate GDNative object"); return false; } + if (library->should_load_once()) { + Vector<Ref<GDNative> > *gdnatives = &(*GDNativeLibrary::loaded_libraries)[library->get_current_library_path()]; + if (gdnatives->size() > 1) { + // there are other GDNative's still using this library, so we actually don't terminte + gdnatives->erase(Ref<GDNative>(this)); + initialized = false; + return true; + } else if (gdnatives->size() == 1) { + // we're the last one, terminate! + gdnatives->clear(); + // wew this looks scary, but all it does is remove the entry completely + GDNativeLibrary::loaded_libraries->erase(GDNativeLibrary::loaded_libraries->find(library->get_current_library_path())); + } + } + void *library_terminate; - Error error = get_symbol(terminate_symbol, library_terminate); + Error error = get_symbol(library->get_symbol_prefix() + terminate_symbol, library_terminate); if (error || !library_terminate) { OS::get_singleton()->close_dynamic_library(native_handle); native_handle = NULL; @@ -281,13 +218,13 @@ bool GDNative::terminate() { godot_gdnative_terminate_fn library_terminate_pointer; library_terminate_pointer = (godot_gdnative_terminate_fn)library_terminate; - // TODO(karroffel): remove this? Should be part of NativeScript, not - // GDNative IMO godot_gdnative_terminate_options options; options.in_editor = Engine::get_singleton()->is_editor_hint(); library_terminate_pointer(&options); + initialized = false; + // GDNativeScriptLanguage::get_singleton()->initialized_libraries.erase(p_native_lib->path); OS::get_singleton()->close_dynamic_library(native_handle); @@ -297,7 +234,7 @@ bool GDNative::terminate() { } bool GDNative::is_initialized() { - return (native_handle != NULL); + return initialized; } void GDNativeCallRegistry::register_native_call_type(StringName p_call_type, native_call_cb p_callback) { @@ -342,7 +279,7 @@ Variant GDNative::call_native(StringName p_native_call_type, StringName p_proced Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle) { - if (native_handle == NULL) { + if (!initialized) { ERR_PRINT("No valid library handle, can't get symbol from GDNative object"); return ERR_CANT_OPEN; } @@ -355,3 +292,159 @@ Error GDNative::get_symbol(StringName p_procedure_name, void *&r_handle) { return result; } + +RES GDNativeLibraryResourceLoader::load(const String &p_path, const String &p_original_path, Error *r_error) { + Ref<GDNativeLibrary> lib; + lib.instance(); + + Ref<ConfigFile> config = lib->get_config_file(); + + Error err = config->load(p_path); + + if (r_error) { + *r_error = err; + } + + lib->set_singleton(config->get_value("general", "singleton", false)); + lib->set_load_once(config->get_value("general", "load_once", true)); + lib->set_symbol_prefix(config->get_value("general", "symbol_prefix", default_symbol_prefix)); + + String entry_lib_path; + { + + List<String> entry_keys; + config->get_section_keys("entry", &entry_keys); + + for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) { + String key = E->get(); + + Vector<String> tags = key.split("."); + + bool skip = false; + for (int i = 0; i < tags.size(); i++) { + bool has_feature = OS::get_singleton()->has_feature(tags[i]); + + if (!has_feature) { + skip = true; + break; + } + } + + if (skip) { + continue; + } + + entry_lib_path = config->get_value("entry", key); + break; + } + } + + Vector<String> dependency_paths; + { + + List<String> dependency_keys; + config->get_section_keys("dependencies", &dependency_keys); + + for (List<String>::Element *E = dependency_keys.front(); E; E = E->next()) { + String key = E->get(); + + Vector<String> tags = key.split("."); + + bool skip = false; + for (int i = 0; i < tags.size(); i++) { + bool has_feature = OS::get_singleton()->has_feature(tags[i]); + + if (!has_feature) { + skip = true; + break; + } + } + + if (skip) { + continue; + } + + dependency_paths = config->get_value("dependencies", key); + break; + } + } + + bool is_statically_linked = false; + { + + List<String> static_linking_keys; + config->get_section_keys("static_linking", &static_linking_keys); + + for (List<String>::Element *E = static_linking_keys.front(); E; E = E->next()) { + String key = E->get(); + + Vector<String> tags = key.split("."); + + bool skip = false; + + for (int i = 0; i < tags.size(); i++) { + bool has_feature = OS::get_singleton()->has_feature(tags[i]); + + if (!has_feature) { + skip = true; + break; + } + } + + if (skip) { + continue; + } + + is_statically_linked = config->get_value("static_linking", key); + break; + } + } + + lib->current_library_path = entry_lib_path; + lib->current_dependencies = dependency_paths; + lib->current_library_statically_linked = is_statically_linked; + + return lib; +} + +void GDNativeLibraryResourceLoader::get_recognized_extensions(List<String> *p_extensions) const { + p_extensions->push_back("gdnlib"); +} + +bool GDNativeLibraryResourceLoader::handles_type(const String &p_type) const { + return p_type == "GDNativeLibrary"; +} + +String GDNativeLibraryResourceLoader::get_resource_type(const String &p_path) const { + String el = p_path.get_extension().to_lower(); + if (el == "gdnlib") + return "GDNativeLibrary"; + return ""; +} + +Error GDNativeLibraryResourceSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { + + Ref<GDNativeLibrary> lib = p_resource; + + if (lib.is_null()) { + return ERR_INVALID_DATA; + } + + Ref<ConfigFile> config = lib->get_config_file(); + + config->set_value("general", "singleton", lib->is_singleton()); + config->set_value("general", "load_once", lib->should_load_once()); + config->set_value("general", "symbol_prefix", lib->get_symbol_prefix()); + + return config->save(p_path); +} + +bool GDNativeLibraryResourceSaver::recognize(const RES &p_resource) const { + return Object::cast_to<GDNativeLibrary>(*p_resource) != NULL; +} + +void GDNativeLibraryResourceSaver::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const { + if (Object::cast_to<GDNativeLibrary>(*p_resource) != NULL) { + p_extensions->push_back("gdnlib"); + } +} diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h index e44cc55a79..061dff9267 100644 --- a/modules/gdnative/gdnative.h +++ b/modules/gdnative/gdnative.h @@ -38,66 +38,69 @@ #include "gdnative/gdnative.h" #include "gdnative_api_struct.gen.h" -class GDNativeLibrary : public Resource { - GDCLASS(GDNativeLibrary, Resource) - - enum Platform { - X11_32BIT, - X11_64BIT, - WINDOWS_32BIT, - WINDOWS_64BIT, - // NOTE(karroffel): I heard OSX 32 bit is dead, so 64 only - OSX, - - // Android .so files must be located in directories corresponding to Android ABI names: - // https://developer.android.com/ndk/guides/abis.html - // Android runtime will select the matching library depending on the device. - // The value here must simply point to the .so name, for example: - // "res://libmy_gdnative.so" or "libmy_gdnative.so", - // while in the project the actual paths can be "lib/android/armeabi-v7a/libmy_gdnative.so", - // "lib/android/arm64-v8a/libmy_gdnative.so". - ANDROID, - - IOS_32BIT, - IOS_64BIT, - - // TODO(karroffel): figure out how to deal with web stuff at all... - WASM, - - // TODO(karroffel): does UWP have different libs?? - // UWP, +#include "io/config_file.h" - NUM_PLATFORMS +class GDNativeLibraryResourceLoader; +class GDNative; - }; +class GDNativeLibrary : public Resource { + GDCLASS(GDNativeLibrary, Resource) - static String platform_names[NUM_PLATFORMS + 1]; - static String platform_lib_ext[NUM_PLATFORMS + 1]; + static Map<String, Vector<Ref<GDNative> > > *loaded_libraries; - static Platform current_platform; + friend class GDNativeLibraryResourceLoader; + friend class GDNative; - String library_paths[NUM_PLATFORMS]; + Ref<ConfigFile> config_file; - bool singleton_gdnative; + String current_library_path; + Vector<String> current_dependencies; + bool current_library_statically_linked; -protected: - bool _set(const StringName &p_name, const Variant &p_value); - bool _get(const StringName &p_name, Variant &r_ret) const; - void _get_property_list(List<PropertyInfo> *p_list) const; + bool singleton; + bool load_once; + String symbol_prefix; public: GDNativeLibrary(); ~GDNativeLibrary(); - static void _bind_methods(); + _FORCE_INLINE_ Ref<ConfigFile> get_config_file() { return config_file; } + + // things that change per-platform + // so there are no setters for this + _FORCE_INLINE_ String get_current_library_path() const { + return current_library_path; + } + _FORCE_INLINE_ Vector<String> get_current_dependencies() const { + return current_dependencies; + } + _FORCE_INLINE_ bool is_current_library_statically_linked() const { + return current_library_statically_linked; + } - void set_library_path(StringName p_platform, String p_path); - String get_library_path(StringName p_platform) const; + // things that are a property of the library itself, not platform specific + _FORCE_INLINE_ bool should_load_once() const { + return load_once; + } + _FORCE_INLINE_ bool is_singleton() const { + return singleton; + } + _FORCE_INLINE_ String get_symbol_prefix() const { + return symbol_prefix; + } - String get_active_library_path() const; + _FORCE_INLINE_ void set_load_once(bool p_load_once) { + load_once = p_load_once; + } + _FORCE_INLINE_ void set_singleton(bool p_singleton) { + singleton = p_singleton; + } + _FORCE_INLINE_ void set_symbol_prefix(String p_symbol_prefix) { + symbol_prefix = p_symbol_prefix; + } - _FORCE_INLINE_ bool is_singleton_gdnative() const { return singleton_gdnative; } - _FORCE_INLINE_ void set_singleton_gdnative(bool p_singleton) { singleton_gdnative = p_singleton; } + static void _bind_methods(); }; typedef godot_variant (*native_call_cb)(void *, godot_array *); @@ -124,10 +127,9 @@ class GDNative : public Reference { Ref<GDNativeLibrary> library; - // TODO(karroffel): different platforms? WASM???? void *native_handle; - void _compile_dummy_for_api(); + bool initialized; public: GDNative(); @@ -148,4 +150,19 @@ public: Error get_symbol(StringName p_procedure_name, void *&r_handle); }; +class GDNativeLibraryResourceLoader : public ResourceFormatLoader { +public: + virtual RES load(const String &p_path, const String &p_original_path, Error *r_error); + virtual void get_recognized_extensions(List<String> *p_extensions) const; + virtual bool handles_type(const String &p_type) const; + virtual String get_resource_type(const String &p_path) const; +}; + +class GDNativeLibraryResourceSaver : public ResourceFormatSaver { +public: + virtual Error save(const String &p_path, const RES &p_resource, uint32_t p_flags); + virtual bool recognize(const RES &p_resource) const; + virtual void get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const; +}; + #endif // GDNATIVE_H diff --git a/modules/gdnative/gdnative/aabb.cpp b/modules/gdnative/gdnative/aabb.cpp new file mode 100644 index 0000000000..6c89bcdceb --- /dev/null +++ b/modules/gdnative/gdnative/aabb.cpp @@ -0,0 +1,217 @@ +/*************************************************************************/ +/* aabb.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "gdnative/aabb.h" + +#include "core/math/aabb.h" +#include "core/variant.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) { + const Vector3 *pos = (const Vector3 *)p_pos; + const Vector3 *size = (const Vector3 *)p_size; + AABB *dest = (AABB *)r_dest; + *dest = AABB(*pos, *size); +} + +godot_vector3 GDAPI godot_aabb_get_position(const godot_aabb *p_self) { + godot_vector3 raw_ret; + const AABB *self = (const AABB *)p_self; + Vector3 *ret = (Vector3 *)&raw_ret; + *ret = self->position; + return raw_ret; +} + +void GDAPI godot_aabb_set_position(const godot_aabb *p_self, const godot_vector3 *p_v) { + AABB *self = (AABB *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + self->position = *v; +} + +godot_vector3 GDAPI godot_aabb_get_size(const godot_aabb *p_self) { + godot_vector3 raw_ret; + const AABB *self = (const AABB *)p_self; + Vector3 *ret = (Vector3 *)&raw_ret; + *ret = self->size; + return raw_ret; +} + +void GDAPI godot_aabb_set_size(const godot_aabb *p_self, const godot_vector3 *p_v) { + AABB *self = (AABB *)p_self; + const Vector3 *v = (const Vector3 *)p_v; + self->size = *v; +} + +godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self) { + godot_string ret; + const AABB *self = (const AABB *)p_self; + memnew_placement(&ret, String(*self)); + return ret; +} + +godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->get_area(); +} + +godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->has_no_area(); +} + +godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->has_no_surface(); +} + +godot_bool GDAPI godot_aabb_intersects(const godot_aabb *p_self, const godot_aabb *p_with) { + const AABB *self = (const AABB *)p_self; + const AABB *with = (const AABB *)p_with; + return self->intersects(*with); +} + +godot_bool GDAPI godot_aabb_encloses(const godot_aabb *p_self, const godot_aabb *p_with) { + const AABB *self = (const AABB *)p_self; + const AABB *with = (const AABB *)p_with; + return self->encloses(*with); +} + +godot_aabb GDAPI godot_aabb_merge(const godot_aabb *p_self, const godot_aabb *p_with) { + godot_aabb dest; + const AABB *self = (const AABB *)p_self; + const AABB *with = (const AABB *)p_with; + *((AABB *)&dest) = self->merge(*with); + return dest; +} + +godot_aabb GDAPI godot_aabb_intersection(const godot_aabb *p_self, const godot_aabb *p_with) { + godot_aabb dest; + const AABB *self = (const AABB *)p_self; + const AABB *with = (const AABB *)p_with; + *((AABB *)&dest) = self->intersection(*with); + return dest; +} + +godot_bool GDAPI godot_aabb_intersects_plane(const godot_aabb *p_self, const godot_plane *p_plane) { + const AABB *self = (const AABB *)p_self; + const Plane *plane = (const Plane *)p_plane; + return self->intersects_plane(*plane); +} + +godot_bool GDAPI godot_aabb_intersects_segment(const godot_aabb *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to) { + const AABB *self = (const AABB *)p_self; + const Vector3 *from = (const Vector3 *)p_from; + const Vector3 *to = (const Vector3 *)p_to; + return self->intersects_segment(*from, *to); +} + +godot_bool GDAPI godot_aabb_has_point(const godot_aabb *p_self, const godot_vector3 *p_point) { + const AABB *self = (const AABB *)p_self; + const Vector3 *point = (const Vector3 *)p_point; + return self->has_point(*point); +} + +godot_vector3 GDAPI godot_aabb_get_support(const godot_aabb *p_self, const godot_vector3 *p_dir) { + godot_vector3 dest; + const AABB *self = (const AABB *)p_self; + const Vector3 *dir = (const Vector3 *)p_dir; + *((Vector3 *)&dest) = self->get_support(*dir); + return dest; +} + +godot_vector3 GDAPI godot_aabb_get_longest_axis(const godot_aabb *p_self) { + godot_vector3 dest; + const AABB *self = (const AABB *)p_self; + *((Vector3 *)&dest) = self->get_longest_axis(); + return dest; +} + +godot_int GDAPI godot_aabb_get_longest_axis_index(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->get_longest_axis_index(); +} + +godot_real GDAPI godot_aabb_get_longest_axis_size(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->get_longest_axis_size(); +} + +godot_vector3 GDAPI godot_aabb_get_shortest_axis(const godot_aabb *p_self) { + godot_vector3 dest; + const AABB *self = (const AABB *)p_self; + *((Vector3 *)&dest) = self->get_shortest_axis(); + return dest; +} + +godot_int GDAPI godot_aabb_get_shortest_axis_index(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->get_shortest_axis_index(); +} + +godot_real GDAPI godot_aabb_get_shortest_axis_size(const godot_aabb *p_self) { + const AABB *self = (const AABB *)p_self; + return self->get_shortest_axis_size(); +} + +godot_aabb GDAPI godot_aabb_expand(const godot_aabb *p_self, const godot_vector3 *p_to_point) { + godot_aabb dest; + const AABB *self = (const AABB *)p_self; + const Vector3 *to_point = (const Vector3 *)p_to_point; + *((AABB *)&dest) = self->expand(*to_point); + return dest; +} + +godot_aabb GDAPI godot_aabb_grow(const godot_aabb *p_self, const godot_real p_by) { + godot_aabb dest; + const AABB *self = (const AABB *)p_self; + + *((AABB *)&dest) = self->grow(p_by); + return dest; +} + +godot_vector3 GDAPI godot_aabb_get_endpoint(const godot_aabb *p_self, const godot_int p_idx) { + godot_vector3 dest; + const AABB *self = (const AABB *)p_self; + + *((Vector3 *)&dest) = self->get_endpoint(p_idx); + return dest; +} + +godot_bool GDAPI godot_aabb_operator_equal(const godot_aabb *p_self, const godot_aabb *p_b) { + const AABB *self = (const AABB *)p_self; + const AABB *b = (const AABB *)p_b; + return *self == *b; +} + +#ifdef __cplusplus +} +#endif diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp index 51c023981f..e0d9514985 100644 --- a/modules/gdnative/gdnative/array.cpp +++ b/modules/gdnative/gdnative/array.cpp @@ -41,9 +41,6 @@ extern "C" { #endif -void _array_api_anchor() { -} - void GDAPI godot_array_new(godot_array *r_dest) { Array *dest = (Array *)r_dest; memnew_placement(dest, Array); @@ -158,6 +155,11 @@ godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, const godot return (godot_variant *)&self->operator[](p_idx); } +const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, const godot_int p_idx) { + const Array *self = (const Array *)p_self; + return (const godot_variant *)&self->operator[](p_idx); +} + void GDAPI godot_array_append(godot_array *p_self, const godot_variant *p_value) { Array *self = (Array *)p_self; Variant *val = (Variant *)p_value; diff --git a/modules/gdnative/gdnative/basis.cpp b/modules/gdnative/gdnative/basis.cpp index 28af93f942..39ca754dc7 100644 --- a/modules/gdnative/gdnative/basis.cpp +++ b/modules/gdnative/gdnative/basis.cpp @@ -36,8 +36,6 @@ extern "C" { #endif -void _basis_api_anchor() {} - void GDAPI godot_basis_new_with_rows(godot_basis *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis) { const Vector3 *x_axis = (const Vector3 *)p_x_axis; const Vector3 *y_axis = (const Vector3 *)p_y_axis; diff --git a/modules/gdnative/gdnative/color.cpp b/modules/gdnative/gdnative/color.cpp index 2a5c0887a1..281a4c416f 100644 --- a/modules/gdnative/gdnative/color.cpp +++ b/modules/gdnative/gdnative/color.cpp @@ -36,8 +36,6 @@ extern "C" { #endif -void _color_api_anchor() {} - void GDAPI godot_color_new_rgba(godot_color *r_dest, const godot_real p_r, const godot_real p_g, const godot_real p_b, const godot_real p_a) { Color *dest = (Color *)r_dest; diff --git a/modules/gdnative/gdnative/dictionary.cpp b/modules/gdnative/gdnative/dictionary.cpp index ed98cdbb00..8363416946 100644 --- a/modules/gdnative/gdnative/dictionary.cpp +++ b/modules/gdnative/gdnative/dictionary.cpp @@ -38,8 +38,6 @@ extern "C" { #endif -void _dictionary_api_anchor() {} - void GDAPI godot_dictionary_new(godot_dictionary *r_dest) { Dictionary *dest = (Dictionary *)r_dest; memnew_placement(dest, Dictionary); @@ -130,6 +128,12 @@ godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, c return (godot_variant *)&self->operator[](*key); } +const godot_variant GDAPI *godot_dictionary_operator_index_const(const godot_dictionary *p_self, const godot_variant *p_key) { + const Dictionary *self = (const Dictionary *)p_self; + const Variant *key = (const Variant *)p_key; + return (const godot_variant *)&self->operator[](*key); +} + godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key) { Dictionary *self = (Dictionary *)p_self; const Variant *key = (const Variant *)p_key; diff --git a/modules/gdnative/gdnative/gdnative.cpp b/modules/gdnative/gdnative/gdnative.cpp index 64a7c33cf8..6dfa7ec20b 100644 --- a/modules/gdnative/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative/gdnative.cpp @@ -30,57 +30,16 @@ #include "gdnative/gdnative.h" #include "class_db.h" +#include "engine.h" #include "error_macros.h" #include "global_constants.h" #include "os/os.h" -#include "project_settings.h" #include "variant.h" #ifdef __cplusplus extern "C" { #endif -extern "C" void _string_api_anchor(); -extern "C" void _string_name_api_anchor(); -extern "C" void _vector2_api_anchor(); -extern "C" void _rect2_api_anchor(); -extern "C" void _vector3_api_anchor(); -extern "C" void _transform2d_api_anchor(); -extern "C" void _plane_api_anchor(); -extern "C" void _quat_api_anchor(); -extern "C" void _basis_api_anchor(); -extern "C" void _rect3_api_anchor(); -extern "C" void _transform_api_anchor(); -extern "C" void _color_api_anchor(); -extern "C" void _node_path_api_anchor(); -extern "C" void _rid_api_anchor(); -extern "C" void _dictionary_api_anchor(); -extern "C" void _array_api_anchor(); -extern "C" void _pool_arrays_api_anchor(); -extern "C" void _variant_api_anchor(); - -void _api_anchor() { - - _string_api_anchor(); - _string_name_api_anchor(); - _vector2_api_anchor(); - _rect2_api_anchor(); - _vector3_api_anchor(); - _transform2d_api_anchor(); - _plane_api_anchor(); - _quat_api_anchor(); - _rect3_api_anchor(); - _basis_api_anchor(); - _transform_api_anchor(); - _color_api_anchor(); - _node_path_api_anchor(); - _rid_api_anchor(); - _dictionary_api_anchor(); - _array_api_anchor(); - _pool_arrays_api_anchor(); - _variant_api_anchor(); -} - void GDAPI godot_object_destroy(godot_object *p_o) { memdelete((Object *)p_o); } @@ -88,7 +47,7 @@ void GDAPI godot_object_destroy(godot_object *p_o) { // Singleton API godot_object GDAPI *godot_global_get_singleton(char *p_name) { - return (godot_object *)ProjectSettings::get_singleton()->get_singleton_object(String(p_name)); + return (godot_object *)Engine::get_singleton()->get_singleton_object(String(p_name)); } // result shouldn't be freed void GDAPI *godot_get_stack_bottom() { @@ -133,14 +92,6 @@ godot_variant GDAPI godot_method_bind_call(godot_method_bind *p_method_bind, god return ret; } -// @Todo -/* -void GDAPI godot_method_bind_varcall(godot_method_bind *p_method_bind) -{ - -} -*/ - godot_class_constructor GDAPI godot_get_class_constructor(const char *p_classname) { ClassDB::ClassInfo *class_info = ClassDB::classes.getptr(StringName(p_classname)); if (class_info) diff --git a/modules/gdnative/gdnative/node_path.cpp b/modules/gdnative/gdnative/node_path.cpp index 50fade5b94..2bd278e050 100644 --- a/modules/gdnative/gdnative/node_path.cpp +++ b/modules/gdnative/gdnative/node_path.cpp @@ -36,8 +36,6 @@ extern "C" { #endif -void _node_path_api_anchor() {} - void GDAPI godot_node_path_new(godot_node_path *r_dest, const godot_string *p_from) { NodePath *dest = (NodePath *)r_dest; const String *from = (const String *)p_from; diff --git a/modules/gdnative/gdnative/plane.cpp b/modules/gdnative/gdnative/plane.cpp index a5e05ffa6b..c92efb8d99 100644 --- a/modules/gdnative/gdnative/plane.cpp +++ b/modules/gdnative/gdnative/plane.cpp @@ -36,8 +36,6 @@ extern "C" { #endif -void _plane_api_anchor() {} - void GDAPI godot_plane_new_with_reals(godot_plane *r_dest, const godot_real p_a, const godot_real p_b, const godot_real p_c, const godot_real p_d) { Plane *dest = (Plane *)r_dest; diff --git a/modules/gdnative/gdnative/pool_arrays.cpp b/modules/gdnative/gdnative/pool_arrays.cpp index 731e930908..562cc344a9 100644 --- a/modules/gdnative/gdnative/pool_arrays.cpp +++ b/modules/gdnative/gdnative/pool_arrays.cpp @@ -41,9 +41,6 @@ extern "C" { #endif -void _pool_arrays_api_anchor() { -} - #define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr) // byte diff --git a/modules/gdnative/gdnative/quat.cpp b/modules/gdnative/gdnative/quat.cpp index 7db7847da1..2d012c069f 100644 --- a/modules/gdnative/gdnative/quat.cpp +++ b/modules/gdnative/gdnative/quat.cpp @@ -36,8 +36,6 @@ extern "C" { #endif -void _quat_api_anchor() {} - void GDAPI godot_quat_new(godot_quat *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z, const godot_real p_w) { Quat *dest = (Quat *)r_dest; diff --git a/modules/gdnative/gdnative/rect2.cpp b/modules/gdnative/gdnative/rect2.cpp index ecd8cce9ca..b0b0e28138 100644 --- a/modules/gdnative/gdnative/rect2.cpp +++ b/modules/gdnative/gdnative/rect2.cpp @@ -36,8 +36,6 @@ extern "C" { #endif -void _rect2_api_anchor() {} - void GDAPI godot_rect2_new_with_position_and_size(godot_rect2 *r_dest, const godot_vector2 *p_pos, const godot_vector2 *p_size) { const Vector2 *position = (const Vector2 *)p_pos; const Vector2 *size = (const Vector2 *)p_size; diff --git a/modules/gdnative/gdnative/rect3.cpp b/modules/gdnative/gdnative/rect3.cpp deleted file mode 100644 index d34d964db9..0000000000 --- a/modules/gdnative/gdnative/rect3.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/*************************************************************************/ -/* rect3.cpp */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#include "gdnative/rect3.h" - -#include "core/math/rect3.h" -#include "core/variant.h" - -#ifdef __cplusplus -extern "C" { -#endif - -void _rect3_api_anchor() {} - -void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size) { - const Vector3 *pos = (const Vector3 *)p_pos; - const Vector3 *size = (const Vector3 *)p_size; - Rect3 *dest = (Rect3 *)r_dest; - *dest = Rect3(*pos, *size); -} - -godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self) { - godot_vector3 raw_ret; - const Rect3 *self = (const Rect3 *)p_self; - Vector3 *ret = (Vector3 *)&raw_ret; - *ret = self->position; - return raw_ret; -} - -void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v) { - Rect3 *self = (Rect3 *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - self->position = *v; -} - -godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self) { - godot_vector3 raw_ret; - const Rect3 *self = (const Rect3 *)p_self; - Vector3 *ret = (Vector3 *)&raw_ret; - *ret = self->size; - return raw_ret; -} - -void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v) { - Rect3 *self = (Rect3 *)p_self; - const Vector3 *v = (const Vector3 *)p_v; - self->size = *v; -} - -godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self) { - godot_string ret; - const Rect3 *self = (const Rect3 *)p_self; - memnew_placement(&ret, String(*self)); - return ret; -} - -godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_area(); -} - -godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->has_no_area(); -} - -godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->has_no_surface(); -} - -godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with) { - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - return self->intersects(*with); -} - -godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with) { - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - return self->encloses(*with); -} - -godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - *((Rect3 *)&dest) = self->merge(*with); - return dest; -} - -godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *with = (const Rect3 *)p_with; - *((Rect3 *)&dest) = self->intersection(*with); - return dest; -} - -godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane) { - const Rect3 *self = (const Rect3 *)p_self; - const Plane *plane = (const Plane *)p_plane; - return self->intersects_plane(*plane); -} - -godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to) { - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *from = (const Vector3 *)p_from; - const Vector3 *to = (const Vector3 *)p_to; - return self->intersects_segment(*from, *to); -} - -godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point) { - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *point = (const Vector3 *)p_point; - return self->has_point(*point); -} - -godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *dir = (const Vector3 *)p_dir; - *((Vector3 *)&dest) = self->get_support(*dir); - return dest; -} - -godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - *((Vector3 *)&dest) = self->get_longest_axis(); - return dest; -} - -godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_longest_axis_index(); -} - -godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_longest_axis_size(); -} - -godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - *((Vector3 *)&dest) = self->get_shortest_axis(); - return dest; -} - -godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_shortest_axis_index(); -} - -godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self) { - const Rect3 *self = (const Rect3 *)p_self; - return self->get_shortest_axis_size(); -} - -godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - const Vector3 *to_point = (const Vector3 *)p_to_point; - *((Rect3 *)&dest) = self->expand(*to_point); - return dest; -} - -godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by) { - godot_rect3 dest; - const Rect3 *self = (const Rect3 *)p_self; - - *((Rect3 *)&dest) = self->grow(p_by); - return dest; -} - -godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx) { - godot_vector3 dest; - const Rect3 *self = (const Rect3 *)p_self; - - *((Vector3 *)&dest) = self->get_endpoint(p_idx); - return dest; -} - -godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b) { - const Rect3 *self = (const Rect3 *)p_self; - const Rect3 *b = (const Rect3 *)p_b; - return *self == *b; -} - -#ifdef __cplusplus -} -#endif diff --git a/modules/gdnative/gdnative/rid.cpp b/modules/gdnative/gdnative/rid.cpp index f05c39906c..c6e8d82494 100644 --- a/modules/gdnative/gdnative/rid.cpp +++ b/modules/gdnative/gdnative/rid.cpp @@ -37,8 +37,6 @@ extern "C" { #endif -void _rid_api_anchor() {} - void GDAPI godot_rid_new(godot_rid *r_dest) { RID *dest = (RID *)r_dest; memnew_placement(dest, RID); diff --git a/modules/gdnative/gdnative/string.cpp b/modules/gdnative/gdnative/string.cpp index 619003083d..781b8754bd 100644 --- a/modules/gdnative/gdnative/string.cpp +++ b/modules/gdnative/gdnative/string.cpp @@ -39,9 +39,6 @@ extern "C" { #endif -void _string_api_anchor() { -} - void GDAPI godot_string_new(godot_string *r_dest) { String *dest = (String *)r_dest; memnew_placement(dest, String); diff --git a/modules/gdnative/gdnative/string_name.cpp b/modules/gdnative/gdnative/string_name.cpp index 5c00fdfc2f..5c79e0acbd 100644 --- a/modules/gdnative/gdnative/string_name.cpp +++ b/modules/gdnative/gdnative/string_name.cpp @@ -38,9 +38,6 @@ extern "C" { #endif -void _string_name_api_anchor() { -} - void GDAPI godot_string_name_new(godot_string_name *r_dest, const godot_string *p_name) { StringName *dest = (StringName *)r_dest; const String *name = (const String *)p_name; diff --git a/modules/gdnative/gdnative/transform.cpp b/modules/gdnative/gdnative/transform.cpp index d7a3e78d3f..b07fcffcb6 100644 --- a/modules/gdnative/gdnative/transform.cpp +++ b/modules/gdnative/gdnative/transform.cpp @@ -36,8 +36,6 @@ extern "C" { #endif -void _transform_api_anchor() {} - void GDAPI godot_transform_new_with_axis_origin(godot_transform *r_dest, const godot_vector3 *p_x_axis, const godot_vector3 *p_y_axis, const godot_vector3 *p_z_axis, const godot_vector3 *p_origin) { const Vector3 *x_axis = (const Vector3 *)p_x_axis; const Vector3 *y_axis = (const Vector3 *)p_y_axis; @@ -200,20 +198,20 @@ godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_s return raw_dest; } -godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v) { - godot_rect3 raw_dest; - Rect3 *dest = (Rect3 *)&raw_dest; +godot_aabb GDAPI godot_transform_xform_aabb(const godot_transform *p_self, const godot_aabb *p_v) { + godot_aabb raw_dest; + AABB *dest = (AABB *)&raw_dest; const Transform *self = (const Transform *)p_self; - const Rect3 *v = (const Rect3 *)p_v; + const AABB *v = (const AABB *)p_v; *dest = self->xform(*v); return raw_dest; } -godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v) { - godot_rect3 raw_dest; - Rect3 *dest = (Rect3 *)&raw_dest; +godot_aabb GDAPI godot_transform_xform_inv_aabb(const godot_transform *p_self, const godot_aabb *p_v) { + godot_aabb raw_dest; + AABB *dest = (AABB *)&raw_dest; const Transform *self = (const Transform *)p_self; - const Rect3 *v = (const Rect3 *)p_v; + const AABB *v = (const AABB *)p_v; *dest = self->xform_inv(*v); return raw_dest; } diff --git a/modules/gdnative/gdnative/transform2d.cpp b/modules/gdnative/gdnative/transform2d.cpp index dcb54f7a53..0a6334516b 100644 --- a/modules/gdnative/gdnative/transform2d.cpp +++ b/modules/gdnative/gdnative/transform2d.cpp @@ -36,8 +36,6 @@ extern "C" { #endif -void _transform2d_api_anchor() {} - void GDAPI godot_transform2d_new(godot_transform2d *r_dest, const godot_real p_rot, const godot_vector2 *p_pos) { const Vector2 *pos = (const Vector2 *)p_pos; Transform2D *dest = (Transform2D *)r_dest; diff --git a/modules/gdnative/gdnative/variant.cpp b/modules/gdnative/gdnative/variant.cpp index 9ba4166c1d..6483d19d74 100644 --- a/modules/gdnative/gdnative/variant.cpp +++ b/modules/gdnative/gdnative/variant.cpp @@ -36,8 +36,6 @@ extern "C" { #endif -void _variant_api_anchor() {} - #define memnew_placement_custom(m_placement, m_class, m_constr) _post_initialize(new (m_placement, sizeof(m_class), "") m_constr) // Constructors @@ -120,10 +118,10 @@ void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_qua memnew_placement_custom(dest, Variant, Variant(*quat)); } -void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3) { +void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb) { Variant *dest = (Variant *)r_dest; - Rect3 *rect3 = (Rect3 *)p_rect3; - memnew_placement_custom(dest, Variant, Variant(*rect3)); + AABB *aabb = (AABB *)p_aabb; + memnew_placement_custom(dest, Variant, Variant(*aabb)); } void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis) { @@ -306,10 +304,10 @@ godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self) { return raw_dest; } -godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self) { - godot_rect3 raw_dest; +godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self) { + godot_aabb raw_dest; const Variant *self = (const Variant *)p_self; - Rect3 *dest = (Rect3 *)&raw_dest; + AABB *dest = (AABB *)&raw_dest; *dest = *self; return raw_dest; } diff --git a/modules/gdnative/gdnative/vector2.cpp b/modules/gdnative/gdnative/vector2.cpp index 67f858997f..7a5b29e0c4 100644 --- a/modules/gdnative/gdnative/vector2.cpp +++ b/modules/gdnative/gdnative/vector2.cpp @@ -36,8 +36,6 @@ extern "C" { #endif -void _vector2_api_anchor() {} - void GDAPI godot_vector2_new(godot_vector2 *r_dest, const godot_real p_x, const godot_real p_y) { Vector2 *dest = (Vector2 *)r_dest; diff --git a/modules/gdnative/gdnative/vector3.cpp b/modules/gdnative/gdnative/vector3.cpp index c85a3f1c08..11ffb3320b 100644 --- a/modules/gdnative/gdnative/vector3.cpp +++ b/modules/gdnative/gdnative/vector3.cpp @@ -36,8 +36,6 @@ extern "C" { #endif -void _vector3_api_anchor() {} - void GDAPI godot_vector3_new(godot_vector3 *r_dest, const godot_real p_x, const godot_real p_y, const godot_real p_z) { Vector3 *dest = (Vector3 *)r_dest; diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index ac0293172d..877c65dfb9 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -1,5734 +1,5792 @@ { - "version": "1.0.0", - "api": [ - { - "name": "godot_color_new_rgba", - "return_type": "void", - "arguments": [ - ["godot_color *", "r_dest"], - ["const godot_real", "p_r"], - ["const godot_real", "p_g"], - ["const godot_real", "p_b"], - ["const godot_real", "p_a"] - ] - }, - { - "name": "godot_color_new_rgb", - "return_type": "void", - "arguments": [ - ["godot_color *", "r_dest"], - ["const godot_real", "p_r"], - ["const godot_real", "p_g"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_color_get_r", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_set_r", - "return_type": "void", - "arguments": [ - ["godot_color *", "p_self"], - ["const godot_real", "r"] - ] - }, - { - "name": "godot_color_get_g", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_set_g", - "return_type": "void", - "arguments": [ - ["godot_color *", "p_self"], - ["const godot_real", "g"] - ] - }, - { - "name": "godot_color_get_b", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_set_b", - "return_type": "void", - "arguments": [ - ["godot_color *", "p_self"], - ["const godot_real", "b"] - ] - }, - { - "name": "godot_color_get_a", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_set_a", - "return_type": "void", - "arguments": [ - ["godot_color *", "p_self"], - ["const godot_real", "a"] - ] - }, - { - "name": "godot_color_get_h", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_get_s", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_get_v", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_to_rgba32", - "return_type": "godot_int", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_to_argb32", - "return_type": "godot_int", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_gray", - "return_type": "godot_real", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_inverted", - "return_type": "godot_color", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_contrasted", - "return_type": "godot_color", - "arguments": [ - ["const godot_color *", "p_self"] - ] - }, - { - "name": "godot_color_linear_interpolate", - "return_type": "godot_color", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_color *", "p_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_color_blend", - "return_type": "godot_color", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_color *", "p_over"] - ] - }, - { - "name": "godot_color_to_html", - "return_type": "godot_string", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_bool", "p_with_alpha"] - ] - }, - { - "name": "godot_color_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_color *", "p_b"] - ] - }, - { - "name": "godot_color_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_color *", "p_self"], - ["const godot_color *", "p_b"] - ] - }, - { - "name": "godot_vector2_new", - "return_type": "void", - "arguments": [ - ["godot_vector2 *", "r_dest"], - ["const godot_real", "p_x"], - ["const godot_real", "p_y"] - ] - }, - { - "name": "godot_vector2_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_normalized", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_length", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_angle", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_length_squared", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_is_normalized", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_distance_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_to"] - ] - }, - { - "name": "godot_vector2_distance_squared_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_to"] - ] - }, - { - "name": "godot_vector2_angle_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_to"] - ] - }, - { - "name": "godot_vector2_angle_to_point", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_to"] - ] - }, - { - "name": "godot_vector2_linear_interpolate", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_vector2_cubic_interpolate", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"], - ["const godot_vector2 *", "p_pre_a"], - ["const godot_vector2 *", "p_post_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_vector2_rotated", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_vector2_tangent", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_floor", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_snapped", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_by"] - ] - }, - { - "name": "godot_vector2_aspect", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_dot", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_with"] - ] - }, - { - "name": "godot_vector2_slide", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_n"] - ] - }, - { - "name": "godot_vector2_bounce", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_n"] - ] - }, - { - "name": "godot_vector2_reflect", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_n"] - ] - }, - { - "name": "godot_vector2_abs", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_clamped", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_real", "p_length"] - ] - }, - { - "name": "godot_vector2_operator_add", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_substract", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_multiply_vector", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_multiply_scalar", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_divide_vector", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_divide_scalar", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector2 *", "p_self"], - ["const godot_vector2 *", "p_b"] - ] - }, - { - "name": "godot_vector2_operator_neg", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_set_x", - "return_type": "void", - "arguments": [ - ["godot_vector2 *", "p_self"], - ["const godot_real", "p_x"] - ] - }, - { - "name": "godot_vector2_set_y", - "return_type": "void", - "arguments": [ - ["godot_vector2 *", "p_self"], - ["const godot_real", "p_y"] - ] - }, - { - "name": "godot_vector2_get_x", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_vector2_get_y", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector2 *", "p_self"] - ] - }, - { - "name": "godot_quat_new", - "return_type": "void", - "arguments": [ - ["godot_quat *", "r_dest"], - ["const godot_real", "p_x"], - ["const godot_real", "p_y"], - ["const godot_real", "p_z"], - ["const godot_real", "p_w"] - ] - }, - { - "name": "godot_quat_new_with_axis_angle", - "return_type": "void", - "arguments": [ - ["godot_quat *", "r_dest"], - ["const godot_vector3 *", "p_axis"], - ["const godot_real", "p_angle"] - ] - }, - { - "name": "godot_quat_get_x", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_set_x", - "return_type": "void", - "arguments": [ - ["godot_quat *", "p_self"], - ["const godot_real", "val"] - ] - }, - { - "name": "godot_quat_get_y", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_set_y", - "return_type": "void", - "arguments": [ - ["godot_quat *", "p_self"], - ["const godot_real", "val"] - ] - }, - { - "name": "godot_quat_get_z", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_set_z", - "return_type": "void", - "arguments": [ - ["godot_quat *", "p_self"], - ["const godot_real", "val"] - ] - }, - { - "name": "godot_quat_get_w", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_set_w", - "return_type": "void", - "arguments": [ - ["godot_quat *", "p_self"], - ["const godot_real", "val"] - ] - }, - { - "name": "godot_quat_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_length", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_length_squared", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_normalized", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_is_normalized", - "return_type": "godot_bool", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_inverse", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_quat_dot", - "return_type": "godot_real", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"] - ] - }, - { - "name": "godot_quat_xform", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_quat_slerp", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_quat_slerpni", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_quat_cubic_slerp", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"], - ["const godot_quat *", "p_pre_a"], - ["const godot_quat *", "p_post_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_quat_operator_multiply", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_quat_operator_add", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"] - ] - }, - { - "name": "godot_quat_operator_substract", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"] - ] - }, - { - "name": "godot_quat_operator_divide", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_quat_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_quat *", "p_self"], - ["const godot_quat *", "p_b"] - ] - }, - { - "name": "godot_quat_operator_neg", - "return_type": "godot_quat", - "arguments": [ - ["const godot_quat *", "p_self"] - ] - }, - { - "name": "godot_basis_new_with_rows", - "return_type": "void", - "arguments": [ - ["godot_basis *", "r_dest"], - ["const godot_vector3 *", "p_x_axis"], - ["const godot_vector3 *", "p_y_axis"], - ["const godot_vector3 *", "p_z_axis"] - ] - }, - { - "name": "godot_basis_new_with_axis_and_angle", - "return_type": "void", - "arguments": [ - ["godot_basis *", "r_dest"], - ["const godot_vector3 *", "p_axis"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_basis_new_with_euler", - "return_type": "void", - "arguments": [ - ["godot_basis *", "r_dest"], - ["const godot_vector3 *", "p_euler"] - ] - }, - { - "name": "godot_basis_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_inverse", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_transposed", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_orthonormalized", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_determinant", - "return_type": "godot_real", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_rotated", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_axis"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_basis_scaled", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_scale"] - ] - }, - { - "name": "godot_basis_get_scale", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_get_euler", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_tdotx", - "return_type": "godot_real", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_with"] - ] - }, - { - "name": "godot_basis_tdoty", - "return_type": "godot_real", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_with"] - ] - }, - { - "name": "godot_basis_tdotz", - "return_type": "godot_real", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_with"] - ] - }, - { - "name": "godot_basis_xform", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_basis_xform_inv", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_basis_get_orthogonal_index", - "return_type": "godot_int", - "arguments": [ - ["const godot_basis *", "p_self"] - ] - }, - { - "name": "godot_basis_new", - "return_type": "void", - "arguments": [ - ["godot_basis *", "r_dest"] - ] - }, - { - "name": "godot_basis_new_with_euler_quat", - "return_type": "void", - "arguments": [ - ["godot_basis *", "r_dest"], - ["const godot_quat *", "p_euler"] - ] - }, - { - "name": "godot_basis_get_elements", - "return_type": "void", - "arguments": [ - ["const godot_basis *", "p_self"], - ["godot_vector3 *", "p_elements"] - ] - }, - { - "name": "godot_basis_get_axis", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_int", "p_axis"] - ] - }, - { - "name": "godot_basis_set_axis", - "return_type": "void", - "arguments": [ - ["godot_basis *", "p_self"], - ["const godot_int", "p_axis"], - ["const godot_vector3 *", "p_value"] - ] - }, - { - "name": "godot_basis_get_row", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_int", "p_row"] - ] - }, - { - "name": "godot_basis_set_row", - "return_type": "void", - "arguments": [ - ["godot_basis *", "p_self"], - ["const godot_int", "p_row"], - ["const godot_vector3 *", "p_value"] - ] - }, - { - "name": "godot_basis_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_basis *", "p_b"] - ] - }, - { - "name": "godot_basis_operator_add", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_basis *", "p_b"] - ] - }, - { - "name": "godot_basis_operator_substract", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_basis *", "p_b"] - ] - }, - { - "name": "godot_basis_operator_multiply_vector", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_basis *", "p_b"] - ] - }, - { - "name": "godot_basis_operator_multiply_scalar", - "return_type": "godot_basis", - "arguments": [ - ["const godot_basis *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_vector3_new", - "return_type": "void", - "arguments": [ - ["godot_vector3 *", "r_dest"], - ["const godot_real", "p_x"], - ["const godot_real", "p_y"], - ["const godot_real", "p_z"] - ] - }, - { - "name": "godot_vector3_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_min_axis", - "return_type": "godot_int", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_max_axis", - "return_type": "godot_int", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_length", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_length_squared", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_is_normalized", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_normalized", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_inverse", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_snapped", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_by"] - ] - }, - { - "name": "godot_vector3_rotated", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_axis"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_vector3_linear_interpolate", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_vector3_cubic_interpolate", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"], - ["const godot_vector3 *", "p_pre_a"], - ["const godot_vector3 *", "p_post_b"], - ["const godot_real", "p_t"] - ] - }, - { - "name": "godot_vector3_dot", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_cross", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_outer", - "return_type": "godot_basis", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_to_diagonal_matrix", - "return_type": "godot_basis", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_abs", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_floor", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_ceil", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_distance_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_distance_squared_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_angle_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_to"] - ] - }, - { - "name": "godot_vector3_slide", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_n"] - ] - }, - { - "name": "godot_vector3_bounce", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_n"] - ] - }, - { - "name": "godot_vector3_reflect", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_n"] - ] - }, - { - "name": "godot_vector3_operator_add", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_substract", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_multiply_vector", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_multiply_scalar", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_divide_vector", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_divide_scalar", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_real", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3 *", "p_b"] - ] - }, - { - "name": "godot_vector3_operator_neg", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_vector3 *", "p_self"] - ] - }, - { - "name": "godot_vector3_set_axis", - "return_type": "void", - "arguments": [ - ["godot_vector3 *", "p_self"], - ["const godot_vector3_axis", "p_axis"], - ["const godot_real", "p_val"] - ] - }, - { - "name": "godot_vector3_get_axis", - "return_type": "godot_real", - "arguments": [ - ["const godot_vector3 *", "p_self"], - ["const godot_vector3_axis", "p_axis"] - ] - }, - { - "name": "godot_pool_byte_array_new", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array *", "r_dest"] - ] - }, - { - "name": "godot_pool_byte_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array *", "r_dest"], - ["const godot_pool_byte_array *", "p_src"] - ] - }, - { - "name": "godot_pool_byte_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_pool_byte_array_append", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array *", "p_self"], - ["const uint8_t", "p_data"] - ] - }, - { - "name": "godot_pool_byte_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array *", "p_self"], - ["const godot_pool_byte_array *", "p_array"] - ] - }, - { - "name": "godot_pool_byte_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_pool_byte_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const uint8_t", "p_data"] - ] - }, - { - "name": "godot_pool_byte_array_invert", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array *", "p_self"] - ] - }, - { - "name": "godot_pool_byte_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array *", "p_self"], - ["const uint8_t", "p_data"] - ] - }, - { - "name": "godot_pool_byte_array_remove", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_byte_array_resize", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_pool_byte_array_read", - "return_type": "godot_pool_byte_array_read_access *", - "arguments": [ - ["const godot_pool_byte_array *", "p_self"] - ] - }, - { - "name": "godot_pool_byte_array_write", - "return_type": "godot_pool_byte_array_write_access *", - "arguments": [ - ["godot_pool_byte_array *", "p_self"] - ] - }, - { - "name": "godot_pool_byte_array_set", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const uint8_t", "p_data"] - ] - }, - { - "name": "godot_pool_byte_array_get", - "return_type": "uint8_t", - "arguments": [ - ["const godot_pool_byte_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_byte_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_pool_byte_array *", "p_self"] - ] - }, - { - "name": "godot_pool_byte_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array *", "p_self"] - ] - }, - { - "name": "godot_pool_int_array_new", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array *", "r_dest"] - ] - }, - { - "name": "godot_pool_int_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array *", "r_dest"], - ["const godot_pool_int_array *", "p_src"] - ] - }, - { - "name": "godot_pool_int_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_pool_int_array_append", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array *", "p_self"], - ["const godot_int", "p_data"] - ] - }, - { - "name": "godot_pool_int_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array *", "p_self"], - ["const godot_pool_int_array *", "p_array"] - ] - }, - { - "name": "godot_pool_int_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_pool_int_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_int", "p_data"] - ] - }, - { - "name": "godot_pool_int_array_invert", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array *", "p_self"] - ] - }, - { - "name": "godot_pool_int_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array *", "p_self"], - ["const godot_int", "p_data"] - ] - }, - { - "name": "godot_pool_int_array_remove", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_int_array_resize", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_pool_int_array_read", - "return_type": "godot_pool_int_array_read_access *", - "arguments": [ - ["const godot_pool_int_array *", "p_self"] - ] - }, - { - "name": "godot_pool_int_array_write", - "return_type": "godot_pool_int_array_write_access *", - "arguments": [ - ["godot_pool_int_array *", "p_self"] - ] - }, - { - "name": "godot_pool_int_array_set", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_int", "p_data"] - ] - }, - { - "name": "godot_pool_int_array_get", - "return_type": "godot_int", - "arguments": [ - ["const godot_pool_int_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_int_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_pool_int_array *", "p_self"] - ] - }, - { - "name": "godot_pool_int_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array *", "p_self"] - ] - }, - { - "name": "godot_pool_real_array_new", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array *", "r_dest"] - ] - }, - { - "name": "godot_pool_real_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array *", "r_dest"], - ["const godot_pool_real_array *", "p_src"] - ] - }, - { - "name": "godot_pool_real_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_pool_real_array_append", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array *", "p_self"], - ["const godot_real", "p_data"] - ] - }, - { - "name": "godot_pool_real_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array *", "p_self"], - ["const godot_pool_real_array *", "p_array"] - ] - }, - { - "name": "godot_pool_real_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_pool_real_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_real", "p_data"] - ] - }, - { - "name": "godot_pool_real_array_invert", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array *", "p_self"] - ] - }, - { - "name": "godot_pool_real_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array *", "p_self"], - ["const godot_real", "p_data"] - ] - }, - { - "name": "godot_pool_real_array_remove", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_real_array_resize", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_pool_real_array_read", - "return_type": "godot_pool_real_array_read_access *", - "arguments": [ - ["const godot_pool_real_array *", "p_self"] - ] - }, - { - "name": "godot_pool_real_array_write", - "return_type": "godot_pool_real_array_write_access *", - "arguments": [ - ["godot_pool_real_array *", "p_self"] - ] - }, - { - "name": "godot_pool_real_array_set", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_real", "p_data"] - ] - }, - { - "name": "godot_pool_real_array_get", - "return_type": "godot_real", - "arguments": [ - ["const godot_pool_real_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_real_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_pool_real_array *", "p_self"] - ] - }, - { - "name": "godot_pool_real_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array *", "p_self"] - ] - }, - { - "name": "godot_pool_string_array_new", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array *", "r_dest"] - ] - }, - { - "name": "godot_pool_string_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array *", "r_dest"], - ["const godot_pool_string_array *", "p_src"] - ] - }, - { - "name": "godot_pool_string_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_pool_string_array_append", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array *", "p_self"], - ["const godot_string *", "p_data"] - ] - }, - { - "name": "godot_pool_string_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array *", "p_self"], - ["const godot_pool_string_array *", "p_array"] - ] - }, - { - "name": "godot_pool_string_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_pool_string_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_string *", "p_data"] - ] - }, - { - "name": "godot_pool_string_array_invert", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array *", "p_self"] - ] - }, - { - "name": "godot_pool_string_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array *", "p_self"], - ["const godot_string *", "p_data"] - ] - }, - { - "name": "godot_pool_string_array_remove", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_string_array_resize", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_pool_string_array_read", - "return_type": "godot_pool_string_array_read_access *", - "arguments": [ - ["const godot_pool_string_array *", "p_self"] - ] - }, - { - "name": "godot_pool_string_array_write", - "return_type": "godot_pool_string_array_write_access *", - "arguments": [ - ["godot_pool_string_array *", "p_self"] - ] - }, - { - "name": "godot_pool_string_array_set", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_string *", "p_data"] - ] - }, - { - "name": "godot_pool_string_array_get", - "return_type": "godot_string", - "arguments": [ - ["const godot_pool_string_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_string_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_pool_string_array *", "p_self"] - ] - }, - { - "name": "godot_pool_string_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array *", "p_self"] - ] - }, - { - "name": "godot_pool_vector2_array_new", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array *", "r_dest"] - ] - }, - { - "name": "godot_pool_vector2_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array *", "r_dest"], - ["const godot_pool_vector2_array *", "p_src"] - ] - }, - { - "name": "godot_pool_vector2_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_pool_vector2_array_append", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array *", "p_self"], - ["const godot_vector2 *", "p_data"] - ] - }, - { - "name": "godot_pool_vector2_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array *", "p_self"], - ["const godot_pool_vector2_array *", "p_array"] - ] - }, - { - "name": "godot_pool_vector2_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_pool_vector2_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_vector2 *", "p_data"] - ] - }, - { - "name": "godot_pool_vector2_array_invert", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_pool_vector2_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array *", "p_self"], - ["const godot_vector2 *", "p_data"] - ] - }, - { - "name": "godot_pool_vector2_array_remove", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_vector2_array_resize", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_pool_vector2_array_read", - "return_type": "godot_pool_vector2_array_read_access *", - "arguments": [ - ["const godot_pool_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_pool_vector2_array_write", - "return_type": "godot_pool_vector2_array_write_access *", - "arguments": [ - ["godot_pool_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_pool_vector2_array_set", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_vector2 *", "p_data"] - ] - }, - { - "name": "godot_pool_vector2_array_get", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_pool_vector2_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_vector2_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_pool_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_pool_vector2_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array *", "p_self"] - ] - }, - { - "name": "godot_pool_vector3_array_new", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array *", "r_dest"] - ] - }, - { - "name": "godot_pool_vector3_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array *", "r_dest"], - ["const godot_pool_vector3_array *", "p_src"] - ] - }, - { - "name": "godot_pool_vector3_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_pool_vector3_array_append", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array *", "p_self"], - ["const godot_vector3 *", "p_data"] - ] - }, - { - "name": "godot_pool_vector3_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array *", "p_self"], - ["const godot_pool_vector3_array *", "p_array"] - ] - }, - { - "name": "godot_pool_vector3_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_pool_vector3_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_vector3 *", "p_data"] - ] - }, - { - "name": "godot_pool_vector3_array_invert", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_pool_vector3_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array *", "p_self"], - ["const godot_vector3 *", "p_data"] - ] - }, - { - "name": "godot_pool_vector3_array_remove", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_vector3_array_resize", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_pool_vector3_array_read", - "return_type": "godot_pool_vector3_array_read_access *", - "arguments": [ - ["const godot_pool_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_pool_vector3_array_write", - "return_type": "godot_pool_vector3_array_write_access *", - "arguments": [ - ["godot_pool_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_pool_vector3_array_set", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_vector3 *", "p_data"] - ] - }, - { - "name": "godot_pool_vector3_array_get", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_pool_vector3_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_vector3_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_pool_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_pool_vector3_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array *", "p_self"] - ] - }, - { - "name": "godot_pool_color_array_new", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array *", "r_dest"] - ] - }, - { - "name": "godot_pool_color_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array *", "r_dest"], - ["const godot_pool_color_array *", "p_src"] - ] - }, - { - "name": "godot_pool_color_array_new_with_array", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array *", "r_dest"], - ["const godot_array *", "p_a"] - ] - }, - { - "name": "godot_pool_color_array_append", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array *", "p_self"], - ["const godot_color *", "p_data"] - ] - }, - { - "name": "godot_pool_color_array_append_array", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array *", "p_self"], - ["const godot_pool_color_array *", "p_array"] - ] - }, - { - "name": "godot_pool_color_array_insert", - "return_type": "godot_error", - "arguments": [ - ["godot_pool_color_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_color *", "p_data"] - ] - }, - { - "name": "godot_pool_color_array_invert", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array *", "p_self"] - ] - }, - { - "name": "godot_pool_color_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array *", "p_self"], - ["const godot_color *", "p_data"] - ] - }, - { - "name": "godot_pool_color_array_remove", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_color_array_resize", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_pool_color_array_read", - "return_type": "godot_pool_color_array_read_access *", - "arguments": [ - ["const godot_pool_color_array *", "p_self"] - ] - }, - { - "name": "godot_pool_color_array_write", - "return_type": "godot_pool_color_array_write_access *", - "arguments": [ - ["godot_pool_color_array *", "p_self"] - ] - }, - { - "name": "godot_pool_color_array_set", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_color *", "p_data"] - ] - }, - { - "name": "godot_pool_color_array_get", - "return_type": "godot_color", - "arguments": [ - ["const godot_pool_color_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_pool_color_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_pool_color_array *", "p_self"] - ] - }, - { - "name": "godot_pool_color_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array *", "p_self"] - ] - }, - { - "name": "godot_pool_byte_array_read_access_ptr", - "return_type": "const uint8_t *", - "arguments": [ - ["const godot_pool_byte_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_byte_array_read_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array_read_access *", "p_read"], - ["godot_pool_byte_array_read_access *", "p_other"] - ] - }, - { - "name": "godot_pool_byte_array_read_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_int_array_read_access_ptr", - "return_type": "const godot_int *", - "arguments": [ - ["const godot_pool_int_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_int_array_read_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array_read_access *", "p_read"], - ["godot_pool_int_array_read_access *", "p_other"] - ] - }, - { - "name": "godot_pool_int_array_read_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_real_array_read_access_ptr", - "return_type": "const godot_real *", - "arguments": [ - ["const godot_pool_real_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_real_array_read_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array_read_access *", "p_read"], - ["godot_pool_real_array_read_access *", "p_other"] - ] - }, - { - "name": "godot_pool_real_array_read_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_string_array_read_access_ptr", - "return_type": "const godot_string *", - "arguments": [ - ["const godot_pool_string_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_string_array_read_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array_read_access *", "p_read"], - ["godot_pool_string_array_read_access *", "p_other"] - ] - }, - { - "name": "godot_pool_string_array_read_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_vector2_array_read_access_ptr", - "return_type": "const godot_vector2 *", - "arguments": [ - ["const godot_pool_vector2_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_vector2_array_read_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array_read_access *", "p_read"], - ["godot_pool_vector2_array_read_access *", "p_other"] - ] - }, - { - "name": "godot_pool_vector2_array_read_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_vector3_array_read_access_ptr", - "return_type": "const godot_vector3 *", - "arguments": [ - ["const godot_pool_vector3_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_vector3_array_read_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array_read_access *", "p_read"], - ["godot_pool_vector3_array_read_access *", "p_other"] - ] - }, - { - "name": "godot_pool_vector3_array_read_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_color_array_read_access_ptr", - "return_type": "const godot_color *", - "arguments": [ - ["const godot_pool_color_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_color_array_read_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array_read_access *", "p_read"], - ["godot_pool_color_array_read_access *", "p_other"] - ] - }, - { - "name": "godot_pool_color_array_read_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array_read_access *", "p_read"] - ] - }, - { - "name": "godot_pool_byte_array_write_access_ptr", - "return_type": "uint8_t *", - "arguments": [ - ["const godot_pool_byte_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_byte_array_write_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array_write_access *", "p_write"], - ["godot_pool_byte_array_write_access *", "p_other"] - ] - }, - { - "name": "godot_pool_byte_array_write_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_byte_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_int_array_write_access_ptr", - "return_type": "godot_int *", - "arguments": [ - ["const godot_pool_int_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_int_array_write_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array_write_access *", "p_write"], - ["godot_pool_int_array_write_access *", "p_other"] - ] - }, - { - "name": "godot_pool_int_array_write_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_int_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_real_array_write_access_ptr", - "return_type": "godot_real *", - "arguments": [ - ["const godot_pool_real_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_real_array_write_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array_write_access *", "p_write"], - ["godot_pool_real_array_write_access *", "p_other"] - ] - }, - { - "name": "godot_pool_real_array_write_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_real_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_string_array_write_access_ptr", - "return_type": "godot_string *", - "arguments": [ - ["const godot_pool_string_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_string_array_write_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array_write_access *", "p_write"], - ["godot_pool_string_array_write_access *", "p_other"] - ] - }, - { - "name": "godot_pool_string_array_write_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_string_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_vector2_array_write_access_ptr", - "return_type": "godot_vector2 *", - "arguments": [ - ["const godot_pool_vector2_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_vector2_array_write_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array_write_access *", "p_write"], - ["godot_pool_vector2_array_write_access *", "p_other"] - ] - }, - { - "name": "godot_pool_vector2_array_write_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_vector2_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_vector3_array_write_access_ptr", - "return_type": "godot_vector3 *", - "arguments": [ - ["const godot_pool_vector3_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_vector3_array_write_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array_write_access *", "p_write"], - ["godot_pool_vector3_array_write_access *", "p_other"] - ] - }, - { - "name": "godot_pool_vector3_array_write_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_vector3_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_color_array_write_access_ptr", - "return_type": "godot_color *", - "arguments": [ - ["const godot_pool_color_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_pool_color_array_write_access_operator_assign", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array_write_access *", "p_write"], - ["godot_pool_color_array_write_access *", "p_other"] - ] - }, - { - "name": "godot_pool_color_array_write_access_destroy", - "return_type": "void", - "arguments": [ - ["godot_pool_color_array_write_access *", "p_write"] - ] - }, - { - "name": "godot_array_new", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"] - ] - }, - { - "name": "godot_array_new_copy", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_array *", "p_src"] - ] - }, - { - "name": "godot_array_new_pool_color_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_pool_color_array *", "p_pca"] - ] - }, - { - "name": "godot_array_new_pool_vector3_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_pool_vector3_array *", "p_pv3a"] - ] - }, - { - "name": "godot_array_new_pool_vector2_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_pool_vector2_array *", "p_pv2a"] - ] - }, - { - "name": "godot_array_new_pool_string_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_pool_string_array *", "p_psa"] - ] - }, - { - "name": "godot_array_new_pool_real_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_pool_real_array *", "p_pra"] - ] - }, - { - "name": "godot_array_new_pool_int_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_pool_int_array *", "p_pia"] - ] - }, - { - "name": "godot_array_new_pool_byte_array", - "return_type": "void", - "arguments": [ - ["godot_array *", "r_dest"], - ["const godot_pool_byte_array *", "p_pba"] - ] - }, - { - "name": "godot_array_set", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_int", "p_idx"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_get", - "return_type": "godot_variant", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_array_operator_index", - "return_type": "godot_variant *", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_array_append", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_clear", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_count", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_erase", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_front", - "return_type": "godot_variant", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_back", - "return_type": "godot_variant", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_find", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_variant *", "p_what"], - ["const godot_int", "p_from"] - ] - }, - { - "name": "godot_array_find_last", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_variant *", "p_what"] - ] - }, - { - "name": "godot_array_has", - "return_type": "godot_bool", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_hash", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_insert", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_int", "p_pos"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_invert", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_pop_back", - "return_type": "godot_variant", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_pop_front", - "return_type": "godot_variant", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_push_back", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_push_front", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_array_remove", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_array_resize", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["const godot_int", "p_size"] - ] - }, - { - "name": "godot_array_rfind", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"], - ["const godot_variant *", "p_what"], - ["const godot_int", "p_from"] - ] - }, - { - "name": "godot_array_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_sort", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_array_sort_custom", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"], - ["godot_object *", "p_obj"], - ["const godot_string *", "p_func"] - ] - }, - { - "name": "godot_array_destroy", - "return_type": "void", - "arguments": [ - ["godot_array *", "p_self"] - ] - }, - { - "name": "godot_dictionary_new", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "r_dest"] - ] - }, - { - "name": "godot_dictionary_new_copy", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "r_dest"], - ["const godot_dictionary *", "p_src"] - ] - }, - { - "name": "godot_dictionary_destroy", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_size", - "return_type": "godot_int", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_clear", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_has", - "return_type": "godot_bool", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_dictionary_has_all", - "return_type": "godot_bool", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_array *", "p_keys"] - ] - }, - { - "name": "godot_dictionary_erase", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_dictionary_hash", - "return_type": "godot_int", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_keys", - "return_type": "godot_array", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_values", - "return_type": "godot_array", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_dictionary_get", - "return_type": "godot_variant", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_dictionary_set", - "return_type": "void", - "arguments": [ - ["godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"], - ["const godot_variant *", "p_value"] - ] - }, - { - "name": "godot_dictionary_operator_index", - "return_type": "godot_variant *", - "arguments": [ - ["godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_dictionary_next", - "return_type": "godot_variant *", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_variant *", "p_key"] - ] - }, - { - "name": "godot_dictionary_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_dictionary *", "p_self"], - ["const godot_dictionary *", "p_b"] - ] - }, - { - "name": "godot_dictionary_to_json", - "return_type": "godot_string", - "arguments": [ - ["const godot_dictionary *", "p_self"] - ] - }, - { - "name": "godot_node_path_new", - "return_type": "void", - "arguments": [ - ["godot_node_path *", "r_dest"], - ["const godot_string *", "p_from"] - ] - }, - { - "name": "godot_node_path_new_copy", - "return_type": "void", - "arguments": [ - ["godot_node_path *", "r_dest"], - ["const godot_node_path *", "p_src"] - ] - }, - { - "name": "godot_node_path_destroy", - "return_type": "void", - "arguments": [ - ["godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_is_absolute", - "return_type": "godot_bool", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_get_name_count", - "return_type": "godot_int", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_get_name", - "return_type": "godot_string", - "arguments": [ - ["const godot_node_path *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_node_path_get_subname_count", - "return_type": "godot_int", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_get_subname", - "return_type": "godot_string", - "arguments": [ - ["const godot_node_path *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_node_path_get_property", - "return_type": "godot_string", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_is_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_node_path *", "p_self"] - ] - }, - { - "name": "godot_node_path_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_node_path *", "p_self"], - ["const godot_node_path *", "p_b"] - ] - }, - { - "name": "godot_plane_new_with_reals", - "return_type": "void", - "arguments": [ - ["godot_plane *", "r_dest"], - ["const godot_real", "p_a"], - ["const godot_real", "p_b"], - ["const godot_real", "p_c"], - ["const godot_real", "p_d"] - ] - }, - { - "name": "godot_plane_new_with_vectors", - "return_type": "void", - "arguments": [ - ["godot_plane *", "r_dest"], - ["const godot_vector3 *", "p_v1"], - ["const godot_vector3 *", "p_v2"], - ["const godot_vector3 *", "p_v3"] - ] - }, - { - "name": "godot_plane_new_with_normal", - "return_type": "void", - "arguments": [ - ["godot_plane *", "r_dest"], - ["const godot_vector3 *", "p_normal"], - ["const godot_real", "p_d"] - ] - }, - { - "name": "godot_plane_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_normalized", - "return_type": "godot_plane", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_center", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_get_any_point", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_is_point_over", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["const godot_vector3 *", "p_point"] - ] - }, - { - "name": "godot_plane_distance_to", - "return_type": "godot_real", - "arguments": [ - ["const godot_plane *", "p_self"], - ["const godot_vector3 *", "p_point"] - ] - }, - { - "name": "godot_plane_has_point", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["const godot_vector3 *", "p_point"], - ["const godot_real", "p_epsilon"] - ] - }, - { - "name": "godot_plane_project", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_plane *", "p_self"], - ["const godot_vector3 *", "p_point"] - ] - }, - { - "name": "godot_plane_intersect_3", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["godot_vector3 *", "r_dest"], - ["const godot_plane *", "p_b"], - ["const godot_plane *", "p_c"] - ] - }, - { - "name": "godot_plane_intersects_ray", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["godot_vector3 *", "r_dest"], - ["const godot_vector3 *", "p_from"], - ["const godot_vector3 *", "p_dir"] - ] - }, - { - "name": "godot_plane_intersects_segment", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["godot_vector3 *", "r_dest"], - ["const godot_vector3 *", "p_begin"], - ["const godot_vector3 *", "p_end"] - ] - }, - { - "name": "godot_plane_operator_neg", - "return_type": "godot_plane", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_plane *", "p_self"], - ["const godot_plane *", "p_b"] - ] - }, - { - "name": "godot_plane_set_normal", - "return_type": "void", - "arguments": [ - ["godot_plane *", "p_self"], - ["const godot_vector3 *", "p_normal"] - ] - }, - { - "name": "godot_plane_get_normal", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_get_d", - "return_type": "godot_real", - "arguments": [ - ["const godot_plane *", "p_self"] - ] - }, - { - "name": "godot_plane_set_d", - "return_type": "void", - "arguments": [ - ["godot_plane *", "p_self"], - ["const godot_real", "p_d"] - ] - }, - { - "name": "godot_rect2_new_with_position_and_size", - "return_type": "void", - "arguments": [ - ["godot_rect2 *", "r_dest"], - ["const godot_vector2 *", "p_pos"], - ["const godot_vector2 *", "p_size"] - ] - }, - { - "name": "godot_rect2_new", - "return_type": "void", - "arguments": [ - ["godot_rect2 *", "r_dest"], - ["const godot_real", "p_x"], - ["const godot_real", "p_y"], - ["const godot_real", "p_width"], - ["const godot_real", "p_height"] - ] - }, - { - "name": "godot_rect2_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_get_area", - "return_type": "godot_real", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_intersects", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_rect2 *", "p_b"] - ] - }, - { - "name": "godot_rect2_encloses", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_rect2 *", "p_b"] - ] - }, - { - "name": "godot_rect2_has_no_area", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_clip", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_rect2 *", "p_b"] - ] - }, - { - "name": "godot_rect2_merge", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_rect2 *", "p_b"] - ] - }, - { - "name": "godot_rect2_has_point", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_vector2 *", "p_point"] - ] - }, - { - "name": "godot_rect2_grow", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_real", "p_by"] - ] - }, - { - "name": "godot_rect2_expand", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_vector2 *", "p_to"] - ] - }, - { - "name": "godot_rect2_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect2 *", "p_self"], - ["const godot_rect2 *", "p_b"] - ] - }, - { - "name": "godot_rect2_get_position", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_get_size", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_rect2 *", "p_self"] - ] - }, - { - "name": "godot_rect2_set_position", - "return_type": "void", - "arguments": [ - ["godot_rect2 *", "p_self"], - ["const godot_vector2 *", "p_pos"] - ] - }, - { - "name": "godot_rect2_set_size", - "return_type": "void", - "arguments": [ - ["godot_rect2 *", "p_self"], - ["const godot_vector2 *", "p_size"] - ] - }, - { - "name": "godot_rect3_new", - "return_type": "void", - "arguments": [ - ["godot_rect3 *", "r_dest"], - ["const godot_vector3 *", "p_pos"], - ["const godot_vector3 *", "p_size"] - ] - }, - { - "name": "godot_rect3_get_position", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_set_position", - "return_type": "void", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_rect3_get_size", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_set_size", - "return_type": "void", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_rect3_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_get_area", - "return_type": "godot_real", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_has_no_area", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_has_no_surface", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_intersects", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_rect3 *", "p_with"] - ] - }, - { - "name": "godot_rect3_encloses", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_rect3 *", "p_with"] - ] - }, - { - "name": "godot_rect3_merge", - "return_type": "godot_rect3", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_rect3 *", "p_with"] - ] - }, - { - "name": "godot_rect3_intersection", - "return_type": "godot_rect3", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_rect3 *", "p_with"] - ] - }, - { - "name": "godot_rect3_intersects_plane", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_plane *", "p_plane"] - ] - }, - { - "name": "godot_rect3_intersects_segment", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_vector3 *", "p_from"], - ["const godot_vector3 *", "p_to"] - ] - }, - { - "name": "godot_rect3_has_point", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_vector3 *", "p_point"] - ] - }, - { - "name": "godot_rect3_get_support", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_vector3 *", "p_dir"] - ] - }, - { - "name": "godot_rect3_get_longest_axis", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_get_longest_axis_index", - "return_type": "godot_int", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_get_longest_axis_size", - "return_type": "godot_real", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_get_shortest_axis", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_get_shortest_axis_index", - "return_type": "godot_int", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_get_shortest_axis_size", - "return_type": "godot_real", - "arguments": [ - ["const godot_rect3 *", "p_self"] - ] - }, - { - "name": "godot_rect3_expand", - "return_type": "godot_rect3", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_vector3 *", "p_to_point"] - ] - }, - { - "name": "godot_rect3_grow", - "return_type": "godot_rect3", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_real", "p_by"] - ] - }, - { - "name": "godot_rect3_get_endpoint", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_rect3_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rect3 *", "p_self"], - ["const godot_rect3 *", "p_b"] - ] - }, - { - "name": "godot_rid_new", - "return_type": "void", - "arguments": [ - ["godot_rid *", "r_dest"] - ] - }, - { - "name": "godot_rid_get_id", - "return_type": "godot_int", - "arguments": [ - ["const godot_rid *", "p_self"] - ] - }, - { - "name": "godot_rid_new_with_resource", - "return_type": "void", - "arguments": [ - ["godot_rid *", "r_dest"], - ["const godot_object *", "p_from"] - ] - }, - { - "name": "godot_rid_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rid *", "p_self"], - ["const godot_rid *", "p_b"] - ] - }, - { - "name": "godot_rid_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_rid *", "p_self"], - ["const godot_rid *", "p_b"] - ] - }, - { - "name": "godot_transform_new_with_axis_origin", - "return_type": "void", - "arguments": [ - ["godot_transform *", "r_dest"], - ["const godot_vector3 *", "p_x_axis"], - ["const godot_vector3 *", "p_y_axis"], - ["const godot_vector3 *", "p_z_axis"], - ["const godot_vector3 *", "p_origin"] - ] - }, - { - "name": "godot_transform_new", - "return_type": "void", - "arguments": [ - ["godot_transform *", "r_dest"], - ["const godot_basis *", "p_basis"], - ["const godot_vector3 *", "p_origin"] - ] - }, - { - "name": "godot_transform_get_basis", - "return_type": "godot_basis", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_set_basis", - "return_type": "void", - "arguments": [ - ["godot_transform *", "p_self"], - ["godot_basis *", "p_v"] - ] - }, - { - "name": "godot_transform_get_origin", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_set_origin", - "return_type": "void", - "arguments": [ - ["godot_transform *", "p_self"], - ["godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_transform_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_inverse", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_affine_inverse", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_orthonormalized", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"] - ] - }, - { - "name": "godot_transform_rotated", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_axis"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_transform_scaled", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_scale"] - ] - }, - { - "name": "godot_transform_translated", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_ofs"] - ] - }, - { - "name": "godot_transform_looking_at", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_target"], - ["const godot_vector3 *", "p_up"] - ] - }, - { - "name": "godot_transform_xform_plane", - "return_type": "godot_plane", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_plane *", "p_v"] - ] - }, - { - "name": "godot_transform_xform_inv_plane", - "return_type": "godot_plane", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_plane *", "p_v"] - ] - }, - { - "name": "godot_transform_new_identity", - "return_type": "void", - "arguments": [ - ["godot_transform *", "r_dest"] - ] - }, - { - "name": "godot_transform_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_transform *", "p_b"] - ] - }, - { - "name": "godot_transform_operator_multiply", - "return_type": "godot_transform", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_transform *", "p_b"] - ] - }, - { - "name": "godot_transform_xform_vector3", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_transform_xform_inv_vector3", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_vector3 *", "p_v"] - ] - }, - { - "name": "godot_transform_xform_rect3", - "return_type": "godot_rect3", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_rect3 *", "p_v"] - ] - }, - { - "name": "godot_transform_xform_inv_rect3", - "return_type": "godot_rect3", - "arguments": [ - ["const godot_transform *", "p_self"], - ["const godot_rect3 *", "p_v"] - ] - }, - { - "name": "godot_transform2d_new", - "return_type": "void", - "arguments": [ - ["godot_transform2d *", "r_dest"], - ["const godot_real", "p_rot"], - ["const godot_vector2 *", "p_pos"] - ] - }, - { - "name": "godot_transform2d_new_axis_origin", - "return_type": "void", - "arguments": [ - ["godot_transform2d *", "r_dest"], - ["const godot_vector2 *", "p_x_axis"], - ["const godot_vector2 *", "p_y_axis"], - ["const godot_vector2 *", "p_origin"] - ] - }, - { - "name": "godot_transform2d_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_inverse", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_affine_inverse", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_get_rotation", - "return_type": "godot_real", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_get_origin", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_get_scale", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_orthonormalized", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"] - ] - }, - { - "name": "godot_transform2d_rotated", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_real", "p_phi"] - ] - }, - { - "name": "godot_transform2d_scaled", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_scale"] - ] - }, - { - "name": "godot_transform2d_translated", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_offset"] - ] - }, - { - "name": "godot_transform2d_xform_vector2", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_v"] - ] - }, - { - "name": "godot_transform2d_xform_inv_vector2", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_v"] - ] - }, - { - "name": "godot_transform2d_basis_xform_vector2", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_v"] - ] - }, - { - "name": "godot_transform2d_basis_xform_inv_vector2", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_vector2 *", "p_v"] - ] - }, - { - "name": "godot_transform2d_interpolate_with", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_transform2d *", "p_m"], - ["const godot_real", "p_c"] - ] - }, - { - "name": "godot_transform2d_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_transform2d *", "p_b"] - ] - }, - { - "name": "godot_transform2d_operator_multiply", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_transform2d *", "p_b"] - ] - }, - { - "name": "godot_transform2d_new_identity", - "return_type": "void", - "arguments": [ - ["godot_transform2d *", "r_dest"] - ] - }, - { - "name": "godot_transform2d_xform_rect2", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_rect2 *", "p_v"] - ] - }, - { - "name": "godot_transform2d_xform_inv_rect2", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_transform2d *", "p_self"], - ["const godot_rect2 *", "p_v"] - ] - }, - { - "name": "godot_variant_get_type", - "return_type": "godot_variant_type", - "arguments": [ - ["const godot_variant *", "p_v"] - ] - }, - { - "name": "godot_variant_new_copy", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_variant *", "p_src"] - ] - }, - { - "name": "godot_variant_new_nil", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"] - ] - }, - { - "name": "godot_variant_new_bool", - "return_type": "void", - "arguments": [ - ["godot_variant *", "p_v"], - ["const godot_bool", "p_b"] - ] - }, - { - "name": "godot_variant_new_uint", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const uint64_t", "p_i"] - ] - }, - { - "name": "godot_variant_new_int", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const int64_t", "p_i"] - ] - }, - { - "name": "godot_variant_new_real", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const double", "p_r"] - ] - }, - { - "name": "godot_variant_new_string", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_string *", "p_s"] - ] - }, - { - "name": "godot_variant_new_vector2", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_vector2 *", "p_v2"] - ] - }, - { - "name": "godot_variant_new_rect2", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_rect2 *", "p_rect2"] - ] - }, - { - "name": "godot_variant_new_vector3", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_vector3 *", "p_v3"] - ] - }, - { - "name": "godot_variant_new_transform2d", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_transform2d *", "p_t2d"] - ] - }, - { - "name": "godot_variant_new_plane", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_plane *", "p_plane"] - ] - }, - { - "name": "godot_variant_new_quat", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_quat *", "p_quat"] - ] - }, - { - "name": "godot_variant_new_rect3", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_rect3 *", "p_rect3"] - ] - }, - { - "name": "godot_variant_new_basis", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_basis *", "p_basis"] - ] - }, - { - "name": "godot_variant_new_transform", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_transform *", "p_trans"] - ] - }, - { - "name": "godot_variant_new_color", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_color *", "p_color"] - ] - }, - { - "name": "godot_variant_new_node_path", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_node_path *", "p_np"] - ] - }, - { - "name": "godot_variant_new_rid", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_rid *", "p_rid"] - ] - }, - { - "name": "godot_variant_new_object", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_object *", "p_obj"] - ] - }, - { - "name": "godot_variant_new_dictionary", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_dictionary *", "p_dict"] - ] - }, - { - "name": "godot_variant_new_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_array *", "p_arr"] - ] - }, - { - "name": "godot_variant_new_pool_byte_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_pool_byte_array *", "p_pba"] - ] - }, - { - "name": "godot_variant_new_pool_int_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_pool_int_array *", "p_pia"] - ] - }, - { - "name": "godot_variant_new_pool_real_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_pool_real_array *", "p_pra"] - ] - }, - { - "name": "godot_variant_new_pool_string_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_pool_string_array *", "p_psa"] - ] - }, - { - "name": "godot_variant_new_pool_vector2_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_pool_vector2_array *", "p_pv2a"] - ] - }, - { - "name": "godot_variant_new_pool_vector3_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_pool_vector3_array *", "p_pv3a"] - ] - }, - { - "name": "godot_variant_new_pool_color_array", - "return_type": "void", - "arguments": [ - ["godot_variant *", "r_dest"], - ["const godot_pool_color_array *", "p_pca"] - ] - }, - { - "name": "godot_variant_as_bool", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_uint", - "return_type": "uint64_t", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_int", - "return_type": "int64_t", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_real", - "return_type": "double", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_string", - "return_type": "godot_string", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_vector2", - "return_type": "godot_vector2", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_rect2", - "return_type": "godot_rect2", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_vector3", - "return_type": "godot_vector3", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_transform2d", - "return_type": "godot_transform2d", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_plane", - "return_type": "godot_plane", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_quat", - "return_type": "godot_quat", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_rect3", - "return_type": "godot_rect3", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_basis", - "return_type": "godot_basis", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_transform", - "return_type": "godot_transform", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_color", - "return_type": "godot_color", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_node_path", - "return_type": "godot_node_path", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_rid", - "return_type": "godot_rid", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_object", - "return_type": "godot_object *", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_dictionary", - "return_type": "godot_dictionary", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_array", - "return_type": "godot_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_pool_byte_array", - "return_type": "godot_pool_byte_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_pool_int_array", - "return_type": "godot_pool_int_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_pool_real_array", - "return_type": "godot_pool_real_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_pool_string_array", - "return_type": "godot_pool_string_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_pool_vector2_array", - "return_type": "godot_pool_vector2_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_pool_vector3_array", - "return_type": "godot_pool_vector3_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_as_pool_color_array", - "return_type": "godot_pool_color_array", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_call", - "return_type": "godot_variant", - "arguments": [ - ["godot_variant *", "p_self"], - ["const godot_string *", "p_method"], - ["const godot_variant **", "p_args"], - ["const godot_int", "p_argcount"], - ["godot_variant_call_error *", "r_error"] - ] - }, - { - "name": "godot_variant_has_method", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"], - ["const godot_string *", "p_method"] - ] - }, - { - "name": "godot_variant_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"], - ["const godot_variant *", "p_other"] - ] - }, - { - "name": "godot_variant_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"], - ["const godot_variant *", "p_other"] - ] - }, - { - "name": "godot_variant_hash_compare", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"], - ["const godot_variant *", "p_other"] - ] - }, - { - "name": "godot_variant_booleanize", - "return_type": "godot_bool", - "arguments": [ - ["const godot_variant *", "p_self"] - ] - }, - { - "name": "godot_variant_destroy", - "return_type": "void", - "arguments": [ - ["godot_variant *", "p_self"] - ] - }, - { - "name": "godot_string_new", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"] - ] - }, - { - "name": "godot_string_new_copy", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const godot_string *", "p_src"] - ] - }, - { - "name": "godot_string_new_data", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const char *", "p_contents"], - ["const int", "p_size"] - ] - }, - { - "name": "godot_string_new_unicode_data", - "return_type": "void", - "arguments": [ - ["godot_string *", "r_dest"], - ["const wchar_t *", "p_contents"], - ["const int", "p_size"] - ] - }, - { - "name": "godot_string_get_data", - "return_type": "void", - "arguments": [ - ["const godot_string *", "p_self"], - ["char *", "p_dest"], - ["int *", "p_size"] - ] - }, - { - "name": "godot_string_operator_index", - "return_type": "wchar_t *", - "arguments": [ - ["godot_string *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_string_operator_index_const", - "return_type": "wchar_t", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_int", "p_idx"] - ] - }, - { - "name": "godot_string_c_str", - "return_type": "const char *", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_unicode_str", - "return_type": "const wchar_t *", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_b"] - ] - }, - { - "name": "godot_string_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_b"] - ] - }, - { - "name": "godot_string_operator_plus", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_b"] - ] - }, - { - "name": "godot_string_length", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_begins_with", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_string"] - ] - }, - { - "name": "godot_string_begins_with_char_array", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const char *", "p_char_array"] - ] - }, - { - "name": "godot_string_bigrams", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_chr", - "return_type": "godot_string", - "arguments": [ - ["wchar_t", "p_character"] - ] - }, - { - "name": "godot_string_ends_with", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_string"] - ] - }, - { - "name": "godot_string_find", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_what"] - ] - }, - { - "name": "godot_string_find_from", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_what"], - ["godot_int", "p_from"] - ] - }, - { - "name": "godot_string_findmk", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_array *", "p_keys"] - ] - }, - { - "name": "godot_string_findmk_from", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_array *", "p_keys"], - ["godot_int", "p_from"] - ] - }, - { - "name": "godot_string_findmk_from_in_place", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_array *", "p_keys"], - ["godot_int", "p_from"], - ["godot_int *", "r_key"] - ] - }, - { - "name": "godot_string_findn", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_what"] - ] - }, - { - "name": "godot_string_findn_from", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_what"], - ["godot_int", "p_from"] - ] - }, - { - "name": "godot_string_find_last", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_what"] - ] - }, - { - "name": "godot_string_format", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_variant *", "p_values"] - ] - }, - { - "name": "godot_string_format_with_custom_placeholder", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_variant *", "p_values"], - ["const char *", "p_placeholder"] - ] - }, - { - "name": "godot_string_hex_encode_buffer", - "return_type": "godot_string", - "arguments": [ - ["const uint8_t *", "p_buffer"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_hex_to_int", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_hex_to_int_without_prefix", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_insert", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_at_pos"], - ["godot_string", "p_string"] - ] - }, - { - "name": "godot_string_is_numeric", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_subsequence_of", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_string"] - ] - }, - { - "name": "godot_string_is_subsequence_ofi", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_string"] - ] - }, - { - "name": "godot_string_lpad", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_min_length"] - ] - }, - { - "name": "godot_string_lpad_with_custom_character", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_min_length"], - ["const godot_string *", "p_character"] - ] - }, - { - "name": "godot_string_match", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_wildcard"] - ] - }, - { - "name": "godot_string_matchn", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_wildcard"] - ] - }, - { - "name": "godot_string_md5", - "return_type": "godot_string", - "arguments": [ - ["const uint8_t *", "p_md5"] - ] - }, - { - "name": "godot_string_num", - "return_type": "godot_string", - "arguments": [ - ["double", "p_num"] - ] - }, - { - "name": "godot_string_num_int64", - "return_type": "godot_string", - "arguments": [ - ["int64_t", "p_num"], - ["godot_int", "p_base"] - ] - }, - { - "name": "godot_string_num_int64_capitalized", - "return_type": "godot_string", - "arguments": [ - ["int64_t", "p_num"], - ["godot_int", "p_base"], - ["godot_bool", "p_capitalize_hex"] - ] - }, - { - "name": "godot_string_num_real", - "return_type": "godot_string", - "arguments": [ - ["double", "p_num"] - ] - }, - { - "name": "godot_string_num_scientific", - "return_type": "godot_string", - "arguments": [ - ["double", "p_num"] - ] - }, - { - "name": "godot_string_num_with_decimals", - "return_type": "godot_string", - "arguments": [ - ["double", "p_num"], - ["godot_int", "p_decimals"] - ] - }, - { - "name": "godot_string_pad_decimals", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_digits"] - ] - }, - { - "name": "godot_string_pad_zeros", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_digits"] - ] - }, - { - "name": "godot_string_replace_first", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_key"], - ["godot_string", "p_with"] - ] - }, - { - "name": "godot_string_replace", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_key"], - ["godot_string", "p_with"] - ] - }, - { - "name": "godot_string_replacen", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_key"], - ["godot_string", "p_with"] - ] - }, - { - "name": "godot_string_rfind", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_what"] - ] - }, - { - "name": "godot_string_rfindn", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_what"] - ] - }, - { - "name": "godot_string_rfind_from", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_what"], - ["godot_int", "p_from"] - ] - }, - { - "name": "godot_string_rfindn_from", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_what"], - ["godot_int", "p_from"] - ] - }, - { - "name": "godot_string_rpad", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_min_length"] - ] - }, - { - "name": "godot_string_rpad_with_custom_character", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_min_length"], - ["const godot_string *", "p_character"] - ] - }, - { - "name": "godot_string_similarity", - "return_type": "godot_real", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_string"] - ] - }, - { - "name": "godot_string_sprintf", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_array *", "p_values"], - ["godot_bool *", "p_error"] - ] - }, - { - "name": "godot_string_substr", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_from"], - ["godot_int", "p_chars"] - ] - }, - { - "name": "godot_string_to_double", - "return_type": "double", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_to_float", - "return_type": "godot_real", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_to_int", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_camelcase_to_underscore", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_camelcase_to_underscore_lowercased", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_capitalize", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_char_to_double", - "return_type": "double", - "arguments": [ - ["const char *", "p_what"] - ] - }, - { - "name": "godot_string_char_to_int", - "return_type": "godot_int", - "arguments": [ - ["const char *", "p_what"] - ] - }, - { - "name": "godot_string_wchar_to_int", - "return_type": "int64_t", - "arguments": [ - ["const wchar_t *", "p_str"] - ] - }, - { - "name": "godot_string_char_to_int_with_len", - "return_type": "godot_int", - "arguments": [ - ["const char *", "p_what"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_char_to_int64_with_len", - "return_type": "int64_t", - "arguments": [ - ["const wchar_t *", "p_str"], - ["int", "p_len"] - ] - }, - { - "name": "godot_string_hex_to_int64", - "return_type": "int64_t", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_hex_to_int64_with_prefix", - "return_type": "int64_t", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_to_int64", - "return_type": "int64_t", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_unicode_char_to_double", - "return_type": "double", - "arguments": [ - ["const wchar_t *", "p_str"], - ["const wchar_t **", "r_end"] - ] - }, - { - "name": "godot_string_get_slice_count", - "return_type": "godot_int", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_splitter"] - ] - }, - { - "name": "godot_string_get_slice", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_string", "p_splitter"], - ["godot_int", "p_slice"] - ] - }, - { - "name": "godot_string_get_slicec", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["wchar_t", "p_splitter"], - ["godot_int", "p_slice"] - ] - }, - { - "name": "godot_string_split", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_allow_empty", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_floats", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_floats_allows_empty", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_floats_mk", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_array *", "p_splitters"] - ] - }, - { - "name": "godot_string_split_floats_mk_allows_empty", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_array *", "p_splitters"] - ] - }, - { - "name": "godot_string_split_ints", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_ints_allows_empty", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_splitter"] - ] - }, - { - "name": "godot_string_split_ints_mk", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_array *", "p_splitters"] - ] - }, - { - "name": "godot_string_split_ints_mk_allows_empty", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_array *", "p_splitters"] - ] - }, - { - "name": "godot_string_split_spaces", - "return_type": "godot_array", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_char_lowercase", - "return_type": "wchar_t", - "arguments": [ - ["wchar_t", "p_char"] - ] - }, - { - "name": "godot_string_char_uppercase", - "return_type": "wchar_t", - "arguments": [ - ["wchar_t", "p_char"] - ] - }, - { - "name": "godot_string_to_lower", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_to_upper", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_get_basename", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_get_extension", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_left", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_pos"] - ] - }, - { - "name": "godot_string_ord_at", - "return_type": "wchar_t", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_idx"] - ] - }, - { - "name": "godot_string_plus_file", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_file"] - ] - }, - { - "name": "godot_string_right", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_pos"] - ] - }, - { - "name": "godot_string_strip_edges", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_bool", "p_left"], - ["godot_bool", "p_right"] - ] - }, - { - "name": "godot_string_strip_escapes", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_erase", - "return_type": "void", - "arguments": [ - ["godot_string *", "p_self"], - ["godot_int", "p_pos"], - ["godot_int", "p_chars"] - ] - }, - { - "name": "godot_string_ascii", - "return_type": "void", - "arguments": [ - ["godot_string *", "p_self"], - ["char *", "result"] - ] - }, - { - "name": "godot_string_ascii_extended", - "return_type": "void", - "arguments": [ - ["godot_string *", "p_self"], - ["char *", "result"] - ] - }, - { - "name": "godot_string_utf8", - "return_type": "void", - "arguments": [ - ["godot_string *", "p_self"], - ["char *", "result"] - ] - }, - { - "name": "godot_string_parse_utf8", - "return_type": "godot_bool", - "arguments": [ - ["godot_string *", "p_self"], - ["const char *", "p_utf8"] - ] - }, - { - "name": "godot_string_parse_utf8_with_len", - "return_type": "godot_bool", - "arguments": [ - ["godot_string *", "p_self"], - ["const char *", "p_utf8"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_chars_to_utf8", - "return_type": "godot_string", - "arguments": [ - ["const char *", "p_utf8"] - ] - }, - { - "name": "godot_string_chars_to_utf8_with_len", - "return_type": "godot_string", - "arguments": [ - ["const char *", "p_utf8"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_hash", - "return_type": "uint32_t", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_hash64", - "return_type": "uint64_t", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_hash_chars", - "return_type": "uint32_t", - "arguments": [ - ["const char *", "p_cstr"] - ] - }, - { - "name": "godot_string_hash_chars_with_len", - "return_type": "uint32_t", - "arguments": [ - ["const char *", "p_cstr"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_hash_utf8_chars", - "return_type": "uint32_t", - "arguments": [ - ["const wchar_t *", "p_str"] - ] - }, - { - "name": "godot_string_hash_utf8_chars_with_len", - "return_type": "uint32_t", - "arguments": [ - ["const wchar_t *", "p_str"], - ["godot_int", "p_len"] - ] - }, - { - "name": "godot_string_md5_buffer", - "return_type": "godot_pool_byte_array", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_md5_text", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_sha256_buffer", - "return_type": "godot_pool_byte_array", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_sha256_text", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_empty", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_get_base_dir", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_get_file", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_humanize_size", - "return_type": "godot_string", - "arguments": [ - ["size_t", "p_size"] - ] - }, - { - "name": "godot_string_is_abs_path", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_rel_path", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_resource_file", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_path_to", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_path"] - ] - }, - { - "name": "godot_string_path_to_file", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["const godot_string *", "p_path"] - ] - }, - { - "name": "godot_string_simplify_path", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_c_escape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_c_escape_multiline", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_c_unescape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_http_escape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_http_unescape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_json_escape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_word_wrap", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_int", "p_chars_per_line"] - ] - }, - { - "name": "godot_string_xml_escape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_xml_escape_with_quotes", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_xml_unescape", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_percent_decode", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_percent_encode", - "return_type": "godot_string", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_valid_float", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_valid_hex_number", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"], - ["godot_bool", "p_with_prefix"] - ] - }, - { - "name": "godot_string_is_valid_html_color", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_valid_identifier", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_valid_integer", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_is_valid_ip_address", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_destroy", - "return_type": "void", - "arguments": [ - ["godot_string *", "p_self"] - ] - }, - { - "name": "godot_string_name_new", - "return_type": "void", - "arguments": [ - ["godot_string_name *", "r_dest"], - ["const godot_string *", "p_name"] - ] - }, - { - "name": "godot_string_name_new_data", - "return_type": "void", - "arguments": [ - ["godot_string_name *", "r_dest"], - ["const char *", "p_name"] - ] - }, - { - "name": "godot_string_name_get_name", - "return_type": "godot_string", - "arguments": [ - ["const godot_string_name *", "p_self"] - ] - }, - { - "name": "godot_string_name_get_hash", - "return_type": "uint32_t", - "arguments": [ - ["const godot_string_name *", "p_self"] - ] - }, - { - "name": "godot_string_name_get_data_unique_pointer", - "return_type": "const void *", - "arguments": [ - ["const godot_string_name *", "p_self"] - ] - }, - { - "name": "godot_string_name_operator_equal", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string_name *", "p_self"], - ["const godot_string_name *", "p_other"] - ] - }, - { - "name": "godot_string_name_operator_less", - "return_type": "godot_bool", - "arguments": [ - ["const godot_string_name *", "p_self"], - ["const godot_string_name *", "p_other"] - ] - }, - { - "name": "godot_string_name_destroy", - "return_type": "void", - "arguments": [ - ["godot_string_name *", "p_self"] - ] - }, - { - "name": "godot_object_destroy", - "return_type": "void", - "arguments": [ - ["godot_object *", "p_o"] - ] - }, - { - "name": "godot_global_get_singleton", - "return_type": "godot_object *", - "arguments": [ - ["char *", "p_name"] - ] - }, - { - "name": "godot_method_bind_get_method", - "return_type": "godot_method_bind *", - "arguments": [ - ["const char *", "p_classname"], - ["const char *", "p_methodname"] - ] - }, - { - "name": "godot_method_bind_ptrcall", - "return_type": "void", - "arguments": [ - ["godot_method_bind *", "p_method_bind"], - ["godot_object *", "p_instance"], - ["const void **", "p_args"], - ["void *", "p_ret"] - ] - }, - { - "name": "godot_method_bind_call", - "return_type": "godot_variant", - "arguments": [ - ["godot_method_bind *", "p_method_bind"], - ["godot_object *", "p_instance"], - ["const godot_variant **", "p_args"], - ["const int", "p_arg_count"], - ["godot_variant_call_error *", "p_call_error"] - ] - }, - { - "name": "godot_get_class_constructor", - "return_type": "godot_class_constructor", - "arguments": [ - ["const char *", "p_classname"] - ] - }, - { - "name": "godot_alloc", - "return_type": "void *", - "arguments": [ - ["int", "p_bytes"] - ] - }, - { - "name": "godot_realloc", - "return_type": "void *", - "arguments": [ - ["void *", "p_ptr"], - ["int", "p_bytes"] - ] - }, - { - "name": "godot_free", - "return_type": "void", - "arguments": [ - ["void *", "p_ptr"] - ] - }, - { - "name": "godot_print_error", - "return_type": "void", - "arguments": [ - ["const char *", "p_description"], - ["const char *", "p_function"], - ["const char *", "p_file"], - ["int", "p_line"] - ] - }, - { - "name": "godot_print_warning", - "return_type": "void", - "arguments": [ - ["const char *", "p_description"], - ["const char *", "p_function"], - ["const char *", "p_file"], - ["int", "p_line"] - ] - }, - { - "name": "godot_print", - "return_type": "void", - "arguments": [ - ["const godot_string *", "p_message"] - ] - }, - { - "name": "godot_nativescript_register_class", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_base"], - ["godot_instance_create_func", "p_create_func"], - ["godot_instance_destroy_func", "p_destroy_func"] - ] - }, - { - "name": "godot_nativescript_register_tool_class", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_base"], - ["godot_instance_create_func", "p_create_func"], - ["godot_instance_destroy_func", "p_destroy_func"] - ] - }, - { - "name": "godot_nativescript_register_method", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_function_name"], - ["godot_method_attributes", "p_attr"], - ["godot_instance_method", "p_method"] - ] - }, - { - "name": "godot_nativescript_register_property", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const char *", "p_path"], - ["godot_property_attributes *", "p_attr"], - ["godot_property_set_func", "p_set_func"], - ["godot_property_get_func", "p_get_func"] - ] - }, - { - "name": "godot_nativescript_register_signal", - "return_type": "void", - "arguments": [ - ["void *", "p_gdnative_handle"], - ["const char *", "p_name"], - ["const godot_signal *", "p_signal"] - ] - }, - { - "name": "godot_nativescript_get_userdata", - "return_type": "void *", - "arguments": [ - ["godot_object *", "p_instance"] - ] - }, - { - "name": "godot_arvr_register_interface", - "return_type": "void", - "arguments": [ - ["const godot_arvr_interface_gdnative *", "p_interface"] - ] - }, - { - "name": "godot_arvr_get_worldscale", - "return_type": "godot_real", - "arguments": [] - }, - { - "name": "godot_arvr_get_reference_frame", - "return_type": "godot_transform", - "arguments": [] - }, - { - "name": "godot_arvr_blit", - "return_type": "void", - "arguments": [ - ["int", "p_eye"], - ["godot_rid *", "p_render_target"], - ["godot_rect2 *", "p_screen_rect"] - ] - }, - { - "name": "godot_arvr_get_texid", - "return_type": "godot_int", - "arguments": [ - ["godot_rid *", "p_render_target"] - ] - }, - { - "name": "godot_arvr_add_controller", - "return_type": "godot_int", - "arguments": [ - ["char *", "p_device_name"], - ["godot_int", "p_hand"], - ["godot_bool", "p_tracks_orientation"], - ["godot_bool", "p_tracks_position"] - ] - }, - { - "name": "godot_arvr_remove_controller", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"] - ] - }, - { - "name": "godot_arvr_set_controller_transform", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"], - ["godot_transform *", "p_transform"], - ["godot_bool", "p_tracks_orientation"], - ["godot_bool", "p_tracks_position"] - ] - }, - { - "name": "godot_arvr_set_controller_button", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"], - ["godot_int", "p_button"], - ["godot_bool", "p_is_pressed"] - ] - }, - { - "name": "godot_arvr_set_controller_axis", - "return_type": "void", - "arguments": [ - ["godot_int", "p_controller_id"], - ["godot_int", "p_exis"], - ["godot_real", "p_value"], - ["godot_bool", "p_can_be_negative"] - ] - }, - { - "name": "godot_arvr_get_controller_rumble", - "return_type": "godot_real", - "arguments": [ - ["godot_int", "p_controller_id"] + "core": { + "type": "CORE", + "version": { + "major": 1, + "minor": 0 + }, + "api": [ + { + "name": "godot_color_new_rgba", + "return_type": "void", + "arguments": [ + ["godot_color *", "r_dest"], + ["const godot_real", "p_r"], + ["const godot_real", "p_g"], + ["const godot_real", "p_b"], + ["const godot_real", "p_a"] + ] + }, + { + "name": "godot_color_new_rgb", + "return_type": "void", + "arguments": [ + ["godot_color *", "r_dest"], + ["const godot_real", "p_r"], + ["const godot_real", "p_g"], + ["const godot_real", "p_b"] + ] + }, + { + "name": "godot_color_get_r", + "return_type": "godot_real", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_set_r", + "return_type": "void", + "arguments": [ + ["godot_color *", "p_self"], + ["const godot_real", "r"] + ] + }, + { + "name": "godot_color_get_g", + "return_type": "godot_real", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_set_g", + "return_type": "void", + "arguments": [ + ["godot_color *", "p_self"], + ["const godot_real", "g"] + ] + }, + { + "name": "godot_color_get_b", + "return_type": "godot_real", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_set_b", + "return_type": "void", + "arguments": [ + ["godot_color *", "p_self"], + ["const godot_real", "b"] + ] + }, + { + "name": "godot_color_get_a", + "return_type": "godot_real", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_set_a", + "return_type": "void", + "arguments": [ + ["godot_color *", "p_self"], + ["const godot_real", "a"] + ] + }, + { + "name": "godot_color_get_h", + "return_type": "godot_real", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_get_s", + "return_type": "godot_real", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_get_v", + "return_type": "godot_real", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_to_rgba32", + "return_type": "godot_int", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_to_argb32", + "return_type": "godot_int", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_gray", + "return_type": "godot_real", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_inverted", + "return_type": "godot_color", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_contrasted", + "return_type": "godot_color", + "arguments": [ + ["const godot_color *", "p_self"] + ] + }, + { + "name": "godot_color_linear_interpolate", + "return_type": "godot_color", + "arguments": [ + ["const godot_color *", "p_self"], + ["const godot_color *", "p_b"], + ["const godot_real", "p_t"] + ] + }, + { + "name": "godot_color_blend", + "return_type": "godot_color", + "arguments": [ + ["const godot_color *", "p_self"], + ["const godot_color *", "p_over"] + ] + }, + { + "name": "godot_color_to_html", + "return_type": "godot_string", + "arguments": [ + ["const godot_color *", "p_self"], + ["const godot_bool", "p_with_alpha"] + ] + }, + { + "name": "godot_color_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_color *", "p_self"], + ["const godot_color *", "p_b"] + ] + }, + { + "name": "godot_color_operator_less", + "return_type": "godot_bool", + "arguments": [ + ["const godot_color *", "p_self"], + ["const godot_color *", "p_b"] + ] + }, + { + "name": "godot_vector2_new", + "return_type": "void", + "arguments": [ + ["godot_vector2 *", "r_dest"], + ["const godot_real", "p_x"], + ["const godot_real", "p_y"] + ] + }, + { + "name": "godot_vector2_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_normalized", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_length", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_angle", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_length_squared", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_is_normalized", + "return_type": "godot_bool", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_distance_to", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_to"] + ] + }, + { + "name": "godot_vector2_distance_squared_to", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_to"] + ] + }, + { + "name": "godot_vector2_angle_to", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_to"] + ] + }, + { + "name": "godot_vector2_angle_to_point", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_to"] + ] + }, + { + "name": "godot_vector2_linear_interpolate", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_b"], + ["const godot_real", "p_t"] + ] + }, + { + "name": "godot_vector2_cubic_interpolate", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_b"], + ["const godot_vector2 *", "p_pre_a"], + ["const godot_vector2 *", "p_post_b"], + ["const godot_real", "p_t"] + ] + }, + { + "name": "godot_vector2_rotated", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_real", "p_phi"] + ] + }, + { + "name": "godot_vector2_tangent", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_floor", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_snapped", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_by"] + ] + }, + { + "name": "godot_vector2_aspect", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_dot", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_with"] + ] + }, + { + "name": "godot_vector2_slide", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_n"] + ] + }, + { + "name": "godot_vector2_bounce", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_n"] + ] + }, + { + "name": "godot_vector2_reflect", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_n"] + ] + }, + { + "name": "godot_vector2_abs", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_clamped", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_real", "p_length"] + ] + }, + { + "name": "godot_vector2_operator_add", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_b"] + ] + }, + { + "name": "godot_vector2_operator_substract", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_b"] + ] + }, + { + "name": "godot_vector2_operator_multiply_vector", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_b"] + ] + }, + { + "name": "godot_vector2_operator_multiply_scalar", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_real", "p_b"] + ] + }, + { + "name": "godot_vector2_operator_divide_vector", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_b"] + ] + }, + { + "name": "godot_vector2_operator_divide_scalar", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_real", "p_b"] + ] + }, + { + "name": "godot_vector2_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_b"] + ] + }, + { + "name": "godot_vector2_operator_less", + "return_type": "godot_bool", + "arguments": [ + ["const godot_vector2 *", "p_self"], + ["const godot_vector2 *", "p_b"] + ] + }, + { + "name": "godot_vector2_operator_neg", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_set_x", + "return_type": "void", + "arguments": [ + ["godot_vector2 *", "p_self"], + ["const godot_real", "p_x"] + ] + }, + { + "name": "godot_vector2_set_y", + "return_type": "void", + "arguments": [ + ["godot_vector2 *", "p_self"], + ["const godot_real", "p_y"] + ] + }, + { + "name": "godot_vector2_get_x", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_vector2_get_y", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector2 *", "p_self"] + ] + }, + { + "name": "godot_quat_new", + "return_type": "void", + "arguments": [ + ["godot_quat *", "r_dest"], + ["const godot_real", "p_x"], + ["const godot_real", "p_y"], + ["const godot_real", "p_z"], + ["const godot_real", "p_w"] + ] + }, + { + "name": "godot_quat_new_with_axis_angle", + "return_type": "void", + "arguments": [ + ["godot_quat *", "r_dest"], + ["const godot_vector3 *", "p_axis"], + ["const godot_real", "p_angle"] + ] + }, + { + "name": "godot_quat_get_x", + "return_type": "godot_real", + "arguments": [ + ["const godot_quat *", "p_self"] + ] + }, + { + "name": "godot_quat_set_x", + "return_type": "void", + "arguments": [ + ["godot_quat *", "p_self"], + ["const godot_real", "val"] + ] + }, + { + "name": "godot_quat_get_y", + "return_type": "godot_real", + "arguments": [ + ["const godot_quat *", "p_self"] + ] + }, + { + "name": "godot_quat_set_y", + "return_type": "void", + "arguments": [ + ["godot_quat *", "p_self"], + ["const godot_real", "val"] + ] + }, + { + "name": "godot_quat_get_z", + "return_type": "godot_real", + "arguments": [ + ["const godot_quat *", "p_self"] + ] + }, + { + "name": "godot_quat_set_z", + "return_type": "void", + "arguments": [ + ["godot_quat *", "p_self"], + ["const godot_real", "val"] + ] + }, + { + "name": "godot_quat_get_w", + "return_type": "godot_real", + "arguments": [ + ["const godot_quat *", "p_self"] + ] + }, + { + "name": "godot_quat_set_w", + "return_type": "void", + "arguments": [ + ["godot_quat *", "p_self"], + ["const godot_real", "val"] + ] + }, + { + "name": "godot_quat_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_quat *", "p_self"] + ] + }, + { + "name": "godot_quat_length", + "return_type": "godot_real", + "arguments": [ + ["const godot_quat *", "p_self"] + ] + }, + { + "name": "godot_quat_length_squared", + "return_type": "godot_real", + "arguments": [ + ["const godot_quat *", "p_self"] + ] + }, + { + "name": "godot_quat_normalized", + "return_type": "godot_quat", + "arguments": [ + ["const godot_quat *", "p_self"] + ] + }, + { + "name": "godot_quat_is_normalized", + "return_type": "godot_bool", + "arguments": [ + ["const godot_quat *", "p_self"] + ] + }, + { + "name": "godot_quat_inverse", + "return_type": "godot_quat", + "arguments": [ + ["const godot_quat *", "p_self"] + ] + }, + { + "name": "godot_quat_dot", + "return_type": "godot_real", + "arguments": [ + ["const godot_quat *", "p_self"], + ["const godot_quat *", "p_b"] + ] + }, + { + "name": "godot_quat_xform", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_quat *", "p_self"], + ["const godot_vector3 *", "p_v"] + ] + }, + { + "name": "godot_quat_slerp", + "return_type": "godot_quat", + "arguments": [ + ["const godot_quat *", "p_self"], + ["const godot_quat *", "p_b"], + ["const godot_real", "p_t"] + ] + }, + { + "name": "godot_quat_slerpni", + "return_type": "godot_quat", + "arguments": [ + ["const godot_quat *", "p_self"], + ["const godot_quat *", "p_b"], + ["const godot_real", "p_t"] + ] + }, + { + "name": "godot_quat_cubic_slerp", + "return_type": "godot_quat", + "arguments": [ + ["const godot_quat *", "p_self"], + ["const godot_quat *", "p_b"], + ["const godot_quat *", "p_pre_a"], + ["const godot_quat *", "p_post_b"], + ["const godot_real", "p_t"] + ] + }, + { + "name": "godot_quat_operator_multiply", + "return_type": "godot_quat", + "arguments": [ + ["const godot_quat *", "p_self"], + ["const godot_real", "p_b"] + ] + }, + { + "name": "godot_quat_operator_add", + "return_type": "godot_quat", + "arguments": [ + ["const godot_quat *", "p_self"], + ["const godot_quat *", "p_b"] + ] + }, + { + "name": "godot_quat_operator_substract", + "return_type": "godot_quat", + "arguments": [ + ["const godot_quat *", "p_self"], + ["const godot_quat *", "p_b"] + ] + }, + { + "name": "godot_quat_operator_divide", + "return_type": "godot_quat", + "arguments": [ + ["const godot_quat *", "p_self"], + ["const godot_real", "p_b"] + ] + }, + { + "name": "godot_quat_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_quat *", "p_self"], + ["const godot_quat *", "p_b"] + ] + }, + { + "name": "godot_quat_operator_neg", + "return_type": "godot_quat", + "arguments": [ + ["const godot_quat *", "p_self"] + ] + }, + { + "name": "godot_basis_new_with_rows", + "return_type": "void", + "arguments": [ + ["godot_basis *", "r_dest"], + ["const godot_vector3 *", "p_x_axis"], + ["const godot_vector3 *", "p_y_axis"], + ["const godot_vector3 *", "p_z_axis"] + ] + }, + { + "name": "godot_basis_new_with_axis_and_angle", + "return_type": "void", + "arguments": [ + ["godot_basis *", "r_dest"], + ["const godot_vector3 *", "p_axis"], + ["const godot_real", "p_phi"] + ] + }, + { + "name": "godot_basis_new_with_euler", + "return_type": "void", + "arguments": [ + ["godot_basis *", "r_dest"], + ["const godot_vector3 *", "p_euler"] + ] + }, + { + "name": "godot_basis_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_basis *", "p_self"] + ] + }, + { + "name": "godot_basis_inverse", + "return_type": "godot_basis", + "arguments": [ + ["const godot_basis *", "p_self"] + ] + }, + { + "name": "godot_basis_transposed", + "return_type": "godot_basis", + "arguments": [ + ["const godot_basis *", "p_self"] + ] + }, + { + "name": "godot_basis_orthonormalized", + "return_type": "godot_basis", + "arguments": [ + ["const godot_basis *", "p_self"] + ] + }, + { + "name": "godot_basis_determinant", + "return_type": "godot_real", + "arguments": [ + ["const godot_basis *", "p_self"] + ] + }, + { + "name": "godot_basis_rotated", + "return_type": "godot_basis", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_vector3 *", "p_axis"], + ["const godot_real", "p_phi"] + ] + }, + { + "name": "godot_basis_scaled", + "return_type": "godot_basis", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_vector3 *", "p_scale"] + ] + }, + { + "name": "godot_basis_get_scale", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_basis *", "p_self"] + ] + }, + { + "name": "godot_basis_get_euler", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_basis *", "p_self"] + ] + }, + { + "name": "godot_basis_tdotx", + "return_type": "godot_real", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_vector3 *", "p_with"] + ] + }, + { + "name": "godot_basis_tdoty", + "return_type": "godot_real", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_vector3 *", "p_with"] + ] + }, + { + "name": "godot_basis_tdotz", + "return_type": "godot_real", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_vector3 *", "p_with"] + ] + }, + { + "name": "godot_basis_xform", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_vector3 *", "p_v"] + ] + }, + { + "name": "godot_basis_xform_inv", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_vector3 *", "p_v"] + ] + }, + { + "name": "godot_basis_get_orthogonal_index", + "return_type": "godot_int", + "arguments": [ + ["const godot_basis *", "p_self"] + ] + }, + { + "name": "godot_basis_new", + "return_type": "void", + "arguments": [ + ["godot_basis *", "r_dest"] + ] + }, + { + "name": "godot_basis_new_with_euler_quat", + "return_type": "void", + "arguments": [ + ["godot_basis *", "r_dest"], + ["const godot_quat *", "p_euler"] + ] + }, + { + "name": "godot_basis_get_elements", + "return_type": "void", + "arguments": [ + ["const godot_basis *", "p_self"], + ["godot_vector3 *", "p_elements"] + ] + }, + { + "name": "godot_basis_get_axis", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_int", "p_axis"] + ] + }, + { + "name": "godot_basis_set_axis", + "return_type": "void", + "arguments": [ + ["godot_basis *", "p_self"], + ["const godot_int", "p_axis"], + ["const godot_vector3 *", "p_value"] + ] + }, + { + "name": "godot_basis_get_row", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_int", "p_row"] + ] + }, + { + "name": "godot_basis_set_row", + "return_type": "void", + "arguments": [ + ["godot_basis *", "p_self"], + ["const godot_int", "p_row"], + ["const godot_vector3 *", "p_value"] + ] + }, + { + "name": "godot_basis_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_basis *", "p_b"] + ] + }, + { + "name": "godot_basis_operator_add", + "return_type": "godot_basis", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_basis *", "p_b"] + ] + }, + { + "name": "godot_basis_operator_substract", + "return_type": "godot_basis", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_basis *", "p_b"] + ] + }, + { + "name": "godot_basis_operator_multiply_vector", + "return_type": "godot_basis", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_basis *", "p_b"] + ] + }, + { + "name": "godot_basis_operator_multiply_scalar", + "return_type": "godot_basis", + "arguments": [ + ["const godot_basis *", "p_self"], + ["const godot_real", "p_b"] + ] + }, + { + "name": "godot_vector3_new", + "return_type": "void", + "arguments": [ + ["godot_vector3 *", "r_dest"], + ["const godot_real", "p_x"], + ["const godot_real", "p_y"], + ["const godot_real", "p_z"] + ] + }, + { + "name": "godot_vector3_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_min_axis", + "return_type": "godot_int", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_max_axis", + "return_type": "godot_int", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_length", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_length_squared", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_is_normalized", + "return_type": "godot_bool", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_normalized", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_inverse", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_snapped", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_by"] + ] + }, + { + "name": "godot_vector3_rotated", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_axis"], + ["const godot_real", "p_phi"] + ] + }, + { + "name": "godot_vector3_linear_interpolate", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"], + ["const godot_real", "p_t"] + ] + }, + { + "name": "godot_vector3_cubic_interpolate", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"], + ["const godot_vector3 *", "p_pre_a"], + ["const godot_vector3 *", "p_post_b"], + ["const godot_real", "p_t"] + ] + }, + { + "name": "godot_vector3_dot", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"] + ] + }, + { + "name": "godot_vector3_cross", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"] + ] + }, + { + "name": "godot_vector3_outer", + "return_type": "godot_basis", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"] + ] + }, + { + "name": "godot_vector3_to_diagonal_matrix", + "return_type": "godot_basis", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_abs", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_floor", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_ceil", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_distance_to", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"] + ] + }, + { + "name": "godot_vector3_distance_squared_to", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"] + ] + }, + { + "name": "godot_vector3_angle_to", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_to"] + ] + }, + { + "name": "godot_vector3_slide", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_n"] + ] + }, + { + "name": "godot_vector3_bounce", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_n"] + ] + }, + { + "name": "godot_vector3_reflect", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_n"] + ] + }, + { + "name": "godot_vector3_operator_add", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"] + ] + }, + { + "name": "godot_vector3_operator_substract", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"] + ] + }, + { + "name": "godot_vector3_operator_multiply_vector", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"] + ] + }, + { + "name": "godot_vector3_operator_multiply_scalar", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_real", "p_b"] + ] + }, + { + "name": "godot_vector3_operator_divide_vector", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"] + ] + }, + { + "name": "godot_vector3_operator_divide_scalar", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_real", "p_b"] + ] + }, + { + "name": "godot_vector3_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"] + ] + }, + { + "name": "godot_vector3_operator_less", + "return_type": "godot_bool", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3 *", "p_b"] + ] + }, + { + "name": "godot_vector3_operator_neg", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_vector3 *", "p_self"] + ] + }, + { + "name": "godot_vector3_set_axis", + "return_type": "void", + "arguments": [ + ["godot_vector3 *", "p_self"], + ["const godot_vector3_axis", "p_axis"], + ["const godot_real", "p_val"] + ] + }, + { + "name": "godot_vector3_get_axis", + "return_type": "godot_real", + "arguments": [ + ["const godot_vector3 *", "p_self"], + ["const godot_vector3_axis", "p_axis"] + ] + }, + { + "name": "godot_pool_byte_array_new", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array *", "r_dest"] + ] + }, + { + "name": "godot_pool_byte_array_new_copy", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array *", "r_dest"], + ["const godot_pool_byte_array *", "p_src"] + ] + }, + { + "name": "godot_pool_byte_array_new_with_array", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array *", "r_dest"], + ["const godot_array *", "p_a"] + ] + }, + { + "name": "godot_pool_byte_array_append", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array *", "p_self"], + ["const uint8_t", "p_data"] + ] + }, + { + "name": "godot_pool_byte_array_append_array", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array *", "p_self"], + ["const godot_pool_byte_array *", "p_array"] + ] + }, + { + "name": "godot_pool_byte_array_insert", + "return_type": "godot_error", + "arguments": [ + ["godot_pool_byte_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const uint8_t", "p_data"] + ] + }, + { + "name": "godot_pool_byte_array_invert", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array *", "p_self"] + ] + }, + { + "name": "godot_pool_byte_array_push_back", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array *", "p_self"], + ["const uint8_t", "p_data"] + ] + }, + { + "name": "godot_pool_byte_array_remove", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_byte_array_resize", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array *", "p_self"], + ["const godot_int", "p_size"] + ] + }, + { + "name": "godot_pool_byte_array_read", + "return_type": "godot_pool_byte_array_read_access *", + "arguments": [ + ["const godot_pool_byte_array *", "p_self"] + ] + }, + { + "name": "godot_pool_byte_array_write", + "return_type": "godot_pool_byte_array_write_access *", + "arguments": [ + ["godot_pool_byte_array *", "p_self"] + ] + }, + { + "name": "godot_pool_byte_array_set", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const uint8_t", "p_data"] + ] + }, + { + "name": "godot_pool_byte_array_get", + "return_type": "uint8_t", + "arguments": [ + ["const godot_pool_byte_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_byte_array_size", + "return_type": "godot_int", + "arguments": [ + ["const godot_pool_byte_array *", "p_self"] + ] + }, + { + "name": "godot_pool_byte_array_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array *", "p_self"] + ] + }, + { + "name": "godot_pool_int_array_new", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array *", "r_dest"] + ] + }, + { + "name": "godot_pool_int_array_new_copy", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array *", "r_dest"], + ["const godot_pool_int_array *", "p_src"] + ] + }, + { + "name": "godot_pool_int_array_new_with_array", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array *", "r_dest"], + ["const godot_array *", "p_a"] + ] + }, + { + "name": "godot_pool_int_array_append", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array *", "p_self"], + ["const godot_int", "p_data"] + ] + }, + { + "name": "godot_pool_int_array_append_array", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array *", "p_self"], + ["const godot_pool_int_array *", "p_array"] + ] + }, + { + "name": "godot_pool_int_array_insert", + "return_type": "godot_error", + "arguments": [ + ["godot_pool_int_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_int", "p_data"] + ] + }, + { + "name": "godot_pool_int_array_invert", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array *", "p_self"] + ] + }, + { + "name": "godot_pool_int_array_push_back", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array *", "p_self"], + ["const godot_int", "p_data"] + ] + }, + { + "name": "godot_pool_int_array_remove", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_int_array_resize", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array *", "p_self"], + ["const godot_int", "p_size"] + ] + }, + { + "name": "godot_pool_int_array_read", + "return_type": "godot_pool_int_array_read_access *", + "arguments": [ + ["const godot_pool_int_array *", "p_self"] + ] + }, + { + "name": "godot_pool_int_array_write", + "return_type": "godot_pool_int_array_write_access *", + "arguments": [ + ["godot_pool_int_array *", "p_self"] + ] + }, + { + "name": "godot_pool_int_array_set", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_int", "p_data"] + ] + }, + { + "name": "godot_pool_int_array_get", + "return_type": "godot_int", + "arguments": [ + ["const godot_pool_int_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_int_array_size", + "return_type": "godot_int", + "arguments": [ + ["const godot_pool_int_array *", "p_self"] + ] + }, + { + "name": "godot_pool_int_array_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array *", "p_self"] + ] + }, + { + "name": "godot_pool_real_array_new", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array *", "r_dest"] + ] + }, + { + "name": "godot_pool_real_array_new_copy", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array *", "r_dest"], + ["const godot_pool_real_array *", "p_src"] + ] + }, + { + "name": "godot_pool_real_array_new_with_array", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array *", "r_dest"], + ["const godot_array *", "p_a"] + ] + }, + { + "name": "godot_pool_real_array_append", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array *", "p_self"], + ["const godot_real", "p_data"] + ] + }, + { + "name": "godot_pool_real_array_append_array", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array *", "p_self"], + ["const godot_pool_real_array *", "p_array"] + ] + }, + { + "name": "godot_pool_real_array_insert", + "return_type": "godot_error", + "arguments": [ + ["godot_pool_real_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_real", "p_data"] + ] + }, + { + "name": "godot_pool_real_array_invert", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array *", "p_self"] + ] + }, + { + "name": "godot_pool_real_array_push_back", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array *", "p_self"], + ["const godot_real", "p_data"] + ] + }, + { + "name": "godot_pool_real_array_remove", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_real_array_resize", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array *", "p_self"], + ["const godot_int", "p_size"] + ] + }, + { + "name": "godot_pool_real_array_read", + "return_type": "godot_pool_real_array_read_access *", + "arguments": [ + ["const godot_pool_real_array *", "p_self"] + ] + }, + { + "name": "godot_pool_real_array_write", + "return_type": "godot_pool_real_array_write_access *", + "arguments": [ + ["godot_pool_real_array *", "p_self"] + ] + }, + { + "name": "godot_pool_real_array_set", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_real", "p_data"] + ] + }, + { + "name": "godot_pool_real_array_get", + "return_type": "godot_real", + "arguments": [ + ["const godot_pool_real_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_real_array_size", + "return_type": "godot_int", + "arguments": [ + ["const godot_pool_real_array *", "p_self"] + ] + }, + { + "name": "godot_pool_real_array_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array *", "p_self"] + ] + }, + { + "name": "godot_pool_string_array_new", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array *", "r_dest"] + ] + }, + { + "name": "godot_pool_string_array_new_copy", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array *", "r_dest"], + ["const godot_pool_string_array *", "p_src"] + ] + }, + { + "name": "godot_pool_string_array_new_with_array", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array *", "r_dest"], + ["const godot_array *", "p_a"] + ] + }, + { + "name": "godot_pool_string_array_append", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array *", "p_self"], + ["const godot_string *", "p_data"] + ] + }, + { + "name": "godot_pool_string_array_append_array", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array *", "p_self"], + ["const godot_pool_string_array *", "p_array"] + ] + }, + { + "name": "godot_pool_string_array_insert", + "return_type": "godot_error", + "arguments": [ + ["godot_pool_string_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_string *", "p_data"] + ] + }, + { + "name": "godot_pool_string_array_invert", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array *", "p_self"] + ] + }, + { + "name": "godot_pool_string_array_push_back", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array *", "p_self"], + ["const godot_string *", "p_data"] + ] + }, + { + "name": "godot_pool_string_array_remove", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_string_array_resize", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array *", "p_self"], + ["const godot_int", "p_size"] + ] + }, + { + "name": "godot_pool_string_array_read", + "return_type": "godot_pool_string_array_read_access *", + "arguments": [ + ["const godot_pool_string_array *", "p_self"] + ] + }, + { + "name": "godot_pool_string_array_write", + "return_type": "godot_pool_string_array_write_access *", + "arguments": [ + ["godot_pool_string_array *", "p_self"] + ] + }, + { + "name": "godot_pool_string_array_set", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_string *", "p_data"] + ] + }, + { + "name": "godot_pool_string_array_get", + "return_type": "godot_string", + "arguments": [ + ["const godot_pool_string_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_string_array_size", + "return_type": "godot_int", + "arguments": [ + ["const godot_pool_string_array *", "p_self"] + ] + }, + { + "name": "godot_pool_string_array_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array *", "p_self"] + ] + }, + { + "name": "godot_pool_vector2_array_new", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array *", "r_dest"] + ] + }, + { + "name": "godot_pool_vector2_array_new_copy", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array *", "r_dest"], + ["const godot_pool_vector2_array *", "p_src"] + ] + }, + { + "name": "godot_pool_vector2_array_new_with_array", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array *", "r_dest"], + ["const godot_array *", "p_a"] + ] + }, + { + "name": "godot_pool_vector2_array_append", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array *", "p_self"], + ["const godot_vector2 *", "p_data"] + ] + }, + { + "name": "godot_pool_vector2_array_append_array", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array *", "p_self"], + ["const godot_pool_vector2_array *", "p_array"] + ] + }, + { + "name": "godot_pool_vector2_array_insert", + "return_type": "godot_error", + "arguments": [ + ["godot_pool_vector2_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_vector2 *", "p_data"] + ] + }, + { + "name": "godot_pool_vector2_array_invert", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array *", "p_self"] + ] + }, + { + "name": "godot_pool_vector2_array_push_back", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array *", "p_self"], + ["const godot_vector2 *", "p_data"] + ] + }, + { + "name": "godot_pool_vector2_array_remove", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_vector2_array_resize", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array *", "p_self"], + ["const godot_int", "p_size"] + ] + }, + { + "name": "godot_pool_vector2_array_read", + "return_type": "godot_pool_vector2_array_read_access *", + "arguments": [ + ["const godot_pool_vector2_array *", "p_self"] + ] + }, + { + "name": "godot_pool_vector2_array_write", + "return_type": "godot_pool_vector2_array_write_access *", + "arguments": [ + ["godot_pool_vector2_array *", "p_self"] + ] + }, + { + "name": "godot_pool_vector2_array_set", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_vector2 *", "p_data"] + ] + }, + { + "name": "godot_pool_vector2_array_get", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_pool_vector2_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_vector2_array_size", + "return_type": "godot_int", + "arguments": [ + ["const godot_pool_vector2_array *", "p_self"] + ] + }, + { + "name": "godot_pool_vector2_array_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array *", "p_self"] + ] + }, + { + "name": "godot_pool_vector3_array_new", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array *", "r_dest"] + ] + }, + { + "name": "godot_pool_vector3_array_new_copy", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array *", "r_dest"], + ["const godot_pool_vector3_array *", "p_src"] + ] + }, + { + "name": "godot_pool_vector3_array_new_with_array", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array *", "r_dest"], + ["const godot_array *", "p_a"] + ] + }, + { + "name": "godot_pool_vector3_array_append", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array *", "p_self"], + ["const godot_vector3 *", "p_data"] + ] + }, + { + "name": "godot_pool_vector3_array_append_array", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array *", "p_self"], + ["const godot_pool_vector3_array *", "p_array"] + ] + }, + { + "name": "godot_pool_vector3_array_insert", + "return_type": "godot_error", + "arguments": [ + ["godot_pool_vector3_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_vector3 *", "p_data"] + ] + }, + { + "name": "godot_pool_vector3_array_invert", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array *", "p_self"] + ] + }, + { + "name": "godot_pool_vector3_array_push_back", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array *", "p_self"], + ["const godot_vector3 *", "p_data"] + ] + }, + { + "name": "godot_pool_vector3_array_remove", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_vector3_array_resize", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array *", "p_self"], + ["const godot_int", "p_size"] + ] + }, + { + "name": "godot_pool_vector3_array_read", + "return_type": "godot_pool_vector3_array_read_access *", + "arguments": [ + ["const godot_pool_vector3_array *", "p_self"] + ] + }, + { + "name": "godot_pool_vector3_array_write", + "return_type": "godot_pool_vector3_array_write_access *", + "arguments": [ + ["godot_pool_vector3_array *", "p_self"] + ] + }, + { + "name": "godot_pool_vector3_array_set", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_vector3 *", "p_data"] + ] + }, + { + "name": "godot_pool_vector3_array_get", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_pool_vector3_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_vector3_array_size", + "return_type": "godot_int", + "arguments": [ + ["const godot_pool_vector3_array *", "p_self"] + ] + }, + { + "name": "godot_pool_vector3_array_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array *", "p_self"] + ] + }, + { + "name": "godot_pool_color_array_new", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array *", "r_dest"] + ] + }, + { + "name": "godot_pool_color_array_new_copy", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array *", "r_dest"], + ["const godot_pool_color_array *", "p_src"] + ] + }, + { + "name": "godot_pool_color_array_new_with_array", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array *", "r_dest"], + ["const godot_array *", "p_a"] + ] + }, + { + "name": "godot_pool_color_array_append", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array *", "p_self"], + ["const godot_color *", "p_data"] + ] + }, + { + "name": "godot_pool_color_array_append_array", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array *", "p_self"], + ["const godot_pool_color_array *", "p_array"] + ] + }, + { + "name": "godot_pool_color_array_insert", + "return_type": "godot_error", + "arguments": [ + ["godot_pool_color_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_color *", "p_data"] + ] + }, + { + "name": "godot_pool_color_array_invert", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array *", "p_self"] + ] + }, + { + "name": "godot_pool_color_array_push_back", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array *", "p_self"], + ["const godot_color *", "p_data"] + ] + }, + { + "name": "godot_pool_color_array_remove", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_color_array_resize", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array *", "p_self"], + ["const godot_int", "p_size"] + ] + }, + { + "name": "godot_pool_color_array_read", + "return_type": "godot_pool_color_array_read_access *", + "arguments": [ + ["const godot_pool_color_array *", "p_self"] + ] + }, + { + "name": "godot_pool_color_array_write", + "return_type": "godot_pool_color_array_write_access *", + "arguments": [ + ["godot_pool_color_array *", "p_self"] + ] + }, + { + "name": "godot_pool_color_array_set", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_color *", "p_data"] + ] + }, + { + "name": "godot_pool_color_array_get", + "return_type": "godot_color", + "arguments": [ + ["const godot_pool_color_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_pool_color_array_size", + "return_type": "godot_int", + "arguments": [ + ["const godot_pool_color_array *", "p_self"] + ] + }, + { + "name": "godot_pool_color_array_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array *", "p_self"] + ] + }, + { + "name": "godot_pool_byte_array_read_access_ptr", + "return_type": "const uint8_t *", + "arguments": [ + ["const godot_pool_byte_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_byte_array_read_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array_read_access *", "p_read"], + ["godot_pool_byte_array_read_access *", "p_other"] + ] + }, + { + "name": "godot_pool_byte_array_read_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_int_array_read_access_ptr", + "return_type": "const godot_int *", + "arguments": [ + ["const godot_pool_int_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_int_array_read_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array_read_access *", "p_read"], + ["godot_pool_int_array_read_access *", "p_other"] + ] + }, + { + "name": "godot_pool_int_array_read_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_real_array_read_access_ptr", + "return_type": "const godot_real *", + "arguments": [ + ["const godot_pool_real_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_real_array_read_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array_read_access *", "p_read"], + ["godot_pool_real_array_read_access *", "p_other"] + ] + }, + { + "name": "godot_pool_real_array_read_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_string_array_read_access_ptr", + "return_type": "const godot_string *", + "arguments": [ + ["const godot_pool_string_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_string_array_read_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array_read_access *", "p_read"], + ["godot_pool_string_array_read_access *", "p_other"] + ] + }, + { + "name": "godot_pool_string_array_read_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_vector2_array_read_access_ptr", + "return_type": "const godot_vector2 *", + "arguments": [ + ["const godot_pool_vector2_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_vector2_array_read_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array_read_access *", "p_read"], + ["godot_pool_vector2_array_read_access *", "p_other"] + ] + }, + { + "name": "godot_pool_vector2_array_read_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_vector3_array_read_access_ptr", + "return_type": "const godot_vector3 *", + "arguments": [ + ["const godot_pool_vector3_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_vector3_array_read_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array_read_access *", "p_read"], + ["godot_pool_vector3_array_read_access *", "p_other"] + ] + }, + { + "name": "godot_pool_vector3_array_read_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_color_array_read_access_ptr", + "return_type": "const godot_color *", + "arguments": [ + ["const godot_pool_color_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_color_array_read_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array_read_access *", "p_read"], + ["godot_pool_color_array_read_access *", "p_other"] + ] + }, + { + "name": "godot_pool_color_array_read_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array_read_access *", "p_read"] + ] + }, + { + "name": "godot_pool_byte_array_write_access_ptr", + "return_type": "uint8_t *", + "arguments": [ + ["const godot_pool_byte_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_byte_array_write_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array_write_access *", "p_write"], + ["godot_pool_byte_array_write_access *", "p_other"] + ] + }, + { + "name": "godot_pool_byte_array_write_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_byte_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_int_array_write_access_ptr", + "return_type": "godot_int *", + "arguments": [ + ["const godot_pool_int_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_int_array_write_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array_write_access *", "p_write"], + ["godot_pool_int_array_write_access *", "p_other"] + ] + }, + { + "name": "godot_pool_int_array_write_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_int_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_real_array_write_access_ptr", + "return_type": "godot_real *", + "arguments": [ + ["const godot_pool_real_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_real_array_write_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array_write_access *", "p_write"], + ["godot_pool_real_array_write_access *", "p_other"] + ] + }, + { + "name": "godot_pool_real_array_write_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_real_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_string_array_write_access_ptr", + "return_type": "godot_string *", + "arguments": [ + ["const godot_pool_string_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_string_array_write_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array_write_access *", "p_write"], + ["godot_pool_string_array_write_access *", "p_other"] + ] + }, + { + "name": "godot_pool_string_array_write_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_string_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_vector2_array_write_access_ptr", + "return_type": "godot_vector2 *", + "arguments": [ + ["const godot_pool_vector2_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_vector2_array_write_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array_write_access *", "p_write"], + ["godot_pool_vector2_array_write_access *", "p_other"] + ] + }, + { + "name": "godot_pool_vector2_array_write_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_vector2_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_vector3_array_write_access_ptr", + "return_type": "godot_vector3 *", + "arguments": [ + ["const godot_pool_vector3_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_vector3_array_write_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array_write_access *", "p_write"], + ["godot_pool_vector3_array_write_access *", "p_other"] + ] + }, + { + "name": "godot_pool_vector3_array_write_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_vector3_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_color_array_write_access_ptr", + "return_type": "godot_color *", + "arguments": [ + ["const godot_pool_color_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_pool_color_array_write_access_operator_assign", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array_write_access *", "p_write"], + ["godot_pool_color_array_write_access *", "p_other"] + ] + }, + { + "name": "godot_pool_color_array_write_access_destroy", + "return_type": "void", + "arguments": [ + ["godot_pool_color_array_write_access *", "p_write"] + ] + }, + { + "name": "godot_array_new", + "return_type": "void", + "arguments": [ + ["godot_array *", "r_dest"] + ] + }, + { + "name": "godot_array_new_copy", + "return_type": "void", + "arguments": [ + ["godot_array *", "r_dest"], + ["const godot_array *", "p_src"] + ] + }, + { + "name": "godot_array_new_pool_color_array", + "return_type": "void", + "arguments": [ + ["godot_array *", "r_dest"], + ["const godot_pool_color_array *", "p_pca"] + ] + }, + { + "name": "godot_array_new_pool_vector3_array", + "return_type": "void", + "arguments": [ + ["godot_array *", "r_dest"], + ["const godot_pool_vector3_array *", "p_pv3a"] + ] + }, + { + "name": "godot_array_new_pool_vector2_array", + "return_type": "void", + "arguments": [ + ["godot_array *", "r_dest"], + ["const godot_pool_vector2_array *", "p_pv2a"] + ] + }, + { + "name": "godot_array_new_pool_string_array", + "return_type": "void", + "arguments": [ + ["godot_array *", "r_dest"], + ["const godot_pool_string_array *", "p_psa"] + ] + }, + { + "name": "godot_array_new_pool_real_array", + "return_type": "void", + "arguments": [ + ["godot_array *", "r_dest"], + ["const godot_pool_real_array *", "p_pra"] + ] + }, + { + "name": "godot_array_new_pool_int_array", + "return_type": "void", + "arguments": [ + ["godot_array *", "r_dest"], + ["const godot_pool_int_array *", "p_pia"] + ] + }, + { + "name": "godot_array_new_pool_byte_array", + "return_type": "void", + "arguments": [ + ["godot_array *", "r_dest"], + ["const godot_pool_byte_array *", "p_pba"] + ] + }, + { + "name": "godot_array_set", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"], + ["const godot_int", "p_idx"], + ["const godot_variant *", "p_value"] + ] + }, + { + "name": "godot_array_get", + "return_type": "godot_variant", + "arguments": [ + ["const godot_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_array_operator_index", + "return_type": "godot_variant *", + "arguments": [ + ["godot_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_array_operator_index_const", + "return_type": "const godot_variant *", + "arguments": [ + ["const godot_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_array_append", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"], + ["const godot_variant *", "p_value"] + ] + }, + { + "name": "godot_array_clear", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"] + ] + }, + { + "name": "godot_array_count", + "return_type": "godot_int", + "arguments": [ + ["const godot_array *", "p_self"], + ["const godot_variant *", "p_value"] + ] + }, + { + "name": "godot_array_empty", + "return_type": "godot_bool", + "arguments": [ + ["const godot_array *", "p_self"] + ] + }, + { + "name": "godot_array_erase", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"], + ["const godot_variant *", "p_value"] + ] + }, + { + "name": "godot_array_front", + "return_type": "godot_variant", + "arguments": [ + ["const godot_array *", "p_self"] + ] + }, + { + "name": "godot_array_back", + "return_type": "godot_variant", + "arguments": [ + ["const godot_array *", "p_self"] + ] + }, + { + "name": "godot_array_find", + "return_type": "godot_int", + "arguments": [ + ["const godot_array *", "p_self"], + ["const godot_variant *", "p_what"], + ["const godot_int", "p_from"] + ] + }, + { + "name": "godot_array_find_last", + "return_type": "godot_int", + "arguments": [ + ["const godot_array *", "p_self"], + ["const godot_variant *", "p_what"] + ] + }, + { + "name": "godot_array_has", + "return_type": "godot_bool", + "arguments": [ + ["const godot_array *", "p_self"], + ["const godot_variant *", "p_value"] + ] + }, + { + "name": "godot_array_hash", + "return_type": "godot_int", + "arguments": [ + ["const godot_array *", "p_self"] + ] + }, + { + "name": "godot_array_insert", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"], + ["const godot_int", "p_pos"], + ["const godot_variant *", "p_value"] + ] + }, + { + "name": "godot_array_invert", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"] + ] + }, + { + "name": "godot_array_pop_back", + "return_type": "godot_variant", + "arguments": [ + ["godot_array *", "p_self"] + ] + }, + { + "name": "godot_array_pop_front", + "return_type": "godot_variant", + "arguments": [ + ["godot_array *", "p_self"] + ] + }, + { + "name": "godot_array_push_back", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"], + ["const godot_variant *", "p_value"] + ] + }, + { + "name": "godot_array_push_front", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"], + ["const godot_variant *", "p_value"] + ] + }, + { + "name": "godot_array_remove", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_array_resize", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"], + ["const godot_int", "p_size"] + ] + }, + { + "name": "godot_array_rfind", + "return_type": "godot_int", + "arguments": [ + ["const godot_array *", "p_self"], + ["const godot_variant *", "p_what"], + ["const godot_int", "p_from"] + ] + }, + { + "name": "godot_array_size", + "return_type": "godot_int", + "arguments": [ + ["const godot_array *", "p_self"] + ] + }, + { + "name": "godot_array_sort", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"] + ] + }, + { + "name": "godot_array_sort_custom", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"], + ["godot_object *", "p_obj"], + ["const godot_string *", "p_func"] + ] + }, + { + "name": "godot_array_destroy", + "return_type": "void", + "arguments": [ + ["godot_array *", "p_self"] + ] + }, + { + "name": "godot_dictionary_new", + "return_type": "void", + "arguments": [ + ["godot_dictionary *", "r_dest"] + ] + }, + { + "name": "godot_dictionary_new_copy", + "return_type": "void", + "arguments": [ + ["godot_dictionary *", "r_dest"], + ["const godot_dictionary *", "p_src"] + ] + }, + { + "name": "godot_dictionary_destroy", + "return_type": "void", + "arguments": [ + ["godot_dictionary *", "p_self"] + ] + }, + { + "name": "godot_dictionary_size", + "return_type": "godot_int", + "arguments": [ + ["const godot_dictionary *", "p_self"] + ] + }, + { + "name": "godot_dictionary_empty", + "return_type": "godot_bool", + "arguments": [ + ["const godot_dictionary *", "p_self"] + ] + }, + { + "name": "godot_dictionary_clear", + "return_type": "void", + "arguments": [ + ["godot_dictionary *", "p_self"] + ] + }, + { + "name": "godot_dictionary_has", + "return_type": "godot_bool", + "arguments": [ + ["const godot_dictionary *", "p_self"], + ["const godot_variant *", "p_key"] + ] + }, + { + "name": "godot_dictionary_has_all", + "return_type": "godot_bool", + "arguments": [ + ["const godot_dictionary *", "p_self"], + ["const godot_array *", "p_keys"] + ] + }, + { + "name": "godot_dictionary_erase", + "return_type": "void", + "arguments": [ + ["godot_dictionary *", "p_self"], + ["const godot_variant *", "p_key"] + ] + }, + { + "name": "godot_dictionary_hash", + "return_type": "godot_int", + "arguments": [ + ["const godot_dictionary *", "p_self"] + ] + }, + { + "name": "godot_dictionary_keys", + "return_type": "godot_array", + "arguments": [ + ["const godot_dictionary *", "p_self"] + ] + }, + { + "name": "godot_dictionary_values", + "return_type": "godot_array", + "arguments": [ + ["const godot_dictionary *", "p_self"] + ] + }, + { + "name": "godot_dictionary_get", + "return_type": "godot_variant", + "arguments": [ + ["const godot_dictionary *", "p_self"], + ["const godot_variant *", "p_key"] + ] + }, + { + "name": "godot_dictionary_set", + "return_type": "void", + "arguments": [ + ["godot_dictionary *", "p_self"], + ["const godot_variant *", "p_key"], + ["const godot_variant *", "p_value"] + ] + }, + { + "name": "godot_dictionary_operator_index", + "return_type": "godot_variant *", + "arguments": [ + ["godot_dictionary *", "p_self"], + ["const godot_variant *", "p_key"] + ] + }, + { + "name": "godot_dictionary_operator_index_const", + "return_type": "const godot_variant *", + "arguments": [ + ["const godot_dictionary *", "p_self"], + ["const godot_variant *", "p_key"] + ] + }, + { + "name": "godot_dictionary_next", + "return_type": "godot_variant *", + "arguments": [ + ["const godot_dictionary *", "p_self"], + ["const godot_variant *", "p_key"] + ] + }, + { + "name": "godot_dictionary_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_dictionary *", "p_self"], + ["const godot_dictionary *", "p_b"] + ] + }, + { + "name": "godot_dictionary_to_json", + "return_type": "godot_string", + "arguments": [ + ["const godot_dictionary *", "p_self"] + ] + }, + { + "name": "godot_node_path_new", + "return_type": "void", + "arguments": [ + ["godot_node_path *", "r_dest"], + ["const godot_string *", "p_from"] + ] + }, + { + "name": "godot_node_path_new_copy", + "return_type": "void", + "arguments": [ + ["godot_node_path *", "r_dest"], + ["const godot_node_path *", "p_src"] + ] + }, + { + "name": "godot_node_path_destroy", + "return_type": "void", + "arguments": [ + ["godot_node_path *", "p_self"] + ] + }, + { + "name": "godot_node_path_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_node_path *", "p_self"] + ] + }, + { + "name": "godot_node_path_is_absolute", + "return_type": "godot_bool", + "arguments": [ + ["const godot_node_path *", "p_self"] + ] + }, + { + "name": "godot_node_path_get_name_count", + "return_type": "godot_int", + "arguments": [ + ["const godot_node_path *", "p_self"] + ] + }, + { + "name": "godot_node_path_get_name", + "return_type": "godot_string", + "arguments": [ + ["const godot_node_path *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_node_path_get_subname_count", + "return_type": "godot_int", + "arguments": [ + ["const godot_node_path *", "p_self"] + ] + }, + { + "name": "godot_node_path_get_subname", + "return_type": "godot_string", + "arguments": [ + ["const godot_node_path *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_node_path_get_property", + "return_type": "godot_string", + "arguments": [ + ["const godot_node_path *", "p_self"] + ] + }, + { + "name": "godot_node_path_is_empty", + "return_type": "godot_bool", + "arguments": [ + ["const godot_node_path *", "p_self"] + ] + }, + { + "name": "godot_node_path_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_node_path *", "p_self"], + ["const godot_node_path *", "p_b"] + ] + }, + { + "name": "godot_plane_new_with_reals", + "return_type": "void", + "arguments": [ + ["godot_plane *", "r_dest"], + ["const godot_real", "p_a"], + ["const godot_real", "p_b"], + ["const godot_real", "p_c"], + ["const godot_real", "p_d"] + ] + }, + { + "name": "godot_plane_new_with_vectors", + "return_type": "void", + "arguments": [ + ["godot_plane *", "r_dest"], + ["const godot_vector3 *", "p_v1"], + ["const godot_vector3 *", "p_v2"], + ["const godot_vector3 *", "p_v3"] + ] + }, + { + "name": "godot_plane_new_with_normal", + "return_type": "void", + "arguments": [ + ["godot_plane *", "r_dest"], + ["const godot_vector3 *", "p_normal"], + ["const godot_real", "p_d"] + ] + }, + { + "name": "godot_plane_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_plane *", "p_self"] + ] + }, + { + "name": "godot_plane_normalized", + "return_type": "godot_plane", + "arguments": [ + ["const godot_plane *", "p_self"] + ] + }, + { + "name": "godot_plane_center", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_plane *", "p_self"] + ] + }, + { + "name": "godot_plane_get_any_point", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_plane *", "p_self"] + ] + }, + { + "name": "godot_plane_is_point_over", + "return_type": "godot_bool", + "arguments": [ + ["const godot_plane *", "p_self"], + ["const godot_vector3 *", "p_point"] + ] + }, + { + "name": "godot_plane_distance_to", + "return_type": "godot_real", + "arguments": [ + ["const godot_plane *", "p_self"], + ["const godot_vector3 *", "p_point"] + ] + }, + { + "name": "godot_plane_has_point", + "return_type": "godot_bool", + "arguments": [ + ["const godot_plane *", "p_self"], + ["const godot_vector3 *", "p_point"], + ["const godot_real", "p_epsilon"] + ] + }, + { + "name": "godot_plane_project", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_plane *", "p_self"], + ["const godot_vector3 *", "p_point"] + ] + }, + { + "name": "godot_plane_intersect_3", + "return_type": "godot_bool", + "arguments": [ + ["const godot_plane *", "p_self"], + ["godot_vector3 *", "r_dest"], + ["const godot_plane *", "p_b"], + ["const godot_plane *", "p_c"] + ] + }, + { + "name": "godot_plane_intersects_ray", + "return_type": "godot_bool", + "arguments": [ + ["const godot_plane *", "p_self"], + ["godot_vector3 *", "r_dest"], + ["const godot_vector3 *", "p_from"], + ["const godot_vector3 *", "p_dir"] + ] + }, + { + "name": "godot_plane_intersects_segment", + "return_type": "godot_bool", + "arguments": [ + ["const godot_plane *", "p_self"], + ["godot_vector3 *", "r_dest"], + ["const godot_vector3 *", "p_begin"], + ["const godot_vector3 *", "p_end"] + ] + }, + { + "name": "godot_plane_operator_neg", + "return_type": "godot_plane", + "arguments": [ + ["const godot_plane *", "p_self"] + ] + }, + { + "name": "godot_plane_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_plane *", "p_self"], + ["const godot_plane *", "p_b"] + ] + }, + { + "name": "godot_plane_set_normal", + "return_type": "void", + "arguments": [ + ["godot_plane *", "p_self"], + ["const godot_vector3 *", "p_normal"] + ] + }, + { + "name": "godot_plane_get_normal", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_plane *", "p_self"] + ] + }, + { + "name": "godot_plane_get_d", + "return_type": "godot_real", + "arguments": [ + ["const godot_plane *", "p_self"] + ] + }, + { + "name": "godot_plane_set_d", + "return_type": "void", + "arguments": [ + ["godot_plane *", "p_self"], + ["const godot_real", "p_d"] + ] + }, + { + "name": "godot_rect2_new_with_position_and_size", + "return_type": "void", + "arguments": [ + ["godot_rect2 *", "r_dest"], + ["const godot_vector2 *", "p_pos"], + ["const godot_vector2 *", "p_size"] + ] + }, + { + "name": "godot_rect2_new", + "return_type": "void", + "arguments": [ + ["godot_rect2 *", "r_dest"], + ["const godot_real", "p_x"], + ["const godot_real", "p_y"], + ["const godot_real", "p_width"], + ["const godot_real", "p_height"] + ] + }, + { + "name": "godot_rect2_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_rect2 *", "p_self"] + ] + }, + { + "name": "godot_rect2_get_area", + "return_type": "godot_real", + "arguments": [ + ["const godot_rect2 *", "p_self"] + ] + }, + { + "name": "godot_rect2_intersects", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rect2 *", "p_self"], + ["const godot_rect2 *", "p_b"] + ] + }, + { + "name": "godot_rect2_encloses", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rect2 *", "p_self"], + ["const godot_rect2 *", "p_b"] + ] + }, + { + "name": "godot_rect2_has_no_area", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rect2 *", "p_self"] + ] + }, + { + "name": "godot_rect2_clip", + "return_type": "godot_rect2", + "arguments": [ + ["const godot_rect2 *", "p_self"], + ["const godot_rect2 *", "p_b"] + ] + }, + { + "name": "godot_rect2_merge", + "return_type": "godot_rect2", + "arguments": [ + ["const godot_rect2 *", "p_self"], + ["const godot_rect2 *", "p_b"] + ] + }, + { + "name": "godot_rect2_has_point", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rect2 *", "p_self"], + ["const godot_vector2 *", "p_point"] + ] + }, + { + "name": "godot_rect2_grow", + "return_type": "godot_rect2", + "arguments": [ + ["const godot_rect2 *", "p_self"], + ["const godot_real", "p_by"] + ] + }, + { + "name": "godot_rect2_expand", + "return_type": "godot_rect2", + "arguments": [ + ["const godot_rect2 *", "p_self"], + ["const godot_vector2 *", "p_to"] + ] + }, + { + "name": "godot_rect2_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rect2 *", "p_self"], + ["const godot_rect2 *", "p_b"] + ] + }, + { + "name": "godot_rect2_get_position", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_rect2 *", "p_self"] + ] + }, + { + "name": "godot_rect2_get_size", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_rect2 *", "p_self"] + ] + }, + { + "name": "godot_rect2_set_position", + "return_type": "void", + "arguments": [ + ["godot_rect2 *", "p_self"], + ["const godot_vector2 *", "p_pos"] + ] + }, + { + "name": "godot_rect2_set_size", + "return_type": "void", + "arguments": [ + ["godot_rect2 *", "p_self"], + ["const godot_vector2 *", "p_size"] + ] + }, + { + "name": "godot_aabb_new", + "return_type": "void", + "arguments": [ + ["godot_aabb *", "r_dest"], + ["const godot_vector3 *", "p_pos"], + ["const godot_vector3 *", "p_size"] + ] + }, + { + "name": "godot_aabb_get_position", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_set_position", + "return_type": "void", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_vector3 *", "p_v"] + ] + }, + { + "name": "godot_aabb_get_size", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_set_size", + "return_type": "void", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_vector3 *", "p_v"] + ] + }, + { + "name": "godot_aabb_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_get_area", + "return_type": "godot_real", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_has_no_area", + "return_type": "godot_bool", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_has_no_surface", + "return_type": "godot_bool", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_intersects", + "return_type": "godot_bool", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_aabb *", "p_with"] + ] + }, + { + "name": "godot_aabb_encloses", + "return_type": "godot_bool", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_aabb *", "p_with"] + ] + }, + { + "name": "godot_aabb_merge", + "return_type": "godot_aabb", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_aabb *", "p_with"] + ] + }, + { + "name": "godot_aabb_intersection", + "return_type": "godot_aabb", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_aabb *", "p_with"] + ] + }, + { + "name": "godot_aabb_intersects_plane", + "return_type": "godot_bool", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_plane *", "p_plane"] + ] + }, + { + "name": "godot_aabb_intersects_segment", + "return_type": "godot_bool", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_vector3 *", "p_from"], + ["const godot_vector3 *", "p_to"] + ] + }, + { + "name": "godot_aabb_has_point", + "return_type": "godot_bool", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_vector3 *", "p_point"] + ] + }, + { + "name": "godot_aabb_get_support", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_vector3 *", "p_dir"] + ] + }, + { + "name": "godot_aabb_get_longest_axis", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_get_longest_axis_index", + "return_type": "godot_int", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_get_longest_axis_size", + "return_type": "godot_real", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_get_shortest_axis", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_get_shortest_axis_index", + "return_type": "godot_int", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_get_shortest_axis_size", + "return_type": "godot_real", + "arguments": [ + ["const godot_aabb *", "p_self"] + ] + }, + { + "name": "godot_aabb_expand", + "return_type": "godot_aabb", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_vector3 *", "p_to_point"] + ] + }, + { + "name": "godot_aabb_grow", + "return_type": "godot_aabb", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_real", "p_by"] + ] + }, + { + "name": "godot_aabb_get_endpoint", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_aabb_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_aabb *", "p_self"], + ["const godot_aabb *", "p_b"] + ] + }, + { + "name": "godot_rid_new", + "return_type": "void", + "arguments": [ + ["godot_rid *", "r_dest"] + ] + }, + { + "name": "godot_rid_get_id", + "return_type": "godot_int", + "arguments": [ + ["const godot_rid *", "p_self"] + ] + }, + { + "name": "godot_rid_new_with_resource", + "return_type": "void", + "arguments": [ + ["godot_rid *", "r_dest"], + ["const godot_object *", "p_from"] + ] + }, + { + "name": "godot_rid_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rid *", "p_self"], + ["const godot_rid *", "p_b"] + ] + }, + { + "name": "godot_rid_operator_less", + "return_type": "godot_bool", + "arguments": [ + ["const godot_rid *", "p_self"], + ["const godot_rid *", "p_b"] + ] + }, + { + "name": "godot_transform_new_with_axis_origin", + "return_type": "void", + "arguments": [ + ["godot_transform *", "r_dest"], + ["const godot_vector3 *", "p_x_axis"], + ["const godot_vector3 *", "p_y_axis"], + ["const godot_vector3 *", "p_z_axis"], + ["const godot_vector3 *", "p_origin"] + ] + }, + { + "name": "godot_transform_new", + "return_type": "void", + "arguments": [ + ["godot_transform *", "r_dest"], + ["const godot_basis *", "p_basis"], + ["const godot_vector3 *", "p_origin"] + ] + }, + { + "name": "godot_transform_get_basis", + "return_type": "godot_basis", + "arguments": [ + ["const godot_transform *", "p_self"] + ] + }, + { + "name": "godot_transform_set_basis", + "return_type": "void", + "arguments": [ + ["godot_transform *", "p_self"], + ["godot_basis *", "p_v"] + ] + }, + { + "name": "godot_transform_get_origin", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_transform *", "p_self"] + ] + }, + { + "name": "godot_transform_set_origin", + "return_type": "void", + "arguments": [ + ["godot_transform *", "p_self"], + ["godot_vector3 *", "p_v"] + ] + }, + { + "name": "godot_transform_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_transform *", "p_self"] + ] + }, + { + "name": "godot_transform_inverse", + "return_type": "godot_transform", + "arguments": [ + ["const godot_transform *", "p_self"] + ] + }, + { + "name": "godot_transform_affine_inverse", + "return_type": "godot_transform", + "arguments": [ + ["const godot_transform *", "p_self"] + ] + }, + { + "name": "godot_transform_orthonormalized", + "return_type": "godot_transform", + "arguments": [ + ["const godot_transform *", "p_self"] + ] + }, + { + "name": "godot_transform_rotated", + "return_type": "godot_transform", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_vector3 *", "p_axis"], + ["const godot_real", "p_phi"] + ] + }, + { + "name": "godot_transform_scaled", + "return_type": "godot_transform", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_vector3 *", "p_scale"] + ] + }, + { + "name": "godot_transform_translated", + "return_type": "godot_transform", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_vector3 *", "p_ofs"] + ] + }, + { + "name": "godot_transform_looking_at", + "return_type": "godot_transform", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_vector3 *", "p_target"], + ["const godot_vector3 *", "p_up"] + ] + }, + { + "name": "godot_transform_xform_plane", + "return_type": "godot_plane", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_plane *", "p_v"] + ] + }, + { + "name": "godot_transform_xform_inv_plane", + "return_type": "godot_plane", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_plane *", "p_v"] + ] + }, + { + "name": "godot_transform_new_identity", + "return_type": "void", + "arguments": [ + ["godot_transform *", "r_dest"] + ] + }, + { + "name": "godot_transform_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_transform *", "p_b"] + ] + }, + { + "name": "godot_transform_operator_multiply", + "return_type": "godot_transform", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_transform *", "p_b"] + ] + }, + { + "name": "godot_transform_xform_vector3", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_vector3 *", "p_v"] + ] + }, + { + "name": "godot_transform_xform_inv_vector3", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_vector3 *", "p_v"] + ] + }, + { + "name": "godot_transform_xform_aabb", + "return_type": "godot_aabb", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_aabb *", "p_v"] + ] + }, + { + "name": "godot_transform_xform_inv_aabb", + "return_type": "godot_aabb", + "arguments": [ + ["const godot_transform *", "p_self"], + ["const godot_aabb *", "p_v"] + ] + }, + { + "name": "godot_transform2d_new", + "return_type": "void", + "arguments": [ + ["godot_transform2d *", "r_dest"], + ["const godot_real", "p_rot"], + ["const godot_vector2 *", "p_pos"] + ] + }, + { + "name": "godot_transform2d_new_axis_origin", + "return_type": "void", + "arguments": [ + ["godot_transform2d *", "r_dest"], + ["const godot_vector2 *", "p_x_axis"], + ["const godot_vector2 *", "p_y_axis"], + ["const godot_vector2 *", "p_origin"] + ] + }, + { + "name": "godot_transform2d_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_transform2d *", "p_self"] + ] + }, + { + "name": "godot_transform2d_inverse", + "return_type": "godot_transform2d", + "arguments": [ + ["const godot_transform2d *", "p_self"] + ] + }, + { + "name": "godot_transform2d_affine_inverse", + "return_type": "godot_transform2d", + "arguments": [ + ["const godot_transform2d *", "p_self"] + ] + }, + { + "name": "godot_transform2d_get_rotation", + "return_type": "godot_real", + "arguments": [ + ["const godot_transform2d *", "p_self"] + ] + }, + { + "name": "godot_transform2d_get_origin", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_transform2d *", "p_self"] + ] + }, + { + "name": "godot_transform2d_get_scale", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_transform2d *", "p_self"] + ] + }, + { + "name": "godot_transform2d_orthonormalized", + "return_type": "godot_transform2d", + "arguments": [ + ["const godot_transform2d *", "p_self"] + ] + }, + { + "name": "godot_transform2d_rotated", + "return_type": "godot_transform2d", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_real", "p_phi"] + ] + }, + { + "name": "godot_transform2d_scaled", + "return_type": "godot_transform2d", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_vector2 *", "p_scale"] + ] + }, + { + "name": "godot_transform2d_translated", + "return_type": "godot_transform2d", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_vector2 *", "p_offset"] + ] + }, + { + "name": "godot_transform2d_xform_vector2", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_vector2 *", "p_v"] + ] + }, + { + "name": "godot_transform2d_xform_inv_vector2", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_vector2 *", "p_v"] + ] + }, + { + "name": "godot_transform2d_basis_xform_vector2", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_vector2 *", "p_v"] + ] + }, + { + "name": "godot_transform2d_basis_xform_inv_vector2", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_vector2 *", "p_v"] + ] + }, + { + "name": "godot_transform2d_interpolate_with", + "return_type": "godot_transform2d", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_transform2d *", "p_m"], + ["const godot_real", "p_c"] + ] + }, + { + "name": "godot_transform2d_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_transform2d *", "p_b"] + ] + }, + { + "name": "godot_transform2d_operator_multiply", + "return_type": "godot_transform2d", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_transform2d *", "p_b"] + ] + }, + { + "name": "godot_transform2d_new_identity", + "return_type": "void", + "arguments": [ + ["godot_transform2d *", "r_dest"] + ] + }, + { + "name": "godot_transform2d_xform_rect2", + "return_type": "godot_rect2", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_rect2 *", "p_v"] + ] + }, + { + "name": "godot_transform2d_xform_inv_rect2", + "return_type": "godot_rect2", + "arguments": [ + ["const godot_transform2d *", "p_self"], + ["const godot_rect2 *", "p_v"] + ] + }, + { + "name": "godot_variant_get_type", + "return_type": "godot_variant_type", + "arguments": [ + ["const godot_variant *", "p_v"] + ] + }, + { + "name": "godot_variant_new_copy", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_variant *", "p_src"] + ] + }, + { + "name": "godot_variant_new_nil", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"] + ] + }, + { + "name": "godot_variant_new_bool", + "return_type": "void", + "arguments": [ + ["godot_variant *", "p_v"], + ["const godot_bool", "p_b"] + ] + }, + { + "name": "godot_variant_new_uint", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const uint64_t", "p_i"] + ] + }, + { + "name": "godot_variant_new_int", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const int64_t", "p_i"] + ] + }, + { + "name": "godot_variant_new_real", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const double", "p_r"] + ] + }, + { + "name": "godot_variant_new_string", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_string *", "p_s"] + ] + }, + { + "name": "godot_variant_new_vector2", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_vector2 *", "p_v2"] + ] + }, + { + "name": "godot_variant_new_rect2", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_rect2 *", "p_rect2"] + ] + }, + { + "name": "godot_variant_new_vector3", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_vector3 *", "p_v3"] + ] + }, + { + "name": "godot_variant_new_transform2d", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_transform2d *", "p_t2d"] + ] + }, + { + "name": "godot_variant_new_plane", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_plane *", "p_plane"] + ] + }, + { + "name": "godot_variant_new_quat", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_quat *", "p_quat"] + ] + }, + { + "name": "godot_variant_new_aabb", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_aabb *", "p_aabb"] + ] + }, + { + "name": "godot_variant_new_basis", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_basis *", "p_basis"] + ] + }, + { + "name": "godot_variant_new_transform", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_transform *", "p_trans"] + ] + }, + { + "name": "godot_variant_new_color", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_color *", "p_color"] + ] + }, + { + "name": "godot_variant_new_node_path", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_node_path *", "p_np"] + ] + }, + { + "name": "godot_variant_new_rid", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_rid *", "p_rid"] + ] + }, + { + "name": "godot_variant_new_object", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_object *", "p_obj"] + ] + }, + { + "name": "godot_variant_new_dictionary", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_dictionary *", "p_dict"] + ] + }, + { + "name": "godot_variant_new_array", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_array *", "p_arr"] + ] + }, + { + "name": "godot_variant_new_pool_byte_array", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_pool_byte_array *", "p_pba"] + ] + }, + { + "name": "godot_variant_new_pool_int_array", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_pool_int_array *", "p_pia"] + ] + }, + { + "name": "godot_variant_new_pool_real_array", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_pool_real_array *", "p_pra"] + ] + }, + { + "name": "godot_variant_new_pool_string_array", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_pool_string_array *", "p_psa"] + ] + }, + { + "name": "godot_variant_new_pool_vector2_array", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_pool_vector2_array *", "p_pv2a"] + ] + }, + { + "name": "godot_variant_new_pool_vector3_array", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_pool_vector3_array *", "p_pv3a"] + ] + }, + { + "name": "godot_variant_new_pool_color_array", + "return_type": "void", + "arguments": [ + ["godot_variant *", "r_dest"], + ["const godot_pool_color_array *", "p_pca"] + ] + }, + { + "name": "godot_variant_as_bool", + "return_type": "godot_bool", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_uint", + "return_type": "uint64_t", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_int", + "return_type": "int64_t", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_real", + "return_type": "double", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_string", + "return_type": "godot_string", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_vector2", + "return_type": "godot_vector2", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_rect2", + "return_type": "godot_rect2", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_vector3", + "return_type": "godot_vector3", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_transform2d", + "return_type": "godot_transform2d", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_plane", + "return_type": "godot_plane", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_quat", + "return_type": "godot_quat", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_aabb", + "return_type": "godot_aabb", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_basis", + "return_type": "godot_basis", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_transform", + "return_type": "godot_transform", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_color", + "return_type": "godot_color", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_node_path", + "return_type": "godot_node_path", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_rid", + "return_type": "godot_rid", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_object", + "return_type": "godot_object *", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_dictionary", + "return_type": "godot_dictionary", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_array", + "return_type": "godot_array", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_pool_byte_array", + "return_type": "godot_pool_byte_array", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_pool_int_array", + "return_type": "godot_pool_int_array", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_pool_real_array", + "return_type": "godot_pool_real_array", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_pool_string_array", + "return_type": "godot_pool_string_array", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_pool_vector2_array", + "return_type": "godot_pool_vector2_array", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_pool_vector3_array", + "return_type": "godot_pool_vector3_array", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_as_pool_color_array", + "return_type": "godot_pool_color_array", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_call", + "return_type": "godot_variant", + "arguments": [ + ["godot_variant *", "p_self"], + ["const godot_string *", "p_method"], + ["const godot_variant **", "p_args"], + ["const godot_int", "p_argcount"], + ["godot_variant_call_error *", "r_error"] + ] + }, + { + "name": "godot_variant_has_method", + "return_type": "godot_bool", + "arguments": [ + ["const godot_variant *", "p_self"], + ["const godot_string *", "p_method"] + ] + }, + { + "name": "godot_variant_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_variant *", "p_self"], + ["const godot_variant *", "p_other"] + ] + }, + { + "name": "godot_variant_operator_less", + "return_type": "godot_bool", + "arguments": [ + ["const godot_variant *", "p_self"], + ["const godot_variant *", "p_other"] + ] + }, + { + "name": "godot_variant_hash_compare", + "return_type": "godot_bool", + "arguments": [ + ["const godot_variant *", "p_self"], + ["const godot_variant *", "p_other"] + ] + }, + { + "name": "godot_variant_booleanize", + "return_type": "godot_bool", + "arguments": [ + ["const godot_variant *", "p_self"] + ] + }, + { + "name": "godot_variant_destroy", + "return_type": "void", + "arguments": [ + ["godot_variant *", "p_self"] + ] + }, + { + "name": "godot_string_new", + "return_type": "void", + "arguments": [ + ["godot_string *", "r_dest"] + ] + }, + { + "name": "godot_string_new_copy", + "return_type": "void", + "arguments": [ + ["godot_string *", "r_dest"], + ["const godot_string *", "p_src"] + ] + }, + { + "name": "godot_string_new_data", + "return_type": "void", + "arguments": [ + ["godot_string *", "r_dest"], + ["const char *", "p_contents"], + ["const int", "p_size"] + ] + }, + { + "name": "godot_string_new_unicode_data", + "return_type": "void", + "arguments": [ + ["godot_string *", "r_dest"], + ["const wchar_t *", "p_contents"], + ["const int", "p_size"] + ] + }, + { + "name": "godot_string_get_data", + "return_type": "void", + "arguments": [ + ["const godot_string *", "p_self"], + ["char *", "p_dest"], + ["int *", "p_size"] + ] + }, + { + "name": "godot_string_operator_index", + "return_type": "wchar_t *", + "arguments": [ + ["godot_string *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_string_operator_index_const", + "return_type": "wchar_t", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_int", "p_idx"] + ] + }, + { + "name": "godot_string_c_str", + "return_type": "const char *", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_unicode_str", + "return_type": "const wchar_t *", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_b"] + ] + }, + { + "name": "godot_string_operator_less", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_b"] + ] + }, + { + "name": "godot_string_operator_plus", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_b"] + ] + }, + { + "name": "godot_string_length", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_begins_with", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_string"] + ] + }, + { + "name": "godot_string_begins_with_char_array", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"], + ["const char *", "p_char_array"] + ] + }, + { + "name": "godot_string_bigrams", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_chr", + "return_type": "godot_string", + "arguments": [ + ["wchar_t", "p_character"] + ] + }, + { + "name": "godot_string_ends_with", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_string"] + ] + }, + { + "name": "godot_string_find", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_what"] + ] + }, + { + "name": "godot_string_find_from", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_what"], + ["godot_int", "p_from"] + ] + }, + { + "name": "godot_string_findmk", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_array *", "p_keys"] + ] + }, + { + "name": "godot_string_findmk_from", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_array *", "p_keys"], + ["godot_int", "p_from"] + ] + }, + { + "name": "godot_string_findmk_from_in_place", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_array *", "p_keys"], + ["godot_int", "p_from"], + ["godot_int *", "r_key"] + ] + }, + { + "name": "godot_string_findn", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_what"] + ] + }, + { + "name": "godot_string_findn_from", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_what"], + ["godot_int", "p_from"] + ] + }, + { + "name": "godot_string_find_last", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_what"] + ] + }, + { + "name": "godot_string_format", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_variant *", "p_values"] + ] + }, + { + "name": "godot_string_format_with_custom_placeholder", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_variant *", "p_values"], + ["const char *", "p_placeholder"] + ] + }, + { + "name": "godot_string_hex_encode_buffer", + "return_type": "godot_string", + "arguments": [ + ["const uint8_t *", "p_buffer"], + ["godot_int", "p_len"] + ] + }, + { + "name": "godot_string_hex_to_int", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_hex_to_int_without_prefix", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_insert", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_at_pos"], + ["godot_string", "p_string"] + ] + }, + { + "name": "godot_string_is_numeric", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_is_subsequence_of", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_string"] + ] + }, + { + "name": "godot_string_is_subsequence_ofi", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_string"] + ] + }, + { + "name": "godot_string_lpad", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_min_length"] + ] + }, + { + "name": "godot_string_lpad_with_custom_character", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_min_length"], + ["const godot_string *", "p_character"] + ] + }, + { + "name": "godot_string_match", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_wildcard"] + ] + }, + { + "name": "godot_string_matchn", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_wildcard"] + ] + }, + { + "name": "godot_string_md5", + "return_type": "godot_string", + "arguments": [ + ["const uint8_t *", "p_md5"] + ] + }, + { + "name": "godot_string_num", + "return_type": "godot_string", + "arguments": [ + ["double", "p_num"] + ] + }, + { + "name": "godot_string_num_int64", + "return_type": "godot_string", + "arguments": [ + ["int64_t", "p_num"], + ["godot_int", "p_base"] + ] + }, + { + "name": "godot_string_num_int64_capitalized", + "return_type": "godot_string", + "arguments": [ + ["int64_t", "p_num"], + ["godot_int", "p_base"], + ["godot_bool", "p_capitalize_hex"] + ] + }, + { + "name": "godot_string_num_real", + "return_type": "godot_string", + "arguments": [ + ["double", "p_num"] + ] + }, + { + "name": "godot_string_num_scientific", + "return_type": "godot_string", + "arguments": [ + ["double", "p_num"] + ] + }, + { + "name": "godot_string_num_with_decimals", + "return_type": "godot_string", + "arguments": [ + ["double", "p_num"], + ["godot_int", "p_decimals"] + ] + }, + { + "name": "godot_string_pad_decimals", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_digits"] + ] + }, + { + "name": "godot_string_pad_zeros", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_digits"] + ] + }, + { + "name": "godot_string_replace_first", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_key"], + ["godot_string", "p_with"] + ] + }, + { + "name": "godot_string_replace", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_key"], + ["godot_string", "p_with"] + ] + }, + { + "name": "godot_string_replacen", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_key"], + ["godot_string", "p_with"] + ] + }, + { + "name": "godot_string_rfind", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_what"] + ] + }, + { + "name": "godot_string_rfindn", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_what"] + ] + }, + { + "name": "godot_string_rfind_from", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_what"], + ["godot_int", "p_from"] + ] + }, + { + "name": "godot_string_rfindn_from", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_what"], + ["godot_int", "p_from"] + ] + }, + { + "name": "godot_string_rpad", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_min_length"] + ] + }, + { + "name": "godot_string_rpad_with_custom_character", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_min_length"], + ["const godot_string *", "p_character"] + ] + }, + { + "name": "godot_string_similarity", + "return_type": "godot_real", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_string"] + ] + }, + { + "name": "godot_string_sprintf", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_array *", "p_values"], + ["godot_bool *", "p_error"] + ] + }, + { + "name": "godot_string_substr", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_from"], + ["godot_int", "p_chars"] + ] + }, + { + "name": "godot_string_to_double", + "return_type": "double", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_to_float", + "return_type": "godot_real", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_to_int", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_camelcase_to_underscore", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_camelcase_to_underscore_lowercased", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_capitalize", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_char_to_double", + "return_type": "double", + "arguments": [ + ["const char *", "p_what"] + ] + }, + { + "name": "godot_string_char_to_int", + "return_type": "godot_int", + "arguments": [ + ["const char *", "p_what"] + ] + }, + { + "name": "godot_string_wchar_to_int", + "return_type": "int64_t", + "arguments": [ + ["const wchar_t *", "p_str"] + ] + }, + { + "name": "godot_string_char_to_int_with_len", + "return_type": "godot_int", + "arguments": [ + ["const char *", "p_what"], + ["godot_int", "p_len"] + ] + }, + { + "name": "godot_string_char_to_int64_with_len", + "return_type": "int64_t", + "arguments": [ + ["const wchar_t *", "p_str"], + ["int", "p_len"] + ] + }, + { + "name": "godot_string_hex_to_int64", + "return_type": "int64_t", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_hex_to_int64_with_prefix", + "return_type": "int64_t", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_to_int64", + "return_type": "int64_t", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_unicode_char_to_double", + "return_type": "double", + "arguments": [ + ["const wchar_t *", "p_str"], + ["const wchar_t **", "r_end"] + ] + }, + { + "name": "godot_string_get_slice_count", + "return_type": "godot_int", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_splitter"] + ] + }, + { + "name": "godot_string_get_slice", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_string", "p_splitter"], + ["godot_int", "p_slice"] + ] + }, + { + "name": "godot_string_get_slicec", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["wchar_t", "p_splitter"], + ["godot_int", "p_slice"] + ] + }, + { + "name": "godot_string_split", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_splitter"] + ] + }, + { + "name": "godot_string_split_allow_empty", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_splitter"] + ] + }, + { + "name": "godot_string_split_floats", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_splitter"] + ] + }, + { + "name": "godot_string_split_floats_allows_empty", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_splitter"] + ] + }, + { + "name": "godot_string_split_floats_mk", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_array *", "p_splitters"] + ] + }, + { + "name": "godot_string_split_floats_mk_allows_empty", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_array *", "p_splitters"] + ] + }, + { + "name": "godot_string_split_ints", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_splitter"] + ] + }, + { + "name": "godot_string_split_ints_allows_empty", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_splitter"] + ] + }, + { + "name": "godot_string_split_ints_mk", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_array *", "p_splitters"] + ] + }, + { + "name": "godot_string_split_ints_mk_allows_empty", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_array *", "p_splitters"] + ] + }, + { + "name": "godot_string_split_spaces", + "return_type": "godot_array", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_char_lowercase", + "return_type": "wchar_t", + "arguments": [ + ["wchar_t", "p_char"] + ] + }, + { + "name": "godot_string_char_uppercase", + "return_type": "wchar_t", + "arguments": [ + ["wchar_t", "p_char"] + ] + }, + { + "name": "godot_string_to_lower", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_to_upper", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_get_basename", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_get_extension", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_left", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_pos"] + ] + }, + { + "name": "godot_string_ord_at", + "return_type": "wchar_t", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_idx"] + ] + }, + { + "name": "godot_string_plus_file", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_file"] + ] + }, + { + "name": "godot_string_right", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_pos"] + ] + }, + { + "name": "godot_string_strip_edges", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_bool", "p_left"], + ["godot_bool", "p_right"] + ] + }, + { + "name": "godot_string_strip_escapes", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_erase", + "return_type": "void", + "arguments": [ + ["godot_string *", "p_self"], + ["godot_int", "p_pos"], + ["godot_int", "p_chars"] + ] + }, + { + "name": "godot_string_ascii", + "return_type": "void", + "arguments": [ + ["godot_string *", "p_self"], + ["char *", "result"] + ] + }, + { + "name": "godot_string_ascii_extended", + "return_type": "void", + "arguments": [ + ["godot_string *", "p_self"], + ["char *", "result"] + ] + }, + { + "name": "godot_string_utf8", + "return_type": "void", + "arguments": [ + ["godot_string *", "p_self"], + ["char *", "result"] + ] + }, + { + "name": "godot_string_parse_utf8", + "return_type": "godot_bool", + "arguments": [ + ["godot_string *", "p_self"], + ["const char *", "p_utf8"] + ] + }, + { + "name": "godot_string_parse_utf8_with_len", + "return_type": "godot_bool", + "arguments": [ + ["godot_string *", "p_self"], + ["const char *", "p_utf8"], + ["godot_int", "p_len"] + ] + }, + { + "name": "godot_string_chars_to_utf8", + "return_type": "godot_string", + "arguments": [ + ["const char *", "p_utf8"] + ] + }, + { + "name": "godot_string_chars_to_utf8_with_len", + "return_type": "godot_string", + "arguments": [ + ["const char *", "p_utf8"], + ["godot_int", "p_len"] + ] + }, + { + "name": "godot_string_hash", + "return_type": "uint32_t", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_hash64", + "return_type": "uint64_t", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_hash_chars", + "return_type": "uint32_t", + "arguments": [ + ["const char *", "p_cstr"] + ] + }, + { + "name": "godot_string_hash_chars_with_len", + "return_type": "uint32_t", + "arguments": [ + ["const char *", "p_cstr"], + ["godot_int", "p_len"] + ] + }, + { + "name": "godot_string_hash_utf8_chars", + "return_type": "uint32_t", + "arguments": [ + ["const wchar_t *", "p_str"] + ] + }, + { + "name": "godot_string_hash_utf8_chars_with_len", + "return_type": "uint32_t", + "arguments": [ + ["const wchar_t *", "p_str"], + ["godot_int", "p_len"] + ] + }, + { + "name": "godot_string_md5_buffer", + "return_type": "godot_pool_byte_array", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_md5_text", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_sha256_buffer", + "return_type": "godot_pool_byte_array", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_sha256_text", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_empty", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_get_base_dir", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_get_file", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_humanize_size", + "return_type": "godot_string", + "arguments": [ + ["size_t", "p_size"] + ] + }, + { + "name": "godot_string_is_abs_path", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_is_rel_path", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_is_resource_file", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_path_to", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_path"] + ] + }, + { + "name": "godot_string_path_to_file", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["const godot_string *", "p_path"] + ] + }, + { + "name": "godot_string_simplify_path", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_c_escape", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_c_escape_multiline", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_c_unescape", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_http_escape", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_http_unescape", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_json_escape", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_word_wrap", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_int", "p_chars_per_line"] + ] + }, + { + "name": "godot_string_xml_escape", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_xml_escape_with_quotes", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_xml_unescape", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_percent_decode", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_percent_encode", + "return_type": "godot_string", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_is_valid_float", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_is_valid_hex_number", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"], + ["godot_bool", "p_with_prefix"] + ] + }, + { + "name": "godot_string_is_valid_html_color", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_is_valid_identifier", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_is_valid_integer", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_is_valid_ip_address", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_destroy", + "return_type": "void", + "arguments": [ + ["godot_string *", "p_self"] + ] + }, + { + "name": "godot_string_name_new", + "return_type": "void", + "arguments": [ + ["godot_string_name *", "r_dest"], + ["const godot_string *", "p_name"] + ] + }, + { + "name": "godot_string_name_new_data", + "return_type": "void", + "arguments": [ + ["godot_string_name *", "r_dest"], + ["const char *", "p_name"] + ] + }, + { + "name": "godot_string_name_get_name", + "return_type": "godot_string", + "arguments": [ + ["const godot_string_name *", "p_self"] + ] + }, + { + "name": "godot_string_name_get_hash", + "return_type": "uint32_t", + "arguments": [ + ["const godot_string_name *", "p_self"] + ] + }, + { + "name": "godot_string_name_get_data_unique_pointer", + "return_type": "const void *", + "arguments": [ + ["const godot_string_name *", "p_self"] + ] + }, + { + "name": "godot_string_name_operator_equal", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string_name *", "p_self"], + ["const godot_string_name *", "p_other"] + ] + }, + { + "name": "godot_string_name_operator_less", + "return_type": "godot_bool", + "arguments": [ + ["const godot_string_name *", "p_self"], + ["const godot_string_name *", "p_other"] + ] + }, + { + "name": "godot_string_name_destroy", + "return_type": "void", + "arguments": [ + ["godot_string_name *", "p_self"] + ] + }, + { + "name": "godot_object_destroy", + "return_type": "void", + "arguments": [ + ["godot_object *", "p_o"] + ] + }, + { + "name": "godot_global_get_singleton", + "return_type": "godot_object *", + "arguments": [ + ["char *", "p_name"] + ] + }, + { + "name": "godot_method_bind_get_method", + "return_type": "godot_method_bind *", + "arguments": [ + ["const char *", "p_classname"], + ["const char *", "p_methodname"] + ] + }, + { + "name": "godot_method_bind_ptrcall", + "return_type": "void", + "arguments": [ + ["godot_method_bind *", "p_method_bind"], + ["godot_object *", "p_instance"], + ["const void **", "p_args"], + ["void *", "p_ret"] + ] + }, + { + "name": "godot_method_bind_call", + "return_type": "godot_variant", + "arguments": [ + ["godot_method_bind *", "p_method_bind"], + ["godot_object *", "p_instance"], + ["const godot_variant **", "p_args"], + ["const int", "p_arg_count"], + ["godot_variant_call_error *", "p_call_error"] + ] + }, + { + "name": "godot_get_class_constructor", + "return_type": "godot_class_constructor", + "arguments": [ + ["const char *", "p_classname"] + ] + }, + { + "name": "godot_alloc", + "return_type": "void *", + "arguments": [ + ["int", "p_bytes"] + ] + }, + { + "name": "godot_realloc", + "return_type": "void *", + "arguments": [ + ["void *", "p_ptr"], + ["int", "p_bytes"] + ] + }, + { + "name": "godot_free", + "return_type": "void", + "arguments": [ + ["void *", "p_ptr"] + ] + }, + { + "name": "godot_print_error", + "return_type": "void", + "arguments": [ + ["const char *", "p_description"], + ["const char *", "p_function"], + ["const char *", "p_file"], + ["int", "p_line"] + ] + }, + { + "name": "godot_print_warning", + "return_type": "void", + "arguments": [ + ["const char *", "p_description"], + ["const char *", "p_function"], + ["const char *", "p_file"], + ["int", "p_line"] + ] + }, + { + "name": "godot_print", + "return_type": "void", + "arguments": [ + ["const godot_string *", "p_message"] + ] + } + ] + }, + "extensions": { + "nativescript": { + "type": "NATIVESCRIPT", + "version": { + "major": 1, + "minor": 0 + }, + "api": [ + { + "name": "godot_nativescript_register_class", + "return_type": "void", + "arguments": [ + ["void *", "p_gdnative_handle"], + ["const char *", "p_name"], + ["const char *", "p_base"], + ["godot_instance_create_func", "p_create_func"], + ["godot_instance_destroy_func", "p_destroy_func"] + ] + }, + { + "name": "godot_nativescript_register_tool_class", + "return_type": "void", + "arguments": [ + ["void *", "p_gdnative_handle"], + ["const char *", "p_name"], + ["const char *", "p_base"], + ["godot_instance_create_func", "p_create_func"], + ["godot_instance_destroy_func", "p_destroy_func"] + ] + }, + { + "name": "godot_nativescript_register_method", + "return_type": "void", + "arguments": [ + ["void *", "p_gdnative_handle"], + ["const char *", "p_name"], + ["const char *", "p_function_name"], + ["godot_method_attributes", "p_attr"], + ["godot_instance_method", "p_method"] + ] + }, + { + "name": "godot_nativescript_register_property", + "return_type": "void", + "arguments": [ + ["void *", "p_gdnative_handle"], + ["const char *", "p_name"], + ["const char *", "p_path"], + ["godot_property_attributes *", "p_attr"], + ["godot_property_set_func", "p_set_func"], + ["godot_property_get_func", "p_get_func"] + ] + }, + { + "name": "godot_nativescript_register_signal", + "return_type": "void", + "arguments": [ + ["void *", "p_gdnative_handle"], + ["const char *", "p_name"], + ["const godot_signal *", "p_signal"] + ] + }, + { + "name": "godot_nativescript_get_userdata", + "return_type": "void *", + "arguments": [ + ["godot_object *", "p_instance"] + ] + } + ] + }, + "pluginscript": { + "type": "PLUGINSCRIPT", + "version": { + "major": 1, + "minor": 0 + }, + "api": [ + { + "name": "godot_pluginscript_register_language", + "return_type": "void", + "arguments": [ + ["const godot_pluginscript_language_desc *", "language_desc"] + ] + } + ] + }, + "arvr": { + "type": "ARVR", + "version": { + "major": 1, + "minor": 0 + }, + "api": [ + { + "name": "godot_arvr_register_interface", + "return_type": "void", + "arguments": [ + ["const godot_arvr_interface_gdnative *", "p_interface"] + ] + }, + { + "name": "godot_arvr_get_worldscale", + "return_type": "godot_real", + "arguments": [] + }, + { + "name": "godot_arvr_get_reference_frame", + "return_type": "godot_transform", + "arguments": [] + }, + { + "name": "godot_arvr_blit", + "return_type": "void", + "arguments": [ + ["int", "p_eye"], + ["godot_rid *", "p_render_target"], + ["godot_rect2 *", "p_screen_rect"] + ] + }, + { + "name": "godot_arvr_get_texid", + "return_type": "godot_int", + "arguments": [ + ["godot_rid *", "p_render_target"] + ] + }, + { + "name": "godot_arvr_add_controller", + "return_type": "godot_int", + "arguments": [ + ["char *", "p_device_name"], + ["godot_int", "p_hand"], + ["godot_bool", "p_tracks_orientation"], + ["godot_bool", "p_tracks_position"] + ] + }, + { + "name": "godot_arvr_remove_controller", + "return_type": "void", + "arguments": [ + ["godot_int", "p_controller_id"] + ] + }, + { + "name": "godot_arvr_set_controller_transform", + "return_type": "void", + "arguments": [ + ["godot_int", "p_controller_id"], + ["godot_transform *", "p_transform"], + ["godot_bool", "p_tracks_orientation"], + ["godot_bool", "p_tracks_position"] + ] + }, + { + "name": "godot_arvr_set_controller_button", + "return_type": "void", + "arguments": [ + ["godot_int", "p_controller_id"], + ["godot_int", "p_button"], + ["godot_bool", "p_is_pressed"] + ] + }, + { + "name": "godot_arvr_set_controller_axis", + "return_type": "void", + "arguments": [ + ["godot_int", "p_controller_id"], + ["godot_int", "p_exis"], + ["godot_real", "p_value"], + ["godot_bool", "p_can_be_negative"] + ] + }, + { + "name": "godot_arvr_get_controller_rumble", + "return_type": "godot_real", + "arguments": [ + ["godot_int", "p_controller_id"] + ] + } ] } - ] + } } diff --git a/modules/gdnative/include/nativearvr/godot_nativearvr.h b/modules/gdnative/include/arvr/godot_arvr.h index a4f4d6a9f1..be13ac954b 100644 --- a/modules/gdnative/include/nativearvr/godot_nativearvr.h +++ b/modules/gdnative/include/arvr/godot_arvr.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* godot_nativearvr.h */ +/* godot_arvr.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -47,7 +47,7 @@ typedef struct { godot_bool (*is_initialized)(const void *); godot_bool (*initialize)(void *); void (*uninitialize)(void *); - godot_vector2 (*get_recommended_render_targetsize)(const void *); + godot_vector2 (*get_render_targetsize)(const void *); godot_transform (*get_transform_for_eye)(void *, godot_int, godot_transform *); void (*fill_projection_for_eye)(void *, godot_real *, godot_int, godot_real, godot_real, godot_real); void (*commit_for_eye)(void *, godot_int, godot_rid *, godot_rect2 *); diff --git a/modules/gdnative/include/gdnative/aabb.h b/modules/gdnative/include/gdnative/aabb.h new file mode 100644 index 0000000000..34339fa242 --- /dev/null +++ b/modules/gdnative/include/gdnative/aabb.h @@ -0,0 +1,117 @@ +/*************************************************************************/ +/* aabb.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef GODOT_AABB_H +#define GODOT_AABB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +#define GODOT_AABB_SIZE 24 + +#ifndef GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED +#define GODOT_CORE_API_GODOT_AABB_TYPE_DEFINED +typedef struct { + uint8_t _dont_touch_that[GODOT_AABB_SIZE]; +} godot_aabb; +#endif + +// reduce extern "C" nesting for VS2013 +#ifdef __cplusplus +} +#endif + +#include <gdnative/gdnative.h> +#include <gdnative/plane.h> +#include <gdnative/vector3.h> + +#ifdef __cplusplus +extern "C" { +#endif + +void GDAPI godot_aabb_new(godot_aabb *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size); + +godot_vector3 GDAPI godot_aabb_get_position(const godot_aabb *p_self); +void GDAPI godot_aabb_set_position(const godot_aabb *p_self, const godot_vector3 *p_v); + +godot_vector3 GDAPI godot_aabb_get_size(const godot_aabb *p_self); +void GDAPI godot_aabb_set_size(const godot_aabb *p_self, const godot_vector3 *p_v); + +godot_string GDAPI godot_aabb_as_string(const godot_aabb *p_self); + +godot_real GDAPI godot_aabb_get_area(const godot_aabb *p_self); + +godot_bool GDAPI godot_aabb_has_no_area(const godot_aabb *p_self); + +godot_bool GDAPI godot_aabb_has_no_surface(const godot_aabb *p_self); + +godot_bool GDAPI godot_aabb_intersects(const godot_aabb *p_self, const godot_aabb *p_with); + +godot_bool GDAPI godot_aabb_encloses(const godot_aabb *p_self, const godot_aabb *p_with); + +godot_aabb GDAPI godot_aabb_merge(const godot_aabb *p_self, const godot_aabb *p_with); + +godot_aabb GDAPI godot_aabb_intersection(const godot_aabb *p_self, const godot_aabb *p_with); + +godot_bool GDAPI godot_aabb_intersects_plane(const godot_aabb *p_self, const godot_plane *p_plane); + +godot_bool GDAPI godot_aabb_intersects_segment(const godot_aabb *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to); + +godot_bool GDAPI godot_aabb_has_point(const godot_aabb *p_self, const godot_vector3 *p_point); + +godot_vector3 GDAPI godot_aabb_get_support(const godot_aabb *p_self, const godot_vector3 *p_dir); + +godot_vector3 GDAPI godot_aabb_get_longest_axis(const godot_aabb *p_self); + +godot_int GDAPI godot_aabb_get_longest_axis_index(const godot_aabb *p_self); + +godot_real GDAPI godot_aabb_get_longest_axis_size(const godot_aabb *p_self); + +godot_vector3 GDAPI godot_aabb_get_shortest_axis(const godot_aabb *p_self); + +godot_int GDAPI godot_aabb_get_shortest_axis_index(const godot_aabb *p_self); + +godot_real GDAPI godot_aabb_get_shortest_axis_size(const godot_aabb *p_self); + +godot_aabb GDAPI godot_aabb_expand(const godot_aabb *p_self, const godot_vector3 *p_to_point); + +godot_aabb GDAPI godot_aabb_grow(const godot_aabb *p_self, const godot_real p_by); + +godot_vector3 GDAPI godot_aabb_get_endpoint(const godot_aabb *p_self, const godot_int p_idx); + +godot_bool GDAPI godot_aabb_operator_equal(const godot_aabb *p_self, const godot_aabb *p_b); + +#ifdef __cplusplus +} +#endif + +#endif // GODOT_AABB_H diff --git a/modules/gdnative/include/gdnative/array.h b/modules/gdnative/include/gdnative/array.h index d0639589b7..01ae61e280 100644 --- a/modules/gdnative/include/gdnative/array.h +++ b/modules/gdnative/include/gdnative/array.h @@ -76,6 +76,8 @@ godot_variant GDAPI godot_array_get(const godot_array *p_self, const godot_int p godot_variant GDAPI *godot_array_operator_index(godot_array *p_self, const godot_int p_idx); +const godot_variant GDAPI *godot_array_operator_index_const(const godot_array *p_self, const godot_int p_idx); + void GDAPI godot_array_append(godot_array *p_self, const godot_variant *p_value); void GDAPI godot_array_clear(godot_array *p_self); diff --git a/modules/gdnative/include/gdnative/dictionary.h b/modules/gdnative/include/gdnative/dictionary.h index e68d0fdc29..6d1f436921 100644 --- a/modules/gdnative/include/gdnative/dictionary.h +++ b/modules/gdnative/include/gdnative/dictionary.h @@ -85,6 +85,8 @@ void GDAPI godot_dictionary_set(godot_dictionary *p_self, const godot_variant *p godot_variant GDAPI *godot_dictionary_operator_index(godot_dictionary *p_self, const godot_variant *p_key); +const godot_variant GDAPI *godot_dictionary_operator_index_const(const godot_dictionary *p_self, const godot_variant *p_key); + godot_variant GDAPI *godot_dictionary_next(const godot_dictionary *p_self, const godot_variant *p_key); godot_bool GDAPI godot_dictionary_operator_equal(const godot_dictionary *p_self, const godot_dictionary *p_b); diff --git a/modules/gdnative/include/gdnative/gdnative.h b/modules/gdnative/include/gdnative/gdnative.h index 25d45db306..38a42ab658 100644 --- a/modules/gdnative/include/gdnative/gdnative.h +++ b/modules/gdnative/include/gdnative/gdnative.h @@ -53,7 +53,7 @@ extern "C" { // This is for libraries *using* the header, NOT GODOT EXPOSING STUFF!! #ifdef _WIN32 -#define GDN_EXPORT __declspec(dllexport) +#define GDN_EXPORT #else #define GDN_EXPORT #endif @@ -169,9 +169,9 @@ typedef void godot_object; #include <gdnative/quat.h> -/////// Rect3 +/////// AABB -#include <gdnative/rect3.h> +#include <gdnative/aabb.h> /////// Basis @@ -237,7 +237,7 @@ typedef struct { uint64_t editor_api_hash; uint64_t no_api_hash; godot_object *gd_native_library; // pointer to GDNativeLibrary that is being initialized - const struct godot_gdnative_api_struct *api_struct; + const struct godot_gdnative_core_api_struct *api_struct; const godot_string *active_library_path; } godot_gdnative_init_options; diff --git a/modules/gdnative/include/gdnative/rect3.h b/modules/gdnative/include/gdnative/rect3.h deleted file mode 100644 index f603a9268a..0000000000 --- a/modules/gdnative/include/gdnative/rect3.h +++ /dev/null @@ -1,117 +0,0 @@ -/*************************************************************************/ -/* rect3.h */ -/*************************************************************************/ -/* This file is part of: */ -/* GODOT ENGINE */ -/* https://godotengine.org */ -/*************************************************************************/ -/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ -/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ -/* */ -/* Permission is hereby granted, free of charge, to any person obtaining */ -/* a copy of this software and associated documentation files (the */ -/* "Software"), to deal in the Software without restriction, including */ -/* without limitation the rights to use, copy, modify, merge, publish, */ -/* distribute, sublicense, and/or sell copies of the Software, and to */ -/* permit persons to whom the Software is furnished to do so, subject to */ -/* the following conditions: */ -/* */ -/* The above copyright notice and this permission notice shall be */ -/* included in all copies or substantial portions of the Software. */ -/* */ -/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ -/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ -/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ -/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ -/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ -/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ -/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -/*************************************************************************/ -#ifndef GODOT_RECT3_H -#define GODOT_RECT3_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stdint.h> - -#define GODOT_RECT3_SIZE 24 - -#ifndef GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED -#define GODOT_CORE_API_GODOT_RECT3_TYPE_DEFINED -typedef struct { - uint8_t _dont_touch_that[GODOT_RECT3_SIZE]; -} godot_rect3; -#endif - -// reduce extern "C" nesting for VS2013 -#ifdef __cplusplus -} -#endif - -#include <gdnative/gdnative.h> -#include <gdnative/plane.h> -#include <gdnative/vector3.h> - -#ifdef __cplusplus -extern "C" { -#endif - -void GDAPI godot_rect3_new(godot_rect3 *r_dest, const godot_vector3 *p_pos, const godot_vector3 *p_size); - -godot_vector3 GDAPI godot_rect3_get_position(const godot_rect3 *p_self); -void GDAPI godot_rect3_set_position(const godot_rect3 *p_self, const godot_vector3 *p_v); - -godot_vector3 GDAPI godot_rect3_get_size(const godot_rect3 *p_self); -void GDAPI godot_rect3_set_size(const godot_rect3 *p_self, const godot_vector3 *p_v); - -godot_string GDAPI godot_rect3_as_string(const godot_rect3 *p_self); - -godot_real GDAPI godot_rect3_get_area(const godot_rect3 *p_self); - -godot_bool GDAPI godot_rect3_has_no_area(const godot_rect3 *p_self); - -godot_bool GDAPI godot_rect3_has_no_surface(const godot_rect3 *p_self); - -godot_bool GDAPI godot_rect3_intersects(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_bool GDAPI godot_rect3_encloses(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_rect3 GDAPI godot_rect3_merge(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_rect3 GDAPI godot_rect3_intersection(const godot_rect3 *p_self, const godot_rect3 *p_with); - -godot_bool GDAPI godot_rect3_intersects_plane(const godot_rect3 *p_self, const godot_plane *p_plane); - -godot_bool GDAPI godot_rect3_intersects_segment(const godot_rect3 *p_self, const godot_vector3 *p_from, const godot_vector3 *p_to); - -godot_bool GDAPI godot_rect3_has_point(const godot_rect3 *p_self, const godot_vector3 *p_point); - -godot_vector3 GDAPI godot_rect3_get_support(const godot_rect3 *p_self, const godot_vector3 *p_dir); - -godot_vector3 GDAPI godot_rect3_get_longest_axis(const godot_rect3 *p_self); - -godot_int GDAPI godot_rect3_get_longest_axis_index(const godot_rect3 *p_self); - -godot_real GDAPI godot_rect3_get_longest_axis_size(const godot_rect3 *p_self); - -godot_vector3 GDAPI godot_rect3_get_shortest_axis(const godot_rect3 *p_self); - -godot_int GDAPI godot_rect3_get_shortest_axis_index(const godot_rect3 *p_self); - -godot_real GDAPI godot_rect3_get_shortest_axis_size(const godot_rect3 *p_self); - -godot_rect3 GDAPI godot_rect3_expand(const godot_rect3 *p_self, const godot_vector3 *p_to_point); - -godot_rect3 GDAPI godot_rect3_grow(const godot_rect3 *p_self, const godot_real p_by); - -godot_vector3 GDAPI godot_rect3_get_endpoint(const godot_rect3 *p_self, const godot_int p_idx); - -godot_bool GDAPI godot_rect3_operator_equal(const godot_rect3 *p_self, const godot_rect3 *p_b); - -#ifdef __cplusplus -} -#endif - -#endif // GODOT_RECT3_H diff --git a/modules/gdnative/include/gdnative/string.h b/modules/gdnative/include/gdnative/string.h index 29510313c9..cca3eb2672 100644 --- a/modules/gdnative/include/gdnative/string.h +++ b/modules/gdnative/include/gdnative/string.h @@ -51,6 +51,7 @@ typedef struct { } #endif +#include <gdnative/array.h> #include <gdnative/gdnative.h> #include <gdnative/variant.h> diff --git a/modules/gdnative/include/gdnative/transform.h b/modules/gdnative/include/gdnative/transform.h index 8f50b01fb5..3b5c189bdf 100644 --- a/modules/gdnative/include/gdnative/transform.h +++ b/modules/gdnative/include/gdnative/transform.h @@ -98,9 +98,9 @@ godot_vector3 GDAPI godot_transform_xform_vector3(const godot_transform *p_self, godot_vector3 GDAPI godot_transform_xform_inv_vector3(const godot_transform *p_self, const godot_vector3 *p_v); -godot_rect3 GDAPI godot_transform_xform_rect3(const godot_transform *p_self, const godot_rect3 *p_v); +godot_aabb GDAPI godot_transform_xform_aabb(const godot_transform *p_self, const godot_aabb *p_v); -godot_rect3 GDAPI godot_transform_xform_inv_rect3(const godot_transform *p_self, const godot_rect3 *p_v); +godot_aabb GDAPI godot_transform_xform_inv_aabb(const godot_transform *p_self, const godot_aabb *p_v); #ifdef __cplusplus } diff --git a/modules/gdnative/include/gdnative/variant.h b/modules/gdnative/include/gdnative/variant.h index 3d744ef1f2..06cafcfa63 100644 --- a/modules/gdnative/include/gdnative/variant.h +++ b/modules/gdnative/include/gdnative/variant.h @@ -62,7 +62,7 @@ typedef enum godot_variant_type { GODOT_VARIANT_TYPE_TRANSFORM2D, GODOT_VARIANT_TYPE_PLANE, GODOT_VARIANT_TYPE_QUAT, // 10 - GODOT_VARIANT_TYPE_RECT3, + GODOT_VARIANT_TYPE_AABB, GODOT_VARIANT_TYPE_BASIS, GODOT_VARIANT_TYPE_TRANSFORM, @@ -104,6 +104,7 @@ typedef struct godot_variant_call_error { } #endif +#include <gdnative/aabb.h> #include <gdnative/array.h> #include <gdnative/basis.h> #include <gdnative/color.h> @@ -113,7 +114,6 @@ typedef struct godot_variant_call_error { #include <gdnative/pool_arrays.h> #include <gdnative/quat.h> #include <gdnative/rect2.h> -#include <gdnative/rect3.h> #include <gdnative/rid.h> #include <gdnative/string.h> #include <gdnative/transform.h> @@ -145,7 +145,7 @@ void GDAPI godot_variant_new_vector3(godot_variant *r_dest, const godot_vector3 void GDAPI godot_variant_new_transform2d(godot_variant *r_dest, const godot_transform2d *p_t2d); void GDAPI godot_variant_new_plane(godot_variant *r_dest, const godot_plane *p_plane); void GDAPI godot_variant_new_quat(godot_variant *r_dest, const godot_quat *p_quat); -void GDAPI godot_variant_new_rect3(godot_variant *r_dest, const godot_rect3 *p_rect3); +void GDAPI godot_variant_new_aabb(godot_variant *r_dest, const godot_aabb *p_aabb); void GDAPI godot_variant_new_basis(godot_variant *r_dest, const godot_basis *p_basis); void GDAPI godot_variant_new_transform(godot_variant *r_dest, const godot_transform *p_trans); void GDAPI godot_variant_new_color(godot_variant *r_dest, const godot_color *p_color); @@ -173,7 +173,7 @@ godot_vector3 GDAPI godot_variant_as_vector3(const godot_variant *p_self); godot_transform2d GDAPI godot_variant_as_transform2d(const godot_variant *p_self); godot_plane GDAPI godot_variant_as_plane(const godot_variant *p_self); godot_quat GDAPI godot_variant_as_quat(const godot_variant *p_self); -godot_rect3 GDAPI godot_variant_as_rect3(const godot_variant *p_self); +godot_aabb GDAPI godot_variant_as_aabb(const godot_variant *p_self); godot_basis GDAPI godot_variant_as_basis(const godot_variant *p_self); godot_transform GDAPI godot_variant_as_transform(const godot_variant *p_self); godot_color GDAPI godot_variant_as_color(const godot_variant *p_self); diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index 63fb71feb6..f9d699fb59 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -32,9 +32,9 @@ #ifdef TOOLS_ENABLED #include "core/class_db.h" +#include "core/engine.h" #include "core/global_constants.h" #include "core/pair.h" -#include "core/project_settings.h" #include "os/file_access.h" // helper stuff @@ -177,7 +177,7 @@ List<ClassAPI> generate_c_api_classes() { if (name.begins_with("_")) { name.remove(0); } - class_api.is_singleton = ProjectSettings::get_singleton()->has_singleton(name); + class_api.is_singleton = Engine::get_singleton()->has_singleton(name); } class_api.is_instanciable = !class_api.is_singleton && ClassDB::can_instance(class_name); diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index c1df7def2e..c2c7c27f25 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -40,6 +40,8 @@ #include "scene/main/scene_tree.h" #include "scene/resources/scene_format_text.h" +#include <stdlib.h> + #ifndef NO_THREADS #include "os/thread.h" #endif @@ -52,7 +54,11 @@ #include "editor/editor_node.h" #endif -////// Script stuff +// +// +// Script stuff +// +// void NativeScript::_bind_methods() { ClassDB::bind_method(D_METHOD("set_class_name", "class_name"), &NativeScript::set_class_name); @@ -108,7 +114,7 @@ void NativeScript::set_library(Ref<GDNativeLibrary> p_library) { return; } library = p_library; - lib_path = library->get_active_library_path(); + lib_path = library->get_current_library_path(); #ifndef NO_THREADS if (Thread::get_caller_id() != Thread::get_main_id()) { @@ -414,7 +420,6 @@ Variant NativeScript::_new(const Variant **p_args, int p_argcount, Variant::Call } } -// TODO(karroffel): implement this NativeScript::NativeScript() { library = Ref<GDNative>(); lib_path = ""; @@ -424,7 +429,6 @@ NativeScript::NativeScript() { #endif } -// TODO(karroffel): implement this NativeScript::~NativeScript() { NSL->unregister_script(this); @@ -433,7 +437,11 @@ NativeScript::~NativeScript() { #endif } -////// ScriptInstance stuff +// +// +// ScriptInstance stuff +// +// #define GET_SCRIPT_DESC() script->get_script_desc() @@ -691,7 +699,6 @@ NativeScriptInstance::RPCMode NativeScriptInstance::get_rpc_mode(const StringNam return RPC_MODE_DISABLED; } -// TODO(karroffel): implement this NativeScriptInstance::RPCMode NativeScriptInstance::get_rset_mode(const StringName &p_variable) const { NativeScriptDesc *script_data = GET_SCRIPT_DESC(); @@ -774,15 +781,14 @@ NativeScriptInstance::~NativeScriptInstance() { } } -////// ScriptingLanguage stuff +// +// +// ScriptingLanguage stuff +// +// NativeScriptLanguage *NativeScriptLanguage::singleton; -extern "C" void _native_script_hook(); -void NativeScriptLanguage::_hacky_api_anchor() { - _native_script_hook(); -} - void NativeScriptLanguage::_unload_stuff() { for (Map<String, Map<StringName, NativeScriptDesc> >::Element *L = library_classes.front(); L; L = L->next()) { for (Map<StringName, NativeScriptDesc>::Element *C = L->get().front(); C; C = C->next()) { @@ -819,9 +825,7 @@ NativeScriptLanguage::NativeScriptLanguage() { #endif } -// TODO(karroffel): implement this NativeScriptLanguage::~NativeScriptLanguage() { - // _unload_stuff(); // NOTE(karroffel): This gets called in ::finish() for (Map<String, Ref<GDNative> >::Element *L = NSL->library_gdnatives.front(); L; L = L->next()) { @@ -847,7 +851,6 @@ void _add_reload_node() { #endif } -// TODO(karroffel): implement this void NativeScriptLanguage::init() { #if defined(TOOLS_ENABLED) && defined(DEBUG_METHODS_ENABLED) @@ -860,6 +863,7 @@ void NativeScriptLanguage::init() { if (generate_c_api(E->next()->get()) != OK) { ERR_PRINT("Failed to generate C API\n"); } + exit(0); } #endif @@ -886,11 +890,9 @@ void NativeScriptLanguage::get_comment_delimiters(List<String> *p_delimiters) co void NativeScriptLanguage::get_string_delimiters(List<String> *p_delimiters) const { } -// TODO(karroffel): implement this Ref<Script> NativeScriptLanguage::get_template(const String &p_class_name, const String &p_base_class_name) const { NativeScript *s = memnew(NativeScript); s->set_class_name(p_class_name); - // TODO(karroffel): use p_base_class_name return Ref<NativeScript>(s); } bool NativeScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const { @@ -988,7 +990,7 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) { MutexLock lock(mutex); #endif // See if this library was "registered" already. - const String &lib_path = lib->get_active_library_path(); + const String &lib_path = lib->get_current_library_path(); ERR_EXPLAIN(lib->get_name() + " does not have a library for the current platform"); ERR_FAIL_COND(lib_path.length() == 0); Map<String, Ref<GDNative> >::Element *E = library_gdnatives.find(lib_path); @@ -998,7 +1000,7 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) { gdn.instance(); gdn->set_library(lib); - // TODO(karroffel): check the return value? + // TODO check the return value? gdn->initialize(); library_gdnatives.insert(lib_path, gdn); @@ -1010,7 +1012,7 @@ void NativeScriptLanguage::init_library(const Ref<GDNativeLibrary> &lib) { void *proc_ptr; - Error err = gdn->get_symbol(_init_call_name, proc_ptr); + Error err = gdn->get_symbol(lib->get_symbol_prefix() + _init_call_name, proc_ptr); if (err != OK) { ERR_PRINT(String("No " + _init_call_name + " in \"" + lib_path + "\" found").utf8().get_data()); @@ -1051,7 +1053,7 @@ void NativeScriptLanguage::call_libraries_cb(const StringName &name) { if (L->get()->is_initialized()) { void *proc_ptr; - Error err = L->get()->get_symbol(name, proc_ptr); + Error err = L->get()->get_symbol(L->get()->get_library()->get_symbol_prefix() + name, proc_ptr); if (!err) { ((void (*)())proc_ptr)(); @@ -1140,7 +1142,7 @@ void NativeReloadNode::_notification(int p_what) { // here the library registers all the classes and stuff. void *proc_ptr; - Error err = L->get()->get_symbol("godot_nativescript_init", proc_ptr); + Error err = L->get()->get_symbol(L->get()->get_library()->get_symbol_prefix() + "nativescript_init", proc_ptr); if (err != OK) { ERR_PRINT(String("No godot_nativescript_init in \"" + L->key() + "\" found").utf8().get_data()); } else { diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index e8fc9e6880..f0f14e2f30 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -229,15 +229,15 @@ public: Map<String, Set<NativeScript *> > library_script_users; const StringName _init_call_type = "nativescript_init"; - const StringName _init_call_name = "godot_nativescript_init"; + const StringName _init_call_name = "nativescript_init"; const StringName _noarg_call_type = "nativescript_no_arg"; - const StringName _frame_call_name = "godot_nativescript_frame"; + const StringName _frame_call_name = "nativescript_frame"; #ifndef NO_THREADS - const StringName _thread_enter_call_name = "godot_nativescript_thread_enter"; - const StringName _thread_exit_call_name = "godot_nativescript_thread_exit"; + const StringName _thread_enter_call_name = "nativescript_thread_enter"; + const StringName _thread_exit_call_name = "nativescript_thread_exit"; #endif NativeScriptLanguage(); diff --git a/modules/gdnative/register_types.cpp b/modules/gdnative/register_types.cpp index 87f9cddaa2..8af643df50 100644 --- a/modules/gdnative/register_types.cpp +++ b/modules/gdnative/register_types.cpp @@ -35,7 +35,7 @@ #include "io/resource_loader.h" #include "io/resource_saver.h" -#include "nativearvr/register_types.h" +#include "arvr/register_types.h" #include "nativescript/register_types.h" #include "pluginscript/register_types.h" @@ -48,7 +48,7 @@ #include "gd_native_library_editor.h" // Class used to discover singleton gdnative files -void actual_discoverer_handler(); +static void actual_discoverer_handler(); class GDNativeSingletonDiscover : public Object { // GDCLASS(GDNativeSingletonDiscover, Object) @@ -66,7 +66,7 @@ class GDNativeSingletonDiscover : public Object { } }; -Set<String> get_gdnative_singletons(EditorFileSystemDirectory *p_dir) { +static Set<String> get_gdnative_singletons(EditorFileSystemDirectory *p_dir) { Set<String> file_paths; @@ -81,7 +81,7 @@ Set<String> get_gdnative_singletons(EditorFileSystemDirectory *p_dir) { } Ref<GDNativeLibrary> lib = ResourceLoader::load(p_dir->get_file_path(i)); - if (lib.is_valid() && lib->is_singleton_gdnative()) { + if (lib.is_valid() && lib->is_singleton()) { file_paths.insert(p_dir->get_file_path(i)); } } @@ -98,7 +98,7 @@ Set<String> get_gdnative_singletons(EditorFileSystemDirectory *p_dir) { return file_paths; } -void actual_discoverer_handler() { +static void actual_discoverer_handler() { EditorFileSystemDirectory *dir = EditorFileSystem::get_singleton()->get_filesystem(); Set<String> file_paths = get_gdnative_singletons(dir); @@ -115,7 +115,125 @@ void actual_discoverer_handler() { ProjectSettings::get_singleton()->save(); } -GDNativeSingletonDiscover *discoverer = NULL; +static GDNativeSingletonDiscover *discoverer = NULL; + +class GDNativeExportPlugin : public EditorExportPlugin { + +protected: + virtual void _export_file(const String &p_path, const String &p_type, const Set<String> &p_features); +}; + +void GDNativeExportPlugin::_export_file(const String &p_path, const String &p_type, const Set<String> &p_features) { + if (p_type != "GDNativeLibrary") { + return; + } + + Ref<GDNativeLibrary> lib = ResourceLoader::load(p_path); + + if (lib.is_null()) { + return; + } + + Ref<ConfigFile> config = lib->get_config_file(); + + String entry_lib_path; + { + + List<String> entry_keys; + config->get_section_keys("entry", &entry_keys); + + for (List<String>::Element *E = entry_keys.front(); E; E = E->next()) { + String key = E->get(); + + Vector<String> tags = key.split("."); + + bool skip = false; + for (int i = 0; i < tags.size(); i++) { + bool has_feature = p_features.has(tags[i]); + + if (!has_feature) { + skip = true; + break; + } + } + + if (skip) { + continue; + } + + entry_lib_path = config->get_value("entry", key); + break; + } + } + + Vector<String> dependency_paths; + { + + List<String> dependency_keys; + config->get_section_keys("dependencies", &dependency_keys); + + for (List<String>::Element *E = dependency_keys.front(); E; E = E->next()) { + String key = E->get(); + + Vector<String> tags = key.split("."); + + bool skip = false; + for (int i = 0; i < tags.size(); i++) { + bool has_feature = p_features.has(tags[i]); + + if (!has_feature) { + skip = true; + break; + } + } + + if (skip) { + continue; + } + + dependency_paths = config->get_value("dependencies", key); + break; + } + } + + bool is_statically_linked = false; + { + + List<String> static_linking_keys; + config->get_section_keys("static_linking", &static_linking_keys); + + for (List<String>::Element *E = static_linking_keys.front(); E; E = E->next()) { + String key = E->get(); + + Vector<String> tags = key.split("."); + + bool skip = false; + + for (int i = 0; i < tags.size(); i++) { + bool has_feature = p_features.has(tags[i]); + + if (!has_feature) { + skip = true; + break; + } + } + + if (skip) { + continue; + } + + is_statically_linked = config->get_value("static_linking", key); + break; + } + } + + if (!is_statically_linked) + add_shared_object(entry_lib_path); + + for (int i = 0; i < dependency_paths.size(); i++) { + add_shared_object(dependency_paths[i]); + } +} static void editor_init_callback() { @@ -125,11 +243,16 @@ static void editor_init_callback() { discoverer = memnew(GDNativeSingletonDiscover); EditorFileSystem::get_singleton()->connect("filesystem_changed", discoverer, "get_class"); + + Ref<GDNativeExportPlugin> export_plugin; + export_plugin.instance(); + + EditorExport::get_singleton()->add_export_plugin(export_plugin); } #endif -godot_variant cb_standard_varcall(void *p_procedure_handle, godot_array *p_args) { +static godot_variant cb_standard_varcall(void *p_procedure_handle, godot_array *p_args) { godot_gdnative_procedure_fn proc; proc = (godot_gdnative_procedure_fn)p_procedure_handle; @@ -141,6 +264,9 @@ GDNativeCallRegistry *GDNativeCallRegistry::singleton; Vector<Ref<GDNative> > singleton_gdnatives; +GDNativeLibraryResourceLoader *resource_loader_gdnlib = NULL; +GDNativeLibraryResourceSaver *resource_saver_gdnlib = NULL; + void register_gdnative_types() { #ifdef TOOLS_ENABLED @@ -153,11 +279,17 @@ void register_gdnative_types() { ClassDB::register_class<GDNativeLibrary>(); ClassDB::register_class<GDNative>(); + resource_loader_gdnlib = memnew(GDNativeLibraryResourceLoader); + resource_saver_gdnlib = memnew(GDNativeLibraryResourceSaver); + + ResourceLoader::add_resource_format_loader(resource_loader_gdnlib); + ResourceSaver::add_resource_format_saver(resource_saver_gdnlib); + GDNativeCallRegistry::singleton = memnew(GDNativeCallRegistry); GDNativeCallRegistry::singleton->register_native_call_type("standard_varcall", cb_standard_varcall); - register_nativearvr_types(); + register_arvr_types(); register_nativescript_types(); register_pluginscript_types(); @@ -185,11 +317,11 @@ void register_gdnative_types() { void *proc_ptr; Error err = singleton_gdnatives[i]->get_symbol( - "godot_gdnative_singleton", + lib->get_symbol_prefix() + "gdnative_singleton", proc_ptr); if (err != OK) { - ERR_PRINT((String("No godot_gdnative_singleton in \"" + singleton_gdnatives[i]->get_library()->get_active_library_path()) + "\" found").utf8().get_data()); + ERR_PRINT((String("No godot_gdnative_singleton in \"" + singleton_gdnatives[i]->get_library()->get_current_library_path()) + "\" found").utf8().get_data()); } else { ((void (*)())proc_ptr)(); } @@ -214,7 +346,7 @@ void unregister_gdnative_types() { unregister_pluginscript_types(); unregister_nativescript_types(); - unregister_nativearvr_types(); + unregister_arvr_types(); memdelete(GDNativeCallRegistry::singleton); @@ -224,6 +356,9 @@ void unregister_gdnative_types() { } #endif + memdelete(resource_loader_gdnlib); + memdelete(resource_saver_gdnlib); + // This is for printing out the sizes of the core types /* @@ -236,7 +371,7 @@ void unregister_gdnative_types() { print_line(String("poolarray:\t") + itos(sizeof(PoolByteArray))); print_line(String("quat:\t") + itos(sizeof(Quat))); print_line(String("rect2:\t") + itos(sizeof(Rect2))); - print_line(String("rect3:\t") + itos(sizeof(Rect3))); + print_line(String("aabb:\t") + itos(sizeof(AABB))); print_line(String("rid:\t") + itos(sizeof(RID))); print_line(String("string:\t") + itos(sizeof(String))); print_line(String("transform:\t") + itos(sizeof(Transform))); diff --git a/modules/gdscript/config.py b/modules/gdscript/config.py index 5698a37295..6496b59d75 100644 --- a/modules/gdscript/config.py +++ b/modules/gdscript/config.py @@ -1,8 +1,15 @@ - - def can_build(platform): return True - def configure(env): pass + +def get_doc_classes(): + return [ + "GDScript", + "GDScriptFunctionState", + "GDScriptNativeClass", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/doc/classes/GDScript.xml b/modules/gdscript/doc_classes/GDScript.xml index 2faa0ff968..13d45aa520 100644 --- a/doc/classes/GDScript.xml +++ b/modules/gdscript/doc_classes/GDScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GDScript" inherits="Script" category="Core" version="3.0.alpha.custom_build"> +<class name="GDScript" inherits="Script" category="Core" version="3.0-alpha"> <brief_description> A script implemented in the GDScript programming language. </brief_description> diff --git a/doc/classes/GDFunctionState.xml b/modules/gdscript/doc_classes/GDScriptFunctionState.xml index 801ca718e7..2df4e7c217 100644 --- a/doc/classes/GDFunctionState.xml +++ b/modules/gdscript/doc_classes/GDScriptFunctionState.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GDFunctionState" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="GDScriptFunctionState" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> State of a function call after yielding. </brief_description> @@ -18,7 +18,7 @@ </argument> <description> Check whether the function call may be resumed. This is not the case if the function state was already resumed. - If [code]extended_check[/code] is enabled, it also checks if the associated script and object still exist. The extended check is done in debug mode as part of [method GDFunctionState.resume], but you can use this if you know you may be trying to resume without knowing for sure the object and/or script have survived up to that point. + If [code]extended_check[/code] is enabled, it also checks if the associated script and object still exist. The extended check is done in debug mode as part of [method GDScriptFunctionState.resume], but you can use this if you know you may be trying to resume without knowing for sure the object and/or script have survived up to that point. </description> </method> <method name="resume"> diff --git a/doc/classes/GDNativeClass.xml b/modules/gdscript/doc_classes/GDScriptNativeClass.xml index 5a3f353720..4514a78469 100644 --- a/doc/classes/GDNativeClass.xml +++ b/modules/gdscript/doc_classes/GDScriptNativeClass.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GDNativeClass" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="GDScriptNativeClass" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/modules/gdscript/gd_script.cpp b/modules/gdscript/gdscript.cpp index 3f3818ffb9..55ea8a5f24 100644 --- a/modules/gdscript/gd_script.cpp +++ b/modules/gdscript/gdscript.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_script.cpp */ +/* gdscript.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,9 +27,10 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "gd_script.h" +#include "gdscript.h" -#include "gd_compiler.h" +#include "engine.h" +#include "gdscript_compiler.h" #include "global_constants.h" #include "io/file_access_encrypted.h" #include "os/file_access.h" @@ -38,12 +39,12 @@ /////////////////////////// -GDNativeClass::GDNativeClass(const StringName &p_name) { +GDScriptNativeClass::GDScriptNativeClass(const StringName &p_name) { name = p_name; } -bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const { +bool GDScriptNativeClass::_get(const StringName &p_name, Variant &r_ret) const { bool ok; int v = ClassDB::get_integer_constant(name, p_name, &ok); @@ -56,12 +57,12 @@ bool GDNativeClass::_get(const StringName &p_name, Variant &r_ret) const { } } -void GDNativeClass::_bind_methods() { +void GDScriptNativeClass::_bind_methods() { - ClassDB::bind_method(D_METHOD("new"), &GDNativeClass::_new); + ClassDB::bind_method(D_METHOD("new"), &GDScriptNativeClass::_new); } -Variant GDNativeClass::_new() { +Variant GDScriptNativeClass::_new() { Object *o = instance(); if (!o) { @@ -77,16 +78,16 @@ Variant GDNativeClass::_new() { } } -Object *GDNativeClass::instance() { +Object *GDScriptNativeClass::instance() { return ClassDB::instance(name); } -GDInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error) { +GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error) { /* STEP 1, CREATE */ - GDInstance *instance = memnew(GDInstance); + GDScriptInstance *instance = memnew(GDScriptInstance); instance->base_ref = p_isref; instance->members.resize(member_indices.size()); instance->script = Ref<GDScript>(this); @@ -162,7 +163,7 @@ Variant GDScript::_new(const Variant **p_args, int p_argcount, Variant::CallErro ref = REF(r); } - GDInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error); + GDScriptInstance *instance = _create_instance(p_args, p_argcount, owner, r != NULL, r_error); if (!instance) { if (ref.is_null()) { memdelete(owner); //no owner, sorry @@ -217,7 +218,7 @@ void GDScript::_placeholder_erased(PlaceHolderScriptInstance *p_placeholder) { void GDScript::get_script_method_list(List<MethodInfo> *p_list) const { - for (const Map<StringName, GDFunction *>::Element *E = member_functions.front(); E; E = E->next()) { + for (const Map<StringName, GDScriptFunction *>::Element *E = member_functions.front(); E; E = E->next()) { MethodInfo mi; mi.name = E->key(); for (int i = 0; i < E->get()->get_argument_count(); i++) { @@ -271,7 +272,7 @@ bool GDScript::has_method(const StringName &p_method) const { MethodInfo GDScript::get_method_info(const StringName &p_method) const { - const Map<StringName, GDFunction *>::Element *E = member_functions.find(p_method); + const Map<StringName, GDScriptFunction *>::Element *E = member_functions.find(p_method); if (!E) return MethodInfo(); @@ -419,15 +420,15 @@ bool GDScript::_update_exports() { if (basedir != "") basedir = basedir.get_base_dir(); - GDParser parser; + GDScriptParser parser; Error err = parser.parse(source, basedir, true, path); if (err == OK) { - const GDParser::Node *root = parser.get_parse_tree(); - ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, false); + const GDScriptParser::Node *root = parser.get_parse_tree(); + ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, false); - const GDParser::ClassNode *c = static_cast<const GDParser::ClassNode *>(root); + const GDScriptParser::ClassNode *c = static_cast<const GDScriptParser::ClassNode *>(root); if (base_cache.is_valid()) { base_cache->inheriters_cache.erase(get_instance_id()); @@ -571,7 +572,7 @@ Error GDScript::reload(bool p_keep_state) { } valid = false; - GDParser parser; + GDScriptParser parser; Error err = parser.parse(source, basedir, false, path); if (err) { if (ScriptDebugger::get_singleton()) { @@ -583,7 +584,7 @@ Error GDScript::reload(bool p_keep_state) { bool can_run = ScriptServer::is_scripting_enabled() || parser.is_tool_script(); - GDCompiler compiler; + GDScriptCompiler compiler; err = compiler.compile(&parser, this, p_keep_state); if (err) { @@ -619,7 +620,7 @@ Variant GDScript::call(const StringName &p_method, const Variant **p_args, int p GDScript *top = this; while (top) { - Map<StringName, GDFunction *>::Element *E = top->member_functions.find(p_method); + Map<StringName, GDScriptFunction *>::Element *E = top->member_functions.find(p_method); if (E) { if (!E->get()->is_static()) { @@ -698,7 +699,7 @@ void GDScript::_bind_methods() { Vector<uint8_t> GDScript::get_as_byte_code() const { - GDTokenizerBuffer tokenizer; + GDScriptTokenizerBuffer tokenizer; return tokenizer.parse_code_string(source); }; @@ -738,14 +739,14 @@ Error GDScript::load_byte_code(const String &p_path) { basedir = basedir.get_base_dir(); valid = false; - GDParser parser; + GDScriptParser parser; Error err = parser.parse_bytecode(bytecode, basedir, get_path()); if (err) { _err_print_error("GDScript::load_byte_code", path.empty() ? "built-in" : (const char *)path.utf8().get_data(), parser.get_error_line(), ("Parse Error: " + parser.get_error()).utf8().get_data(), ERR_HANDLER_SCRIPT); ERR_FAIL_V(ERR_PARSE_ERROR); } - GDCompiler compiler; + GDScriptCompiler compiler; err = compiler.compile(&parser, this); if (err) { @@ -798,7 +799,7 @@ Error GDScript::load_source_code(const String &p_path) { return OK; } -const Map<StringName, GDFunction *> &GDScript::debug_get_member_functions() const { +const Map<StringName, GDScriptFunction *> &GDScript::debug_get_member_functions() const { return member_functions; } @@ -885,7 +886,7 @@ GDScript::GDScript() } GDScript::~GDScript() { - for (Map<StringName, GDFunction *>::Element *E = member_functions.front(); E; E = E->next()) { + for (Map<StringName, GDScriptFunction *>::Element *E = member_functions.front(); E; E = E->next()) { memdelete(E->get()); } @@ -909,7 +910,7 @@ GDScript::~GDScript() { // INSTANCE // ////////////////////////////// -bool GDInstance::set(const StringName &p_name, const Variant &p_value) { +bool GDScriptInstance::set(const StringName &p_name, const Variant &p_value) { //member { @@ -931,7 +932,7 @@ bool GDInstance::set(const StringName &p_name, const Variant &p_value) { GDScript *sptr = script.ptr(); while (sptr) { - Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._set); + Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._set); if (E) { Variant name = p_name; @@ -948,7 +949,7 @@ bool GDInstance::set(const StringName &p_name, const Variant &p_value) { return false; } -bool GDInstance::get(const StringName &p_name, Variant &r_ret) const { +bool GDScriptInstance::get(const StringName &p_name, Variant &r_ret) const { const GDScript *sptr = script.ptr(); while (sptr) { @@ -958,7 +959,7 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const { if (E) { if (E->get().getter) { Variant::CallError err; - r_ret = const_cast<GDInstance *>(this)->call(E->get().getter, NULL, 0, err); + r_ret = const_cast<GDScriptInstance *>(this)->call(E->get().getter, NULL, 0, err); if (err.error == Variant::CallError::CALL_OK) { return true; } @@ -982,14 +983,14 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const { } { - const Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get); + const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get); if (E) { Variant name = p_name; const Variant *args[1] = { &name }; Variant::CallError err; - Variant ret = const_cast<GDFunction *>(E->get())->call(const_cast<GDInstance *>(this), (const Variant **)args, 1, err); + Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), (const Variant **)args, 1, err); if (err.error == Variant::CallError::CALL_OK && ret.get_type() != Variant::NIL) { r_ret = ret; return true; @@ -1002,7 +1003,7 @@ bool GDInstance::get(const StringName &p_name, Variant &r_ret) const { return false; } -Variant::Type GDInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const { +Variant::Type GDScriptInstance::get_property_type(const StringName &p_name, bool *r_is_valid) const { const GDScript *sptr = script.ptr(); while (sptr) { @@ -1020,7 +1021,7 @@ Variant::Type GDInstance::get_property_type(const StringName &p_name, bool *r_is return Variant::NIL; } -void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const { +void GDScriptInstance::get_property_list(List<PropertyInfo> *p_properties) const { // exported members, not doen yet! const GDScript *sptr = script.ptr(); @@ -1028,11 +1029,11 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const { while (sptr) { - const Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list); + const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._get_property_list); if (E) { Variant::CallError err; - Variant ret = const_cast<GDFunction *>(E->get())->call(const_cast<GDInstance *>(this), NULL, 0, err); + Variant ret = const_cast<GDScriptFunction *>(E->get())->call(const_cast<GDScriptInstance *>(this), NULL, 0, err); if (err.error == Variant::CallError::CALL_OK) { if (ret.get_type() != Variant::ARRAY) { @@ -1091,12 +1092,12 @@ void GDInstance::get_property_list(List<PropertyInfo> *p_properties) const { } } -void GDInstance::get_method_list(List<MethodInfo> *p_list) const { +void GDScriptInstance::get_method_list(List<MethodInfo> *p_list) const { const GDScript *sptr = script.ptr(); while (sptr) { - for (Map<StringName, GDFunction *>::Element *E = sptr->member_functions.front(); E; E = E->next()) { + for (Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.front(); E; E = E->next()) { MethodInfo mi; mi.name = E->key(); @@ -1109,11 +1110,11 @@ void GDInstance::get_method_list(List<MethodInfo> *p_list) const { } } -bool GDInstance::has_method(const StringName &p_method) const { +bool GDScriptInstance::has_method(const StringName &p_method) const { const GDScript *sptr = script.ptr(); while (sptr) { - const Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method); + const Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method); if (E) return true; sptr = sptr->_base; @@ -1121,13 +1122,13 @@ bool GDInstance::has_method(const StringName &p_method) const { return false; } -Variant GDInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { +Variant GDScriptInstance::call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) { //printf("calling %ls:%i method %ls\n", script->get_path().c_str(), -1, String(p_method).c_str()); GDScript *sptr = script.ptr(); while (sptr) { - Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method); + Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method); if (E) { return E->get()->call(this, p_args, p_argcount, r_error); } @@ -1137,13 +1138,13 @@ Variant GDInstance::call(const StringName &p_method, const Variant **p_args, int return Variant(); } -void GDInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) { +void GDScriptInstance::call_multilevel(const StringName &p_method, const Variant **p_args, int p_argcount) { GDScript *sptr = script.ptr(); Variant::CallError ce; while (sptr) { - Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method); + Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method); if (E) { E->get()->call(this, p_args, p_argcount, ce); } @@ -1151,27 +1152,27 @@ void GDInstance::call_multilevel(const StringName &p_method, const Variant **p_a } } -void GDInstance::_ml_call_reversed(GDScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount) { +void GDScriptInstance::_ml_call_reversed(GDScript *sptr, const StringName &p_method, const Variant **p_args, int p_argcount) { if (sptr->_base) _ml_call_reversed(sptr->_base, p_method, p_args, p_argcount); Variant::CallError ce; - Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(p_method); + Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(p_method); if (E) { E->get()->call(this, p_args, p_argcount, ce); } } -void GDInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) { +void GDScriptInstance::call_multilevel_reversed(const StringName &p_method, const Variant **p_args, int p_argcount) { if (script.ptr()) { _ml_call_reversed(script.ptr(), p_method, p_args, p_argcount); } } -void GDInstance::notification(int p_notification) { +void GDScriptInstance::notification(int p_notification) { //notification is not virtual, it gets called at ALL levels just like in C. Variant value = p_notification; @@ -1179,7 +1180,7 @@ void GDInstance::notification(int p_notification) { GDScript *sptr = script.ptr(); while (sptr) { - Map<StringName, GDFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification); + Map<StringName, GDScriptFunction *>::Element *E = sptr->member_functions.find(GDScriptLanguage::get_singleton()->strings._notification); if (E) { Variant::CallError err; E->get()->call(this, args, 1, err); @@ -1191,22 +1192,22 @@ void GDInstance::notification(int p_notification) { } } -Ref<Script> GDInstance::get_script() const { +Ref<Script> GDScriptInstance::get_script() const { return script; } -ScriptLanguage *GDInstance::get_language() { +ScriptLanguage *GDScriptInstance::get_language() { return GDScriptLanguage::get_singleton(); } -GDInstance::RPCMode GDInstance::get_rpc_mode(const StringName &p_method) const { +GDScriptInstance::RPCMode GDScriptInstance::get_rpc_mode(const StringName &p_method) const { const GDScript *cscript = script.ptr(); while (cscript) { - const Map<StringName, GDFunction *>::Element *E = cscript->member_functions.find(p_method); + const Map<StringName, GDScriptFunction *>::Element *E = cscript->member_functions.find(p_method); if (E) { if (E->get()->get_rpc_mode() != RPC_MODE_DISABLED) { @@ -1219,7 +1220,7 @@ GDInstance::RPCMode GDInstance::get_rpc_mode(const StringName &p_method) const { return RPC_MODE_DISABLED; } -GDInstance::RPCMode GDInstance::get_rset_mode(const StringName &p_variable) const { +GDScriptInstance::RPCMode GDScriptInstance::get_rset_mode(const StringName &p_variable) const { const GDScript *cscript = script.ptr(); @@ -1237,7 +1238,7 @@ GDInstance::RPCMode GDInstance::get_rset_mode(const StringName &p_variable) cons return RPC_MODE_DISABLED; } -void GDInstance::reload_members() { +void GDScriptInstance::reload_members() { #ifdef DEBUG_ENABLED @@ -1268,12 +1269,12 @@ void GDInstance::reload_members() { #endif } -GDInstance::GDInstance() { +GDScriptInstance::GDScriptInstance() { owner = NULL; base_ref = false; } -GDInstance::~GDInstance() { +GDScriptInstance::~GDScriptInstance() { if (script.is_valid() && owner) { #ifndef NO_THREADS GDScriptLanguage::singleton->lock->lock(); @@ -1324,6 +1325,7 @@ void GDScriptLanguage::init() { } _add_global(StaticCString::create("PI"), Math_PI); + _add_global(StaticCString::create("TAU"), Math_TAU); _add_global(StaticCString::create("INF"), Math_INF); _add_global(StaticCString::create("NAN"), Math_NAN); @@ -1340,15 +1342,15 @@ void GDScriptLanguage::init() { if (globals.has(n)) continue; - Ref<GDNativeClass> nc = memnew(GDNativeClass(E->get())); + Ref<GDScriptNativeClass> nc = memnew(GDScriptNativeClass(E->get())); _add_global(n, nc); } //populate singletons - List<ProjectSettings::Singleton> singletons; - ProjectSettings::get_singleton()->get_singletons(&singletons); - for (List<ProjectSettings::Singleton>::Element *E = singletons.front(); E; E = E->next()) { + List<Engine::Singleton> singletons; + Engine::get_singleton()->get_singletons(&singletons); + for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { _add_global(E->get().name, E->get().ptr); } @@ -1377,7 +1379,7 @@ void GDScriptLanguage::profiling_start() { lock->lock(); } - SelfList<GDFunction> *elem = function_list.first(); + SelfList<GDScriptFunction> *elem = function_list.first(); while (elem) { elem->self()->profile.call_count = 0; elem->self()->profile.self_time = 0; @@ -1422,7 +1424,7 @@ int GDScriptLanguage::profiling_get_accumulated_data(ProfilingInfo *p_info_arr, lock->lock(); } - SelfList<GDFunction> *elem = function_list.first(); + SelfList<GDScriptFunction> *elem = function_list.first(); while (elem) { if (current >= p_info_max) break; @@ -1452,7 +1454,7 @@ int GDScriptLanguage::profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_ lock->lock(); } - SelfList<GDFunction> *elem = function_list.first(); + SelfList<GDScriptFunction> *elem = function_list.first(); while (elem) { if (current >= p_info_max) break; @@ -1597,17 +1599,18 @@ void GDScriptLanguage::reload_tool_script(const Ref<Script> &p_script, bool p_so Object *obj = E->get()->placeholders.front()->get()->get_owner(); //save instance info - List<Pair<StringName, Variant> > state; if (obj->get_script_instance()) { + map.insert(obj->get_instance_id(), List<Pair<StringName, Variant> >()); + List<Pair<StringName, Variant> > &state = map[obj->get_instance_id()]; obj->get_script_instance()->get_property_state(state); - map[obj->get_instance_id()] = state; obj->set_script(RefPtr()); } else { // no instance found. Let's remove it so we don't loop forever E->get()->placeholders.erase(E->get()->placeholders.front()->get()); } } + #endif for (Map<ObjectID, List<Pair<StringName, Variant> > >::Element *F = E->get()->pending_reload_state.front(); F; F = F->next()) { @@ -1665,7 +1668,7 @@ void GDScriptLanguage::frame() { lock->lock(); } - SelfList<GDFunction> *elem = function_list.first(); + SelfList<GDScriptFunction> *elem = function_list.first(); while (elem) { elem->self()->profile.last_frame_call_count = elem->self()->profile.frame_call_count; elem->self()->profile.last_frame_self_time = elem->self()->profile.frame_self_time; @@ -1700,6 +1703,7 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const { "bool", "null", "PI", + "TAU", "INF", "NAN", "self", @@ -1749,8 +1753,8 @@ void GDScriptLanguage::get_reserved_words(List<String> *p_words) const { w++; } - for (int i = 0; i < GDFunctions::FUNC_MAX; i++) { - p_words->push_back(GDFunctions::get_func_name(GDFunctions::Function(i))); + for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) { + p_words->push_back(GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i))); } } diff --git a/modules/gdscript/gd_script.h b/modules/gdscript/gdscript.h index e0d142014a..3f6f431938 100644 --- a/modules/gdscript/gd_script.h +++ b/modules/gdscript/gdscript.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_script.h */ +/* gdscript.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,16 +27,17 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GD_SCRIPT_H -#define GD_SCRIPT_H +#ifndef GDSCRIPT_H +#define GDSCRIPT_H -#include "gd_function.h" +#include "gdscript_function.h" #include "io/resource_loader.h" #include "io/resource_saver.h" #include "script_language.h" -class GDNativeClass : public Reference { - GDCLASS(GDNativeClass, Reference); +class GDScriptNativeClass : public Reference { + + GDCLASS(GDScriptNativeClass, Reference); StringName name; @@ -48,7 +49,7 @@ public: _FORCE_INLINE_ const StringName &get_name() const { return name; } Variant _new(); Object *instance(); - GDNativeClass(const StringName &p_name); + GDScriptNativeClass(const StringName &p_name); }; class GDScript : public Script { @@ -64,21 +65,21 @@ class GDScript : public Script { ScriptInstance::RPCMode rpc_mode; }; - friend class GDInstance; - friend class GDFunction; - friend class GDCompiler; - friend class GDFunctions; + friend class GDScriptInstance; + friend class GDScriptFunction; + friend class GDScriptCompiler; + friend class GDScriptFunctions; friend class GDScriptLanguage; Variant _static_ref; //used for static call - Ref<GDNativeClass> native; + Ref<GDScriptNativeClass> native; Ref<GDScript> base; GDScript *_base; //fast pointer access GDScript *_owner; //for subclasses Set<StringName> members; //members are just indices to the instanced script. Map<StringName, Variant> constants; - Map<StringName, GDFunction *> member_functions; + Map<StringName, GDScriptFunction *> member_functions; Map<StringName, MemberInfo> member_indices; //members are just indices to the instanced script. Map<StringName, Ref<GDScript> > subclasses; Map<StringName, Vector<StringName> > _signals; @@ -99,7 +100,7 @@ class GDScript : public Script { #endif Map<StringName, PropertyInfo> member_info; - GDFunction *initializer; //direct pointer to _init , faster to locate + GDScriptFunction *initializer; //direct pointer to _init , faster to locate int subclass_count; Set<Object *> instances; @@ -109,7 +110,7 @@ class GDScript : public Script { String name; SelfList<GDScript> script_list; - GDInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error); + GDScriptInstance *_create_instance(const Variant **p_args, int p_argcount, Object *p_owner, bool p_isref, Variant::CallError &r_error); void _set_subclass_path(Ref<GDScript> &p_sc, const String &p_path); @@ -143,8 +144,8 @@ public: const Map<StringName, Ref<GDScript> > &get_subclasses() const { return subclasses; } const Map<StringName, Variant> &get_constants() const { return constants; } const Set<StringName> &get_members() const { return members; } - const Map<StringName, GDFunction *> &get_member_functions() const { return member_functions; } - const Ref<GDNativeClass> &get_native() const { return native; } + const Map<StringName, GDScriptFunction *> &get_member_functions() const { return member_functions; } + const Ref<GDScriptNativeClass> &get_native() const { return native; } virtual bool has_script_signal(const StringName &p_signal) const; virtual void get_script_signal_list(List<MethodInfo> *r_signals) const; @@ -153,7 +154,7 @@ public: Ref<GDScript> get_base() const; const Map<StringName, MemberInfo> &debug_get_member_indices() const { return member_indices; } - const Map<StringName, GDFunction *> &debug_get_member_functions() const; //this is debug only + const Map<StringName, GDScriptFunction *> &debug_get_member_functions() const; //this is debug only StringName debug_get_member_by_index(int p_idx) const; Variant _new(const Variant **p_args, int p_argcount, Variant::CallError &r_error); @@ -201,11 +202,11 @@ public: ~GDScript(); }; -class GDInstance : public ScriptInstance { +class GDScriptInstance : public ScriptInstance { friend class GDScript; - friend class GDFunction; - friend class GDFunctions; - friend class GDCompiler; + friend class GDScriptFunction; + friend class GDScriptFunctions; + friend class GDScriptCompiler; Object *owner; Ref<GDScript> script; @@ -246,8 +247,8 @@ public: virtual RPCMode get_rpc_mode(const StringName &p_method) const; virtual RPCMode get_rset_mode(const StringName &p_variable) const; - GDInstance(); - ~GDInstance(); + GDScriptInstance(); + ~GDScriptInstance(); }; class GDScriptLanguage : public ScriptLanguage { @@ -261,8 +262,8 @@ class GDScriptLanguage : public ScriptLanguage { struct CallLevel { Variant *stack; - GDFunction *function; - GDInstance *instance; + GDScriptFunction *function; + GDScriptInstance *instance; int *ip; int *line; }; @@ -276,16 +277,16 @@ class GDScriptLanguage : public ScriptLanguage { void _add_global(const StringName &p_name, const Variant &p_value); - friend class GDInstance; + friend class GDScriptInstance; Mutex *lock; friend class GDScript; SelfList<GDScript>::List script_list; - friend class GDFunction; + friend class GDScriptFunction; - SelfList<GDFunction>::List function_list; + SelfList<GDScriptFunction>::List function_list; bool profiling; uint64_t script_frame_time; @@ -295,7 +296,7 @@ public: bool debug_break(const String &p_error, bool p_allow_continue = true); bool debug_break_parse(const String &p_file, int p_line, const String &p_error); - _FORCE_INLINE_ void enter_function(GDInstance *p_instance, GDFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) { + _FORCE_INLINE_ void enter_function(GDScriptInstance *p_instance, GDScriptFunction *p_function, Variant *p_stack, int *p_ip, int *p_line) { if (Thread::get_main_id() != Thread::get_caller_id()) return; //no support for other threads than main for now @@ -446,4 +447,4 @@ public: virtual bool recognize(const RES &p_resource) const; }; -#endif // GD_SCRIPT_H +#endif // GDSCRIPT_H diff --git a/modules/gdscript/gd_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 7036a708e5..3121a61436 100644 --- a/modules/gdscript/gd_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_compiler.cpp */ +/* gdscript_compiler.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,10 +27,11 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "gd_compiler.h" -#include "gd_script.h" +#include "gdscript_compiler.h" -bool GDCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p_name) { +#include "gdscript.h" + +bool GDScriptCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p_name) { if (!codegen.function_node || codegen.function_node->_static) return false; @@ -38,10 +39,10 @@ bool GDCompiler::_is_class_member_property(CodeGen &codegen, const StringName &p return _is_class_member_property(codegen.script, p_name); } -bool GDCompiler::_is_class_member_property(GDScript *owner, const StringName &p_name) { +bool GDScriptCompiler::_is_class_member_property(GDScript *owner, const StringName &p_name) { GDScript *scr = owner; - GDNativeClass *nc = NULL; + GDScriptNativeClass *nc = NULL; while (scr) { if (scr->native.is_valid()) @@ -54,7 +55,7 @@ bool GDCompiler::_is_class_member_property(GDScript *owner, const StringName &p_ return ClassDB::has_property(nc->get_name(), p_name); } -void GDCompiler::_set_error(const String &p_error, const GDParser::Node *p_node) { +void GDScriptCompiler::_set_error(const String &p_error, const GDScriptParser::Node *p_node) { if (error != "") return; @@ -69,7 +70,7 @@ void GDCompiler::_set_error(const String &p_error, const GDParser::Node *p_node) } } -bool GDCompiler::_create_unary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level) { +bool GDScriptCompiler::_create_unary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level) { ERR_FAIL_COND_V(on->arguments.size() != 1, false); @@ -77,29 +78,29 @@ bool GDCompiler::_create_unary_operator(CodeGen &codegen, const GDParser::Operat if (src_address_a < 0) return false; - codegen.opcodes.push_back(GDFunction::OPCODE_OPERATOR); // perform operator + codegen.opcodes.push_back(GDScriptFunction::OPCODE_OPERATOR); // perform operator codegen.opcodes.push_back(op); //which operator codegen.opcodes.push_back(src_address_a); // argument 1 codegen.opcodes.push_back(src_address_a); // argument 2 (repeated) - //codegen.opcodes.push_back(GDFunction::ADDR_TYPE_NIL); // argument 2 (unary only takes one parameter) + //codegen.opcodes.push_back(GDScriptFunction::ADDR_TYPE_NIL); // argument 2 (unary only takes one parameter) return true; } -bool GDCompiler::_create_binary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer) { +bool GDScriptCompiler::_create_binary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer) { ERR_FAIL_COND_V(on->arguments.size() != 2, false); int src_address_a = _parse_expression(codegen, on->arguments[0], p_stack_level, false, p_initializer); if (src_address_a < 0) return false; - if (src_address_a & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) + if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) p_stack_level++; //uses stack for return, increase stack int src_address_b = _parse_expression(codegen, on->arguments[1], p_stack_level, false, p_initializer); if (src_address_b < 0) return false; - codegen.opcodes.push_back(GDFunction::OPCODE_OPERATOR); // perform operator + codegen.opcodes.push_back(GDScriptFunction::OPCODE_OPERATOR); // perform operator codegen.opcodes.push_back(op); //which operator codegen.opcodes.push_back(src_address_a); // argument 1 codegen.opcodes.push_back(src_address_b); // argument 2 (unary only takes one parameter) @@ -107,14 +108,14 @@ bool GDCompiler::_create_binary_operator(CodeGen &codegen, const GDParser::Opera } /* -int GDCompiler::_parse_subexpression(CodeGen& codegen,const GDParser::Node *p_expression) { +int GDScriptCompiler::_parse_subexpression(CodeGen& codegen,const GDScriptParser::Node *p_expression) { int ret = _parse_expression(codegen,p_expression); if (ret<0) return ret; - if (ret&(GDFunction::ADDR_TYPE_STACK<<GDFunction::ADDR_BITS)) { + if (ret&(GDScriptFunction::ADDR_TYPE_STACK<<GDScriptFunction::ADDR_BITS)) { codegen.stack_level++; codegen.check_max_stack_level(); //stack was used, keep value @@ -124,24 +125,24 @@ int GDCompiler::_parse_subexpression(CodeGen& codegen,const GDParser::Node *p_ex } */ -int GDCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDParser::OperatorNode *p_expression, int p_stack_level) { +int GDScriptCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level) { Variant::Operator var_op = Variant::OP_MAX; switch (p_expression->op) { - case GDParser::OperatorNode::OP_ASSIGN_ADD: var_op = Variant::OP_ADD; break; - case GDParser::OperatorNode::OP_ASSIGN_SUB: var_op = Variant::OP_SUBTRACT; break; - case GDParser::OperatorNode::OP_ASSIGN_MUL: var_op = Variant::OP_MULTIPLY; break; - case GDParser::OperatorNode::OP_ASSIGN_DIV: var_op = Variant::OP_DIVIDE; break; - case GDParser::OperatorNode::OP_ASSIGN_MOD: var_op = Variant::OP_MODULE; break; - case GDParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: var_op = Variant::OP_SHIFT_LEFT; break; - case GDParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: var_op = Variant::OP_SHIFT_RIGHT; break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: var_op = Variant::OP_BIT_AND; break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: var_op = Variant::OP_BIT_OR; break; - case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: var_op = Variant::OP_BIT_XOR; break; - case GDParser::OperatorNode::OP_INIT_ASSIGN: - case GDParser::OperatorNode::OP_ASSIGN: { + case GDScriptParser::OperatorNode::OP_ASSIGN_ADD: var_op = Variant::OP_ADD; break; + case GDScriptParser::OperatorNode::OP_ASSIGN_SUB: var_op = Variant::OP_SUBTRACT; break; + case GDScriptParser::OperatorNode::OP_ASSIGN_MUL: var_op = Variant::OP_MULTIPLY; break; + case GDScriptParser::OperatorNode::OP_ASSIGN_DIV: var_op = Variant::OP_DIVIDE; break; + case GDScriptParser::OperatorNode::OP_ASSIGN_MOD: var_op = Variant::OP_MODULE; break; + case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: var_op = Variant::OP_SHIFT_LEFT; break; + case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: var_op = Variant::OP_SHIFT_RIGHT; break; + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_AND: var_op = Variant::OP_BIT_AND; break; + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_OR: var_op = Variant::OP_BIT_OR; break; + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR: var_op = Variant::OP_BIT_XOR; break; + case GDScriptParser::OperatorNode::OP_INIT_ASSIGN: + case GDScriptParser::OperatorNode::OP_ASSIGN: { //none } break; @@ -151,7 +152,7 @@ int GDCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDParser: } } - bool initializer = p_expression->op == GDParser::OperatorNode::OP_INIT_ASSIGN; + bool initializer = p_expression->op == GDScriptParser::OperatorNode::OP_INIT_ASSIGN; if (var_op == Variant::OP_MAX) { @@ -161,32 +162,32 @@ int GDCompiler::_parse_assign_right_expression(CodeGen &codegen, const GDParser: if (!_create_binary_operator(codegen, p_expression, var_op, p_stack_level, initializer)) return -1; - int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); + int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode codegen.alloc_stack(p_stack_level); return dst_addr; } -int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expression, int p_stack_level, bool p_root, bool p_initializer) { +int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root, bool p_initializer) { switch (p_expression->type) { //should parse variable declaration and adjust stack accordingly... - case GDParser::Node::TYPE_IDENTIFIER: { + case GDScriptParser::Node::TYPE_IDENTIFIER: { //return identifier //wait, identifier could be a local variable or something else... careful here, must reference properly //as stack may be more interesting to work with //This could be made much simpler by just indexing "self", but done this way (with custom self-addressing modes) increases peformance a lot. - const GDParser::IdentifierNode *in = static_cast<const GDParser::IdentifierNode *>(p_expression); + const GDScriptParser::IdentifierNode *in = static_cast<const GDScriptParser::IdentifierNode *>(p_expression); StringName identifier = in->name; if (_is_class_member_property(codegen, identifier)) { //get property - codegen.opcodes.push_back(GDFunction::OPCODE_GET_MEMBER); // perform operator + codegen.opcodes.push_back(GDScriptFunction::OPCODE_GET_MEMBER); // perform operator codegen.opcodes.push_back(codegen.get_name_map_pos(identifier)); // argument 2 (unary only takes one parameter) - int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); + int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode codegen.alloc_stack(p_stack_level); return dst_addr; @@ -196,7 +197,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (!p_initializer && codegen.stack_identifiers.has(identifier)) { int pos = codegen.stack_identifiers[identifier]; - return pos | (GDFunction::ADDR_TYPE_STACK_VARIABLE << GDFunction::ADDR_BITS); + return pos | (GDScriptFunction::ADDR_TYPE_STACK_VARIABLE << GDScriptFunction::ADDR_BITS); } //TRY MEMBERS! if (!codegen.function_node || !codegen.function_node->_static) { @@ -206,7 +207,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (codegen.script->member_indices.has(identifier)) { int idx = codegen.script->member_indices[identifier].index; - return idx | (GDFunction::ADDR_TYPE_MEMBER << GDFunction::ADDR_BITS); //argument (stack root) + return idx | (GDScriptFunction::ADDR_TYPE_MEMBER << GDScriptFunction::ADDR_BITS); //argument (stack root) } } @@ -216,14 +217,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr while (owner) { GDScript *scr = owner; - GDNativeClass *nc = NULL; + GDScriptNativeClass *nc = NULL; while (scr) { if (scr->constants.has(identifier)) { //int idx=scr->constants[identifier]; int idx = codegen.get_name_map_pos(identifier); - return idx | (GDFunction::ADDR_TYPE_CLASS_CONSTANT << GDFunction::ADDR_BITS); //argument (stack root) + return idx | (GDScriptFunction::ADDR_TYPE_CLASS_CONSTANT << GDScriptFunction::ADDR_BITS); //argument (stack root) } if (scr->native.is_valid()) nc = scr->native.ptr(); @@ -249,7 +250,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr idx = codegen.constant_map[key]; } - return idx | (GDFunction::ADDR_TYPE_LOCAL_CONSTANT << GDFunction::ADDR_BITS); //make it a local constant (faster access) + return idx | (GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT << GDScriptFunction::ADDR_BITS); //make it a local constant (faster access) } } @@ -261,14 +262,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (codegen.script->subclasses.has(identifier)) { //same with a subclass, make it a local constant. int idx = codegen.get_constant_pos(codegen.script->subclasses[identifier]); - return idx|(GDFunction::ADDR_TYPE_LOCAL_CONSTANT<<GDFunction::ADDR_BITS); //make it a local constant (faster access) + return idx|(GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT<<GDScriptFunction::ADDR_BITS); //make it a local constant (faster access) }*/ if (GDScriptLanguage::get_singleton()->get_global_map().has(identifier)) { int idx = GDScriptLanguage::get_singleton()->get_global_map()[identifier]; - return idx | (GDFunction::ADDR_TYPE_GLOBAL << GDFunction::ADDR_BITS); //argument (stack root) + return idx | (GDScriptFunction::ADDR_TYPE_GLOBAL << GDScriptFunction::ADDR_BITS); //argument (stack root) } //not found, error @@ -278,9 +279,9 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr return -1; } break; - case GDParser::Node::TYPE_CONSTANT: { + case GDScriptParser::Node::TYPE_CONSTANT: { //return constant - const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(p_expression); + const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(p_expression); int idx; @@ -293,20 +294,20 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr idx = codegen.constant_map[cn->value]; } - return idx | (GDFunction::ADDR_TYPE_LOCAL_CONSTANT << GDFunction::ADDR_BITS); //argument (stack root) + return idx | (GDScriptFunction::ADDR_TYPE_LOCAL_CONSTANT << GDScriptFunction::ADDR_BITS); //argument (stack root) } break; - case GDParser::Node::TYPE_SELF: { + case GDScriptParser::Node::TYPE_SELF: { //return constant if (codegen.function_node && codegen.function_node->_static) { _set_error("'self' not present in static function!", p_expression); return -1; } - return (GDFunction::ADDR_TYPE_SELF << GDFunction::ADDR_BITS); + return (GDScriptFunction::ADDR_TYPE_SELF << GDScriptFunction::ADDR_BITS); } break; - case GDParser::Node::TYPE_ARRAY: { + case GDScriptParser::Node::TYPE_ARRAY: { - const GDParser::ArrayNode *an = static_cast<const GDParser::ArrayNode *>(p_expression); + const GDScriptParser::ArrayNode *an = static_cast<const GDScriptParser::ArrayNode *>(p_expression); Vector<int> values; int slevel = p_stack_level; @@ -316,7 +317,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr int ret = _parse_expression(codegen, an->elements[i], slevel); if (ret < 0) return ret; - if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) { + if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); } @@ -324,20 +325,20 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr values.push_back(ret); } - codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT_ARRAY); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_CONSTRUCT_ARRAY); codegen.opcodes.push_back(values.size()); for (int i = 0; i < values.size(); i++) codegen.opcodes.push_back(values[i]); - int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); + int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode codegen.alloc_stack(p_stack_level); return dst_addr; } break; - case GDParser::Node::TYPE_DICTIONARY: { + case GDScriptParser::Node::TYPE_DICTIONARY: { - const GDParser::DictionaryNode *dn = static_cast<const GDParser::DictionaryNode *>(p_expression); + const GDScriptParser::DictionaryNode *dn = static_cast<const GDScriptParser::DictionaryNode *>(p_expression); Vector<int> values; int slevel = p_stack_level; @@ -347,7 +348,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr int ret = _parse_expression(codegen, dn->elements[i].key, slevel); if (ret < 0) return ret; - if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) { + if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); } @@ -357,7 +358,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr ret = _parse_expression(codegen, dn->elements[i].value, slevel); if (ret < 0) return ret; - if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) { + if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); } @@ -365,29 +366,29 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr values.push_back(ret); } - codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT_DICTIONARY); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_CONSTRUCT_DICTIONARY); codegen.opcodes.push_back(dn->elements.size()); for (int i = 0; i < values.size(); i++) codegen.opcodes.push_back(values[i]); - int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); + int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode codegen.alloc_stack(p_stack_level); return dst_addr; } break; - case GDParser::Node::TYPE_OPERATOR: { + case GDScriptParser::Node::TYPE_OPERATOR: { //hell breaks loose - const GDParser::OperatorNode *on = static_cast<const GDParser::OperatorNode *>(p_expression); + const GDScriptParser::OperatorNode *on = static_cast<const GDScriptParser::OperatorNode *>(p_expression); switch (on->op) { //call/constructor operator - case GDParser::OperatorNode::OP_PARENT_CALL: { + case GDScriptParser::OperatorNode::OP_PARENT_CALL: { ERR_FAIL_COND_V(on->arguments.size() < 1, -1); - const GDParser::IdentifierNode *in = (const GDParser::IdentifierNode *)on->arguments[0]; + const GDScriptParser::IdentifierNode *in = (const GDScriptParser::IdentifierNode *)on->arguments[0]; Vector<int> arguments; int slevel = p_stack_level; @@ -396,7 +397,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr int ret = _parse_expression(codegen, on->arguments[i], slevel); if (ret < 0) return ret; - if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) { + if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); } @@ -404,7 +405,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr } //push call bytecode - codegen.opcodes.push_back(GDFunction::OPCODE_CALL_SELF_BASE); // basic type constructor + codegen.opcodes.push_back(GDScriptFunction::OPCODE_CALL_SELF_BASE); // basic type constructor codegen.opcodes.push_back(codegen.get_name_map_pos(in->name)); //instance codegen.opcodes.push_back(arguments.size()); //argument count @@ -413,13 +414,13 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr codegen.opcodes.push_back(arguments[i]); //arguments } break; - case GDParser::OperatorNode::OP_CALL: { + case GDScriptParser::OperatorNode::OP_CALL: { - if (on->arguments[0]->type == GDParser::Node::TYPE_TYPE) { + if (on->arguments[0]->type == GDScriptParser::Node::TYPE_TYPE) { //construct a basic type ERR_FAIL_COND_V(on->arguments.size() < 1, -1); - const GDParser::TypeNode *tn = (const GDParser::TypeNode *)on->arguments[0]; + const GDScriptParser::TypeNode *tn = (const GDScriptParser::TypeNode *)on->arguments[0]; int vtype = tn->vtype; Vector<int> arguments; @@ -429,7 +430,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr int ret = _parse_expression(codegen, on->arguments[i], slevel); if (ret < 0) return ret; - if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) { + if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); } @@ -437,14 +438,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr } //push call bytecode - codegen.opcodes.push_back(GDFunction::OPCODE_CONSTRUCT); // basic type constructor + codegen.opcodes.push_back(GDScriptFunction::OPCODE_CONSTRUCT); // basic type constructor codegen.opcodes.push_back(vtype); //instance codegen.opcodes.push_back(arguments.size()); //argument count codegen.alloc_call(arguments.size()); for (int i = 0; i < arguments.size(); i++) codegen.opcodes.push_back(arguments[i]); //arguments - } else if (on->arguments[0]->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) { + } else if (on->arguments[0]->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) { //built in function ERR_FAIL_COND_V(on->arguments.size() < 1, -1); @@ -457,7 +458,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (ret < 0) return ret; - if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) { + if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); } @@ -465,8 +466,8 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr arguments.push_back(ret); } - codegen.opcodes.push_back(GDFunction::OPCODE_CALL_BUILT_IN); - codegen.opcodes.push_back(static_cast<const GDParser::BuiltInFunctionNode *>(on->arguments[0])->function); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_CALL_BUILT_IN); + codegen.opcodes.push_back(static_cast<const GDScriptParser::BuiltInFunctionNode *>(on->arguments[0])->function); codegen.opcodes.push_back(on->arguments.size() - 1); codegen.alloc_call(on->arguments.size() - 1); for (int i = 0; i < arguments.size(); i++) @@ -476,9 +477,9 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr //regular function ERR_FAIL_COND_V(on->arguments.size() < 2, -1); - const GDParser::Node *instance = on->arguments[0]; + const GDScriptParser::Node *instance = on->arguments[0]; - if (instance->type == GDParser::Node::TYPE_SELF) { + if (instance->type == GDScriptParser::Node::TYPE_SELF) { //room for optimization } @@ -489,16 +490,16 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr int ret; - if (i == 0 && on->arguments[i]->type == GDParser::Node::TYPE_SELF && codegen.function_node && codegen.function_node->_static) { + if (i == 0 && on->arguments[i]->type == GDScriptParser::Node::TYPE_SELF && codegen.function_node && codegen.function_node->_static) { //static call to self - ret = (GDFunction::ADDR_TYPE_CLASS << GDFunction::ADDR_BITS); + ret = (GDScriptFunction::ADDR_TYPE_CLASS << GDScriptFunction::ADDR_BITS); } else if (i == 1) { - if (on->arguments[i]->type != GDParser::Node::TYPE_IDENTIFIER) { + if (on->arguments[i]->type != GDScriptParser::Node::TYPE_IDENTIFIER) { _set_error("Attempt to call a non-identifier.", on); return -1; } - GDParser::IdentifierNode *id = static_cast<GDParser::IdentifierNode *>(on->arguments[i]); + GDScriptParser::IdentifierNode *id = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[i]); ret = codegen.get_name_map_pos(id->name); } else { @@ -506,7 +507,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr ret = _parse_expression(codegen, on->arguments[i], slevel); if (ret < 0) return ret; - if (ret & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) { + if (ret & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); } @@ -514,14 +515,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr arguments.push_back(ret); } - codegen.opcodes.push_back(p_root ? GDFunction::OPCODE_CALL : GDFunction::OPCODE_CALL_RETURN); // perform operator + codegen.opcodes.push_back(p_root ? GDScriptFunction::OPCODE_CALL : GDScriptFunction::OPCODE_CALL_RETURN); // perform operator codegen.opcodes.push_back(on->arguments.size() - 2); codegen.alloc_call(on->arguments.size() - 2); for (int i = 0; i < arguments.size(); i++) codegen.opcodes.push_back(arguments[i]); } } break; - case GDParser::OperatorNode::OP_YIELD: { + case GDScriptParser::OperatorNode::OP_YIELD: { ERR_FAIL_COND_V(on->arguments.size() && on->arguments.size() != 2, -1); @@ -532,7 +533,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr int ret = _parse_expression(codegen, on->arguments[i], slevel); if (ret < 0) return ret; - if (ret & (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)) { + if (ret & (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)) { slevel++; codegen.alloc_stack(slevel); } @@ -540,22 +541,22 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr } //push call bytecode - codegen.opcodes.push_back(arguments.size() == 0 ? GDFunction::OPCODE_YIELD : GDFunction::OPCODE_YIELD_SIGNAL); // basic type constructor + codegen.opcodes.push_back(arguments.size() == 0 ? GDScriptFunction::OPCODE_YIELD : GDScriptFunction::OPCODE_YIELD_SIGNAL); // basic type constructor for (int i = 0; i < arguments.size(); i++) codegen.opcodes.push_back(arguments[i]); //arguments - codegen.opcodes.push_back(GDFunction::OPCODE_YIELD_RESUME); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_YIELD_RESUME); //next will be where to place the result :) } break; //indexing operator - case GDParser::OperatorNode::OP_INDEX: - case GDParser::OperatorNode::OP_INDEX_NAMED: { + case GDScriptParser::OperatorNode::OP_INDEX: + case GDScriptParser::OperatorNode::OP_INDEX_NAMED: { ERR_FAIL_COND_V(on->arguments.size() != 2, -1); int slevel = p_stack_level; - bool named = (on->op == GDParser::OperatorNode::OP_INDEX_NAMED); + bool named = (on->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED); int from = _parse_expression(codegen, on->arguments[0], slevel); if (from < 0) @@ -563,14 +564,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr int index; if (named) { - if (on->arguments[0]->type == GDParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) { + if (on->arguments[0]->type == GDScriptParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) { - GDParser::IdentifierNode *identifier = static_cast<GDParser::IdentifierNode *>(on->arguments[1]); + GDScriptParser::IdentifierNode *identifier = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1]); const Map<StringName, GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(identifier->name); #ifdef DEBUG_ENABLED if (MI && MI->get().getter == codegen.function_node->name) { - String n = static_cast<GDParser::IdentifierNode *>(on->arguments[1])->name; + String n = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1])->name; _set_error("Must use '" + n + "' instead of 'self." + n + "' in getter.", on); return -1; } @@ -578,23 +579,23 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (MI && MI->get().getter == "") { // Faster than indexing self (as if no self. had been used) - return (MI->get().index) | (GDFunction::ADDR_TYPE_MEMBER << GDFunction::ADDR_BITS); + return (MI->get().index) | (GDScriptFunction::ADDR_TYPE_MEMBER << GDScriptFunction::ADDR_BITS); } } - index = codegen.get_name_map_pos(static_cast<GDParser::IdentifierNode *>(on->arguments[1])->name); + index = codegen.get_name_map_pos(static_cast<GDScriptParser::IdentifierNode *>(on->arguments[1])->name); } else { - if (on->arguments[1]->type == GDParser::Node::TYPE_CONSTANT && static_cast<const GDParser::ConstantNode *>(on->arguments[1])->value.get_type() == Variant::STRING) { + if (on->arguments[1]->type == GDScriptParser::Node::TYPE_CONSTANT && static_cast<const GDScriptParser::ConstantNode *>(on->arguments[1])->value.get_type() == Variant::STRING) { //also, somehow, named (speed up anyway) - StringName name = static_cast<const GDParser::ConstantNode *>(on->arguments[1])->value; + StringName name = static_cast<const GDScriptParser::ConstantNode *>(on->arguments[1])->value; index = codegen.get_name_map_pos(name); named = true; } else { //regular indexing - if (from & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) { + if (from & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); } @@ -605,19 +606,19 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr } } - codegen.opcodes.push_back(named ? GDFunction::OPCODE_GET_NAMED : GDFunction::OPCODE_GET); // perform operator + codegen.opcodes.push_back(named ? GDScriptFunction::OPCODE_GET_NAMED : GDScriptFunction::OPCODE_GET); // perform operator codegen.opcodes.push_back(from); // argument 1 codegen.opcodes.push_back(index); // argument 2 (unary only takes one parameter) } break; - case GDParser::OperatorNode::OP_AND: { + case GDScriptParser::OperatorNode::OP_AND: { // AND operator with early out on failure int res = _parse_expression(codegen, on->arguments[0], p_stack_level); if (res < 0) return res; - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT); codegen.opcodes.push_back(res); int jump_fail_pos = codegen.opcodes.size(); codegen.opcodes.push_back(0); @@ -626,31 +627,31 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (res < 0) return res; - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT); codegen.opcodes.push_back(res); int jump_fail_pos2 = codegen.opcodes.size(); codegen.opcodes.push_back(0); codegen.alloc_stack(p_stack_level); //it will be used.. - codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_TRUE); - codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN_TRUE); + codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(codegen.opcodes.size() + 3); codegen.opcodes[jump_fail_pos] = codegen.opcodes.size(); codegen.opcodes[jump_fail_pos2] = codegen.opcodes.size(); - codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_FALSE); - codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); - return p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS; + codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN_FALSE); + codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); + return p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS; } break; - case GDParser::OperatorNode::OP_OR: { + case GDScriptParser::OperatorNode::OP_OR: { // OR operator with early out on success int res = _parse_expression(codegen, on->arguments[0], p_stack_level); if (res < 0) return res; - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF); codegen.opcodes.push_back(res); int jump_success_pos = codegen.opcodes.size(); codegen.opcodes.push_back(0); @@ -659,32 +660,32 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (res < 0) return res; - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF); codegen.opcodes.push_back(res); int jump_success_pos2 = codegen.opcodes.size(); codegen.opcodes.push_back(0); codegen.alloc_stack(p_stack_level); //it will be used.. - codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_FALSE); - codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN_FALSE); + codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(codegen.opcodes.size() + 3); codegen.opcodes[jump_success_pos] = codegen.opcodes.size(); codegen.opcodes[jump_success_pos2] = codegen.opcodes.size(); - codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN_TRUE); - codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); - return p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS; + codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN_TRUE); + codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); + return p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS; } break; // ternary operators - case GDParser::OperatorNode::OP_TERNARY_IF: { + case GDScriptParser::OperatorNode::OP_TERNARY_IF: { // x IF a ELSE y operator with early out on failure int res = _parse_expression(codegen, on->arguments[0], p_stack_level); if (res < 0) return res; - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT); codegen.opcodes.push_back(res); int jump_fail_pos = codegen.opcodes.size(); codegen.opcodes.push_back(0); @@ -694,10 +695,10 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr return res; codegen.alloc_stack(p_stack_level); //it will be used.. - codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN); - codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN); + codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); codegen.opcodes.push_back(res); - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); int jump_past_pos = codegen.opcodes.size(); codegen.opcodes.push_back(0); @@ -706,116 +707,116 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (res < 0) return res; - codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN); - codegen.opcodes.push_back(p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN); + codegen.opcodes.push_back(p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); codegen.opcodes.push_back(res); codegen.opcodes[jump_past_pos] = codegen.opcodes.size(); - return p_stack_level | GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS; + return p_stack_level | GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS; } break; //unary operators - case GDParser::OperatorNode::OP_NEG: { + case GDScriptParser::OperatorNode::OP_NEG: { if (!_create_unary_operator(codegen, on, Variant::OP_NEGATE, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_NOT: { + case GDScriptParser::OperatorNode::OP_NOT: { if (!_create_unary_operator(codegen, on, Variant::OP_NOT, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_BIT_INVERT: { + case GDScriptParser::OperatorNode::OP_BIT_INVERT: { if (!_create_unary_operator(codegen, on, Variant::OP_BIT_NEGATE, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_PREINC: { + case GDScriptParser::OperatorNode::OP_PREINC: { } break; //? - case GDParser::OperatorNode::OP_PREDEC: { + case GDScriptParser::OperatorNode::OP_PREDEC: { } break; - case GDParser::OperatorNode::OP_INC: { + case GDScriptParser::OperatorNode::OP_INC: { } break; - case GDParser::OperatorNode::OP_DEC: { + case GDScriptParser::OperatorNode::OP_DEC: { } break; //binary operators (in precedence order) - case GDParser::OperatorNode::OP_IN: { + case GDScriptParser::OperatorNode::OP_IN: { if (!_create_binary_operator(codegen, on, Variant::OP_IN, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_EQUAL: { + case GDScriptParser::OperatorNode::OP_EQUAL: { if (!_create_binary_operator(codegen, on, Variant::OP_EQUAL, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_NOT_EQUAL: { + case GDScriptParser::OperatorNode::OP_NOT_EQUAL: { if (!_create_binary_operator(codegen, on, Variant::OP_NOT_EQUAL, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_LESS: { + case GDScriptParser::OperatorNode::OP_LESS: { if (!_create_binary_operator(codegen, on, Variant::OP_LESS, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_LESS_EQUAL: { + case GDScriptParser::OperatorNode::OP_LESS_EQUAL: { if (!_create_binary_operator(codegen, on, Variant::OP_LESS_EQUAL, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_GREATER: { + case GDScriptParser::OperatorNode::OP_GREATER: { if (!_create_binary_operator(codegen, on, Variant::OP_GREATER, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_GREATER_EQUAL: { + case GDScriptParser::OperatorNode::OP_GREATER_EQUAL: { if (!_create_binary_operator(codegen, on, Variant::OP_GREATER_EQUAL, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_ADD: { + case GDScriptParser::OperatorNode::OP_ADD: { if (!_create_binary_operator(codegen, on, Variant::OP_ADD, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_SUB: { + case GDScriptParser::OperatorNode::OP_SUB: { if (!_create_binary_operator(codegen, on, Variant::OP_SUBTRACT, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_MUL: { + case GDScriptParser::OperatorNode::OP_MUL: { if (!_create_binary_operator(codegen, on, Variant::OP_MULTIPLY, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_DIV: { + case GDScriptParser::OperatorNode::OP_DIV: { if (!_create_binary_operator(codegen, on, Variant::OP_DIVIDE, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_MOD: { + case GDScriptParser::OperatorNode::OP_MOD: { if (!_create_binary_operator(codegen, on, Variant::OP_MODULE, p_stack_level)) return -1; } break; - //case GDParser::OperatorNode::OP_SHIFT_LEFT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_LEFT,p_stack_level)) return -1;} break; - //case GDParser::OperatorNode::OP_SHIFT_RIGHT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_RIGHT,p_stack_level)) return -1;} break; - case GDParser::OperatorNode::OP_BIT_AND: { + //case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_LEFT,p_stack_level)) return -1;} break; + //case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: { if (!_create_binary_operator(codegen,on,Variant::OP_SHIFT_RIGHT,p_stack_level)) return -1;} break; + case GDScriptParser::OperatorNode::OP_BIT_AND: { if (!_create_binary_operator(codegen, on, Variant::OP_BIT_AND, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_BIT_OR: { + case GDScriptParser::OperatorNode::OP_BIT_OR: { if (!_create_binary_operator(codegen, on, Variant::OP_BIT_OR, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_BIT_XOR: { + case GDScriptParser::OperatorNode::OP_BIT_XOR: { if (!_create_binary_operator(codegen, on, Variant::OP_BIT_XOR, p_stack_level)) return -1; } break; //shift - case GDParser::OperatorNode::OP_SHIFT_LEFT: { + case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: { if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_LEFT, p_stack_level)) return -1; } break; - case GDParser::OperatorNode::OP_SHIFT_RIGHT: { + case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: { if (!_create_binary_operator(codegen, on, Variant::OP_SHIFT_RIGHT, p_stack_level)) return -1; } break; //assignment operators - case GDParser::OperatorNode::OP_ASSIGN_ADD: - case GDParser::OperatorNode::OP_ASSIGN_SUB: - case GDParser::OperatorNode::OP_ASSIGN_MUL: - case GDParser::OperatorNode::OP_ASSIGN_DIV: - case GDParser::OperatorNode::OP_ASSIGN_MOD: - case GDParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: - case GDParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: - case GDParser::OperatorNode::OP_ASSIGN_BIT_AND: - case GDParser::OperatorNode::OP_ASSIGN_BIT_OR: - case GDParser::OperatorNode::OP_ASSIGN_BIT_XOR: - case GDParser::OperatorNode::OP_INIT_ASSIGN: - case GDParser::OperatorNode::OP_ASSIGN: { + case GDScriptParser::OperatorNode::OP_ASSIGN_ADD: + case GDScriptParser::OperatorNode::OP_ASSIGN_SUB: + case GDScriptParser::OperatorNode::OP_ASSIGN_MUL: + case GDScriptParser::OperatorNode::OP_ASSIGN_DIV: + case GDScriptParser::OperatorNode::OP_ASSIGN_MOD: + case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_LEFT: + case GDScriptParser::OperatorNode::OP_ASSIGN_SHIFT_RIGHT: + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_AND: + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_OR: + case GDScriptParser::OperatorNode::OP_ASSIGN_BIT_XOR: + case GDScriptParser::OperatorNode::OP_INIT_ASSIGN: + case GDScriptParser::OperatorNode::OP_ASSIGN: { ERR_FAIL_COND_V(on->arguments.size() != 2, -1); - if (on->arguments[0]->type == GDParser::Node::TYPE_OPERATOR && (static_cast<GDParser::OperatorNode *>(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX || static_cast<GDParser::OperatorNode *>(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX_NAMED)) { + if (on->arguments[0]->type == GDScriptParser::Node::TYPE_OPERATOR && (static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX || static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED)) { //SET (chained) MODE!! #ifdef DEBUG_ENABLED - if (static_cast<GDParser::OperatorNode *>(on->arguments[0])->op == GDParser::OperatorNode::OP_INDEX_NAMED) { - const GDParser::OperatorNode *inon = static_cast<GDParser::OperatorNode *>(on->arguments[0]); + if (static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) { + const GDScriptParser::OperatorNode *inon = static_cast<GDScriptParser::OperatorNode *>(on->arguments[0]); - if (inon->arguments[0]->type == GDParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) { + if (inon->arguments[0]->type == GDScriptParser::Node::TYPE_SELF && codegen.script && codegen.function_node && !codegen.function_node->_static) { - const Map<StringName, GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(static_cast<GDParser::IdentifierNode *>(inon->arguments[1])->name); + const Map<StringName, GDScript::MemberInfo>::Element *MI = codegen.script->member_indices.find(static_cast<GDScriptParser::IdentifierNode *>(inon->arguments[1])->name); if (MI && MI->get().setter == codegen.function_node->name) { - String n = static_cast<GDParser::IdentifierNode *>(inon->arguments[1])->name; + String n = static_cast<GDScriptParser::IdentifierNode *>(inon->arguments[1])->name; _set_error("Must use '" + n + "' instead of 'self." + n + "' in setter.", inon); return -1; } @@ -825,34 +826,34 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr int slevel = p_stack_level; - GDParser::OperatorNode *op = static_cast<GDParser::OperatorNode *>(on->arguments[0]); + GDScriptParser::OperatorNode *op = static_cast<GDScriptParser::OperatorNode *>(on->arguments[0]); /* Find chain of sets */ StringName assign_property; - List<GDParser::OperatorNode *> chain; + List<GDScriptParser::OperatorNode *> chain; { //create get/set chain - GDParser::OperatorNode *n = op; + GDScriptParser::OperatorNode *n = op; while (true) { chain.push_back(n); - if (n->arguments[0]->type != GDParser::Node::TYPE_OPERATOR) { + if (n->arguments[0]->type != GDScriptParser::Node::TYPE_OPERATOR) { //check for a built-in property - if (n->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER) { + if (n->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER) { - GDParser::IdentifierNode *identifier = static_cast<GDParser::IdentifierNode *>(n->arguments[0]); + GDScriptParser::IdentifierNode *identifier = static_cast<GDScriptParser::IdentifierNode *>(n->arguments[0]); if (_is_class_member_property(codegen, identifier->name)) { assign_property = identifier->name; } } break; } - n = static_cast<GDParser::OperatorNode *>(n->arguments[0]); - if (n->op != GDParser::OperatorNode::OP_INDEX && n->op != GDParser::OperatorNode::OP_INDEX_NAMED) + n = static_cast<GDScriptParser::OperatorNode *>(n->arguments[0]); + if (n->op != GDScriptParser::OperatorNode::OP_INDEX && n->op != GDScriptParser::OperatorNode::OP_INDEX_NAMED) break; } } @@ -867,7 +868,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr //print_line("retval: "+itos(retval)); - if (retval & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) { + if (retval & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); } @@ -881,30 +882,30 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr // in Node2D setchain.push_back(prev_pos); setchain.push_back(codegen.get_name_map_pos(assign_property)); - setchain.push_back(GDFunction::OPCODE_SET_MEMBER); + setchain.push_back(GDScriptFunction::OPCODE_SET_MEMBER); } - for (List<GDParser::OperatorNode *>::Element *E = chain.back(); E; E = E->prev()) { + for (List<GDScriptParser::OperatorNode *>::Element *E = chain.back(); E; E = E->prev()) { if (E == chain.front()) //ignore first break; - bool named = E->get()->op == GDParser::OperatorNode::OP_INDEX_NAMED; + bool named = E->get()->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED; int key_idx; if (named) { - key_idx = codegen.get_name_map_pos(static_cast<const GDParser::IdentifierNode *>(E->get()->arguments[1])->name); + key_idx = codegen.get_name_map_pos(static_cast<const GDScriptParser::IdentifierNode *>(E->get()->arguments[1])->name); //printf("named key %x\n",key_idx); } else { - if (prev_pos & (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS)) { + if (prev_pos & (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS)) { slevel++; codegen.alloc_stack(slevel); } - GDParser::Node *key = E->get()->arguments[1]; + GDScriptParser::Node *key = E->get()->arguments[1]; key_idx = _parse_expression(codegen, key, slevel); //printf("expr key %x\n",key_idx); @@ -914,12 +915,12 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (key_idx < 0) //error return key_idx; - codegen.opcodes.push_back(named ? GDFunction::OPCODE_GET_NAMED : GDFunction::OPCODE_GET); + codegen.opcodes.push_back(named ? GDScriptFunction::OPCODE_GET_NAMED : GDScriptFunction::OPCODE_GET); codegen.opcodes.push_back(prev_pos); codegen.opcodes.push_back(key_idx); slevel++; codegen.alloc_stack(slevel); - int dst_pos = (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) | slevel; + int dst_pos = (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) | slevel; codegen.opcodes.push_back(dst_pos); @@ -928,7 +929,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr setchain.push_back(dst_pos); setchain.push_back(key_idx); setchain.push_back(prev_pos); - setchain.push_back(named ? GDFunction::OPCODE_SET_NAMED : GDFunction::OPCODE_SET); + setchain.push_back(named ? GDScriptFunction::OPCODE_SET_NAMED : GDScriptFunction::OPCODE_SET); prev_pos = dst_pos; } @@ -938,9 +939,9 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr int set_index; bool named = false; - if (static_cast<const GDParser::OperatorNode *>(op)->op == GDParser::OperatorNode::OP_INDEX_NAMED) { + if (static_cast<const GDScriptParser::OperatorNode *>(op)->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) { - set_index = codegen.get_name_map_pos(static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name); + set_index = codegen.get_name_map_pos(static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name); named = true; } else { @@ -951,7 +952,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (set_index < 0) //error return set_index; - if (set_index & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) { + if (set_index & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); } @@ -960,7 +961,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (set_value < 0) //error return set_value; - codegen.opcodes.push_back(named ? GDFunction::OPCODE_SET_NAMED : GDFunction::OPCODE_SET); + codegen.opcodes.push_back(named ? GDScriptFunction::OPCODE_SET_NAMED : GDScriptFunction::OPCODE_SET); codegen.opcodes.push_back(prev_pos); codegen.opcodes.push_back(set_index); codegen.opcodes.push_back(set_value); @@ -972,7 +973,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr return retval; - } else if (on->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && _is_class_member_property(codegen, static_cast<GDParser::IdentifierNode *>(on->arguments[0])->name)) { + } else if (on->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER && _is_class_member_property(codegen, static_cast<GDScriptParser::IdentifierNode *>(on->arguments[0])->name)) { //assignment to member property int slevel = p_stack_level; @@ -981,24 +982,24 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (src_address < 0) return -1; - StringName name = static_cast<GDParser::IdentifierNode *>(on->arguments[0])->name; + StringName name = static_cast<GDScriptParser::IdentifierNode *>(on->arguments[0])->name; - codegen.opcodes.push_back(GDFunction::OPCODE_SET_MEMBER); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_SET_MEMBER); codegen.opcodes.push_back(codegen.get_name_map_pos(name)); codegen.opcodes.push_back(src_address); - return GDFunction::ADDR_TYPE_NIL << GDFunction::ADDR_BITS; + return GDScriptFunction::ADDR_TYPE_NIL << GDScriptFunction::ADDR_BITS; } else { //REGULAR ASSIGNMENT MODE!! int slevel = p_stack_level; - int dst_address_a = _parse_expression(codegen, on->arguments[0], slevel, false, on->op == GDParser::OperatorNode::OP_INIT_ASSIGN); + int dst_address_a = _parse_expression(codegen, on->arguments[0], slevel, false, on->op == GDScriptParser::OperatorNode::OP_INIT_ASSIGN); if (dst_address_a < 0) return -1; - if (dst_address_a & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) { + if (dst_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) { slevel++; codegen.alloc_stack(slevel); } @@ -1007,14 +1008,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (src_address_b < 0) return -1; - codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN); // perform operator + codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN); // perform operator codegen.opcodes.push_back(dst_address_a); // argument 1 codegen.opcodes.push_back(src_address_b); // argument 2 (unary only takes one parameter) return dst_address_a; //if anything, returns wathever was assigned or correct stack position } } break; - case GDParser::OperatorNode::OP_IS: { + case GDScriptParser::OperatorNode::OP_IS: { ERR_FAIL_COND_V(on->arguments.size() != 2, false); @@ -1024,14 +1025,14 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr if (src_address_a < 0) return -1; - if (src_address_a & GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) + if (src_address_a & GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) slevel++; //uses stack for return, increase stack int src_address_b = _parse_expression(codegen, on->arguments[1], slevel); if (src_address_b < 0) return -1; - codegen.opcodes.push_back(GDFunction::OPCODE_EXTENDS_TEST); // perform operator + codegen.opcodes.push_back(GDScriptFunction::OPCODE_EXTENDS_TEST); // perform operator codegen.opcodes.push_back(src_address_a); // argument 1 codegen.opcodes.push_back(src_address_b); // argument 2 (unary only takes one parameter) @@ -1044,7 +1045,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr } break; } - int dst_addr = (p_stack_level) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); + int dst_addr = (p_stack_level) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); codegen.opcodes.push_back(dst_addr); // append the stack level as destination address of the opcode codegen.alloc_stack(p_stack_level); return dst_addr; @@ -1060,7 +1061,7 @@ int GDCompiler::_parse_expression(CodeGen &codegen, const GDParser::Node *p_expr ERR_FAIL_V(-1); //unreachable code } -Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_block, int p_stack_level, int p_break_addr, int p_continue_addr) { +Error GDScriptCompiler::_parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level, int p_break_addr, int p_continue_addr) { codegen.push_stack_identifiers(); int new_identifiers = 0; @@ -1068,28 +1069,28 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl for (int i = 0; i < p_block->statements.size(); i++) { - const GDParser::Node *s = p_block->statements[i]; + const GDScriptParser::Node *s = p_block->statements[i]; switch (s->type) { - case GDParser::Node::TYPE_NEWLINE: { + case GDScriptParser::Node::TYPE_NEWLINE: { #ifdef DEBUG_ENABLED - const GDParser::NewLineNode *nl = static_cast<const GDParser::NewLineNode *>(s); - codegen.opcodes.push_back(GDFunction::OPCODE_LINE); + const GDScriptParser::NewLineNode *nl = static_cast<const GDScriptParser::NewLineNode *>(s); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_LINE); codegen.opcodes.push_back(nl->line); codegen.current_line = nl->line; #endif } break; - case GDParser::Node::TYPE_CONTROL_FLOW: { + case GDScriptParser::Node::TYPE_CONTROL_FLOW: { // try subblocks - const GDParser::ControlFlowNode *cf = static_cast<const GDParser::ControlFlowNode *>(s); + const GDScriptParser::ControlFlowNode *cf = static_cast<const GDScriptParser::ControlFlowNode *>(s); switch (cf->cf_type) { - case GDParser::ControlFlowNode::CF_MATCH: { - GDParser::MatchNode *match = cf->match; + case GDScriptParser::ControlFlowNode::CF_MATCH: { + GDScriptParser::MatchNode *match = cf->match; - GDParser::IdentifierNode *id = memnew(GDParser::IdentifierNode); + GDScriptParser::IdentifierNode *id = memnew(GDScriptParser::IdentifierNode); id->name = "#match_value"; // var #match_value @@ -1098,8 +1099,8 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl codegen.alloc_stack(p_stack_level); new_identifiers++; - GDParser::OperatorNode *op = memnew(GDParser::OperatorNode); - op->op = GDParser::OperatorNode::OP_ASSIGN; + GDScriptParser::OperatorNode *op = memnew(GDScriptParser::OperatorNode); + op->op = GDScriptParser::OperatorNode::OP_ASSIGN; op->arguments.push_back(id); op->arguments.push_back(match->val_to_match); @@ -1109,14 +1110,14 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl } // break address - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(codegen.opcodes.size() + 3); int break_addr = codegen.opcodes.size(); - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(0); // break addr for (int j = 0; j < match->compiled_pattern_branches.size(); j++) { - GDParser::MatchNode::CompiledPatternBranch branch = match->compiled_pattern_branches[j]; + GDScriptParser::MatchNode::CompiledPatternBranch branch = match->compiled_pattern_branches[j]; // jump over continue // jump unconditionally @@ -1127,11 +1128,11 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl return ERR_PARSE_ERROR; } - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF); codegen.opcodes.push_back(ret); codegen.opcodes.push_back(codegen.opcodes.size() + 3); int continue_addr = codegen.opcodes.size(); - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(0); Error err = _parse_block(codegen, branch.body, p_stack_level, p_break_addr, continue_addr); @@ -1139,7 +1140,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl return ERR_PARSE_ERROR; } - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(break_addr); codegen.opcodes[continue_addr + 1] = codegen.opcodes.size(); @@ -1149,10 +1150,10 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl } break; - case GDParser::ControlFlowNode::CF_IF: { + case GDScriptParser::ControlFlowNode::CF_IF: { #ifdef DEBUG_ENABLED - codegen.opcodes.push_back(GDFunction::OPCODE_LINE); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_LINE); codegen.opcodes.push_back(cf->line); codegen.current_line = cf->line; #endif @@ -1160,7 +1161,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl if (ret < 0) return ERR_PARSE_ERROR; - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT); codegen.opcodes.push_back(ret); int else_addr = codegen.opcodes.size(); codegen.opcodes.push_back(0); //temporary @@ -1171,7 +1172,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl if (cf->body_else) { - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); int end_addr = codegen.opcodes.size(); codegen.opcodes.push_back(0); codegen.opcodes[else_addr] = codegen.opcodes.size(); @@ -1187,42 +1188,42 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl } } break; - case GDParser::ControlFlowNode::CF_FOR: { + case GDScriptParser::ControlFlowNode::CF_FOR: { int slevel = p_stack_level; int iter_stack_pos = slevel; - int iterator_pos = (slevel++) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); - int counter_pos = (slevel++) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); - int container_pos = (slevel++) | (GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS); + int iterator_pos = (slevel++) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); + int counter_pos = (slevel++) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); + int container_pos = (slevel++) | (GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS); codegen.alloc_stack(slevel); codegen.push_stack_identifiers(); - codegen.add_stack_identifier(static_cast<const GDParser::IdentifierNode *>(cf->arguments[0])->name, iter_stack_pos); + codegen.add_stack_identifier(static_cast<const GDScriptParser::IdentifierNode *>(cf->arguments[0])->name, iter_stack_pos); int ret = _parse_expression(codegen, cf->arguments[1], slevel, false); if (ret < 0) return ERR_COMPILATION_FAILED; //assign container - codegen.opcodes.push_back(GDFunction::OPCODE_ASSIGN); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSIGN); codegen.opcodes.push_back(container_pos); codegen.opcodes.push_back(ret); //begin loop - codegen.opcodes.push_back(GDFunction::OPCODE_ITERATE_BEGIN); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_ITERATE_BEGIN); codegen.opcodes.push_back(counter_pos); codegen.opcodes.push_back(container_pos); codegen.opcodes.push_back(codegen.opcodes.size() + 4); codegen.opcodes.push_back(iterator_pos); - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); //skip code for next + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); //skip code for next codegen.opcodes.push_back(codegen.opcodes.size() + 8); //break loop int break_pos = codegen.opcodes.size(); - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); //skip code for next + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); //skip code for next codegen.opcodes.push_back(0); //skip code for next //next loop int continue_pos = codegen.opcodes.size(); - codegen.opcodes.push_back(GDFunction::OPCODE_ITERATE); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_ITERATE); codegen.opcodes.push_back(counter_pos); codegen.opcodes.push_back(container_pos); codegen.opcodes.push_back(break_pos); @@ -1232,52 +1233,52 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl if (err) return err; - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(continue_pos); codegen.opcodes[break_pos + 1] = codegen.opcodes.size(); codegen.pop_stack_identifiers(); } break; - case GDParser::ControlFlowNode::CF_WHILE: { + case GDScriptParser::ControlFlowNode::CF_WHILE: { - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(codegen.opcodes.size() + 3); int break_addr = codegen.opcodes.size(); - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(0); int continue_addr = codegen.opcodes.size(); int ret = _parse_expression(codegen, cf->arguments[0], p_stack_level, false); if (ret < 0) return ERR_PARSE_ERROR; - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_IF_NOT); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_IF_NOT); codegen.opcodes.push_back(ret); codegen.opcodes.push_back(break_addr); Error err = _parse_block(codegen, cf->body, p_stack_level, break_addr, continue_addr); if (err) return err; - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(continue_addr); codegen.opcodes[break_addr + 1] = codegen.opcodes.size(); } break; - case GDParser::ControlFlowNode::CF_SWITCH: { + case GDScriptParser::ControlFlowNode::CF_SWITCH: { } break; - case GDParser::ControlFlowNode::CF_BREAK: { + case GDScriptParser::ControlFlowNode::CF_BREAK: { if (p_break_addr < 0) { _set_error("'break'' not within loop", cf); return ERR_COMPILATION_FAILED; } - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(p_break_addr); } break; - case GDParser::ControlFlowNode::CF_CONTINUE: { + case GDScriptParser::ControlFlowNode::CF_CONTINUE: { if (p_continue_addr < 0) { @@ -1285,11 +1286,11 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl return ERR_COMPILATION_FAILED; } - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP); codegen.opcodes.push_back(p_continue_addr); } break; - case GDParser::ControlFlowNode::CF_RETURN: { + case GDScriptParser::ControlFlowNode::CF_RETURN: { int ret; @@ -1301,38 +1302,38 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl } else { - ret = GDFunction::ADDR_TYPE_NIL << GDFunction::ADDR_BITS; + ret = GDScriptFunction::ADDR_TYPE_NIL << GDScriptFunction::ADDR_BITS; } - codegen.opcodes.push_back(GDFunction::OPCODE_RETURN); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_RETURN); codegen.opcodes.push_back(ret); } break; } } break; - case GDParser::Node::TYPE_ASSERT: { + case GDScriptParser::Node::TYPE_ASSERT: { #ifdef DEBUG_ENABLED // try subblocks - const GDParser::AssertNode *as = static_cast<const GDParser::AssertNode *>(s); + const GDScriptParser::AssertNode *as = static_cast<const GDScriptParser::AssertNode *>(s); int ret = _parse_expression(codegen, as->condition, p_stack_level, false); if (ret < 0) return ERR_PARSE_ERROR; - codegen.opcodes.push_back(GDFunction::OPCODE_ASSERT); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_ASSERT); codegen.opcodes.push_back(ret); #endif } break; - case GDParser::Node::TYPE_BREAKPOINT: { + case GDScriptParser::Node::TYPE_BREAKPOINT: { #ifdef DEBUG_ENABLED // try subblocks - codegen.opcodes.push_back(GDFunction::OPCODE_BREAKPOINT); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_BREAKPOINT); #endif } break; - case GDParser::Node::TYPE_LOCAL_VAR: { + case GDScriptParser::Node::TYPE_LOCAL_VAR: { - const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(s); + const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(s); if (_is_class_member_property(codegen, lv->name)) { _set_error("Name for local variable '" + String(lv->name) + "' can't shadow class property of the same name.", lv); @@ -1356,7 +1357,7 @@ Error GDCompiler::_parse_block(CodeGen &codegen, const GDParser::BlockNode *p_bl return OK; } -Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode *p_class, const GDParser::FunctionNode *p_func, bool p_for_ready) { +Error GDScriptCompiler::_parse_function(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready) { Vector<int> bytecode; CodeGen codegen; @@ -1397,10 +1398,10 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode if (!p_func && p_class->extends_used && p_script->native.is_null()) { //call implicit parent constructor - codegen.opcodes.push_back(GDFunction::OPCODE_CALL_SELF_BASE); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_CALL_SELF_BASE); codegen.opcodes.push_back(codegen.get_name_map_pos("_init")); codegen.opcodes.push_back(0); - codegen.opcodes.push_back((GDFunction::ADDR_TYPE_STACK << GDFunction::ADDR_BITS) | 0); + codegen.opcodes.push_back((GDScriptFunction::ADDR_TYPE_STACK << GDScriptFunction::ADDR_BITS) | 0); } Error err = _parse_block(codegen, p_class->initializer, stack_level); if (err) @@ -1426,7 +1427,7 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode if (p_func->default_values.size()) { - codegen.opcodes.push_back(GDFunction::OPCODE_JUMP_TO_DEF_ARGUMENT); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_JUMP_TO_DEF_ARGUMENT); defarg_addr.push_back(codegen.opcodes.size()); for (int i = 0; i < p_func->default_values.size(); i++) { @@ -1449,15 +1450,15 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode func_name = "_init"; } - codegen.opcodes.push_back(GDFunction::OPCODE_END); + codegen.opcodes.push_back(GDScriptFunction::OPCODE_END); /* if (String(p_func->name)=="") { //initializer func gdfunc = &p_script->initializer; */ //} else { //regular func - p_script->member_functions[func_name] = memnew(GDFunction); - GDFunction *gdfunc = p_script->member_functions[func_name]; + p_script->member_functions[func_name] = memnew(GDScriptFunction); + GDScriptFunction *gdfunc = p_script->member_functions[func_name]; //} if (p_func) { @@ -1579,7 +1580,7 @@ Error GDCompiler::_parse_function(GDScript *p_script, const GDParser::ClassNode return OK; } -Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDParser::ClassNode *p_class, bool p_keep_state) { +Error GDScriptCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDScriptParser::ClassNode *p_class, bool p_keep_state) { Map<StringName, Ref<GDScript> > old_subclasses; @@ -1587,12 +1588,12 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa old_subclasses = p_script->subclasses; } - p_script->native = Ref<GDNativeClass>(); + p_script->native = Ref<GDScriptNativeClass>(); p_script->base = Ref<GDScript>(); p_script->_base = NULL; p_script->members.clear(); p_script->constants.clear(); - for (Map<StringName, GDFunction *>::Element *E = p_script->member_functions.front(); E; E = E->next()) { + for (Map<StringName, GDScriptFunction *>::Element *E = p_script->member_functions.front(); E; E = E->next()) { memdelete(E->get()); } p_script->member_functions.clear(); @@ -1606,7 +1607,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa p_script->tool = p_class->tool; p_script->name = p_class->name; - Ref<GDNativeClass> native; + Ref<GDScriptNativeClass> native; if (p_class->extends_used) { //do inheritance @@ -1801,14 +1802,14 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa for (int i = 0; i < p_class->constant_expressions.size(); i++) { StringName name = p_class->constant_expressions[i].identifier; - ERR_CONTINUE(p_class->constant_expressions[i].expression->type != GDParser::Node::TYPE_CONSTANT); + ERR_CONTINUE(p_class->constant_expressions[i].expression->type != GDScriptParser::Node::TYPE_CONSTANT); if (_is_class_member_property(p_script, name)) { _set_error("Member '" + name + "' already exists as a class property.", p_class); return ERR_ALREADY_EXISTS; } - GDParser::ConstantNode *constant = static_cast<GDParser::ConstantNode *>(p_class->constant_expressions[i].expression); + GDScriptParser::ConstantNode *constant = static_cast<GDScriptParser::ConstantNode *>(p_class->constant_expressions[i].expression); p_script->constants.insert(name, constant->value); //p_script->constants[constant->value].make_const(); @@ -1917,7 +1918,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa for (int i = 0; i < p_class->variables.size(); i++) { if (p_class->variables[i].setter) { - const Map<StringName, GDFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].setter); + const Map<StringName, GDScriptFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].setter); if (!E) { _set_error("Setter function '" + String(p_class->variables[i].setter) + "' not found in class.", NULL); err_line = p_class->variables[i].line; @@ -1934,7 +1935,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa } } if (p_class->variables[i].getter) { - const Map<StringName, GDFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].getter); + const Map<StringName, GDScriptFunction *>::Element *E = p_script->get_member_functions().find(p_class->variables[i].getter); if (!E) { _set_error("Getter function '" + String(p_class->variables[i].getter) + "' not found in class.", NULL); err_line = p_class->variables[i].line; @@ -1970,7 +1971,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa //re-create as an instance p_script->placeholders.erase(psi); //remove placeholder - GDInstance *instance = memnew(GDInstance); + GDScriptInstance *instance = memnew(GDScriptInstance); instance->base_ref = Object::cast_to<Reference>(E->get()); instance->members.resize(p_script->member_indices.size()); instance->script = Ref<GDScript>(p_script); @@ -1994,7 +1995,7 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa #endif } else { - GDInstance *gi = static_cast<GDInstance *>(si); + GDScriptInstance *gi = static_cast<GDScriptInstance *>(si); gi->reload_members(); } @@ -2007,18 +2008,18 @@ Error GDCompiler::_parse_class(GDScript *p_script, GDScript *p_owner, const GDPa return OK; } -Error GDCompiler::compile(const GDParser *p_parser, GDScript *p_script, bool p_keep_state) { +Error GDScriptCompiler::compile(const GDScriptParser *p_parser, GDScript *p_script, bool p_keep_state) { err_line = -1; err_column = -1; error = ""; parser = p_parser; - const GDParser::Node *root = parser->get_parse_tree(); - ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, ERR_INVALID_DATA); + const GDScriptParser::Node *root = parser->get_parse_tree(); + ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, ERR_INVALID_DATA); source = p_script->get_path(); - Error err = _parse_class(p_script, NULL, static_cast<const GDParser::ClassNode *>(root), p_keep_state); + Error err = _parse_class(p_script, NULL, static_cast<const GDScriptParser::ClassNode *>(root), p_keep_state); if (err) return err; @@ -2026,18 +2027,18 @@ Error GDCompiler::compile(const GDParser *p_parser, GDScript *p_script, bool p_k return OK; } -String GDCompiler::get_error() const { +String GDScriptCompiler::get_error() const { return error; } -int GDCompiler::get_error_line() const { +int GDScriptCompiler::get_error_line() const { return err_line; } -int GDCompiler::get_error_column() const { +int GDScriptCompiler::get_error_column() const { return err_column; } -GDCompiler::GDCompiler() { +GDScriptCompiler::GDScriptCompiler() { } diff --git a/modules/gdscript/gd_compiler.h b/modules/gdscript/gdscript_compiler.h index ac713ae75b..6e0457ba30 100644 --- a/modules/gdscript/gd_compiler.h +++ b/modules/gdscript/gdscript_compiler.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_compiler.h */ +/* gdscript_compiler.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,26 +27,26 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GD_COMPILER_H -#define GD_COMPILER_H +#ifndef GDSCRIPT_COMPILER_H +#define GDSCRIPT_COMPILER_H -#include "gd_parser.h" -#include "gd_script.h" +#include "gdscript.h" +#include "gdscript_parser.h" -class GDCompiler { +class GDScriptCompiler { - const GDParser *parser; + const GDScriptParser *parser; struct CodeGen { GDScript *script; - const GDParser::ClassNode *class_node; - const GDParser::FunctionNode *function_node; + const GDScriptParser::ClassNode *class_node; + const GDScriptParser::FunctionNode *function_node; bool debug_stack; List<Map<StringName, int> > stack_id_stack; Map<StringName, int> stack_identifiers; - List<GDFunction::StackDebug> stack_debug; + List<GDScriptFunction::StackDebug> stack_debug; List<Map<StringName, int> > block_identifier_stack; Map<StringName, int> block_identifiers; @@ -54,7 +54,7 @@ class GDCompiler { stack_identifiers[p_id] = p_stackpos; if (debug_stack) { block_identifiers[p_id] = p_stackpos; - GDFunction::StackDebug sd; + GDScriptFunction::StackDebug sd; sd.added = true; sd.line = current_line; sd.identifier = p_id; @@ -79,7 +79,7 @@ class GDCompiler { if (debug_stack) { for (Map<StringName, int>::Element *E = block_identifiers.front(); E; E = E->next()) { - GDFunction::StackDebug sd; + GDScriptFunction::StackDebug sd; sd.added = false; sd.identifier = E->key(); sd.line = current_line; @@ -129,29 +129,29 @@ class GDCompiler { bool _is_class_member_property(CodeGen &codegen, const StringName &p_name); bool _is_class_member_property(GDScript *owner, const StringName &p_name); - void _set_error(const String &p_error, const GDParser::Node *p_node); + void _set_error(const String &p_error, const GDScriptParser::Node *p_node); - bool _create_unary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level); - bool _create_binary_operator(CodeGen &codegen, const GDParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false); + bool _create_unary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level); + bool _create_binary_operator(CodeGen &codegen, const GDScriptParser::OperatorNode *on, Variant::Operator op, int p_stack_level, bool p_initializer = false); - int _parse_assign_right_expression(CodeGen &codegen, const GDParser::OperatorNode *p_expression, int p_stack_level); - int _parse_expression(CodeGen &codegen, const GDParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false); - Error _parse_block(CodeGen &codegen, const GDParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1); - Error _parse_function(GDScript *p_script, const GDParser::ClassNode *p_class, const GDParser::FunctionNode *p_func, bool p_for_ready = false); - Error _parse_class(GDScript *p_script, GDScript *p_owner, const GDParser::ClassNode *p_class, bool p_keep_state); + int _parse_assign_right_expression(CodeGen &codegen, const GDScriptParser::OperatorNode *p_expression, int p_stack_level); + int _parse_expression(CodeGen &codegen, const GDScriptParser::Node *p_expression, int p_stack_level, bool p_root = false, bool p_initializer = false); + Error _parse_block(CodeGen &codegen, const GDScriptParser::BlockNode *p_block, int p_stack_level = 0, int p_break_addr = -1, int p_continue_addr = -1); + Error _parse_function(GDScript *p_script, const GDScriptParser::ClassNode *p_class, const GDScriptParser::FunctionNode *p_func, bool p_for_ready = false); + Error _parse_class(GDScript *p_script, GDScript *p_owner, const GDScriptParser::ClassNode *p_class, bool p_keep_state); int err_line; int err_column; StringName source; String error; public: - Error compile(const GDParser *p_parser, GDScript *p_script, bool p_keep_state = false); + Error compile(const GDScriptParser *p_parser, GDScript *p_script, bool p_keep_state = false); String get_error() const; int get_error_line() const; int get_error_column() const; - GDCompiler(); + GDScriptCompiler(); }; -#endif // COMPILER_H +#endif // GDSCRIPT_COMPILER_H diff --git a/modules/gdscript/gd_editor.cpp b/modules/gdscript/gdscript_editor.cpp index d9b10ff3fa..a74b8a8483 100644 --- a/modules/gdscript/gd_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_editor.cpp */ +/* gdscript_editor.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,10 +27,10 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "gd_script.h" +#include "gdscript.h" #include "editor/editor_settings.h" -#include "gd_compiler.h" +#include "gdscript_compiler.h" #include "global_constants.h" #include "os/file_access.h" #include "project_settings.h" @@ -92,7 +92,7 @@ void GDScriptLanguage::make_template(const String &p_class_name, const String &p bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int &r_col_error, String &r_test_error, const String &p_path, List<String> *r_functions) const { - GDParser parser; + GDScriptParser parser; Error err = parser.parse(p_script, p_path.get_base_dir(), true, p_path); if (err) { @@ -102,10 +102,10 @@ bool GDScriptLanguage::validate(const String &p_script, int &r_line_error, int & return false; } else { - const GDParser::Node *root = parser.get_parse_tree(); - ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, false); + const GDScriptParser::Node *root = parser.get_parse_tree(); + ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, false); - const GDParser::ClassNode *cl = static_cast<const GDParser::ClassNode *>(root); + const GDScriptParser::ClassNode *cl = static_cast<const GDScriptParser::ClassNode *>(root); Map<int, String> funcs; for (int i = 0; i < cl->functions.size(); i++) { @@ -138,16 +138,16 @@ bool GDScriptLanguage::supports_builtin_mode() const { int GDScriptLanguage::find_function(const String &p_function, const String &p_code) const { - GDTokenizerText tokenizer; + GDScriptTokenizerText tokenizer; tokenizer.set_code(p_code); int indent = 0; - while (tokenizer.get_token() != GDTokenizer::TK_EOF && tokenizer.get_token() != GDTokenizer::TK_ERROR) { + while (tokenizer.get_token() != GDScriptTokenizer::TK_EOF && tokenizer.get_token() != GDScriptTokenizer::TK_ERROR) { - if (tokenizer.get_token() == GDTokenizer::TK_NEWLINE) { + if (tokenizer.get_token() == GDScriptTokenizer::TK_NEWLINE) { indent = tokenizer.get_token_line_indent(); } - //print_line("TOKEN: "+String(GDTokenizer::get_token_name(tokenizer.get_token()))); - if (indent == 0 && tokenizer.get_token() == GDTokenizer::TK_PR_FUNCTION && tokenizer.get_token(1) == GDTokenizer::TK_IDENTIFIER) { + //print_line("TOKEN: "+String(GDScriptTokenizer::get_token_name(tokenizer.get_token()))); + if (indent == 0 && tokenizer.get_token() == GDScriptTokenizer::TK_PR_FUNCTION && tokenizer.get_token(1) == GDScriptTokenizer::TK_IDENTIFIER) { String identifier = tokenizer.get_token_identifier(1); if (identifier == p_function) { @@ -155,7 +155,7 @@ int GDScriptLanguage::find_function(const String &p_function, const String &p_co } } tokenizer.advance(); - //print_line("NEXT: "+String(GDTokenizer::get_token_name(tokenizer.get_token()))); + //print_line("NEXT: "+String(GDScriptTokenizer::get_token_name(tokenizer.get_token()))); } return -1; } @@ -245,7 +245,7 @@ void GDScriptLanguage::debug_get_stack_level_locals(int p_level, List<String> *p ERR_FAIL_INDEX(p_level, _debug_call_stack_pos); int l = _debug_call_stack_pos - p_level - 1; - GDFunction *f = _call_stack[l].function; + GDScriptFunction *f = _call_stack[l].function; List<Pair<StringName, int> > locals; @@ -264,7 +264,7 @@ void GDScriptLanguage::debug_get_stack_level_members(int p_level, List<String> * ERR_FAIL_INDEX(p_level, _debug_call_stack_pos); int l = _debug_call_stack_pos - p_level - 1; - GDInstance *instance = _call_stack[l].instance; + GDScriptInstance *instance = _call_stack[l].instance; if (!instance) return; @@ -298,9 +298,9 @@ void GDScriptLanguage::get_recognized_extensions(List<String> *p_extensions) con void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const { - for (int i = 0; i < GDFunctions::FUNC_MAX; i++) { + for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) { - p_functions->push_back(GDFunctions::get_info(GDFunctions::Function(i))); + p_functions->push_back(GDScriptFunctions::get_info(GDScriptFunctions::Function(i))); } //not really "functions", but.. @@ -318,7 +318,7 @@ void GDScriptLanguage::get_public_functions(List<MethodInfo> *p_functions) const mi.arguments.push_back(PropertyInfo(Variant::STRING, "signal")); mi.default_arguments.push_back(Variant::NIL); mi.default_arguments.push_back(Variant::STRING); - mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "GDFunctionState"); + mi.return_val = PropertyInfo(Variant::OBJECT, "", PROPERTY_HINT_RESOURCE_TYPE, "GDScriptFunctionState"); p_functions->push_back(mi); } { @@ -337,6 +337,11 @@ void GDScriptLanguage::get_public_constants(List<Pair<String, Variant> > *p_cons pi.second = Math_PI; p_constants->push_back(pi); + Pair<String, Variant> tau; + tau.first = "TAU"; + tau.second = Math_TAU; + p_constants->push_back(tau); + Pair<String, Variant> infinity; infinity.first = "INF"; infinity.second = Math_INF; @@ -360,14 +365,14 @@ String GDScriptLanguage::make_function(const String &p_class, const String &p_na } s += " "; } - s += "):\n\tpass # replace with function body\n"; + s += "):\n" + _get_indentation() + "pass # replace with function body\n"; return s; } #if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED) -struct GDCompletionIdentifier { +struct GDScriptCompletionIdentifier { String enumeration; StringName obj_type; @@ -376,17 +381,17 @@ struct GDCompletionIdentifier { Variant value; //im case there is a value, also return it }; -static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) { +static GDScriptCompletionIdentifier _get_type_from_variant(const Variant &p_variant, bool p_allow_gdnative_class = false) { - GDCompletionIdentifier t; + GDScriptCompletionIdentifier t; t.type = p_variant.get_type(); t.value = p_variant; if (p_variant.get_type() == Variant::OBJECT) { Object *obj = p_variant; if (obj) { - if (p_allow_gdnative_class && Object::cast_to<GDNativeClass>(obj)) { - t.obj_type = Object::cast_to<GDNativeClass>(obj)->get_name(); + if (p_allow_gdnative_class && Object::cast_to<GDScriptNativeClass>(obj)) { + t.obj_type = Object::cast_to<GDScriptNativeClass>(obj)->get_name(); t.value = Variant(); } else { @@ -397,9 +402,9 @@ static GDCompletionIdentifier _get_type_from_variant(const Variant &p_variant, b return t; } -static GDCompletionIdentifier _get_type_from_pinfo(const PropertyInfo &p_info) { +static GDScriptCompletionIdentifier _get_type_from_pinfo(const PropertyInfo &p_info) { - GDCompletionIdentifier t; + GDScriptCompletionIdentifier t; t.type = p_info.type; if (p_info.hint == PROPERTY_HINT_RESOURCE_TYPE) { t.obj_type = p_info.hint_string; @@ -407,23 +412,23 @@ static GDCompletionIdentifier _get_type_from_pinfo(const PropertyInfo &p_info) { return t; } -struct GDCompletionContext { +struct GDScriptCompletionContext { - const GDParser::ClassNode *_class; - const GDParser::FunctionNode *function; - const GDParser::BlockNode *block; + const GDScriptParser::ClassNode *_class; + const GDScriptParser::FunctionNode *function; + const GDScriptParser::BlockNode *block; Object *base; String base_path; }; -static Ref<Reference> _get_parent_class(GDCompletionContext &context) { +static Ref<Reference> _get_parent_class(GDScriptCompletionContext &context) { if (context._class->extends_used) { //do inheritance String path = context._class->extends_file; Ref<GDScript> script; - Ref<GDNativeClass> native; + Ref<GDScriptNativeClass> native; if (path != "") { //path (and optionally subclasses) @@ -493,17 +498,17 @@ static Ref<Reference> _get_parent_class(GDCompletionContext &context) { return Ref<Reference>(); } -static GDCompletionIdentifier _get_native_class(GDCompletionContext &context) { +static GDScriptCompletionIdentifier _get_native_class(GDScriptCompletionContext &context) { //eeh... - GDCompletionIdentifier id; + GDScriptCompletionIdentifier id; id.type = Variant::NIL; REF pc = _get_parent_class(context); if (!pc.is_valid()) { return id; } - Ref<GDNativeClass> nc = pc; + Ref<GDScriptNativeClass> nc = pc; Ref<GDScript> s = pc; if (s.is_null() && nc.is_null()) { @@ -524,28 +529,28 @@ static GDCompletionIdentifier _get_native_class(GDCompletionContext &context) { return id; } -static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing); +static bool _guess_identifier_type(GDScriptCompletionContext &context, int p_line, const StringName &p_identifier, GDScriptCompletionIdentifier &r_type, bool p_for_indexing); -static bool _guess_expression_type(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, GDCompletionIdentifier &r_type, bool p_for_indexing = false) { +static bool _guess_expression_type(GDScriptCompletionContext &context, const GDScriptParser::Node *p_node, int p_line, GDScriptCompletionIdentifier &r_type, bool p_for_indexing = false) { - if (p_node->type == GDParser::Node::TYPE_CONSTANT) { + if (p_node->type == GDScriptParser::Node::TYPE_CONSTANT) { - const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(p_node); + const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(p_node); r_type = _get_type_from_variant(cn->value); return true; - } else if (p_node->type == GDParser::Node::TYPE_DICTIONARY) { + } else if (p_node->type == GDScriptParser::Node::TYPE_DICTIONARY) { r_type.type = Variant::DICTIONARY; //what the heck, fill it anyway - const GDParser::DictionaryNode *an = static_cast<const GDParser::DictionaryNode *>(p_node); + const GDScriptParser::DictionaryNode *an = static_cast<const GDScriptParser::DictionaryNode *>(p_node); Dictionary d; for (int i = 0; i < an->elements.size(); i++) { - GDCompletionIdentifier k; + GDScriptCompletionIdentifier k; if (_guess_expression_type(context, an->elements[i].key, p_line, k) && k.value.get_type() != Variant::NIL) { - GDCompletionIdentifier v; + GDScriptCompletionIdentifier v; if (_guess_expression_type(context, an->elements[i].value, p_line, v)) { d[k.value] = v.value; } @@ -553,15 +558,15 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: } r_type.value = d; return true; - } else if (p_node->type == GDParser::Node::TYPE_ARRAY) { + } else if (p_node->type == GDScriptParser::Node::TYPE_ARRAY) { r_type.type = Variant::ARRAY; //what the heck, fill it anyway - const GDParser::ArrayNode *an = static_cast<const GDParser::ArrayNode *>(p_node); + const GDScriptParser::ArrayNode *an = static_cast<const GDScriptParser::ArrayNode *>(p_node); Array arr; arr.resize(an->elements.size()); for (int i = 0; i < an->elements.size(); i++) { - GDCompletionIdentifier ci; + GDScriptCompletionIdentifier ci; if (_guess_expression_type(context, an->elements[i], p_line, ci)) { arr[i] = ci.value; } @@ -569,44 +574,44 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: r_type.value = arr; return true; - } else if (p_node->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) { + } else if (p_node->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) { - MethodInfo mi = GDFunctions::get_info(static_cast<const GDParser::BuiltInFunctionNode *>(p_node)->function); + MethodInfo mi = GDScriptFunctions::get_info(static_cast<const GDScriptParser::BuiltInFunctionNode *>(p_node)->function); r_type = _get_type_from_pinfo(mi.return_val); return true; - } else if (p_node->type == GDParser::Node::TYPE_IDENTIFIER) { + } else if (p_node->type == GDScriptParser::Node::TYPE_IDENTIFIER) { - return _guess_identifier_type(context, p_line - 1, static_cast<const GDParser::IdentifierNode *>(p_node)->name, r_type, p_for_indexing); - } else if (p_node->type == GDParser::Node::TYPE_SELF) { + return _guess_identifier_type(context, p_line - 1, static_cast<const GDScriptParser::IdentifierNode *>(p_node)->name, r_type, p_for_indexing); + } else if (p_node->type == GDScriptParser::Node::TYPE_SELF) { //eeh... r_type = _get_native_class(context); return r_type.type != Variant::NIL; - } else if (p_node->type == GDParser::Node::TYPE_OPERATOR) { + } else if (p_node->type == GDScriptParser::Node::TYPE_OPERATOR) { - const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_node); - if (op->op == GDParser::OperatorNode::OP_CALL) { + const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_node); + if (op->op == GDScriptParser::OperatorNode::OP_CALL) { - if (op->arguments[0]->type == GDParser::Node::TYPE_TYPE) { + if (op->arguments[0]->type == GDScriptParser::Node::TYPE_TYPE) { - const GDParser::TypeNode *tn = static_cast<const GDParser::TypeNode *>(op->arguments[0]); + const GDScriptParser::TypeNode *tn = static_cast<const GDScriptParser::TypeNode *>(op->arguments[0]); r_type.type = tn->vtype; return true; - } else if (op->arguments[0]->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) { + } else if (op->arguments[0]->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) { - const GDParser::BuiltInFunctionNode *bin = static_cast<const GDParser::BuiltInFunctionNode *>(op->arguments[0]); + const GDScriptParser::BuiltInFunctionNode *bin = static_cast<const GDScriptParser::BuiltInFunctionNode *>(op->arguments[0]); return _guess_expression_type(context, bin, p_line, r_type); - } else if (op->arguments.size() > 1 && op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) { + } else if (op->arguments.size() > 1 && op->arguments[1]->type == GDScriptParser::Node::TYPE_IDENTIFIER) { - StringName id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name; + StringName id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name; - if (op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && String(id) == "new") { + if (op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER && String(id) == "new") { //shortcut - StringName identifier = static_cast<const GDParser::IdentifierNode *>(op->arguments[0])->name; + StringName identifier = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0])->name; if (ClassDB::class_exists(identifier)) { r_type.type = Variant::OBJECT; @@ -616,7 +621,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: } } - GDCompletionIdentifier base; + GDScriptCompletionIdentifier base; if (!_guess_expression_type(context, op->arguments[0], p_line, base)) return false; @@ -625,8 +630,8 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: if (id.operator String() == "new" && base.value.get_type() == Variant::OBJECT) { Object *obj = base.value; - if (obj && Object::cast_to<GDNativeClass>(obj)) { - GDNativeClass *gdnc = Object::cast_to<GDNativeClass>(obj); + if (obj && Object::cast_to<GDScriptNativeClass>(obj)) { + GDScriptNativeClass *gdnc = Object::cast_to<GDScriptNativeClass>(obj); r_type.type = Variant::OBJECT; r_type.value = Variant(); r_type.obj_type = gdnc->get_name(); @@ -657,7 +662,7 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: bool all_valid = true; Vector<Variant> args; for (int i = 2; i < op->arguments.size(); i++) { - GDCompletionIdentifier arg; + GDScriptCompletionIdentifier arg; if (_guess_expression_type(context, op->arguments[i], p_line, arg)) { if (arg.value.get_type() != Variant::NIL && arg.value.get_type() != Variant::OBJECT) { // calling with object seems dangerous, i don' t know @@ -780,15 +785,15 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: } } } - } else if (op->op == GDParser::OperatorNode::OP_INDEX || op->op == GDParser::OperatorNode::OP_INDEX_NAMED) { + } else if (op->op == GDScriptParser::OperatorNode::OP_INDEX || op->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) { - GDCompletionIdentifier p1; - GDCompletionIdentifier p2; + GDScriptCompletionIdentifier p1; + GDScriptCompletionIdentifier p2; - if (op->op == GDParser::OperatorNode::OP_INDEX_NAMED) { + if (op->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) { - if (op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) { - String id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1])->name; + if (op->arguments[1]->type == GDScriptParser::Node::TYPE_IDENTIFIER) { + String id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1])->name; p2.type = Variant::STRING; p2.value = id; } @@ -802,9 +807,9 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: } } - if (op->arguments[0]->type == GDParser::Node::TYPE_ARRAY) { + if (op->arguments[0]->type == GDScriptParser::Node::TYPE_ARRAY) { - const GDParser::ArrayNode *an = static_cast<const GDParser::ArrayNode *>(op->arguments[0]); + const GDScriptParser::ArrayNode *an = static_cast<const GDScriptParser::ArrayNode *>(op->arguments[0]); if (p2.value.is_num()) { int index = p2.value; if (index < 0 || index >= an->elements.size()) @@ -812,16 +817,16 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: return _guess_expression_type(context, an->elements[index], p_line, r_type); } - } else if (op->arguments[0]->type == GDParser::Node::TYPE_DICTIONARY) { + } else if (op->arguments[0]->type == GDScriptParser::Node::TYPE_DICTIONARY) { - const GDParser::DictionaryNode *dn = static_cast<const GDParser::DictionaryNode *>(op->arguments[0]); + const GDScriptParser::DictionaryNode *dn = static_cast<const GDScriptParser::DictionaryNode *>(op->arguments[0]); if (p2.value.get_type() == Variant::NIL) return false; for (int i = 0; i < dn->elements.size(); i++) { - GDCompletionIdentifier k; + GDScriptCompletionIdentifier k; if (!_guess_expression_type(context, dn->elements[i].key, p_line, k)) { @@ -853,9 +858,9 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: StringName base_type = p1.obj_type; - if (p1.obj_type == "GDNativeClass") { + if (p1.obj_type == "GDScriptNativeClass") { //native enum - Ref<GDNativeClass> gdn = p1.value; + Ref<GDScriptNativeClass> gdn = p1.value; if (gdn.is_valid()) { base_type = gdn->get_name(); @@ -916,24 +921,24 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: Variant::Operator vop = Variant::OP_MAX; switch (op->op) { - case GDParser::OperatorNode::OP_ADD: vop = Variant::OP_ADD; break; - case GDParser::OperatorNode::OP_SUB: vop = Variant::OP_SUBTRACT; break; - case GDParser::OperatorNode::OP_MUL: vop = Variant::OP_MULTIPLY; break; - case GDParser::OperatorNode::OP_DIV: vop = Variant::OP_DIVIDE; break; - case GDParser::OperatorNode::OP_MOD: vop = Variant::OP_MODULE; break; - case GDParser::OperatorNode::OP_SHIFT_LEFT: vop = Variant::OP_SHIFT_LEFT; break; - case GDParser::OperatorNode::OP_SHIFT_RIGHT: vop = Variant::OP_SHIFT_RIGHT; break; - case GDParser::OperatorNode::OP_BIT_AND: vop = Variant::OP_BIT_AND; break; - case GDParser::OperatorNode::OP_BIT_OR: vop = Variant::OP_BIT_OR; break; - case GDParser::OperatorNode::OP_BIT_XOR: vop = Variant::OP_BIT_XOR; break; + case GDScriptParser::OperatorNode::OP_ADD: vop = Variant::OP_ADD; break; + case GDScriptParser::OperatorNode::OP_SUB: vop = Variant::OP_SUBTRACT; break; + case GDScriptParser::OperatorNode::OP_MUL: vop = Variant::OP_MULTIPLY; break; + case GDScriptParser::OperatorNode::OP_DIV: vop = Variant::OP_DIVIDE; break; + case GDScriptParser::OperatorNode::OP_MOD: vop = Variant::OP_MODULE; break; + case GDScriptParser::OperatorNode::OP_SHIFT_LEFT: vop = Variant::OP_SHIFT_LEFT; break; + case GDScriptParser::OperatorNode::OP_SHIFT_RIGHT: vop = Variant::OP_SHIFT_RIGHT; break; + case GDScriptParser::OperatorNode::OP_BIT_AND: vop = Variant::OP_BIT_AND; break; + case GDScriptParser::OperatorNode::OP_BIT_OR: vop = Variant::OP_BIT_OR; break; + case GDScriptParser::OperatorNode::OP_BIT_XOR: vop = Variant::OP_BIT_XOR; break; default: {} } if (vop == Variant::OP_MAX) return false; - GDCompletionIdentifier p1; - GDCompletionIdentifier p2; + GDScriptCompletionIdentifier p1; + GDScriptCompletionIdentifier p2; if (op->arguments[0]) { if (!_guess_expression_type(context, op->arguments[0], p_line, p1)) { @@ -980,15 +985,15 @@ static bool _guess_expression_type(GDCompletionContext &context, const GDParser: return false; } -static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type) { +static bool _guess_identifier_type_in_block(GDScriptCompletionContext &context, int p_line, const StringName &p_identifier, GDScriptCompletionIdentifier &r_type) { - if (context.block->if_condition && context.block->if_condition->type == GDParser::Node::TYPE_OPERATOR && static_cast<const GDParser::OperatorNode *>(context.block->if_condition)->op == GDParser::OperatorNode::OP_IS) { + if (context.block->if_condition && context.block->if_condition->type == GDScriptParser::Node::TYPE_OPERATOR && static_cast<const GDScriptParser::OperatorNode *>(context.block->if_condition)->op == GDScriptParser::OperatorNode::OP_IS) { //is used, check if identifier is in there! this helps resolve in blocks that are (if (identifier is value)): which are very common.. //super dirty hack, but very useful //credit: Zylann //TODO: this could be hacked to detect ANDed conditions too.. - const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(context.block->if_condition); - if (op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER && static_cast<const GDParser::IdentifierNode *>(op->arguments[0])->name == p_identifier) { + const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(context.block->if_condition); + if (op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER && static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0])->name == p_identifier) { //bingo if (_guess_expression_type(context, op->arguments[1], op->line, r_type)) { return true; @@ -996,7 +1001,7 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_ } } - GDCompletionIdentifier gdi = _get_native_class(context); + GDScriptCompletionIdentifier gdi = _get_native_class(context); if (gdi.obj_type != StringName()) { bool valid; Variant::Type t = ClassDB::get_property_type(gdi.obj_type, p_identifier, &valid); @@ -1022,7 +1027,7 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_ } } - const GDParser::Node *last_assign = NULL; + const GDScriptParser::Node *last_assign = NULL; int last_assign_line = -1; for (int i = 0; i < context.block->statements.size(); i++) { @@ -1030,9 +1035,9 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_ if (context.block->statements[i]->line > p_line) continue; - if (context.block->statements[i]->type == GDParser::BlockNode::TYPE_LOCAL_VAR) { + if (context.block->statements[i]->type == GDScriptParser::BlockNode::TYPE_LOCAL_VAR) { - const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(context.block->statements[i]); + const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(context.block->statements[i]); if (lv->assign && lv->name == p_identifier) { @@ -1041,13 +1046,13 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_ } } - if (context.block->statements[i]->type == GDParser::BlockNode::TYPE_OPERATOR) { - const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(context.block->statements[i]); - if (op->op == GDParser::OperatorNode::OP_ASSIGN) { + if (context.block->statements[i]->type == GDScriptParser::BlockNode::TYPE_OPERATOR) { + const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(context.block->statements[i]); + if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) { - if (op->arguments.size() && op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER) { + if (op->arguments.size() && op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER) { - const GDParser::IdentifierNode *id = static_cast<const GDParser::IdentifierNode *>(op->arguments[0]); + const GDScriptParser::IdentifierNode *id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0]); if (id->name == p_identifier) { @@ -1060,7 +1065,7 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_ } //use the last assignment, (then backwards?) - if (last_assign) { + if (last_assign && last_assign_line != p_line) { return _guess_expression_type(context, last_assign, last_assign_line, r_type); } @@ -1068,9 +1073,9 @@ static bool _guess_identifier_type_in_block(GDCompletionContext &context, int p_ return false; } -static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &context, int p_src_line, const StringName &p_identifier, const StringName &p_function, GDCompletionIdentifier &r_type) { +static bool _guess_identifier_from_assignment_in_function(GDScriptCompletionContext &context, int p_src_line, const StringName &p_identifier, const StringName &p_function, GDScriptCompletionIdentifier &r_type) { - const GDParser::FunctionNode *func = NULL; + const GDScriptParser::FunctionNode *func = NULL; for (int i = 0; i < context._class->functions.size(); i++) { if (context._class->functions[i]->name == p_function) { func = context._class->functions[i]; @@ -1087,13 +1092,13 @@ static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &c break; } - if (func->body->statements[i]->type == GDParser::BlockNode::TYPE_OPERATOR) { - const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(func->body->statements[i]); - if (op->op == GDParser::OperatorNode::OP_ASSIGN) { + if (func->body->statements[i]->type == GDScriptParser::BlockNode::TYPE_OPERATOR) { + const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(func->body->statements[i]); + if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) { - if (op->arguments.size() && op->arguments[0]->type == GDParser::Node::TYPE_IDENTIFIER) { + if (op->arguments.size() && op->arguments[0]->type == GDScriptParser::Node::TYPE_IDENTIFIER) { - const GDParser::IdentifierNode *id = static_cast<const GDParser::IdentifierNode *>(op->arguments[0]); + const GDScriptParser::IdentifierNode *id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[0]); if (id->name == p_identifier) { @@ -1107,15 +1112,15 @@ static bool _guess_identifier_from_assignment_in_function(GDCompletionContext &c return false; } -static bool _guess_identifier_type(GDCompletionContext &context, int p_line, const StringName &p_identifier, GDCompletionIdentifier &r_type, bool p_for_indexing) { +static bool _guess_identifier_type(GDScriptCompletionContext &context, int p_line, const StringName &p_identifier, GDScriptCompletionIdentifier &r_type, bool p_for_indexing) { //go to block first - const GDParser::BlockNode *block = context.block; + const GDScriptParser::BlockNode *block = context.block; while (block) { - GDCompletionContext c = context; + GDScriptCompletionContext c = context; c.block = block; if (_guess_identifier_type_in_block(c, p_line, p_identifier, r_type)) { @@ -1139,7 +1144,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con } if (argindex != -1) { - GDCompletionIdentifier id = _get_native_class(context); + GDScriptCompletionIdentifier id = _get_native_class(context); if (id.type == Variant::OBJECT && id.obj_type != StringName()) { //this kinda sucks but meh @@ -1177,8 +1182,8 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con if (context._class->constant_expressions[i].identifier == p_identifier) { - ERR_FAIL_COND_V(context._class->constant_expressions[i].expression->type != GDParser::Node::TYPE_CONSTANT, false); - r_type = _get_type_from_variant(static_cast<const GDParser::ConstantNode *>(context._class->constant_expressions[i].expression)->value); + ERR_FAIL_COND_V(context._class->constant_expressions[i].expression->type != GDScriptParser::Node::TYPE_CONSTANT, false); + r_type = _get_type_from_variant(static_cast<const GDScriptParser::ConstantNode *>(context._class->constant_expressions[i].expression)->value); return true; } } @@ -1194,6 +1199,8 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con r_type = _get_type_from_pinfo(context._class->variables[i]._export); return true; } else if (context._class->variables[i].expression) { + if (p_line <= context._class->variables[i].line) + return false; bool rtype = _guess_expression_type(context, context._class->variables[i].expression, context._class->variables[i].line, r_type); if (rtype && r_type.type != Variant::NIL) @@ -1268,7 +1275,7 @@ static bool _guess_identifier_type(GDCompletionContext &context, int p_line, con return false; } -static void _find_identifiers_in_block(GDCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) { +static void _find_identifiers_in_block(GDScriptCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) { if (p_only_functions) return; @@ -1278,15 +1285,15 @@ static void _find_identifiers_in_block(GDCompletionContext &context, int p_line, if (context.block->statements[i]->line > p_line) continue; - if (context.block->statements[i]->type == GDParser::BlockNode::TYPE_LOCAL_VAR) { + if (context.block->statements[i]->type == GDScriptParser::BlockNode::TYPE_LOCAL_VAR) { - const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(context.block->statements[i]); + const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(context.block->statements[i]); result.insert(lv->name.operator String()); } } } -static void _find_identifiers_in_class(GDCompletionContext &context, bool p_static, bool p_only_functions, Set<String> &result) { +static void _find_identifiers_in_class(GDScriptCompletionContext &context, bool p_static, bool p_only_functions, Set<String> &result) { if (!p_static && !p_only_functions) { @@ -1329,7 +1336,7 @@ static void _find_identifiers_in_class(GDCompletionContext &context, bool p_stat while (true) { Ref<GDScript> script = base; - Ref<GDNativeClass> nc = base; + Ref<GDScriptNativeClass> nc = base; if (script.is_valid()) { if (!p_static && !p_only_functions) { @@ -1344,7 +1351,7 @@ static void _find_identifiers_in_class(GDCompletionContext &context, bool p_stat } } - for (const Map<StringName, GDFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) { + for (const Map<StringName, GDScriptFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) { if (!p_static || E->get()->is_static()) { if (E->get()->get_argument_count()) result.insert(E->key().operator String() + "("); @@ -1403,13 +1410,13 @@ static void _find_identifiers_in_class(GDCompletionContext &context, bool p_stat } } -static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) { +static void _find_identifiers(GDScriptCompletionContext &context, int p_line, bool p_only_functions, Set<String> &result) { - const GDParser::BlockNode *block = context.block; + const GDScriptParser::BlockNode *block = context.block; if (context.function) { - const GDParser::FunctionNode *f = context.function; + const GDScriptParser::FunctionNode *f = context.function; for (int i = 0; i < f->arguments.size(); i++) { result.insert(f->arguments[i].operator String()); @@ -1418,19 +1425,19 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o while (block) { - GDCompletionContext c = context; + GDScriptCompletionContext c = context; c.block = block; _find_identifiers_in_block(c, p_line, p_only_functions, result); block = block->parent_block; } - const GDParser::ClassNode *clss = context._class; + const GDScriptParser::ClassNode *clss = context._class; bool _static = context.function && context.function->_static; while (clss) { - GDCompletionContext c = context; + GDScriptCompletionContext c = context; c._class = clss; c.block = NULL; c.function = NULL; @@ -1438,9 +1445,9 @@ static void _find_identifiers(GDCompletionContext &context, int p_line, bool p_o clss = clss->owner; } - for (int i = 0; i < GDFunctions::FUNC_MAX; i++) { + for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) { - result.insert(GDFunctions::get_func_name(GDFunctions::Function(i))); + result.insert(GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i))); } static const char *_type_names[Variant::VARIANT_MAX] = { @@ -1494,7 +1501,7 @@ static String _get_visual_datatype(const PropertyInfo &p_info, bool p_isarg = tr return Variant::get_type_name(p_info.type); } -static void _make_function_hint(const GDParser::FunctionNode *p_func, int p_argidx, String &arghint) { +static void _make_function_hint(const GDScriptParser::FunctionNode *p_func, int p_argidx, String &arghint) { arghint = "func " + p_func->name + "("; for (int i = 0; i < p_func->arguments.size(); i++) { @@ -1514,11 +1521,11 @@ static void _make_function_hint(const GDParser::FunctionNode *p_func, int p_argi if (defidx >= 0 && defidx < p_func->default_values.size()) { - if (p_func->default_values[defidx]->type == GDParser::Node::TYPE_OPERATOR) { + if (p_func->default_values[defidx]->type == GDScriptParser::Node::TYPE_OPERATOR) { - const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_func->default_values[defidx]); - if (op->op == GDParser::OperatorNode::OP_ASSIGN) { - const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(op->arguments[1]); + const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_func->default_values[defidx]); + if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) { + const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(op->arguments[1]); arghint += "=" + cn->value.get_construct_string(); } } else { @@ -1546,7 +1553,7 @@ void get_directory_contents(EditorFileSystemDirectory *p_dir, Set<String> &r_lis } } -static void _find_type_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, const StringName &p_method, const GDCompletionIdentifier &id, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) { +static void _find_type_arguments(GDScriptCompletionContext &context, const GDScriptParser::Node *p_node, int p_line, const StringName &p_method, const GDScriptCompletionIdentifier &id, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) { //print_line("find type arguments?"); if (id.type == Variant::OBJECT && id.obj_type != StringName()) { @@ -1565,7 +1572,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N if (scr) { while (scr) { - for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { + for (const Map<StringName, GDScriptFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { if (E->get()->is_static() && p_method == E->get()->get_name()) { arghint = "static func " + String(p_method) + "("; for (int i = 0; i < E->get()->get_argument_count(); i++) { @@ -1622,7 +1629,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N if (code != "") { //if there is code, parse it. This way is slower but updates in real-time - GDParser p; + GDScriptParser p; //Error parse(const String& p_code, const String& p_base_path="", bool p_just_validate=false,const String& p_self_path="",bool p_for_completion=false); Error err = p.parse(scr->get_source_code(), scr->get_path().get_base_dir(), true, "", false); @@ -1630,13 +1637,13 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N if (err == OK) { //print_line("checking the functions..."); //only if ok, otherwise use what is cached on the script - //GDParser::ClassNode *base = p. - const GDParser::Node *root = p.get_parse_tree(); - ERR_FAIL_COND(root->type != GDParser::Node::TYPE_CLASS); + //GDScriptParser::ClassNode *base = p. + const GDScriptParser::Node *root = p.get_parse_tree(); + ERR_FAIL_COND(root->type != GDScriptParser::Node::TYPE_CLASS); - const GDParser::ClassNode *cl = static_cast<const GDParser::ClassNode *>(root); + const GDScriptParser::ClassNode *cl = static_cast<const GDScriptParser::ClassNode *>(root); - const GDParser::FunctionNode *func = NULL; + const GDScriptParser::FunctionNode *func = NULL; bool st = false; for (int i = 0; i < cl->functions.size(); i++) { @@ -1674,10 +1681,10 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N int defidx = deffrom - i; - if (defidx >= 0 && defidx < func->default_values.size() && func->default_values[defidx]->type == GDParser::Node::TYPE_OPERATOR) { - const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(func->default_values[defidx]); - if (op->op == GDParser::OperatorNode::OP_ASSIGN) { - const GDParser::ConstantNode *cn = static_cast<const GDParser::ConstantNode *>(op->arguments[1]); + if (defidx >= 0 && defidx < func->default_values.size() && func->default_values[defidx]->type == GDScriptParser::Node::TYPE_OPERATOR) { + const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(func->default_values[defidx]); + if (op->op == GDScriptParser::OperatorNode::OP_ASSIGN) { + const GDScriptParser::ConstantNode *cn = static_cast<const GDScriptParser::ConstantNode *>(op->arguments[1]); arghint += "=" + cn->value.get_construct_string(); } } @@ -1698,7 +1705,7 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N if (code == "") { - for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { + for (const Map<StringName, GDScriptFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { if (p_method == E->get()->get_name()) { arghint = "func " + String(p_method) + "("; for (int i = 0; i < E->get()->get_argument_count(); i++) { @@ -1807,8 +1814,8 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N } /*if (p_argidx==2) { - ERR_FAIL_COND(p_node->type!=GDParser::Node::TYPE_OPERATOR); - const GDParser::OperatorNode *op=static_cast<const GDParser::OperatorNode *>(p_node); + ERR_FAIL_COND(p_node->type!=GDScriptParser::Node::TYPE_OPERATOR); + const GDScriptParser::OperatorNode *op=static_cast<const GDScriptParser::OperatorNode *>(p_node); if (op->arguments.size()>) }*/ @@ -1883,30 +1890,30 @@ static void _find_type_arguments(GDCompletionContext &context, const GDParser::N } } -static void _find_call_arguments(GDCompletionContext &context, const GDParser::Node *p_node, int p_line, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) { +static void _find_call_arguments(GDScriptCompletionContext &context, const GDScriptParser::Node *p_node, int p_line, int p_argidx, Set<String> &result, bool &r_forced, String &arghint) { - if (!p_node || p_node->type != GDParser::Node::TYPE_OPERATOR) { + if (!p_node || p_node->type != GDScriptParser::Node::TYPE_OPERATOR) { return; } - const GDParser::OperatorNode *op = static_cast<const GDParser::OperatorNode *>(p_node); + const GDScriptParser::OperatorNode *op = static_cast<const GDScriptParser::OperatorNode *>(p_node); - if (op->op != GDParser::OperatorNode::OP_CALL) { + if (op->op != GDScriptParser::OperatorNode::OP_CALL) { return; } - if (op->arguments[0]->type == GDParser::Node::TYPE_BUILT_IN_FUNCTION) { + if (op->arguments[0]->type == GDScriptParser::Node::TYPE_BUILT_IN_FUNCTION) { //complete built-in function - const GDParser::BuiltInFunctionNode *fn = static_cast<const GDParser::BuiltInFunctionNode *>(op->arguments[0]); - MethodInfo mi = GDFunctions::get_info(fn->function); + const GDScriptParser::BuiltInFunctionNode *fn = static_cast<const GDScriptParser::BuiltInFunctionNode *>(op->arguments[0]); + MethodInfo mi = GDScriptFunctions::get_info(fn->function); if (mi.name == "load" && bool(EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths"))) { get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), result); } - arghint = _get_visual_datatype(mi.return_val, false) + " " + GDFunctions::get_func_name(fn->function) + String("("); + arghint = _get_visual_datatype(mi.return_val, false) + " " + GDScriptFunctions::get_func_name(fn->function) + String("("); for (int i = 0; i < mi.arguments.size(); i++) { if (i > 0) arghint += ", "; @@ -1924,9 +1931,9 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N arghint += " "; arghint += ")"; - } else if (op->arguments[0]->type == GDParser::Node::TYPE_TYPE) { + } else if (op->arguments[0]->type == GDScriptParser::Node::TYPE_TYPE) { //complete constructor - const GDParser::TypeNode *tn = static_cast<const GDParser::TypeNode *>(op->arguments[0]); + const GDScriptParser::TypeNode *tn = static_cast<const GDScriptParser::TypeNode *>(op->arguments[0]); List<MethodInfo> mil; Variant::get_constructor_list(tn->vtype, &mil); @@ -1957,11 +1964,11 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N arghint += ")"; } - } else if (op->arguments.size() >= 2 && op->arguments[1]->type == GDParser::Node::TYPE_IDENTIFIER) { + } else if (op->arguments.size() >= 2 && op->arguments[1]->type == GDScriptParser::Node::TYPE_IDENTIFIER) { //make sure identifier exists... - const GDParser::IdentifierNode *id = static_cast<const GDParser::IdentifierNode *>(op->arguments[1]); - if (op->arguments[0]->type == GDParser::Node::TYPE_SELF) { + const GDScriptParser::IdentifierNode *id = static_cast<const GDScriptParser::IdentifierNode *>(op->arguments[1]); + if (op->arguments[0]->type == GDScriptParser::Node::TYPE_SELF) { //self, look up for (int i = 0; i < context._class->static_functions.size(); i++) { @@ -1986,10 +1993,10 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N while (true) { Ref<GDScript> script = base; - Ref<GDNativeClass> nc = base; + Ref<GDScriptNativeClass> nc = base; if (script.is_valid()) { - for (const Map<StringName, GDFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) { + for (const Map<StringName, GDScriptFunction *>::Element *E = script->get_member_functions().front(); E; E = E->next()) { if (E->key() == id->name) { @@ -2031,7 +2038,7 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N if (!(context.function && context.function->_static)) { - GDCompletionIdentifier ci; + GDScriptCompletionIdentifier ci; ci.type = Variant::OBJECT; ci.obj_type = nc->get_name(); if (!context._class->owner) @@ -2056,7 +2063,7 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N } else { //indexed lookup - GDCompletionIdentifier ci; + GDScriptCompletionIdentifier ci; if (_guess_expression_type(context, op->arguments[0], p_line, ci)) { _find_type_arguments(context, p_node, p_line, id->name, ci, p_argidx, result, r_forced, arghint); @@ -2068,13 +2075,13 @@ static void _find_call_arguments(GDCompletionContext &context, const GDParser::N Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base_path, Object *p_owner, List<String> *r_options, bool &r_forced, String &r_call_hint) { - GDParser p; + GDScriptParser p; p.parse(p_code, p_base_path, false, "", true); bool isfunction = false; Set<String> options; r_forced = false; - GDCompletionContext context; + GDScriptCompletionContext context; context._class = p.get_completion_class(); context.block = p.get_completion_block(); context.function = p.get_completion_function(); @@ -2083,9 +2090,9 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base switch (p.get_completion_type()) { - case GDParser::COMPLETION_NONE: { + case GDScriptParser::COMPLETION_NONE: { } break; - case GDParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: { + case GDScriptParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: { List<StringName> constants; Variant::get_numeric_constants_for_type(p.get_completion_built_in_constant(), &constants); for (List<StringName>::Element *E = constants.front(); E; E = E->next()) { @@ -2093,16 +2100,16 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base } } break; - case GDParser::COMPLETION_FUNCTION: + case GDScriptParser::COMPLETION_FUNCTION: isfunction = true; - case GDParser::COMPLETION_IDENTIFIER: { + case GDScriptParser::COMPLETION_IDENTIFIER: { _find_identifiers(context, p.get_completion_line(), isfunction, options); } break; - case GDParser::COMPLETION_PARENT_FUNCTION: { + case GDScriptParser::COMPLETION_PARENT_FUNCTION: { } break; - case GDParser::COMPLETION_GET_NODE: { + case GDScriptParser::COMPLETION_GET_NODE: { if (p_owner) { List<String> opts; @@ -2123,20 +2130,20 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base } } } break; - case GDParser::COMPLETION_METHOD: + case GDScriptParser::COMPLETION_METHOD: isfunction = true; - case GDParser::COMPLETION_INDEX: { + case GDScriptParser::COMPLETION_INDEX: { - const GDParser::Node *node = p.get_completion_node(); - if (node->type != GDParser::Node::TYPE_OPERATOR) + const GDScriptParser::Node *node = p.get_completion_node(); + if (node->type != GDScriptParser::Node::TYPE_OPERATOR) break; - GDCompletionIdentifier t; - if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t, true)) { + GDScriptCompletionIdentifier t; + if (_guess_expression_type(context, static_cast<const GDScriptParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t, true)) { - if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") { + if (t.type == Variant::OBJECT && t.obj_type == "GDScriptNativeClass") { //native enum - Ref<GDNativeClass> gdn = t.value; + Ref<GDScriptNativeClass> gdn = t.value; if (gdn.is_valid()) { StringName cn = gdn->get_name(); List<String> cnames; @@ -2172,7 +2179,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base options.insert(E->key()); } } - for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { + for (const Map<StringName, GDScriptFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { if (E->get()->is_static()) options.insert(E->key()); } @@ -2203,17 +2210,17 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base if (code != "") { //if there is code, parse it. This way is slower but updates in real-time - GDParser p; + GDScriptParser p; Error err = p.parse(scr->get_source_code(), scr->get_path().get_base_dir(), true, "", false); if (err == OK) { //only if ok, otherwise use what is cached on the script - //GDParser::ClassNode *base = p. - const GDParser::Node *root = p.get_parse_tree(); - ERR_FAIL_COND_V(root->type != GDParser::Node::TYPE_CLASS, ERR_PARSE_ERROR); + //GDScriptParser::ClassNode *base = p. + const GDScriptParser::Node *root = p.get_parse_tree(); + ERR_FAIL_COND_V(root->type != GDScriptParser::Node::TYPE_CLASS, ERR_PARSE_ERROR); - const GDParser::ClassNode *cl = static_cast<const GDParser::ClassNode *>(root); + const GDScriptParser::ClassNode *cl = static_cast<const GDScriptParser::ClassNode *>(root); for (int i = 0; i < cl->functions.size(); i++) { @@ -2255,7 +2262,7 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base options.insert(E->key()); } } - for (const Map<StringName, GDFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { + for (const Map<StringName, GDScriptFunction *>::Element *E = scr->get_member_functions().front(); E; E = E->next()) { if (E->get()->get_argument_count()) options.insert(String(E->key()) + "()"); else @@ -2334,13 +2341,13 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base } } break; - case GDParser::COMPLETION_CALL_ARGUMENTS: { + case GDScriptParser::COMPLETION_CALL_ARGUMENTS: { _find_call_arguments(context, p.get_completion_node(), p.get_completion_line(), p.get_completion_argument_index(), options, r_forced, r_call_hint); } break; - case GDParser::COMPLETION_VIRTUAL_FUNC: { + case GDScriptParser::COMPLETION_VIRTUAL_FUNC: { - GDCompletionIdentifier cid = _get_native_class(context); + GDScriptCompletionIdentifier cid = _get_native_class(context); if (cid.obj_type != StringName()) { List<MethodInfo> vm; @@ -2369,11 +2376,11 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base } } } break; - case GDParser::COMPLETION_YIELD: { + case GDScriptParser::COMPLETION_YIELD: { - const GDParser::Node *node = p.get_completion_node(); + const GDScriptParser::Node *node = p.get_completion_node(); - GDCompletionIdentifier t; + GDScriptCompletionIdentifier t; if (!_guess_expression_type(context, node, p.get_completion_line(), t)) break; @@ -2388,15 +2395,15 @@ Error GDScriptLanguage::complete_code(const String &p_code, const String &p_base } } break; - case GDParser::COMPLETION_RESOURCE_PATH: { + case GDScriptParser::COMPLETION_RESOURCE_PATH: { if (EditorSettings::get_singleton()->get("text_editor/completion/complete_file_paths")) get_directory_contents(EditorFileSystem::get_singleton()->get_filesystem(), options); } break; - case GDParser::COMPLETION_ASSIGN: { + case GDScriptParser::COMPLETION_ASSIGN: { #if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED) - GDCompletionIdentifier ci; + GDScriptCompletionIdentifier ci; if (_guess_expression_type(context, p.get_completion_node(), p.get_completion_line(), ci)) { String enumeration = ci.enumeration; @@ -2549,8 +2556,8 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } - for (int i = 0; i < GDFunctions::FUNC_MAX; i++) { - if (GDFunctions::get_func_name(GDFunctions::Function(i)) == p_symbol) { + for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) { + if (GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i)) == p_symbol) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_METHOD; r_result.class_name = "@GDScript"; r_result.class_member = p_symbol; @@ -2558,13 +2565,13 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } - GDParser p; + GDScriptParser p; p.parse(p_code, p_base_path, false, "", true); - if (p.get_completion_type() == GDParser::COMPLETION_NONE) + if (p.get_completion_type() == GDScriptParser::COMPLETION_NONE) return ERR_CANT_RESOLVE; - GDCompletionContext context; + GDScriptCompletionContext context; context._class = p.get_completion_class(); context.block = p.get_completion_block(); @@ -2575,10 +2582,10 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol switch (p.get_completion_type()) { - case GDParser::COMPLETION_GET_NODE: - case GDParser::COMPLETION_NONE: { + case GDScriptParser::COMPLETION_GET_NODE: + case GDScriptParser::COMPLETION_NONE: { } break; - case GDParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: { + case GDScriptParser::COMPLETION_BUILT_IN_TYPE_CONSTANT: { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; r_result.class_name = Variant::get_type_name(p.get_completion_built_in_constant()); @@ -2586,7 +2593,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol return OK; } break; - case GDParser::COMPLETION_FUNCTION: { + case GDScriptParser::COMPLETION_FUNCTION: { if (context._class && context._class->functions.size()) { for (int i = 0; i < context._class->functions.size(); i++) { @@ -2611,7 +2618,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol parent = parent->get_base(); } - GDCompletionIdentifier identifier = _get_native_class(context); + GDScriptCompletionIdentifier identifier = _get_native_class(context); print_line("identifier: " + String(identifier.obj_type)); if (ClassDB::has_method(identifier.obj_type, p_symbol)) { @@ -2623,7 +2630,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } break; - case GDParser::COMPLETION_IDENTIFIER: { + case GDScriptParser::COMPLETION_IDENTIFIER: { //check if a function if (p.get_completion_identifier_is_function()) { @@ -2650,7 +2657,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol parent = parent->get_base(); } - GDCompletionIdentifier identifier = _get_native_class(context); + GDScriptCompletionIdentifier identifier = _get_native_class(context); if (ClassDB::has_method(identifier.obj_type, p_symbol)) { @@ -2661,7 +2668,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } else { - GDCompletionIdentifier gdi = _get_native_class(context); + GDScriptCompletionIdentifier gdi = _get_native_class(context); if (gdi.obj_type != StringName()) { bool valid; Variant::Type t = ClassDB::get_property_type(gdi.obj_type, p_symbol, &valid); @@ -2673,7 +2680,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } - const GDParser::BlockNode *block = context.block; + const GDScriptParser::BlockNode *block = context.block; //search in blocks going up (local var?) while (block) { @@ -2682,9 +2689,9 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol if (block->statements[i]->line > p.get_completion_line()) continue; - if (block->statements[i]->type == GDParser::BlockNode::TYPE_LOCAL_VAR) { + if (block->statements[i]->type == GDScriptParser::BlockNode::TYPE_LOCAL_VAR) { - const GDParser::LocalVarNode *lv = static_cast<const GDParser::LocalVarNode *>(block->statements[i]); + const GDScriptParser::LocalVarNode *lv = static_cast<const GDScriptParser::LocalVarNode *>(block->statements[i]); if (lv->assign && lv->name == p_symbol) { @@ -2769,53 +2776,53 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } //global - for (Map<StringName, int>::Element *E = GDScriptLanguage::get_singleton()->get_global_map().front(); E; E = E->next()) { - if (E->key() == p_symbol) { - - Variant value = GDScriptLanguage::get_singleton()->get_global_array()[E->get()]; - if (value.get_type() == Variant::OBJECT) { - Object *obj = value; - if (obj) { - - if (Object::cast_to<GDNativeClass>(obj)) { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; - r_result.class_name = Object::cast_to<GDNativeClass>(obj)->get_name(); - - } else { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; - r_result.class_name = obj->get_class(); - } - return OK; + Map<StringName, int> classes = GDScriptLanguage::get_singleton()->get_global_map(); + if (classes.has(p_symbol)) { + Variant value = GDScriptLanguage::get_singleton()->get_global_array()[classes[p_symbol]]; + if (value.get_type() == Variant::OBJECT) { + Object *obj = value; + if (obj) { + if (Object::cast_to<GDScriptNativeClass>(obj)) { + r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; + r_result.class_name = Object::cast_to<GDScriptNativeClass>(obj)->get_name(); + } else { + r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS; + r_result.class_name = obj->get_class(); } - } else { - r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; - r_result.class_name = "@Global Scope"; - r_result.class_member = p_symbol; + // proxy class remove the underscore. + if (r_result.class_name.begins_with("_")) { + r_result.class_name = r_result.class_name.right(1); + } return OK; } + } else { + r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; + r_result.class_name = "@GlobalScope"; + r_result.class_member = p_symbol; + return OK; } } } } break; - case GDParser::COMPLETION_PARENT_FUNCTION: { + case GDScriptParser::COMPLETION_PARENT_FUNCTION: { } break; - case GDParser::COMPLETION_METHOD: + case GDScriptParser::COMPLETION_METHOD: isfunction = true; - case GDParser::COMPLETION_INDEX: { + case GDScriptParser::COMPLETION_INDEX: { - const GDParser::Node *node = p.get_completion_node(); - if (node->type != GDParser::Node::TYPE_OPERATOR) + const GDScriptParser::Node *node = p.get_completion_node(); + if (node->type != GDScriptParser::Node::TYPE_OPERATOR) break; - GDCompletionIdentifier t; - if (_guess_expression_type(context, static_cast<const GDParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t)) { + GDScriptCompletionIdentifier t; + if (_guess_expression_type(context, static_cast<const GDScriptParser::OperatorNode *>(node)->arguments[0], p.get_completion_line(), t)) { - if (t.type == Variant::OBJECT && t.obj_type == "GDNativeClass") { + if (t.type == Variant::OBJECT && t.obj_type == "GDScriptNativeClass") { //native enum - Ref<GDNativeClass> gdn = t.value; + Ref<GDScriptNativeClass> gdn = t.value; if (gdn.is_valid()) { r_result.type = ScriptLanguage::LookupResult::RESULT_CLASS_CONSTANT; r_result.class_name = gdn->get_name(); @@ -2907,13 +2914,13 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } break; - case GDParser::COMPLETION_CALL_ARGUMENTS: { + case GDScriptParser::COMPLETION_CALL_ARGUMENTS: { return ERR_CANT_RESOLVE; } break; - case GDParser::COMPLETION_VIRTUAL_FUNC: { + case GDScriptParser::COMPLETION_VIRTUAL_FUNC: { - GDCompletionIdentifier cid = _get_native_class(context); + GDScriptCompletionIdentifier cid = _get_native_class(context); if (cid.obj_type != StringName()) { List<MethodInfo> vm; @@ -2930,7 +2937,7 @@ Error GDScriptLanguage::lookup_code(const String &p_code, const String &p_symbol } } } break; - case GDParser::COMPLETION_YIELD: { + case GDScriptParser::COMPLETION_YIELD: { return ERR_CANT_RESOLVE; diff --git a/modules/gdscript/gd_function.cpp b/modules/gdscript/gdscript_function.cpp index ce503b62f2..765a76fec4 100644 --- a/modules/gdscript/gd_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_function.cpp */ +/* gdscript_function.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,13 +27,13 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "gd_function.h" +#include "gdscript_function.h" -#include "gd_functions.h" -#include "gd_script.h" +#include "gdscript.h" +#include "gdscript_functions.h" #include "os/os.h" -Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const { +Variant *GDScriptFunction::_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const { int address = p_address & ADDR_MASK; @@ -85,7 +85,7 @@ Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScrip o = o->_owner; } - ERR_EXPLAIN("GDCompiler bug.."); + ERR_EXPLAIN("GDScriptCompiler bug.."); ERR_FAIL_V(NULL); } break; case ADDR_TYPE_LOCAL_CONSTANT: { @@ -117,7 +117,7 @@ Variant *GDFunction::_get_variant(int p_address, GDInstance *p_instance, GDScrip return NULL; } -String GDFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const { +String GDScriptFunction::_get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const { String err_text; @@ -170,7 +170,7 @@ static String _get_var_type(const Variant *p_type) { return basestr; } -#if defined(__GNUC__) && !defined(__clang__) +#if defined(__GNUC__) #define OPCODES_TABLE \ static const void *switch_table_ops[] = { \ &&OPCODE_OPERATOR, \ @@ -231,7 +231,7 @@ static String _get_var_type(const Variant *p_type) { #define OPCODE_OUT break #endif -Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state) { +Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state) { OPCODES_TABLE; @@ -427,8 +427,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = ret; #endif ip += 5; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_EXTENDS_TEST) { CHECK_SPACE(4); @@ -478,7 +479,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } else { - GDNativeClass *nc = Object::cast_to<GDNativeClass>(obj_B); + GDScriptNativeClass *nc = Object::cast_to<GDScriptNativeClass>(obj_B); #ifdef DEBUG_ENABLED if (!nc) { @@ -492,8 +493,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = extends_ok; ip += 4; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_SET) { CHECK_SPACE(3); @@ -518,8 +520,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } #endif ip += 4; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_GET) { CHECK_SPACE(3); @@ -550,8 +553,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = ret; #endif ip += 4; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_SET_NAMED) { CHECK_SPACE(3); @@ -575,8 +579,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } #endif ip += 4; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_GET_NAMED) { CHECK_SPACE(4); @@ -609,8 +614,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = ret; #endif ip += 4; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_SET_MEMBER) { CHECK_SPACE(3); @@ -631,8 +637,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } #endif ip += 3; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_GET_MEMBER) { CHECK_SPACE(3); @@ -649,8 +656,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } #endif ip += 3; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_ASSIGN) { CHECK_SPACE(3); @@ -660,8 +668,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = *src; ip += 3; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_ASSIGN_TRUE) { CHECK_SPACE(2); @@ -670,8 +679,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = true; ip += 2; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_ASSIGN_FALSE) { CHECK_SPACE(2); @@ -680,8 +690,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = false; ip += 2; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_CONSTRUCT) { CHECK_SPACE(2); @@ -708,8 +719,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a ip += 4 + argc; //construct a basic type - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_CONSTRUCT_ARRAY) { CHECK_SPACE(1); @@ -728,8 +740,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = array; ip += 3 + argc; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_CONSTRUCT_DICTIONARY) { CHECK_SPACE(1); @@ -750,8 +763,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a *dst = dict; ip += 3 + argc * 2; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_CALL_RETURN) OPCODE(OPCODE_CALL) { @@ -830,13 +844,14 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a //_call_func(NULL,base,*methodname,ip,argc,p_instance,stack); ip += argc + 1; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_CALL_BUILT_IN) { CHECK_SPACE(4); - GDFunctions::Function func = GDFunctions::Function(_code_ptr[ip + 1]); + GDScriptFunctions::Function func = GDScriptFunctions::Function(_code_ptr[ip + 1]); int argc = _code_ptr[ip + 2]; GD_ERR_BREAK(argc < 0); @@ -853,12 +868,12 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a Variant::CallError err; - GDFunctions::call(func, (const Variant **)argptrs, argc, *dst, err); + GDScriptFunctions::call(func, (const Variant **)argptrs, argc, *dst, err); #ifdef DEBUG_ENABLED if (err.error != Variant::CallError::CALL_OK) { - String methodstr = GDFunctions::get_func_name(func); + String methodstr = GDScriptFunctions::get_func_name(func); if (dst->get_type() == Variant::STRING) { //call provided error string err_text = "Error calling built-in function '" + methodstr + "': " + String(*dst); @@ -869,12 +884,14 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } #endif ip += argc + 1; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_CALL_SELF) { OPCODE_BREAK; } + OPCODE(OPCODE_CALL_SELF_BASE) { CHECK_SPACE(2); @@ -904,7 +921,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a const GDScript *gds = _script; - const Map<StringName, GDFunction *>::Element *E = NULL; + const Map<StringName, GDScriptFunction *>::Element *E = NULL; while (gds->base.ptr()) { gds = gds->base.ptr(); E = gds->member_functions.find(*methodname); @@ -948,8 +965,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } ip += 4 + argc; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_YIELD) OPCODE(OPCODE_YIELD_SIGNAL) { @@ -961,7 +979,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a CHECK_SPACE(2); } - Ref<GDFunctionState> gdfs = memnew(GDFunctionState); + Ref<GDScriptFunctionState> gdfs = memnew(GDScriptFunctionState); gdfs->function = this; gdfs->state.stack.resize(alloca_size); @@ -1032,6 +1050,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a exit_ok = true; OPCODE_BREAK; } + OPCODE(OPCODE_YIELD_RESUME) { CHECK_SPACE(2); @@ -1044,8 +1063,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a GET_VARIANT_PTR(result, 1); *result = p_state->result; ip += 2; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_JUMP) { CHECK_SPACE(2); @@ -1053,8 +1073,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a GD_ERR_BREAK(to < 0 || to > _code_size); ip = to; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_JUMP_IF) { CHECK_SPACE(3); @@ -1067,11 +1088,12 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a int to = _code_ptr[ip + 2]; GD_ERR_BREAK(to < 0 || to > _code_size); ip = to; - DISPATCH_OPCODE; + } else { + ip += 3; } - ip += 3; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_JUMP_IF_NOT) { CHECK_SPACE(3); @@ -1084,17 +1106,19 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a int to = _code_ptr[ip + 2]; GD_ERR_BREAK(to < 0 || to > _code_size); ip = to; - DISPATCH_OPCODE; + } else { + ip += 3; } - ip += 3; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_JUMP_TO_DEF_ARGUMENT) { CHECK_SPACE(2); ip = _default_arg_ptr[defarg]; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_RETURN) { CHECK_SPACE(2); @@ -1103,6 +1127,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a exit_ok = true; OPCODE_BREAK; } + OPCODE(OPCODE_ITERATE_BEGIN) { CHECK_SPACE(8); //space for this a regular iterate @@ -1121,20 +1146,21 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a int jumpto = _code_ptr[ip + 3]; GD_ERR_BREAK(jumpto < 0 || jumpto > _code_size); ip = jumpto; - DISPATCH_OPCODE; - } - GET_VARIANT_PTR(iterator, 4); + } else { + GET_VARIANT_PTR(iterator, 4); - *iterator = container->iter_get(*counter, valid); + *iterator = container->iter_get(*counter, valid); #ifdef DEBUG_ENABLED - if (!valid) { - err_text = "Unable to obtain iterator object of type " + Variant::get_type_name(container->get_type()) + "'."; - OPCODE_BREAK; - } + if (!valid) { + err_text = "Unable to obtain iterator object of type " + Variant::get_type_name(container->get_type()) + "'."; + OPCODE_BREAK; + } #endif - ip += 5; //skip regular iterate which is always next - DISPATCH_OPCODE; + ip += 5; //skip regular iterate which is always next + } } + DISPATCH_OPCODE; + OPCODE(OPCODE_ITERATE) { CHECK_SPACE(4); @@ -1153,20 +1179,21 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a int jumpto = _code_ptr[ip + 3]; GD_ERR_BREAK(jumpto < 0 || jumpto > _code_size); ip = jumpto; - DISPATCH_OPCODE; - } - GET_VARIANT_PTR(iterator, 4); + } else { + GET_VARIANT_PTR(iterator, 4); - *iterator = container->iter_get(*counter, valid); + *iterator = container->iter_get(*counter, valid); #ifdef DEBUG_ENABLED - if (!valid) { - err_text = "Unable to obtain iterator object of type " + Variant::get_type_name(container->get_type()) + "' (but was obtained on first iteration?)."; - OPCODE_BREAK; - } + if (!valid) { + err_text = "Unable to obtain iterator object of type " + Variant::get_type_name(container->get_type()) + "' (but was obtained on first iteration?)."; + OPCODE_BREAK; + } #endif - ip += 5; //loop again - DISPATCH_OPCODE; + ip += 5; //loop again + } } + DISPATCH_OPCODE; + OPCODE(OPCODE_ASSERT) { CHECK_SPACE(2); GET_VARIANT_PTR(test, 1); @@ -1182,8 +1209,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a #endif ip += 2; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_BREAKPOINT) { #ifdef DEBUG_ENABLED if (ScriptDebugger::get_singleton()) { @@ -1191,8 +1219,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a } #endif ip += 1; - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_LINE) { CHECK_SPACE(2); @@ -1220,8 +1249,9 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a ScriptDebugger::get_singleton()->line_poll(); } - DISPATCH_OPCODE; } + DISPATCH_OPCODE; + OPCODE(OPCODE_END) { exit_ok = true; @@ -1291,43 +1321,43 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a return retvalue; } -const int *GDFunction::get_code() const { +const int *GDScriptFunction::get_code() const { return _code_ptr; } -int GDFunction::get_code_size() const { +int GDScriptFunction::get_code_size() const { return _code_size; } -Variant GDFunction::get_constant(int p_idx) const { +Variant GDScriptFunction::get_constant(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, constants.size(), "<errconst>"); return constants[p_idx]; } -StringName GDFunction::get_global_name(int p_idx) const { +StringName GDScriptFunction::get_global_name(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, global_names.size(), "<errgname>"); return global_names[p_idx]; } -int GDFunction::get_default_argument_count() const { +int GDScriptFunction::get_default_argument_count() const { return default_arguments.size(); } -int GDFunction::get_default_argument_addr(int p_idx) const { +int GDScriptFunction::get_default_argument_addr(int p_idx) const { ERR_FAIL_INDEX_V(p_idx, default_arguments.size(), -1); return default_arguments[p_idx]; } -StringName GDFunction::get_name() const { +StringName GDScriptFunction::get_name() const { return name; } -int GDFunction::get_max_stack_size() const { +int GDScriptFunction::get_max_stack_size() const { return _stack_size; } @@ -1350,7 +1380,7 @@ struct _GDFKCS { } }; -void GDFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int> > *r_stackvars) const { +void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, int> > *r_stackvars) const { int oc = 0; Map<StringName, _GDFKC> sdmap; @@ -1402,7 +1432,7 @@ void GDFunction::debug_get_stack_member_state(int p_line, List<Pair<StringName, } } -GDFunction::GDFunction() +GDScriptFunction::GDScriptFunction() : function_list(this) { _stack_size = 0; @@ -1434,7 +1464,7 @@ GDFunction::GDFunction() #endif } -GDFunction::~GDFunction() { +GDScriptFunction::~GDScriptFunction() { #ifdef DEBUG_ENABLED if (GDScriptLanguage::get_singleton()->lock) { GDScriptLanguage::get_singleton()->lock->lock(); @@ -1449,7 +1479,7 @@ GDFunction::~GDFunction() { ///////////////////// -Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) { +Variant GDScriptFunctionState::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) { #ifdef DEBUG_ENABLED if (state.instance_id && !ObjectDB::get_instance(state.instance_id)) { @@ -1484,7 +1514,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount arg = extra_args; } - Ref<GDFunctionState> self = *p_args[p_argcount - 1]; + Ref<GDScriptFunctionState> self = *p_args[p_argcount - 1]; if (self.is_null()) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_ARGUMENT; @@ -1498,10 +1528,10 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount bool completed = true; - // If the return value is a GDFunctionState reference, + // If the return value is a GDScriptFunctionState reference, // then the function did yield again after resuming. if (ret.is_ref()) { - GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret); + GDScriptFunctionState *gdfs = Object::cast_to<GDScriptFunctionState>(ret); if (gdfs && gdfs->function == function) completed = false; } @@ -1516,7 +1546,7 @@ Variant GDFunctionState::_signal_callback(const Variant **p_args, int p_argcount return ret; } -bool GDFunctionState::is_valid(bool p_extended_check) const { +bool GDScriptFunctionState::is_valid(bool p_extended_check) const { if (function == NULL) return false; @@ -1533,7 +1563,7 @@ bool GDFunctionState::is_valid(bool p_extended_check) const { return true; } -Variant GDFunctionState::resume(const Variant &p_arg) { +Variant GDScriptFunctionState::resume(const Variant &p_arg) { ERR_FAIL_COND_V(!function, Variant()); #ifdef DEBUG_ENABLED @@ -1554,10 +1584,10 @@ Variant GDFunctionState::resume(const Variant &p_arg) { bool completed = true; - // If the return value is a GDFunctionState reference, + // If the return value is a GDScriptFunctionState reference, // then the function did yield again after resuming. if (ret.is_ref()) { - GDFunctionState *gdfs = Object::cast_to<GDFunctionState>(ret); + GDScriptFunctionState *gdfs = Object::cast_to<GDScriptFunctionState>(ret); if (gdfs && gdfs->function == function) completed = false; } @@ -1572,21 +1602,21 @@ Variant GDFunctionState::resume(const Variant &p_arg) { return ret; } -void GDFunctionState::_bind_methods() { +void GDScriptFunctionState::_bind_methods() { - ClassDB::bind_method(D_METHOD("resume", "arg"), &GDFunctionState::resume, DEFVAL(Variant())); - 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")); + ClassDB::bind_method(D_METHOD("resume", "arg"), &GDScriptFunctionState::resume, DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("is_valid", "extended_check"), &GDScriptFunctionState::is_valid, DEFVAL(false)); + ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &GDScriptFunctionState::_signal_callback, MethodInfo("_signal_callback")); ADD_SIGNAL(MethodInfo("completed", PropertyInfo(Variant::NIL, "result", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NIL_IS_VARIANT))); } -GDFunctionState::GDFunctionState() { +GDScriptFunctionState::GDScriptFunctionState() { function = NULL; } -GDFunctionState::~GDFunctionState() { +GDScriptFunctionState::~GDScriptFunctionState() { if (function != NULL) { //never called, deinitialize stack diff --git a/modules/gdscript/gd_function.h b/modules/gdscript/gdscript_function.h index bf5ff5f8da..03fd5d52dc 100644 --- a/modules/gdscript/gd_function.h +++ b/modules/gdscript/gdscript_function.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_function.h */ +/* gdscript_function.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,8 +27,8 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GD_FUNCTION_H -#define GD_FUNCTION_H +#ifndef GDSCRIPT_FUNCTION_H +#define GDSCRIPT_FUNCTION_H #include "os/thread.h" #include "pair.h" @@ -38,10 +38,10 @@ #include "string_db.h" #include "variant.h" -class GDInstance; +class GDScriptInstance; class GDScript; -class GDFunction { +class GDScriptFunction { public: enum Opcode { OPCODE_OPERATOR, @@ -111,7 +111,7 @@ public: }; private: - friend class GDCompiler; + friend class GDScriptCompiler; StringName source; @@ -145,12 +145,12 @@ private: List<StackDebug> stack_debug; - _FORCE_INLINE_ Variant *_get_variant(int p_address, GDInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const; + _FORCE_INLINE_ Variant *_get_variant(int p_address, GDScriptInstance *p_instance, GDScript *p_script, Variant &self, Variant *p_stack, String &r_error) const; _FORCE_INLINE_ String _get_call_error(const Variant::CallError &p_err, const String &p_where, const Variant **argptrs) const; friend class GDScriptLanguage; - SelfList<GDFunction> function_list; + SelfList<GDScriptFunction> function_list; #ifdef DEBUG_ENABLED CharString func_cname; const char *_func_cname; @@ -176,7 +176,7 @@ public: ObjectID instance_id; //by debug only ObjectID script_id; - GDInstance *instance; + GDScriptInstance *instance; Vector<uint8_t> stack; int stack_size; Variant self; @@ -219,19 +219,19 @@ public: return default_arguments[p_idx]; } - Variant call(GDInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = NULL); + Variant call(GDScriptInstance *p_instance, const Variant **p_args, int p_argcount, Variant::CallError &r_err, CallState *p_state = NULL); _FORCE_INLINE_ ScriptInstance::RPCMode get_rpc_mode() const { return rpc_mode; } - GDFunction(); - ~GDFunction(); + GDScriptFunction(); + ~GDScriptFunction(); }; -class GDFunctionState : public Reference { +class GDScriptFunctionState : public Reference { - GDCLASS(GDFunctionState, Reference); - friend class GDFunction; - GDFunction *function; - GDFunction::CallState state; + GDCLASS(GDScriptFunctionState, Reference); + friend class GDScriptFunction; + GDScriptFunction *function; + GDScriptFunction::CallState state; Variant _signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error); protected: @@ -240,8 +240,8 @@ protected: public: bool is_valid(bool p_extended_check = false) const; Variant resume(const Variant &p_arg = Variant()); - GDFunctionState(); - ~GDFunctionState(); + GDScriptFunctionState(); + ~GDScriptFunctionState(); }; -#endif // GD_FUNCTION_H +#endif // GDSCRIPT_FUNCTION_H diff --git a/modules/gdscript/gd_functions.cpp b/modules/gdscript/gdscript_functions.cpp index b43ec409a1..c6066ceefb 100644 --- a/modules/gdscript/gd_functions.cpp +++ b/modules/gdscript/gdscript_functions.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_functions.cpp */ +/* gdscript_functions.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,10 +27,11 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "gd_functions.h" +#include "gdscript_functions.h" + #include "class_db.h" #include "func_ref.h" -#include "gd_script.h" +#include "gdscript.h" #include "io/json.h" #include "io/marshalls.h" #include "math_funcs.h" @@ -38,7 +39,7 @@ #include "reference.h" #include "variant_parser.h" -const char *GDFunctions::get_func_name(Function p_func) { +const char *GDScriptFunctions::get_func_name(Function p_func) { ERR_FAIL_INDEX_V(p_func, FUNC_MAX, ""); @@ -123,7 +124,7 @@ const char *GDFunctions::get_func_name(Function p_func) { return _names[p_func]; } -void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error) { +void GDScriptFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, Variant &r_ret, Variant::CallError &r_error) { r_error.error = Variant::CallError::CALL_OK; #ifdef DEBUG_ENABLED @@ -641,7 +642,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, } //str+="\n"; - OS::get_singleton()->printerr("%s\n", str.utf8().get_data()); + print_error(str); r_ret = Variant(); } break; @@ -899,7 +900,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, return; } else { - GDInstance *ins = static_cast<GDInstance *>(obj->get_script_instance()); + GDScriptInstance *ins = static_cast<GDScriptInstance *>(obj->get_script_instance()); Ref<GDScript> base = ins->get_script(); if (base.is_null()) { @@ -1030,7 +1031,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, r_ret = gdscr->_new(NULL, 0, r_error); - GDInstance *ins = static_cast<GDInstance *>(static_cast<Object *>(r_ret)->get_script_instance()); + GDScriptInstance *ins = static_cast<GDScriptInstance *>(static_cast<Object *>(r_ret)->get_script_instance()); Ref<GDScript> gd_ref = ins->get_script(); for (Map<StringName, GDScript::MemberInfo>::Element *E = gd_ref->member_indices.front(); E; E = E->next()) { @@ -1254,7 +1255,7 @@ void GDFunctions::call(Function p_func, const Variant **p_args, int p_arg_count, } } -bool GDFunctions::is_deterministic(Function p_func) { +bool GDScriptFunctions::is_deterministic(Function p_func) { //man i couldn't have chosen a worse function name, //way too controversial.. @@ -1317,7 +1318,7 @@ bool GDFunctions::is_deterministic(Function p_func) { return false; } -MethodInfo GDFunctions::get_info(Function p_func) { +MethodInfo GDScriptFunctions::get_info(Function p_func) { #ifdef TOOLS_ENABLED //using a switch, so the compiler generates a jumptable diff --git a/modules/gdscript/gd_functions.h b/modules/gdscript/gdscript_functions.h index 0de09f2e71..ecbede83a8 100644 --- a/modules/gdscript/gd_functions.h +++ b/modules/gdscript/gdscript_functions.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_functions.h */ +/* gdscript_functions.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,12 +27,12 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GD_FUNCTIONS_H -#define GD_FUNCTIONS_H +#ifndef GDSCRIPT_FUNCTIONS_H +#define GDSCRIPT_FUNCTIONS_H #include "variant.h" -class GDFunctions { +class GDScriptFunctions { public: enum Function { MATH_SIN, @@ -120,4 +120,4 @@ public: static MethodInfo get_info(Function p_func); }; -#endif // GD_FUNCTIONS_H +#endif // GDSCRIPT_FUNCTIONS_H diff --git a/modules/gdscript/gd_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 94385dc0d0..29b9865b1d 100644 --- a/modules/gdscript/gd_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_parser.cpp */ +/* gdscript_parser.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,15 +27,16 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "gd_parser.h" -#include "gd_script.h" +#include "gdscript_parser.h" + +#include "gdscript.h" #include "io/resource_loader.h" #include "os/file_access.h" #include "print_string.h" #include "script_language.h" template <class T> -T *GDParser::alloc_node() { +T *GDScriptParser::alloc_node() { T *t = memnew(T); @@ -50,21 +51,21 @@ T *GDParser::alloc_node() { return t; } -bool GDParser::_end_statement() { +bool GDScriptParser::_end_statement() { - if (tokenizer->get_token() == GDTokenizer::TK_SEMICOLON) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_SEMICOLON) { tokenizer->advance(); return true; //handle next - } else if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE || tokenizer->get_token() == GDTokenizer::TK_EOF) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE || tokenizer->get_token() == GDScriptTokenizer::TK_EOF) { return true; //will be handled properly } return false; } -bool GDParser::_enter_indent_block(BlockNode *p_block) { +bool GDScriptParser::_enter_indent_block(BlockNode *p_block) { - if (tokenizer->get_token() != GDTokenizer::TK_COLON) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_COLON) { // report location at the previous token (on the previous line) int error_line = tokenizer->get_token_line(-1); int error_column = tokenizer->get_token_column(-1); @@ -73,7 +74,7 @@ bool GDParser::_enter_indent_block(BlockNode *p_block) { } tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_NEWLINE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) { // be more python-like int current = tab_level.back()->get(); @@ -85,10 +86,10 @@ bool GDParser::_enter_indent_block(BlockNode *p_block) { while (true) { - if (tokenizer->get_token() != GDTokenizer::TK_NEWLINE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE) { return false; //wtf - } else if (tokenizer->get_token(1) != GDTokenizer::TK_NEWLINE) { + } else if (tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE) { int indent = tokenizer->get_token_line_indent(); int current = tab_level.back()->get(); @@ -113,9 +114,9 @@ bool GDParser::_enter_indent_block(BlockNode *p_block) { } } -bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_static, bool p_can_codecomplete) { +bool GDScriptParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_static, bool p_can_codecomplete) { - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { tokenizer->advance(); } else { @@ -124,10 +125,10 @@ bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_s while (true) { - if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) { _make_completable_call(argidx); completion_node = p_parent; - } else if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING && tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING && tokenizer->get_token(1) == GDScriptTokenizer::TK_CURSOR) { //completing a string argument.. completion_cursor = tokenizer->get_token_constant(); @@ -143,13 +144,13 @@ bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_s p_args.push_back(arg); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { tokenizer->advance(); break; - } else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { - if (tokenizer->get_token(1) == GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token(1) == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expression expected"); return false; @@ -169,7 +170,7 @@ bool GDParser::_parse_arguments(Node *p_parent, Vector<Node *> &p_args, bool p_s return true; } -void GDParser::_make_completable_call(int p_arg) { +void GDScriptParser::_make_completable_call(int p_arg) { completion_cursor = StringName(); completion_type = COMPLETION_CALL_ARGUMENTS; @@ -182,14 +183,14 @@ void GDParser::_make_completable_call(int p_arg) { tokenizer->advance(); } -bool GDParser::_get_completable_identifier(CompletionType p_type, StringName &identifier) { +bool GDScriptParser::_get_completable_identifier(CompletionType p_type, StringName &identifier) { identifier = StringName(); if (tokenizer->is_token_literal()) { identifier = tokenizer->get_token_literal(); tokenizer->advance(); } - if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) { completion_cursor = identifier; completion_type = p_type; @@ -206,7 +207,7 @@ bool GDParser::_get_completable_identifier(CompletionType p_type, StringName &id tokenizer->advance(); } - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) { completion_ident_is_call = true; } return true; @@ -215,7 +216,7 @@ bool GDParser::_get_completable_identifier(CompletionType p_type, StringName &id return false; } -GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool p_allow_assign, bool p_parsing_constant) { +GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_static, bool p_allow_assign, bool p_parsing_constant) { //Vector<Node*> expressions; //Vector<OperatorNode::Operator> operators; @@ -234,12 +235,12 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool if (parenthesis > 0) { //remove empty space (only allowed if inside parenthesis - while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) { + while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) { tokenizer->advance(); } } - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) { //subexpression () tokenizer->advance(); parenthesis++; @@ -248,7 +249,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool if (!subexpr) return NULL; - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ')' in expression"); return NULL; @@ -256,7 +257,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool tokenizer->advance(); expr = subexpr; - } else if (tokenizer->get_token() == GDTokenizer::TK_DOLLAR) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_DOLLAR) { tokenizer->advance(); String path; @@ -267,7 +268,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool while (!done) { switch (tokenizer->get_token()) { - case GDTokenizer::TK_CURSOR: { + case GDScriptTokenizer::TK_CURSOR: { completion_cursor = StringName(); completion_type = COMPLETION_GET_NODE; completion_class = current_class; @@ -279,7 +280,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool completion_found = true; tokenizer->advance(); } break; - case GDTokenizer::TK_CONSTANT: { + case GDScriptTokenizer::TK_CONSTANT: { if (!need_identifier) { done = true; @@ -296,7 +297,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool need_identifier = false; } break; - case GDTokenizer::TK_OP_DIV: { + case GDScriptTokenizer::TK_OP_DIV: { if (need_identifier) { done = true; @@ -344,49 +345,56 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool expr = op; - } else if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) { tokenizer->advance(); continue; //no point in cursor in the middle of expression - } else if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT) { //constant defined by tokenizer ConstantNode *constant = alloc_node<ConstantNode>(); constant->value = tokenizer->get_token_constant(); tokenizer->advance(); expr = constant; - } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_PI) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_PI) { //constant defined by tokenizer ConstantNode *constant = alloc_node<ConstantNode>(); constant->value = Math_PI; tokenizer->advance(); expr = constant; - } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_INF) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_TAU) { + + //constant defined by tokenizer + ConstantNode *constant = alloc_node<ConstantNode>(); + constant->value = Math_TAU; + tokenizer->advance(); + expr = constant; + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_INF) { //constant defined by tokenizer ConstantNode *constant = alloc_node<ConstantNode>(); constant->value = Math_INF; tokenizer->advance(); expr = constant; - } else if (tokenizer->get_token() == GDTokenizer::TK_CONST_NAN) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CONST_NAN) { //constant defined by tokenizer ConstantNode *constant = alloc_node<ConstantNode>(); constant->value = Math_NAN; tokenizer->advance(); expr = constant; - } else if (tokenizer->get_token() == GDTokenizer::TK_PR_PRELOAD) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_PRELOAD) { //constant defined by tokenizer tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) { _set_error("Expected '(' after 'preload'"); return NULL; } tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) { completion_cursor = StringName(); completion_node = p_parent; completion_type = COMPLETION_RESOURCE_PATH; @@ -466,7 +474,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool } } - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ')' after 'preload' path"); return NULL; } @@ -476,12 +484,12 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool constant->value = res; expr = constant; - } else if (tokenizer->get_token() == GDTokenizer::TK_PR_YIELD) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_YIELD) { //constant defined by tokenizer tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) { _set_error("Expected '(' after 'yield'"); return NULL; } @@ -491,11 +499,11 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool OperatorNode *yield = alloc_node<OperatorNode>(); yield->op = OperatorNode::OP_YIELD; - while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) { + while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) { tokenizer->advance(); } - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { expr = yield; tokenizer->advance(); } else { @@ -507,14 +515,14 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool return NULL; yield->arguments.push_back(object); - if (tokenizer->get_token() != GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) { _set_error("Expected ',' after first argument of 'yield'"); return NULL; } tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) { completion_cursor = StringName(); completion_node = object; @@ -533,7 +541,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool return NULL; yield->arguments.push_back(signal); - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ')' after second argument of 'yield'"); return NULL; } @@ -545,7 +553,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool expr = yield; } - } else if (tokenizer->get_token() == GDTokenizer::TK_SELF) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_SELF) { if (p_static) { _set_error("'self'' not allowed in static function or constant expression"); @@ -555,7 +563,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool SelfNode *self = alloc_node<SelfNode>(); tokenizer->advance(); expr = self; - } else if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token(1) == GDTokenizer::TK_PERIOD) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token(1) == GDScriptTokenizer::TK_PERIOD) { Variant::Type bi_type = tokenizer->get_token_type(); tokenizer->advance(2); @@ -582,20 +590,20 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool cn->value = Variant::get_numeric_constant_value(bi_type, identifier); expr = cn; - } else if (tokenizer->get_token(1) == GDTokenizer::TK_PARENTHESIS_OPEN && tokenizer->is_token_literal()) { + } else if (tokenizer->get_token(1) == GDScriptTokenizer::TK_PARENTHESIS_OPEN && tokenizer->is_token_literal()) { // We check with is_token_literal, as this allows us to use match/sync/etc. as a name //function or constructor OperatorNode *op = alloc_node<OperatorNode>(); op->op = OperatorNode::OP_CALL; - if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) { TypeNode *tn = alloc_node<TypeNode>(); tn->vtype = tokenizer->get_token_type(); op->arguments.push_back(tn); tokenizer->advance(2); - } else if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_FUNC) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC) { BuiltInFunctionNode *bn = alloc_node<BuiltInFunctionNode>(); bn->function = tokenizer->get_token_built_in_func(); @@ -616,7 +624,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool tokenizer->advance(1); } - if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) { _make_completable_call(0); completion_node = op; } @@ -661,7 +669,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool expr = id; } - } else if (tokenizer->get_token() == GDTokenizer::TK_OP_ADD || tokenizer->get_token() == GDTokenizer::TK_OP_SUB || tokenizer->get_token() == GDTokenizer::TK_OP_NOT || tokenizer->get_token() == GDTokenizer::TK_OP_BIT_INVERT) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ADD || tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB || tokenizer->get_token() == GDScriptTokenizer::TK_OP_NOT || tokenizer->get_token() == GDScriptTokenizer::TK_OP_BIT_INVERT) { //single prefix operators like !expr +expr -expr ++expr --expr alloc_node<OperatorNode>(); @@ -669,16 +677,16 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool e.is_op = true; switch (tokenizer->get_token()) { - case GDTokenizer::TK_OP_ADD: e.op = OperatorNode::OP_POS; break; - case GDTokenizer::TK_OP_SUB: e.op = OperatorNode::OP_NEG; break; - case GDTokenizer::TK_OP_NOT: e.op = OperatorNode::OP_NOT; break; - case GDTokenizer::TK_OP_BIT_INVERT: e.op = OperatorNode::OP_BIT_INVERT; break; + case GDScriptTokenizer::TK_OP_ADD: e.op = OperatorNode::OP_POS; break; + case GDScriptTokenizer::TK_OP_SUB: e.op = OperatorNode::OP_NEG; break; + case GDScriptTokenizer::TK_OP_NOT: e.op = OperatorNode::OP_NOT; break; + case GDScriptTokenizer::TK_OP_BIT_INVERT: e.op = OperatorNode::OP_BIT_INVERT; break; default: {} } tokenizer->advance(); - if (e.op != OperatorNode::OP_NOT && tokenizer->get_token() == GDTokenizer::TK_OP_NOT) { + if (e.op != OperatorNode::OP_NOT && tokenizer->get_token() == GDScriptTokenizer::TK_OP_NOT) { _set_error("Misplaced 'not'."); return NULL; } @@ -693,7 +701,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool op->arguments.push_back(subexpr); expr=op;*/ - } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_OPEN) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_OPEN) { // array tokenizer->advance(); @@ -702,18 +710,18 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool while (true) { - if (tokenizer->get_token() == GDTokenizer::TK_EOF) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) { _set_error("Unterminated array"); return NULL; - } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) { tokenizer->advance(); break; - } else if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) { tokenizer->advance(); //ignore newline - } else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { if (!expecting_comma) { _set_error("expression or ']' expected"); return NULL; @@ -736,7 +744,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool } expr = arr; - } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_OPEN) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_OPEN) { // array tokenizer->advance(); @@ -758,12 +766,12 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool while (true) { - if (tokenizer->get_token() == GDTokenizer::TK_EOF) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) { _set_error("Unterminated dictionary"); return NULL; - } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) { if (expecting == DICT_EXPECT_COLON) { _set_error("':' expected"); @@ -775,10 +783,10 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool } tokenizer->advance(); break; - } else if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) { tokenizer->advance(); //ignore newline - } else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { if (expecting == DICT_EXPECT_KEY) { _set_error("key or '}' expected"); @@ -796,7 +804,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool expecting = DICT_EXPECT_KEY; tokenizer->advance(); //ignore newline - } else if (tokenizer->get_token() == GDTokenizer::TK_COLON) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) { if (expecting == DICT_EXPECT_KEY) { _set_error("key or '}' expected"); @@ -826,7 +834,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool if (expecting == DICT_EXPECT_KEY) { - if (tokenizer->is_token_literal() && tokenizer->get_token(1) == GDTokenizer::TK_OP_ASSIGN) { + if (tokenizer->is_token_literal() && tokenizer->get_token(1) == GDScriptTokenizer::TK_OP_ASSIGN) { // We check with is_token_literal, as this allows us to use match/sync/etc. as a name //lua style identifier, easier to write ConstantNode *cn = alloc_node<ConstantNode>(); @@ -849,8 +857,8 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool return NULL; expecting = DICT_EXPECT_COMMA; - if (key->type == GDParser::Node::TYPE_CONSTANT) { - Variant const &keyName = static_cast<const GDParser::ConstantNode *>(key)->value; + if (key->type == GDScriptParser::Node::TYPE_CONSTANT) { + Variant const &keyName = static_cast<const GDScriptParser::ConstantNode *>(key)->value; if (keys.has(keyName)) { _set_error("Duplicate key found in Dictionary literal"); @@ -870,7 +878,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool expr = dict; - } else if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && (tokenizer->is_token_literal(1) || tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) && tokenizer->get_token(2) == GDTokenizer::TK_PARENTHESIS_OPEN) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD && (tokenizer->is_token_literal(1) || tokenizer->get_token(1) == GDScriptTokenizer::TK_CURSOR) && tokenizer->get_token(2) == GDScriptTokenizer::TK_PARENTHESIS_OPEN) { // We check with is_token_literal, as this allows us to use match/sync/etc. as a name // parent call @@ -907,7 +915,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool } if (!expr) { - ERR_EXPLAIN("GDParser bug, couldn't figure out what expression is.."); + ERR_EXPLAIN("GDScriptParser bug, couldn't figure out what expression is.."); ERR_FAIL_COND_V(!expr, NULL); } @@ -919,15 +927,15 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool //expressions can be indexed any number of times - if (tokenizer->get_token() == GDTokenizer::TK_PERIOD) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD) { //indexing using "." - if (tokenizer->get_token(1) != GDTokenizer::TK_CURSOR && !tokenizer->is_token_literal(1)) { + if (tokenizer->get_token(1) != GDScriptTokenizer::TK_CURSOR && !tokenizer->is_token_literal(1)) { // We check with is_token_literal, as this allows us to use match/sync/etc. as a name _set_error("Expected identifier as member"); return NULL; - } else if (tokenizer->get_token(2) == GDTokenizer::TK_PARENTHESIS_OPEN) { + } else if (tokenizer->get_token(2) == GDScriptTokenizer::TK_PARENTHESIS_OPEN) { //call!! OperatorNode *op = alloc_node<OperatorNode>(); op->op = OperatorNode::OP_CALL; @@ -935,10 +943,10 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool tokenizer->advance(); IdentifierNode *id = alloc_node<IdentifierNode>(); - if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_FUNC) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_FUNC) { //small hack so built in funcs don't obfuscate methods - id->name = GDFunctions::get_func_name(tokenizer->get_token_built_in_func()); + id->name = GDScriptFunctions::get_func_name(tokenizer->get_token_built_in_func()); tokenizer->advance(); } else { @@ -955,7 +963,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool op->arguments.push_back(id); // call func //get arguments tokenizer->advance(1); - if (tokenizer->get_token() == GDTokenizer::TK_CURSOR) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_CURSOR) { _make_completable_call(0); completion_node = op; } @@ -990,7 +998,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool expr = op; } - } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_OPEN) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_OPEN) { //indexing using "[]" OperatorNode *op = alloc_node<OperatorNode>(); op->op = OperatorNode::OP_INDEX; @@ -1002,7 +1010,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool return NULL; } - if (tokenizer->get_token() != GDTokenizer::TK_BRACKET_CLOSE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_BRACKET_CLOSE) { _set_error("Expected ']'"); return NULL; } @@ -1022,7 +1030,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool if (parenthesis > 0) { //remove empty space (only allowed if inside parenthesis - while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) { + while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) { tokenizer->advance(); } } @@ -1047,29 +1055,29 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool switch (tokenizer->get_token()) { //see operator - case GDTokenizer::TK_OP_IN: op = OperatorNode::OP_IN; break; - case GDTokenizer::TK_OP_EQUAL: op = OperatorNode::OP_EQUAL; break; - case GDTokenizer::TK_OP_NOT_EQUAL: op = OperatorNode::OP_NOT_EQUAL; break; - case GDTokenizer::TK_OP_LESS: op = OperatorNode::OP_LESS; break; - case GDTokenizer::TK_OP_LESS_EQUAL: op = OperatorNode::OP_LESS_EQUAL; break; - case GDTokenizer::TK_OP_GREATER: op = OperatorNode::OP_GREATER; break; - case GDTokenizer::TK_OP_GREATER_EQUAL: op = OperatorNode::OP_GREATER_EQUAL; break; - case GDTokenizer::TK_OP_AND: op = OperatorNode::OP_AND; break; - case GDTokenizer::TK_OP_OR: op = OperatorNode::OP_OR; break; - case GDTokenizer::TK_OP_ADD: op = OperatorNode::OP_ADD; break; - case GDTokenizer::TK_OP_SUB: op = OperatorNode::OP_SUB; break; - case GDTokenizer::TK_OP_MUL: op = OperatorNode::OP_MUL; break; - case GDTokenizer::TK_OP_DIV: op = OperatorNode::OP_DIV; break; - case GDTokenizer::TK_OP_MOD: + case GDScriptTokenizer::TK_OP_IN: op = OperatorNode::OP_IN; break; + case GDScriptTokenizer::TK_OP_EQUAL: op = OperatorNode::OP_EQUAL; break; + case GDScriptTokenizer::TK_OP_NOT_EQUAL: op = OperatorNode::OP_NOT_EQUAL; break; + case GDScriptTokenizer::TK_OP_LESS: op = OperatorNode::OP_LESS; break; + case GDScriptTokenizer::TK_OP_LESS_EQUAL: op = OperatorNode::OP_LESS_EQUAL; break; + case GDScriptTokenizer::TK_OP_GREATER: op = OperatorNode::OP_GREATER; break; + case GDScriptTokenizer::TK_OP_GREATER_EQUAL: op = OperatorNode::OP_GREATER_EQUAL; break; + case GDScriptTokenizer::TK_OP_AND: op = OperatorNode::OP_AND; break; + case GDScriptTokenizer::TK_OP_OR: op = OperatorNode::OP_OR; break; + case GDScriptTokenizer::TK_OP_ADD: op = OperatorNode::OP_ADD; break; + case GDScriptTokenizer::TK_OP_SUB: op = OperatorNode::OP_SUB; break; + case GDScriptTokenizer::TK_OP_MUL: op = OperatorNode::OP_MUL; break; + case GDScriptTokenizer::TK_OP_DIV: op = OperatorNode::OP_DIV; break; + case GDScriptTokenizer::TK_OP_MOD: op = OperatorNode::OP_MOD; break; - //case GDTokenizer::TK_OP_NEG: op=OperatorNode::OP_NEG ; break; - case GDTokenizer::TK_OP_SHIFT_LEFT: op = OperatorNode::OP_SHIFT_LEFT; break; - case GDTokenizer::TK_OP_SHIFT_RIGHT: op = OperatorNode::OP_SHIFT_RIGHT; break; - case GDTokenizer::TK_OP_ASSIGN: { + //case GDScriptTokenizer::TK_OP_NEG: op=OperatorNode::OP_NEG ; break; + case GDScriptTokenizer::TK_OP_SHIFT_LEFT: op = OperatorNode::OP_SHIFT_LEFT; break; + case GDScriptTokenizer::TK_OP_SHIFT_RIGHT: op = OperatorNode::OP_SHIFT_RIGHT; break; + case GDScriptTokenizer::TK_OP_ASSIGN: { _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN; - if (tokenizer->get_token(1) == GDTokenizer::TK_CURSOR) { + if (tokenizer->get_token(1) == GDScriptTokenizer::TK_CURSOR) { //code complete assignment completion_type = COMPLETION_ASSIGN; completion_node = expr; @@ -1082,22 +1090,22 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool } } break; - case GDTokenizer::TK_OP_ASSIGN_ADD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_ADD; break; - case GDTokenizer::TK_OP_ASSIGN_SUB: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SUB; break; - case GDTokenizer::TK_OP_ASSIGN_MUL: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MUL; break; - case GDTokenizer::TK_OP_ASSIGN_DIV: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_DIV; break; - case GDTokenizer::TK_OP_ASSIGN_MOD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MOD; break; - case GDTokenizer::TK_OP_ASSIGN_SHIFT_LEFT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_LEFT; break; - case GDTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_RIGHT; break; - case GDTokenizer::TK_OP_ASSIGN_BIT_AND: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_AND; break; - case GDTokenizer::TK_OP_ASSIGN_BIT_OR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_OR; break; - case GDTokenizer::TK_OP_ASSIGN_BIT_XOR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_XOR; break; - case GDTokenizer::TK_OP_BIT_AND: op = OperatorNode::OP_BIT_AND; break; - case GDTokenizer::TK_OP_BIT_OR: op = OperatorNode::OP_BIT_OR; break; - case GDTokenizer::TK_OP_BIT_XOR: op = OperatorNode::OP_BIT_XOR; break; - case GDTokenizer::TK_PR_IS: op = OperatorNode::OP_IS; break; - case GDTokenizer::TK_CF_IF: op = OperatorNode::OP_TERNARY_IF; break; - case GDTokenizer::TK_CF_ELSE: op = OperatorNode::OP_TERNARY_ELSE; break; + case GDScriptTokenizer::TK_OP_ASSIGN_ADD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_ADD; break; + case GDScriptTokenizer::TK_OP_ASSIGN_SUB: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SUB; break; + case GDScriptTokenizer::TK_OP_ASSIGN_MUL: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MUL; break; + case GDScriptTokenizer::TK_OP_ASSIGN_DIV: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_DIV; break; + case GDScriptTokenizer::TK_OP_ASSIGN_MOD: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_MOD; break; + case GDScriptTokenizer::TK_OP_ASSIGN_SHIFT_LEFT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_LEFT; break; + case GDScriptTokenizer::TK_OP_ASSIGN_SHIFT_RIGHT: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_SHIFT_RIGHT; break; + case GDScriptTokenizer::TK_OP_ASSIGN_BIT_AND: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_AND; break; + case GDScriptTokenizer::TK_OP_ASSIGN_BIT_OR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_OR; break; + case GDScriptTokenizer::TK_OP_ASSIGN_BIT_XOR: _VALIDATE_ASSIGN op = OperatorNode::OP_ASSIGN_BIT_XOR; break; + case GDScriptTokenizer::TK_OP_BIT_AND: op = OperatorNode::OP_BIT_AND; break; + case GDScriptTokenizer::TK_OP_BIT_OR: op = OperatorNode::OP_BIT_OR; break; + case GDScriptTokenizer::TK_OP_BIT_XOR: op = OperatorNode::OP_BIT_XOR; break; + case GDScriptTokenizer::TK_PR_IS: op = OperatorNode::OP_IS; break; + case GDScriptTokenizer::TK_CF_IF: op = OperatorNode::OP_TERNARY_IF; break; + case GDScriptTokenizer::TK_CF_ELSE: op = OperatorNode::OP_TERNARY_ELSE; break; default: valid = false; break; } @@ -1205,7 +1213,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool case OperatorNode::OP_ASSIGN_BIT_XOR: priority = 15; break; default: { - _set_error("GDParser bug, invalid operator in expression: " + itos(expression[i].op)); + _set_error("GDScriptParser bug, invalid operator in expression: " + itos(expression[i].op)); return NULL; } } @@ -1351,7 +1359,7 @@ GDParser::Node *GDParser::_parse_expression(Node *p_parent, bool p_static, bool return expression[0].node; } -GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) { +GDScriptParser::Node *GDScriptParser::_reduce_expression(Node *p_node, bool p_to_const) { switch (p_node->type) { @@ -1448,7 +1456,7 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) { } else if (op->op == OperatorNode::OP_CALL) { //can reduce base type constructors - if ((op->arguments[0]->type == Node::TYPE_TYPE || (op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && GDFunctions::is_deterministic(static_cast<BuiltInFunctionNode *>(op->arguments[0])->function))) && last_not_constant == 0) { + if ((op->arguments[0]->type == Node::TYPE_TYPE || (op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && GDScriptFunctions::is_deterministic(static_cast<BuiltInFunctionNode *>(op->arguments[0])->function))) && last_not_constant == 0) { //native type constructor or intrinsic function const Variant **vptr = NULL; @@ -1473,8 +1481,8 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) { v = Variant::construct(tn->vtype, vptr, ptrs.size(), ce); } else { - GDFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function; - GDFunctions::call(func, vptr, ptrs.size(), v, ce); + GDScriptFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function; + GDScriptFunctions::call(func, vptr, ptrs.size(), v, ce); } if (ce.error != Variant::CallError::CALL_OK) { @@ -1485,8 +1493,8 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) { errwhere = "'" + Variant::get_type_name(tn->vtype) + "'' constructor"; } else { - GDFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function; - errwhere = String("'") + GDFunctions::get_func_name(func) + "'' intrinsic function"; + GDScriptFunctions::Function func = static_cast<BuiltInFunctionNode *>(op->arguments[0])->function; + errwhere = String("'") + GDScriptFunctions::get_func_name(func) + "'' intrinsic function"; } switch (ce.error) { @@ -1736,7 +1744,7 @@ GDParser::Node *GDParser::_reduce_expression(Node *p_node, bool p_to_const) { } } -GDParser::Node *GDParser::_parse_and_reduce_expression(Node *p_parent, bool p_static, bool p_reduce_const, bool p_allow_assign) { +GDScriptParser::Node *GDScriptParser::_parse_and_reduce_expression(Node *p_parent, bool p_static, bool p_reduce_const, bool p_allow_assign) { Node *expr = _parse_expression(p_parent, p_static, p_allow_assign, p_reduce_const); if (!expr || error_set) @@ -1747,58 +1755,58 @@ GDParser::Node *GDParser::_parse_and_reduce_expression(Node *p_parent, bool p_st return expr; } -bool GDParser::_recover_from_completion() { +bool GDScriptParser::_recover_from_completion() { if (!completion_found) { return false; //can't recover if no completion } //skip stuff until newline - while (tokenizer->get_token() != GDTokenizer::TK_NEWLINE && tokenizer->get_token() != GDTokenizer::TK_EOF && tokenizer->get_token() != GDTokenizer::TK_ERROR) { + while (tokenizer->get_token() != GDScriptTokenizer::TK_NEWLINE && tokenizer->get_token() != GDScriptTokenizer::TK_EOF && tokenizer->get_token() != GDScriptTokenizer::TK_ERROR) { tokenizer->advance(); } completion_found = false; error_set = false; - if (tokenizer->get_token() == GDTokenizer::TK_ERROR) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_ERROR) { error_set = true; } return true; } -GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) { +GDScriptParser::PatternNode *GDScriptParser::_parse_pattern(bool p_static) { PatternNode *pattern = alloc_node<PatternNode>(); - GDTokenizer::Token token = tokenizer->get_token(); + GDScriptTokenizer::Token token = tokenizer->get_token(); if (error_set) return NULL; - if (token == GDTokenizer::TK_EOF) { + if (token == GDScriptTokenizer::TK_EOF) { return NULL; } switch (token) { // array - case GDTokenizer::TK_BRACKET_OPEN: { + case GDScriptTokenizer::TK_BRACKET_OPEN: { tokenizer->advance(); - pattern->pt_type = GDParser::PatternNode::PT_ARRAY; + pattern->pt_type = GDScriptParser::PatternNode::PT_ARRAY; while (true) { - if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) { tokenizer->advance(); break; } - if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDTokenizer::TK_PERIOD) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDScriptTokenizer::TK_PERIOD) { // match everything tokenizer->advance(2); PatternNode *sub_pattern = alloc_node<PatternNode>(); - sub_pattern->pt_type = GDParser::PatternNode::PT_IGNORE_REST; + sub_pattern->pt_type = GDScriptParser::PatternNode::PT_IGNORE_REST; pattern->array.push_back(sub_pattern); - if (tokenizer->get_token() == GDTokenizer::TK_COMMA && tokenizer->get_token(1) == GDTokenizer::TK_BRACKET_CLOSE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA && tokenizer->get_token(1) == GDScriptTokenizer::TK_BRACKET_CLOSE) { tokenizer->advance(2); break; - } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) { tokenizer->advance(1); break; } else { @@ -1814,10 +1822,10 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) { pattern->array.push_back(sub_pattern); - if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { tokenizer->advance(); continue; - } else if (tokenizer->get_token() == GDTokenizer::TK_BRACKET_CLOSE) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_BRACKET_CLOSE) { tokenizer->advance(); break; } else { @@ -1827,33 +1835,33 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) { } } break; // bind - case GDTokenizer::TK_PR_VAR: { + case GDScriptTokenizer::TK_PR_VAR: { tokenizer->advance(); - pattern->pt_type = GDParser::PatternNode::PT_BIND; + pattern->pt_type = GDScriptParser::PatternNode::PT_BIND; pattern->bind = tokenizer->get_token_identifier(); tokenizer->advance(); } break; // dictionary - case GDTokenizer::TK_CURLY_BRACKET_OPEN: { + case GDScriptTokenizer::TK_CURLY_BRACKET_OPEN: { tokenizer->advance(); - pattern->pt_type = GDParser::PatternNode::PT_DICTIONARY; + pattern->pt_type = GDScriptParser::PatternNode::PT_DICTIONARY; while (true) { - if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) { tokenizer->advance(); break; } - if (tokenizer->get_token() == GDTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDTokenizer::TK_PERIOD) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD && tokenizer->get_token(1) == GDScriptTokenizer::TK_PERIOD) { // match everything tokenizer->advance(2); PatternNode *sub_pattern = alloc_node<PatternNode>(); sub_pattern->pt_type = PatternNode::PT_IGNORE_REST; pattern->array.push_back(sub_pattern); - if (tokenizer->get_token() == GDTokenizer::TK_COMMA && tokenizer->get_token(1) == GDTokenizer::TK_CURLY_BRACKET_CLOSE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA && tokenizer->get_token(1) == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) { tokenizer->advance(2); break; - } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) { tokenizer->advance(1); break; } else { @@ -1868,12 +1876,12 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) { return NULL; } - if (key->type != GDParser::Node::TYPE_CONSTANT) { + if (key->type != GDScriptParser::Node::TYPE_CONSTANT) { _set_error("Not a constant expression as key"); return NULL; } - if (tokenizer->get_token() == GDTokenizer::TK_COLON) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COLON) { tokenizer->advance(); PatternNode *value = _parse_pattern(p_static); @@ -1887,10 +1895,10 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) { pattern->dictionary.insert(static_cast<ConstantNode *>(key), NULL); } - if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { tokenizer->advance(); continue; - } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) { tokenizer->advance(); break; } else { @@ -1899,7 +1907,7 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) { } } } break; - case GDTokenizer::TK_WILDCARD: { + case GDScriptTokenizer::TK_WILDCARD: { tokenizer->advance(); pattern->pt_type = PatternNode::PT_WILDCARD; } break; @@ -1943,15 +1951,15 @@ GDParser::PatternNode *GDParser::_parse_pattern(bool p_static) { return pattern; } -void GDParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode *> &p_branches, bool p_static) { +void GDScriptParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode *> &p_branches, bool p_static) { int indent_level = tab_level.back()->get(); while (true) { - while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE && _parse_newline()) + while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE && _parse_newline()) ; - // GDTokenizer::Token token = tokenizer->get_token(); + // GDScriptTokenizer::Token token = tokenizer->get_token(); if (error_set) return; @@ -1970,7 +1978,7 @@ void GDParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode return; } - while (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + while (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { tokenizer->advance(); branch->patterns.push_back(_parse_pattern(p_static)); if (!branch->patterns[branch->patterns.size() - 1]) { @@ -1996,13 +2004,13 @@ void GDParser::_parse_pattern_block(BlockNode *p_block, Vector<PatternBranchNode } } -void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, Node *&p_resulting_node, Map<StringName, Node *> &p_bindings) { +void GDScriptParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, Node *&p_resulting_node, Map<StringName, Node *> &p_bindings) { switch (p_pattern->pt_type) { case PatternNode::PT_CONSTANT: { // typecheck BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>(); - typeof_node->function = GDFunctions::TYPE_OF; + typeof_node->function = GDScriptFunctions::TYPE_OF; OperatorNode *typeof_match_value = alloc_node<OperatorNode>(); typeof_match_value->op = OperatorNode::OP_CALL; @@ -2057,7 +2065,7 @@ void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, { // typecheck BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>(); - typeof_node->function = GDFunctions::TYPE_OF; + typeof_node->function = GDScriptFunctions::TYPE_OF; OperatorNode *typeof_match_value = alloc_node<OperatorNode>(); typeof_match_value->op = OperatorNode::OP_CALL; @@ -2136,7 +2144,7 @@ void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, { // typecheck BuiltInFunctionNode *typeof_node = alloc_node<BuiltInFunctionNode>(); - typeof_node->function = GDFunctions::TYPE_OF; + typeof_node->function = GDScriptFunctions::TYPE_OF; OperatorNode *typeof_match_value = alloc_node<OperatorNode>(); typeof_match_value->op = OperatorNode::OP_CALL; @@ -2234,7 +2242,7 @@ void GDParser::_generate_pattern(PatternNode *p_pattern, Node *p_node_to_match, } } -void GDParser::_transform_match_statment(BlockNode *p_block, MatchNode *p_match_statement) { +void GDScriptParser::_transform_match_statment(BlockNode *p_block, MatchNode *p_match_statement) { IdentifierNode *id = alloc_node<IdentifierNode>(); id->name = "#match_value"; @@ -2298,7 +2306,7 @@ void GDParser::_transform_match_statment(BlockNode *p_block, MatchNode *p_match_ } } -void GDParser::_parse_block(BlockNode *p_block, bool p_static) { +void GDScriptParser::_parse_block(BlockNode *p_block, bool p_static) { int indent_level = tab_level.back()->get(); @@ -2321,7 +2329,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { } is_first_line = false; - GDTokenizer::Token token = tokenizer->get_token(); + GDScriptTokenizer::Token token = tokenizer->get_token(); if (error_set) return; @@ -2340,15 +2348,15 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { switch (token) { - case GDTokenizer::TK_EOF: + case GDScriptTokenizer::TK_EOF: p_block->end_line = tokenizer->get_token_line(); - case GDTokenizer::TK_ERROR: { + case GDScriptTokenizer::TK_ERROR: { return; //go back //end of file! } break; - case GDTokenizer::TK_NEWLINE: { + case GDScriptTokenizer::TK_NEWLINE: { if (!_parse_newline()) { if (!error_set) { @@ -2363,19 +2371,19 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { p_block->statements.push_back(nl); } break; - case GDTokenizer::TK_CF_PASS: { - if (tokenizer->get_token(1) != GDTokenizer::TK_SEMICOLON && tokenizer->get_token(1) != GDTokenizer::TK_NEWLINE && tokenizer->get_token(1) != GDTokenizer::TK_EOF) { + case GDScriptTokenizer::TK_CF_PASS: { + if (tokenizer->get_token(1) != GDScriptTokenizer::TK_SEMICOLON && tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE && tokenizer->get_token(1) != GDScriptTokenizer::TK_EOF) { _set_error("Expected ';' or <NewLine>."); return; } tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_SEMICOLON) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_SEMICOLON) { // Ignore semicolon after 'pass' tokenizer->advance(); } } break; - case GDTokenizer::TK_PR_VAR: { + case GDScriptTokenizer::TK_PR_VAR: { //variale declaration and (eventual) initialization tokenizer->advance(); @@ -2414,7 +2422,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { Node *assigned = NULL; - if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) { tokenizer->advance(); Node *subexpr = _parse_and_reduce_expression(p_block, p_static); @@ -2452,7 +2460,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { } } break; - case GDTokenizer::TK_CF_IF: { + case GDScriptTokenizer::TK_CF_IF: { tokenizer->advance(); @@ -2491,7 +2499,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { while (true) { - while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE && _parse_newline()) + while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE && _parse_newline()) ; if (tab_level.back()->get() < indent_level) { //not at current indent level @@ -2499,7 +2507,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { return; } - if (tokenizer->get_token() == GDTokenizer::TK_CF_ELIF) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_CF_ELIF) { if (tab_level.back()->get() > indent_level) { @@ -2545,7 +2553,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { if (error_set) return; - } else if (tokenizer->get_token() == GDTokenizer::TK_CF_ELSE) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CF_ELSE) { if (tab_level.back()->get() > indent_level) { _set_error("Invalid indent"); @@ -2575,7 +2583,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { } } break; - case GDTokenizer::TK_CF_WHILE: { + case GDScriptTokenizer::TK_CF_WHILE: { tokenizer->advance(); Node *condition = _parse_and_reduce_expression(p_block, p_static); @@ -2608,7 +2616,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { return; p_block->statements.push_back(cf_while); } break; - case GDTokenizer::TK_CF_FOR: { + case GDScriptTokenizer::TK_CF_FOR: { tokenizer->advance(); @@ -2622,7 +2630,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_OP_IN) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_OP_IN) { _set_error("'in' expected after identifier"); return; } @@ -2640,7 +2648,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { if (container->type == Node::TYPE_OPERATOR) { OperatorNode *op = static_cast<OperatorNode *>(container); - if (op->op == OperatorNode::OP_CALL && op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && static_cast<BuiltInFunctionNode *>(op->arguments[0])->function == GDFunctions::GEN_RANGE) { + if (op->op == OperatorNode::OP_CALL && op->arguments[0]->type == Node::TYPE_BUILT_IN_FUNCTION && static_cast<BuiltInFunctionNode *>(op->arguments[0])->function == GDScriptFunctions::GEN_RANGE) { //iterating a range, so see if range() can be optimized without allocating memory, by replacing it by vectors (which can work as iterable too!) Vector<Node *> args; @@ -2726,7 +2734,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { return; p_block->statements.push_back(cf_for); } break; - case GDTokenizer::TK_CF_CONTINUE: { + case GDScriptTokenizer::TK_CF_CONTINUE: { tokenizer->advance(); ControlFlowNode *cf_continue = alloc_node<ControlFlowNode>(); @@ -2737,7 +2745,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { return; } } break; - case GDTokenizer::TK_CF_BREAK: { + case GDScriptTokenizer::TK_CF_BREAK: { tokenizer->advance(); ControlFlowNode *cf_break = alloc_node<ControlFlowNode>(); @@ -2748,13 +2756,13 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { return; } } break; - case GDTokenizer::TK_CF_RETURN: { + case GDScriptTokenizer::TK_CF_RETURN: { tokenizer->advance(); ControlFlowNode *cf_return = alloc_node<ControlFlowNode>(); cf_return->cf_type = ControlFlowNode::CF_RETURN; - if (tokenizer->get_token() == GDTokenizer::TK_SEMICOLON || tokenizer->get_token() == GDTokenizer::TK_NEWLINE || tokenizer->get_token() == GDTokenizer::TK_EOF) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_SEMICOLON || tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE || tokenizer->get_token() == GDScriptTokenizer::TK_EOF) { //expect end of statement p_block->statements.push_back(cf_return); if (!_end_statement()) { @@ -2778,7 +2786,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { } } break; - case GDTokenizer::TK_CF_MATCH: { + case GDScriptTokenizer::TK_CF_MATCH: { tokenizer->advance(); @@ -2818,7 +2826,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { _end_statement(); } break; - case GDTokenizer::TK_PR_ASSERT: { + case GDScriptTokenizer::TK_PR_ASSERT: { tokenizer->advance(); Node *condition = _parse_and_reduce_expression(p_block, p_static); @@ -2837,7 +2845,7 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { return; } } break; - case GDTokenizer::TK_PR_BREAKPOINT: { + case GDScriptTokenizer::TK_PR_BREAKPOINT: { tokenizer->advance(); BreakpointNode *bn = alloc_node<BreakpointNode>(); @@ -2865,9 +2873,9 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { } break; /* - case GDTokenizer::TK_CF_LOCAL: { + case GDScriptTokenizer::TK_CF_LOCAL: { - if (tokenizer->get_token(1)!=GDTokenizer::TK_SEMICOLON && tokenizer->get_token(1)!=GDTokenizer::TK_NEWLINE ) { + if (tokenizer->get_token(1)!=GDScriptTokenizer::TK_SEMICOLON && tokenizer->get_token(1)!=GDScriptTokenizer::TK_NEWLINE ) { _set_error("Expected ';' or <NewLine>."); } @@ -2878,9 +2886,9 @@ void GDParser::_parse_block(BlockNode *p_block, bool p_static) { } } -bool GDParser::_parse_newline() { +bool GDScriptParser::_parse_newline() { - if (tokenizer->get_token(1) != GDTokenizer::TK_EOF && tokenizer->get_token(1) != GDTokenizer::TK_NEWLINE) { + if (tokenizer->get_token(1) != GDScriptTokenizer::TK_EOF && tokenizer->get_token(1) != GDScriptTokenizer::TK_NEWLINE) { int indent = tokenizer->get_token_line_indent(); int current_indent = tab_level.back()->get(); @@ -2919,7 +2927,7 @@ bool GDParser::_parse_newline() { return true; } -void GDParser::_parse_extends(ClassNode *p_class) { +void GDScriptParser::_parse_extends(ClassNode *p_class) { if (p_class->extends_used) { @@ -2937,14 +2945,14 @@ void GDParser::_parse_extends(ClassNode *p_class) { tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token_type() == Variant::OBJECT) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE && tokenizer->get_token_type() == Variant::OBJECT) { p_class->extends_class.push_back(Variant::get_type_name(Variant::OBJECT)); tokenizer->advance(); return; } // see if inheritance happens from a file - if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT) { Variant constant = tokenizer->get_token_constant(); if (constant.get_type() != Variant::STRING) { @@ -2956,14 +2964,14 @@ void GDParser::_parse_extends(ClassNode *p_class) { p_class->extends_file = constant; tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_PERIOD) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PERIOD) { return; } else tokenizer->advance(); } while (true) { - if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER) { _set_error("Invalid 'extends' syntax, expected string constant (path) and/or identifier (parent class)."); return; @@ -2973,18 +2981,18 @@ void GDParser::_parse_extends(ClassNode *p_class) { p_class->extends_class.push_back(identifier); tokenizer->advance(1); - if (tokenizer->get_token() != GDTokenizer::TK_PERIOD) + if (tokenizer->get_token() != GDScriptTokenizer::TK_PERIOD) return; } } -void GDParser::_parse_class(ClassNode *p_class) { +void GDScriptParser::_parse_class(ClassNode *p_class) { int indent_level = tab_level.back()->get(); while (true) { - GDTokenizer::Token token = tokenizer->get_token(); + GDScriptTokenizer::Token token = tokenizer->get_token(); if (error_set) return; @@ -2995,13 +3003,13 @@ void GDParser::_parse_class(ClassNode *p_class) { switch (token) { - case GDTokenizer::TK_EOF: + case GDScriptTokenizer::TK_EOF: p_class->end_line = tokenizer->get_token_line(); - case GDTokenizer::TK_ERROR: { + case GDScriptTokenizer::TK_ERROR: { return; //go back //end of file! } break; - case GDTokenizer::TK_NEWLINE: { + case GDScriptTokenizer::TK_NEWLINE: { if (!_parse_newline()) { if (!error_set) { p_class->end_line = tokenizer->get_token_line(); @@ -3009,7 +3017,7 @@ void GDParser::_parse_class(ClassNode *p_class) { return; } } break; - case GDTokenizer::TK_PR_EXTENDS: { + case GDScriptTokenizer::TK_PR_EXTENDS: { _parse_extends(p_class); if (error_set) @@ -3020,7 +3028,7 @@ void GDParser::_parse_class(ClassNode *p_class) { } } break; - case GDTokenizer::TK_PR_TOOL: { + case GDScriptTokenizer::TK_PR_TOOL: { if (p_class->tool) { @@ -3032,13 +3040,13 @@ void GDParser::_parse_class(ClassNode *p_class) { tokenizer->advance(); } break; - case GDTokenizer::TK_PR_CLASS: { + case GDScriptTokenizer::TK_PR_CLASS: { //class inside class :D StringName name; StringName extends; - if (tokenizer->get_token(1) != GDTokenizer::TK_IDENTIFIER) { + if (tokenizer->get_token(1) != GDScriptTokenizer::TK_IDENTIFIER) { _set_error("'class' syntax: 'class <Name>:' or 'class <Name> extends <BaseClass>:'"); return; @@ -3056,7 +3064,7 @@ void GDParser::_parse_class(ClassNode *p_class) { p_class->subclasses.push_back(newclass); - if (tokenizer->get_token() == GDTokenizer::TK_PR_EXTENDS) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_EXTENDS) { _parse_extends(newclass); if (error_set) @@ -3074,26 +3082,26 @@ void GDParser::_parse_class(ClassNode *p_class) { } break; /* this is for functions.... - case GDTokenizer::TK_CF_PASS: { + case GDScriptTokenizer::TK_CF_PASS: { tokenizer->advance(1); } break; */ - case GDTokenizer::TK_PR_STATIC: { + case GDScriptTokenizer::TK_PR_STATIC: { tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) { _set_error("Expected 'func'."); return; } }; //fallthrough to function - case GDTokenizer::TK_PR_FUNCTION: { + case GDScriptTokenizer::TK_PR_FUNCTION: { bool _static = false; pending_newline = -1; - if (tokenizer->get_token(-1) == GDTokenizer::TK_PR_STATIC) { + if (tokenizer->get_token(-1) == GDScriptTokenizer::TK_PR_STATIC) { _static = true; } @@ -3121,7 +3129,7 @@ void GDParser::_parse_class(ClassNode *p_class) { } } - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) { _set_error("Expected '(' after identifier (syntax: 'func <identifier>([arguments]):' )."); return; @@ -3134,17 +3142,17 @@ void GDParser::_parse_class(ClassNode *p_class) { int fnline = tokenizer->get_token_line(); - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { //has arguments bool defaulting = false; while (true) { - if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) { tokenizer->advance(); continue; } - if (tokenizer->get_token() == GDTokenizer::TK_PR_VAR) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_VAR) { tokenizer->advance(); //var before the identifier is allowed } @@ -3160,7 +3168,7 @@ void GDParser::_parse_class(ClassNode *p_class) { tokenizer->advance(); - if (defaulting && tokenizer->get_token() != GDTokenizer::TK_OP_ASSIGN) { + if (defaulting && tokenizer->get_token() != GDScriptTokenizer::TK_OP_ASSIGN) { _set_error("Default parameter expected."); return; @@ -3168,7 +3176,7 @@ void GDParser::_parse_class(ClassNode *p_class) { //tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) { defaulting = true; tokenizer->advance(1); Node *defval = _parse_and_reduce_expression(p_class, _static); @@ -3192,14 +3200,14 @@ void GDParser::_parse_class(ClassNode *p_class) { default_values.push_back(on); } - while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) { + while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) { tokenizer->advance(); } - if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { tokenizer->advance(); continue; - } else if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + } else if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ',' or ')'."); return; @@ -3226,14 +3234,14 @@ void GDParser::_parse_class(ClassNode *p_class) { id->name = "_init"; cparent->arguments.push_back(id); - if (tokenizer->get_token() == GDTokenizer::TK_PERIOD) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD) { tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_OPEN) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_OPEN) { _set_error("expected '(' for parent constructor arguments."); } tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { //has arguments parenthesis++; while (true) { @@ -3241,10 +3249,10 @@ void GDParser::_parse_class(ClassNode *p_class) { Node *arg = _parse_and_reduce_expression(p_class, _static); cparent->arguments.push_back(arg); - if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { tokenizer->advance(); continue; - } else if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + } else if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ',' or ')'."); return; @@ -3259,7 +3267,7 @@ void GDParser::_parse_class(ClassNode *p_class) { } } else { - if (tokenizer->get_token() == GDTokenizer::TK_PERIOD) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PERIOD) { _set_error("Parent constructor call found for a class without inheritance."); return; @@ -3296,7 +3304,7 @@ void GDParser::_parse_class(ClassNode *p_class) { //arguments } break; - case GDTokenizer::TK_PR_SIGNAL: { + case GDScriptTokenizer::TK_PR_SIGNAL: { tokenizer->advance(); if (!tokenizer->is_token_literal()) { @@ -3308,15 +3316,15 @@ void GDParser::_parse_class(ClassNode *p_class) { sig.name = tokenizer->get_token_identifier(); tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) { tokenizer->advance(); while (true) { - if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) { tokenizer->advance(); continue; } - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { tokenizer->advance(); break; } @@ -3329,13 +3337,13 @@ void GDParser::_parse_class(ClassNode *p_class) { sig.arguments.push_back(tokenizer->get_token_identifier()); tokenizer->advance(); - while (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) { + while (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) { tokenizer->advance(); } - if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { tokenizer->advance(); - } else if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + } else if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ',' or ')' after signal parameter identifier."); return; } @@ -3349,14 +3357,14 @@ void GDParser::_parse_class(ClassNode *p_class) { return; } } break; - case GDTokenizer::TK_PR_EXPORT: { + case GDScriptTokenizer::TK_PR_EXPORT: { tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_OPEN) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_OPEN) { tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) { Variant::Type type = tokenizer->get_token_type(); if (type == Variant::NIL) { @@ -3369,17 +3377,17 @@ void GDParser::_parse_class(ClassNode *p_class) { String hint_prefix = ""; - if (type == Variant::ARRAY && tokenizer->get_token() == GDTokenizer::TK_COMMA) { + if (type == Variant::ARRAY && tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { tokenizer->advance(); - while (tokenizer->get_token() == GDTokenizer::TK_BUILT_IN_TYPE) { + while (tokenizer->get_token() == GDScriptTokenizer::TK_BUILT_IN_TYPE) { type = tokenizer->get_token_type(); tokenizer->advance(); if (type == Variant::ARRAY) { hint_prefix += itos(Variant::ARRAY) + ":"; - if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { tokenizer->advance(); } } else { @@ -3389,7 +3397,7 @@ void GDParser::_parse_class(ClassNode *p_class) { } } - if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { // hint expected next! tokenizer->advance(); @@ -3397,15 +3405,15 @@ void GDParser::_parse_class(ClassNode *p_class) { case Variant::INT: { - if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FLAGS") { + if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FLAGS") { //current_export.hint=PROPERTY_HINT_ALL_FLAGS; tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { break; } - if (tokenizer->get_token() != GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) { _set_error("Expected ')' or ',' in bit flags hint."); return; } @@ -3416,7 +3424,7 @@ void GDParser::_parse_class(ClassNode *p_class) { bool first = true; while (true) { - if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) { current_export = PropertyInfo(); _set_error("Expected a string constant in named bit flags hint."); return; @@ -3431,10 +3439,10 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export.hint_string += c.xml_escape(); tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) break; - if (tokenizer->get_token() != GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) { current_export = PropertyInfo(); _set_error("Expected ')' or ',' in named bit flags hint."); return; @@ -3445,13 +3453,13 @@ void GDParser::_parse_class(ClassNode *p_class) { break; } - if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) { //enumeration current_export.hint = PROPERTY_HINT_ENUM; bool first = true; while (true) { - if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) { current_export = PropertyInfo(); _set_error("Expected a string constant in enumeration hint."); @@ -3467,10 +3475,10 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export.hint_string += c.xml_escape(); tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) break; - if (tokenizer->get_token() != GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) { current_export = PropertyInfo(); _set_error("Expected ')' or ',' in enumeration hint."); return; @@ -3485,10 +3493,10 @@ void GDParser::_parse_class(ClassNode *p_class) { }; //fallthrough to use the same case Variant::REAL: { - if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EASE") { + if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EASE") { current_export.hint = PROPERTY_HINT_EXP_EASING; tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ')' in hint."); return; } @@ -3496,14 +3504,14 @@ void GDParser::_parse_class(ClassNode *p_class) { } // range - if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EXP") { + if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "EXP") { current_export.hint = PROPERTY_HINT_EXP_RANGE; tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) break; - else if (tokenizer->get_token() != GDTokenizer::TK_COMMA) { + else if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) { _set_error("Expected ')' or ',' in exponential range hint."); return; } @@ -3513,11 +3521,11 @@ void GDParser::_parse_class(ClassNode *p_class) { float sign = 1.0; - if (tokenizer->get_token() == GDTokenizer::TK_OP_SUB) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB) { sign = -1; tokenizer->advance(); } - if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) { current_export = PropertyInfo(); _set_error("Expected a range in numeric hint."); @@ -3527,12 +3535,12 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export.hint_string = rtos(sign * double(tokenizer->get_token_constant())); tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { current_export.hint_string = "0," + current_export.hint_string; break; } - if (tokenizer->get_token() != GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) { current_export = PropertyInfo(); _set_error("Expected ',' or ')' in numeric range hint."); @@ -3542,12 +3550,12 @@ void GDParser::_parse_class(ClassNode *p_class) { tokenizer->advance(); sign = 1.0; - if (tokenizer->get_token() == GDTokenizer::TK_OP_SUB) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB) { sign = -1; tokenizer->advance(); } - if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) { current_export = PropertyInfo(); _set_error("Expected a number as upper bound in numeric range hint."); @@ -3557,10 +3565,10 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export.hint_string += "," + rtos(sign * double(tokenizer->get_token_constant())); tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) break; - if (tokenizer->get_token() != GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) { current_export = PropertyInfo(); _set_error("Expected ',' or ')' in numeric range hint."); @@ -3569,12 +3577,12 @@ void GDParser::_parse_class(ClassNode *p_class) { tokenizer->advance(); sign = 1.0; - if (tokenizer->get_token() == GDTokenizer::TK_OP_SUB) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_SUB) { sign = -1; tokenizer->advance(); } - if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || !tokenizer->get_token_constant().is_num()) { current_export = PropertyInfo(); _set_error("Expected a number as step in numeric range hint."); @@ -3587,13 +3595,13 @@ void GDParser::_parse_class(ClassNode *p_class) { } break; case Variant::STRING: { - if (tokenizer->get_token() == GDTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_CONSTANT && tokenizer->get_token_constant().get_type() == Variant::STRING) { //enumeration current_export.hint = PROPERTY_HINT_ENUM; bool first = true; while (true) { - if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) { current_export = PropertyInfo(); _set_error("Expected a string constant in enumeration hint."); @@ -3608,10 +3616,10 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export.hint_string += c.xml_escape(); tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) break; - if (tokenizer->get_token() != GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) { current_export = PropertyInfo(); _set_error("Expected ')' or ',' in enumeration hint."); return; @@ -3622,17 +3630,17 @@ void GDParser::_parse_class(ClassNode *p_class) { break; } - if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "DIR") { + if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "DIR") { tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) current_export.hint = PROPERTY_HINT_DIR; - else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER || !(tokenizer->get_token_identifier() == "GLOBAL")) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER || !(tokenizer->get_token_identifier() == "GLOBAL")) { _set_error("Expected 'GLOBAL' after comma in directory hint."); return; } @@ -3643,7 +3651,7 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export.hint = PROPERTY_HINT_GLOBAL_DIR; tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ')' in hint."); return; } @@ -3654,16 +3662,16 @@ void GDParser::_parse_class(ClassNode *p_class) { break; } - if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FILE") { + if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "FILE") { current_export.hint = PROPERTY_HINT_FILE; tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "GLOBAL") { + if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "GLOBAL") { if (!p_class->tool) { _set_error("Global filesystem hints may only be used in tool scripts."); @@ -3672,9 +3680,9 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export.hint = PROPERTY_HINT_GLOBAL_FILE; tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_PARENTHESIS_CLOSE) + if (tokenizer->get_token() == GDScriptTokenizer::TK_PARENTHESIS_CLOSE) break; - else if (tokenizer->get_token() == GDTokenizer::TK_COMMA) + else if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) tokenizer->advance(); else { _set_error("Expected ')' or ',' in hint."); @@ -3682,7 +3690,7 @@ void GDParser::_parse_class(ClassNode *p_class) { } } - if (tokenizer->get_token() != GDTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_CONSTANT || tokenizer->get_token_constant().get_type() != Variant::STRING) { if (current_export.hint == PROPERTY_HINT_GLOBAL_FILE) _set_error("Expected string constant with filter"); @@ -3694,18 +3702,18 @@ void GDParser::_parse_class(ClassNode *p_class) { tokenizer->advance(); } - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ')' in hint."); return; } break; } - if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "MULTILINE") { + if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER && tokenizer->get_token_identifier() == "MULTILINE") { current_export.hint = PROPERTY_HINT_MULTILINE_TEXT; tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { _set_error("Expected ')' in hint."); return; } @@ -3714,7 +3722,7 @@ void GDParser::_parse_class(ClassNode *p_class) { } break; case Variant::COLOR: { - if (tokenizer->get_token() != GDTokenizer::TK_IDENTIFIER) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_IDENTIFIER) { current_export = PropertyInfo(); _set_error("Color type hint expects RGB or RGBA as hints"); @@ -3750,7 +3758,7 @@ void GDParser::_parse_class(ClassNode *p_class) { current_export.hint = PROPERTY_HINT_NONE; } - } else if (tokenizer->get_token() == GDTokenizer::TK_IDENTIFIER) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_IDENTIFIER) { String identifier = tokenizer->get_token_identifier(); if (!ClassDB::is_parent_class(identifier, "Resource")) { @@ -3768,7 +3776,7 @@ void GDParser::_parse_class(ClassNode *p_class) { tokenizer->advance(); } - if (tokenizer->get_token() != GDTokenizer::TK_PARENTHESIS_CLOSE) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PARENTHESIS_CLOSE) { current_export = PropertyInfo(); _set_error("Expected ')' or ',' after export hint."); @@ -3778,7 +3786,7 @@ void GDParser::_parse_class(ClassNode *p_class) { tokenizer->advance(); } - if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_ONREADY && tokenizer->get_token() != GDTokenizer::TK_PR_REMOTE && tokenizer->get_token() != GDTokenizer::TK_PR_MASTER && tokenizer->get_token() != GDTokenizer::TK_PR_SLAVE && tokenizer->get_token() != GDTokenizer::TK_PR_SYNC) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_ONREADY && tokenizer->get_token() != GDScriptTokenizer::TK_PR_REMOTE && tokenizer->get_token() != GDScriptTokenizer::TK_PR_MASTER && tokenizer->get_token() != GDScriptTokenizer::TK_PR_SLAVE && tokenizer->get_token() != GDScriptTokenizer::TK_PR_SYNC) { current_export = PropertyInfo(); _set_error("Expected 'var', 'onready', 'remote', 'master', 'slave' or 'sync'."); @@ -3787,29 +3795,29 @@ void GDParser::_parse_class(ClassNode *p_class) { continue; } break; - case GDTokenizer::TK_PR_ONREADY: { + case GDScriptTokenizer::TK_PR_ONREADY: { //may be fallthrough from export, ignore if so tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) { _set_error("Expected 'var'."); return; } continue; } break; - case GDTokenizer::TK_PR_REMOTE: { + case GDScriptTokenizer::TK_PR_REMOTE: { //may be fallthrough from export, ignore if so tokenizer->advance(); if (current_export.type) { - if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) { _set_error("Expected 'var'."); return; } } else { - if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) { _set_error("Expected 'var' or 'func'."); return; } @@ -3818,18 +3826,18 @@ void GDParser::_parse_class(ClassNode *p_class) { continue; } break; - case GDTokenizer::TK_PR_MASTER: { + case GDScriptTokenizer::TK_PR_MASTER: { //may be fallthrough from export, ignore if so tokenizer->advance(); if (current_export.type) { - if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) { _set_error("Expected 'var'."); return; } } else { - if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) { _set_error("Expected 'var' or 'func'."); return; } @@ -3838,18 +3846,18 @@ void GDParser::_parse_class(ClassNode *p_class) { rpc_mode = ScriptInstance::RPC_MODE_MASTER; continue; } break; - case GDTokenizer::TK_PR_SLAVE: { + case GDScriptTokenizer::TK_PR_SLAVE: { //may be fallthrough from export, ignore if so tokenizer->advance(); if (current_export.type) { - if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR) { _set_error("Expected 'var'."); return; } } else { - if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) { _set_error("Expected 'var' or 'func'."); return; } @@ -3858,11 +3866,11 @@ void GDParser::_parse_class(ClassNode *p_class) { rpc_mode = ScriptInstance::RPC_MODE_SLAVE; continue; } break; - case GDTokenizer::TK_PR_SYNC: { + case GDScriptTokenizer::TK_PR_SYNC: { //may be fallthrough from export, ignore if so tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_PR_VAR && tokenizer->get_token() != GDTokenizer::TK_PR_FUNCTION) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_PR_VAR && tokenizer->get_token() != GDScriptTokenizer::TK_PR_FUNCTION) { if (current_export.type) _set_error("Expected 'var'."); else @@ -3873,17 +3881,17 @@ void GDParser::_parse_class(ClassNode *p_class) { rpc_mode = ScriptInstance::RPC_MODE_SYNC; continue; } break; - case GDTokenizer::TK_PR_VAR: { + case GDScriptTokenizer::TK_PR_VAR: { //variale declaration and (eventual) initialization ClassNode::Member member; - bool autoexport = tokenizer->get_token(-1) == GDTokenizer::TK_PR_EXPORT; + bool autoexport = tokenizer->get_token(-1) == GDScriptTokenizer::TK_PR_EXPORT; if (current_export.type != Variant::NIL) { member._export = current_export; current_export = PropertyInfo(); } - bool onready = tokenizer->get_token(-1) == GDTokenizer::TK_PR_ONREADY; + bool onready = tokenizer->get_token(-1) == GDScriptTokenizer::TK_PR_ONREADY; tokenizer->advance(); if (!tokenizer->is_token_literal(0, true)) { @@ -3902,7 +3910,7 @@ void GDParser::_parse_class(ClassNode *p_class) { rpc_mode = ScriptInstance::RPC_MODE_DISABLED; - if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) { #ifdef DEBUG_ENABLED int line = tokenizer->get_token_line(); @@ -4010,11 +4018,11 @@ void GDParser::_parse_class(ClassNode *p_class) { } } - if (tokenizer->get_token() == GDTokenizer::TK_PR_SETGET) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_PR_SETGET) { tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_COMMA) { //just comma means using only getter if (!tokenizer->is_token_literal()) { _set_error("Expected identifier for setter function after 'setget'."); @@ -4025,7 +4033,7 @@ void GDParser::_parse_class(ClassNode *p_class) { tokenizer->advance(); } - if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { //there is a getter tokenizer->advance(); @@ -4045,7 +4053,7 @@ void GDParser::_parse_class(ClassNode *p_class) { return; } } break; - case GDTokenizer::TK_PR_CONST: { + case GDScriptTokenizer::TK_PR_CONST: { //variale declaration and (eventual) initialization ClassNode::Constant constant; @@ -4060,7 +4068,7 @@ void GDParser::_parse_class(ClassNode *p_class) { constant.identifier = tokenizer->get_token_literal(); tokenizer->advance(); - if (tokenizer->get_token() != GDTokenizer::TK_OP_ASSIGN) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_OP_ASSIGN) { _set_error("Constant expects assignment."); return; } @@ -4088,7 +4096,7 @@ void GDParser::_parse_class(ClassNode *p_class) { } } break; - case GDTokenizer::TK_PR_ENUM: { + case GDScriptTokenizer::TK_PR_ENUM: { //mutiple constant declarations.. int last_assign = -1; // Incremented by 1 right before the assingment. @@ -4100,26 +4108,26 @@ void GDParser::_parse_class(ClassNode *p_class) { enum_name = tokenizer->get_token_literal(); tokenizer->advance(); } - if (tokenizer->get_token() != GDTokenizer::TK_CURLY_BRACKET_OPEN) { + if (tokenizer->get_token() != GDScriptTokenizer::TK_CURLY_BRACKET_OPEN) { _set_error("Expected '{' in enum declaration"); return; } tokenizer->advance(); while (true) { - if (tokenizer->get_token() == GDTokenizer::TK_NEWLINE) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_NEWLINE) { tokenizer->advance(); // Ignore newlines - } else if (tokenizer->get_token() == GDTokenizer::TK_CURLY_BRACKET_CLOSE) { + } else if (tokenizer->get_token() == GDScriptTokenizer::TK_CURLY_BRACKET_CLOSE) { tokenizer->advance(); break; // End of enum } else if (!tokenizer->is_token_literal(0, true)) { - if (tokenizer->get_token() == GDTokenizer::TK_EOF) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_EOF) { _set_error("Unexpected end of file."); } else { - _set_error(String("Unexpected ") + GDTokenizer::get_token_name(tokenizer->get_token()) + ", expected identifier"); + _set_error(String("Unexpected ") + GDScriptTokenizer::get_token_name(tokenizer->get_token()) + ", expected identifier"); } return; @@ -4130,7 +4138,7 @@ void GDParser::_parse_class(ClassNode *p_class) { tokenizer->advance(); - if (tokenizer->get_token() == GDTokenizer::TK_OP_ASSIGN) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_OP_ASSIGN) { tokenizer->advance(); Node *subexpr = _parse_and_reduce_expression(p_class, true, true); @@ -4162,7 +4170,7 @@ void GDParser::_parse_class(ClassNode *p_class) { constant.expression = cn; } - if (tokenizer->get_token() == GDTokenizer::TK_COMMA) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_COMMA) { tokenizer->advance(); } @@ -4191,7 +4199,7 @@ void GDParser::_parse_class(ClassNode *p_class) { } break; - case GDTokenizer::TK_CONSTANT: { + case GDScriptTokenizer::TK_CONSTANT: { if (tokenizer->get_token_constant().get_type() == Variant::STRING) { tokenizer->advance(); // Ignore @@ -4211,7 +4219,7 @@ void GDParser::_parse_class(ClassNode *p_class) { } } -void GDParser::_set_error(const String &p_error, int p_line, int p_column) { +void GDScriptParser::_set_error(const String &p_error, int p_line, int p_column) { if (error_set) return; //allow no further errors @@ -4222,21 +4230,21 @@ void GDParser::_set_error(const String &p_error, int p_line, int p_column) { error_set = true; } -String GDParser::get_error() const { +String GDScriptParser::get_error() const { return error; } -int GDParser::get_error_line() const { +int GDScriptParser::get_error_line() const { return error_line; } -int GDParser::get_error_column() const { +int GDScriptParser::get_error_column() const { return error_column; } -Error GDParser::_parse(const String &p_base_path) { +Error GDScriptParser::_parse(const String &p_base_path) { base_path = p_base_path; @@ -4252,7 +4260,7 @@ Error GDParser::_parse(const String &p_base_path) { _parse_class(main_class); - if (tokenizer->get_token() == GDTokenizer::TK_ERROR) { + if (tokenizer->get_token() == GDScriptTokenizer::TK_ERROR) { error_set = false; _set_error("Parse Error: " + tokenizer->get_token_error()); } @@ -4264,7 +4272,7 @@ Error GDParser::_parse(const String &p_base_path) { return OK; } -Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &p_base_path, const String &p_self_path) { +Error GDScriptParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String &p_base_path, const String &p_self_path) { for_completion = false; validating = false; @@ -4279,7 +4287,7 @@ Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String & current_function = NULL; self_path = p_self_path; - GDTokenizerBuffer *tb = memnew(GDTokenizerBuffer); + GDScriptTokenizerBuffer *tb = memnew(GDScriptTokenizerBuffer); tb->set_code_buffer(p_bytecode); tokenizer = tb; Error ret = _parse(p_base_path); @@ -4288,7 +4296,7 @@ Error GDParser::parse_bytecode(const Vector<uint8_t> &p_bytecode, const String & return ret; } -Error GDParser::parse(const String &p_code, const String &p_base_path, bool p_just_validate, const String &p_self_path, bool p_for_completion) { +Error GDScriptParser::parse(const String &p_code, const String &p_base_path, bool p_just_validate, const String &p_self_path, bool p_for_completion) { completion_type = COMPLETION_NONE; completion_node = NULL; @@ -4302,7 +4310,7 @@ Error GDParser::parse(const String &p_code, const String &p_base_path, bool p_ju current_function = NULL; self_path = p_self_path; - GDTokenizerText *tt = memnew(GDTokenizerText); + GDScriptTokenizerText *tt = memnew(GDScriptTokenizerText); tt->set_code(p_code); validating = p_just_validate; @@ -4314,17 +4322,17 @@ Error GDParser::parse(const String &p_code, const String &p_base_path, bool p_ju return ret; } -bool GDParser::is_tool_script() const { +bool GDScriptParser::is_tool_script() const { return (head && head->type == Node::TYPE_CLASS && static_cast<const ClassNode *>(head)->tool); } -const GDParser::Node *GDParser::get_parse_tree() const { +const GDScriptParser::Node *GDScriptParser::get_parse_tree() const { return head; } -void GDParser::clear() { +void GDScriptParser::clear() { while (list) { @@ -4362,57 +4370,57 @@ void GDParser::clear() { error = ""; } -GDParser::CompletionType GDParser::get_completion_type() { +GDScriptParser::CompletionType GDScriptParser::get_completion_type() { return completion_type; } -StringName GDParser::get_completion_cursor() { +StringName GDScriptParser::get_completion_cursor() { return completion_cursor; } -int GDParser::get_completion_line() { +int GDScriptParser::get_completion_line() { return completion_line; } -Variant::Type GDParser::get_completion_built_in_constant() { +Variant::Type GDScriptParser::get_completion_built_in_constant() { return completion_built_in_constant; } -GDParser::Node *GDParser::get_completion_node() { +GDScriptParser::Node *GDScriptParser::get_completion_node() { return completion_node; } -GDParser::BlockNode *GDParser::get_completion_block() { +GDScriptParser::BlockNode *GDScriptParser::get_completion_block() { return completion_block; } -GDParser::ClassNode *GDParser::get_completion_class() { +GDScriptParser::ClassNode *GDScriptParser::get_completion_class() { return completion_class; } -GDParser::FunctionNode *GDParser::get_completion_function() { +GDScriptParser::FunctionNode *GDScriptParser::get_completion_function() { return completion_function; } -int GDParser::get_completion_argument_index() { +int GDScriptParser::get_completion_argument_index() { return completion_argument; } -int GDParser::get_completion_identifier_is_function() { +int GDScriptParser::get_completion_identifier_is_function() { return completion_ident_is_call; } -GDParser::GDParser() { +GDScriptParser::GDScriptParser() { head = NULL; list = NULL; @@ -4421,7 +4429,7 @@ GDParser::GDParser() { clear(); } -GDParser::~GDParser() { +GDScriptParser::~GDScriptParser() { clear(); } diff --git a/modules/gdscript/gd_parser.h b/modules/gdscript/gdscript_parser.h index 7e88fd9746..3c9c5ea02c 100644 --- a/modules/gdscript/gd_parser.h +++ b/modules/gdscript/gdscript_parser.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_parser.h */ +/* gdscript_parser.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,16 +27,16 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GD_PARSER_H -#define GD_PARSER_H +#ifndef GDSCRIPT_PARSER_H +#define GDSCRIPT_PARSER_H -#include "gd_functions.h" -#include "gd_tokenizer.h" +#include "gdscript_functions.h" +#include "gdscript_tokenizer.h" #include "map.h" #include "object.h" #include "script_language.h" -class GDParser { +class GDScriptParser { public: struct Node { @@ -166,7 +166,7 @@ public: TypeNode() { type = TYPE_TYPE; } }; struct BuiltInFunctionNode : public Node { - GDFunctions::Function function; + GDScriptFunctions::Function function; BuiltInFunctionNode() { type = TYPE_BUILT_IN_FUNCTION; } }; @@ -448,7 +448,7 @@ public: }; private: - GDTokenizer *tokenizer; + GDScriptTokenizer *tokenizer; Node *head; Node *list; @@ -540,8 +540,8 @@ public: int get_completion_identifier_is_function(); void clear(); - GDParser(); - ~GDParser(); + GDScriptParser(); + ~GDScriptParser(); }; -#endif // PARSER_H +#endif // GDSCRIPT_PARSER_H diff --git a/modules/gdscript/gd_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index 5f85158232..e3a0af8ee6 100644 --- a/modules/gdscript/gd_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_tokenizer.cpp */ +/* gdscript_tokenizer.cpp */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,14 +27,14 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#include "gd_tokenizer.h" +#include "gdscript_tokenizer.h" -#include "gd_functions.h" +#include "gdscript_functions.h" #include "io/marshalls.h" #include "map.h" #include "print_string.h" -const char *GDTokenizer::token_names[TK_MAX] = { +const char *GDScriptTokenizer::token_names[TK_MAX] = { "Empty", "Identifier", "Constant", @@ -123,6 +123,7 @@ const char *GDTokenizer::token_names[TK_MAX] = { "'$'", "'\\n'", "PI", + "TAU", "_", "INF", "NAN", @@ -147,7 +148,7 @@ static const _bit _type_list[] = { { Variant::RECT2, "Rect2" }, { Variant::TRANSFORM2D, "Transform2D" }, { Variant::VECTOR3, "Vector3" }, - { Variant::RECT3, "Rect3" }, + { Variant::AABB, "AABB" }, { Variant::PLANE, "Plane" }, { Variant::QUAT, "Quat" }, { Variant::BASIS, "Basis" }, @@ -169,67 +170,68 @@ static const _bit _type_list[] = { }; struct _kws { - GDTokenizer::Token token; + GDScriptTokenizer::Token token; const char *text; }; static const _kws _keyword_list[] = { //ops - { GDTokenizer::TK_OP_IN, "in" }, - { GDTokenizer::TK_OP_NOT, "not" }, - { GDTokenizer::TK_OP_OR, "or" }, - { GDTokenizer::TK_OP_AND, "and" }, + { GDScriptTokenizer::TK_OP_IN, "in" }, + { GDScriptTokenizer::TK_OP_NOT, "not" }, + { GDScriptTokenizer::TK_OP_OR, "or" }, + { GDScriptTokenizer::TK_OP_AND, "and" }, //func - { GDTokenizer::TK_PR_FUNCTION, "func" }, - { GDTokenizer::TK_PR_CLASS, "class" }, - { GDTokenizer::TK_PR_EXTENDS, "extends" }, - { GDTokenizer::TK_PR_IS, "is" }, - { GDTokenizer::TK_PR_ONREADY, "onready" }, - { GDTokenizer::TK_PR_TOOL, "tool" }, - { GDTokenizer::TK_PR_STATIC, "static" }, - { GDTokenizer::TK_PR_EXPORT, "export" }, - { GDTokenizer::TK_PR_SETGET, "setget" }, - { GDTokenizer::TK_PR_VAR, "var" }, - { GDTokenizer::TK_PR_PRELOAD, "preload" }, - { GDTokenizer::TK_PR_ASSERT, "assert" }, - { GDTokenizer::TK_PR_YIELD, "yield" }, - { GDTokenizer::TK_PR_SIGNAL, "signal" }, - { GDTokenizer::TK_PR_BREAKPOINT, "breakpoint" }, - { GDTokenizer::TK_PR_REMOTE, "remote" }, - { GDTokenizer::TK_PR_MASTER, "master" }, - { GDTokenizer::TK_PR_SLAVE, "slave" }, - { GDTokenizer::TK_PR_SYNC, "sync" }, - { GDTokenizer::TK_PR_CONST, "const" }, - { GDTokenizer::TK_PR_ENUM, "enum" }, + { GDScriptTokenizer::TK_PR_FUNCTION, "func" }, + { GDScriptTokenizer::TK_PR_CLASS, "class" }, + { GDScriptTokenizer::TK_PR_EXTENDS, "extends" }, + { GDScriptTokenizer::TK_PR_IS, "is" }, + { GDScriptTokenizer::TK_PR_ONREADY, "onready" }, + { GDScriptTokenizer::TK_PR_TOOL, "tool" }, + { GDScriptTokenizer::TK_PR_STATIC, "static" }, + { GDScriptTokenizer::TK_PR_EXPORT, "export" }, + { GDScriptTokenizer::TK_PR_SETGET, "setget" }, + { GDScriptTokenizer::TK_PR_VAR, "var" }, + { GDScriptTokenizer::TK_PR_PRELOAD, "preload" }, + { GDScriptTokenizer::TK_PR_ASSERT, "assert" }, + { GDScriptTokenizer::TK_PR_YIELD, "yield" }, + { GDScriptTokenizer::TK_PR_SIGNAL, "signal" }, + { GDScriptTokenizer::TK_PR_BREAKPOINT, "breakpoint" }, + { GDScriptTokenizer::TK_PR_REMOTE, "remote" }, + { GDScriptTokenizer::TK_PR_MASTER, "master" }, + { GDScriptTokenizer::TK_PR_SLAVE, "slave" }, + { GDScriptTokenizer::TK_PR_SYNC, "sync" }, + { GDScriptTokenizer::TK_PR_CONST, "const" }, + { GDScriptTokenizer::TK_PR_ENUM, "enum" }, //controlflow - { GDTokenizer::TK_CF_IF, "if" }, - { GDTokenizer::TK_CF_ELIF, "elif" }, - { GDTokenizer::TK_CF_ELSE, "else" }, - { GDTokenizer::TK_CF_FOR, "for" }, - { GDTokenizer::TK_CF_WHILE, "while" }, - { GDTokenizer::TK_CF_DO, "do" }, - { GDTokenizer::TK_CF_SWITCH, "switch" }, - { GDTokenizer::TK_CF_CASE, "case" }, - { GDTokenizer::TK_CF_BREAK, "break" }, - { GDTokenizer::TK_CF_CONTINUE, "continue" }, - { GDTokenizer::TK_CF_RETURN, "return" }, - { GDTokenizer::TK_CF_MATCH, "match" }, - { GDTokenizer::TK_CF_PASS, "pass" }, - { GDTokenizer::TK_SELF, "self" }, - { GDTokenizer::TK_CONST_PI, "PI" }, - { GDTokenizer::TK_WILDCARD, "_" }, - { GDTokenizer::TK_CONST_INF, "INF" }, - { GDTokenizer::TK_CONST_NAN, "NAN" }, - { GDTokenizer::TK_ERROR, NULL } + { GDScriptTokenizer::TK_CF_IF, "if" }, + { GDScriptTokenizer::TK_CF_ELIF, "elif" }, + { GDScriptTokenizer::TK_CF_ELSE, "else" }, + { GDScriptTokenizer::TK_CF_FOR, "for" }, + { GDScriptTokenizer::TK_CF_WHILE, "while" }, + { GDScriptTokenizer::TK_CF_DO, "do" }, + { GDScriptTokenizer::TK_CF_SWITCH, "switch" }, + { GDScriptTokenizer::TK_CF_CASE, "case" }, + { GDScriptTokenizer::TK_CF_BREAK, "break" }, + { GDScriptTokenizer::TK_CF_CONTINUE, "continue" }, + { GDScriptTokenizer::TK_CF_RETURN, "return" }, + { GDScriptTokenizer::TK_CF_MATCH, "match" }, + { GDScriptTokenizer::TK_CF_PASS, "pass" }, + { GDScriptTokenizer::TK_SELF, "self" }, + { GDScriptTokenizer::TK_CONST_PI, "PI" }, + { GDScriptTokenizer::TK_CONST_TAU, "TAU" }, + { GDScriptTokenizer::TK_WILDCARD, "_" }, + { GDScriptTokenizer::TK_CONST_INF, "INF" }, + { GDScriptTokenizer::TK_CONST_NAN, "NAN" }, + { GDScriptTokenizer::TK_ERROR, NULL } }; -const char *GDTokenizer::get_token_name(Token p_token) { +const char *GDScriptTokenizer::get_token_name(Token p_token) { ERR_FAIL_INDEX_V(p_token, TK_MAX, "<error>"); return token_names[p_token]; } -bool GDTokenizer::is_token_literal(int p_offset, bool variable_safe) const { +bool GDScriptTokenizer::is_token_literal(int p_offset, bool variable_safe) const { switch (get_token(p_offset)) { // Can always be literal: case TK_IDENTIFIER: @@ -251,9 +253,9 @@ bool GDTokenizer::is_token_literal(int p_offset, bool variable_safe) const { case TK_BUILT_IN_FUNC: case TK_OP_IN: - //case TK_OP_NOT: - //case TK_OP_OR: - //case TK_OP_AND: + //case TK_OP_NOT: + //case TK_OP_OR: + //case TK_OP_AND: case TK_PR_CLASS: case TK_PR_CONST: @@ -280,6 +282,7 @@ bool GDTokenizer::is_token_literal(int p_offset, bool variable_safe) const { case TK_CF_PASS: case TK_SELF: case TK_CONST_PI: + case TK_CONST_TAU: case TK_WILDCARD: case TK_CONST_INF: case TK_CONST_NAN: @@ -300,7 +303,7 @@ bool GDTokenizer::is_token_literal(int p_offset, bool variable_safe) const { } } -StringName GDTokenizer::get_token_literal(int p_offset) const { +StringName GDScriptTokenizer::get_token_literal(int p_offset) const { Token token = get_token(p_offset); switch (token) { case TK_IDENTIFIER: @@ -317,7 +320,7 @@ StringName GDTokenizer::get_token_literal(int p_offset) const { } } break; // Shouldn't get here, stuff happens case TK_BUILT_IN_FUNC: - return GDFunctions::get_func_name(get_token_built_in_func(p_offset)); + return GDScriptFunctions::get_func_name(get_token_built_in_func(p_offset)); case TK_CONSTANT: { const Variant value = get_token_constant(p_offset); @@ -362,7 +365,7 @@ static bool _is_hex(CharType c) { return (c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); } -void GDTokenizerText::_make_token(Token p_type) { +void GDScriptTokenizerText::_make_token(Token p_type) { TokenData &tk = tk_rb[tk_rb_pos]; @@ -372,7 +375,7 @@ void GDTokenizerText::_make_token(Token p_type) { tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE; } -void GDTokenizerText::_make_identifier(const StringName &p_identifier) { +void GDScriptTokenizerText::_make_identifier(const StringName &p_identifier) { TokenData &tk = tk_rb[tk_rb_pos]; @@ -384,7 +387,7 @@ void GDTokenizerText::_make_identifier(const StringName &p_identifier) { tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE; } -void GDTokenizerText::_make_built_in_func(GDFunctions::Function p_func) { +void GDScriptTokenizerText::_make_built_in_func(GDScriptFunctions::Function p_func) { TokenData &tk = tk_rb[tk_rb_pos]; @@ -395,7 +398,7 @@ void GDTokenizerText::_make_built_in_func(GDFunctions::Function p_func) { tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE; } -void GDTokenizerText::_make_constant(const Variant &p_constant) { +void GDScriptTokenizerText::_make_constant(const Variant &p_constant) { TokenData &tk = tk_rb[tk_rb_pos]; @@ -407,7 +410,7 @@ void GDTokenizerText::_make_constant(const Variant &p_constant) { tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE; } -void GDTokenizerText::_make_type(const Variant::Type &p_type) { +void GDScriptTokenizerText::_make_type(const Variant::Type &p_type) { TokenData &tk = tk_rb[tk_rb_pos]; @@ -419,7 +422,7 @@ void GDTokenizerText::_make_type(const Variant::Type &p_type) { tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE; } -void GDTokenizerText::_make_error(const String &p_error) { +void GDScriptTokenizerText::_make_error(const String &p_error) { error_flag = true; last_error = p_error; @@ -432,7 +435,7 @@ void GDTokenizerText::_make_error(const String &p_error) { tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE; } -void GDTokenizerText::_make_newline(int p_spaces) { +void GDScriptTokenizerText::_make_newline(int p_spaces) { TokenData &tk = tk_rb[tk_rb_pos]; tk.type = TK_NEWLINE; @@ -442,7 +445,7 @@ void GDTokenizerText::_make_newline(int p_spaces) { tk_rb_pos = (tk_rb_pos + 1) % TK_RB_SIZE; } -void GDTokenizerText::_advance() { +void GDScriptTokenizerText::_advance() { if (error_flag) { //parser broke @@ -882,6 +885,9 @@ void GDTokenizerText::_advance() { return; } sign_found = true; + } else if (GETCHAR(i) == '_') { + i++; + continue; // Included for readability, shouldn't be a part of the string } else break; @@ -894,7 +900,7 @@ void GDTokenizerText::_advance() { return; } - INCPOS(str.length()); + INCPOS(i); if (hexa_found) { int64_t val = str.hex_to_int64(); _make_constant(val); @@ -960,11 +966,11 @@ void GDTokenizerText::_advance() { //built in func? - for (int i = 0; i < GDFunctions::FUNC_MAX; i++) { + for (int i = 0; i < GDScriptFunctions::FUNC_MAX; i++) { - if (str == GDFunctions::get_func_name(GDFunctions::Function(i))) { + if (str == GDScriptFunctions::get_func_name(GDScriptFunctions::Function(i))) { - _make_built_in_func(GDFunctions::Function(i)); + _make_built_in_func(GDScriptFunctions::Function(i)); found = true; break; } @@ -1010,7 +1016,7 @@ void GDTokenizerText::_advance() { } } -void GDTokenizerText::set_code(const String &p_code) { +void GDScriptTokenizerText::set_code(const String &p_code) { code = p_code; len = p_code.length(); @@ -1029,7 +1035,7 @@ void GDTokenizerText::set_code(const String &p_code) { _advance(); } -GDTokenizerText::Token GDTokenizerText::get_token(int p_offset) const { +GDScriptTokenizerText::Token GDScriptTokenizerText::get_token(int p_offset) const { ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, TK_ERROR); ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, TK_ERROR); @@ -1037,7 +1043,7 @@ GDTokenizerText::Token GDTokenizerText::get_token(int p_offset) const { return tk_rb[ofs].type; } -int GDTokenizerText::get_token_line(int p_offset) const { +int GDScriptTokenizerText::get_token_line(int p_offset) const { ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, -1); ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, -1); @@ -1045,7 +1051,7 @@ int GDTokenizerText::get_token_line(int p_offset) const { return tk_rb[ofs].line; } -int GDTokenizerText::get_token_column(int p_offset) const { +int GDScriptTokenizerText::get_token_column(int p_offset) const { ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, -1); ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, -1); @@ -1053,7 +1059,7 @@ int GDTokenizerText::get_token_column(int p_offset) const { return tk_rb[ofs].col; } -const Variant &GDTokenizerText::get_token_constant(int p_offset) const { +const Variant &GDScriptTokenizerText::get_token_constant(int p_offset) const { ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, tk_rb[0].constant); ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, tk_rb[0].constant); @@ -1062,7 +1068,7 @@ const Variant &GDTokenizerText::get_token_constant(int p_offset) const { return tk_rb[ofs].constant; } -StringName GDTokenizerText::get_token_identifier(int p_offset) const { +StringName GDScriptTokenizerText::get_token_identifier(int p_offset) const { ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, StringName()); ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, StringName()); @@ -1072,17 +1078,17 @@ StringName GDTokenizerText::get_token_identifier(int p_offset) const { return tk_rb[ofs].identifier; } -GDFunctions::Function GDTokenizerText::get_token_built_in_func(int p_offset) const { +GDScriptFunctions::Function GDScriptTokenizerText::get_token_built_in_func(int p_offset) const { - ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, GDFunctions::FUNC_MAX); - ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, GDFunctions::FUNC_MAX); + ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, GDScriptFunctions::FUNC_MAX); + ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, GDScriptFunctions::FUNC_MAX); int ofs = (TK_RB_SIZE + tk_rb_pos + p_offset - MAX_LOOKAHEAD - 1) % TK_RB_SIZE; - ERR_FAIL_COND_V(tk_rb[ofs].type != TK_BUILT_IN_FUNC, GDFunctions::FUNC_MAX); + ERR_FAIL_COND_V(tk_rb[ofs].type != TK_BUILT_IN_FUNC, GDScriptFunctions::FUNC_MAX); return tk_rb[ofs].func; } -Variant::Type GDTokenizerText::get_token_type(int p_offset) const { +Variant::Type GDScriptTokenizerText::get_token_type(int p_offset) const { ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, Variant::NIL); ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, Variant::NIL); @@ -1092,7 +1098,7 @@ Variant::Type GDTokenizerText::get_token_type(int p_offset) const { return tk_rb[ofs].vtype; } -int GDTokenizerText::get_token_line_indent(int p_offset) const { +int GDScriptTokenizerText::get_token_line_indent(int p_offset) const { ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, 0); ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, 0); @@ -1102,7 +1108,7 @@ int GDTokenizerText::get_token_line_indent(int p_offset) const { return tk_rb[ofs].constant; } -String GDTokenizerText::get_token_error(int p_offset) const { +String GDScriptTokenizerText::get_token_error(int p_offset) const { ERR_FAIL_COND_V(p_offset <= -MAX_LOOKAHEAD, String()); ERR_FAIL_COND_V(p_offset >= MAX_LOOKAHEAD, String()); @@ -1112,18 +1118,18 @@ String GDTokenizerText::get_token_error(int p_offset) const { return tk_rb[ofs].constant; } -void GDTokenizerText::advance(int p_amount) { +void GDScriptTokenizerText::advance(int p_amount) { ERR_FAIL_COND(p_amount <= 0); for (int i = 0; i < p_amount; i++) _advance(); } -////////////////////////////////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////////////////////////////////// #define BYTECODE_VERSION 12 -Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) { +Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) { const uint8_t *buf = p_buffer.ptr(); int total_len = p_buffer.size(); @@ -1211,7 +1217,7 @@ Error GDTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer) { return OK; } -Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String &p_code) { +Vector<uint8_t> GDScriptTokenizerBuffer::parse_code_string(const String &p_code) { Vector<uint8_t> buf; @@ -1220,7 +1226,7 @@ Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String &p_code) { Map<uint32_t, int> line_map; Vector<uint32_t> token_array; - GDTokenizerText tt; + GDScriptTokenizerText tt; tt.set_code(p_code); int line = -1; @@ -1369,17 +1375,17 @@ Vector<uint8_t> GDTokenizerBuffer::parse_code_string(const String &p_code) { return buf; } -GDTokenizerBuffer::Token GDTokenizerBuffer::get_token(int p_offset) const { +GDScriptTokenizerBuffer::Token GDScriptTokenizerBuffer::get_token(int p_offset) const { int offset = token + p_offset; if (offset < 0 || offset >= tokens.size()) return TK_EOF; - return GDTokenizerBuffer::Token(tokens[offset] & TOKEN_MASK); + return GDScriptTokenizerBuffer::Token(tokens[offset] & TOKEN_MASK); } -StringName GDTokenizerBuffer::get_token_identifier(int p_offset) const { +StringName GDScriptTokenizerBuffer::get_token_identifier(int p_offset) const { int offset = token + p_offset; @@ -1390,14 +1396,14 @@ StringName GDTokenizerBuffer::get_token_identifier(int p_offset) const { return identifiers[identifier]; } -GDFunctions::Function GDTokenizerBuffer::get_token_built_in_func(int p_offset) const { +GDScriptFunctions::Function GDScriptTokenizerBuffer::get_token_built_in_func(int p_offset) const { int offset = token + p_offset; - ERR_FAIL_INDEX_V(offset, tokens.size(), GDFunctions::FUNC_MAX); - return GDFunctions::Function(tokens[offset] >> TOKEN_BITS); + ERR_FAIL_INDEX_V(offset, tokens.size(), GDScriptFunctions::FUNC_MAX); + return GDScriptFunctions::Function(tokens[offset] >> TOKEN_BITS); } -Variant::Type GDTokenizerBuffer::get_token_type(int p_offset) const { +Variant::Type GDScriptTokenizerBuffer::get_token_type(int p_offset) const { int offset = token + p_offset; ERR_FAIL_INDEX_V(offset, tokens.size(), Variant::NIL); @@ -1405,7 +1411,7 @@ Variant::Type GDTokenizerBuffer::get_token_type(int p_offset) const { return Variant::Type(tokens[offset] >> TOKEN_BITS); } -int GDTokenizerBuffer::get_token_line(int p_offset) const { +int GDScriptTokenizerBuffer::get_token_line(int p_offset) const { int offset = token + p_offset; int pos = lines.find_nearest(offset); @@ -1418,7 +1424,7 @@ int GDTokenizerBuffer::get_token_line(int p_offset) const { uint32_t l = lines.getv(pos); return l & TOKEN_LINE_MASK; } -int GDTokenizerBuffer::get_token_column(int p_offset) const { +int GDScriptTokenizerBuffer::get_token_column(int p_offset) const { int offset = token + p_offset; int pos = lines.find_nearest(offset); @@ -1430,13 +1436,13 @@ int GDTokenizerBuffer::get_token_column(int p_offset) const { uint32_t l = lines.getv(pos); return l >> TOKEN_LINE_BITS; } -int GDTokenizerBuffer::get_token_line_indent(int p_offset) const { +int GDScriptTokenizerBuffer::get_token_line_indent(int p_offset) const { int offset = token + p_offset; ERR_FAIL_INDEX_V(offset, tokens.size(), 0); return tokens[offset] >> TOKEN_BITS; } -const Variant &GDTokenizerBuffer::get_token_constant(int p_offset) const { +const Variant &GDScriptTokenizerBuffer::get_token_constant(int p_offset) const { int offset = token + p_offset; ERR_FAIL_INDEX_V(offset, tokens.size(), nil); @@ -1444,17 +1450,17 @@ const Variant &GDTokenizerBuffer::get_token_constant(int p_offset) const { ERR_FAIL_INDEX_V(constant, (uint32_t)constants.size(), nil); return constants[constant]; } -String GDTokenizerBuffer::get_token_error(int p_offset) const { +String GDScriptTokenizerBuffer::get_token_error(int p_offset) const { ERR_FAIL_V(String()); } -void GDTokenizerBuffer::advance(int p_amount) { +void GDScriptTokenizerBuffer::advance(int p_amount) { ERR_FAIL_INDEX(p_amount + token, tokens.size()); token += p_amount; } -GDTokenizerBuffer::GDTokenizerBuffer() { +GDScriptTokenizerBuffer::GDScriptTokenizerBuffer() { token = 0; } diff --git a/modules/gdscript/gd_tokenizer.h b/modules/gdscript/gdscript_tokenizer.h index c935ce45a1..d19367177b 100644 --- a/modules/gdscript/gd_tokenizer.h +++ b/modules/gdscript/gdscript_tokenizer.h @@ -1,5 +1,5 @@ /*************************************************************************/ -/* gd_tokenizer.h */ +/* gdscript_tokenizer.h */ /*************************************************************************/ /* This file is part of: */ /* GODOT ENGINE */ @@ -27,16 +27,16 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef GD_TOKENIZER_H -#define GD_TOKENIZER_H +#ifndef GDSCRIPT_TOKENIZER_H +#define GDSCRIPT_TOKENIZER_H -#include "gd_functions.h" +#include "gdscript_functions.h" #include "string_db.h" #include "ustring.h" #include "variant.h" #include "vmap.h" -class GDTokenizer { +class GDScriptTokenizer { public: enum Token { @@ -128,6 +128,7 @@ public: TK_DOLLAR, TK_NEWLINE, TK_CONST_PI, + TK_CONST_TAU, TK_WILDCARD, TK_CONST_INF, TK_CONST_NAN, @@ -155,7 +156,7 @@ public: virtual const Variant &get_token_constant(int p_offset = 0) const = 0; virtual Token get_token(int p_offset = 0) const = 0; virtual StringName get_token_identifier(int p_offset = 0) const = 0; - virtual GDFunctions::Function get_token_built_in_func(int p_offset = 0) const = 0; + virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const = 0; virtual Variant::Type get_token_type(int p_offset = 0) const = 0; virtual int get_token_line(int p_offset = 0) const = 0; virtual int get_token_column(int p_offset = 0) const = 0; @@ -163,10 +164,10 @@ public: virtual String get_token_error(int p_offset = 0) const = 0; virtual void advance(int p_amount = 1) = 0; - virtual ~GDTokenizer(){}; + virtual ~GDScriptTokenizer(){}; }; -class GDTokenizerText : public GDTokenizer { +class GDScriptTokenizerText : public GDScriptTokenizer { enum { MAX_LOOKAHEAD = 4, @@ -180,7 +181,7 @@ class GDTokenizerText : public GDTokenizer { Variant constant; //for constant types union { Variant::Type vtype; //for type types - GDFunctions::Function func; //function for built in functions + GDScriptFunctions::Function func; //function for built in functions }; int line, col; TokenData() { @@ -193,7 +194,7 @@ class GDTokenizerText : public GDTokenizer { void _make_token(Token p_type); void _make_newline(int p_spaces = 0); void _make_identifier(const StringName &p_identifier); - void _make_built_in_func(GDFunctions::Function p_func); + void _make_built_in_func(GDScriptFunctions::Function p_func); void _make_constant(const Variant &p_constant); void _make_type(const Variant::Type &p_type); void _make_error(const String &p_error); @@ -215,7 +216,7 @@ public: void set_code(const String &p_code); virtual Token get_token(int p_offset = 0) const; virtual StringName get_token_identifier(int p_offset = 0) const; - virtual GDFunctions::Function get_token_built_in_func(int p_offset = 0) const; + virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const; virtual Variant::Type get_token_type(int p_offset = 0) const; virtual int get_token_line(int p_offset = 0) const; virtual int get_token_column(int p_offset = 0) const; @@ -225,7 +226,7 @@ public: virtual void advance(int p_amount = 1); }; -class GDTokenizerBuffer : public GDTokenizer { +class GDScriptTokenizerBuffer : public GDScriptTokenizer { enum { @@ -248,7 +249,7 @@ public: static Vector<uint8_t> parse_code_string(const String &p_code); virtual Token get_token(int p_offset = 0) const; virtual StringName get_token_identifier(int p_offset = 0) const; - virtual GDFunctions::Function get_token_built_in_func(int p_offset = 0) const; + virtual GDScriptFunctions::Function get_token_built_in_func(int p_offset = 0) const; virtual Variant::Type get_token_type(int p_offset = 0) const; virtual int get_token_line(int p_offset = 0) const; virtual int get_token_column(int p_offset = 0) const; @@ -256,7 +257,7 @@ public: virtual const Variant &get_token_constant(int p_offset = 0) const; virtual String get_token_error(int p_offset = 0) const; virtual void advance(int p_amount = 1); - GDTokenizerBuffer(); + GDScriptTokenizerBuffer(); }; -#endif // TOKENIZER_H +#endif // GDSCRIPT_TOKENIZER_H diff --git a/modules/gdscript/register_types.cpp b/modules/gdscript/register_types.cpp index 036274c8f2..1e007ddb0f 100644 --- a/modules/gdscript/register_types.cpp +++ b/modules/gdscript/register_types.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "register_types.h" -#include "gd_script.h" +#include "gdscript.h" #include "io/file_access_encrypted.h" #include "io/resource_loader.h" #include "os/file_access.h" @@ -41,10 +41,9 @@ ResourceFormatSaverGDScript *resource_saver_gd = NULL; void register_gdscript_types() { ClassDB::register_class<GDScript>(); - ClassDB::register_virtual_class<GDFunctionState>(); + ClassDB::register_virtual_class<GDScriptFunctionState>(); script_language_gd = memnew(GDScriptLanguage); - //script_language_gd->init(); ScriptServer::register_language(script_language_gd); resource_loader_gd = memnew(ResourceFormatLoaderGDScript); ResourceLoader::add_resource_format_loader(resource_loader_gd); diff --git a/modules/gridmap/config.py b/modules/gridmap/config.py index b3dbb9f46a..a93f4edb81 100644 --- a/modules/gridmap/config.py +++ b/modules/gridmap/config.py @@ -1,14 +1,13 @@ - - def can_build(platform): return True - def configure(env): pass def get_doc_classes(): - return ["GridMap"] + return [ + "GridMap", + ] def get_doc_path(): - return "doc_classes" + return "doc_classes" diff --git a/modules/gridmap/doc_classes/GridMap.xml b/modules/gridmap/doc_classes/GridMap.xml index 5b0fe56f25..ee8ecfff66 100644 --- a/modules/gridmap/doc_classes/GridMap.xml +++ b/modules/gridmap/doc_classes/GridMap.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GridMap" inherits="Spatial" category="Core" version="3.0.alpha.custom_build"> +<class name="GridMap" inherits="Spatial" category="Core" version="3.0-alpha"> <brief_description> Node for 3D tile-based maps. </brief_description> diff --git a/modules/gridmap/grid_map.cpp b/modules/gridmap/grid_map.cpp index cb14a5ee9c..b3a1947647 100644 --- a/modules/gridmap/grid_map.cpp +++ b/modules/gridmap/grid_map.cpp @@ -747,7 +747,6 @@ void GridMap::_update_octants_callback() { } while (to_delete.front()) { - memdelete(octant_map[to_delete.front()->get()]); octant_map.erase(to_delete.front()->get()); to_delete.pop_back(); } diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index f6a76ad2a1..491adb31ee 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -28,8 +28,10 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "grid_map_editor_plugin.h" +#include "editor/editor_scale.h" #include "editor/editor_settings.h" #include "editor/plugins/spatial_editor_plugin.h" +#include "os/input.h" #include "scene/3d/camera.h" #include "geometry.h" @@ -56,6 +58,14 @@ void GridMapEditor::_menu_option(int p_option) { switch (p_option) { + case MENU_OPTION_PREV_LEVEL: { + floor->set_value(floor->get_value() - 1); + } break; + + case MENU_OPTION_NEXT_LEVEL: { + floor->set_value(floor->get_value() + 1); + } break; + case MENU_OPTION_CONFIGURE: { } break; @@ -94,6 +104,7 @@ void GridMapEditor::_menu_option(int p_option) { } break; case MENU_OPTION_CURSOR_ROTATE_Y: { + Basis r; if (input_action == INPUT_DUPLICATE) { @@ -109,6 +120,7 @@ void GridMapEditor::_menu_option(int p_option) { _update_cursor_transform(); } break; case MENU_OPTION_CURSOR_ROTATE_X: { + Basis r; if (input_action == INPUT_DUPLICATE) { @@ -125,6 +137,7 @@ void GridMapEditor::_menu_option(int p_option) { _update_cursor_transform(); } break; case MENU_OPTION_CURSOR_ROTATE_Z: { + Basis r; if (input_action == INPUT_DUPLICATE) { @@ -141,6 +154,7 @@ void GridMapEditor::_menu_option(int p_option) { _update_cursor_transform(); } break; case MENU_OPTION_CURSOR_BACK_ROTATE_Y: { + Basis r; r.set_orthogonal_index(cursor_rot); r.rotate(Vector3(0, 1, 0), Math_PI / 2.0); @@ -148,6 +162,7 @@ void GridMapEditor::_menu_option(int p_option) { _update_cursor_transform(); } break; case MENU_OPTION_CURSOR_BACK_ROTATE_X: { + Basis r; r.set_orthogonal_index(cursor_rot); r.rotate(Vector3(1, 0, 0), Math_PI / 2.0); @@ -155,6 +170,7 @@ void GridMapEditor::_menu_option(int p_option) { _update_cursor_transform(); } break; case MENU_OPTION_CURSOR_BACK_ROTATE_Z: { + Basis r; r.set_orthogonal_index(cursor_rot); r.rotate(Vector3(0, 0, 1), Math_PI / 2.0); @@ -184,6 +200,9 @@ void GridMapEditor::_menu_option(int p_option) { if (last_mouseover == Vector3(-1, -1, -1)) //nono mouseovering anythin break; + last_mouseover = selection.begin; + VS::get_singleton()->instance_set_transform(grid_instance[edit_axis], Transform(Basis(), grid_ofs)); + input_action = INPUT_DUPLICATE; selection.click = last_mouseover; selection.current = last_mouseover; @@ -198,7 +217,7 @@ void GridMapEditor::_menu_option(int p_option) { } break; case MENU_OPTION_GRIDMAP_SETTINGS: { - settings_dialog->popup_centered(settings_vbc->get_combined_minimum_size() + Size2(50, 50)); + settings_dialog->popup_centered(settings_vbc->get_combined_minimum_size() + Size2(50, 50) * EDSCALE); } break; } } @@ -551,12 +570,11 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu input_action = INPUT_NONE; _update_duplicate_indicator(); - } else { + } else if (mb->get_shift()) { input_action = INPUT_ERASE; set_items.clear(); - } - else - return false; + } else + return false; return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); } else { @@ -829,70 +847,77 @@ void GridMapEditor::update_grid() { void GridMapEditor::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { + switch (p_what) { - theme_pallete->connect("item_selected", this, "_item_selected_cbk"); - for (int i = 0; i < 3; i++) { + case NOTIFICATION_ENTER_TREE: { + theme_pallete->connect("item_selected", this, "_item_selected_cbk"); + for (int i = 0; i < 3; i++) { - grid[i] = VS::get_singleton()->mesh_create(); - grid_instance[i] = VS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario()); - selection_level_instance[i] = VisualServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world()->get_scenario()); - } + grid[i] = VS::get_singleton()->mesh_create(); + grid_instance[i] = VS::get_singleton()->instance_create2(grid[i], get_tree()->get_root()->get_world()->get_scenario()); + selection_level_instance[i] = VisualServer::get_singleton()->instance_create2(selection_level_mesh[i], get_tree()->get_root()->get_world()->get_scenario()); + } - selection_instance = VisualServer::get_singleton()->instance_create2(selection_mesh, get_tree()->get_root()->get_world()->get_scenario()); - duplicate_instance = VisualServer::get_singleton()->instance_create2(duplicate_mesh, get_tree()->get_root()->get_world()->get_scenario()); + selection_instance = VisualServer::get_singleton()->instance_create2(selection_mesh, get_tree()->get_root()->get_world()->get_scenario()); + duplicate_instance = VisualServer::get_singleton()->instance_create2(duplicate_mesh, get_tree()->get_root()->get_world()->get_scenario()); - _update_selection_transform(); - _update_duplicate_indicator(); - - } else if (p_what == NOTIFICATION_EXIT_TREE) { + _update_selection_transform(); + _update_duplicate_indicator(); + } break; - for (int i = 0; i < 3; i++) { + case NOTIFICATION_EXIT_TREE: { + for (int i = 0; i < 3; i++) { - VS::get_singleton()->free(grid_instance[i]); - VS::get_singleton()->free(grid[i]); - grid_instance[i] = RID(); - grid[i] = RID(); - VisualServer::get_singleton()->free(selection_level_instance[i]); - } + VS::get_singleton()->free(grid_instance[i]); + VS::get_singleton()->free(grid[i]); + grid_instance[i] = RID(); + grid[i] = RID(); + VisualServer::get_singleton()->free(selection_level_instance[i]); + } - VisualServer::get_singleton()->free(selection_instance); - VisualServer::get_singleton()->free(duplicate_instance); - selection_instance = RID(); - duplicate_instance = RID(); + VisualServer::get_singleton()->free(selection_instance); + VisualServer::get_singleton()->free(duplicate_instance); + selection_instance = RID(); + duplicate_instance = RID(); + } break; - } else if (p_what == NOTIFICATION_PROCESS) { - if (!node) { - return; - } + case NOTIFICATION_PROCESS: { + if (!node) { + return; + } - Transform xf = node->get_global_transform(); + Transform xf = node->get_global_transform(); - if (xf != grid_xform) { - for (int i = 0; i < 3; i++) { + if (xf != grid_xform) { + for (int i = 0; i < 3; i++) { - VS::get_singleton()->instance_set_transform(grid_instance[i], xf * edit_grid_xform); + VS::get_singleton()->instance_set_transform(grid_instance[i], xf * edit_grid_xform); + } + grid_xform = xf; } - grid_xform = xf; - } - Ref<MeshLibrary> cgmt = node->get_theme(); - if (cgmt.operator->() != last_theme) - update_pallete(); + Ref<MeshLibrary> cgmt = node->get_theme(); + if (cgmt.operator->() != last_theme) + update_pallete(); - if (lock_view) { + if (lock_view) { - EditorNode *editor = Object::cast_to<EditorNode>(get_tree()->get_root()->get_child(0)); + EditorNode *editor = Object::cast_to<EditorNode>(get_tree()->get_root()->get_child(0)); - Plane p; - p.normal[edit_axis] = 1.0; - p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis]; - p = node->get_transform().xform(p); // plane to snap + Plane p; + p.normal[edit_axis] = 1.0; + p.d = edit_floor[edit_axis] * node->get_cell_size()[edit_axis]; + p = node->get_transform().xform(p); // plane to snap - SpatialEditorPlugin *sep = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen()); - if (sep) - sep->snap_cursor_to_plane(p); - //editor->get_editor_plugin_screen()->call("snap_cursor_to_plane",p); - } + SpatialEditorPlugin *sep = Object::cast_to<SpatialEditorPlugin>(editor->get_editor_plugin_screen()); + if (sep) + sep->snap_cursor_to_plane(p); + //editor->get_editor_plugin_screen()->call("snap_cursor_to_plane",p); + } + } break; + + case NOTIFICATION_THEME_CHANGED: { + options->set_icon(get_icon("GridMap", "EditorIcons")); + } break; } } @@ -954,20 +979,38 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { int mw = EDITOR_DEF("editors/grid_map/palette_min_width", 230); Control *ec = memnew(Control); - ec->set_custom_minimum_size(Size2(mw, 0)); + ec->set_custom_minimum_size(Size2(mw, 0) * EDSCALE); add_child(ec); spatial_editor_hb = memnew(HBoxContainer); + spatial_editor_hb->set_h_size_flags(SIZE_EXPAND_FILL); + spatial_editor_hb->set_alignment(BoxContainer::ALIGN_END); SpatialEditor::get_singleton()->add_control_to_menu_panel(spatial_editor_hb); + + Label *fl = memnew(Label); + fl->set_text(TTR("Floor:")); + spatial_editor_hb->add_child(fl); + + floor = memnew(SpinBox); + floor->set_min(-32767); + floor->set_max(32767); + floor->set_step(1); + floor->get_line_edit()->add_constant_override("minimum_spaces", 16); + + spatial_editor_hb->add_child(floor); + floor->connect("value_changed", this, "_floor_changed"); + + spatial_editor_hb->add_child(memnew(VSeparator)); + options = memnew(MenuButton); spatial_editor_hb->add_child(options); spatial_editor_hb->hide(); - options->set_text("Grid"); + options->set_text(TTR("Grid Map")); options->get_popup()->add_check_item(TTR("Snap View"), MENU_OPTION_LOCK_VIEW); options->get_popup()->add_separator(); - options->get_popup()->add_item(vformat(TTR("Prev Level (%sDown Wheel)"), keycode_get_string(KEY_MASK_CMD)), MENU_OPTION_PREV_LEVEL); - options->get_popup()->add_item(vformat(TTR("Next Level (%sUp Wheel)"), keycode_get_string(KEY_MASK_CMD)), MENU_OPTION_NEXT_LEVEL); + options->get_popup()->add_item(TTR("Previous Floor"), MENU_OPTION_PREV_LEVEL, KEY_Q); + options->get_popup()->add_item(TTR("Next Floor"), MENU_OPTION_NEXT_LEVEL, KEY_E); options->get_popup()->add_separator(); options->get_popup()->add_check_item(TTR("Clip Disabled"), MENU_OPTION_CLIP_DISABLED); options->get_popup()->set_item_checked(options->get_popup()->get_item_index(MENU_OPTION_CLIP_DISABLED), true); @@ -993,8 +1036,8 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { options->get_popup()->add_item(TTR("Create Exterior Connector"), MENU_OPTION_SELECTION_MAKE_EXTERIOR_CONNECTOR); options->get_popup()->add_item(TTR("Erase Area"), MENU_OPTION_REMOVE_AREA); options->get_popup()->add_separator(); - options->get_popup()->add_item(TTR("Selection -> Duplicate"), MENU_OPTION_SELECTION_DUPLICATE, KEY_MASK_SHIFT + KEY_INSERT); - options->get_popup()->add_item(TTR("Selection -> Clear"), MENU_OPTION_SELECTION_CLEAR, KEY_MASK_SHIFT + KEY_DELETE); + options->get_popup()->add_item(TTR("Duplicate Selection"), MENU_OPTION_SELECTION_DUPLICATE, KEY_MASK_SHIFT + KEY_C); + options->get_popup()->add_item(TTR("Clear Selection"), MENU_OPTION_SELECTION_CLEAR, KEY_MASK_SHIFT + KEY_X); options->get_popup()->add_separator(); options->get_popup()->add_item(TTR("Settings"), MENU_OPTION_GRIDMAP_SETTINGS); @@ -1003,7 +1046,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { settings_dialog->set_title(TTR("GridMap Settings")); add_child(settings_dialog); settings_vbc = memnew(VBoxContainer); - settings_vbc->set_custom_minimum_size(Size2(200, 0)); + settings_vbc->set_custom_minimum_size(Size2(200, 0) * EDSCALE); settings_dialog->add_child(settings_vbc); settings_pick_distance = memnew(SpinBox); @@ -1042,20 +1085,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { add_child(theme_pallete); theme_pallete->set_v_size_flags(SIZE_EXPAND_FILL); - spatial_editor_hb->add_child(memnew(VSeparator)); - Label *fl = memnew(Label); - fl->set_text(" Floor: "); - spatial_editor_hb->add_child(fl); - - floor = memnew(SpinBox); - floor->set_min(-32767); - floor->set_max(32767); - floor->set_step(1); - floor->get_line_edit()->add_constant_override("minimum_spaces", 16); - - spatial_editor_hb->add_child(floor); - floor->connect("value_changed", this, "_floor_changed"); - edit_axis = Vector3::AXIS_Y; edit_floor[0] = -1; edit_floor[1] = -1; @@ -1108,7 +1137,7 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { for (int i = 0; i < 12; i++) { - Rect3 base(Vector3(0, 0, 0), Vector3(1, 1, 1)); + AABB base(Vector3(0, 0, 0), Vector3(1, 1, 1)); Vector3 a, b; base.get_edge(i, a, b); lines.push_back(a); @@ -1250,7 +1279,9 @@ GridMapEditorPlugin::GridMapEditorPlugin(EditorNode *p_node) { gridmap_editor = memnew(GridMapEditor(editor)); SpatialEditor::get_singleton()->get_palette_split()->add_child(gridmap_editor); - SpatialEditor::get_singleton()->get_palette_split()->move_child(gridmap_editor, 0); + // TODO: make this configurable, so the user can choose were to put this, it makes more sense + // on the right, but some people might find it strange. + SpatialEditor::get_singleton()->get_palette_split()->move_child(gridmap_editor, 1); gridmap_editor->hide(); } diff --git a/modules/hdr/config.py b/modules/hdr/config.py index fb920482f5..5f133eba90 100644 --- a/modules/hdr/config.py +++ b/modules/hdr/config.py @@ -1,7 +1,5 @@ - def can_build(platform): return True - def configure(env): pass diff --git a/modules/jpg/config.py b/modules/jpg/config.py index fb920482f5..5f133eba90 100644 --- a/modules/jpg/config.py +++ b/modules/jpg/config.py @@ -1,7 +1,5 @@ - def can_build(platform): return True - def configure(env): pass diff --git a/modules/mobile_vr/config.py b/modules/mobile_vr/config.py index cf96c66125..4e1155f0c6 100644 --- a/modules/mobile_vr/config.py +++ b/modules/mobile_vr/config.py @@ -1,12 +1,14 @@ def can_build(platform): - # should probably change this to only be true on iOS and Android - return True + # should probably change this to only be true on iOS and Android + return True def configure(env): - pass + pass def get_doc_classes(): - return ["MobileVRInterface"] + return [ + "MobileVRInterface", + ] def get_doc_path(): - return "doc_classes" + return "doc_classes" diff --git a/modules/mobile_vr/doc_classes/MobileVRInterface.xml b/modules/mobile_vr/doc_classes/MobileVRInterface.xml index c945a99a9a..c99934aea9 100644 --- a/modules/mobile_vr/doc_classes/MobileVRInterface.xml +++ b/modules/mobile_vr/doc_classes/MobileVRInterface.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="MobileVRInterface" inherits="ARVRInterface" category="Core" version="3.0.alpha.custom_build"> +<class name="MobileVRInterface" inherits="ARVRInterface" category="Core" version="3.0-alpha"> <brief_description> Generic mobile VR implementation </brief_description> diff --git a/modules/mobile_vr/mobile_interface.cpp b/modules/mobile_vr/mobile_interface.cpp index eb87bb2cf0..3a0b83d534 100644 --- a/modules/mobile_vr/mobile_interface.cpp +++ b/modules/mobile_vr/mobile_interface.cpp @@ -122,6 +122,7 @@ void MobileVRInterface::set_position_from_sensors() { Vector3 north(0.0, 0.0, 1.0); // North is Z positive // make copies of our inputs + bool has_grav = false; Vector3 acc = input->get_accelerometer(); Vector3 gyro = input->get_gyroscope(); Vector3 grav = input->get_gravity(); @@ -143,25 +144,17 @@ void MobileVRInterface::set_position_from_sensors() { // what a stable gravity vector is grav = acc; if (grav.length() > 0.1) { - has_gyro = true; + has_grav = true; }; } else { - has_gyro = true; + has_grav = true; }; bool has_magneto = magneto.length() > 0.1; - bool has_grav = grav.length() > 0.1; - -#ifdef ANDROID_ENABLED - ///@TODO needs testing, i don't have a gyro, potentially can be removed depending on what comes out of issue #8101 - // On Android x and z axis seem inverted - gyro.x = -gyro.x; - gyro.z = -gyro.z; - grav.x = -grav.x; - grav.z = -grav.z; - magneto.x = -magneto.x; - magneto.z = -magneto.z; -#endif + if (gyro.length() > 0.1) { + /* this can return to 0.0 if the user doesn't move the phone, so once on, it's on */ + has_gyro = true; + }; if (has_gyro) { // start with applying our gyro (do NOT smooth our gyro!) @@ -330,7 +323,7 @@ void MobileVRInterface::uninitialize() { }; }; -Size2 MobileVRInterface::get_recommended_render_targetsize() { +Size2 MobileVRInterface::get_render_targetsize() { _THREAD_SAFE_METHOD_ // we use half our window size diff --git a/modules/mobile_vr/mobile_interface.h b/modules/mobile_vr/mobile_interface.h index 747377ae46..b652edc1c6 100644 --- a/modules/mobile_vr/mobile_interface.h +++ b/modules/mobile_vr/mobile_interface.h @@ -137,7 +137,7 @@ public: virtual bool initialize(); virtual void uninitialize(); - virtual Size2 get_recommended_render_targetsize(); + virtual Size2 get_render_targetsize(); virtual bool is_stereo(); virtual Transform get_transform_for_eye(ARVRInterface::Eyes p_eye, const Transform &p_cam_transform); virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far); diff --git a/modules/mono/config.py b/modules/mono/config.py index 7ad135e0b9..b4e6433256 100644 --- a/modules/mono/config.py +++ b/modules/mono/config.py @@ -177,7 +177,11 @@ def configure(env): def get_doc_classes(): - return ["@C#", "CSharpScript", "GodotSharp"] + return [ + "@C#", + "CSharpScript", + "GodotSharp", + ] def get_doc_path(): diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 161e130a07..dfa5e720ae 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -346,7 +346,7 @@ static String variant_type_to_managed_name(const String &p_var_type_name) { Variant::TRANSFORM2D, Variant::PLANE, Variant::QUAT, - Variant::RECT3, + Variant::AABB, Variant::BASIS, Variant::TRANSFORM, Variant::COLOR, diff --git a/modules/mono/doc_classes/@C#.xml b/modules/mono/doc_classes/@C#.xml index 487ba9835f..5d27b32200 100644 --- a/modules/mono/doc_classes/@C#.xml +++ b/modules/mono/doc_classes/@C#.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="@C#" category="Core" version="3.0.alpha.custom_build"> +<class name="@C#" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/modules/mono/doc_classes/CSharpScript.xml b/modules/mono/doc_classes/CSharpScript.xml index 5f21c9774d..ccc24b832c 100644 --- a/modules/mono/doc_classes/CSharpScript.xml +++ b/modules/mono/doc_classes/CSharpScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="CSharpScript" inherits="Script" category="Core" version="3.0.alpha.custom_build"> +<class name="CSharpScript" inherits="Script" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/modules/mono/doc_classes/GodotSharp.xml b/modules/mono/doc_classes/GodotSharp.xml index e7e06ddd8f..9edbd18fc1 100644 --- a/modules/mono/doc_classes/GodotSharp.xml +++ b/modules/mono/doc_classes/GodotSharp.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="GodotSharp" inherits="Object" category="Core" version="3.0.alpha.custom_build"> +<class name="GodotSharp" inherits="Object" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index eb504ec021..59a2b73dbc 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -31,12 +31,12 @@ #ifdef DEBUG_METHODS_ENABLED +#include "engine.h" #include "global_constants.h" #include "io/compression.h" #include "os/dir_access.h" #include "os/file_access.h" #include "os/os.h" -#include "project_settings.h" #include "ucaps.h" #include "../glue/cs_compressed.gen.h" @@ -320,9 +320,9 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_output_dir, bo int global_constants_count = GlobalConstants::get_global_constant_count(); if (global_constants_count > 0) { - Map<String, DocData::ClassDoc>::Element *match = EditorHelp::get_doc_data()->class_list.find("@Global Scope"); + Map<String, DocData::ClassDoc>::Element *match = EditorHelp::get_doc_data()->class_list.find("@GlobalScope"); - ERR_EXPLAIN("Could not find `@Global Scope` in DocData"); + ERR_EXPLAIN("Could not find `@GlobalScope` in DocData"); ERR_FAIL_COND_V(!match, ERR_BUG); const DocData::ClassDoc &global_scope_doc = match->value(); @@ -1169,7 +1169,7 @@ Error BindingsGenerator::generate_glue(const String &p_output_dir) { output.push_back("Object* "); output.push_back(singleton_icall_name); - output.push_back("() " OPEN_BLOCK "\treturn ProjectSettings::get_singleton()->get_singleton_object(\""); + output.push_back("() " OPEN_BLOCK "\treturn Engine::get_singleton()->get_singleton_object(\""); output.push_back(itype.proxy_name); output.push_back("\");\n" CLOSE_BLOCK "\n"); } @@ -1505,7 +1505,7 @@ void BindingsGenerator::_populate_object_type_interfaces() { TypeInterface itype = TypeInterface::create_object_type(type_cname, api_type); itype.base_name = ClassDB::get_parent_class(type_cname); - itype.is_singleton = ProjectSettings::get_singleton()->has_singleton(itype.proxy_name); + itype.is_singleton = Engine::get_singleton()->has_singleton(itype.proxy_name); itype.is_instantiable = ClassDB::can_instance(type_cname) && !itype.is_singleton; itype.is_reference = ClassDB::is_parent_class(type_cname, refclass_name); itype.memory_own = itype.is_reference; @@ -1721,7 +1721,7 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL; break; case Variant::PLANE: - case Variant::RECT3: + case Variant::AABB: case Variant::COLOR: r_iarg.default_argument = "new Color(1, 1, 1, 1)"; r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL; @@ -1793,7 +1793,7 @@ void BindingsGenerator::_populate_builtin_type_interfaces() { INSERT_STRUCT_TYPE(Basis, "real_t*") INSERT_STRUCT_TYPE(Quat, "real_t*") INSERT_STRUCT_TYPE(Transform, "real_t*") - INSERT_STRUCT_TYPE(Rect3, "real_t*") + INSERT_STRUCT_TYPE(AABB, "real_t*") INSERT_STRUCT_TYPE(Color, "real_t*") INSERT_STRUCT_TYPE(Plane, "real_t*") diff --git a/modules/mono/editor/godotsharp_builds.cpp b/modules/mono/editor/godotsharp_builds.cpp index a26f36d64f..b88d34fc33 100644 --- a/modules/mono/editor/godotsharp_builds.cpp +++ b/modules/mono/editor/godotsharp_builds.cpp @@ -365,16 +365,14 @@ GodotSharpBuilds::GodotSharpBuilds() { // Build tool settings EditorSettings *ed_settings = EditorSettings::get_singleton(); - if (!ed_settings->has_setting("mono/builds/build_tool")) { - ed_settings->set_setting("mono/builds/build_tool", + #ifdef WINDOWS_ENABLED - // TODO: Default to MSBUILD_MONO if its csc.exe issue is fixed in the installed mono version - MSBUILD + // TODO: Default to MSBUILD_MONO if its csc.exe issue is fixed in the installed mono version + EDITOR_DEF("mono/builds/build_tool", MSBUILD); #else - MSBUILD_MONO + EDITOR_DEF("mono/builds/build_tool", MSBUILD_MONO); #endif - ); - } + ed_settings->add_property_hint(PropertyInfo(Variant::INT, "mono/builds/build_tool", PROPERTY_HINT_ENUM, #ifdef WINDOWS_ENABLED "MSBuild (Mono),MSBuild (System)" diff --git a/modules/mono/editor/godotsharp_editor.cpp b/modules/mono/editor/godotsharp_editor.cpp index 837dbfde66..1bc1e8a515 100644 --- a/modules/mono/editor/godotsharp_editor.cpp +++ b/modules/mono/editor/godotsharp_editor.cpp @@ -221,9 +221,7 @@ GodotSharpEditor::GodotSharpEditor(EditorNode *p_editor) { // External editor settings EditorSettings *ed_settings = EditorSettings::get_singleton(); - if (!ed_settings->has_setting("mono/editor/external_editor")) { - ed_settings->set_setting("mono/editor/external_editor", EDITOR_NONE); - } + EDITOR_DEF("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 Code")); } diff --git a/modules/mono/glue/cs_files/Rect3.cs b/modules/mono/glue/cs_files/AABB.cs index 617d33e7fd..6ee3bbe53a 100644 --- a/modules/mono/glue/cs_files/Rect3.cs +++ b/modules/mono/glue/cs_files/AABB.cs @@ -1,15 +1,15 @@ using System; -// file: core/math/rect3.h +// file: core/math/aabb.h // commit: 7ad14e7a3e6f87ddc450f7e34621eb5200808451 -// file: core/math/rect3.cpp +// file: core/math/aabb.cpp // commit: bd282ff43f23fe845f29a3e25c8efc01bd65ffb0 // file: core/variant_call.cpp // commit: 5ad9be4c24e9d7dc5672fdc42cea896622fe5685 namespace Godot { - public struct Rect3 : IEquatable<Rect3> + public struct AABB : IEquatable<AABB> { private Vector3 position; private Vector3 size; @@ -38,7 +38,7 @@ namespace Godot } } - public bool encloses(Rect3 with) + public bool encloses(AABB with) { Vector3 src_min = position; Vector3 src_max = position + size; @@ -53,7 +53,7 @@ namespace Godot (src_max.z > dst_max.z)); } - public Rect3 expand(Vector3 to_point) + public AABB expand(Vector3 to_point) { Vector3 begin = position; Vector3 end = position + size; @@ -72,7 +72,7 @@ namespace Godot if (to_point.z > end.z) end.z = to_point.z; - return new Rect3(begin, end - begin); + return new AABB(begin, end - begin); } public float get_area() @@ -222,9 +222,9 @@ namespace Godot (dir.z > 0f) ? -half_extents.z : half_extents.z); } - public Rect3 grow(float by) + public AABB grow(float by) { - Rect3 res = this; + AABB res = this; res.position.x -= by; res.position.y -= by; @@ -264,7 +264,7 @@ namespace Godot return true; } - public Rect3 intersection(Rect3 with) + public AABB intersection(AABB with) { Vector3 src_min = position; Vector3 src_max = position + size; @@ -275,7 +275,7 @@ namespace Godot if (src_min.x > dst_max.x || src_max.x < dst_min.x) { - return new Rect3(); + return new AABB(); } else { @@ -285,7 +285,7 @@ namespace Godot if (src_min.y > dst_max.y || src_max.y < dst_min.y) { - return new Rect3(); + return new AABB(); } else { @@ -295,7 +295,7 @@ namespace Godot if (src_min.z > dst_max.z || src_max.z < dst_min.z) { - return new Rect3(); + return new AABB(); } else { @@ -303,10 +303,10 @@ namespace Godot max.z = (src_max.z < dst_max.z) ? src_max.z : dst_max.z; } - return new Rect3(min, max - min); + return new AABB(min, max - min); } - public bool intersects(Rect3 with) + public bool intersects(AABB with) { if (position.x >= (with.position.x + with.size.x)) return false; @@ -398,7 +398,7 @@ namespace Godot return true; } - public Rect3 merge(Rect3 with) + public AABB merge(AABB with) { Vector3 beg_1 = position; Vector3 beg_2 = with.position; @@ -417,36 +417,36 @@ namespace Godot (end_1.z > end_2.z) ? end_1.z : end_2.z ); - return new Rect3(min, max - min); + return new AABB(min, max - min); } - public Rect3(Vector3 position, Vector3 size) + public AABB(Vector3 position, Vector3 size) { this.position = position; this.size = size; } - public static bool operator ==(Rect3 left, Rect3 right) + public static bool operator ==(AABB left, AABB right) { return left.Equals(right); } - public static bool operator !=(Rect3 left, Rect3 right) + public static bool operator !=(AABB left, AABB right) { return !left.Equals(right); } public override bool Equals(object obj) { - if (obj is Rect3) + if (obj is AABB) { - return Equals((Rect3)obj); + return Equals((AABB)obj); } return false; } - public bool Equals(Rect3 other) + public bool Equals(AABB other) { return position == other.position && size == other.size; } diff --git a/modules/mono/glue/glue_header.h b/modules/mono/glue/glue_header.h index 0751a0160f..75a4eb2b40 100644 --- a/modules/mono/glue/glue_header.h +++ b/modules/mono/glue/glue_header.h @@ -35,10 +35,10 @@ #include "bind/core_bind.h" #include "class_db.h" +#include "engine.h" #include "io/marshalls.h" #include "object.h" #include "os/os.h" -#include "project_settings.h" #include "reference.h" #include "variant_parser.h" diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index 7cc2168b70..a0c2508b0d 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -57,7 +57,7 @@ String _get_expected_build_config() { String _get_mono_user_dir() { #ifdef TOOLS_ENABLED if (EditorSettings::get_singleton()) { - return EditorSettings::get_singleton()->get_settings_path().plus_file("mono"); + return EditorSettings::get_singleton()->get_data_dir().plus_file("mono"); } else { String settings_path; @@ -68,19 +68,13 @@ String _get_mono_user_dir() { // contain yourself settings_path = exe_dir.plus_file("editor_data"); } else { - if (OS::get_singleton()->has_environment("APPDATA")) { - String app_data = OS::get_singleton()->get_environment("APPDATA").replace("\\", "/"); - settings_path = app_data.plus_file(String(_MKSTR(VERSION_SHORT_NAME)).capitalize()); - } else if (OS::get_singleton()->has_environment("HOME")) { - String home = OS::get_singleton()->get_environment("HOME"); - settings_path = home.plus_file("." + String(_MKSTR(VERSION_SHORT_NAME)).to_lower()); - } + settings_path = OS::get_singleton()->get_data_path().plus_file(OS::get_singleton()->get_godot_dir_name()); } return settings_path.plus_file("mono"); } #else - return OS::get_singleton()->get_data_dir().plus_file("mono"); + return OS::get_singleton()->get_user_data_dir().plus_file("mono"); #endif } diff --git a/modules/mono/mono_gd/gd_mono_field.cpp b/modules/mono/mono_gd/gd_mono_field.cpp index 1643f8cfc5..eb34f9dd3f 100644 --- a/modules/mono/mono_gd/gd_mono_field.cpp +++ b/modules/mono/mono_gd/gd_mono_field.cpp @@ -41,7 +41,7 @@ void GDMonoField::set_value_raw(MonoObject *p_object, void *p_ptr) { void GDMonoField::set_value(MonoObject *p_object, const Variant &p_value) { #define SET_FROM_STRUCT_AND_BREAK(m_type) \ { \ - const m_type &val = p_value.operator m_type(); \ + const m_type &val = p_value.operator ::m_type(); \ MARSHALLED_OUT(m_type, val, raw); \ mono_field_set_value(p_object, mono_field, raw); \ break; \ @@ -129,8 +129,8 @@ void GDMonoField::set_value(MonoObject *p_object, const Variant &p_value) { if (tclass == CACHED_CLASS(Transform)) SET_FROM_STRUCT_AND_BREAK(Transform); - if (tclass == CACHED_CLASS(Rect3)) - SET_FROM_STRUCT_AND_BREAK(Rect3); + if (tclass == CACHED_CLASS(AABB)) + SET_FROM_STRUCT_AND_BREAK(AABB); if (tclass == CACHED_CLASS(Color)) SET_FROM_STRUCT_AND_BREAK(Color); @@ -229,7 +229,7 @@ void GDMonoField::set_value(MonoObject *p_object, const Variant &p_value) { case Variant::TRANSFORM2D: SET_FROM_STRUCT_AND_BREAK(Transform2D); case Variant::PLANE: SET_FROM_STRUCT_AND_BREAK(Plane); case Variant::QUAT: SET_FROM_STRUCT_AND_BREAK(Quat); - case Variant::RECT3: SET_FROM_STRUCT_AND_BREAK(Rect3); + case Variant::AABB: SET_FROM_STRUCT_AND_BREAK(AABB); case Variant::BASIS: SET_FROM_STRUCT_AND_BREAK(Basis); case Variant::TRANSFORM: SET_FROM_STRUCT_AND_BREAK(Transform); case Variant::COLOR: SET_FROM_STRUCT_AND_BREAK(Color); diff --git a/modules/mono/mono_gd/gd_mono_marshal.cpp b/modules/mono/mono_gd/gd_mono_marshal.cpp index 01392447f3..8bc2bb5096 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.cpp +++ b/modules/mono/mono_gd/gd_mono_marshal.cpp @@ -36,7 +36,7 @@ namespace GDMonoMarshal { #define RETURN_BOXED_STRUCT(m_t, m_var_in) \ { \ - const m_t &m_in = m_var_in->operator m_t(); \ + const m_t &m_in = m_var_in->operator ::m_t(); \ MARSHALLED_OUT(m_t, m_in, raw); \ return mono_value_box(mono_domain_get(), CACHED_CLASS_RAW(m_t), raw); \ } @@ -104,8 +104,8 @@ Variant::Type managed_to_variant_type(const ManagedType &p_type) { if (tclass == CACHED_CLASS(Transform)) return Variant::TRANSFORM; - if (tclass == CACHED_CLASS(Rect3)) - return Variant::RECT3; + if (tclass == CACHED_CLASS(AABB)) + return Variant::AABB; if (tclass == CACHED_CLASS(Color)) return Variant::COLOR; @@ -297,8 +297,8 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty if (tclass == CACHED_CLASS(Transform)) RETURN_BOXED_STRUCT(Transform, p_var); - if (tclass == CACHED_CLASS(Rect3)) - RETURN_BOXED_STRUCT(Rect3, p_var); + if (tclass == CACHED_CLASS(AABB)) + RETURN_BOXED_STRUCT(AABB, p_var); if (tclass == CACHED_CLASS(Color)) RETURN_BOXED_STRUCT(Color, p_var); @@ -394,8 +394,8 @@ MonoObject *variant_to_mono_object(const Variant *p_var, const ManagedType &p_ty RETURN_BOXED_STRUCT(Plane, p_var); case Variant::QUAT: RETURN_BOXED_STRUCT(Quat, p_var); - case Variant::RECT3: - RETURN_BOXED_STRUCT(Rect3, p_var); + case Variant::AABB: + RETURN_BOXED_STRUCT(AABB, p_var); case Variant::BASIS: RETURN_BOXED_STRUCT(Basis, p_var); case Variant::TRANSFORM: @@ -518,8 +518,8 @@ Variant mono_object_to_variant(MonoObject *p_obj, const ManagedType &p_type) { if (tclass == CACHED_CLASS(Transform)) RETURN_UNBOXED_STRUCT(Transform, p_obj); - if (tclass == CACHED_CLASS(Rect3)) - RETURN_UNBOXED_STRUCT(Rect3, p_obj); + if (tclass == CACHED_CLASS(AABB)) + RETURN_UNBOXED_STRUCT(AABB, p_obj); if (tclass == CACHED_CLASS(Color)) RETURN_UNBOXED_STRUCT(Color, p_obj); diff --git a/modules/mono/mono_gd/gd_mono_marshal.h b/modules/mono/mono_gd/gd_mono_marshal.h index 9f403b787f..443e947fb5 100644 --- a/modules/mono/mono_gd/gd_mono_marshal.h +++ b/modules/mono/mono_gd/gd_mono_marshal.h @@ -197,10 +197,10 @@ Dictionary mono_object_to_Dictionary(MonoObject *p_dict); Basis(m_in[0], m_in[1], m_in[2], m_in[3], m_in[4], m_in[5], m_in[6], m_in[7], m_in[8]), \ Vector3(m_in[9], m_in[10], m_in[11])); -// Rect3 +// AABB -#define MARSHALLED_OUT_Rect3(m_in, m_out) real_t m_out[6] = { m_in.position.x, m_in.position.y, m_in.position.z, m_in.size.x, m_in.size.y, m_in.size.z }; -#define MARSHALLED_IN_Rect3(m_in, m_out) Rect3 m_out(Vector3(m_in[0], m_in[1], m_in[2]), Vector3(m_in[3], m_in[4], m_in[5])); +#define MARSHALLED_OUT_AABB(m_in, m_out) real_t m_out[6] = { m_in.position.x, m_in.position.y, m_in.position.z, m_in.size.x, m_in.size.y, m_in.size.z }; +#define MARSHALLED_IN_AABB(m_in, m_out) AABB m_out(Vector3(m_in[0], m_in[1], m_in[2]), Vector3(m_in[3], m_in[4], m_in[5])); // Color @@ -214,6 +214,6 @@ Dictionary mono_object_to_Dictionary(MonoObject *p_dict); #endif -} // GDMonoMarshal +} // namespace GDMonoMarshal #endif // GDMONOMARSHAL_H diff --git a/modules/mono/mono_gd/gd_mono_utils.cpp b/modules/mono/mono_gd/gd_mono_utils.cpp index 53e45002c4..1cccd0ad9d 100644 --- a/modules/mono/mono_gd/gd_mono_utils.cpp +++ b/modules/mono/mono_gd/gd_mono_utils.cpp @@ -80,7 +80,7 @@ void MonoCache::clear_members() { class_Basis = NULL; class_Quat = NULL; class_Transform = NULL; - class_Rect3 = NULL; + class_AABB = NULL; class_Color = NULL; class_Plane = NULL; class_NodePath = NULL; @@ -147,7 +147,7 @@ void update_godot_api_cache() { CACHE_CLASS_AND_CHECK(Basis, GODOT_API_CLASS(Basis)); CACHE_CLASS_AND_CHECK(Quat, GODOT_API_CLASS(Quat)); CACHE_CLASS_AND_CHECK(Transform, GODOT_API_CLASS(Transform)); - CACHE_CLASS_AND_CHECK(Rect3, GODOT_API_CLASS(Rect3)); + CACHE_CLASS_AND_CHECK(AABB, GODOT_API_CLASS(AABB)); CACHE_CLASS_AND_CHECK(Color, GODOT_API_CLASS(Color)); CACHE_CLASS_AND_CHECK(Plane, GODOT_API_CLASS(Plane)); CACHE_CLASS_AND_CHECK(NodePath, GODOT_API_CLASS(NodePath)); @@ -364,4 +364,4 @@ String get_exception_name_and_message(MonoObject *p_ex) { return res; } -} +} // namespace GDMonoUtils diff --git a/modules/mono/mono_gd/gd_mono_utils.h b/modules/mono/mono_gd/gd_mono_utils.h index ebb5d28e4d..c38f8c5af5 100644 --- a/modules/mono/mono_gd/gd_mono_utils.h +++ b/modules/mono/mono_gd/gd_mono_utils.h @@ -82,7 +82,7 @@ struct MonoCache { GDMonoClass *class_Basis; GDMonoClass *class_Quat; GDMonoClass *class_Transform; - GDMonoClass *class_Rect3; + GDMonoClass *class_AABB; GDMonoClass *class_Color; GDMonoClass *class_Plane; GDMonoClass *class_NodePath; @@ -166,7 +166,7 @@ MonoDomain *create_domain(const String &p_friendly_name); String get_exception_name_and_message(MonoObject *p_ex); -} // GDMonoUtils +} // namespace GDMonoUtils #define NATIVE_GDMONOCLASS_NAME(m_class) (GDMonoMarshal::mono_string_to_godot((MonoString *)m_class->get_field(BINDINGS_NATIVE_NAME_FIELD)->get_value(NULL))) diff --git a/modules/mono/register_types.cpp b/modules/mono/register_types.cpp index 2656de5b14..217460a439 100644 --- a/modules/mono/register_types.cpp +++ b/modules/mono/register_types.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "register_types.h" -#include "project_settings.h" +#include "engine.h" #include "csharp_script.h" @@ -45,7 +45,7 @@ void register_mono_types() { _godotsharp = memnew(_GodotSharp); ClassDB::register_class<_GodotSharp>(); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("GodotSharp", _GodotSharp::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("GodotSharp", _GodotSharp::get_singleton())); script_language_cs = memnew(CSharpLanguage); script_language_cs->set_language_index(ScriptServer::get_language_count()); diff --git a/modules/ogg/config.py b/modules/ogg/config.py index ef5daca05c..5f133eba90 100644 --- a/modules/ogg/config.py +++ b/modules/ogg/config.py @@ -1,8 +1,5 @@ - def can_build(platform): -# return True - return False - + return True def configure(env): pass diff --git a/modules/openssl/config.py b/modules/openssl/config.py index fb920482f5..5f133eba90 100644 --- a/modules/openssl/config.py +++ b/modules/openssl/config.py @@ -1,7 +1,5 @@ - def can_build(platform): return True - def configure(env): pass diff --git a/modules/opus/SCsub b/modules/opus/SCsub index fee06bd267..6f643ef08c 100644 --- a/modules/opus/SCsub +++ b/modules/opus/SCsub @@ -3,6 +3,9 @@ Import('env') Import('env_modules') + +stub = True + env_opus = env_modules.Clone() # Thirdparty source files @@ -212,5 +215,9 @@ if env['builtin_opus']: if env['builtin_libogg']: env_opus.Append(CPPPATH=["#thirdparty/libogg"]) -# Module files -env_opus.add_source_files(env.modules_sources, "*.cpp") +if not stub: + # Module files + env_opus.add_source_files(env.modules_sources, "*.cpp") +else: + # Module files + env_opus.add_source_files(env.modules_sources, "stub/register_types.cpp") diff --git a/modules/opus/config.py b/modules/opus/config.py index ef5daca05c..60f8d838d6 100644 --- a/modules/opus/config.py +++ b/modules/opus/config.py @@ -1,8 +1,13 @@ - def can_build(platform): -# return True - return False - + return True def configure(env): pass + +def get_doc_classes(): + return [ + "AudioStreamOpus", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/modules/opus/stub/register_types.cpp b/modules/opus/stub/register_types.cpp new file mode 100644 index 0000000000..c5ae3e274e --- /dev/null +++ b/modules/opus/stub/register_types.cpp @@ -0,0 +1,36 @@ +/*************************************************************************/ +/* register_types.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "register_types.h" + +// Dummy module as libvorbis is needed by other modules (theora ...) + +void register_opus_types() {} + +void unregister_opus_types() {} diff --git a/modules/opus/stub/register_types.h b/modules/opus/stub/register_types.h new file mode 100644 index 0000000000..4517dc5df7 --- /dev/null +++ b/modules/opus/stub/register_types.h @@ -0,0 +1,31 @@ +/*************************************************************************/ +/* register_types.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +void register_opus_types(); +void unregister_opus_types(); diff --git a/modules/pbm/config.py b/modules/pbm/config.py index fb920482f5..5f133eba90 100644 --- a/modules/pbm/config.py +++ b/modules/pbm/config.py @@ -1,7 +1,5 @@ - def can_build(platform): return True - def configure(env): pass diff --git a/modules/pvr/config.py b/modules/pvr/config.py index fb920482f5..5f133eba90 100644 --- a/modules/pvr/config.py +++ b/modules/pvr/config.py @@ -1,7 +1,5 @@ - def can_build(platform): return True - def configure(env): pass diff --git a/modules/recast/config.py b/modules/recast/config.py index d42f07b2a9..fc074cf661 100644 --- a/modules/recast/config.py +++ b/modules/recast/config.py @@ -1,7 +1,5 @@ - def can_build(platform): return platform != "android" - def configure(env): pass diff --git a/modules/regex/config.py b/modules/regex/config.py index 5347cfd243..cb2da26738 100644 --- a/modules/regex/config.py +++ b/modules/regex/config.py @@ -1,9 +1,14 @@ -#!/usr/bin/env python - - def can_build(platform): return True - def configure(env): pass + +def get_doc_classes(): + return [ + "RegEx", + "RegExMatch", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/modules/regex/doc_classes/RegEx.xml b/modules/regex/doc_classes/RegEx.xml new file mode 100644 index 0000000000..4cf272fe8c --- /dev/null +++ b/modules/regex/doc_classes/RegEx.xml @@ -0,0 +1,134 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="RegEx" inherits="Reference" category="Core" version="3.0-alpha"> + <brief_description> + Class for searching text for patterns using regular expressions. + </brief_description> + <description> + Regular Expression (or regex) is a compact programming language that can be used to recognise strings that follow a specific pattern, such as URLs, email addresses, complete sentences, etc. For instance, a regex of [code]ab[0-9][/code] would find any string that is [code]ab[/code] followed by any number from [code]0[/code] to [code]9[/code]. For a more in-depth look, you can easily find various tutorials and detailed explainations on the Internet. + To begin, the RegEx object needs to be compiled with the search pattern using [method compile] before it can be used. + [codeblock] + var regex = RegEx.new() + regex.compile("\\w-(\\d+)") + [/codeblock] + The search pattern must be escaped first for gdscript before it is escaped for the expression. For example, [code]compile("\\d+")[/code] would be read by RegEx as [code]\d+[/code]. Similarly, [code]compile("\"(?:\\\\.|[^\"])*\"")[/code] would be read as [code]"(?:\\.|[^"])*"[/code] + Using [method search] you can find the pattern within the given text. If a pattern is found, [RegExMatch] is returned and you can retrieve details of the results using fuctions such as [method RegExMatch.get_string] and [method RegExMatch.get_start]. + [codeblock] + var regex = RegEx.new() + regex.compile("\\w-(\\d+)") + var result = regex.search("abc n-0123") + if result: + print(result.get_string()) # Would print n-0123 + [/codeblock] + The results of capturing groups [code]()[/code] can be retrieved by passing the group number to the various functions in [RegExMatch]. Group 0 is the default and would always refer to the entire pattern. In the above example, calling [code]result.get_string(1)[/code] would give you [code]0123[/code]. + This version of RegEx also supports named capturing groups, and the names can be used to retrieve the results. If two or more groups have the same name, the name would only refer to the first one with a match. + [codeblock] + var regex = RegEx.new() + regex.compile("d(?<digit>[0-9]+)|x(?<digit>[0-9a-f]+)") + var result = regex.search("the number is x2f") + if result: + print(result.get_string("digit")) # Would print 2f + [/codeblock] + If you need to process multiple results, [method search_all] generates a list of all non-overlapping results. This can be combined with a for-loop for convenience. + [codeblock] + for result in regex.search_all("d01, d03, d0c, x3f and x42"): + print(result.get_string("digit")) + # Would print 01 03 3f 42 + # Note that d0c would not match + [/codeblock] + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + <method name="clear"> + <return type="void"> + </return> + <description> + This method resets the state of the object, as it was freshly created. Namely, it unassigns the regular expression of this object. + </description> + </method> + <method name="compile"> + <return type="int" enum="Error"> + </return> + <argument index="0" name="pattern" type="String"> + </argument> + <description> + Compiles and assign the search pattern to use. Returns OK if the compilation is successful. If an error is encountered the details are printed to STDOUT and FAILED is returned. + </description> + </method> + <method name="get_group_count" qualifiers="const"> + <return type="int"> + </return> + <description> + Returns the number of capturing groups in compiled pattern. + </description> + </method> + <method name="get_names" qualifiers="const"> + <return type="Array"> + </return> + <description> + Returns an array of names of named capturing groups in the compiled pattern. They are ordered by appearance. + </description> + </method> + <method name="get_pattern" qualifiers="const"> + <return type="String"> + </return> + <description> + Returns the original search pattern that was compiled. + </description> + </method> + <method name="is_valid" qualifiers="const"> + <return type="bool"> + </return> + <description> + Returns whether this object has a valid search pattern assigned. + </description> + </method> + <method name="search" qualifiers="const"> + <return type="RegExMatch"> + </return> + <argument index="0" name="subject" type="String"> + </argument> + <argument index="1" name="offset" type="int" default="0"> + </argument> + <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 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="search_all" qualifiers="const"> + <return type="Array"> + </return> + <argument index="0" name="subject" type="String"> + </argument> + <argument index="1" name="offset" type="int" default="0"> + </argument> + <argument index="2" name="end" type="int" default="-1"> + </argument> + <description> + Searches the text for the compiled pattern. Returns an array of [RegExMatch] containers for each non-overlapping result. If no results were found an empty array is returned instead. 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"> + <return type="String"> + </return> + <argument index="0" name="subject" type="String"> + </argument> + <argument index="1" name="replacement" type="String"> + </argument> + <argument index="2" name="all" type="bool" default="false"> + </argument> + <argument index="3" name="offset" type="int" default="0"> + </argument> + <argument index="4" name="end" type="int" default="-1"> + </argument> + <description> + Searches the text for the compiled pattern and replaces it with the specified string. Escapes and backreferences such as [code]\1[/code] and [code]\g<name>[/code] expanded and resolved. By default only the first instance is replaced but it can be changed for all instances (global replacement). The region to search within can be specified without modifying where the start and end anchor would be. + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/modules/regex/doc_classes/RegExMatch.xml b/modules/regex/doc_classes/RegExMatch.xml new file mode 100644 index 0000000000..8c6951fea2 --- /dev/null +++ b/modules/regex/doc_classes/RegExMatch.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="RegExMatch" inherits="Reference" category="Core" version="3.0-alpha"> + <brief_description> + Contains the results of a regex search. + </brief_description> + <description> + Contains the results of a single regex match returned by [method RegEx.search] and [method RegEx.search_all]. It can be used to find the position and range of the match and its capturing groups, and it can extract its sub-string for you. + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + <method name="get_end" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="name" type="Variant" default="0"> + </argument> + <description> + Returns the end position of the match within the source string. The end position of capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern. + Returns -1 if the group did not match or doesn't exist. + </description> + </method> + <method name="get_group_count" qualifiers="const"> + <return type="int"> + </return> + <description> + Returns the number of capturing groups. + </description> + </method> + <method name="get_names" qualifiers="const"> + <return type="Dictionary"> + </return> + <description> + Returns a dictionary of named groups and its corresponding group number. Only groups with that were matched are included. If multiple groups have the same name, that name would refer to the first matching one. + </description> + </method> + <method name="get_start" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="name" type="Variant" default="0"> + </argument> + <description> + Returns the starting position of the match within the source string. The starting position of capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern. + Returns -1 if the group did not match or doesn't exist. + </description> + </method> + <method name="get_string" qualifiers="const"> + <return type="String"> + </return> + <argument index="0" name="name" type="Variant" default="0"> + </argument> + <description> + Returns the substring of the match from the source string. Capturing groups can be retrieved by providing its group number as an integer or its string name (if it's a named group). The default value of 0 refers to the whole pattern. + Returns an empty string if the group did not match or doesn't exist. + </description> + </method> + <method name="get_strings" qualifiers="const"> + <return type="Array"> + </return> + <description> + Returns an [Array] of the match and its capturing groups. + </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> + <constants> + </constants> +</class> diff --git a/modules/regex/regex.cpp b/modules/regex/regex.cpp index 00e8ce0f54..daadfcc659 100644 --- a/modules/regex/regex.cpp +++ b/modules/regex/regex.cpp @@ -324,6 +324,21 @@ Ref<RegExMatch> RegEx::search(const String &p_subject, int p_offset, int p_end) return result; } +Array RegEx::search_all(const String &p_subject, int p_offset, int p_end) const { + + int last_end = -1; + Array result; + Ref<RegExMatch> match = search(p_subject, p_offset, p_end); + while (match.is_valid()) { + if (last_end == match->get_end(0)) + break; + result.push_back(match); + last_end = match->get_end(0); + match = search(p_subject, match->get_end(0), p_end); + } + return result; +} + String RegEx::sub(const String &p_subject, const String &p_replacement, bool p_all, int p_offset, int p_end) const { ERR_FAIL_COND_V(!is_valid(), String()); @@ -489,6 +504,7 @@ void RegEx::_bind_methods() { ClassDB::bind_method(D_METHOD("clear"), &RegEx::clear); ClassDB::bind_method(D_METHOD("compile", "pattern"), &RegEx::compile); ClassDB::bind_method(D_METHOD("search", "subject", "offset", "end"), &RegEx::search, DEFVAL(0), DEFVAL(-1)); + ClassDB::bind_method(D_METHOD("search_all", "subject", "offset", "end"), &RegEx::search_all, DEFVAL(0), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("sub", "subject", "replacement", "all", "offset", "end"), &RegEx::sub, DEFVAL(false), DEFVAL(0), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("is_valid"), &RegEx::is_valid); ClassDB::bind_method(D_METHOD("get_pattern"), &RegEx::get_pattern); diff --git a/modules/regex/regex.h b/modules/regex/regex.h index bfa9c84042..21387222f2 100644 --- a/modules/regex/regex.h +++ b/modules/regex/regex.h @@ -88,6 +88,7 @@ public: void _init(const String &p_pattern = ""); Ref<RegExMatch> search(const String &p_subject, int p_offset = 0, int p_end = -1) const; + Array search_all(const String &p_subject, int p_offset = 0, int p_end = -1) const; String sub(const String &p_subject, const String &p_replacement, bool p_all = false, int p_offset = 0, int p_end = -1) const; bool is_valid() const; diff --git a/modules/squish/config.py b/modules/squish/config.py index 9b7729bda4..97c95999c8 100644 --- a/modules/squish/config.py +++ b/modules/squish/config.py @@ -1,8 +1,6 @@ - def can_build(platform): return True - def configure(env): # Tools only, disabled for non-tools # TODO: Find a cleaner way to achieve that diff --git a/modules/stb_vorbis/config.py b/modules/stb_vorbis/config.py index fb920482f5..defe8d0c94 100644 --- a/modules/stb_vorbis/config.py +++ b/modules/stb_vorbis/config.py @@ -1,7 +1,14 @@ - def can_build(platform): return True - def configure(env): pass + +def get_doc_classes(): + return [ + "AudioStreamOGGVorbis", + "ResourceImporterOGGVorbis", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/doc/classes/AudioStreamOGGVorbis.xml b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml index 679438b66b..ee6c28c36a 100644 --- a/doc/classes/AudioStreamOGGVorbis.xml +++ b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="AudioStreamOGGVorbis" inherits="AudioStream" category="Core" version="3.0.alpha.custom_build"> +<class name="AudioStreamOGGVorbis" inherits="AudioStream" category="Core" version="3.0-alpha"> <brief_description> OGG Vorbis audio stream driver. </brief_description> diff --git a/doc/classes/ResourceImporterOGGVorbis.xml b/modules/stb_vorbis/doc_classes/ResourceImporterOGGVorbis.xml index eef626cee7..ce16632d6e 100644 --- a/doc/classes/ResourceImporterOGGVorbis.xml +++ b/modules/stb_vorbis/doc_classes/ResourceImporterOGGVorbis.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="ResourceImporterOGGVorbis" inherits="ResourceImporter" category="Core" version="3.0.alpha.custom_build"> +<class name="ResourceImporterOGGVorbis" inherits="ResourceImporter" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/modules/svg/config.py b/modules/svg/config.py index fb920482f5..5f133eba90 100644 --- a/modules/svg/config.py +++ b/modules/svg/config.py @@ -1,7 +1,5 @@ - def can_build(platform): return True - def configure(env): pass diff --git a/modules/tga/config.py b/modules/tga/config.py index fb920482f5..5f133eba90 100644 --- a/modules/tga/config.py +++ b/modules/tga/config.py @@ -1,7 +1,5 @@ - def can_build(platform): return True - def configure(env): pass diff --git a/modules/theora/config.py b/modules/theora/config.py index 8eefe81288..34d34f8be2 100644 --- a/modules/theora/config.py +++ b/modules/theora/config.py @@ -1,8 +1,14 @@ - def can_build(platform): -# return True - return False - + return True def configure(env): pass + +def get_doc_classes(): + return [ + "ResourceImporterTheora", + "VideoStreamTheora", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/modules/theora/doc_classes/ResourceImporterTheora.xml b/modules/theora/doc_classes/ResourceImporterTheora.xml new file mode 100644 index 0000000000..497c938826 --- /dev/null +++ b/modules/theora/doc_classes/ResourceImporterTheora.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ResourceImporterTheora" inherits="ResourceImporter" category="Core" version="3.0-alpha"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + </methods> + <constants> + </constants> +</class> diff --git a/modules/theora/doc_classes/VideoStreamTheora.xml b/modules/theora/doc_classes/VideoStreamTheora.xml new file mode 100644 index 0000000000..8f155b786f --- /dev/null +++ b/modules/theora/doc_classes/VideoStreamTheora.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="VideoStreamTheora" inherits="VideoStream" category="Core" version="3.0-alpha"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + <method name="get_file"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="set_file"> + <return type="void"> + </return> + <argument index="0" name="file" type="String"> + </argument> + <description> + </description> + </method> + </methods> + <members> + <member name="file" type="String" setter="set_file" getter="get_file"> + </member> + </members> + <constants> + </constants> +</class> diff --git a/modules/theora/register_types.cpp b/modules/theora/register_types.cpp index ae6961b3da..c51b87b8fc 100644 --- a/modules/theora/register_types.cpp +++ b/modules/theora/register_types.cpp @@ -28,19 +28,18 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "register_types.h" - +#include "resource_importer_theora.h" #include "video_stream_theora.h" -static ResourceFormatLoaderVideoStreamTheora *theora_stream_loader = NULL; - void register_theora_types() { - theora_stream_loader = memnew(ResourceFormatLoaderVideoStreamTheora); - ResourceLoader::add_resource_format_loader(theora_stream_loader); +#ifdef TOOLS_ENABLED + Ref<ResourceImporterTheora> theora_import; + theora_import.instance(); + ResourceFormatImporter::get_singleton()->add_importer(theora_import); +#endif ClassDB::register_class<VideoStreamTheora>(); } void unregister_theora_types() { - - memdelete(theora_stream_loader); } diff --git a/modules/theora/resource_importer_theora.cpp b/modules/theora/resource_importer_theora.cpp new file mode 100644 index 0000000000..c25c0e7427 --- /dev/null +++ b/modules/theora/resource_importer_theora.cpp @@ -0,0 +1,89 @@ +/*************************************************************************/ +/* resource_importer_theora.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "resource_importer_theora.h" + +#include "io/resource_saver.h" +#include "os/file_access.h" +#include "scene/resources/texture.h" + +String ResourceImporterTheora::get_importer_name() const { + + return "Theora"; +} + +String ResourceImporterTheora::get_visible_name() const { + + return "Theora"; +} +void ResourceImporterTheora::get_recognized_extensions(List<String> *p_extensions) const { + + p_extensions->push_back("ogv"); + p_extensions->push_back("ogm"); +} + +String ResourceImporterTheora::get_save_extension() const { + return "ogvstr"; +} + +String ResourceImporterTheora::get_resource_type() const { + + return "VideoStreamTheora"; +} + +bool ResourceImporterTheora::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { + + return true; +} + +int ResourceImporterTheora::get_preset_count() const { + return 0; +} +String ResourceImporterTheora::get_preset_name(int p_idx) const { + + return String(); +} + +void ResourceImporterTheora::get_import_options(List<ImportOption> *r_options, int p_preset) const { + + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "loop"), true)); +} + +Error ResourceImporterTheora::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) { + + VideoStreamTheora *stream = memnew(VideoStreamTheora); + stream->set_file(p_source_file); + + Ref<VideoStreamTheora> ogv_stream = Ref<VideoStreamTheora>(stream); + + return ResourceSaver::save(p_save_path + ".ogvstr", ogv_stream); +} + +ResourceImporterTheora::ResourceImporterTheora() { +} diff --git a/modules/theora/resource_importer_theora.h b/modules/theora/resource_importer_theora.h new file mode 100644 index 0000000000..8bf0ad38c4 --- /dev/null +++ b/modules/theora/resource_importer_theora.h @@ -0,0 +1,57 @@ +/*************************************************************************/ +/* resource_importer_theora.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef RESOURCEIMPORTEROGGTHEORA_H +#define RESOURCEIMPORTEROGGTHEORA_H + +#include "video_stream_theora.h" + +#include "core/io/resource_import.h" + +class ResourceImporterTheora : public ResourceImporter { + GDCLASS(ResourceImporterTheora, ResourceImporter) +public: + virtual String get_importer_name() const; + virtual String get_visible_name() const; + virtual void get_recognized_extensions(List<String> *p_extensions) const; + virtual String get_save_extension() const; + virtual String get_resource_type() const; + + virtual int get_preset_count() const; + virtual String get_preset_name(int p_idx) const; + + virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; + virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; + + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL); + + ResourceImporterTheora(); +}; + +#endif // RESOURCEIMPORTEROGGTHEORA_H diff --git a/modules/theora/video_stream_theora.cpp b/modules/theora/video_stream_theora.cpp index c75bec31df..bc8ca23d60 100644 --- a/modules/theora/video_stream_theora.cpp +++ b/modules/theora/video_stream_theora.cpp @@ -406,20 +406,19 @@ void VideoStreamPlaybackTheora::update(float p_delta) { ogg_packet op; bool no_theora = false; + bool buffer_full = false; - while (vorbis_p) { + while (vorbis_p && !audio_done && !buffer_full) { int ret; float **pcm; - bool buffer_full = false; - /* if there's pending, decoded audio, grab it */ ret = vorbis_synthesis_pcmout(&vd, &pcm); if (ret > 0) { const int AUXBUF_LEN = 4096; int to_read = ret; - int16_t aux_buffer[AUXBUF_LEN]; + float aux_buffer[AUXBUF_LEN]; while (to_read) { @@ -429,11 +428,7 @@ void VideoStreamPlaybackTheora::update(float p_delta) { for (int j = 0; j < m; j++) { for (int i = 0; i < vi.channels; i++) { - - int val = Math::fast_ftoi(pcm[i][j] * 32767.f); - if (val > 32767) val = 32767; - if (val < -32768) val = -32768; - aux_buffer[count++] = val; + aux_buffer[count++] = pcm[i][j]; } } @@ -602,10 +597,9 @@ bool VideoStreamPlaybackTheora::is_playing() const { void VideoStreamPlaybackTheora::set_paused(bool p_paused) { paused = p_paused; - //pau = !p_paused; }; -bool VideoStreamPlaybackTheora::is_paused(bool p_paused) const { +bool VideoStreamPlaybackTheora::is_paused() const { return paused; }; @@ -733,32 +727,10 @@ VideoStreamPlaybackTheora::~VideoStreamPlaybackTheora() { memdelete(file); }; -RES ResourceFormatLoaderVideoStreamTheora::load(const String &p_path, const String &p_original_path, Error *r_error) { - if (r_error) - *r_error = ERR_FILE_CANT_OPEN; - - VideoStreamTheora *stream = memnew(VideoStreamTheora); - stream->set_file(p_path); - - if (r_error) - *r_error = OK; - - return Ref<VideoStreamTheora>(stream); -} +void VideoStreamTheora::_bind_methods() { -void ResourceFormatLoaderVideoStreamTheora::get_recognized_extensions(List<String> *p_extensions) const { + ClassDB::bind_method(D_METHOD("set_file", "file"), &VideoStreamTheora::set_file); + ClassDB::bind_method(D_METHOD("get_file"), &VideoStreamTheora::get_file); - p_extensions->push_back("ogm"); - p_extensions->push_back("ogv"); -} -bool ResourceFormatLoaderVideoStreamTheora::handles_type(const String &p_type) const { - return (p_type == "VideoStream" || p_type == "VideoStreamTheora"); -} - -String ResourceFormatLoaderVideoStreamTheora::get_resource_type(const String &p_path) const { - - String exl = p_path.get_extension().to_lower(); - if (exl == "ogm" || exl == "ogv") - return "VideoStreamTheora"; - return ""; + ADD_PROPERTY(PropertyInfo(Variant::STRING, "file", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_file", "get_file"); } diff --git a/modules/theora/video_stream_theora.h b/modules/theora/video_stream_theora.h index 484a1a7fb9..ec0e5aa34a 100644 --- a/modules/theora/video_stream_theora.h +++ b/modules/theora/video_stream_theora.h @@ -36,6 +36,7 @@ #include "os/thread.h" #include "ring_buffer.h" #include "scene/resources/video_stream.h" +#include "servers/audio_server.h" #include <theora/theoradec.h> #include <vorbis/codec.h> @@ -129,7 +130,7 @@ public: virtual bool is_playing() const; virtual void set_paused(bool p_paused); - virtual bool is_paused(bool p_paused) const; + virtual bool is_paused() const; virtual void set_loop(bool p_enable); virtual bool has_loop() const; @@ -161,10 +162,14 @@ public: class VideoStreamTheora : public VideoStream { GDCLASS(VideoStreamTheora, VideoStream); + RES_BASE_EXTENSION("ogvstr"); String file; int audio_track; +protected: + static void _bind_methods(); + public: Ref<VideoStreamPlayback> instance_playback() { Ref<VideoStreamPlaybackTheora> pb = memnew(VideoStreamPlaybackTheora); @@ -174,17 +179,10 @@ public: } void set_file(const String &p_file) { file = p_file; } + String get_file() { return file; } void set_audio_track(int p_track) { audio_track = p_track; } VideoStreamTheora() { audio_track = 0; } }; -class ResourceFormatLoaderVideoStreamTheora : public ResourceFormatLoader { -public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL); - virtual void get_recognized_extensions(List<String> *p_extensions) const; - virtual bool handles_type(const String &p_type) const; - virtual String get_resource_type(const String &p_path) const; -}; - #endif diff --git a/modules/tinyexr/config.py b/modules/tinyexr/config.py index 3e16fd725e..e12bb398ce 100644 --- a/modules/tinyexr/config.py +++ b/modules/tinyexr/config.py @@ -1,8 +1,6 @@ - def can_build(platform): return True - def configure(env): # Tools only, disabled for non-tools # TODO: Find a cleaner way to achieve that diff --git a/modules/visual_script/config.py b/modules/visual_script/config.py index 5698a37295..6b1ce41014 100644 --- a/modules/visual_script/config.py +++ b/modules/visual_script/config.py @@ -1,8 +1,57 @@ - - def can_build(platform): return True - def configure(env): pass + +def get_doc_classes(): + return [ + "VisualScriptBasicTypeConstant", + "VisualScriptBuiltinFunc", + "VisualScriptClassConstant", + "VisualScriptComment", + "VisualScriptCondition", + "VisualScriptConstant", + "VisualScriptConstructor", + "VisualScriptCustomNode", + "VisualScriptDeconstruct", + "VisualScriptEditor", + "VisualScriptEmitSignal", + "VisualScriptEngineSingleton", + "VisualScriptExpression", + "VisualScriptFunctionCall", + "VisualScriptFunctionState", + "VisualScriptFunction", + "VisualScriptGlobalConstant", + "VisualScriptIndexGet", + "VisualScriptIndexSet", + "VisualScriptInputAction", + "VisualScriptIterator", + "VisualScriptLocalVarSet", + "VisualScriptLocalVar", + "VisualScriptMathConstant", + "VisualScriptNode", + "VisualScriptOperator", + "VisualScriptPreload", + "VisualScriptPropertyGet", + "VisualScriptPropertySet", + "VisualScriptResourcePath", + "VisualScriptReturn", + "VisualScriptSceneNode", + "VisualScriptSceneTree", + "VisualScriptSelect", + "VisualScriptSelf", + "VisualScriptSequence", + "VisualScriptSubCall", + "VisualScriptSwitch", + "VisualScriptTypeCast", + "VisualScriptVariableGet", + "VisualScriptVariableSet", + "VisualScriptWhile", + "VisualScript", + "VisualScriptYieldSignal", + "VisualScriptYield", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/doc/classes/VisualScript.xml b/modules/visual_script/doc_classes/VisualScript.xml index 8961ff1564..80b1ed86d7 100644 --- a/doc/classes/VisualScript.xml +++ b/modules/visual_script/doc_classes/VisualScript.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScript" inherits="Script" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScript" inherits="Script" category="Core" version="3.0-alpha"> <brief_description> A script implemented in the Visual Script programming environment. </brief_description> diff --git a/doc/classes/VisualScriptBasicTypeConstant.xml b/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml index cc09815481..6c028e5f28 100644 --- a/doc/classes/VisualScriptBasicTypeConstant.xml +++ b/modules/visual_script/doc_classes/VisualScriptBasicTypeConstant.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptBasicTypeConstant" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptBasicTypeConstant" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> A Visual Script node representing a constant from the base types. </brief_description> diff --git a/doc/classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml index 5891b24bfd..27231574d7 100644 --- a/doc/classes/VisualScriptBuiltinFunc.xml +++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptBuiltinFunc" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptBuiltinFunc" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> A Visual Script node used to call built-in functions. </brief_description> @@ -151,64 +151,68 @@ <constant name="MATH_DB2LINEAR" value="39"> Convert the input from decibel volume to linear volume. </constant> - <constant name="LOGIC_MAX" value="40"> + <constant name="MATH_WRAP" value="40"> + </constant> + <constant name="MATH_WRAPF" value="41"> + </constant> + <constant name="LOGIC_MAX" value="42"> Return the greater of the two numbers, also known as their maximum. </constant> - <constant name="LOGIC_MIN" value="41"> + <constant name="LOGIC_MIN" value="43"> Return the lesser of the two numbers, also known as their minimum. </constant> - <constant name="LOGIC_CLAMP" value="42"> + <constant name="LOGIC_CLAMP" value="44"> Return the input clamped inside the given range, ensuring the result is never outside it. Equivalent to `min(max(input, range_low), range_high)` </constant> - <constant name="LOGIC_NEAREST_PO2" value="43"> + <constant name="LOGIC_NEAREST_PO2" value="45"> Return the nearest power of 2 to the input. </constant> - <constant name="OBJ_WEAKREF" value="44"> + <constant name="OBJ_WEAKREF" value="46"> Create a [WeakRef] from the input. </constant> - <constant name="FUNC_FUNCREF" value="45"> + <constant name="FUNC_FUNCREF" value="47"> Create a [FuncRef] from the input. </constant> - <constant name="TYPE_CONVERT" value="46"> + <constant name="TYPE_CONVERT" value="48"> Convert between types. </constant> - <constant name="TYPE_OF" value="47"> + <constant name="TYPE_OF" value="49"> Return the type of the input as an integer. Check [enum Variant.Type] for the integers that might be returned. </constant> - <constant name="TYPE_EXISTS" value="48"> + <constant name="TYPE_EXISTS" value="50"> Checks if a type is registered in the [ClassDB]. </constant> - <constant name="TEXT_CHAR" value="49"> + <constant name="TEXT_CHAR" value="51"> Return a character with the given ascii value. </constant> - <constant name="TEXT_STR" value="50"> + <constant name="TEXT_STR" value="52"> Convert the input to a string. </constant> - <constant name="TEXT_PRINT" value="51"> + <constant name="TEXT_PRINT" value="53"> Print the given string to the output window. </constant> - <constant name="TEXT_PRINTERR" value="52"> + <constant name="TEXT_PRINTERR" value="54"> Print the given string to the standard error output. </constant> - <constant name="TEXT_PRINTRAW" value="53"> + <constant name="TEXT_PRINTRAW" value="55"> Print the given string to the standard output, without adding a newline. </constant> - <constant name="VAR_TO_STR" value="54"> + <constant name="VAR_TO_STR" value="56"> Serialize a [Variant] to a string. </constant> - <constant name="STR_TO_VAR" value="55"> + <constant name="STR_TO_VAR" value="57"> Deserialize a [Variant] from a string serialized using [VAR_TO_STR]. </constant> - <constant name="VAR_TO_BYTES" value="56"> + <constant name="VAR_TO_BYTES" value="58"> Serialize a [Variant] to a [PoolByteArray]. </constant> - <constant name="BYTES_TO_VAR" value="57"> + <constant name="BYTES_TO_VAR" value="59"> Deserialize a [Variant] from a [PoolByteArray] serialized using [VAR_TO_BYTES]. </constant> - <constant name="COLORN" value="58"> + <constant name="COLORN" value="60"> Return the [Color] with the given name and alpha ranging from 0 to 1. Note: names are defined in color_names.inc. </constant> - <constant name="FUNC_MAX" value="59"> + <constant name="FUNC_MAX" value="61"> The maximum value the [member function] property can have. </constant> </constants> diff --git a/doc/classes/VisualScriptClassConstant.xml b/modules/visual_script/doc_classes/VisualScriptClassConstant.xml index 0377fa8f09..e6498e92ad 100644 --- a/doc/classes/VisualScriptClassConstant.xml +++ b/modules/visual_script/doc_classes/VisualScriptClassConstant.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptClassConstant" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptClassConstant" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Gets a constant from a given class. </brief_description> diff --git a/doc/classes/VisualScriptComment.xml b/modules/visual_script/doc_classes/VisualScriptComment.xml index 69126052d0..ea4545f8ef 100644 --- a/doc/classes/VisualScriptComment.xml +++ b/modules/visual_script/doc_classes/VisualScriptComment.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptComment" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptComment" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> A Visual Script node used to annotate the script. </brief_description> diff --git a/doc/classes/VisualScriptCondition.xml b/modules/visual_script/doc_classes/VisualScriptCondition.xml index a776c9bc9b..2a30c604a5 100644 --- a/doc/classes/VisualScriptCondition.xml +++ b/modules/visual_script/doc_classes/VisualScriptCondition.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptCondition" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptCondition" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> A Visual Script node which branches the flow. </brief_description> diff --git a/doc/classes/VisualScriptConstant.xml b/modules/visual_script/doc_classes/VisualScriptConstant.xml index 2a704adecf..51c6d19238 100644 --- a/doc/classes/VisualScriptConstant.xml +++ b/modules/visual_script/doc_classes/VisualScriptConstant.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptConstant" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptConstant" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Gets a contant's value. </brief_description> diff --git a/doc/classes/VisualScriptConstructor.xml b/modules/visual_script/doc_classes/VisualScriptConstructor.xml index 3b1fc5e385..91df52e893 100644 --- a/doc/classes/VisualScriptConstructor.xml +++ b/modules/visual_script/doc_classes/VisualScriptConstructor.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptConstructor" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptConstructor" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> A Visual Script node which calls a base type constructor. </brief_description> diff --git a/doc/classes/VisualScriptCustomNode.xml b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml index e321c8854a..38c325cfb7 100644 --- a/doc/classes/VisualScriptCustomNode.xml +++ b/modules/visual_script/doc_classes/VisualScriptCustomNode.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptCustomNode" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptCustomNode" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> A scripted Visual Script node. </brief_description> diff --git a/doc/classes/VisualScriptDeconstruct.xml b/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml index cd7d79ae56..cbed3ba22c 100644 --- a/doc/classes/VisualScriptDeconstruct.xml +++ b/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptDeconstruct" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptDeconstruct" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> A Visual Script node which deconstructs a base type instance into its parts. </brief_description> diff --git a/modules/visual_script/doc_classes/VisualScriptEditor.xml b/modules/visual_script/doc_classes/VisualScriptEditor.xml new file mode 100644 index 0000000000..70d52b2bd7 --- /dev/null +++ b/modules/visual_script/doc_classes/VisualScriptEditor.xml @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="VisualScriptEditor" inherits="Object" category="Core" version="3.0.alpha.custom_build"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + <method name="add_custom_node"> + <return type="void"> + </return> + <argument index="0" name="name" type="String"> + </argument> + <argument index="1" name="category" type="String"> + </argument> + <argument index="2" name="script" type="Script"> + </argument> + <description> + Add a custom Visual Script node to the editor. It'll be placed under "Custom Nodes" with the [code]category[/code] as the parameter. + </description> + </method> + <method name="remove_custom_node"> + <return type="void"> + </return> + <argument index="0" name="name" type="String"> + </argument> + <argument index="1" name="category" type="String"> + </argument> + <description> + Remove a custom Visual Script node from the editor. Custom nodes already placed on scripts won't be removed. + </description> + </method> + </methods> + <signals> + <signal name="custom_nodes_updated"> + <description> + Emitted when a custom Visual Script node is added or removed. + </description> + </signal> + </signals> + <constants> + </constants> +</class> diff --git a/doc/classes/VisualScriptEmitSignal.xml b/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml index 8d132ed321..669276f0d0 100644 --- a/doc/classes/VisualScriptEmitSignal.xml +++ b/modules/visual_script/doc_classes/VisualScriptEmitSignal.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptEmitSignal" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptEmitSignal" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Emits a specified signal. </brief_description> diff --git a/doc/classes/VisualScriptEngineSingleton.xml b/modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml index 6606f10f11..6703ff4eda 100644 --- a/doc/classes/VisualScriptEngineSingleton.xml +++ b/modules/visual_script/doc_classes/VisualScriptEngineSingleton.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptEngineSingleton" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptEngineSingleton" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> A Visual Script node returning a singleton from [@GlobalScope] </brief_description> diff --git a/doc/classes/VisualScriptExpression.xml b/modules/visual_script/doc_classes/VisualScriptExpression.xml index 1ca943a8a8..fb3b6ef19d 100644 --- a/doc/classes/VisualScriptExpression.xml +++ b/modules/visual_script/doc_classes/VisualScriptExpression.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptExpression" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptExpression" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptFunction.xml b/modules/visual_script/doc_classes/VisualScriptFunction.xml index 946231eaad..d77169679b 100644 --- a/doc/classes/VisualScriptFunction.xml +++ b/modules/visual_script/doc_classes/VisualScriptFunction.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptFunction" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptFunction" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptFunctionCall.xml b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml index 36c808afce..7a0a7c9f55 100644 --- a/doc/classes/VisualScriptFunctionCall.xml +++ b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptFunctionCall" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptFunctionCall" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptFunctionState.xml b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml index d5c06682ef..9b30f62236 100644 --- a/doc/classes/VisualScriptFunctionState.xml +++ b/modules/visual_script/doc_classes/VisualScriptFunctionState.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptFunctionState" inherits="Reference" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptFunctionState" inherits="Reference" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptGlobalConstant.xml b/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml index 52bf8c2821..961244fe88 100644 --- a/doc/classes/VisualScriptGlobalConstant.xml +++ b/modules/visual_script/doc_classes/VisualScriptGlobalConstant.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptGlobalConstant" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptGlobalConstant" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptIndexGet.xml b/modules/visual_script/doc_classes/VisualScriptIndexGet.xml index c0226b6677..c5229f7678 100644 --- a/doc/classes/VisualScriptIndexGet.xml +++ b/modules/visual_script/doc_classes/VisualScriptIndexGet.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptIndexGet" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptIndexGet" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptIndexSet.xml b/modules/visual_script/doc_classes/VisualScriptIndexSet.xml index 440b4801b4..27646b4a5f 100644 --- a/doc/classes/VisualScriptIndexSet.xml +++ b/modules/visual_script/doc_classes/VisualScriptIndexSet.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptIndexSet" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptIndexSet" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptInputAction.xml b/modules/visual_script/doc_classes/VisualScriptInputAction.xml index b555a0228b..7f6d13264e 100644 --- a/doc/classes/VisualScriptInputAction.xml +++ b/modules/visual_script/doc_classes/VisualScriptInputAction.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptInputAction" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptInputAction" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptIterator.xml b/modules/visual_script/doc_classes/VisualScriptIterator.xml index 1f9a4fddde..fc905d6c39 100644 --- a/doc/classes/VisualScriptIterator.xml +++ b/modules/visual_script/doc_classes/VisualScriptIterator.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptIterator" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptIterator" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Steps through items in a given input. </brief_description> diff --git a/doc/classes/VisualScriptLocalVar.xml b/modules/visual_script/doc_classes/VisualScriptLocalVar.xml index 3101b3e34b..ff77dfac0d 100644 --- a/doc/classes/VisualScriptLocalVar.xml +++ b/modules/visual_script/doc_classes/VisualScriptLocalVar.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptLocalVar" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptLocalVar" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Gets a local variable's value. </brief_description> diff --git a/doc/classes/VisualScriptLocalVarSet.xml b/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml index e039a7204e..07b01d4576 100644 --- a/doc/classes/VisualScriptLocalVarSet.xml +++ b/modules/visual_script/doc_classes/VisualScriptLocalVarSet.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptLocalVarSet" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptLocalVarSet" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Changes a local variable's value. </brief_description> diff --git a/doc/classes/VisualScriptMathConstant.xml b/modules/visual_script/doc_classes/VisualScriptMathConstant.xml index 86744e5caf..817bcb5ce2 100644 --- a/doc/classes/VisualScriptMathConstant.xml +++ b/modules/visual_script/doc_classes/VisualScriptMathConstant.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptMathConstant" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptMathConstant" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Commonly used mathematical constants. </brief_description> @@ -42,12 +42,12 @@ <constant name="MATH_CONSTANT_PI" value="1"> Pi: [code]3.141593[/code] </constant> - <constant name="MATH_CONSTANT_2PI" value="2"> - Pi times two: [code]6.283185[/code] - </constant> - <constant name="MATH_CONSTANT_HALF_PI" value="3"> + <constant name="MATH_CONSTANT_HALF_PI" value="2"> Pi divided by two: [code]1.570796[/code] </constant> + <constant name="MATH_CONSTANT_TAU" value="3"> + Tau: [code]6.283185[/code] + </constant> <constant name="MATH_CONSTANT_E" value="4"> Natural log: [code]2.718282[/code] </constant> diff --git a/doc/classes/VisualScriptNode.xml b/modules/visual_script/doc_classes/VisualScriptNode.xml index 74ec9bdc2e..f6f2867172 100644 --- a/doc/classes/VisualScriptNode.xml +++ b/modules/visual_script/doc_classes/VisualScriptNode.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptNode" inherits="Resource" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptNode" inherits="Resource" category="Core" version="3.0-alpha"> <brief_description> A node which is part of a [VisualScript]. </brief_description> diff --git a/doc/classes/VisualScriptOperator.xml b/modules/visual_script/doc_classes/VisualScriptOperator.xml index de08075af2..bf4032c09c 100644 --- a/doc/classes/VisualScriptOperator.xml +++ b/modules/visual_script/doc_classes/VisualScriptOperator.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptOperator" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptOperator" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptPreload.xml b/modules/visual_script/doc_classes/VisualScriptPreload.xml index b683439751..4a71e23809 100644 --- a/doc/classes/VisualScriptPreload.xml +++ b/modules/visual_script/doc_classes/VisualScriptPreload.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptPreload" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptPreload" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Creates a new [Resource] or loads one from the filesystem. </brief_description> diff --git a/doc/classes/VisualScriptPropertyGet.xml b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml index c790a59b0c..eb5c52f4be 100644 --- a/doc/classes/VisualScriptPropertyGet.xml +++ b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptPropertyGet" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptPropertyGet" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptPropertySet.xml b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml index 88d47a7463..794caa2518 100644 --- a/doc/classes/VisualScriptPropertySet.xml +++ b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptPropertySet" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptPropertySet" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptResourcePath.xml b/modules/visual_script/doc_classes/VisualScriptResourcePath.xml index e4b881b659..274a852c3e 100644 --- a/doc/classes/VisualScriptResourcePath.xml +++ b/modules/visual_script/doc_classes/VisualScriptResourcePath.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptResourcePath" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptResourcePath" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptReturn.xml b/modules/visual_script/doc_classes/VisualScriptReturn.xml index ad18e96230..4ac586a02c 100644 --- a/doc/classes/VisualScriptReturn.xml +++ b/modules/visual_script/doc_classes/VisualScriptReturn.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptReturn" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptReturn" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Exits a function and returns an optional value. </brief_description> diff --git a/doc/classes/VisualScriptSceneNode.xml b/modules/visual_script/doc_classes/VisualScriptSceneNode.xml index b71bd9adfb..e8fdb69c6a 100644 --- a/doc/classes/VisualScriptSceneNode.xml +++ b/modules/visual_script/doc_classes/VisualScriptSceneNode.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptSceneNode" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptSceneNode" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Node reference. </brief_description> diff --git a/doc/classes/VisualScriptSceneTree.xml b/modules/visual_script/doc_classes/VisualScriptSceneTree.xml index 55e27460ab..e74c330623 100644 --- a/doc/classes/VisualScriptSceneTree.xml +++ b/modules/visual_script/doc_classes/VisualScriptSceneTree.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptSceneTree" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptSceneTree" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptSelect.xml b/modules/visual_script/doc_classes/VisualScriptSelect.xml index f265c57645..6a62e364f3 100644 --- a/doc/classes/VisualScriptSelect.xml +++ b/modules/visual_script/doc_classes/VisualScriptSelect.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptSelect" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptSelect" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Chooses between two input values. </brief_description> diff --git a/doc/classes/VisualScriptSelf.xml b/modules/visual_script/doc_classes/VisualScriptSelf.xml index 723b138722..f39a02bf84 100644 --- a/doc/classes/VisualScriptSelf.xml +++ b/modules/visual_script/doc_classes/VisualScriptSelf.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptSelf" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptSelf" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Outputs a reference to the current instance. </brief_description> diff --git a/doc/classes/VisualScriptSequence.xml b/modules/visual_script/doc_classes/VisualScriptSequence.xml index 845da4e50b..51238070d5 100644 --- a/doc/classes/VisualScriptSequence.xml +++ b/modules/visual_script/doc_classes/VisualScriptSequence.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptSequence" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptSequence" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Executes a series of Sequence ports. </brief_description> diff --git a/doc/classes/VisualScriptSubCall.xml b/modules/visual_script/doc_classes/VisualScriptSubCall.xml index 297ec96781..381095f49b 100644 --- a/doc/classes/VisualScriptSubCall.xml +++ b/modules/visual_script/doc_classes/VisualScriptSubCall.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptSubCall" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptSubCall" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptSwitch.xml b/modules/visual_script/doc_classes/VisualScriptSwitch.xml index 2540ae54cc..3c8a79f686 100644 --- a/doc/classes/VisualScriptSwitch.xml +++ b/modules/visual_script/doc_classes/VisualScriptSwitch.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptSwitch" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptSwitch" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Branches program flow based on a given input's value. </brief_description> diff --git a/doc/classes/VisualScriptTypeCast.xml b/modules/visual_script/doc_classes/VisualScriptTypeCast.xml index 3008426900..417c0a5159 100644 --- a/doc/classes/VisualScriptTypeCast.xml +++ b/modules/visual_script/doc_classes/VisualScriptTypeCast.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptTypeCast" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptTypeCast" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptVariableGet.xml b/modules/visual_script/doc_classes/VisualScriptVariableGet.xml index 5b45dd0cc4..1cad4480a6 100644 --- a/doc/classes/VisualScriptVariableGet.xml +++ b/modules/visual_script/doc_classes/VisualScriptVariableGet.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptVariableGet" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptVariableGet" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Gets a variable's value. </brief_description> diff --git a/doc/classes/VisualScriptVariableSet.xml b/modules/visual_script/doc_classes/VisualScriptVariableSet.xml index 51f85f6881..fa3befa21d 100644 --- a/doc/classes/VisualScriptVariableSet.xml +++ b/modules/visual_script/doc_classes/VisualScriptVariableSet.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptVariableSet" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptVariableSet" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Changes a variable's value. </brief_description> diff --git a/doc/classes/VisualScriptWhile.xml b/modules/visual_script/doc_classes/VisualScriptWhile.xml index 60bf161339..f948660997 100644 --- a/doc/classes/VisualScriptWhile.xml +++ b/modules/visual_script/doc_classes/VisualScriptWhile.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptWhile" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptWhile" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> Conditional loop. </brief_description> diff --git a/doc/classes/VisualScriptYield.xml b/modules/visual_script/doc_classes/VisualScriptYield.xml index a0d95f151a..5474ee8b78 100644 --- a/doc/classes/VisualScriptYield.xml +++ b/modules/visual_script/doc_classes/VisualScriptYield.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptYield" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptYield" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/doc/classes/VisualScriptYieldSignal.xml b/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml index f4202edf2b..a3b6982075 100644 --- a/doc/classes/VisualScriptYieldSignal.xml +++ b/modules/visual_script/doc_classes/VisualScriptYieldSignal.xml @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="UTF-8" ?> -<class name="VisualScriptYieldSignal" inherits="VisualScriptNode" category="Core" version="3.0.alpha.custom_build"> +<class name="VisualScriptYieldSignal" inherits="VisualScriptNode" category="Core" version="3.0-alpha"> <brief_description> </brief_description> <description> diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp index c50ba17c35..b6ce10381d 100644 --- a/modules/visual_script/register_types.cpp +++ b/modules/visual_script/register_types.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "register_types.h" +#include "core/engine.h" #include "io/resource_loader.h" #include "visual_script.h" #include "visual_script_builtin_funcs.h" @@ -40,6 +41,9 @@ #include "visual_script_yield_nodes.h" VisualScriptLanguage *visual_script_language = NULL; +#ifdef TOOLS_ENABLED +static _VisualScriptEditor *vs_editor_singleton = NULL; +#endif void register_visual_script_types() { @@ -107,6 +111,10 @@ void register_visual_script_types() { register_visual_script_expression_node(); #ifdef TOOLS_ENABLED + ClassDB::register_class<_VisualScriptEditor>(); + vs_editor_singleton = memnew(_VisualScriptEditor); + Engine::get_singleton()->add_singleton(Engine::Singleton("VisualScriptEditor", _VisualScriptEditor::get_singleton())); + VisualScriptEditor::register_editor(); #endif } @@ -119,6 +127,9 @@ void unregister_visual_script_types() { #ifdef TOOLS_ENABLED VisualScriptEditor::free_clipboard(); + if (vs_editor_singleton) { + memdelete(vs_editor_singleton); + } #endif if (visual_script_language) memdelete(visual_script_language); diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 765fe4c2f2..0834bc81d9 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -2644,6 +2644,11 @@ void VisualScriptLanguage::add_register_func(const String &p_name, VisualScriptN register_funcs[p_name] = p_func; } +void VisualScriptLanguage::remove_register_func(const String &p_name) { + ERR_FAIL_COND(!register_funcs.has(p_name)); + register_funcs.erase(p_name); +} + Ref<VisualScriptNode> VisualScriptLanguage::create_node_from_name(const String &p_name) { ERR_FAIL_COND_V(!register_funcs.has(p_name), Ref<VisualScriptNode>()); diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 0f60b103c9..3e31876941 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -600,6 +600,7 @@ public: virtual int profiling_get_frame_data(ProfilingInfo *p_info_arr, int p_info_max); void add_register_func(const String &p_name, VisualScriptNodeRegisterFunc p_func); + void remove_register_func(const String &p_name); Ref<VisualScriptNode> create_node_from_name(const String &p_name); void get_registered_node_names(List<String> *r_names); diff --git a/modules/visual_script/visual_script_builtin_funcs.cpp b/modules/visual_script/visual_script_builtin_funcs.cpp index 7c9d306831..8f7fe58bee 100644 --- a/modules/visual_script/visual_script_builtin_funcs.cpp +++ b/modules/visual_script/visual_script_builtin_funcs.cpp @@ -1109,7 +1109,7 @@ void VisualScriptBuiltinFunc::exec_func(BuiltinFunc p_func, const Variant **p_in String str = *p_inputs[0]; //str+="\n"; - OS::get_singleton()->printerr("%s\n", str.utf8().get_data()); + print_error(str); } break; case VisualScriptBuiltinFunc::TEXT_PRINTRAW: { diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 03015df844..83b8d8da2d 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "visual_script_editor.h" +#include "core/script_language.h" #include "editor/editor_node.h" #include "editor/editor_resource_preview.h" #include "os/input.h" @@ -348,7 +349,7 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { case Variant::TRANSFORM2D: color = Color::html("#c4ec69"); break; case Variant::PLANE: color = Color::html("#f77070"); break; case Variant::QUAT: color = Color::html("#ec69a3"); break; - case Variant::RECT3: color = Color::html("#ee7991"); break; + case Variant::AABB: color = Color::html("#ee7991"); break; case Variant::BASIS: color = Color::html("#e3ec69"); break; case Variant::TRANSFORM: color = Color::html("#f6a86e"); break; @@ -385,7 +386,7 @@ static Color _color_from_type(Variant::Type p_type, bool dark_theme = true) { case Variant::TRANSFORM2D: color = Color::html("#96ce1a"); break; case Variant::PLANE: color = Color::html("#f77070"); break; case Variant::QUAT: color = Color::html("#ec69a3"); break; - case Variant::RECT3: color = Color::html("#ee7991"); break; + case Variant::AABB: color = Color::html("#ee7991"); break; case Variant::BASIS: color = Color::html("#b2bb19"); break; case Variant::TRANSFORM: color = Color::html("#f49047"); break; @@ -2764,6 +2765,23 @@ void VisualScriptEditor::_default_value_edited(Node *p_button, int p_id, int p_i default_value_edit->set_position(Object::cast_to<Control>(p_button)->get_global_position() + Vector2(0, Object::cast_to<Control>(p_button)->get_size().y)); default_value_edit->set_size(Size2(1, 1)); + + if (pinfo.type == Variant::NODE_PATH) { + + Node *edited_scene = get_tree()->get_edited_scene_root(); + Node *script_node = _find_script_node(edited_scene, edited_scene, script); + + if (script_node) { + //pick a node relative to the script, IF the script exists + pinfo.hint = PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE; + pinfo.hint_string = script_node->get_path(); + } else { + //pick a path relative to edited scene + pinfo.hint = PROPERTY_HINT_NODE_PATH_TO_EDITED_NODE; + pinfo.hint_string = get_tree()->get_edited_scene_root()->get_path(); + } + } + if (default_value_edit->edit(NULL, pinfo.name, pinfo.type, existing, pinfo.hint, pinfo.hint_string)) { if (pinfo.hint == PROPERTY_HINT_MULTILINE_TEXT) default_value_edit->popup_centered_ratio(); @@ -3241,6 +3259,8 @@ void VisualScriptEditor::_bind_methods() { ClassDB::bind_method("_member_rmb_selected", &VisualScriptEditor::_member_rmb_selected); ClassDB::bind_method("_member_option", &VisualScriptEditor::_member_option); + + ClassDB::bind_method("_update_available_nodes", &VisualScriptEditor::_update_available_nodes); } VisualScriptEditor::VisualScriptEditor() { @@ -3425,6 +3445,8 @@ VisualScriptEditor::VisualScriptEditor() { members->connect("item_rmb_selected", this, "_member_rmb_selected"); members->set_allow_rmb_select(true); member_popup->connect("id_pressed", this, "_member_option"); + + _VisualScriptEditor::get_singleton()->connect("custom_nodes_updated", this, "_update_available_nodes"); } VisualScriptEditor::~VisualScriptEditor() { @@ -3468,4 +3490,42 @@ void VisualScriptEditor::register_editor() { EditorNode::add_plugin_init_callback(register_editor_callback); } +Ref<VisualScriptNode> _VisualScriptEditor::create_node_custom(const String &p_name) { + + Ref<VisualScriptCustomNode> node; + node.instance(); + node->set_script(singleton->custom_nodes[p_name]); + return node; +} + +_VisualScriptEditor *_VisualScriptEditor::singleton = NULL; +Map<String, RefPtr> _VisualScriptEditor::custom_nodes; + +_VisualScriptEditor::_VisualScriptEditor() { + singleton = this; +} + +_VisualScriptEditor::~_VisualScriptEditor() { + custom_nodes.clear(); +} + +void _VisualScriptEditor::add_custom_node(const String &p_name, const String &p_category, const Ref<Script> &p_script) { + String node_name = "custom/" + p_category + "/" + p_name; + custom_nodes.insert(node_name, p_script.get_ref_ptr()); + VisualScriptLanguage::singleton->add_register_func(node_name, &_VisualScriptEditor::create_node_custom); + emit_signal("custom_nodes_updated"); +} + +void _VisualScriptEditor::remove_custom_node(const String &p_name, const String &p_category) { + String node_name = "custom/" + p_category + "/" + p_name; + custom_nodes.erase(node_name); + VisualScriptLanguage::singleton->remove_register_func(node_name); + emit_signal("custom_nodes_updated"); +} + +void _VisualScriptEditor::_bind_methods() { + ClassDB::bind_method(D_METHOD("add_custom_node", "name", "category", "script"), &_VisualScriptEditor::add_custom_node); + ClassDB::bind_method(D_METHOD("remove_custom_node", "name", "category"), &_VisualScriptEditor::remove_custom_node); + ADD_SIGNAL(MethodInfo("custom_nodes_updated")); +} #endif diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index db54d10300..3d037e82ea 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -278,6 +278,29 @@ public: VisualScriptEditor(); ~VisualScriptEditor(); }; + +// Singleton +class _VisualScriptEditor : public Object { + GDCLASS(_VisualScriptEditor, Object); + + friend class VisualScriptLanguage; + +protected: + static void _bind_methods(); + static _VisualScriptEditor *singleton; + + static Map<String, RefPtr> custom_nodes; + static Ref<VisualScriptNode> create_node_custom(const String &p_name); + +public: + static _VisualScriptEditor *get_singleton() { return singleton; } + + void add_custom_node(const String &p_name, const String &p_category, const Ref<Script> &p_script); + void remove_custom_node(const String &p_name, const String &p_category); + + _VisualScriptEditor(); + ~_VisualScriptEditor(); +}; #endif #endif // VISUALSCRIPT_EDITOR_H diff --git a/modules/visual_script/visual_script_expression.cpp b/modules/visual_script/visual_script_expression.cpp index 897e910f20..07dca4b904 100644 --- a/modules/visual_script/visual_script_expression.cpp +++ b/modules/visual_script/visual_script_expression.cpp @@ -564,6 +564,9 @@ Error VisualScriptExpression::_get_token(Token &r_token) { } else if (id == "PI") { r_token.type = TK_CONSTANT; r_token.value = Math_PI; + } else if (id == "TAU") { + r_token.type = TK_CONSTANT; + r_token.value = Math_TAU; } else if (id == "INF") { r_token.type = TK_CONSTANT; r_token.value = Math_INF; diff --git a/modules/visual_script/visual_script_func_nodes.cpp b/modules/visual_script/visual_script_func_nodes.cpp index 8d73de9889..cbe4438cdf 100644 --- a/modules/visual_script/visual_script_func_nodes.cpp +++ b/modules/visual_script/visual_script_func_nodes.cpp @@ -29,9 +29,9 @@ /*************************************************************************/ #include "visual_script_func_nodes.h" +#include "engine.h" #include "io/resource_loader.h" #include "os/os.h" -#include "project_settings.h" #include "scene/main/node.h" #include "scene/main/scene_tree.h" #include "visual_script_nodes.h" @@ -344,7 +344,7 @@ void VisualScriptFunctionCall::set_singleton(const StringName &p_type) { return; singleton = p_type; - Object *obj = ProjectSettings::get_singleton()->get_singleton_object(singleton); + Object *obj = Engine::get_singleton()->get_singleton_object(singleton); if (obj) { base_type = obj->get_class(); } @@ -380,7 +380,7 @@ void VisualScriptFunctionCall::_update_method_cache() { } else if (call_mode == CALL_MODE_SINGLETON) { - Object *obj = ProjectSettings::get_singleton()->get_singleton_object(singleton); + Object *obj = Engine::get_singleton()->get_singleton_object(singleton); if (obj) { type = obj->get_class(); script = obj->get_script(); @@ -565,11 +565,11 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const if (call_mode != CALL_MODE_SINGLETON) { property.usage = 0; } else { - List<ProjectSettings::Singleton> names; - ProjectSettings::get_singleton()->get_singletons(&names); + List<Engine::Singleton> names; + Engine::get_singleton()->get_singletons(&names); property.hint = PROPERTY_HINT_ENUM; String sl; - for (List<ProjectSettings::Singleton>::Element *E = names.front(); E; E = E->next()) { + for (List<Engine::Singleton>::Element *E = names.front(); E; E = E->next()) { if (sl != String()) sl += ","; sl += E->get().name; @@ -603,7 +603,7 @@ void VisualScriptFunctionCall::_validate_property(PropertyInfo &property) const property.hint_string = itos(get_visual_script()->get_instance_id()); } else if (call_mode == CALL_MODE_SINGLETON) { - Object *obj = ProjectSettings::get_singleton()->get_singleton_object(singleton); + Object *obj = Engine::get_singleton()->get_singleton_object(singleton); if (obj) { property.hint = PROPERTY_HINT_METHOD_OF_INSTANCE; property.hint_string = itos(obj->get_instance_id()); @@ -858,6 +858,8 @@ public: if (call_mode == VisualScriptFunctionCall::CALL_MODE_INSTANCE) { if (returns >= 2) { *p_outputs[1] = v.call(function, p_inputs + 1, input_args, r_error); + } else if (returns == 1) { + v.call(function, p_inputs + 1, input_args, r_error); } else { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Invalid returns count for call_mode == CALL_MODE_INSTANCE"; @@ -877,7 +879,7 @@ public: } break; case VisualScriptFunctionCall::CALL_MODE_SINGLETON: { - Object *object = ProjectSettings::get_singleton()->get_singleton_object(singleton); + Object *object = Engine::get_singleton()->get_singleton_object(singleton); if (!object) { r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD; r_error_str = "Invalid singleton name: '" + String(singleton) + "'"; diff --git a/modules/visual_script/visual_script_nodes.cpp b/modules/visual_script/visual_script_nodes.cpp index d3cd839cf3..05ff629d1b 100644 --- a/modules/visual_script/visual_script_nodes.cpp +++ b/modules/visual_script/visual_script_nodes.cpp @@ -29,6 +29,7 @@ /*************************************************************************/ #include "visual_script_nodes.h" +#include "engine.h" #include "global_constants.h" #include "os/input.h" #include "os/os.h" @@ -1776,8 +1777,8 @@ VisualScriptBasicTypeConstant::VisualScriptBasicTypeConstant() { const char *VisualScriptMathConstant::const_name[MATH_CONSTANT_MAX] = { "One", "PI", - "PIx2", "PI/2", + "TAU", "E", "Sqrt2", "INF", @@ -1787,8 +1788,8 @@ const char *VisualScriptMathConstant::const_name[MATH_CONSTANT_MAX] = { double VisualScriptMathConstant::const_value[MATH_CONSTANT_MAX] = { 1.0, Math_PI, - Math_PI * 2, Math_PI * 0.5, + Math_TAU, 2.71828182845904523536, Math::sqrt(2.0), Math_INF, @@ -1886,8 +1887,8 @@ void VisualScriptMathConstant::_bind_methods() { BIND_ENUM_CONSTANT(MATH_CONSTANT_ONE); BIND_ENUM_CONSTANT(MATH_CONSTANT_PI); - BIND_ENUM_CONSTANT(MATH_CONSTANT_2PI); BIND_ENUM_CONSTANT(MATH_CONSTANT_HALF_PI); + BIND_ENUM_CONSTANT(MATH_CONSTANT_TAU); BIND_ENUM_CONSTANT(MATH_CONSTANT_E); BIND_ENUM_CONSTANT(MATH_CONSTANT_SQRT2); BIND_ENUM_CONSTANT(MATH_CONSTANT_INF); @@ -1976,13 +1977,13 @@ public: VisualScriptNodeInstance *VisualScriptEngineSingleton::instance(VisualScriptInstance *p_instance) { VisualScriptNodeInstanceEngineSingleton *instance = memnew(VisualScriptNodeInstanceEngineSingleton); - instance->singleton = ProjectSettings::get_singleton()->get_singleton_object(singleton); + instance->singleton = Engine::get_singleton()->get_singleton_object(singleton); return instance; } VisualScriptEngineSingleton::TypeGuess VisualScriptEngineSingleton::guess_output_type(TypeGuess *p_inputs, int p_output) const { - Object *obj = ProjectSettings::get_singleton()->get_singleton_object(singleton); + Object *obj = Engine::get_singleton()->get_singleton_object(singleton); TypeGuess tg; tg.type = Variant::OBJECT; if (obj) { @@ -2000,11 +2001,11 @@ void VisualScriptEngineSingleton::_bind_methods() { String cc; - List<ProjectSettings::Singleton> singletons; + List<Engine::Singleton> singletons; - ProjectSettings::get_singleton()->get_singletons(&singletons); + Engine::get_singleton()->get_singletons(&singletons); - for (List<ProjectSettings::Singleton>::Element *E = singletons.front(); E; E = E->next()) { + for (List<Engine::Singleton>::Element *E = singletons.front(); E; E = E->next()) { if (E->get().name == "VS" || E->get().name == "PS" || E->get().name == "PS2D" || E->get().name == "AS" || E->get().name == "TS" || E->get().name == "SS" || E->get().name == "SS2D") continue; //skip these, too simple named diff --git a/modules/visual_script/visual_script_nodes.h b/modules/visual_script/visual_script_nodes.h index 421409b265..6648f57e7b 100644 --- a/modules/visual_script/visual_script_nodes.h +++ b/modules/visual_script/visual_script_nodes.h @@ -474,8 +474,8 @@ public: enum MathConstant { MATH_CONSTANT_ONE, MATH_CONSTANT_PI, - MATH_CONSTANT_2PI, MATH_CONSTANT_HALF_PI, + MATH_CONSTANT_TAU, MATH_CONSTANT_E, MATH_CONSTANT_SQRT2, MATH_CONSTANT_INF, diff --git a/modules/vorbis/SCsub b/modules/vorbis/SCsub index 9d2d0feb92..55a112585b 100644 --- a/modules/vorbis/SCsub +++ b/modules/vorbis/SCsub @@ -5,6 +5,8 @@ Import('env_modules') env_vorbis = env_modules.Clone() +stub = True + # Thirdparty source files if env['builtin_libvorbis']: thirdparty_dir = "#thirdparty/libvorbis/" @@ -45,5 +47,9 @@ if env['builtin_libvorbis']: if env['builtin_libogg']: env_vorbis.Append(CPPPATH=["#thirdparty/libogg"]) -# Godot source files -env_vorbis.add_source_files(env.modules_sources, "*.cpp") +if not stub: + # Module files + env_vorbis.add_source_files(env.modules_sources, "*.cpp") +else: + # Module files + env_vorbis.add_source_files(env.modules_sources, "stub/register_types.cpp") diff --git a/modules/vorbis/audio_stream_ogg_vorbis.cpp b/modules/vorbis/audio_stream_ogg_vorbis.cpp index 6235799fc2..9fb6fa8197 100644 --- a/modules/vorbis/audio_stream_ogg_vorbis.cpp +++ b/modules/vorbis/audio_stream_ogg_vorbis.cpp @@ -106,8 +106,6 @@ int AudioStreamPlaybackOGGVorbis::mix(int16_t *p_buffer, int p_frames) { break; } -//printf("to mix %i - mix me %i bytes\n",to_mix,to_mix*stream_channels*sizeof(int16_t)); - #ifdef BIG_ENDIAN_ENABLED long ret = ov_read(&vf, (char *)p_buffer, todo * stream_channels * sizeof(int16_t), 1, 2, 1, ¤t_section); #else @@ -359,7 +357,7 @@ void AudioStreamPlaybackOGGVorbis::set_paused(bool p_paused) { paused = p_paused; } -bool AudioStreamPlaybackOGGVorbis::is_paused(bool p_paused) const { +bool AudioStreamPlaybackOGGVorbis::is_paused() const { return paused; } diff --git a/modules/vorbis/audio_stream_ogg_vorbis.h b/modules/vorbis/audio_stream_ogg_vorbis.h index 79eadec56e..5000d03fd4 100644 --- a/modules/vorbis/audio_stream_ogg_vorbis.h +++ b/modules/vorbis/audio_stream_ogg_vorbis.h @@ -85,7 +85,7 @@ public: virtual void set_loop_restart_time(float p_time) { loop_restart_time = p_time; } virtual void set_paused(bool p_paused); - virtual bool is_paused(bool p_paused) const; + virtual bool is_paused() const; virtual void set_loop(bool p_enable); virtual bool has_loop() const; diff --git a/modules/vorbis/config.py b/modules/vorbis/config.py index ef5daca05c..5f133eba90 100644 --- a/modules/vorbis/config.py +++ b/modules/vorbis/config.py @@ -1,8 +1,5 @@ - def can_build(platform): -# return True - return False - + return True def configure(env): pass diff --git a/modules/vorbis/stub/register_types.cpp b/modules/vorbis/stub/register_types.cpp new file mode 100644 index 0000000000..b93d890436 --- /dev/null +++ b/modules/vorbis/stub/register_types.cpp @@ -0,0 +1,36 @@ +/*************************************************************************/ +/* register_types.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "register_types.h" + +// Dummy module as libvorbis is needed by other modules (theora ...) + +void register_vorbis_types() {} + +void unregister_vorbis_types() {} diff --git a/modules/vorbis/stub/register_types.h b/modules/vorbis/stub/register_types.h new file mode 100644 index 0000000000..e7cde7a66c --- /dev/null +++ b/modules/vorbis/stub/register_types.h @@ -0,0 +1,31 @@ +/*************************************************************************/ +/* register_types.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +void register_vorbis_types(); +void unregister_vorbis_types(); diff --git a/modules/webm/config.py b/modules/webm/config.py index ef5daca05c..0374bb36f7 100644 --- a/modules/webm/config.py +++ b/modules/webm/config.py @@ -1,8 +1,14 @@ - def can_build(platform): -# return True - return False - + return True def configure(env): pass + +def get_doc_classes(): + return [ + "ResourceImporterWebm", + "VideoStreamWebm", + ] + +def get_doc_path(): + return "doc_classes" diff --git a/modules/webm/doc_classes/ResourceImporterWebm.xml b/modules/webm/doc_classes/ResourceImporterWebm.xml new file mode 100644 index 0000000000..dcba351e37 --- /dev/null +++ b/modules/webm/doc_classes/ResourceImporterWebm.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ResourceImporterWebm" inherits="ResourceImporter" category="Core" version="3.0-alpha"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + </methods> + <constants> + </constants> +</class> diff --git a/modules/webm/doc_classes/VideoStreamWebm.xml b/modules/webm/doc_classes/VideoStreamWebm.xml new file mode 100644 index 0000000000..9a430f6b0d --- /dev/null +++ b/modules/webm/doc_classes/VideoStreamWebm.xml @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="VideoStreamWebm" inherits="VideoStream" category="Core" version="3.0-alpha"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + <method name="get_file"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="set_file"> + <return type="void"> + </return> + <argument index="0" name="file" type="String"> + </argument> + <description> + </description> + </method> + </methods> + <members> + <member name="file" type="String" setter="set_file" getter="get_file"> + </member> + </members> + <constants> + </constants> +</class> diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub index fd8d762a5e..73ba17d184 100644 --- a/modules/webm/libvpx/SCsub +++ b/modules/webm/libvpx/SCsub @@ -298,7 +298,7 @@ if webm_cpu_x86: if not yasm_found: webm_cpu_x86 = False - print "YASM is necessary for WebM SIMD optimizations." + print("YASM is necessary for WebM SIMD optimizations.") webm_simd_optimizations = False @@ -345,7 +345,7 @@ if webm_cpu_arm: webm_simd_optimizations = True if webm_simd_optimizations == False: - print "WebM SIMD optimizations are disabled. Check if your CPU architecture, CPU bits or platform are supported!" + print("WebM SIMD optimizations are disabled. Check if your CPU architecture, CPU bits or platform are supported!") env_libvpx.add_source_files(env.modules_sources, libvpx_sources) diff --git a/modules/webm/register_types.cpp b/modules/webm/register_types.cpp index 892d1b8420..669c9997f1 100644 --- a/modules/webm/register_types.cpp +++ b/modules/webm/register_types.cpp @@ -28,19 +28,18 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "register_types.h" - +#include "resource_importer_webm.h" #include "video_stream_webm.h" -static ResourceFormatLoaderVideoStreamWebm *webm_stream_loader = NULL; - void register_webm_types() { - webm_stream_loader = memnew(ResourceFormatLoaderVideoStreamWebm); - ResourceLoader::add_resource_format_loader(webm_stream_loader); +#ifdef TOOLS_ENABLED + Ref<ResourceImporterWebm> webm_import; + webm_import.instance(); + ResourceFormatImporter::get_singleton()->add_importer(webm_import); +#endif ClassDB::register_class<VideoStreamWebm>(); } void unregister_webm_types() { - - memdelete(webm_stream_loader); } diff --git a/modules/webm/resource_importer_webm.cpp b/modules/webm/resource_importer_webm.cpp new file mode 100644 index 0000000000..5db3d4df2e --- /dev/null +++ b/modules/webm/resource_importer_webm.cpp @@ -0,0 +1,95 @@ +/*************************************************************************/ +/* resource_importer_webm.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "resource_importer_webm.h" + +#include "io/resource_saver.h" +#include "os/file_access.h" +#include "scene/resources/texture.h" +#include "video_stream_webm.h" + +String ResourceImporterWebm::get_importer_name() const { + + return "Webm"; +} + +String ResourceImporterWebm::get_visible_name() const { + + return "Webm"; +} +void ResourceImporterWebm::get_recognized_extensions(List<String> *p_extensions) const { + + p_extensions->push_back("webm"); +} + +String ResourceImporterWebm::get_save_extension() const { + return "webmstr"; +} + +String ResourceImporterWebm::get_resource_type() const { + + return "VideoStreamWebm"; +} + +bool ResourceImporterWebm::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { + + return true; +} + +int ResourceImporterWebm::get_preset_count() const { + return 0; +} +String ResourceImporterWebm::get_preset_name(int p_idx) const { + + return String(); +} + +void ResourceImporterWebm::get_import_options(List<ImportOption> *r_options, int p_preset) const { + + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "loop"), true)); +} + +Error ResourceImporterWebm::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) { + + FileAccess *f = FileAccess::open(p_source_file, FileAccess::READ); + if (!f) { + ERR_FAIL_COND_V(!f, ERR_CANT_OPEN); + } + memdelete(f); + + VideoStreamWebm *stream = memnew(VideoStreamWebm); + stream->set_file(p_source_file); + + Ref<VideoStreamWebm> webm_stream = Ref<VideoStreamWebm>(stream); + + return ResourceSaver::save(p_save_path + ".webmstr", webm_stream); +} + +ResourceImporterWebm::ResourceImporterWebm() { +} diff --git a/modules/webm/resource_importer_webm.h b/modules/webm/resource_importer_webm.h new file mode 100644 index 0000000000..4cedd1598d --- /dev/null +++ b/modules/webm/resource_importer_webm.h @@ -0,0 +1,55 @@ +/*************************************************************************/ +/* resource_importer_webm.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef RESOURCEIMPORTERWEBM_H +#define RESOURCEIMPORTERWEBM_H + +#include "io/resource_import.h" + +class ResourceImporterWebm : public ResourceImporter { + GDCLASS(ResourceImporterWebm, ResourceImporter) +public: + virtual String get_importer_name() const; + virtual String get_visible_name() const; + virtual void get_recognized_extensions(List<String> *p_extensions) const; + virtual String get_save_extension() const; + virtual String get_resource_type() const; + + virtual int get_preset_count() const; + virtual String get_preset_name(int p_idx) const; + + virtual void get_import_options(List<ImportOption> *r_options, int p_preset = 0) const; + virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; + + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL); + + ResourceImporterWebm(); +}; + +#endif // RESOURCEIMPORTERWEBM_H diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 2ec6b27471..0fc9df5b58 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -35,10 +35,13 @@ #include "mkvparser/mkvparser.h" #include "os/file_access.h" +#include "os/os.h" #include "project_settings.h" #include "thirdparty/misc/yuv2rgb.h" +#include "servers/audio_server.h" + #include <string.h> class MkvReader : public mkvparser::IMkvReader { @@ -47,6 +50,8 @@ public: MkvReader(const String &p_file) { file = FileAccess::open(p_file, FileAccess::READ); + + ERR_EXPLAIN("Failed loading resource: '" + p_file + "';"); ERR_FAIL_COND(!file); } ~MkvReader() { @@ -113,14 +118,14 @@ bool VideoStreamPlaybackWebm::open_file(const String &p_file) { webm = memnew(WebMDemuxer(new MkvReader(file_name), 0, audio_track)); if (webm->isOpen()) { - video = memnew(VPXDecoder(*webm, 8)); //TODO: Detect CPU threads + video = memnew(VPXDecoder(*webm, OS::get_singleton()->get_processor_count())); if (video->isOpen()) { audio = memnew(OpusVorbisDecoder(*webm)); if (audio->isOpen()) { audio_frame = memnew(WebMFrame); - pcm = (int16_t *)memalloc(sizeof(int16_t) * audio->getBufferSamples() * webm->getChannels()); + pcm = (float *)memalloc(sizeof(float) * audio->getBufferSamples() * webm->getChannels()); } else { memdelete(audio); @@ -183,7 +188,7 @@ void VideoStreamPlaybackWebm::set_paused(bool p_paused) { paused = p_paused; } -bool VideoStreamPlaybackWebm::is_paused(bool p_paused) const { +bool VideoStreamPlaybackWebm::is_paused() const { return paused; } @@ -222,11 +227,18 @@ Ref<Texture> VideoStreamPlaybackWebm::get_texture() { return texture; } + void VideoStreamPlaybackWebm::update(float p_delta) { if ((!playing || paused) || !video) return; + time += p_delta; + + if (time < video_pos) { + return; + } + bool audio_buffer_full = false; if (samples_offset > -1) { @@ -245,13 +257,15 @@ void VideoStreamPlaybackWebm::update(float p_delta) { } const bool hasAudio = (audio && mix_callback); - while ((hasAudio && (!audio_buffer_full || !has_enough_video_frames())) || (!hasAudio && video_frames_pos == 0)) { + while ((hasAudio && !audio_buffer_full && !has_enough_video_frames()) || + (!hasAudio && video_frames_pos == 0)) { - if (hasAudio && !audio_buffer_full && audio_frame->isValid() && audio->getPCMS16(*audio_frame, pcm, num_decoded_samples) && num_decoded_samples > 0) { + if (hasAudio && !audio_buffer_full && audio_frame->isValid() && + audio->getPCMF(*audio_frame, pcm, num_decoded_samples) && num_decoded_samples > 0) { const int mixed = mix_callback(mix_udata, pcm, num_decoded_samples); - if (mixed != num_decoded_samples) { + if (mixed != num_decoded_samples) { samples_offset = mixed; audio_buffer_full = true; } @@ -273,72 +287,61 @@ void VideoStreamPlaybackWebm::update(float p_delta) { ++video_frames_pos; }; - const double video_delay = video->getFramesDelay() * video_frame_delay; - - bool want_this_frame = false; - while (video_frames_pos > 0 && !want_this_frame) { + bool video_frame_done = false; + while (video_frames_pos > 0 && !video_frame_done) { WebMFrame *video_frame = video_frames[0]; - if (video_frame->time <= time + video_delay) { - if (video->decode(*video_frame)) { + // It seems VPXDecoder::decode has to be executed even though we might skip this frame + if (video->decode(*video_frame)) { - VPXDecoder::IMAGE_ERROR err; - VPXDecoder::Image image; + VPXDecoder::IMAGE_ERROR err; + VPXDecoder::Image image; - while ((err = video->getImage(image)) != VPXDecoder::NO_FRAME) { + if (should_process(*video_frame)) { - want_this_frame = (time - video_frame->time <= video_frame_delay); + if ((err = video->getImage(image)) != VPXDecoder::NO_FRAME) { - if (want_this_frame) { + if (err == VPXDecoder::NO_ERROR && image.w == webm->getWidth() && image.h == webm->getHeight()) { - if (err == VPXDecoder::NO_ERROR && image.w == webm->getWidth() && image.h == webm->getHeight()) { + PoolVector<uint8_t>::Write w = frame_data.write(); + bool converted = false; - PoolVector<uint8_t>::Write w = frame_data.write(); - bool converted = false; + if (image.chromaShiftW == 1 && image.chromaShiftH == 1) { - if (image.chromaShiftW == 1 && image.chromaShiftH == 1) { + yuv420_2_rgb8888(w.ptr(), image.planes[0], image.planes[2], image.planes[1], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2, 0); + // libyuv::I420ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); + converted = true; + } else if (image.chromaShiftW == 1 && image.chromaShiftH == 0) { - yuv420_2_rgb8888(w.ptr(), image.planes[0], image.planes[2], image.planes[1], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2, 0); - // libyuv::I420ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); - converted = true; - } else if (image.chromaShiftW == 1 && image.chromaShiftH == 0) { + yuv422_2_rgb8888(w.ptr(), image.planes[0], image.planes[2], image.planes[1], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2, 0); + // libyuv::I422ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); + converted = true; + } else if (image.chromaShiftW == 0 && image.chromaShiftH == 0) { - yuv422_2_rgb8888(w.ptr(), image.planes[0], image.planes[2], image.planes[1], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2, 0); - // libyuv::I422ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); - converted = true; - } else if (image.chromaShiftW == 0 && image.chromaShiftH == 0) { + yuv444_2_rgb8888(w.ptr(), image.planes[0], image.planes[2], image.planes[1], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2, 0); + // libyuv::I444ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); + converted = true; + } else if (image.chromaShiftW == 2 && image.chromaShiftH == 0) { - yuv444_2_rgb8888(w.ptr(), image.planes[0], image.planes[2], image.planes[1], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2, 0); - // libyuv::I444ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); - converted = true; - } else if (image.chromaShiftW == 2 && image.chromaShiftH == 0) { - - // libyuv::I411ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); - // converted = true; - } - - if (converted) - texture->set_data(Image(image.w, image.h, 0, Image::FORMAT_RGBA8, frame_data)); //Zero copy send to visual server + // libyuv::I411ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h); + // converted = true; } - break; + if (converted) { + Ref<Image> img = memnew(Image(image.w, image.h, 0, Image::FORMAT_RGBA8, frame_data)); + texture->set_data(img); //Zero copy send to visual server + video_frame_done = true; + } } } } - - video_frame_delay = video_frame->time - video_pos; - video_pos = video_frame->time; - - memmove(video_frames, video_frames + 1, (--video_frames_pos) * sizeof(void *)); - video_frames[video_frames_pos] = video_frame; - } else { - - break; } - } - time += p_delta; + video_pos = video_frame->time; + memmove(video_frames, video_frames + 1, (--video_frames_pos) * sizeof(void *)); + video_frames[video_frames_pos] = video_frame; + } if (video_frames_pos == 0 && webm->isEOS()) stop(); @@ -372,6 +375,11 @@ inline bool VideoStreamPlaybackWebm::has_enough_video_frames() const { return false; } +bool VideoStreamPlaybackWebm::should_process(WebMFrame &video_frame) { + const double audio_delay = AudioServer::get_singleton()->get_output_delay(); + return video_frame.time >= time + audio_delay + delay_compensation; +} + void VideoStreamPlaybackWebm::delete_pointers() { if (pcm) @@ -395,34 +403,6 @@ void VideoStreamPlaybackWebm::delete_pointers() { /**/ -RES ResourceFormatLoaderVideoStreamWebm::load(const String &p_path, const String &p_original_path, Error *r_error) { - - Ref<VideoStreamWebm> stream = memnew(VideoStreamWebm); - stream->set_file(p_path); - if (r_error) - *r_error = OK; - return stream; -} - -void ResourceFormatLoaderVideoStreamWebm::get_recognized_extensions(List<String> *p_extensions) const { - - p_extensions->push_back("webm"); -} -bool ResourceFormatLoaderVideoStreamWebm::handles_type(const String &p_type) const { - - return (p_type == "VideoStream" || p_type == "VideoStreamWebm"); -} - -String ResourceFormatLoaderVideoStreamWebm::get_resource_type(const String &p_path) const { - - const String exl = p_path.get_extension().to_lower(); - if (exl == "webm") - return "VideoStreamWebm"; - return ""; -} - -/**/ - VideoStreamWebm::VideoStreamWebm() : audio_track(0) {} @@ -439,6 +419,19 @@ void VideoStreamWebm::set_file(const String &p_file) { file = p_file; } +String VideoStreamWebm::get_file() { + + return file; +} + +void VideoStreamWebm::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_file", "file"), &VideoStreamWebm::set_file); + ClassDB::bind_method(D_METHOD("get_file"), &VideoStreamWebm::get_file); + + ADD_PROPERTY(PropertyInfo(Variant::STRING, "file", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_file", "get_file"); +} + void VideoStreamWebm::set_audio_track(int p_track) { audio_track = p_track; diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h index fc0720967a..f7dd16a38f 100644 --- a/modules/webm/video_stream_webm.h +++ b/modules/webm/video_stream_webm.h @@ -60,7 +60,7 @@ class VideoStreamPlaybackWebm : public VideoStreamPlayback { PoolVector<uint8_t> frame_data; Ref<ImageTexture> texture; - int16_t *pcm; + float *pcm; public: VideoStreamPlaybackWebm(); @@ -74,7 +74,7 @@ public: virtual bool is_playing() const; virtual void set_paused(bool p_paused); - virtual bool is_paused(bool p_paused) const; + virtual bool is_paused() const; virtual void set_loop(bool p_enable); virtual bool has_loop() const; @@ -95,6 +95,7 @@ public: private: inline bool has_enough_video_frames() const; + bool should_process(WebMFrame &video_frame); void delete_pointers(); }; @@ -103,27 +104,21 @@ private: class VideoStreamWebm : public VideoStream { - GDCLASS(VideoStreamWebm, VideoStream) + GDCLASS(VideoStreamWebm, VideoStream); + RES_BASE_EXTENSION("webmstr"); String file; int audio_track; +protected: + static void _bind_methods(); + public: VideoStreamWebm(); virtual Ref<VideoStreamPlayback> instance_playback(); virtual void set_file(const String &p_file); + String get_file(); virtual void set_audio_track(int p_track); }; - -/**/ - -class ResourceFormatLoaderVideoStreamWebm : public ResourceFormatLoader { - -public: - virtual RES load(const String &p_path, const String &p_original_path, Error *r_error); - virtual void get_recognized_extensions(List<String> *p_extensions) const; - virtual bool handles_type(const String &p_type) const; - virtual String get_resource_type(const String &p_path) const; -}; diff --git a/modules/webp/config.py b/modules/webp/config.py index fb920482f5..5f133eba90 100644 --- a/modules/webp/config.py +++ b/modules/webp/config.py @@ -1,7 +1,5 @@ - def can_build(platform): return True - def configure(env): pass diff --git a/platform/SCsub b/platform/SCsub new file mode 100644 index 0000000000..4ef23ab053 --- /dev/null +++ b/platform/SCsub @@ -0,0 +1,30 @@ +#!/usr/bin/env python + +from compat import open_utf8 + +Import('env') +platform_sources = [] + +# Register platform-exclusive APIs +reg_apis_inc = '#include "register_platform_apis.h"\n' +reg_apis = 'void register_platform_apis() {\n' +unreg_apis = 'void unregister_platform_apis() {\n' +for platform in env.platform_apis: + platform_dir = env.Dir(platform) + platform_sources.append(platform_dir.File('api/api.cpp')) + reg_apis += '\tregister_' + platform + '_api();\n' + unreg_apis += '\tunregister_' + platform + '_api();\n' + reg_apis_inc += '#include "' + platform + '/api/api.h"\n' +reg_apis_inc += '\n' +reg_apis += '}\n\n' +unreg_apis += '}\n' +f = open_utf8('register_platform_apis.gen.cpp', 'w') +f.write(reg_apis_inc) +f.write(reg_apis) +f.write(unreg_apis) +f.close() +platform_sources.append('register_platform_apis.gen.cpp') + +env.Prepend(LIBS=env.Library('platform', platform_sources)) + +Export('env') diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template index 7cb6cf860a..11c49fbb50 100644 --- a/platform/android/build.gradle.template +++ b/platform/android/build.gradle.template @@ -31,7 +31,7 @@ android { disable 'MissingTranslation' } - compileSdkVersion 23 + compileSdkVersion 24 buildToolsVersion "26.0.1" useLibrary 'org.apache.http.legacy' diff --git a/platform/android/detect.py b/platform/android/detect.py index 4d5e586faf..bc67f6e6dc 100644 --- a/platform/android/detect.py +++ b/platform/android/detect.py @@ -2,6 +2,7 @@ import os import sys import string import platform +from distutils.version import LooseVersion def is_active(): @@ -25,8 +26,7 @@ def get_opts(): ('ndk_platform', 'Target platform (android-<api>, e.g. "android-18")', "android-18"), EnumVariable('android_arch', 'Target architecture', "armv7", ('armv7', 'armv6', 'arm64v8', 'x86')), BoolVariable('android_neon', 'Enable NEON support (armv7 only)', True), - BoolVariable('android_stl', 'Enable Android STL support (for modules)', False), - BoolVariable('ndk_unified_headers', 'Enable NDK unified headers', True) + BoolVariable('android_stl', 'Enable Android STL support (for modules)', True) ] @@ -173,36 +173,39 @@ def configure(env): # For Clang to find NDK tools in preference of those system-wide env.PrependENVPath('PATH', tools_path) - env['CC'] = compiler_path + '/clang' - env['CXX'] = compiler_path + '/clang++' + ccache_path = os.environ.get("CCACHE") + if ccache_path == None: + env['CC'] = compiler_path + '/clang' + env['CXX'] = compiler_path + '/clang++' + else: + # there aren't any ccache wrappers available for Android, + # to enable caching we need to prepend the path to the ccache binary + env['CC'] = ccache_path + ' ' + compiler_path + '/clang' + env['CXX'] = ccache_path + ' ' + compiler_path + '/clang++' env['AR'] = tools_path + "/ar" env['RANLIB'] = tools_path + "/ranlib" env['AS'] = tools_path + "/as" - ndk_unified_headers = env['ndk_unified_headers'] - ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"]) - common_opts = ['-fno-integrated-as', '-gcc-toolchain', gcc_toolchain_path] - if not ndk_unified_headers and ndk_version != None and ndk_version[0] >= 16: - ndk_unified_headers = True - print("Turning NDK unified headers on (starting from r16)") - lib_sysroot = env["ANDROID_NDK_ROOT"] + "/platforms/" + env['ndk_platform'] + "/" + env['ARCH'] ## Compile flags - if ndk_unified_headers: + ndk_version = get_ndk_version(env["ANDROID_NDK_ROOT"]) + if ndk_version != None and LooseVersion(ndk_version) >= LooseVersion("15.0.4075724"): + print("Using NDK unified headers") sysroot = env["ANDROID_NDK_ROOT"] + "/sysroot" env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include"]) env.Append(CPPFLAGS=["-isystem", sysroot + "/usr/include/" + abi_subpath]) # For unified headers this define has to be set manually env.Append(CPPFLAGS=["-D__ANDROID_API__=" + str(int(env['ndk_platform'].split("-")[1]))]) else: + print("Using NDK deprecated headers") env.Append(CPPFLAGS=["-isystem", lib_sysroot + "/usr/include"]) env.Append(CPPFLAGS='-fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fvisibility=hidden -fno-strict-aliasing'.split()) - env.Append(CPPFLAGS='-DNO_STATVFS -DGLES2_ENABLED'.split()) + env.Append(CPPFLAGS='-DNO_STATVFS -DGLES_ENABLED'.split()) env['neon_enabled'] = False if env['android_arch'] == 'x86': @@ -266,8 +269,8 @@ def configure(env): env.Append(CFLAGS=["-DOPUS_ARM_OPT"]) env.opus_fixed_point = "yes" -# Return NDK version as [<major>,<minor>,<build>] or None if cannot be figured out (adapted from the Chromium project). -def get_ndk_version (path): +# Return NDK version string in source.properties (adapted from the Chromium project). +def get_ndk_version(path): if path == None: return None prop_file_path = os.path.join(path, "source.properties") @@ -276,8 +279,7 @@ def get_ndk_version (path): for line in prop_file: key_value = map(lambda x: string.strip(x), line.split("=")) if key_value[0] == "Pkg.Revision": - version_parts = key_value[1].split("-")[0].split(".") - return map(int, version_parts[0:3]) + return key_value[1] except: print("Could not read source prop file '%s'" % prop_file_path) return None diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 79be1501a7..e1ff12c5ac 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -370,7 +370,7 @@ class EditorExportAndroid : public EditorExportPlatform { } if (aname == "") { - aname = _MKSTR(VERSION_NAME); + aname = VERSION_NAME; } return aname; @@ -945,16 +945,17 @@ public: public: virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features) { - int api = p_preset->get("graphics/api"); + // Reenable when a GLES 2.0 backend is readded + /*int api = p_preset->get("graphics/api"); if (api == 0) r_features->push_back("etc"); - else - r_features->push_back("etc2"); + else*/ + r_features->push_back("etc2"); } virtual void get_export_options(List<ExportOption> *r_options) { - r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "graphics/api", PROPERTY_HINT_ENUM, "OpenGL ES 2.0,OpenGL ES 3.0"), 1)); + /*r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "graphics/api", PROPERTY_HINT_ENUM, "OpenGL ES 2.0,OpenGL ES 3.0"), 1));*/ r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "graphics/32_bits_framebuffer"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "one_click_deploy/clear_previous_install"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_package/debug", PROPERTY_HINT_GLOBAL_FILE, "apk"), "")); @@ -1066,7 +1067,7 @@ public: if (use_reverse) p_debug_flags |= DEBUG_FLAG_REMOTE_DEBUG_LOCALHOST; - String export_to = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpexport.apk"; + String export_to = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport.apk"); Error err = export_project(p_preset, true, export_to, p_debug_flags); if (err) { device_lock->unlock(); @@ -1291,7 +1292,7 @@ public: zlib_filefunc_def io2 = io; FileAccess *dst_f = NULL; io2.opaque = &dst_f; - String unaligned_path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpexport-unaligned.apk"; + String unaligned_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpexport-unaligned.apk"); zipFile unaligned_apk = zipOpen2(unaligned_path.utf8().get_data(), APPEND_STATUS_CREATE, NULL, &io2); bool export_x86 = p_preset->get("architecture/x86"); diff --git a/platform/android/globals/global_defaults.cpp b/platform/android/globals/global_defaults.cpp index c73b578154..0e1c17e9c8 100644 --- a/platform/android/globals/global_defaults.cpp +++ b/platform/android/globals/global_defaults.cpp @@ -31,12 +31,4 @@ #include "project_settings.h" void register_android_global_defaults() { - - /* GLOBAL_DEF("rasterizer.Android/use_fragment_lighting",false); - GLOBAL_DEF("rasterizer.Android/fp16_framebuffer",false); - GLOBAL_DEF("display.Android/driver","GLES2"); - //GLOBAL_DEF("rasterizer.Android/trilinear_mipmap_filter",false); - - ProjectSettings::get_singleton()->set_custom_property_info("display.Android/driver",PropertyInfo(Variant::STRING,"display.Android/driver",PROPERTY_HINT_ENUM,"GLES2")); - */ } diff --git a/platform/android/godot_android.cpp b/platform/android/godot_android.cpp index 8235683496..f9bcbadc24 100644 --- a/platform/android/godot_android.cpp +++ b/platform/android/godot_android.cpp @@ -29,23 +29,23 @@ /*************************************************************************/ #ifdef ANDROID_NATIVE_ACTIVITY -#include <errno.h> -#include <jni.h> - -#include <EGL/egl.h> -#include <GLES2/gl2.h> - +#include "engine.h" #include "file_access_android.h" #include "main/main.h" #include "os_android.h" #include "project_settings.h" + +#include <EGL/egl.h> #include <android/log.h> #include <android/sensor.h> #include <android/window.h> #include <android_native_app_glue.h> +#include <errno.h> +#include <jni.h> #include <stdlib.h> #include <string.h> #include <unistd.h> + #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "godot", __VA_ARGS__)) #define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "godot", __VA_ARGS__)) @@ -669,6 +669,14 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) { ASensorEventQueue_setEventRate(engine->sensorEventQueue, engine->accelerometerSensor, (1000L / 60) * 1000); } + // start monitoring gravity + if (engine->gravitySensor != NULL) { + ASensorEventQueue_enableSensor(engine->sensorEventQueue, + engine->gravitySensor); + // We'd like to get 60 events per second (in us). + ASensorEventQueue_setEventRate(engine->sensorEventQueue, + engine->gravitySensor, (1000L / 60) * 1000); + } // Also start monitoring the magnetometer. if (engine->magnetometerSensor != NULL) { ASensorEventQueue_enableSensor(engine->sensorEventQueue, @@ -694,6 +702,10 @@ static void engine_handle_cmd(struct android_app *app, int32_t cmd) { ASensorEventQueue_disableSensor(engine->sensorEventQueue, engine->accelerometerSensor); } + if (engine->gravitySensor != NULL) { + ASensorEventQueue_disableSensor(engine->sensorEventQueue, + engine->gravitySensor); + } if (engine->magnetometerSensor != NULL) { ASensorEventQueue_disableSensor(engine->sensorEventQueue, engine->magnetometerSensor); @@ -729,6 +741,8 @@ void android_main(struct android_app *app) { engine.sensorManager = ASensorManager_getInstance(); engine.accelerometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager, ASENSOR_TYPE_ACCELEROMETER); + engine.gravitySensor = ASensorManager_getDefaultSensor(engine.sensorManager, + ASENSOR_TYPE_GRAVITY); engine.magnetometerSensor = ASensorManager_getDefaultSensor(engine.sensorManager, ASENSOR_TYPE_MAGNETIC_FIELD); engine.gyroscopeSensor = ASensorManager_getDefaultSensor(engine.sensorManager, @@ -828,7 +842,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_Godot_registerSingleton(JNIEnv s->set_instance(env->NewGlobalRef(p_object)); jni_singletons[singname] = s; - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton(singname, s)); + Engine::get_singleton()->add_singleton(Engine::Singleton(singname, s)); } static Variant::Type get_jni_type(const String &p_type) { diff --git a/platform/android/java/src/org/godotengine/godot/Godot.java b/platform/android/java/src/org/godotengine/godot/Godot.java index 59fefc498f..41dcba5c2c 100644 --- a/platform/android/java/src/org/godotengine/godot/Godot.java +++ b/platform/android/java/src/org/godotengine/godot/Godot.java @@ -219,6 +219,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC private SensorManager mSensorManager; private Sensor mAccelerometer; + private Sensor mGravity; private Sensor mMagnetometer; private Sensor mGyroscope; @@ -435,6 +436,8 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); + mGravity = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY); + mSensorManager.registerListener(this, mGravity, SensorManager.SENSOR_DELAY_GAME); mMagnetometer = mSensorManager.getDefaultSensor(Sensor.TYPE_MAGNETIC_FIELD); mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_GAME); mGyroscope = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE); @@ -667,6 +670,7 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC } }); mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); + mSensorManager.registerListener(this, mGravity, SensorManager.SENSOR_DELAY_GAME); mSensorManager.registerListener(this, mMagnetometer, SensorManager.SENSOR_DELAY_GAME); mSensorManager.registerListener(this, mGyroscope, SensorManager.SENSOR_DELAY_GAME); @@ -734,13 +738,16 @@ public class Godot extends Activity implements SensorEventListener, IDownloaderC @Override public void run() { if (typeOfSensor == Sensor.TYPE_ACCELEROMETER) { - GodotLib.accelerometer(x,y,z); + GodotLib.accelerometer(-x,y,-z); + } + if (typeOfSensor == Sensor.TYPE_GRAVITY) { + GodotLib.gravity(-x,y,-z); } if (typeOfSensor == Sensor.TYPE_MAGNETIC_FIELD) { - GodotLib.magnetometer(x,y,z); + GodotLib.magnetometer(-x,y,-z); } if (typeOfSensor == Sensor.TYPE_GYROSCOPE) { - GodotLib.gyroscope(x,y,z); + GodotLib.gyroscope(x,-y,z); } } }); diff --git a/platform/android/java/src/org/godotengine/godot/GodotLib.java b/platform/android/java/src/org/godotengine/godot/GodotLib.java index e0ed4cd38c..6b84ad6555 100644 --- a/platform/android/java/src/org/godotengine/godot/GodotLib.java +++ b/platform/android/java/src/org/godotengine/godot/GodotLib.java @@ -53,6 +53,7 @@ public class GodotLib { public static native void step(); public static native void touch(int what,int pointer,int howmany, int[] arr); public static native void accelerometer(float x, float y, float z); + public static native void gravity(float x, float y, float z); public static native void magnetometer(float x, float y, float z); public static native void gyroscope(float x, float y, float z); public static native void key(int p_scancode, int p_unicode_char, boolean p_pressed); diff --git a/platform/android/java_glue.cpp b/platform/android/java_glue.cpp index 0b193f5882..40dfe6d909 100644 --- a/platform/android/java_glue.cpp +++ b/platform/android/java_glue.cpp @@ -34,6 +34,7 @@ #include "audio_driver_jandroid.h" #include "core/os/keyboard.h" #include "dir_access_jandroid.h" +#include "engine.h" #include "file_access_android.h" #include "file_access_jandroid.h" #include "java_class_wrapper.h" @@ -608,6 +609,7 @@ static bool resized = false; static bool resized_reload = false; static Size2 new_size; static Vector3 accelerometer; +static Vector3 gravity; static Vector3 magnetometer; static Vector3 gyroscope; static HashMap<String, JNISingleton *> jni_singletons; @@ -645,7 +647,7 @@ static int _open_uri(const String &p_uri) { return env->CallIntMethod(godot_io, _openURI, jStr); } -static String _get_data_dir() { +static String _get_user_data_dir() { JNIEnv *env = ThreadAndroid::get_env(); jstring s = (jstring)env->CallObjectMethod(godot_io, _getDataDir); @@ -823,7 +825,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, _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 = new OS_Android(_gfx_init_func, env, _open_uri, _get_user_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]; @@ -952,7 +954,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_setup(JNIEnv *env, jo __android_log_print(ANDROID_LOG_INFO, "godot", "*****SETUP OK"); java_class_wrapper = memnew(JavaClassWrapper(_godot_instance)); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("JavaClassWrapper", java_class_wrapper)); + Engine::get_singleton()->add_singleton(Engine::Singleton("JavaClassWrapper", java_class_wrapper)); _initialize_java_modules(); } @@ -1012,6 +1014,8 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_step(JNIEnv *env, job os_android->process_accelerometer(accelerometer); + os_android->process_gravity(gravity); + os_android->process_magnetometer(magnetometer); os_android->process_gyroscope(gyroscope); @@ -1386,6 +1390,10 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv accelerometer = Vector3(x, y, z); } +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gravity(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z) { + gravity = Vector3(x, y, z); +} + JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnetometer(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z) { magnetometer = Vector3(x, y, z); } @@ -1419,7 +1427,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_singleton(JNIEnv *env s->set_instance(env->NewGlobalRef(p_object)); jni_singletons[singname] = s; - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton(singname, s)); + Engine::get_singleton()->add_singleton(Engine::Singleton(singname, s)); ProjectSettings::get_singleton()->set(singname, s); } diff --git a/platform/android/java_glue.h b/platform/android/java_glue.h index 0aa2489813..4790c65617 100644 --- a/platform/android/java_glue.h +++ b/platform/android/java_glue.h @@ -50,6 +50,7 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, j JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyconnectionchanged(JNIEnv *env, jobject obj, jint p_device, jboolean p_connected, jstring p_name); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_audio(JNIEnv *env, jobject obj); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_accelerometer(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z); +JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gravity(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_magnetometer(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_gyroscope(JNIEnv *env, jobject obj, jfloat x, jfloat y, jfloat z); JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_focusin(JNIEnv *env, jobject obj); diff --git a/platform/android/os_android.cpp b/platform/android/os_android.cpp index 9d43adf788..d5ccf76631 100644 --- a/platform/android/os_android.cpp +++ b/platform/android/os_android.cpp @@ -65,12 +65,6 @@ const char *OS_Android::get_video_driver_name(int p_driver) const { return "GLES2"; } - -OS::VideoMode OS_Android::get_default_video_mode() const { - - return OS::VideoMode(); -} - int OS_Android::get_audio_driver_count() const { return 1; @@ -496,6 +490,11 @@ void OS_Android::process_accelerometer(const Vector3 &p_accelerometer) { input->set_accelerometer(p_accelerometer); } +void OS_Android::process_gravity(const Vector3 &p_gravity) { + + input->set_gravity(p_gravity); +} + void OS_Android::process_magnetometer(const Vector3 &p_magnetometer) { input->set_magnetometer(p_magnetometer); @@ -613,13 +612,13 @@ void OS_Android::set_need_reload_hooks(bool p_needs_them) { use_reload_hooks = p_needs_them; } -String OS_Android::get_data_dir() const { +String OS_Android::get_user_data_dir() const { if (data_dir_cache != String()) return data_dir_cache; - if (get_data_dir_func) { - String data_dir = get_data_dir_func(); + if (get_user_data_dir_func) { + String data_dir = get_user_data_dir_func(); //store current dir char real_current_dir_name[2048]; @@ -642,7 +641,6 @@ String OS_Android::get_data_dir() const { } return "."; - //return ProjectSettings::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir"); } void OS_Android::set_screen_orientation(ScreenOrientation p_orientation) { @@ -710,7 +708,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, 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::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetUserDataDirFunc p_get_user_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; @@ -726,7 +724,7 @@ OS_Android::OS_Android(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURI use_gl2 = false; open_uri_func = p_open_uri_func; - get_data_dir_func = p_get_data_dir_func; + get_user_data_dir_func = p_get_user_data_dir_func; get_locale_func = p_get_locale_func; get_model_func = p_get_model_func; get_screen_dpi_func = p_get_screen_dpi_func; diff --git a/platform/android/os_android.h b/platform/android/os_android.h index d9a66b4e3a..d25f60d540 100644 --- a/platform/android/os_android.h +++ b/platform/android/os_android.h @@ -48,7 +48,7 @@ typedef void (*GFXInitFunc)(void *ud, bool gl2); typedef int (*OpenURIFunc)(const String &); -typedef String (*GetDataDirFunc)(); +typedef String (*GetUserDataDirFunc)(); typedef String (*GetLocaleFunc)(); typedef String (*GetModelFunc)(); typedef int (*GetScreenDPIFunc)(); @@ -116,7 +116,7 @@ private: MainLoop *main_loop; OpenURIFunc open_uri_func; - GetDataDirFunc get_data_dir_func; + GetUserDataDirFunc get_user_data_dir_func; GetLocaleFunc get_locale_func; GetModelFunc get_model_func; GetScreenDPIFunc get_screen_dpi_func; @@ -141,8 +141,6 @@ public: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; - virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; @@ -210,7 +208,7 @@ public: virtual void set_screen_orientation(ScreenOrientation p_orientation); virtual Error shell_open(String p_uri); - virtual String get_data_dir() const; + virtual String get_user_data_dir() const; virtual String get_resource_dir() const; virtual String get_locale() const; virtual String get_model_name() const; @@ -221,6 +219,7 @@ public: virtual String get_system_dir(SystemDir p_dir) const; void process_accelerometer(const Vector3 &p_accelerometer); + void process_gravity(const Vector3 &p_gravity); void process_magnetometer(const Vector3 &p_magnetometer); void process_gyroscope(const Vector3 &p_gyroscope); void process_touch(int p_what, int p_pointer, const Vector<TouchPos> &p_points); @@ -238,7 +237,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, 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(GFXInitFunc p_gfx_init_func, void *p_gfx_init_ud, OpenURIFunc p_open_uri_func, GetUserDataDirFunc p_get_user_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/haiku/detect.py b/platform/haiku/detect.py index 50f9783dd2..7c62654ef6 100644 --- a/platform/haiku/detect.py +++ b/platform/haiku/detect.py @@ -67,7 +67,7 @@ def configure(env): ## Flags env.Append(CPPPATH=['#platform/haiku']) - env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DOPENGL_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) + env.Append(CPPFLAGS=['-DUNIX_ENABLED', '-DOPENGL_ENABLED', '-DGLES_ENABLED', '-DGLES_OVER_GL']) env.Append(CPPFLAGS=['-DMEDIA_KIT_ENABLED']) # env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) env.Append(CPPFLAGS=['-DPTHREAD_NO_RENAME']) # TODO: enable when we have pthread_setname_np diff --git a/platform/haiku/os_haiku.cpp b/platform/haiku/os_haiku.cpp index 7a681d46f7..ef5a065107 100644 --- a/platform/haiku/os_haiku.cpp +++ b/platform/haiku/os_haiku.cpp @@ -76,11 +76,7 @@ int OS_Haiku::get_video_driver_count() const { } const char *OS_Haiku::get_video_driver_name(int p_driver) const { - return "GLES2"; -} - -OS::VideoMode OS_Haiku::get_default_video_mode() const { - return OS::VideoMode(800, 600, false); + return "GLES3"; } void OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { @@ -110,7 +106,9 @@ void OS_Haiku::initialize(const VideoMode &p_desired, int p_video_driver, int p_ context_gl->initialize(); context_gl->make_current(); - rasterizer = memnew(RasterizerGLES2); + /* Port to GLES 3 rasterizer */ + //rasterizer = memnew(RasterizerGLES2); + #endif visual_server = memnew(VisualServerRaster(rasterizer)); @@ -318,3 +316,36 @@ bool OS_Haiku::_check_internal_feature_support(const String &p_feature) { return p_feature == "pc" || p_feature == "s3tc"; } + +String OS_Haiku::get_config_path() const { + + if (has_environment("XDG_CONFIG_HOME")) { + return get_environment("XDG_CONFIG_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".config"); + } else { + return "."; + } +} + +String OS_Haiku::get_data_path() const { + + if (has_environment("XDG_DATA_HOME")) { + return get_environment("XDG_DATA_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".local/share"); + } else { + return get_config_path(); + } +} + +String OS_Haiku::get_cache_path() const { + + if (has_environment("XDG_CACHE_HOME")) { + return get_environment("XDG_CACHE_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".cache"); + } else { + return get_config_path(); + } +} diff --git a/platform/haiku/os_haiku.h b/platform/haiku/os_haiku.h index 501650c94f..4ee54fb48d 100644 --- a/platform/haiku/os_haiku.h +++ b/platform/haiku/os_haiku.h @@ -65,7 +65,6 @@ private: protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); virtual void finalize(); @@ -118,6 +117,10 @@ public: virtual int get_power_percent_left(); virtual bool _check_internal_feature_support(const String &p_feature); + + virtual String get_config_path() const; + virtual String get_data_path() const; + virtual String get_cache_path() const; }; #endif diff --git a/platform/iphone/detect.py b/platform/iphone/detect.py index 993a93ff89..4ea358f871 100644 --- a/platform/iphone/detect.py +++ b/platform/iphone/detect.py @@ -76,11 +76,22 @@ def configure(env): env['ENV']['PATH'] = env['IPHONEPATH'] + "/Developer/usr/bin/:" + env['ENV']['PATH'] - env['CC'] = '$IPHONEPATH/usr/bin/${ios_triple}clang' - env['CXX'] = '$IPHONEPATH/usr/bin/${ios_triple}clang++' - env['AR'] = '$IPHONEPATH/usr/bin/${ios_triple}ar' - env['RANLIB'] = '$IPHONEPATH/usr/bin/${ios_triple}ranlib' - env['S_compiler'] = '$IPHONEPATH/Developer/usr/bin/gcc' + compiler_path = '$IPHONEPATH/usr/bin/${ios_triple}' + s_compiler_path = '$IPHONEPATH/Developer/usr/bin/' + + ccache_path = os.environ.get("CCACHE") + if ccache_path == None: + env['CC'] = compiler_path + 'clang' + env['CXX'] = compiler_path + 'clang++' + env['S_compiler'] = s_compiler_path + 'gcc' + else: + # there aren't any ccache wrappers available for iOS, + # to enable caching we need to prepend the path to the ccache binary + env['CC'] = ccache_path + ' ' + compiler_path + 'clang' + env['CXX'] = ccache_path + ' ' + compiler_path + 'clang++' + env['S_compiler'] = ccache_path + ' ' + s_compiler_path + 'gcc' + env['AR'] = compiler_path + 'ar' + env['RANLIB'] = compiler_path + 'ranlib' ## Compile flags @@ -152,7 +163,7 @@ def configure(env): env['ENV']['CODESIGN_ALLOCATE'] = '/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate' env.Append(CPPPATH=['#platform/iphone']) - env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DMPC_FIXED_POINT', '-DCOREAUDIO_ENABLED']) + env.Append(CPPFLAGS=['-DIPHONE_ENABLED', '-DUNIX_ENABLED', '-DGLES_ENABLED', '-DMPC_FIXED_POINT', '-DCOREAUDIO_ENABLED']) # TODO: Move that to opus module's config if 'module_opus_enabled' in env and env['module_opus_enabled']: diff --git a/platform/iphone/globals/global_defaults.cpp b/platform/iphone/globals/global_defaults.cpp index 4bdc716d6e..b81e6def3b 100644 --- a/platform/iphone/globals/global_defaults.cpp +++ b/platform/iphone/globals/global_defaults.cpp @@ -31,11 +31,4 @@ #include "project_settings.h" void register_iphone_global_defaults() { - - /*GLOBAL_DEF("rasterizer.iOS/use_fragment_lighting",false); - GLOBAL_DEF("rasterizer.iOS/fp16_framebuffer",false); - GLOBAL_DEF("display.iOS/driver","GLES2"); - ProjectSettings::get_singleton()->set_custom_property_info("display.iOS/driver",PropertyInfo(Variant::STRING,"display.iOS/driver",PROPERTY_HINT_ENUM,"GLES1,GLES2")); - GLOBAL_DEF("display.iOS/use_cadisplaylink",true); - */ } diff --git a/platform/iphone/in_app_store.mm b/platform/iphone/in_app_store.mm index 9efd4b9891..25f4e1e166 100644 --- a/platform/iphone/in_app_store.mm +++ b/platform/iphone/in_app_store.mm @@ -92,6 +92,7 @@ void InAppStore::_bind_methods() { PoolRealArray prices; PoolStringArray ids; PoolStringArray localized_prices; + PoolStringArray currency_codes; for (int i = 0; i < [products count]; i++) { @@ -105,12 +106,14 @@ void InAppStore::_bind_methods() { prices.push_back([product.price doubleValue]); ids.push_back(String::utf8([product.productIdentifier UTF8String])); localized_prices.push_back(String::utf8([product.localizedPrice UTF8String])); + currency_codes.push_back(String::utf8([[[product priceLocale] objectForKey:NSLocaleCurrencyCode] UTF8String])); }; ret["titles"] = titles; ret["descriptions"] = descriptions; ret["prices"] = prices; ret["ids"] = ids; ret["localized_prices"] = localized_prices; + ret["currency_codes"] = currency_codes; PoolStringArray invalid_ids; diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index 13e3b7670a..95d7710c76 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -54,7 +54,7 @@ int OSIPhone::get_video_driver_count() const { const char *OSIPhone::get_video_driver_name(int p_driver) const { - return "GLES2"; + return "GLES3"; }; OSIPhone *OSIPhone::get_singleton() { @@ -62,11 +62,6 @@ OSIPhone *OSIPhone::get_singleton() { return (OSIPhone *)OS::get_singleton(); }; -OS::VideoMode OSIPhone::get_default_video_mode() const { - - return video_mode; -}; - uint8_t OSIPhone::get_orientations() const { return supported_orientations; @@ -143,28 +138,28 @@ void OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_ /* #ifdef IOS_SCORELOOP_ENABLED scoreloop = memnew(ScoreloopIOS); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Scoreloop", scoreloop)); + Engine::get_singleton()->add_singleton(Engine::Singleton("Scoreloop", scoreloop)); scoreloop->connect(); #endif */ #ifdef GAME_CENTER_ENABLED game_center = memnew(GameCenter); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("GameCenter", game_center)); + Engine::get_singleton()->add_singleton(Engine::Singleton("GameCenter", game_center)); game_center->connect(); #endif #ifdef STOREKIT_ENABLED store_kit = memnew(InAppStore); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("InAppStore", store_kit)); + Engine::get_singleton()->add_singleton(Engine::Singleton("InAppStore", store_kit)); #endif #ifdef ICLOUD_ENABLED icloud = memnew(ICloud); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ICloud", icloud)); + Engine::get_singleton()->add_singleton(Engine::Singleton("ICloud", icloud)); //icloud->connect(); #endif - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("iOS", memnew(iOS))); + Engine::get_singleton()->add_singleton(Engine::Singleton("iOS", memnew(iOS))); }; MainLoop *OSIPhone::get_main_loop() const { @@ -475,7 +470,7 @@ void OSIPhone::set_cursor_shape(CursorShape p_shape){ }; -String OSIPhone::get_data_dir() const { +String OSIPhone::get_user_data_dir() const { return data_dir; }; @@ -514,7 +509,7 @@ Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_ FileAccess *f = FileAccess::open(p_path, FileAccess::READ); bool exists = f && f->is_open(); - String tempFile = get_data_dir(); + String tempFile = get_user_data_dir(); if (!exists) return FAILED; @@ -526,7 +521,7 @@ Error OSIPhone::native_video_play(String p_path, float p_volume, String p_audio_ p_path = p_path.replace("res:/", ProjectSettings::get_singleton()->get_resource_path()); } } else if (p_path.begins_with("user://")) - p_path = p_path.replace("user:/", get_data_dir()); + p_path = p_path.replace("user:/", get_user_data_dir()); memdelete(f); diff --git a/platform/iphone/os_iphone.h b/platform/iphone/os_iphone.h index eccd294d63..433228b599 100644 --- a/platform/iphone/os_iphone.h +++ b/platform/iphone/os_iphone.h @@ -83,8 +83,6 @@ private: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; - virtual void initialize_logger(); virtual void initialize_core(); virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); @@ -180,7 +178,7 @@ public: Error shell_open(String p_uri); - String get_data_dir() const; + String get_user_data_dir() const; void set_locale(String p_locale); String get_locale() const; diff --git a/platform/iphone/platform_config.h b/platform/iphone/platform_config.h index 54de66082e..7ff6e7a9a9 100644 --- a/platform/iphone/platform_config.h +++ b/platform/iphone/platform_config.h @@ -28,7 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include <alloca.h> -// #define GLES2_INCLUDE_H <ES2/gl.h> + #define GLES3_INCLUDE_H <ES3/gl.h> #define PLATFORM_REFCOUNT diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub index cfc0741318..8d505a5829 100644 --- a/platform/javascript/SCsub +++ b/platform/javascript/SCsub @@ -7,6 +7,7 @@ javascript_files = [ "audio_driver_javascript.cpp", "javascript_main.cpp", "power_javascript.cpp", + "http_client_javascript.cpp", "javascript_eval.cpp", ] @@ -20,31 +21,21 @@ for x in javascript_files: env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_main_after_fs_sync','_send_notification']\""]) -# output file name without file extension -basename = "godot" + env["PROGSUFFIX"] target_dir = env.Dir("#bin") +build = env.Program(['#bin/godot', target_dir.File('godot' + env['PROGSUFFIX'] + '.wasm')], javascript_objects, PROGSUFFIX=env['PROGSUFFIX'] + '.js'); -zip_dir = target_dir.Dir('.javascript_zip') -zip_files = env.InstallAs(zip_dir.File('godot.html'), '#misc/dist/html/default.html') - -implicit_targets = [] -if env['wasm']: - wasm = target_dir.File(basename + '.wasm') - implicit_targets.append(wasm) - zip_files.append(InstallAs(zip_dir.File('godot.wasm'), wasm)) - prejs = env.File('pre_wasm.js') -else: - asmjs_files = [target_dir.File(basename + '.asm.js'), target_dir.File(basename + '.js.mem')] - implicit_targets.extend(asmjs_files) - zip_files.append(InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files)) - prejs = env.File('pre_asmjs.js') - -js = env.Program(['#bin/godot'] + implicit_targets, javascript_objects, PROGSUFFIX=env['PROGSUFFIX'] + '.js')[0]; -zip_files.append(InstallAs(zip_dir.File('godot.js'), js)) +js_libraries = [] +js_libraries.append(env.File('http_request.js')) +for lib in js_libraries: + env.Append(LINKFLAGS=['--js-library', lib.path]) +env.Depends(build, js_libraries) +prejs = env.File('pre.js') postjs = env.File('engine.js') -env.Depends(js, [prejs, postjs]) env.Append(LINKFLAGS=['--pre-js', prejs.path]) env.Append(LINKFLAGS=['--post-js', postjs.path]) +env.Depends(build, [prejs, postjs]) +zip_dir = target_dir.Dir('.javascript_zip') +zip_files = env.InstallAs([zip_dir.File('godot.js'), zip_dir.File('godot.wasm'), zip_dir.File('godot.html')], build + ['#misc/dist/html/default.html']) Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX'] + env['ZIPSUFFIX'], ZIPROOT=zip_dir, ZIPCOMSTR="Archving $SOURCES as $TARGET") diff --git a/platform/javascript/api/api.cpp b/platform/javascript/api/api.cpp new file mode 100644 index 0000000000..f2b2ca40bf --- /dev/null +++ b/platform/javascript/api/api.cpp @@ -0,0 +1,73 @@ +/*************************************************************************/ +/* api.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "api.h" +#include "engine.h" +#include "javascript_eval.h" + +static JavaScript *javascript_eval; + +void register_javascript_api() { + + ClassDB::register_virtual_class<JavaScript>(); + javascript_eval = memnew(JavaScript); + Engine::get_singleton()->add_singleton(Engine::Singleton("JavaScript", javascript_eval)); +} + +void unregister_javascript_api() { + + memdelete(javascript_eval); +} + +JavaScript *JavaScript::singleton = NULL; + +JavaScript *JavaScript::get_singleton() { + + return singleton; +} + +JavaScript::JavaScript() { + + ERR_FAIL_COND(singleton != NULL); + singleton = this; +} + +JavaScript::~JavaScript() {} + +void JavaScript::_bind_methods() { + + ClassDB::bind_method(D_METHOD("eval", "code", "use_global_execution_context"), &JavaScript::eval, DEFVAL(false)); +} + +#if !defined(JAVASCRIPT_ENABLED) || !defined(JAVASCRIPT_EVAL_ENABLED) +Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { + + return Variant(); +} +#endif diff --git a/platform/javascript/api/api.h b/platform/javascript/api/api.h new file mode 100644 index 0000000000..53cd9239fc --- /dev/null +++ b/platform/javascript/api/api.h @@ -0,0 +1,31 @@ +/*************************************************************************/ +/* api.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +void register_javascript_api(); +void unregister_javascript_api(); diff --git a/platform/javascript/javascript_eval.h b/platform/javascript/api/javascript_eval.h index ed7cf383da..4d0b0b21ff 100644 --- a/platform/javascript/javascript_eval.h +++ b/platform/javascript/api/javascript_eval.h @@ -27,8 +27,6 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifdef JAVASCRIPT_EVAL_ENABLED - #ifndef JAVASCRIPT_EVAL_H #define JAVASCRIPT_EVAL_H @@ -52,4 +50,3 @@ public: }; #endif // JAVASCRIPT_EVAL_H -#endif // JAVASCRIPT_EVAL_ENABLED diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py index a2988d9c60..8472c3ccab 100644 --- a/platform/javascript/detect.py +++ b/platform/javascript/detect.py @@ -19,7 +19,6 @@ def can_build(): def get_opts(): from SCons.Variables import BoolVariable return [ - BoolVariable('wasm', 'Compile to WebAssembly', False), BoolVariable('javascript_eval', 'Enable JavaScript eval interface', True), ] @@ -103,20 +102,13 @@ def configure(env): ## Link flags - env.Append(LINKFLAGS=['-s', 'EXTRA_EXPORTED_RUNTIME_METHODS="[\'FS\']"']) + env.Append(LINKFLAGS=['-s', 'BINARYEN=1']) + env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1']) env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1']) + env.Append(LINKFLAGS=['-s', 'EXTRA_EXPORTED_RUNTIME_METHODS="[\'FS\']"']) - if env['wasm']: - env.Append(LINKFLAGS=['-s', 'BINARYEN=1']) - # In contrast to asm.js, enabling memory growth on WebAssembly has no - # major performance impact, and causes only a negligible increase in - # memory size. - env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1']) - env.extra_suffix = '.webassembly' + env.extra_suffix - else: - env.Append(LINKFLAGS=['-s', 'ASM_JS=1']) - env.Append(LINKFLAGS=['--separate-asm']) - env.Append(LINKFLAGS=['--memory-init-file', '1']) + env.Append(LINKFLAGS=['-s', 'INVOKE_RUN=0']) + env.Append(LINKFLAGS=['-s', 'NO_EXIT_RUNTIME=1']) # TODO: Move that to opus module's config if 'module_opus_enabled' in env and env['module_opus_enabled']: diff --git a/platform/javascript/engine.js b/platform/javascript/engine.js index 99d1c20bbd..dc4bdc7efb 100644 --- a/platform/javascript/engine.js +++ b/platform/javascript/engine.js @@ -5,7 +5,6 @@ (function() { var engine = Engine; - var USING_WASM = engine.USING_WASM; var DOWNLOAD_ATTEMPTS_MAX = 4; var basePath = null; @@ -32,87 +31,101 @@ this.rtenv = null; - var gameInitPromise = null; + var initPromise = null; var unloadAfterInit = true; - var memorySize = 268435456; + var preloadedFiles = []; + + var resizeCanvasOnStart = true; var progressFunc = null; - var pckProgressTracker = {}; + var preloadProgressTracker = {}; var lastProgress = { loaded: 0, total: 0 }; var canvas = null; + var executableName = null; + var locale = null; var stdout = null; var stderr = null; - this.initGame = function(mainPack) { - - if (!gameInitPromise) { + this.init = function(newBasePath) { - if (mainPack === undefined) { - if (basePath !== null) { - mainPack = basePath + '.pck'; - } else { - return Promise.reject(new Error("No main pack to load specified")); - } - } - if (basePath === null) - basePath = getBasePath(mainPack); - - gameInitPromise = Engine.initEngine().then( + if (!initPromise) { + initPromise = Engine.load(newBasePath).then( instantiate.bind(this) ); - var gameLoadPromise = loadPromise(mainPack, pckProgressTracker).then(function(xhr) { return xhr.response; }); - gameInitPromise = Promise.all([gameLoadPromise, gameInitPromise]).then(function(values) { - // resolve with pck - return new Uint8Array(values[0]); - }); - if (unloadAfterInit) - gameInitPromise.then(Engine.unloadEngine); requestAnimationFrame(animateProgress); + if (unloadAfterInit) + initPromise.then(Engine.unloadEngine); } - return gameInitPromise; + return initPromise; }; - function instantiate(initializer) { + function instantiate(wasmBuf) { - var rtenvOpts = { - noInitialRun: true, - thisProgram: getBaseName(basePath), + var rtenvProps = { engine: this, + ENV: {}, }; if (typeof stdout === 'function') - rtenvOpts.print = stdout; + rtenvProps.print = stdout; if (typeof stderr === 'function') - rtenvOpts.printErr = stderr; - if (typeof WebAssembly === 'object' && initializer instanceof ArrayBuffer) { - rtenvOpts.instantiateWasm = function(imports, onSuccess) { - WebAssembly.instantiate(initializer, imports).then(function(result) { - onSuccess(result.instance); - }); - return {}; - }; - } else if (initializer.asm && initializer.mem) { - rtenvOpts.asm = initializer.asm; - rtenvOpts.memoryInitializerRequest = initializer.mem; - rtenvOpts.TOTAL_MEMORY = memorySize; - } else { - throw new Error("Invalid initializer"); - } + rtenvProps.printErr = stderr; + rtenvProps.instantiateWasm = function(imports, onSuccess) { + WebAssembly.instantiate(wasmBuf, imports).then(function(result) { + onSuccess(result.instance); + }); + return {}; + }; return new Promise(function(resolve, reject) { - rtenvOpts.onRuntimeInitialized = resolve; - rtenvOpts.onAbort = reject; - rtenvOpts.engine.rtenv = Engine.RuntimeEnvironment(rtenvOpts); + rtenvProps.onRuntimeInitialized = resolve; + rtenvProps.onAbort = reject; + rtenvProps.engine.rtenv = Engine.RuntimeEnvironment(rtenvProps); }); } - this.start = function(mainPack) { + this.preloadFile = function(pathOrBuffer, bufferFilename) { + + if (pathOrBuffer instanceof ArrayBuffer) { + pathOrBuffer = new Uint8Array(pathOrBuffer); + } else if (ArrayBuffer.isView(pathOrBuffer)) { + pathOrBuffer = new Uint8Array(pathOrBuffer.buffer); + } + if (pathOrBuffer instanceof Uint8Array) { + preloadedFiles.push({ + name: bufferFilename, + buffer: pathOrBuffer + }); + return Promise.resolve(); + } else if (typeof pathOrBuffer === 'string') { + return loadPromise(pathOrBuffer, preloadProgressTracker).then(function(xhr) { + preloadedFiles.push({ + name: pathOrBuffer, + buffer: xhr.response + }); + }); + } else { + throw Promise.reject("Invalid object for preloading"); + } + }; + + this.start = function() { + + return this.init().then( + Function.prototype.apply.bind(synchronousStart, this, arguments) + ); + }; + + this.startGame = function(mainPack) { - return this.initGame(mainPack).then(synchronousStart.bind(this)); + executableName = getBaseName(mainPack); + return Promise.all([this.init(getBasePath(mainPack)), this.preloadFile(mainPack)]).then( + Function.prototype.apply.bind(synchronousStart, this, []) + ); }; - function synchronousStart(pckView) { - // TODO don't expect canvas when runninng as cli tool + function synchronousStart() { + if (canvas instanceof HTMLCanvasElement) { this.rtenv.canvas = canvas; } else { @@ -147,15 +160,33 @@ ev.preventDefault(); }, false); - this.rtenv.FS.createDataFile('/', this.rtenv.thisProgram + '.pck', pckView, true, true, true); - gameInitPromise = null; - this.rtenv.callMain(); + if (locale) { + this.rtenv.locale = locale; + } else { + this.rtenv.locale = navigator.languages ? navigator.languages[0] : navigator.language; + } + this.rtenv.locale = this.rtenv.locale.split('.')[0]; + this.rtenv.resizeCanvasOnStart = resizeCanvasOnStart; + + this.rtenv.thisProgram = executableName || getBaseName(basePath); + + preloadedFiles.forEach(function(file) { + this.rtenv.FS.createDataFile('/', file.name, new Uint8Array(file.buffer), true, true, true); + }, this); + + preloadedFiles = null; + initPromise = null; + this.rtenv.callMain(arguments); } this.setProgressFunc = function(func) { progressFunc = func; }; + this.setResizeCanvasOnStart = function(enabled) { + resizeCanvasOnStart = enabled; + }; + function animateProgress() { var loaded = 0; @@ -163,7 +194,7 @@ var totalIsValid = true; var progressIsFinal = true; - [loadingFiles, pckProgressTracker].forEach(function(tracker) { + [loadingFiles, preloadProgressTracker].forEach(function(tracker) { Object.keys(tracker).forEach(function(file) { if (!tracker[file].final) progressIsFinal = false; @@ -190,14 +221,20 @@ canvas = elem; }; - this.setAsmjsMemorySize = function(size) { - memorySize = size; + this.setExecutableName = function(newName) { + + executableName = newName; + }; + + this.setLocale = function(newLocale) { + + locale = newLocale; }; this.setUnloadAfterInit = function(enabled) { - if (enabled && !unloadAfterInit && gameInitPromise) { - gameInitPromise.then(Engine.unloadEngine); + if (enabled && !unloadAfterInit && initPromise) { + initPromise.then(Engine.unloadEngine); } unloadAfterInit = enabled; }; @@ -232,26 +269,16 @@ Engine.RuntimeEnvironment = engine.RuntimeEnvironment; - Engine.initEngine = function(newBasePath) { + Engine.load = function(newBasePath) { if (newBasePath !== undefined) basePath = getBasePath(newBasePath); if (engineLoadPromise === null) { - if (USING_WASM) { - if (typeof WebAssembly !== 'object') - return Promise.reject(new Error("Browser doesn't support WebAssembly")); - // TODO cache/retrieve module to/from idb - engineLoadPromise = loadPromise(basePath + '.wasm').then(function(xhr) { - return xhr.response; - }); - } else { - var asmjsPromise = loadPromise(basePath + '.asm.js').then(function(xhr) { - return asmjsModulePromise(xhr.response); - }); - var memPromise = loadPromise(basePath + '.mem'); - engineLoadPromise = Promise.all([asmjsPromise, memPromise]).then(function(values) { - return { asm: values[0], mem: values[1] }; - }); - } + if (typeof WebAssembly !== 'object') + return Promise.reject(new Error("Browser doesn't support WebAssembly")); + // TODO cache/retrieve module to/from idb + engineLoadPromise = loadPromise(basePath + '.wasm').then(function(xhr) { + return xhr.response; + }); engineLoadPromise = engineLoadPromise.catch(function(err) { engineLoadPromise = null; throw err; @@ -260,34 +287,7 @@ return engineLoadPromise; }; - function asmjsModulePromise(module) { - var elem = document.createElement('script'); - var script = new Blob([ - 'Engine.asm = (function() { var Module = {};', - module, - 'return Module.asm; })();' - ]); - var url = URL.createObjectURL(script); - elem.src = url; - return new Promise(function(resolve, reject) { - elem.addEventListener('load', function() { - URL.revokeObjectURL(url); - var asm = Engine.asm; - Engine.asm = undefined; - setTimeout(function() { - // delay to reclaim compilation memory - resolve(asm); - }, 1); - }); - elem.addEventListener('error', function() { - URL.revokeObjectURL(url); - reject("asm.js faiilure"); - }); - document.body.appendChild(elem); - }); - } - - Engine.unloadEngine = function() { + Engine.unload = function() { engineLoadPromise = null; }; @@ -306,7 +306,7 @@ if (!file.endsWith('.js')) { xhr.responseType = 'arraybuffer'; } - ['loadstart', 'progress', 'load', 'error', 'timeout', 'abort'].forEach(function(ev) { + ['loadstart', 'progress', 'load', 'error', 'abort'].forEach(function(ev) { xhr.addEventListener(ev, onXHREvent.bind(xhr, resolve, reject, file, tracker)); }); xhr.send(); @@ -321,7 +321,7 @@ this.abort(); return; } else { - loadXHR(resolve, reject, file); + setTimeout(loadXHR.bind(null, resolve, reject, file, tracker), 1000); } } @@ -348,12 +348,11 @@ break; case 'error': - case 'timeout': if (++tracker[file].attempts >= DOWNLOAD_ATTEMPTS_MAX) { tracker[file].final = true; reject(new Error("Failed loading file '" + file + "'")); } else { - loadXHR(resolve, reject, file); + setTimeout(loadXHR.bind(null, resolve, reject, file, tracker), 1000); } break; diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp index 4a97bf4c32..943f6d8f35 100644 --- a/platform/javascript/export/export.cpp +++ b/platform/javascript/export/export.cpp @@ -30,13 +30,12 @@ #include "editor/editor_node.h" #include "editor_export.h" #include "io/zip_io.h" +#include "main/splash.gen.h" #include "platform/javascript/logo.gen.h" #include "platform/javascript/run_icon.gen.h" #define EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE "webassembly_release.zip" #define EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG "webassembly_debug.zip" -#define EXPORT_TEMPLATE_ASMJS_RELEASE "javascript_release.zip" -#define EXPORT_TEMPLATE_ASMJS_DEBUG "javascript_debug.zip" class EditorExportPlatformJavaScript : public EditorExportPlatform { @@ -47,18 +46,11 @@ class EditorExportPlatformJavaScript : public EditorExportPlatform { bool runnable_when_last_polled; void _fix_html(Vector<uint8_t> &p_html, const Ref<EditorExportPreset> &p_preset, const String &p_name, bool p_debug); - void _fix_fsloader_js(Vector<uint8_t> &p_js, const String &p_pack_name, uint64_t p_pack_size); public: - enum Target { - TARGET_WEBASSEMBLY, - TARGET_ASMJS - }; - virtual void get_preset_features(const Ref<EditorExportPreset> &p_preset, List<String> *r_features); virtual void get_export_options(List<ExportOption> *r_options); - virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; virtual String get_name() const; virtual String get_os_name() const; @@ -90,17 +82,9 @@ void EditorExportPlatformJavaScript::_fix_html(Vector<uint8_t> &p_html, const Re String str_export; Vector<String> lines = str_template.split("\n"); - int memory_mb; - if (p_preset->get("options/target").operator int() != TARGET_ASMJS) - // WebAssembly allows memory growth, so start with a reasonable default - memory_mb = 1 << 4; - else - memory_mb = 1 << (p_preset->get("options/memory_size").operator int() + 5); - for (int i = 0; i < lines.size(); i++) { String current_line = lines[i]; - current_line = current_line.replace("$GODOT_TOTAL_MEMORY", itos(memory_mb * 1024 * 1024)); current_line = current_line.replace("$GODOT_BASENAME", p_name); current_line = current_line.replace("$GODOT_HEAD_INCLUDE", p_preset->get("html/head_include")); current_line = current_line.replace("$GODOT_DEBUG_ENABLED", p_debug ? "true" : "false"); @@ -129,24 +113,15 @@ void EditorExportPlatformJavaScript::get_preset_features(const Ref<EditorExportP void EditorExportPlatformJavaScript::get_export_options(List<ExportOption> *r_options) { - r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "options/target", PROPERTY_HINT_ENUM, "WebAssembly,asm.js"), TARGET_WEBASSEMBLY)); - r_options->push_back(ExportOption(PropertyInfo(Variant::INT, "options/memory_size", PROPERTY_HINT_ENUM, "32 MB,64 MB,128 MB,256 MB,512 MB,1 GB"), 3)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/s3tc"), false)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "texture_format/etc2"), false)); + r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/custom_html_shell", PROPERTY_HINT_GLOBAL_FILE, "html"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "html/head_include", PROPERTY_HINT_MULTILINE_TEXT), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/release", PROPERTY_HINT_GLOBAL_FILE, "zip"), "")); r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "custom_template/debug", PROPERTY_HINT_GLOBAL_FILE, "zip"), "")); } -bool EditorExportPlatformJavaScript::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const { - - if (p_option == "options/memory_size") { - return p_options["options/target"].operator int() == TARGET_ASMJS; - } - return true; -} - String EditorExportPlatformJavaScript::get_name() const { return "HTML5"; @@ -166,17 +141,10 @@ bool EditorExportPlatformJavaScript::can_export(const Ref<EditorExportPreset> &p r_missing_templates = false; - if (p_preset->get("options/target").operator int() == TARGET_WEBASSEMBLY) { - if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE) == String()) - r_missing_templates = true; - else if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG) == String()) - r_missing_templates = true; - } else { - if (find_export_template(EXPORT_TEMPLATE_ASMJS_RELEASE) == String()) - r_missing_templates = true; - else if (find_export_template(EXPORT_TEMPLATE_ASMJS_DEBUG) == String()) - r_missing_templates = true; - } + if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE) == String()) + r_missing_templates = true; + else if (find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG) == String()) + r_missing_templates = true; return !r_missing_templates; } @@ -190,6 +158,7 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese String custom_debug = p_preset->get("custom_template/debug"); String custom_release = p_preset->get("custom_template/release"); + String custom_html = p_preset->get("html/custom_html_shell"); String template_path = p_debug ? custom_debug : custom_release; @@ -197,17 +166,10 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese if (template_path == String()) { - if (p_preset->get("options/target").operator int() == TARGET_WEBASSEMBLY) { - if (p_debug) - template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG); - else - template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE); - } else { - if (p_debug) - template_path = find_export_template(EXPORT_TEMPLATE_ASMJS_DEBUG); - else - template_path = find_export_template(EXPORT_TEMPLATE_ASMJS_RELEASE); - } + if (p_debug) + template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_DEBUG); + else + template_path = find_export_template(EXPORT_TEMPLATE_WEBASSEMBLY_RELEASE); } if (template_path != String() && !FileAccess::exists(template_path)) { @@ -222,14 +184,6 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese return error; } - FileAccess *f = FileAccess::open(pck_path, FileAccess::READ); - if (!f) { - EditorNode::get_singleton()->show_warning(TTR("Could not read file:\n") + pck_path); - return ERR_FILE_CANT_READ; - } - size_t pack_size = f->get_len(); - memdelete(f); - FileAccess *src_f = NULL; zlib_filefunc_def io = zipio_create_io_from_file(&src_f); unzFile pkg = unzOpen2(template_path.utf8().get_data(), &io); @@ -240,13 +194,17 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese return ERR_FILE_NOT_FOUND; } - int ret = unzGoToFirstFile(pkg); - while (ret == UNZ_OK) { + if (unzGoToFirstFile(pkg) != UNZ_OK) { + EditorNode::get_singleton()->show_warning(TTR("Invalid export template:\n") + template_path); + unzClose(pkg); + return ERR_FILE_CORRUPT; + } + do { //get filename unz_file_info info; char fname[16384]; - ret = unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); + unzGetCurrentFileInfo(pkg, &info, fname, 16384, NULL, 0, NULL, 0); String file = fname; @@ -262,20 +220,18 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese if (file == "godot.html") { + if (!custom_html.empty()) { + continue; + } _fix_html(data, p_preset, p_path.get_file().get_basename(), p_debug); file = p_path.get_file(); + } else if (file == "godot.js") { file = p_path.get_file().get_basename() + ".js"; } else if (file == "godot.wasm") { file = p_path.get_file().get_basename() + ".wasm"; - } else if (file == "godot.asm.js") { - - file = p_path.get_file().get_basename() + ".asm.js"; - } else if (file == "godot.mem") { - - file = p_path.get_file().get_basename() + ".mem"; } String dst = p_path.get_base_dir().plus_file(file); @@ -288,9 +244,50 @@ Error EditorExportPlatformJavaScript::export_project(const Ref<EditorExportPrese f->store_buffer(data.ptr(), data.size()); memdelete(f); - ret = unzGoToNextFile(pkg); + } while (unzGoToNextFile(pkg) == UNZ_OK); + unzClose(pkg); + + if (!custom_html.empty()) { + + FileAccess *f = FileAccess::open(custom_html, FileAccess::READ); + if (!f) { + EditorNode::get_singleton()->show_warning(TTR("Could not read custom HTML shell:\n") + custom_html); + return ERR_FILE_CANT_READ; + } + Vector<uint8_t> buf; + buf.resize(f->get_len()); + f->get_buffer(buf.ptr(), buf.size()); + memdelete(f); + _fix_html(buf, p_preset, p_path.get_file().get_basename(), p_debug); + + f = FileAccess::open(p_path, FileAccess::WRITE); + if (!f) { + EditorNode::get_singleton()->show_warning(TTR("Could not write file:\n") + p_path); + return ERR_FILE_CANT_WRITE; + } + f->store_buffer(buf.ptr(), buf.size()); + memdelete(f); } + Ref<Image> splash; + String splash_path = GLOBAL_GET("application/boot_splash/image"); + splash_path = splash_path.strip_edges(); + if (!splash_path.empty()) { + splash.instance(); + Error err = splash->load(splash_path); + if (err) { + EditorNode::get_singleton()->show_warning(TTR("Could not read boot splash image file:\n") + splash_path + "\nUsing default boot splash image"); + splash.unref(); + } + } + if (splash.is_null()) { + splash = Ref<Image>(memnew(Image(boot_splash_png))); + } + String png_path = p_path.get_base_dir().plus_file(p_path.get_file().get_basename() + ".png"); + if (splash->save_png(png_path) != OK) { + EditorNode::get_singleton()->show_warning(TTR("Could not write file:\n") + png_path); + return ERR_FILE_CANT_WRITE; + } return OK; } @@ -319,7 +316,7 @@ int EditorExportPlatformJavaScript::get_device_count() const { Error EditorExportPlatformJavaScript::run(const Ref<EditorExportPreset> &p_preset, int p_device, int p_debug_flags) { - String path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmp_export.html"; + String path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp_export.html"); Error err = export_project(p_preset, true, path, p_debug_flags); if (err) { return err; diff --git a/platform/javascript/http_client.h.inc b/platform/javascript/http_client.h.inc new file mode 100644 index 0000000000..9e4edf7848 --- /dev/null +++ b/platform/javascript/http_client.h.inc @@ -0,0 +1,48 @@ +/*************************************************************************/ +/* http_client.h.inc */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +// HTTPClient's additional private members in the javascript platform + +Error prepare_request(Method p_method, const String &p_url, const Vector<String> &p_headers); + +int xhr_id; +int read_limit; +int response_read_offset; +Status status; + +String host; +int port; +bool use_tls; +String username; +String password; + +int polled_response_code; +String polled_response_header; +PoolByteArray polled_response; diff --git a/platform/javascript/http_client_javascript.cpp b/platform/javascript/http_client_javascript.cpp new file mode 100644 index 0000000000..0b105dcb40 --- /dev/null +++ b/platform/javascript/http_client_javascript.cpp @@ -0,0 +1,282 @@ +/*************************************************************************/ +/* http_client_javascript.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#include "http_request.h" +#include "io/http_client.h" + +Error HTTPClient::connect_to_host(const String &p_host, int p_port, bool p_ssl, bool p_verify_host) { + + close(); + if (p_ssl && !p_verify_host) { + WARN_PRINT("Disabling HTTPClient's host verification is not supported for the HTML5 platform, host will be verified"); + } + + host = p_host; + if (host.begins_with("http://")) { + host.replace_first("http://", ""); + } else if (host.begins_with("https://")) { + host.replace_first("https://", ""); + } + + status = host.is_valid_ip_address() ? STATUS_CONNECTING : STATUS_RESOLVING; + port = p_port; + use_tls = p_ssl; + return OK; +} + +void HTTPClient::set_connection(const Ref<StreamPeer> &p_connection) { + + ERR_EXPLAIN("Accessing an HTTPClient's StreamPeer is not supported for the HTML5 platform"); + ERR_FAIL(); +} + +Ref<StreamPeer> HTTPClient::get_connection() const { + + ERR_EXPLAIN("Accessing an HTTPClient's StreamPeer is not supported for the HTML5 platform"); + ERR_FAIL_V(REF()); +} + +Error HTTPClient::prepare_request(Method p_method, const String &p_url, const Vector<String> &p_headers) { + + ERR_FAIL_INDEX_V(p_method, METHOD_MAX, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(status != STATUS_CONNECTED, ERR_INVALID_PARAMETER); + ERR_FAIL_COND_V(host.empty(), ERR_UNCONFIGURED); + ERR_FAIL_COND_V(port < 0, ERR_UNCONFIGURED); + + static const char *_methods[HTTPClient::METHOD_MAX] = { + "GET", + "HEAD", + "POST", + "PUT", + "DELETE", + "OPTIONS", + "TRACE", + "CONNECT" + }; + + String url = (use_tls ? "https://" : "http://") + host + ":" + itos(port) + "/" + p_url; + godot_xhr_reset(xhr_id); + godot_xhr_open(xhr_id, _methods[p_method], url.utf8().get_data(), + username.empty() ? NULL : username.utf8().get_data(), + password.empty() ? NULL : password.utf8().get_data()); + + for (int i = 0; i < p_headers.size(); i++) { + int header_separator = p_headers[i].find(": "); + ERR_FAIL_COND_V(header_separator < 0, ERR_INVALID_PARAMETER); + godot_xhr_set_request_header(xhr_id, + p_headers[i].left(header_separator).utf8().get_data(), + p_headers[i].right(header_separator + 2).utf8().get_data()); + } + response_read_offset = 0; + status = STATUS_REQUESTING; + return OK; +} + +Error HTTPClient::request_raw(Method p_method, const String &p_url, const Vector<String> &p_headers, const PoolVector<uint8_t> &p_body) { + + Error err = prepare_request(p_method, p_url, p_headers); + if (err != OK) + return err; + PoolByteArray::Read read = p_body.read(); + godot_xhr_send_data(xhr_id, read.ptr(), p_body.size()); + return OK; +} + +Error HTTPClient::request(Method p_method, const String &p_url, const Vector<String> &p_headers, const String &p_body) { + + Error err = prepare_request(p_method, p_url, p_headers); + if (err != OK) + return err; + godot_xhr_send_string(xhr_id, p_body.utf8().get_data()); + return OK; +} + +void HTTPClient::close() { + + host = ""; + port = -1; + use_tls = false; + status = STATUS_DISCONNECTED; + polled_response.resize(0); + polled_response_code = 0; + polled_response_header = String(); + godot_xhr_reset(xhr_id); +} + +HTTPClient::Status HTTPClient::get_status() const { + + return status; +} + +bool HTTPClient::has_response() const { + + return !polled_response_header.empty(); +} + +bool HTTPClient::is_response_chunked() const { + + // TODO evaluate using moz-chunked-arraybuffer, fetch & ReadableStream + return false; +} + +int HTTPClient::get_response_code() const { + + return polled_response_code; +} + +Error HTTPClient::get_response_headers(List<String> *r_response) { + + if (!polled_response_header.size()) + return ERR_INVALID_PARAMETER; + + Vector<String> header_lines = polled_response_header.split("\r\n", false); + for (int i = 0; i < header_lines.size(); ++i) { + r_response->push_back(header_lines[i]); + } + polled_response_header = String(); + return OK; +} + +int HTTPClient::get_response_body_length() const { + + return polled_response.size(); +} + +PoolByteArray HTTPClient::read_response_body_chunk() { + + ERR_FAIL_COND_V(status != STATUS_BODY, PoolByteArray()); + + int to_read = MIN(read_limit, polled_response.size() - response_read_offset); + PoolByteArray chunk; + chunk.resize(to_read); + PoolByteArray::Write write = chunk.write(); + PoolByteArray::Read read = polled_response.read(); + memcpy(write.ptr(), read.ptr() + response_read_offset, to_read); + write = PoolByteArray::Write(); + read = PoolByteArray::Read(); + response_read_offset += to_read; + + if (response_read_offset == polled_response.size()) { + status = STATUS_CONNECTED; + polled_response.resize(0); + polled_response_code = 0; + polled_response_header = String(); + godot_xhr_reset(xhr_id); + } + + return chunk; +} + +void HTTPClient::set_blocking_mode(bool p_enable) { + + ERR_EXPLAIN("HTTPClient blocking mode is not supported for the HTML5 platform"); + ERR_FAIL_COND(p_enable); +} + +bool HTTPClient::is_blocking_mode_enabled() const { + + return false; +} + +void HTTPClient::set_read_chunk_size(int p_size) { + + read_limit = p_size; +} + +Error HTTPClient::poll() { + + switch (status) { + + case STATUS_DISCONNECTED: + return ERR_UNCONFIGURED; + + case STATUS_RESOLVING: + status = STATUS_CONNECTING; + return OK; + + case STATUS_CONNECTING: + status = STATUS_CONNECTED; + return OK; + + case STATUS_CONNECTED: + case STATUS_BODY: + return OK; + + case STATUS_CONNECTION_ERROR: + return ERR_CONNECTION_ERROR; + + case STATUS_REQUESTING: + polled_response_code = godot_xhr_get_status(xhr_id); + int response_length = godot_xhr_get_response_length(xhr_id); + if (response_length == 0) { + godot_xhr_ready_state_t ready_state = godot_xhr_get_ready_state(xhr_id); + if (ready_state == XHR_READY_STATE_HEADERS_RECEIVED || ready_state == XHR_READY_STATE_LOADING) { + return OK; + } else { + status = STATUS_CONNECTION_ERROR; + return ERR_CONNECTION_ERROR; + } + } + + status = STATUS_BODY; + + PoolByteArray bytes; + int len = godot_xhr_get_response_headers_length(xhr_id); + bytes.resize(len); + PoolByteArray::Write write = bytes.write(); + godot_xhr_get_response_headers(xhr_id, reinterpret_cast<char *>(write.ptr()), len); + write = PoolByteArray::Write(); + + PoolByteArray::Read read = bytes.read(); + polled_response_header = String::utf8(reinterpret_cast<const char *>(read.ptr())); + read = PoolByteArray::Read(); + + polled_response.resize(response_length); + write = polled_response.write(); + godot_xhr_get_response(xhr_id, write.ptr(), response_length); + write = PoolByteArray::Write(); + break; + } + return OK; +} + +HTTPClient::HTTPClient() { + + xhr_id = godot_xhr_new(); + read_limit = 4096; + status = STATUS_DISCONNECTED; + port = -1; + use_tls = false; + polled_response_code = 0; +} + +HTTPClient::~HTTPClient() { + + godot_xhr_free(xhr_id); +} diff --git a/platform/javascript/http_request.h b/platform/javascript/http_request.h new file mode 100644 index 0000000000..06d9239004 --- /dev/null +++ b/platform/javascript/http_request.h @@ -0,0 +1,74 @@ +/*************************************************************************/ +/* http_request.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef HTTP_REQUEST_H +#define HTTP_REQUEST_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "stddef.h" + +typedef enum { + XHR_READY_STATE_UNSENT = 0, + XHR_READY_STATE_OPENED = 1, + XHR_READY_STATE_HEADERS_RECEIVED = 2, + XHR_READY_STATE_LOADING = 3, + XHR_READY_STATE_DONE = 4, +} godot_xhr_ready_state_t; + +extern int godot_xhr_new(); +extern void godot_xhr_reset(int p_xhr_id); +extern bool godot_xhr_free(int p_xhr_id); + +extern int godot_xhr_open(int p_xhr_id, const char *p_method, const char *p_url, const char *p_user = NULL, const char *p_password = NULL); + +extern void godot_xhr_set_request_header(int p_xhr_id, const char *p_header, const char *p_value); + +extern void godot_xhr_send_null(int p_xhr_id); +extern void godot_xhr_send_string(int p_xhr_id, const char *p_data); +extern void godot_xhr_send_data(int p_xhr_id, const void *p_data, int p_len); +extern void godot_xhr_abort(int p_xhr_id); + +/* this is an HTTPClient::ResponseCode, not ::Status */ +extern int godot_xhr_get_status(int p_xhr_id); +extern godot_xhr_ready_state_t godot_xhr_get_ready_state(int p_xhr_id); + +extern int godot_xhr_get_response_headers_length(int p_xhr_id); +extern void godot_xhr_get_response_headers(int p_xhr_id, char *r_dst, int p_len); + +extern int godot_xhr_get_response_length(int p_xhr_id); +extern void godot_xhr_get_response(int p_xhr_id, void *r_dst, int p_len); + +#ifdef __cplusplus +} +#endif + +#endif /* HTTP_REQUEST_H */ diff --git a/platform/javascript/http_request.js b/platform/javascript/http_request.js new file mode 100644 index 0000000000..f30240b41b --- /dev/null +++ b/platform/javascript/http_request.js @@ -0,0 +1,145 @@ +/*************************************************************************/ +/* http_request.js */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* http://www.godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +var GodotHTTPRequest = { + + $GodotHTTPRequest: { + + requests: [], + + getUnusedRequestId: function() { + var idMax = GodotHTTPRequest.requests.length; + for (var potentialId = 0; potentialId < idMax; ++potentialId) { + if (GodotHTTPRequest.requests[potentialId] instanceof XMLHttpRequest) { + continue; + } + return potentialId; + } + GodotHTTPRequest.requests.push(null) + return idMax; + }, + + setupRequest: function(xhr) { + xhr.responseType = 'arraybuffer'; + }, + }, + + godot_xhr_new: function() { + var newId = GodotHTTPRequest.getUnusedRequestId(); + GodotHTTPRequest.requests[newId] = new XMLHttpRequest; + GodotHTTPRequest.setupRequest(GodotHTTPRequest.requests[newId]); + return newId; + }, + + godot_xhr_reset: function(xhrId) { + GodotHTTPRequest.requests[xhrId] = new XMLHttpRequest; + GodotHTTPRequest.setupRequest(GodotHTTPRequest.requests[xhrId]); + }, + + godot_xhr_free: function(xhrId) { + GodotHTTPRequest.requests[xhrId].abort(); + GodotHTTPRequest.requests[xhrId] = null; + }, + + godot_xhr_open: function(xhrId, method, url, user, password) { + user = user > 0 ? UTF8ToString(user) : null; + password = password > 0 ? UTF8ToString(password) : null; + GodotHTTPRequest.requests[xhrId].open(UTF8ToString(method), UTF8ToString(url), true, user, password); + }, + + godot_xhr_set_request_header: function(xhrId, header, value) { + GodotHTTPRequest.requests[xhrId].setRequestHeader(UTF8ToString(header), UTF8ToString(value)); + }, + + godot_xhr_send_null: function(xhrId) { + GodotHTTPRequest.requests[xhrId].send(); + }, + + godot_xhr_send_string: function(xhrId, strPtr) { + if (!strPtr) { + Module.printErr("Failed to send string per XHR: null pointer"); + return; + } + GodotHTTPRequest.requests[xhrId].send(UTF8ToString(strPtr)); + }, + + godot_xhr_send_data: function(xhrId, ptr, len) { + if (!ptr) { + Module.printErr("Failed to send data per XHR: null pointer"); + return; + } + if (len < 0) { + Module.printErr("Failed to send data per XHR: buffer length less than 0"); + return; + } + GodotHTTPRequest.requests[xhrId].send(HEAPU8.subarray(ptr, ptr + len)); + }, + + godot_xhr_abort: function(xhrId) { + GodotHTTPRequest.requests[xhrId].abort(); + }, + + godot_xhr_get_status: function(xhrId) { + return GodotHTTPRequest.requests[xhrId].status; + }, + + godot_xhr_get_ready_state: function(xhrId) { + return GodotHTTPRequest.requests[xhrId].readyState; + }, + + godot_xhr_get_response_headers_length: function(xhrId) { + var headers = GodotHTTPRequest.requests[xhrId].getAllResponseHeaders(); + return headers === null ? 0 : lengthBytesUTF8(headers); + }, + + godot_xhr_get_response_headers: function(xhrId, dst, len) { + var str = GodotHTTPRequest.requests[xhrId].getAllResponseHeaders(); + if (str === null) + return; + var buf = new Uint8Array(len + 1); + stringToUTF8Array(str, buf, 0, buf.length); + buf = buf.subarray(0, -1); + HEAPU8.set(buf, dst); + }, + + godot_xhr_get_response_length: function(xhrId) { + var body = GodotHTTPRequest.requests[xhrId].response; + return body === null ? 0 : body.byteLength; + }, + + godot_xhr_get_response: function(xhrId, dst, len) { + var buf = GodotHTTPRequest.requests[xhrId].response; + if (buf === null) + return; + buf = new Uint8Array(buf).subarray(0, len); + HEAPU8.set(buf, dst); + }, +}; + +autoAddDeps(GodotHTTPRequest, "$GodotHTTPRequest"); +mergeInto(LibraryManager.library, GodotHTTPRequest); diff --git a/platform/javascript/javascript_eval.cpp b/platform/javascript/javascript_eval.cpp index 1d737879f6..a755dcb5c4 100644 --- a/platform/javascript/javascript_eval.cpp +++ b/platform/javascript/javascript_eval.cpp @@ -29,16 +29,9 @@ /*************************************************************************/ #ifdef JAVASCRIPT_EVAL_ENABLED -#include "javascript_eval.h" +#include "api/javascript_eval.h" #include "emscripten.h" -JavaScript *JavaScript::singleton = NULL; - -JavaScript *JavaScript::get_singleton() { - - return singleton; -} - extern "C" EMSCRIPTEN_KEEPALIVE uint8_t *resize_poolbytearray_and_open_write(PoolByteArray *p_arr, PoolByteArray::Write *r_write, int p_len) { p_arr->resize(p_len); @@ -182,18 +175,4 @@ Variant JavaScript::eval(const String &p_code, bool p_use_global_exec_context) { return Variant(); } -void JavaScript::_bind_methods() { - - ClassDB::bind_method(D_METHOD("eval", "code", "use_global_execution_context"), &JavaScript::eval, false); -} - -JavaScript::JavaScript() { - - ERR_FAIL_COND(singleton != NULL); - singleton = this; -} - -JavaScript::~JavaScript() { -} - #endif // JAVASCRIPT_EVAL_ENABLED diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp index ed4f416cfd..5c5d608524 100644 --- a/platform/javascript/javascript_main.cpp +++ b/platform/javascript/javascript_main.cpp @@ -61,7 +61,6 @@ int main(int argc, char *argv[]) { // run the 'main_after_fs_sync' function /* clang-format off */ EM_ASM( - Module.noExitRuntime = true; FS.mkdir('/userfs'); FS.mount(IDBFS, {}, '/userfs'); FS.syncfs(true, function(err) { diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp index 3a57de2646..74cfec14a6 100644 --- a/platform/javascript/os_javascript.cpp +++ b/platform/javascript/os_javascript.cpp @@ -29,8 +29,8 @@ /*************************************************************************/ #include "os_javascript.h" +#include "core/engine.h" #include "core/io/file_access_buffered_fa.h" -#include "core/project_settings.h" #include "dom_keys.h" #include "drivers/gles3/rasterizer_gles3.h" #include "drivers/unix/dir_access_unix.h" @@ -64,11 +64,6 @@ const char *OS_JavaScript::get_video_driver_name(int p_driver) const { return "GLES3"; } -OS::VideoMode OS_JavaScript::get_default_video_mode() const { - - return OS::VideoMode(); -} - int OS_JavaScript::get_audio_driver_count() const { return 1; @@ -171,14 +166,15 @@ static EM_BOOL _mousebutton_callback(int event_type, const EmscriptenMouseEvent } int mask = _input->get_mouse_button_mask(); + int button_flag = 1 << (ev->get_button_index() - 1); if (ev->is_pressed()) { // since the event is consumed, focus manually if (!is_canvas_focused()) { focus_canvas(); } - mask |= ev->get_button_index(); - } else if (mask & ev->get_button_index()) { - mask &= ~ev->get_button_index(); + mask |= button_flag; + } else if (mask & button_flag) { + mask &= ~button_flag; } else { // release event, but press was outside the canvas, so ignore return false; @@ -442,25 +438,23 @@ void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, i video_mode = p_desired; // can't fulfil fullscreen request due to browser security video_mode.fullscreen = false; - set_window_size(Size2(p_desired.width, p_desired.height)); + /* clang-format off */ + bool resize_canvas_on_start = EM_ASM_INT_V( + return Module.resizeCanvasOnStart; + ); + /* clang-format on */ + if (resize_canvas_on_start) { + set_window_size(Size2(video_mode.width, video_mode.height)); + } else { + Size2 canvas_size = get_window_size(); + video_mode.width = canvas_size.width; + video_mode.height = canvas_size.height; + } - // find locale, emscripten only sets "C" char locale_ptr[16]; /* clang-format off */ - EM_ASM_({ - var locale = ""; - if (Module.locale) { - // best case: server-side script reads Accept-Language early and - // defines the locale to be read here - locale = Module.locale; - } else { - // no luck, use what the JS engine can tell us - // if this turns out not compatible enough, add tests for - // browserLanguage, systemLanguage and userLanguage - locale = navigator.languages ? navigator.languages[0] : navigator.language; - } - locale = locale.split('.')[0]; - stringToUTF8(locale, $0, 16); + EM_ASM_ARGS({ + stringToUTF8(Module.locale, $0, 16); }, locale_ptr); /* clang-format on */ setenv("LANG", locale_ptr, true); @@ -516,11 +510,6 @@ void OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver, i #undef SET_EM_CALLBACK #undef EM_CHECK -#ifdef JAVASCRIPT_EVAL_ENABLED - javascript_eval = memnew(JavaScript); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("JavaScript", javascript_eval)); -#endif - visual_server->init(); } @@ -893,14 +882,13 @@ String OS_JavaScript::get_resource_dir() const { return "/"; //javascript has it's own filesystem for resources inside the APK } -String OS_JavaScript::get_data_dir() const { +String OS_JavaScript::get_user_data_dir() const { /* - if (get_data_dir_func) - return get_data_dir_func(); + if (get_user_data_dir_func) + return get_user_data_dir_func(); */ return "/userfs"; - //return ProjectSettings::get_singleton()->get_singleton_object("GodotOS")->call("get_data_dir"); }; String OS_JavaScript::get_executable_path() const { @@ -998,7 +986,7 @@ bool OS_JavaScript::is_userfs_persistent() const { return idbfs_available; } -OS_JavaScript::OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_dir_func) { +OS_JavaScript::OS_JavaScript(const char *p_execpath, GetUserDataDirFunc p_get_user_data_dir_func) { set_cmdline(p_execpath, get_cmdline_args()); main_loop = NULL; gl_extensions = NULL; @@ -1006,7 +994,7 @@ OS_JavaScript::OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_d soft_fs_enabled = false; canvas_size_adjustment_requested = false; - get_data_dir_func = p_get_data_dir_func; + get_user_data_dir_func = p_get_user_data_dir_func; FileAccessUnix::close_notification_func = _close_notification_funcs; idbfs_available = false; diff --git a/platform/javascript/os_javascript.h b/platform/javascript/os_javascript.h index 07720e95ec..77eeb02a9f 100644 --- a/platform/javascript/os_javascript.h +++ b/platform/javascript/os_javascript.h @@ -32,7 +32,6 @@ #include "audio_driver_javascript.h" #include "drivers/unix/os_unix.h" -#include "javascript_eval.h" #include "main/input_default.h" #include "os/input.h" #include "os/main_loop.h" @@ -42,7 +41,7 @@ #include <emscripten/html5.h> -typedef String (*GetDataDirFunc)(); +typedef String (*GetUserDataDirFunc)(); class OS_JavaScript : public OS_Unix { @@ -63,14 +62,10 @@ class OS_JavaScript : public OS_Unix { CursorShape cursor_shape; MainLoop *main_loop; - GetDataDirFunc get_data_dir_func; + GetUserDataDirFunc get_user_data_dir_func; PowerJavascript *power_manager; -#ifdef JAVASCRIPT_EVAL_ENABLED - JavaScript *javascript_eval; -#endif - static void _close_notification_funcs(const String &p_file, int p_flags); void process_joypads(); @@ -83,8 +78,6 @@ public: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; - virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; @@ -148,7 +141,7 @@ public: void set_opengl_extensions(const char *p_gl_extensions); virtual Error shell_open(String p_uri); - virtual String get_data_dir() const; + virtual String get_user_data_dir() const; String get_executable_path() const; virtual String get_resource_dir() const; @@ -167,7 +160,7 @@ public: void set_idbfs_available(bool p_idbfs_available); - OS_JavaScript(const char *p_execpath, GetDataDirFunc p_get_data_dir_func); + OS_JavaScript(const char *p_execpath, GetUserDataDirFunc p_get_user_data_dir_func); ~OS_JavaScript(); }; diff --git a/platform/javascript/pre_wasm.js b/platform/javascript/pre.js index be4383c8c9..311aa44fda 100644 --- a/platform/javascript/pre_wasm.js +++ b/platform/javascript/pre.js @@ -1,3 +1,2 @@ var Engine = { - USING_WASM: true, RuntimeEnvironment: function(Module) { diff --git a/platform/javascript/pre_asmjs.js b/platform/javascript/pre_asmjs.js deleted file mode 100644 index 3c497721b6..0000000000 --- a/platform/javascript/pre_asmjs.js +++ /dev/null @@ -1,3 +0,0 @@ -var Engine = { - USING_WASM: false, - RuntimeEnvironment: function(Module) { diff --git a/platform/osx/detect.py b/platform/osx/detect.py index 31032659b6..ff7cf2ad2f 100644 --- a/platform/osx/detect.py +++ b/platform/osx/detect.py @@ -84,8 +84,15 @@ def configure(env): else: # 64-bit, default basecmd = root + "/target/bin/x86_64-apple-" + env["osxcross_sdk"] + "-" - env['CC'] = basecmd + "cc" - env['CXX'] = basecmd + "c++" + ccache_path = os.environ.get("CCACHE") + if ccache_path == None: + env['CC'] = basecmd + "cc" + env['CXX'] = basecmd + "c++" + else: + # there aren't any ccache wrappers available for OS X cross-compile, + # to enable caching we need to prepend the path to the ccache binary + env['CC'] = ccache_path + ' ' + basecmd + "cc" + env['CXX'] = ccache_path + ' ' + basecmd + "c++" env['AR'] = basecmd + "ar" env['RANLIB'] = basecmd + "ranlib" env['AS'] = basecmd + "as" @@ -103,7 +110,7 @@ def configure(env): ## Flags env.Append(CPPPATH=['#platform/osx']) - env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES2_ENABLED', '-DAPPLE_STYLE_KEYS', '-DCOREAUDIO_ENABLED']) + env.Append(CPPFLAGS=['-DOSX_ENABLED', '-DUNIX_ENABLED', '-DGLES_ENABLED', '-DAPPLE_STYLE_KEYS', '-DCOREAUDIO_ENABLED']) env.Append(LINKFLAGS=['-framework', 'Cocoa', '-framework', 'Carbon', '-framework', 'OpenGL', '-framework', 'AGL', '-framework', 'AudioUnit', '-framework', 'CoreAudio', '-lz', '-framework', 'IOKit', '-framework', 'ForceFeedback']) env.Append(LIBS=['pthread']) diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 8a6f1dc04c..f6922377e3 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -160,7 +160,7 @@ void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_ copy->convert(Image::FORMAT_RGBA8); copy->resize(size, size); it->create_from_image(copy); - String path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/icon.png"; + String path = EditorSettings::get_singleton()->get_cache_dir().plus_file("icon.png"); ResourceSaver::save(path, it); FileAccess *f = FileAccess::open(path, FileAccess::READ); @@ -344,7 +344,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p if (use_dmg()) { // We're on OSX so we can export to DMG, but first we create our application bundle - tmp_app_path_name = EditorSettings::get_singleton()->get_settings_path() + "/tmp/" + pkg_name + ".app"; + tmp_app_path_name = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".app"); print_line("Exporting to " + tmp_app_path_name); DirAccess *tmp_app_path = DirAccess::create_for_path(tmp_app_path_name); if (!tmp_app_path) { @@ -539,7 +539,7 @@ Error EditorExportPlatformOSX::export_project(const Ref<EditorExportPreset> &p_p OS::get_singleton()->move_to_trash(tmp_app_path_name); } else { - String pack_path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/" + pkg_name + ".pck"; + String pack_path = EditorSettings::get_singleton()->get_cache_dir().plus_file(pkg_name + ".pck"); Error err = save_pack(p_preset, pack_path); if (err == OK) { diff --git a/platform/osx/os_osx.h b/platform/osx/os_osx.h index fba53f61b6..aa8ee1fe83 100644 --- a/platform/osx/os_osx.h +++ b/platform/osx/os_osx.h @@ -120,7 +120,6 @@ public: protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; virtual void initialize_logger(); virtual void initialize_core(); @@ -155,6 +154,11 @@ public: virtual MainLoop *get_main_loop() const; + virtual String get_config_path() const; + virtual String get_data_path() const; + virtual String get_cache_path() const; + virtual String get_godot_dir_name() const; + virtual String get_system_dir(SystemDir p_dir) const; virtual bool can_draw() const; @@ -227,6 +231,12 @@ public: virtual Error move_to_trash(const String &p_path); OS_OSX(); + +private: + Point2 get_native_screen_position(int p_screen) const; + Point2 get_native_window_position() const; + void set_native_window_position(const Point2 &p_position); + Point2 get_screens_origin() const; }; #endif diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 78acc97676..110cb776ee 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -36,6 +36,7 @@ #include "print_string.h" #include "sem_osx.h" #include "servers/visual/visual_server_raster.h" +#include "version_generated.gen.h" #include <Carbon/Carbon.h> #import <Cocoa/Cocoa.h> @@ -896,17 +897,7 @@ int OS_OSX::get_video_driver_count() const { const char *OS_OSX::get_video_driver_name(int p_driver) const { - return "GLES2"; -} - -OS::VideoMode OS_OSX::get_default_video_mode() const { - - VideoMode vm; - vm.width = 1024; - vm.height = 600; - vm.fullscreen = false; - vm.resizable = true; - return vm; + return "GLES3"; } void OS_OSX::initialize_core() { @@ -923,10 +914,15 @@ void OS_OSX::initialize_core() { } static bool keyboard_layout_dirty = true; -static void keyboardLayoutChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { +static void keyboard_layout_changed(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef user_info) { keyboard_layout_dirty = true; } +static bool displays_arrangement_dirty = true; +static void displays_arrangement_changed(CGDirectDisplayID display_id, CGDisplayChangeSummaryFlags flags, void *user_info) { + displays_arrangement_dirty = true; +} + void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { /*** OSX INITIALIZATION ***/ @@ -934,13 +930,17 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au /*** OSX INITIALIZATION ***/ keyboard_layout_dirty = true; + displays_arrangement_dirty = true; // Register to be notified on keyboard layout changes CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), - NULL, keyboardLayoutChanged, + NULL, keyboard_layout_changed, kTISNotifySelectedKeyboardInputSourceChanged, NULL, CFNotificationSuspensionBehaviorDeliverImmediately); + // Register to be notified on displays arrangement changes + CGDisplayRegisterReconfigurationCallback(displays_arrangement_changed, NULL); + window_delegate = [[GodotWindowDelegate alloc] init]; // Don't use accumulation buffer support; it's not accelerated @@ -1067,8 +1067,6 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au zoomed = true; /*** END OSX INITIALIZATION ***/ - /*** END OSX INITIALIZATION ***/ - /*** END OSX INITIALIZATION ***/ bool use_gl2 = p_video_driver != 1; @@ -1078,16 +1076,12 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au RasterizerGLES3::register_config(); RasterizerGLES3::make_current(); - //rasterizer = instance_RasterizerGLES2(); - //visual_server = memnew( VisualServerRaster(rasterizer) ); - visual_server = memnew(VisualServerRaster); if (get_render_thread_mode() != RENDER_THREAD_UNSAFE) { visual_server = memnew(VisualServerWrapMT(visual_server, get_render_thread_mode() == RENDER_SEPARATE_THREAD)); } visual_server->init(); - // visual_server->cursor_set_visible(false, 0); AudioDriverManager::initialize(p_audio_driver); @@ -1096,7 +1090,7 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au power_manager = memnew(power_osx); - _ensure_data_dir(); + _ensure_user_data_dir(); restore_rect = Rect2(get_window_position(), get_window_size()); } @@ -1104,6 +1098,8 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au void OS_OSX::finalize() { CFNotificationCenterRemoveObserver(CFNotificationCenterGetDistributedCenter(), NULL, kTISNotifySelectedKeyboardInputSourceChanged, NULL); + CGDisplayRemoveReconfigurationCallback(displays_arrangement_changed, NULL); + delete_main_loop(); memdelete(joypad_osx); @@ -1339,6 +1335,43 @@ MainLoop *OS_OSX::get_main_loop() const { return main_loop; } +String OS_OSX::get_config_path() const { + + if (has_environment("XDG_CONFIG_HOME")) { + return get_environment("XDG_CONFIG_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file("Library/Application Support"); + } else { + return "."; + } +} + +String OS_OSX::get_data_path() const { + + if (has_environment("XDG_DATA_HOME")) { + return get_environment("XDG_DATA_HOME"); + } else { + return get_config_path(); + } +} + +String OS_OSX::get_cache_path() const { + + if (has_environment("XDG_CACHE_HOME")) { + return get_environment("XDG_CACHE_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file("Library/Caches"); + } else { + return get_config_path(); + } +} + +// Get properly capitalized engine name for system paths +String OS_OSX::get_godot_dir_name() const { + + return String(VERSION_SHORT_NAME).capitalize(); +} + String OS_OSX::get_system_dir(SystemDir p_dir) const { NSSearchPathDirectory id = 0; @@ -1466,6 +1499,32 @@ int OS_OSX::get_screen_count() const { return [screenArray count]; }; +// Returns the native top-left screen coordinate of the smallest rectangle +// that encompasses all screens. Needed in get_screen_position(), +// get_window_position, and set_window_position() +// to convert between OS X native screen coordinates and the ones expected by Godot +Point2 OS_OSX::get_screens_origin() const { + static Point2 origin; + + if (displays_arrangement_dirty) { + origin = Point2(); + + for (int i = 0; i < get_screen_count(); i++) { + Point2 position = get_native_screen_position(i); + if (position.x < origin.x) { + origin.x = position.x; + } + if (position.y > origin.y) { + origin.y = position.y; + } + } + + displays_arrangement_dirty = false; + } + + return origin; +} + static int get_screen_index(NSScreen *screen) { const NSUInteger index = [[NSScreen screens] indexOfObject:screen]; return index == NSNotFound ? 0 : index; @@ -1484,21 +1543,30 @@ void OS_OSX::set_current_screen(int p_screen) { set_window_position(wpos + get_screen_position(p_screen)); }; -Point2 OS_OSX::get_screen_position(int p_screen) const { +Point2 OS_OSX::get_native_screen_position(int p_screen) const { if (p_screen == -1) { p_screen = get_current_screen(); } NSArray *screenArray = [NSScreen screens]; if (p_screen < [screenArray count]) { - float displayScale = _display_scale([screenArray objectAtIndex:p_screen]); + float display_scale = _display_scale([screenArray objectAtIndex:p_screen]); NSRect nsrect = [[screenArray objectAtIndex:p_screen] frame]; - return Point2(nsrect.origin.x, nsrect.origin.y) * displayScale; + // Return the top-left corner of the screen, for OS X the y starts at the bottom + return Point2(nsrect.origin.x, nsrect.origin.y + nsrect.size.height) * display_scale; } return Point2(); } +Point2 OS_OSX::get_screen_position(int p_screen) const { + Point2 position = get_native_screen_position(p_screen) - get_screens_origin(); + // OS X native y-coordinate relative to get_screens_origin() is negative, + // Godot expects a positive value + position.y *= -1; + return position; +} + int OS_OSX::get_screen_dpi(int p_screen) const { if (p_screen == -1) { p_screen = get_current_screen(); @@ -1577,28 +1645,48 @@ float OS_OSX::_display_scale(id screen) const { } } -Point2 OS_OSX::get_window_position() const { +Point2 OS_OSX::get_native_window_position() const { - Size2 wp([window_object frame].origin.x, [window_object frame].origin.y); - wp *= _display_scale(); - return wp; + NSRect nsrect = [window_object frame]; + Point2 pos; + float display_scale = _display_scale(); + + // Return the position of the top-left corner, for OS X the y starts at the bottom + pos.x = nsrect.origin.x * display_scale; + pos.y = (nsrect.origin.y + nsrect.size.height) * display_scale; + + return pos; }; -void OS_OSX::set_window_position(const Point2 &p_position) { +Point2 OS_OSX::get_window_position() const { + Point2 position = get_native_window_position() - get_screens_origin(); + // OS X native y-coordinate relative to get_screens_origin() is negative, + // Godot expects a positive value + position.y *= -1; + return position; +} + +void OS_OSX::set_native_window_position(const Point2 &p_position) { - Size2 scr = get_screen_size(); NSPoint pos; float displayScale = _display_scale(); pos.x = p_position.x / displayScale; - // For OS X the y starts at the bottom - pos.y = (scr.height - p_position.y) / displayScale; + pos.y = p_position.y / displayScale; [window_object setFrameTopLeftPoint:pos]; _update_window(); }; +void OS_OSX::set_window_position(const Point2 &p_position) { + Point2 position = p_position; + // OS X native y-coordinate relative to get_screens_origin() is negative, + // Godot passes a positive value + position.y *= -1; + set_native_window_position(get_screens_origin() + position); +}; + Size2 OS_OSX::get_window_size() const { return window_size; diff --git a/platform/register_platform_apis.h b/platform/register_platform_apis.h new file mode 100644 index 0000000000..37f98f6cd3 --- /dev/null +++ b/platform/register_platform_apis.h @@ -0,0 +1,36 @@ +/*************************************************************************/ +/* register_platform_apis.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2017 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2017 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ +#ifndef REGISTER_APIS_H +#define REGISTER_APIS_H + +void register_platform_apis(); +void unregister_platform_apis(); + +#endif diff --git a/platform/server/os_server.cpp b/platform/server/os_server.cpp index 80c04aa5ad..5b852af738 100644 --- a/platform/server/os_server.cpp +++ b/platform/server/os_server.cpp @@ -46,10 +46,6 @@ const char *OS_Server::get_video_driver_name(int p_driver) const { return "Dummy"; } -OS::VideoMode OS_Server::get_default_video_mode() const { - - return OS::VideoMode(800, 600, false); -} void OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver) { @@ -77,7 +73,7 @@ void OS_Server::initialize(const VideoMode &p_desired, int p_video_driver, int p input = memnew(InputDefault); - _ensure_data_dir(); + _ensure_user_data_dir(); } void OS_Server::finalize() { diff --git a/platform/server/os_server.h b/platform/server/os_server.h index 630c82ccdd..03f7c2a6c8 100644 --- a/platform/server/os_server.h +++ b/platform/server/os_server.h @@ -66,7 +66,6 @@ class OS_Server : public OS_Unix { protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; virtual void initialize(const VideoMode &p_desired, int p_video_driver, int p_audio_driver); virtual void finalize(); diff --git a/platform/uwp/app.h b/platform/uwp/app.h index e079fa9c9d..b812512a98 100644 --- a/platform/uwp/app.h +++ b/platform/uwp/app.h @@ -33,6 +33,7 @@ #include <wrl.h> +// ANGLE doesn't provide a specific lib for GLES3, so we keep using GLES2 #include "GLES2/gl2.h" #include "os_uwp.h" diff --git a/platform/uwp/detect.py b/platform/uwp/detect.py index af53f97446..7cc8afff06 100644 --- a/platform/uwp/detect.py +++ b/platform/uwp/detect.py @@ -84,7 +84,7 @@ def configure(env): ## Architecture arch = "" - if os.getenv('Platform') == "ARM": + if str(os.getenv('Platform')).lower() == "arm": print("Compiled program architecture will be an ARM executable. (forcing bits=32).") @@ -136,7 +136,7 @@ def configure(env): env.Append(CPPPATH=['#platform/uwp', '#drivers/windows']) env.Append(CCFLAGS=['/DUWP_ENABLED', '/DWINDOWS_ENABLED', '/DTYPED_METHOD_BIND']) - env.Append(CCFLAGS=['/DGLES2_ENABLED', '/DGL_GLEXT_PROTOTYPES', '/DEGL_EGLEXT_PROTOTYPES', '/DANGLE_ENABLED']) + env.Append(CCFLAGS=['/DGLES_ENABLED', '/DGL_GLEXT_PROTOTYPES', '/DEGL_EGLEXT_PROTOTYPES', '/DANGLE_ENABLED']) winver = "0x0602" # Windows 8 is the minimum target for UWP build env.Append(CCFLAGS=['/DWINVER=%s' % winver, '/D_WIN32_WINNT=%s' % winver]) diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index d66bcaa91c..120df9bc3f 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -456,8 +456,8 @@ void AppxPackager::init(FileAccess *p_fa) { package = p_fa; central_dir_offset = 0; end_of_central_dir_offset = 0; - tmp_blockmap_file_path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpblockmap.xml"; - tmp_content_types_file_path = EditorSettings::get_singleton()->get_settings_path() + "/tmp/tmpcontenttypes.xml"; + tmp_blockmap_file_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpblockmap.xml"); + tmp_content_types_file_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmpcontenttypes.xml"); } void AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t p_len, int p_file_no, int p_total_files, bool p_compress) { @@ -886,7 +886,7 @@ class EditorExportUWP : public EditorExportPlatform { if (!image) return data; - String tmp_path = EditorSettings::get_singleton()->get_settings_path().plus_file("tmp/uwp_tmp_logo.png"); + String tmp_path = EditorSettings::get_singleton()->get_cache_dir().plus_file("uwp_tmp_logo.png"); Error err = image->get_data()->save_png(tmp_path); diff --git a/platform/uwp/gl_context_egl.cpp b/platform/uwp/gl_context_egl.cpp index ed3db65cdf..dafe5d5e25 100644 --- a/platform/uwp/gl_context_egl.cpp +++ b/platform/uwp/gl_context_egl.cpp @@ -101,26 +101,25 @@ Error ContextEGL::initialize() { try { - const EGLint displayAttributes[] = - { - /*EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9, - EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3, - EGL_NONE,*/ - // These are the default display attributes, used to request ANGLE's D3D11 renderer. - // eglInitialize will only succeed with these attributes if the hardware supports D3D11 Feature Level 10_0+. - EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, - - // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices. - // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it. - //EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, - - // EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call - // the IDXGIDevice3::Trim method on behalf of the application when it gets suspended. - // Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement. - EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, - EGL_NONE, - }; + const EGLint displayAttributes[] = { + /*EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE, 9, + EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE, 3, + EGL_NONE,*/ + // These are the default display attributes, used to request ANGLE's D3D11 renderer. + // eglInitialize will only succeed with these attributes if the hardware supports D3D11 Feature Level 10_0+. + EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + + // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices. + // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it. + //EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER, EGL_TRUE, + + // EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call + // the IDXGIDevice3::Trim method on behalf of the application when it gets suspended. + // Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement. + EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, + EGL_NONE, + }; PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = reinterpret_cast<PFNEGLGETPLATFORMDISPLAYEXTPROC>(eglGetProcAddress("eglGetPlatformDisplayEXT")); diff --git a/platform/uwp/os_uwp.cpp b/platform/uwp/os_uwp.cpp index 8db2a749df..64e319327f 100644 --- a/platform/uwp/os_uwp.cpp +++ b/platform/uwp/os_uwp.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "os_uwp.h" + #include "drivers/gles3/rasterizer_gles3.h" #include "drivers/unix/ip_unix.h" #include "drivers/windows/dir_access_windows.h" @@ -69,12 +70,7 @@ int OSUWP::get_video_driver_count() const { } const char *OSUWP::get_video_driver_name(int p_driver) const { - return "GLES2"; -} - -OS::VideoMode OSUWP::get_default_video_mode() const { - - return video_mode; + return "GLES3"; } Size2 OSUWP::get_window_size() const { @@ -303,7 +299,7 @@ void OSUWP::initialize(const VideoMode &p_desired, int p_video_driver, int p_aud ref new TypedEventHandler<Gyrometer ^, GyrometerReadingChangedEventArgs ^>(managed_object, &ManagedType::on_gyroscope_reading_changed); } - _ensure_data_dir(); + _ensure_user_data_dir(); if (is_keep_screen_on()) display_request->RequestActive(); @@ -786,7 +782,7 @@ MainLoop *OSUWP::get_main_loop() const { return main_loop; } -String OSUWP::get_data_dir() const { +String OSUWP::get_user_data_dir() const { Windows::Storage::StorageFolder ^ data_folder = Windows::Storage::ApplicationData::Current->LocalFolder; diff --git a/platform/uwp/os_uwp.h b/platform/uwp/os_uwp.h index e46e4cc020..3c52fc29a8 100644 --- a/platform/uwp/os_uwp.h +++ b/platform/uwp/os_uwp.h @@ -154,8 +154,6 @@ protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; - virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; @@ -228,7 +226,7 @@ public: virtual String get_locale() const; virtual void move_window_to_foreground(); - virtual String get_data_dir() const; + virtual String get_user_data_dir() const; virtual bool _check_internal_feature_support(const String &p_feature); diff --git a/platform/windows/context_gl_win.cpp b/platform/windows/context_gl_win.cpp index 64b6d202a1..81aa18dd23 100644 --- a/platform/windows/context_gl_win.cpp +++ b/platform/windows/context_gl_win.cpp @@ -27,25 +27,12 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#if defined(OPENGL_ENABLED) || defined(GLES2_ENABLED) - -// -// C++ Implementation: context_gl_x11 -// -// Description: -// -// +#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED) + // Author: Juan Linietsky <reduzio@gmail.com>, (C) 2008 -// -// Copyright: See COPYING file that comes with this distribution -// -// #include "context_gl_win.h" -//#include "drivers/opengl/glwrapper.h" -//#include "ctxgl_procaddr.h" - #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 #define WGL_CONTEXT_FLAGS_ARB 0x2094 @@ -165,7 +152,7 @@ Error ContextGL_Win::initialize() { WGL_CONTEXT_MAJOR_VERSION_ARB, 3, //we want a 3.3 context WGL_CONTEXT_MINOR_VERSION_ARB, 3, //and it shall be forward compatible so that we can only use up to date functionality - WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB | _WGL_CONTEXT_DEBUG_BIT_ARB, + WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB /*| _WGL_CONTEXT_DEBUG_BIT_ARB*/, 0 }; //zero indicates the end of the array diff --git a/platform/windows/context_gl_win.h b/platform/windows/context_gl_win.h index 0059cbc311..5a280b0d08 100644 --- a/platform/windows/context_gl_win.h +++ b/platform/windows/context_gl_win.h @@ -27,18 +27,9 @@ /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#if defined(OPENGL_ENABLED) || defined(GLES2_ENABLED) -// -// C++ Interface: context_gl_x11 -// -// Description: -// -// +#if defined(OPENGL_ENABLED) || defined(GLES_ENABLED) + // Author: Juan Linietsky <reduzio@gmail.com>, (C) 2008 -// -// Copyright: See COPYING file that comes with this distribution -// -// #ifndef CONTEXT_GL_WIN_H #define CONTEXT_GL_WIN_H diff --git a/platform/windows/godot_res.rc b/platform/windows/godot_res.rc index b86869d316..c535a749c0 100644 --- a/platform/windows/godot_res.rc +++ b/platform/windows/godot_res.rc @@ -23,13 +23,13 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "Godot Engine" - VALUE "FileDescription", _MKSTR(VERSION_NAME) " Editor" + VALUE "FileDescription", VERSION_NAME " Editor" VALUE "FileVersion", _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) "." _MKSTR(VERSION_PATCH) - VALUE "ProductName", _MKSTR(VERSION_NAME) + VALUE "ProductName", VERSION_NAME VALUE "Licence", "MIT" VALUE "LegalCopyright", "Copyright (c) 2007-" _MKSTR(VERSION_YEAR) " Juan Linietsky, Ariel Manzur" - VALUE "Info", "http://www.godotengine.org" - VALUE "ProductVersion", _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) PATCH_STRING "." _MKSTR(VERSION_REVISION) + VALUE "Info", "https://godotengine.org" + VALUE "ProductVersion", _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR) PATCH_STRING "." VERSION_BUILD END END BLOCK "VarFileInfo" diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 01201beccb..72d51ad62a 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -47,6 +47,7 @@ #include "servers/visual/visual_server_wrap_mt.h" #include "stream_peer_winsock.h" #include "tcp_server_winsock.h" +#include "version_generated.gen.h" #include "windows_terminal_logger.h" #include <process.h> @@ -143,12 +144,7 @@ int OS_Windows::get_video_driver_count() const { } const char *OS_Windows::get_video_driver_name(int p_driver) const { - return "GLES2"; -} - -OS::VideoMode OS_Windows::get_default_video_mode() const { - - return VideoMode(1024, 600, false); + return "GLES3"; } int OS_Windows::get_audio_driver_count() const { @@ -1095,7 +1091,7 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int //RegisterTouchWindow(hWnd, 0); // Windows 7 - _ensure_data_dir(); + _ensure_user_data_dir(); DragAcceptFiles(hWnd, true); @@ -2136,6 +2132,43 @@ MainLoop *OS_Windows::get_main_loop() const { return main_loop; } +String OS_Windows::get_config_path() const { + + if (has_environment("XDG_CONFIG_HOME")) { // unlikely, but after all why not? + return get_environment("XDG_CONFIG_HOME"); + } else if (has_environment("APPDATA")) { + return get_environment("APPDATA"); + } else { + return "."; + } +} + +String OS_Windows::get_data_path() const { + + if (has_environment("XDG_DATA_HOME")) { + return get_environment("XDG_DATA_HOME"); + } else { + return get_config_path(); + } +} + +String OS_Windows::get_cache_path() const { + + if (has_environment("XDG_CACHE_HOME")) { + return get_environment("XDG_CACHE_HOME"); + } else if (has_environment("TEMP")) { + return get_environment("TEMP"); + } else { + return get_config_path(); + } +} + +// Get properly capitalized engine name for system paths +String OS_Windows::get_godot_dir_name() const { + + return String(VERSION_SHORT_NAME).capitalize(); +} + String OS_Windows::get_system_dir(SystemDir p_dir) const { int id; @@ -2172,18 +2205,17 @@ String OS_Windows::get_system_dir(SystemDir p_dir) const { ERR_FAIL_COND_V(res != S_OK, String()); return String(szPath); } -String OS_Windows::get_data_dir() const { - String an = get_safe_application_name(); - if (an != "") { +String OS_Windows::get_user_data_dir() const { - if (has_environment("APPDATA")) { + String appname = get_safe_application_name(); + if (appname != "") { - bool use_godot = ProjectSettings::get_singleton()->get("application/config/use_shared_user_dir"); - if (!use_godot) - return (OS::get_singleton()->get_environment("APPDATA") + "/" + an).replace("\\", "/"); - else - return (OS::get_singleton()->get_environment("APPDATA") + "/Godot/app_userdata/" + an).replace("\\", "/"); + bool use_godot_dir = ProjectSettings::get_singleton()->get("application/config/use_shared_user_dir"); + if (use_godot_dir) { + return get_data_path().plus_file(get_godot_dir_name()).plus_file("app_userdata").plus_file(appname).replace("\\", "/"); + } else { + return get_data_path().plus_file(appname).replace("\\", "/"); } } diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index c9c00b5e36..5e0c240dba 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -142,8 +142,6 @@ protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; - virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; @@ -255,8 +253,14 @@ public: virtual void enable_for_stealing_focus(ProcessID pid); virtual void move_window_to_foreground(); - virtual String get_data_dir() const; + + virtual String get_config_path() const; + virtual String get_data_path() const; + virtual String get_cache_path() const; + virtual String get_godot_dir_name() const; + virtual String get_system_dir(SystemDir p_dir) const; + virtual String get_user_data_dir() const; virtual void release_rendering_thread(); virtual void make_rendering_thread(); diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 6bd0ac8317..3d07851c4f 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -236,7 +236,7 @@ def configure(env): env.ParseConfig('pkg-config zlib --cflags --libs') env.Append(CPPPATH=['#platform/x11']) - env.Append(CPPFLAGS=['-DX11_ENABLED', '-DUNIX_ENABLED', '-DOPENGL_ENABLED', '-DGLES2_ENABLED', '-DGLES_OVER_GL']) + env.Append(CPPFLAGS=['-DX11_ENABLED', '-DUNIX_ENABLED', '-DOPENGL_ENABLED', '-DGLES_ENABLED', '-DGLES_OVER_GL']) env.Append(LIBS=['GL', 'pthread']) if (platform.system() == "Linux"): diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index fbcc22c58e..c1d744215d 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -82,10 +82,6 @@ const char *OS_X11::get_video_driver_name(int p_driver) const { return "GLES3"; } -OS::VideoMode OS_X11::get_default_video_mode() const { - return OS::VideoMode(1024, 600, false); -} - int OS_X11::get_audio_driver_count() const { return AudioDriverManager::get_driver_count(); } @@ -468,7 +464,7 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au #ifdef JOYDEV_ENABLED joypad = memnew(JoypadLinux(input)); #endif - _ensure_data_dir(); + _ensure_user_data_dir(); power_manager = memnew(PowerX11); } @@ -1945,6 +1941,39 @@ bool OS_X11::_check_internal_feature_support(const String &p_feature) { return p_feature == "pc" || p_feature == "s3tc"; } +String OS_X11::get_config_path() const { + + if (has_environment("XDG_CONFIG_HOME")) { + return get_environment("XDG_CONFIG_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".config"); + } else { + return "."; + } +} + +String OS_X11::get_data_path() const { + + if (has_environment("XDG_DATA_HOME")) { + return get_environment("XDG_DATA_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".local/share"); + } else { + return get_config_path(); + } +} + +String OS_X11::get_cache_path() const { + + if (has_environment("XDG_CACHE_HOME")) { + return get_environment("XDG_CACHE_HOME"); + } else if (has_environment("HOME")) { + return get_environment("HOME").plus_file(".cache"); + } else { + return get_config_path(); + } +} + String OS_X11::get_system_dir(SystemDir p_dir) const { String xdgparam; diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index bfa8b5b375..67f3807d99 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -177,7 +177,6 @@ class OS_X11 : public OS_Unix { protected: virtual int get_video_driver_count() const; virtual const char *get_video_driver_name(int p_driver) const; - virtual VideoMode get_default_video_mode() const; virtual int get_audio_driver_count() const; virtual const char *get_audio_driver_name(int p_driver) const; @@ -214,6 +213,10 @@ public: virtual void make_rendering_thread(); virtual void swap_buffers(); + virtual String get_config_path() const; + virtual String get_data_path() const; + virtual String get_cache_path() const; + virtual String get_system_dir(SystemDir p_dir) const; virtual Error shell_open(String p_uri); diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 5982556c18..4865858b7d 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -247,16 +247,16 @@ SpriteFrames::SpriteFrames() { add_animation(SceneStringNames::get_singleton()->_default); } -void AnimatedSprite::edit_set_pivot(const Point2 &p_pivot) { +void AnimatedSprite::_edit_set_pivot(const Point2 &p_pivot) { set_offset(p_pivot); } -Point2 AnimatedSprite::edit_get_pivot() const { +Point2 AnimatedSprite::_edit_get_pivot() const { return get_offset(); } -bool AnimatedSprite::edit_has_pivot() const { +bool AnimatedSprite::_edit_use_pivot() const { return true; } @@ -509,17 +509,17 @@ bool AnimatedSprite::is_flipped_v() const { return vflip; } -Rect2 AnimatedSprite::get_item_rect() const { +Rect2 AnimatedSprite::_edit_get_rect() const { if (!frames.is_valid() || !frames->has_animation(animation) || frame < 0 || frame >= frames->get_frame_count(animation)) { - return Node2D::get_item_rect(); + return Node2D::_edit_get_rect(); } Ref<Texture> t; if (animation) t = frames->get_frame(animation, frame); if (t.is_null()) - return Node2D::get_item_rect(); + return Node2D::_edit_get_rect(); Size2i s = t->get_size(); Point2 ofs = offset; diff --git a/scene/2d/animated_sprite.h b/scene/2d/animated_sprite.h index 6c660d0381..a8d0db021a 100644 --- a/scene/2d/animated_sprite.h +++ b/scene/2d/animated_sprite.h @@ -149,9 +149,9 @@ protected: virtual void _validate_property(PropertyInfo &property) const; public: - virtual void edit_set_pivot(const Point2 &p_pivot); - virtual Point2 edit_get_pivot() const; - virtual bool edit_has_pivot() const; + virtual void _edit_set_pivot(const Point2 &p_pivot); + virtual Point2 _edit_get_pivot() const; + virtual bool _edit_use_pivot() const; void set_sprite_frames(const Ref<SpriteFrames> &p_frames); Ref<SpriteFrames> get_sprite_frames() const; @@ -181,7 +181,7 @@ public: void set_modulate(const Color &p_color); Color get_modulate() const; - virtual Rect2 get_item_rect() const; + virtual Rect2 _edit_get_rect() const; virtual String get_configuration_warning() const; AnimatedSprite(); diff --git a/scene/2d/back_buffer_copy.cpp b/scene/2d/back_buffer_copy.cpp index 2858ddaad5..e4f52a227a 100644 --- a/scene/2d/back_buffer_copy.cpp +++ b/scene/2d/back_buffer_copy.cpp @@ -49,7 +49,7 @@ void BackBufferCopy::_update_copy_mode() { } } -Rect2 BackBufferCopy::get_item_rect() const { +Rect2 BackBufferCopy::_edit_get_rect() const { return rect; } diff --git a/scene/2d/back_buffer_copy.h b/scene/2d/back_buffer_copy.h index 2424dd7b19..cfd632d755 100644 --- a/scene/2d/back_buffer_copy.h +++ b/scene/2d/back_buffer_copy.h @@ -52,14 +52,14 @@ protected: static void _bind_methods(); public: + Rect2 _edit_get_rect() const; + void set_rect(const Rect2 &p_rect); Rect2 get_rect() const; void set_copy_mode(CopyMode p_mode); CopyMode get_copy_mode() const; - Rect2 get_item_rect() const; - BackBufferCopy(); ~BackBufferCopy(); }; diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index b41ba7f590..66abe1baa8 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -178,6 +178,12 @@ CanvasItemMaterial::LightMode CanvasItemMaterial::get_light_mode() const { void CanvasItemMaterial::_validate_property(PropertyInfo &property) const { } +RID CanvasItemMaterial::get_shader_rid() const { + + ERR_FAIL_COND_V(!shader_map.has(current_key), RID()); + return shader_map[current_key].shader; +} + void CanvasItemMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_blend_mode", "blend_mode"), &CanvasItemMaterial::set_blend_mode); @@ -300,22 +306,7 @@ void CanvasItem::hide() { _change_notify("visible"); } -Variant CanvasItem::edit_get_state() const { - - return Variant(); -} -void CanvasItem::edit_set_state(const Variant &p_state) { -} - -void CanvasItem::edit_set_rect(const Rect2 &p_edit_rect) { - - //used by editors, implement at will -} - -void CanvasItem::edit_rotate(float p_rot) { -} - -Size2 CanvasItem::edit_get_minimum_size() const { +Size2 CanvasItem::_edit_get_minimum_size() const { return Size2(-1, -1); //no limit } @@ -935,15 +926,22 @@ void CanvasItem::_bind_methods() { ClassDB::bind_method(D_METHOD("_toplevel_raise_self"), &CanvasItem::_toplevel_raise_self); ClassDB::bind_method(D_METHOD("_update_callback"), &CanvasItem::_update_callback); - - ClassDB::bind_method(D_METHOD("edit_set_state", "state"), &CanvasItem::edit_set_state); - ClassDB::bind_method(D_METHOD("edit_get_state"), &CanvasItem::edit_get_state); - ClassDB::bind_method(D_METHOD("edit_set_rect", "rect"), &CanvasItem::edit_set_rect); - ClassDB::bind_method(D_METHOD("edit_rotate", "degrees"), &CanvasItem::edit_rotate); - - ClassDB::bind_method(D_METHOD("get_item_rect"), &CanvasItem::get_item_rect); - ClassDB::bind_method(D_METHOD("get_item_and_children_rect"), &CanvasItem::get_item_and_children_rect); - //ClassDB::bind_method(D_METHOD("get_transform"),&CanvasItem::get_transform); + ClassDB::bind_method(D_METHOD("_edit_set_state", "state"), &CanvasItem::_edit_set_state); + ClassDB::bind_method(D_METHOD("_edit_get_state"), &CanvasItem::_edit_get_state); + + ClassDB::bind_method(D_METHOD("_edit_set_position", "position"), &CanvasItem::_edit_set_position); + ClassDB::bind_method(D_METHOD("_edit_get_position"), &CanvasItem::_edit_get_position); + ClassDB::bind_method(D_METHOD("_edit_use_position"), &CanvasItem::_edit_use_position); + ClassDB::bind_method(D_METHOD("_edit_set_rect", "rect"), &CanvasItem::_edit_set_rect); + ClassDB::bind_method(D_METHOD("_edit_get_rect"), &CanvasItem::_edit_get_rect); + ClassDB::bind_method(D_METHOD("_edit_use_rect"), &CanvasItem::_edit_use_rect); + ClassDB::bind_method(D_METHOD("_edit_get_item_and_children_rect"), &CanvasItem::_edit_get_item_and_children_rect); + ClassDB::bind_method(D_METHOD("_edit_set_rotation", "degrees"), &CanvasItem::_edit_set_rotation); + ClassDB::bind_method(D_METHOD("_edit_get_rotation"), &CanvasItem::_edit_get_rotation); + ClassDB::bind_method(D_METHOD("_edit_use_rotation"), &CanvasItem::_edit_use_rotation); + ClassDB::bind_method(D_METHOD("_edit_set_pivot", "pivot"), &CanvasItem::_edit_set_pivot); + ClassDB::bind_method(D_METHOD("_edit_get_pivot"), &CanvasItem::_edit_get_pivot); + ClassDB::bind_method(D_METHOD("_edit_use_pivot"), &CanvasItem::_edit_use_pivot); ClassDB::bind_method(D_METHOD("get_canvas_item"), &CanvasItem::get_canvas_item); @@ -1113,14 +1111,14 @@ int CanvasItem::get_canvas_layer() const { return 0; } -Rect2 CanvasItem::get_item_and_children_rect() const { +Rect2 CanvasItem::_edit_get_item_and_children_rect() const { - Rect2 rect = get_item_rect(); + Rect2 rect = _edit_get_rect(); for (int i = 0; i < get_child_count(); i++) { CanvasItem *c = Object::cast_to<CanvasItem>(get_child(i)); if (c) { - Rect2 sir = c->get_transform().xform(c->get_item_and_children_rect()); + Rect2 sir = c->get_transform().xform(c->_edit_get_item_and_children_rect()); rect = rect.merge(sir); } } diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index 1afbd150a2..c877a94755 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -121,6 +121,8 @@ public: static void finish_shaders(); static void flush_changes(); + RID get_shader_rid() const; + CanvasItemMaterial(); virtual ~CanvasItemMaterial(); }; @@ -214,11 +216,31 @@ public: /* EDITOR */ - virtual Variant edit_get_state() const; - virtual void edit_set_state(const Variant &p_state); - virtual void edit_set_rect(const Rect2 &p_edit_rect); - virtual void edit_rotate(float p_rot); - virtual Size2 edit_get_minimum_size() const; + virtual void _edit_set_state(const Dictionary &p_state){}; + virtual Dictionary _edit_get_state() const { return Dictionary(); }; + + // Used to move/select the node + virtual void _edit_set_position(const Point2 &p_position){}; + virtual Point2 _edit_get_position() const { return Point2(); }; + virtual bool _edit_use_position() const { return false; }; + + // Used to resize/move/select the node + virtual void _edit_set_rect(const Rect2 &p_rect){}; + virtual Rect2 _edit_get_rect() const { return Rect2(-32, -32, 64, 64); }; + Rect2 _edit_get_item_and_children_rect() const; + virtual bool _edit_use_rect() const { return false; }; + + // Used to rotate the node + virtual void _edit_set_rotation(float p_rotation){}; + virtual float _edit_get_rotation() const { return 0.0; }; + virtual bool _edit_use_rotation() const { return false; }; + + // Used to set a pivot + virtual void _edit_set_pivot(const Point2 &p_pivot){}; + virtual Point2 _edit_get_pivot() const { return Point2(); }; + virtual bool _edit_use_pivot() const { return false; }; + + virtual Size2 _edit_get_minimum_size() const; /* VISIBILITY */ @@ -248,7 +270,7 @@ public: void draw_circle(const Point2 &p_pos, float p_radius, const Color &p_color); void draw_texture(const Ref<Texture> &p_texture, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1, 1), const Ref<Texture> &p_normal_map = Ref<Texture>()); void draw_texture_rect(const Ref<Texture> &p_texture, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()); - void draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true); + void draw_texture_rect_region(const Ref<Texture> &p_texture, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = false); void draw_style_box(const Ref<StyleBox> &p_style_box, const Rect2 &p_rect); void draw_primitive(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, Ref<Texture> p_texture = Ref<Texture>(), float p_width = 1, const Ref<Texture> &p_normal_map = Ref<Texture>()); void draw_polygon(const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), Ref<Texture> p_texture = Ref<Texture>(), const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_antialiased = false); @@ -270,14 +292,11 @@ public: CanvasItem *get_parent_item() const; - virtual Rect2 get_item_rect() const = 0; virtual Transform2D get_transform() const = 0; virtual Transform2D get_global_transform() const; virtual Transform2D get_global_transform_with_canvas() const; - Rect2 get_item_and_children_rect() const; - CanvasItem *get_toplevel() const; _FORCE_INLINE_ RID get_canvas_item() const { return canvas_item; } diff --git a/scene/2d/collision_polygon_2d.cpp b/scene/2d/collision_polygon_2d.cpp index a840744c78..92855299ae 100644 --- a/scene/2d/collision_polygon_2d.cpp +++ b/scene/2d/collision_polygon_2d.cpp @@ -243,7 +243,7 @@ CollisionPolygon2D::BuildMode CollisionPolygon2D::get_build_mode() const { return build_mode; } -Rect2 CollisionPolygon2D::get_item_rect() const { +Rect2 CollisionPolygon2D::_edit_get_rect() const { return aabb; } diff --git a/scene/2d/collision_polygon_2d.h b/scene/2d/collision_polygon_2d.h index c9ec860e36..2fb08a4599 100644 --- a/scene/2d/collision_polygon_2d.h +++ b/scene/2d/collision_polygon_2d.h @@ -69,7 +69,7 @@ public: void set_polygon(const Vector<Point2> &p_polygon); Vector<Point2> get_polygon() const; - virtual Rect2 get_item_rect() const; + virtual Rect2 _edit_get_rect() const; virtual String get_configuration_warning() const; diff --git a/scene/2d/collision_shape_2d.cpp b/scene/2d/collision_shape_2d.cpp index 0758f4a9bf..f7cb5473e3 100644 --- a/scene/2d/collision_shape_2d.cpp +++ b/scene/2d/collision_shape_2d.cpp @@ -158,7 +158,7 @@ Ref<Shape2D> CollisionShape2D::get_shape() const { return shape; } -Rect2 CollisionShape2D::get_item_rect() const { +Rect2 CollisionShape2D::_edit_get_rect() const { return rect; } diff --git a/scene/2d/collision_shape_2d.h b/scene/2d/collision_shape_2d.h index 04203a75b4..4745c659c8 100644 --- a/scene/2d/collision_shape_2d.h +++ b/scene/2d/collision_shape_2d.h @@ -51,9 +51,10 @@ protected: static void _bind_methods(); public: + virtual Rect2 _edit_get_rect() const; + void set_shape(const Ref<Shape2D> &p_shape); Ref<Shape2D> get_shape() const; - virtual Rect2 get_item_rect() const; void set_disabled(bool p_disabled); bool is_disabled() const; diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 516acefe2a..d2b987e037 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -32,21 +32,21 @@ #include "engine.h" #include "servers/visual_server.h" -void Light2D::edit_set_pivot(const Point2 &p_pivot) { +void Light2D::_edit_set_pivot(const Point2 &p_pivot) { set_texture_offset(p_pivot); } -Point2 Light2D::edit_get_pivot() const { +Point2 Light2D::_edit_get_pivot() const { return get_texture_offset(); } -bool Light2D::edit_has_pivot() const { +bool Light2D::_edit_use_pivot() const { return true; } -Rect2 Light2D::get_item_rect() const { +Rect2 Light2D::_edit_get_rect() const { if (texture.is_null()) return Rect2(0, 0, 1, 1); diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index f6bc943adb..9b9da8379f 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -84,9 +84,10 @@ protected: static void _bind_methods(); public: - virtual void edit_set_pivot(const Point2 &p_pivot); - virtual Point2 edit_get_pivot() const; - virtual bool edit_has_pivot() const; + virtual void _edit_set_pivot(const Point2 &p_pivot); + virtual Point2 _edit_get_pivot() const; + virtual bool _edit_use_pivot() const; + virtual Rect2 _edit_get_rect() const; void set_enabled(bool p_enabled); bool is_enabled() const; @@ -151,8 +152,6 @@ public: void set_shadow_smooth(float p_amount); float get_shadow_smooth() const; - virtual Rect2 get_item_rect() const; - String get_configuration_warning() const; Light2D(); diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index e62b59dd4d..36fbf5fda6 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -34,45 +34,39 @@ #include "scene/main/viewport.h" #include "servers/visual_server.h" -void Node2D::edit_set_pivot(const Point2 &p_pivot) { -} - -Point2 Node2D::edit_get_pivot() const { - - return Point2(); -} -bool Node2D::edit_has_pivot() const { - - return false; -} - -Variant Node2D::edit_get_state() const { +Dictionary Node2D::_edit_get_state() const { - Array state; - state.push_back(get_position()); - state.push_back(get_rotation()); - state.push_back(get_scale()); + Dictionary state; + state["position"] = get_position(); + state["rotation"] = get_rotation(); + state["scale"] = get_scale(); return state; } -void Node2D::edit_set_state(const Variant &p_state) { +void Node2D::_edit_set_state(const Dictionary &p_state) { - Array state = p_state; - ERR_FAIL_COND(state.size() != 3); + Dictionary state = p_state; + pos = state["position"]; + angle = state["rotation"]; + _scale = state["scale"]; - pos = state[0]; - angle = state[1]; - _scale = state[2]; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); _change_notify("scale"); _change_notify("position"); } -void Node2D::edit_set_rect(const Rect2 &p_edit_rect) { +void Node2D::_edit_set_position(const Point2 &p_position) { + pos = p_position; +} + +Point2 Node2D::_edit_get_position() const { + return pos; +} - Rect2 r = get_item_rect(); +void Node2D::_edit_set_rect(const Rect2 &p_edit_rect) { + Rect2 r = _edit_get_rect(); Vector2 zero_offset; if (r.size.x != 0) @@ -101,12 +95,23 @@ void Node2D::edit_set_rect(const Rect2 &p_edit_rect) { _change_notify("position"); } -void Node2D::edit_rotate(float p_rot) { +bool Node2D::_edit_use_rect() const { + return true; +} - angle += p_rot; +void Node2D::_edit_set_rotation(float p_rotation) { + angle = p_rotation; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); +} + +float Node2D::_edit_get_rotation() const { + return angle; +} + +bool Node2D::_edit_use_rotation() const { + return true; } void Node2D::_update_xform_values() { @@ -147,22 +152,14 @@ void Node2D::set_rotation(float p_radians) { angle = p_radians; _update_transform(); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); } -void Node2D::set_rotation_in_degrees(float p_degrees) { +void Node2D::set_rotation_degrees(float p_degrees) { set_rotation(Math::deg2rad(p_degrees)); } -// Kept for compatibility after rename to set_rotd. -// Could be removed after a couple releases. -void Node2D::_set_rotd(float p_degrees) { - - WARN_PRINT("Deprecated method Node2D._set_rotd(): This method was renamed to set_rotd. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotation_in_degrees(p_degrees); -} - void Node2D::set_scale(const Size2 &p_scale) { if (_xform_dirty) @@ -182,23 +179,19 @@ Point2 Node2D::get_position() const { ((Node2D *)this)->_update_xform_values(); return pos; } + float Node2D::get_rotation() const { if (_xform_dirty) ((Node2D *)this)->_update_xform_values(); return angle; } -float Node2D::get_rotation_in_degrees() const { + +float Node2D::get_rotation_degrees() const { return Math::rad2deg(get_rotation()); } -// Kept for compatibility after rename to get_rotd. -// Could be removed after a couple releases. -float Node2D::_get_rotd() const { - WARN_PRINT("Deprecated method Node2D._get_rotd(): This method was renamed to get_rotd. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotation_in_degrees(); -} Size2 Node2D::get_scale() const { if (_xform_dirty) ((Node2D *)this)->_update_xform_values(); @@ -217,17 +210,6 @@ Transform2D Node2D::get_transform() const { return _mat; } -Rect2 Node2D::get_item_rect() const { - - if (get_script_instance()) { - Variant::CallError err; - Rect2 r = get_script_instance()->call("_get_item_rect", NULL, 0, err); - if (err.error == Variant::CallError::CALL_OK) - return r; - } - return Rect2(Point2(-32, -32), Size2(64, 64)); -} - void Node2D::rotate(float p_radians) { set_rotation(get_rotation() + p_radians); @@ -299,12 +281,12 @@ void Node2D::set_global_rotation(float p_radians) { } } -float Node2D::get_global_rotation_in_degrees() const { +float Node2D::get_global_rotation_degrees() const { return Math::rad2deg(get_global_rotation()); } -void Node2D::set_global_rotation_in_degrees(float p_degrees) { +void Node2D::set_global_rotation_degrees(float p_degrees) { set_global_rotation(Math::deg2rad(p_degrees)); } @@ -410,18 +392,14 @@ Point2 Node2D::to_global(Point2 p_local) const { void Node2D::_bind_methods() { - // TODO: Obsolete those two methods (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_get_rotd"), &Node2D::_get_rotd); - ClassDB::bind_method(D_METHOD("_set_rotd", "degrees"), &Node2D::_set_rotd); - ClassDB::bind_method(D_METHOD("set_position", "position"), &Node2D::set_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Node2D::set_rotation); - ClassDB::bind_method(D_METHOD("set_rotation_in_degrees", "degrees"), &Node2D::set_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Node2D::set_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Node2D::set_scale); ClassDB::bind_method(D_METHOD("get_position"), &Node2D::get_position); ClassDB::bind_method(D_METHOD("get_rotation"), &Node2D::get_rotation); - ClassDB::bind_method(D_METHOD("get_rotation_in_degrees"), &Node2D::get_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Node2D::get_rotation_degrees); ClassDB::bind_method(D_METHOD("get_scale"), &Node2D::get_scale); ClassDB::bind_method(D_METHOD("rotate", "radians"), &Node2D::rotate); @@ -435,8 +413,8 @@ void Node2D::_bind_methods() { ClassDB::bind_method(D_METHOD("get_global_position"), &Node2D::get_global_position); ClassDB::bind_method(D_METHOD("set_global_rotation", "radians"), &Node2D::set_global_rotation); ClassDB::bind_method(D_METHOD("get_global_rotation"), &Node2D::get_global_rotation); - ClassDB::bind_method(D_METHOD("set_global_rotation_in_degrees", "degrees"), &Node2D::set_global_rotation_in_degrees); - ClassDB::bind_method(D_METHOD("get_global_rotation_in_degrees"), &Node2D::get_global_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("set_global_rotation_degrees", "degrees"), &Node2D::set_global_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_global_rotation_degrees"), &Node2D::get_global_rotation_degrees); ClassDB::bind_method(D_METHOD("set_global_scale", "scale"), &Node2D::set_global_scale); ClassDB::bind_method(D_METHOD("get_global_scale"), &Node2D::get_global_scale); @@ -455,20 +433,20 @@ void Node2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_z_as_relative", "enable"), &Node2D::set_z_as_relative); ClassDB::bind_method(D_METHOD("is_z_relative"), &Node2D::is_z_relative); - ClassDB::bind_method(D_METHOD("edit_set_pivot", "pivot"), &Node2D::edit_set_pivot); + ClassDB::bind_method(D_METHOD("_edit_set_pivot", "pivot"), &Node2D::_edit_set_pivot); ClassDB::bind_method(D_METHOD("get_relative_transform_to_parent", "parent"), &Node2D::get_relative_transform_to_parent); ADD_GROUP("Transform", ""); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "position"), "set_position", "get_position"); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_rotation", "get_rotation"); - ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation_deg", PROPERTY_HINT_RANGE, "-1440,1440,0.1", PROPERTY_USAGE_EDITOR), "set_rotation_in_degrees", "get_rotation_in_degrees"); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rotation_degrees", PROPERTY_HINT_RANGE, "-1440,1440,0.1", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "transform", PROPERTY_HINT_NONE, "", 0), "set_transform", "get_transform"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_position", PROPERTY_HINT_NONE, "", 0), "set_global_position", "get_global_position"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation", PROPERTY_HINT_NONE, "", 0), "set_global_rotation", "get_global_rotation"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation_deg", PROPERTY_HINT_NONE, "", 0), "set_global_rotation_in_degrees", "get_global_rotation_in_degrees"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_rotation_degrees", PROPERTY_HINT_NONE, "", 0), "set_global_rotation_degrees", "get_global_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "global_scale", PROPERTY_HINT_NONE, "", 0), "set_global_scale", "get_global_scale"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM2D, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform"); diff --git a/scene/2d/node_2d.h b/scene/2d/node_2d.h index 19aafc81ff..e1e07f2895 100644 --- a/scene/2d/node_2d.h +++ b/scene/2d/node_2d.h @@ -48,10 +48,6 @@ class Node2D : public CanvasItem { void _update_transform(); - // Deprecated, should be removed in a future version. - void _set_rotd(float p_degrees); - float _get_rotd() const; - void _update_xform_values(); protected: @@ -60,17 +56,20 @@ protected: static void _bind_methods(); public: - virtual Variant edit_get_state() const; - virtual void edit_set_state(const Variant &p_state); - virtual void edit_set_rect(const Rect2 &p_edit_rect); - virtual void edit_rotate(float p_rot); - virtual void edit_set_pivot(const Point2 &p_pivot); - virtual Point2 edit_get_pivot() const; - virtual bool edit_has_pivot() const; + virtual Dictionary _edit_get_state() const; + virtual void _edit_set_state(const Dictionary &p_state); + + virtual void _edit_set_position(const Point2 &p_position); + virtual Point2 _edit_get_position() const; + virtual void _edit_set_rect(const Rect2 &p_edit_rect); + virtual bool _edit_use_rect() const; + virtual void _edit_set_rotation(float p_rotation); + virtual float _edit_get_rotation() const; + virtual bool _edit_use_rotation() const; void set_position(const Point2 &p_pos); void set_rotation(float p_radians); - void set_rotation_in_degrees(float p_degrees); + void set_rotation_degrees(float p_degrees); void set_scale(const Size2 &p_scale); void rotate(float p_radians); @@ -82,20 +81,19 @@ public: Point2 get_position() const; float get_rotation() const; - float get_rotation_in_degrees() const; + float get_rotation_degrees() const; Size2 get_scale() const; Point2 get_global_position() const; float get_global_rotation() const; - float get_global_rotation_in_degrees() const; + float get_global_rotation_degrees() const; Size2 get_global_scale() const; - virtual Rect2 get_item_rect() const; void set_transform(const Transform2D &p_transform); void set_global_transform(const Transform2D &p_transform); void set_global_position(const Point2 &p_pos); void set_global_rotation(float p_radians); - void set_global_rotation_in_degrees(float p_degrees); + void set_global_rotation_degrees(float p_degrees); void set_global_scale(const Size2 &p_scale); void set_z(int p_z); diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index c146ac08c2..aee5d89150 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -77,7 +77,7 @@ void Particles2D::set_randomness_ratio(float p_ratio) { void Particles2D::set_visibility_rect(const Rect2 &p_aabb) { visibility_rect = p_aabb; - Rect3 aabb; + AABB aabb; aabb.position.x = p_aabb.position.x; aabb.position.y = p_aabb.position.y; aabb.size.x = p_aabb.size.x; @@ -223,7 +223,7 @@ String Particles2D::get_configuration_warning() const { Rect2 Particles2D::capture_rect() const { - Rect3 aabb = VS::get_singleton()->particles_get_current_aabb(particles); + AABB aabb = VS::get_singleton()->particles_get_current_aabb(particles); Rect2 r; r.position.x = aabb.position.x; r.position.y = aabb.position.y; @@ -378,7 +378,7 @@ void Particles2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1"), "set_fixed_fps", "get_fixed_fps"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta"); ADD_GROUP("Drawing", ""); - ADD_PROPERTY(PropertyInfo(Variant::RECT3, "visibility_rect"), "set_visibility_rect", "get_visibility_rect"); + ADD_PROPERTY(PropertyInfo(Variant::AABB, "visibility_rect"), "set_visibility_rect", "get_visibility_rect"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates"); ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime"), "set_draw_order", "get_draw_order"); ADD_GROUP("Process Material", "process_"); diff --git a/scene/2d/path_2d.cpp b/scene/2d/path_2d.cpp index 8413be1ca9..55c055e34f 100644 --- a/scene/2d/path_2d.cpp +++ b/scene/2d/path_2d.cpp @@ -107,28 +107,39 @@ void PathFollow2D::_update_transform() { if (!c.is_valid()) return; + if (delta_offset == 0) { + return; + } + float o = offset; if (loop) o = Math::fposmod(o, c->get_baked_length()); Vector2 pos = c->interpolate_baked(o, cubic); + Vector2 offset = Vector2(h_offset, v_offset); + + Transform2D t = get_transform(); + t.set_origin(pos); + if (rotate) { - Vector2 n = (c->interpolate_baked(o + lookahead, cubic) - pos).normalized(); - Vector2 t = -n.tangent(); - pos += n * h_offset; - pos += t * v_offset; + Vector2 t_prev = (pos - c->interpolate_baked(o - delta_offset, cubic)).normalized(); + Vector2 t_cur = (c->interpolate_baked(o + delta_offset, cubic) - pos).normalized(); + + float dot = t_prev.dot(t_cur); + float angle = Math::acos(CLAMP(dot, -1, 1)); + + t.rotate(angle); - set_rotation(t.angle()); + t.translate(offset); } else { - pos.x += h_offset; - pos.y += v_offset; + t.set_origin(t.get_origin() + offset); } - set_position(pos); + set_transform(t); } void PathFollow2D::_notification(int p_what) { @@ -176,8 +187,6 @@ bool PathFollow2D::_set(const StringName &p_name, const Variant &p_value) { set_cubic_interpolation(p_value); } else if (String(p_name) == "loop") { set_loop(p_value); - } else if (String(p_name) == "lookahead") { - set_lookahead(p_value); } else return false; @@ -200,8 +209,6 @@ bool PathFollow2D::_get(const StringName &p_name, Variant &r_ret) const { r_ret = cubic; } else if (String(p_name) == "loop") { r_ret = loop; - } else if (String(p_name) == "lookahead") { - r_ret = lookahead; } else return false; @@ -219,7 +226,6 @@ void PathFollow2D::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::BOOL, "rotate")); p_list->push_back(PropertyInfo(Variant::BOOL, "cubic_interp")); p_list->push_back(PropertyInfo(Variant::BOOL, "loop")); - p_list->push_back(PropertyInfo(Variant::REAL, "lookahead", PROPERTY_HINT_RANGE, "0.001,1024.0,0.001")); } String PathFollow2D::get_configuration_warning() const { @@ -259,7 +265,7 @@ void PathFollow2D::_bind_methods() { } void PathFollow2D::set_offset(float p_offset) { - + delta_offset = p_offset - offset; offset = p_offset; if (path) _update_transform(); @@ -310,16 +316,6 @@ float PathFollow2D::get_unit_offset() const { return 0; } -void PathFollow2D::set_lookahead(float p_lookahead) { - - lookahead = p_lookahead; -} - -float PathFollow2D::get_lookahead() const { - - return lookahead; -} - void PathFollow2D::set_rotate(bool p_rotate) { rotate = p_rotate; @@ -344,11 +340,11 @@ bool PathFollow2D::has_loop() const { PathFollow2D::PathFollow2D() { offset = 0; + delta_offset = 0; h_offset = 0; v_offset = 0; path = NULL; rotate = true; cubic = true; loop = true; - lookahead = 4; } diff --git a/scene/2d/path_2d.h b/scene/2d/path_2d.h index 88a0abdea9..f5ba3a3d32 100644 --- a/scene/2d/path_2d.h +++ b/scene/2d/path_2d.h @@ -60,9 +60,9 @@ public: private: Path2D *path; real_t offset; + real_t delta_offset; // change in offset since last _update_transform real_t h_offset; real_t v_offset; - real_t lookahead; bool cubic; bool loop; bool rotate; @@ -90,9 +90,6 @@ public: void set_unit_offset(float p_unit_offset); float get_unit_offset() const; - void set_lookahead(float p_lookahead); - float get_lookahead() const; - void set_loop(bool p_loop); bool has_loop() const; diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index f0ee64a53f..1f6127e6eb 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -133,8 +133,9 @@ bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const { } PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) - : CollisionObject2D(Physics2DServer::get_singleton()->body_create(p_mode), false) { + : CollisionObject2D(Physics2DServer::get_singleton()->body_create(), false) { + Physics2DServer::get_singleton()->body_set_mode(get_rid(), p_mode); collision_layer = 1; collision_mask = 1; set_pickable(false); @@ -1027,7 +1028,10 @@ Vector2 KinematicBody2D::move_and_slide(const Vector2 &p_linear_velocity, const on_floor = true; floor_velocity = collision.collider_vel; - if (collision.travel.length() < 1 && ABS((lv.x - floor_velocity.x)) < p_slope_stop_min_velocity) { + Vector2 rel_v = lv - floor_velocity; + Vector2 hv = rel_v - p_floor_direction * p_floor_direction.dot(rel_v); + + if (collision.travel.length() < 1 && hv.length() < p_slope_stop_min_velocity) { Transform2D gt = get_global_transform(); gt.elements[2] -= collision.travel; set_global_transform(gt); diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 197c74352e..3f2ad19e51 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -29,7 +29,7 @@ /*************************************************************************/ #include "polygon_2d.h" -Rect2 Polygon2D::get_item_rect() const { +Rect2 Polygon2D::_edit_get_rect() const { if (rect_cache_dirty) { int l = polygon.size(); @@ -49,16 +49,16 @@ Rect2 Polygon2D::get_item_rect() const { return item_rect; } -void Polygon2D::edit_set_pivot(const Point2 &p_pivot) { +void Polygon2D::_edit_set_pivot(const Point2 &p_pivot) { set_offset(p_pivot); } -Point2 Polygon2D::edit_get_pivot() const { +Point2 Polygon2D::_edit_get_pivot() const { return get_offset(); } -bool Polygon2D::edit_has_pivot() const { +bool Polygon2D::_edit_use_pivot() const { return true; } @@ -264,11 +264,11 @@ float Polygon2D::get_texture_rotation() const { return tex_rot; } -void Polygon2D::_set_texture_rotationd(float p_rot) { +void Polygon2D::set_texture_rotation_degrees(float p_rot) { set_texture_rotation(Math::deg2rad(p_rot)); } -float Polygon2D::_get_texture_rotationd() const { +float Polygon2D::get_texture_rotation_degrees() const { return Math::rad2deg(get_texture_rotation()); } @@ -348,8 +348,8 @@ void Polygon2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture_rotation", "texture_rotation"), &Polygon2D::set_texture_rotation); ClassDB::bind_method(D_METHOD("get_texture_rotation"), &Polygon2D::get_texture_rotation); - ClassDB::bind_method(D_METHOD("_set_texture_rotationd", "texture_rotation"), &Polygon2D::_set_texture_rotationd); - ClassDB::bind_method(D_METHOD("_get_texture_rotationd"), &Polygon2D::_get_texture_rotationd); + ClassDB::bind_method(D_METHOD("set_texture_rotation_degrees", "texture_rotation"), &Polygon2D::set_texture_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_texture_rotation_degrees"), &Polygon2D::get_texture_rotation_degrees); ClassDB::bind_method(D_METHOD("set_texture_scale", "texture_scale"), &Polygon2D::set_texture_scale); ClassDB::bind_method(D_METHOD("get_texture_scale"), &Polygon2D::get_texture_scale); @@ -377,7 +377,7 @@ void Polygon2D::_bind_methods() { ADD_GROUP("Texture", "texture_"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_offset"), "set_texture_offset", "get_texture_offset"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_scale"), "set_texture_scale", "get_texture_scale"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation", PROPERTY_HINT_RANGE, "-1440,1440,0.1"), "_set_texture_rotationd", "_get_texture_rotationd"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "texture_rotation", PROPERTY_HINT_RANGE, "-1440,1440,0.1"), "set_texture_rotation_degrees", "get_texture_rotation_degrees"); ADD_GROUP("Invert", "invert_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "invert_enable"), "set_invert", "get_invert"); diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index 20c3324a50..d09e22f5ff 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -53,9 +53,6 @@ class Polygon2D : public Node2D { mutable bool rect_cache_dirty; mutable Rect2 item_rect; - void _set_texture_rotationd(float p_rot); - float _get_texture_rotationd() const; - protected: void _notification(int p_what); static void _bind_methods(); @@ -82,6 +79,9 @@ public: void set_texture_rotation(float p_rot); float get_texture_rotation() const; + void set_texture_rotation_degrees(float p_rot); + float get_texture_rotation_degrees() const; + void set_texture_scale(const Size2 &p_scale); Size2 get_texture_scale() const; @@ -99,11 +99,11 @@ public: //editor stuff - virtual void edit_set_pivot(const Point2 &p_pivot); - virtual Point2 edit_get_pivot() const; - virtual bool edit_has_pivot() const; + virtual void _edit_set_pivot(const Point2 &p_pivot); + virtual Point2 _edit_get_pivot() const; + virtual bool _edit_use_pivot() const; - virtual Rect2 get_item_rect() const; + virtual Rect2 _edit_get_rect() const; Polygon2D(); }; diff --git a/scene/2d/position_2d.cpp b/scene/2d/position_2d.cpp index cde665d422..1e729bc179 100644 --- a/scene/2d/position_2d.cpp +++ b/scene/2d/position_2d.cpp @@ -38,7 +38,7 @@ void Position2D::_draw_cross() { draw_line(Point2(0, -10), Point2(0, +10), Color(0.5, 1, 0.5)); } -Rect2 Position2D::get_item_rect() const { +Rect2 Position2D::_edit_get_rect() const { return Rect2(Point2(-10, -10), Size2(20, 20)); } diff --git a/scene/2d/position_2d.h b/scene/2d/position_2d.h index af54fb919a..5961e447df 100644 --- a/scene/2d/position_2d.h +++ b/scene/2d/position_2d.h @@ -42,7 +42,7 @@ protected: void _notification(int p_what); public: - virtual Rect2 get_item_rect() const; + virtual Rect2 _edit_get_rect() const; Position2D(); }; diff --git a/scene/2d/screen_button.cpp b/scene/2d/screen_button.cpp index bf7c5a3ba4..d5fcda90d5 100644 --- a/scene/2d/screen_button.cpp +++ b/scene/2d/screen_button.cpp @@ -133,7 +133,7 @@ void TouchScreenButton::_notification(int p_what) { return; if (shape.is_valid()) { Color draw_col = get_tree()->get_debug_collisions_color(); - Vector2 pos = shape_centered ? get_item_rect().size * 0.5f : Vector2(); + Vector2 pos = shape_centered ? _edit_get_rect().size * 0.5f : Vector2(); draw_set_transform_matrix(get_canvas_transform().translated(pos)); shape->draw(get_canvas_item(), draw_col); } @@ -251,7 +251,7 @@ void TouchScreenButton::_input(const Ref<InputEvent> &p_event) { bool TouchScreenButton::_is_point_inside(const Point2 &p_point) { Point2 coord = (get_global_transform_with_canvas()).affine_inverse().xform(p_point); - Rect2 item_rect = get_item_rect(); + Rect2 item_rect = _edit_get_rect(); bool touched = false; bool check_rect = true; @@ -322,13 +322,13 @@ void TouchScreenButton::_release(bool p_exiting_tree) { } } -Rect2 TouchScreenButton::get_item_rect() const { +Rect2 TouchScreenButton::_edit_get_rect() const { if (texture.is_null()) return Rect2(0, 0, 1, 1); /* if (texture.is_null()) - return CanvasItem::get_item_rect(); + return CanvasItem::_edit_get_rect(); */ return Rect2(Size2(), texture->get_size()); diff --git a/scene/2d/screen_button.h b/scene/2d/screen_button.h index 7647070b26..2e674c20b4 100644 --- a/scene/2d/screen_button.h +++ b/scene/2d/screen_button.h @@ -102,7 +102,7 @@ public: bool is_pressed() const; - Rect2 get_item_rect() const; + Rect2 _edit_get_rect() const; TouchScreenButton(); }; diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index c53faab5f9..df2265aae9 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -33,16 +33,16 @@ #include "scene/main/viewport.h" #include "scene/scene_string_names.h" -void Sprite::edit_set_pivot(const Point2 &p_pivot) { +void Sprite::_edit_set_pivot(const Point2 &p_pivot) { set_offset(p_pivot); } -Point2 Sprite::edit_get_pivot() const { +Point2 Sprite::_edit_get_pivot() const { return get_offset(); } -bool Sprite::edit_has_pivot() const { +bool Sprite::_edit_use_pivot() const { return true; } @@ -257,13 +257,13 @@ int Sprite::get_hframes() const { return hframes; } -Rect2 Sprite::get_item_rect() const { +Rect2 Sprite::_edit_get_rect() const { if (texture.is_null()) return Rect2(0, 0, 1, 1); /* if (texture.is_null()) - return CanvasItem::get_item_rect(); + return CanvasItem::_edit_get_rect(); */ Size2i s; @@ -368,224 +368,3 @@ Sprite::Sprite() { vframes = 1; hframes = 1; } - -//////////////////////////// VPSPRITE -/// -/// -/// - -#if 0 -void ViewportSprite::edit_set_pivot(const Point2& p_pivot) { - - set_offset(p_pivot); -} - -Point2 ViewportSprite::edit_get_pivot() const { - - return get_offset(); -} -bool ViewportSprite::edit_has_pivot() const { - - return true; -} - -void ViewportSprite::_notification(int p_what) { - - switch(p_what) { - - case NOTIFICATION_ENTER_TREE: { - - if (!viewport_path.is_empty()) { - - Node *n = get_node(viewport_path); - ERR_FAIL_COND(!n); - Viewport *vp=Object::cast_to<Viewport>(n); - ERR_FAIL_COND(!vp); - - Ref<RenderTargetTexture> rtt = vp->get_render_target_texture(); - texture=rtt; - texture->connect("changed",this,"update"); - item_rect_changed(); - } - } break; - case NOTIFICATION_EXIT_TREE: { - - if (texture.is_valid()) { - - texture->disconnect("changed",this,"update"); - texture=Ref<Texture>(); - } - } break; - case NOTIFICATION_DRAW: { - - if (texture.is_null()) - return; - - RID ci = get_canvas_item(); - - /* - texture->draw(ci,Point2()); - break; - */ - - Size2i s; - Rect2i src_rect; - - s = texture->get_size(); - - src_rect.size=s; - - Point2 ofs=offset; - if (centered) - ofs-=s/2; - - if (OS::get_singleton()->get_use_pixel_snap()) { - ofs=ofs.floor(); - } - Rect2 dst_rect(ofs,s); - texture->draw_rect_region(ci,dst_rect,src_rect,modulate); - - } break; - } -} - -void ViewportSprite::set_viewport_path(const NodePath& p_viewport) { - - viewport_path=p_viewport; - update(); - if (!is_inside_tree()) - return; - - if (texture.is_valid()) { - texture->disconnect("changed",this,"update"); - texture=Ref<Texture>(); - } - - if (viewport_path.is_empty()) - return; - - - Node *n = get_node(viewport_path); - ERR_FAIL_COND(!n); - Viewport *vp=Object::cast_to<Viewport>(n); - ERR_FAIL_COND(!vp); - - Ref<RenderTargetTexture> rtt = vp->get_render_target_texture(); - texture=rtt; - - if (texture.is_valid()) { - texture->connect("changed",this,"update"); - } - - item_rect_changed(); - -} - -NodePath ViewportSprite::get_viewport_path() const { - - return viewport_path; -} - -void ViewportSprite::set_centered(bool p_center) { - - centered=p_center; - update(); - item_rect_changed(); -} - -bool ViewportSprite::is_centered() const { - - return centered; -} - -void ViewportSprite::set_offset(const Point2& p_offset) { - - offset=p_offset; - update(); - item_rect_changed(); -} -Point2 ViewportSprite::get_offset() const { - - return offset; -} -void ViewportSprite::set_modulate(const Color& p_color) { - - modulate=p_color; - update(); -} - -Color ViewportSprite::get_modulate() const{ - - return modulate; -} - - -Rect2 ViewportSprite::get_item_rect() const { - - if (texture.is_null()) - return Rect2(0,0,1,1); - /* - if (texture.is_null()) - return CanvasItem::get_item_rect(); - */ - - Size2i s; - - s = texture->get_size(); - Point2 ofs=offset; - if (centered) - ofs-=s/2; - - if (s==Size2(0,0)) - s=Size2(1,1); - - return Rect2(ofs,s); -} - -String ViewportSprite::get_configuration_warning() const { - - if (!has_node(viewport_path) || !Object::cast_to<Viewport>(get_node(viewport_path))) { - return TTR("Path property must point to a valid Viewport node to work. Such Viewport must be set to 'render target' mode."); - } else { - - Node *n = get_node(viewport_path); - if (n) { - Viewport *vp = Object::cast_to<Viewport>(n); - if (!vp->is_set_as_render_target()) { - - return TTR("The Viewport set in the path property must be set as 'render target' in order for this sprite to work."); - } - } - } - - return String(); - -} - -void ViewportSprite::_bind_methods() { - - ClassDB::bind_method(D_METHOD("set_viewport_path","path"),&ViewportSprite::set_viewport_path); - ClassDB::bind_method(D_METHOD("get_viewport_path"),&ViewportSprite::get_viewport_path); - - ClassDB::bind_method(D_METHOD("set_centered","centered"),&ViewportSprite::set_centered); - ClassDB::bind_method(D_METHOD("is_centered"),&ViewportSprite::is_centered); - - ClassDB::bind_method(D_METHOD("set_offset","offset"),&ViewportSprite::set_offset); - ClassDB::bind_method(D_METHOD("get_offset"),&ViewportSprite::get_offset); - - ClassDB::bind_method(D_METHOD("set_modulate","modulate"),&ViewportSprite::set_modulate); - ClassDB::bind_method(D_METHOD("get_modulate"),&ViewportSprite::get_modulate); - - ADD_PROPERTYNZ( PropertyInfo( Variant::NODE_PATH, "viewport"), "set_viewport_path","get_viewport_path"); - ADD_PROPERTYNO( PropertyInfo( Variant::BOOL, "centered"), "set_centered","is_centered"); - ADD_PROPERTYNZ( PropertyInfo( Variant::VECTOR2, "offset"), "set_offset","get_offset"); - ADD_PROPERTYNO( PropertyInfo( Variant::COLOR, "modulate"), "set_modulate","get_modulate"); - -} - -ViewportSprite::ViewportSprite() { - - centered=true; - modulate=Color(1,1,1,1); -} -#endif diff --git a/scene/2d/sprite.h b/scene/2d/sprite.h index 64d30325f2..1bef73c0a5 100644 --- a/scene/2d/sprite.h +++ b/scene/2d/sprite.h @@ -62,9 +62,10 @@ protected: virtual void _validate_property(PropertyInfo &property) const; public: - virtual void edit_set_pivot(const Point2 &p_pivot); - virtual Point2 edit_get_pivot() const; - virtual bool edit_has_pivot() const; + virtual void _edit_set_pivot(const Point2 &p_pivot); + virtual Point2 _edit_get_pivot() const; + virtual bool _edit_use_pivot() const; + virtual Rect2 _edit_get_rect() const; void set_texture(const Ref<Texture> &p_texture); Ref<Texture> get_texture() const; @@ -102,53 +103,7 @@ public: void set_hframes(int p_amount); int get_hframes() const; - virtual Rect2 get_item_rect() const; - Sprite(); }; -#if 0 -class ViewportSprite : public Node2D { - - GDCLASS( ViewportSprite, Node2D ); - - Ref<Texture> texture; - NodePath viewport_path; - - bool centered; - Point2 offset; - Color modulate; - -protected: - - void _notification(int p_what); - - static void _bind_methods(); - -public: - - virtual void edit_set_pivot(const Point2& p_pivot); - virtual Point2 edit_get_pivot() const; - virtual bool edit_has_pivot() const; - - void set_viewport_path(const NodePath& p_viewport); - NodePath get_viewport_path() const; - - void set_centered(bool p_center); - bool is_centered() const; - - void set_offset(const Point2& p_offset); - Point2 get_offset() const; - - void set_modulate(const Color& p_color); - Color get_modulate() const; - - virtual Rect2 get_item_rect() const; - - virtual String get_configuration_warning() const; - - ViewportSprite(); -}; - -#endif #endif // SPRITE_H diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 4286d88ab1..f067b5a187 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -448,21 +448,20 @@ void TileMap::_update_dirty_quadrants() { if (r == Rect2()) { tex->draw_rect(canvas_item, rect, false, modulate, c.transpose, normal_map); } else { - tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map); + tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map, clip_uv); } Vector<TileSet::ShapeData> shapes = tile_set->tile_get_shapes(c.id); for (int i = 0; i < shapes.size(); i++) { - Ref<Shape2D> shape = shapes[i].shape; if (shape.is_valid()) { Transform2D xform; xform.set_origin(offset.floor()); - _fix_cell_transform(xform, c, center_ofs, s); + Vector2 shape_ofs = tile_set->tile_get_shape_offset(c.id, i); - xform *= shapes[i].shape_transform; + _fix_cell_transform(xform, c, shape_ofs + center_ofs, s); if (debug_canvas_item.is_valid()) { vs->canvas_item_add_set_transform(debug_canvas_item, xform); @@ -587,7 +586,9 @@ Map<TileMap::PosKey, TileMap::Quadrant>::Element *TileMap::_create_quadrant(cons xform.set_origin(q.pos); //q.canvas_item = VisualServer::get_singleton()->canvas_item_create(); - q.body = Physics2DServer::get_singleton()->body_create(use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC); + q.body = Physics2DServer::get_singleton()->body_create(); + Physics2DServer::get_singleton()->body_set_mode(q.body, use_kinematic ? Physics2DServer::BODY_MODE_KINEMATIC : Physics2DServer::BODY_MODE_STATIC); + Physics2DServer::get_singleton()->body_attach_object_instance_id(q.body, get_instance_id()); Physics2DServer::get_singleton()->body_set_collision_layer(q.body, collision_layer); Physics2DServer::get_singleton()->body_set_collision_mask(q.body, collision_mask); @@ -882,7 +883,7 @@ PoolVector<int> TileMap::_get_tile_data() const { return data; } -Rect2 TileMap::get_item_rect() const { +Rect2 TileMap::_edit_get_rect() const { const_cast<TileMap *>(this)->_update_dirty_quadrants(); return rect_cache; @@ -1234,6 +1235,21 @@ void TileMap::set_light_mask(int p_light_mask) { } } +void TileMap::set_clip_uv(bool p_enable) { + + if (clip_uv == p_enable) + return; + + _clear_quadrants(); + clip_uv = p_enable; + _recreate_quadrants(); +} + +bool TileMap::get_clip_uv() const { + + return clip_uv; +} + void TileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_tileset", "tileset"), &TileMap::set_tileset); @@ -1266,6 +1282,9 @@ void TileMap::_bind_methods() { ClassDB::bind_method(D_METHOD("set_center_y", "enable"), &TileMap::set_center_y); ClassDB::bind_method(D_METHOD("get_center_y"), &TileMap::get_center_y); + ClassDB::bind_method(D_METHOD("set_clip_uv", "enable"), &TileMap::set_clip_uv); + ClassDB::bind_method(D_METHOD("get_clip_uv"), &TileMap::get_clip_uv); + ClassDB::bind_method(D_METHOD("set_y_sort_mode", "enable"), &TileMap::set_y_sort_mode); ClassDB::bind_method(D_METHOD("is_y_sort_mode_enabled"), &TileMap::is_y_sort_mode_enabled); @@ -1327,6 +1346,7 @@ void TileMap::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_half_offset", PROPERTY_HINT_ENUM, "Offset X,Offset Y,Disabled"), "set_half_offset", "get_half_offset"); ADD_PROPERTY(PropertyInfo(Variant::INT, "cell_tile_origin", PROPERTY_HINT_ENUM, "Top Left,Center,Bottom Left"), "set_tile_origin", "get_tile_origin"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_y_sort"), "set_y_sort_mode", "is_y_sort_mode_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "cell_clip_uv"), "set_clip_uv", "get_clip_uv"); ADD_GROUP("Collision", "collision_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "collision_use_kinematic", PROPERTY_HINT_NONE, ""), "set_collision_use_kinematic", "get_collision_use_kinematic"); @@ -1377,6 +1397,7 @@ TileMap::TileMap() { navigation = NULL; y_sort_mode = false; occluder_light_mask = 1; + clip_uv = false; fp_adjust = 0.00001; tile_origin = TILE_ORIGIN_TOP_LEFT; diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index c9d14e09d1..9e14ec838a 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -161,6 +161,7 @@ private: bool used_size_cache_dirty; bool quadrant_order_dirty; bool y_sort_mode; + bool clip_uv; float fp_adjust; float friction; float bounce; @@ -228,7 +229,7 @@ public: void set_cellv(const Vector2 &p_pos, int p_tile, bool p_flip_x = false, bool p_flip_y = false, bool p_transpose = false); int get_cellv(const Vector2 &p_pos) const; - Rect2 get_item_rect() const; + Rect2 _edit_get_rect() const; void set_collision_layer(uint32_t p_layer); uint32_t get_collision_layer() const; @@ -285,6 +286,9 @@ public: virtual void set_use_parent_material(bool p_use_parent_material); + void set_clip_uv(bool p_enable); + bool get_clip_uv() const; + void clear(); TileMap(); diff --git a/scene/2d/visibility_notifier_2d.cpp b/scene/2d/visibility_notifier_2d.cpp index b0fd57baf5..298bc2649e 100644 --- a/scene/2d/visibility_notifier_2d.cpp +++ b/scene/2d/visibility_notifier_2d.cpp @@ -83,7 +83,7 @@ void VisibilityNotifier2D::set_rect(const Rect2 &p_rect) { _change_notify("rect"); } -Rect2 VisibilityNotifier2D::get_item_rect() const { +Rect2 VisibilityNotifier2D::_edit_get_rect() const { return rect; } diff --git a/scene/2d/visibility_notifier_2d.h b/scene/2d/visibility_notifier_2d.h index ee5152978b..6e06833912 100644 --- a/scene/2d/visibility_notifier_2d.h +++ b/scene/2d/visibility_notifier_2d.h @@ -54,13 +54,13 @@ protected: static void _bind_methods(); public: + virtual Rect2 _edit_get_rect() const; + void set_rect(const Rect2 &p_rect); Rect2 get_rect() const; bool is_on_screen() const; - virtual Rect2 get_item_rect() const; - VisibilityNotifier2D(); }; diff --git a/scene/3d/collision_polygon.cpp b/scene/3d/collision_polygon.cpp index 382cbb8f38..a6d812efec 100644 --- a/scene/3d/collision_polygon.cpp +++ b/scene/3d/collision_polygon.cpp @@ -117,7 +117,7 @@ Vector<Point2> CollisionPolygon::get_polygon() const { return polygon; } -Rect3 CollisionPolygon::get_item_rect() const { +AABB CollisionPolygon::get_item_rect() const { return aabb; } @@ -176,7 +176,7 @@ void CollisionPolygon::_bind_methods() { CollisionPolygon::CollisionPolygon() { - aabb = Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2)); + aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); depth = 1.0; set_notify_local_transform(true); parent = NULL; diff --git a/scene/3d/collision_polygon.h b/scene/3d/collision_polygon.h index dbed1d7154..14d8c3aba6 100644 --- a/scene/3d/collision_polygon.h +++ b/scene/3d/collision_polygon.h @@ -40,7 +40,7 @@ class CollisionPolygon : public Spatial { protected: float depth; - Rect3 aabb; + AABB aabb; Vector<Point2> polygon; uint32_t owner_id; @@ -64,7 +64,7 @@ public: void set_disabled(bool p_disabled); bool is_disabled() const; - virtual Rect3 get_item_rect() const; + virtual AABB get_item_rect() const; String get_configuration_warning() const; diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index c0ca358717..05d5d52d28 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -31,12 +31,12 @@ #include "mesh_instance.h" -void GIProbeData::set_bounds(const Rect3 &p_bounds) { +void GIProbeData::set_bounds(const AABB &p_bounds) { VS::get_singleton()->gi_probe_set_bounds(probe, p_bounds); } -Rect3 GIProbeData::get_bounds() const { +AABB GIProbeData::get_bounds() const { return VS::get_singleton()->gi_probe_get_bounds(probe); } @@ -180,7 +180,7 @@ void GIProbeData::_bind_methods() { ClassDB::bind_method(D_METHOD("set_compress", "compress"), &GIProbeData::set_compress); ClassDB::bind_method(D_METHOD("is_compressed"), &GIProbeData::is_compressed); - ADD_PROPERTY(PropertyInfo(Variant::RECT3, "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_bounds", "get_bounds"); + ADD_PROPERTY(PropertyInfo(Variant::AABB, "bounds", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_bounds", "get_bounds"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "cell_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_cell_size", "get_cell_size"); ADD_PROPERTY(PropertyInfo(Variant::TRANSFORM, "to_cell_xform", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_to_cell_xform", "get_to_cell_xform"); @@ -410,7 +410,7 @@ static bool planeBoxOverlap(Vector3 normal, float d, Vector3 maxbox) { rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \ if (min > rad || max < -rad) return false; -/*======================== Z-tests ========================*/ + /*======================== Z-tests ========================*/ #define AXISTEST_Z12(a, b, fa, fb) \ p1 = a * v1.x - b * v1.y; \ @@ -542,7 +542,7 @@ static _FORCE_INLINE_ Vector2 get_uv(const Vector3 &p_pos, const Vector3 *p_vtx, return p_uv[0] * u + p_uv[1] * v + p_uv[2] * w; } -void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const Rect3 &p_aabb, Baker *p_baker) { +void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const AABB &p_aabb, Baker *p_baker) { if (p_level == p_baker->cell_subdiv - 1) { //plot the face by guessing it's albedo and emission value @@ -702,7 +702,7 @@ void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, cons int half = (1 << (p_baker->cell_subdiv - 1)) >> (p_level + 1); for (int i = 0; i < 8; i++) { - Rect3 aabb = p_aabb; + AABB aabb = p_aabb; aabb.size *= 0.5; int nx = p_x; @@ -726,7 +726,7 @@ void GIProbe::_plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, cons continue; { - Rect3 test_aabb = aabb; + AABB test_aabb = aabb; //test_aabb.grow_by(test_aabb.get_longest_axis_size()*0.05); //grow a bit to avoid numerical error in real-time Vector3 qsize = test_aabb.size * 0.5; //quarter size, for fast aabb test @@ -891,7 +891,7 @@ void GIProbe::_fixup_plot(int p_idx, int p_level, int p_x, int p_y, int p_z, Bak } } -Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_color) { +Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_color_mul, const Color &p_color_add) { Vector<Color> ret; @@ -899,7 +899,7 @@ Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_colo ret.resize(bake_texture_size * bake_texture_size); for (int i = 0; i < bake_texture_size * bake_texture_size; i++) { - ret[i] = p_color; + ret[i] = p_color_add; } return ret; @@ -919,9 +919,10 @@ Vector<Color> GIProbe::_get_bake_texture(Ref<Image> p_image, const Color &p_colo for (int i = 0; i < bake_texture_size * bake_texture_size; i++) { Color c; - c.r = (r[i * 4 + 0] / 255.0) * p_color.r; - c.g = (r[i * 4 + 1] / 255.0) * p_color.g; - c.b = (r[i * 4 + 2] / 255.0) * p_color.b; + c.r = (r[i * 4 + 0] / 255.0) * p_color_mul.r + p_color_add.r; + c.g = (r[i * 4 + 1] / 255.0) * p_color_mul.g + p_color_add.g; + c.b = (r[i * 4 + 2] / 255.0) * p_color_mul.b + p_color_add.b; + c.a = r[i * 4 + 3] / 255.0; ret[i] = c; @@ -951,17 +952,15 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater if (albedo_tex.is_valid()) { img_albedo = albedo_tex->get_data(); + mc.albedo = _get_bake_texture(img_albedo, mat->get_albedo(), Color(0, 0, 0)); // albedo texture, color is multiplicative } else { + mc.albedo = _get_bake_texture(img_albedo, Color(1, 1, 1), mat->get_albedo()); // no albedo texture, color is additive } - mc.albedo = _get_bake_texture(img_albedo, mat->get_albedo()); - - Ref<ImageTexture> emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION); + Ref<Texture> emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION); Color emission_col = mat->get_emission(); - emission_col.r *= mat->get_emission_energy(); - emission_col.g *= mat->get_emission_energy(); - emission_col.b *= mat->get_emission_energy(); + float emission_energy = mat->get_emission_energy(); Ref<Image> img_emission; @@ -970,13 +969,17 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref<Material> p_mater img_emission = emission_tex->get_data(); } - mc.emission = _get_bake_texture(img_emission, emission_col); + if (mat->get_emission_operator() == SpatialMaterial::EMISSION_OP_ADD) { + mc.emission = _get_bake_texture(img_emission, Color(1, 1, 1) * emission_energy, emission_col * emission_energy); + } else { + mc.emission = _get_bake_texture(img_emission, emission_col * emission_energy, Color(0, 0, 0)); + } } else { Ref<Image> empty; - mc.albedo = _get_bake_texture(empty, Color(0.7, 0.7, 0.7)); - mc.emission = _get_bake_texture(empty, Color(0, 0, 0)); + mc.albedo = _get_bake_texture(empty, Color(0, 0, 0), Color(1, 1, 1)); + mc.emission = _get_bake_texture(empty, Color(0, 0, 0), Color(0, 0, 0)); } p_baker->material_cache[p_material] = mc; @@ -1080,11 +1083,11 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) { Ref<Mesh> mesh = mi->get_mesh(); if (mesh.is_valid()) { - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); Transform xf = get_global_transform().affine_inverse() * mi->get_global_transform(); - if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) { + if (AABB(-extents, extents * 2).intersects(xf.xform(aabb))) { Baker::PlotMesh pm; pm.local_xform = xf; pm.mesh = mesh; @@ -1110,11 +1113,11 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) { if (!mesh.is_valid()) continue; - Rect3 aabb = mesh->get_aabb(); + AABB aabb = mesh->get_aabb(); Transform xf = get_global_transform().affine_inverse() * (s->get_global_transform() * mxf); - if (Rect3(-extents, extents * 2).intersects(xf.xform(aabb))) { + if (AABB(-extents, extents * 2).intersects(xf.xform(aabb))) { Baker::PlotMesh pm; pm.local_xform = xf; pm.mesh = mesh; @@ -1148,7 +1151,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { baker.bake_cells.resize(1); //find out the actual real bounds, power of 2, which gets the highest subdivision - baker.po2_bounds = Rect3(-extents, extents * 2.0); + baker.po2_bounds = AABB(-extents, extents * 2.0); int longest_axis = baker.po2_bounds.get_longest_axis_index(); baker.axis_cell_size[longest_axis] = (1 << (baker.cell_subdiv - 1)); baker.leaf_voxel_count = 0; @@ -1283,7 +1286,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { Ref<GIProbeData> probe_data; probe_data.instance(); - probe_data->set_bounds(Rect3(-extents, extents * 2.0)); + probe_data->set_bounds(AABB(-extents, extents * 2.0)); probe_data->set_cell_size(baker.po2_bounds.size[longest_axis] / baker.axis_cell_size[longest_axis]); probe_data->set_dynamic_data(data); probe_data->set_dynamic_range(dynamic_range); @@ -1303,7 +1306,7 @@ void GIProbe::bake(Node *p_from_node, bool p_create_visual_debug) { } } -void GIProbe::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker) { +void GIProbe::_debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker) { if (p_level == p_baker->cell_subdiv - 1) { @@ -1325,7 +1328,7 @@ void GIProbe::_debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<Multi if (p_baker->bake_cells[p_idx].childs[i] == Baker::CHILD_EMPTY) continue; - Rect3 aabb = p_aabb; + AABB aabb = p_aabb; aabb.size *= 0.5; if (i & 1) @@ -1437,9 +1440,9 @@ void GIProbe::_debug_bake() { bake(NULL, true); } -Rect3 GIProbe::get_aabb() const { +AABB GIProbe::get_aabb() const { - return Rect3(-extents, extents * 2); + return AABB(-extents, extents * 2); } PoolVector<Face3> GIProbe::get_faces(uint32_t p_usage_flags) const { diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index 50d0c33d4f..324ff8e917 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -43,8 +43,8 @@ protected: static void _bind_methods(); public: - void set_bounds(const Rect3 &p_bounds); - Rect3 get_bounds() const; + void set_bounds(const AABB &p_bounds); + AABB get_bounds() const; void set_cell_size(float p_size); float get_cell_size() const; @@ -146,7 +146,7 @@ private: MaterialCache _get_material_cache(Ref<Material> p_material); int leaf_voxel_count; - Rect3 po2_bounds; + AABB po2_bounds; int axis_cell_size[3]; struct PlotMesh { @@ -178,14 +178,14 @@ private: int color_scan_cell_width; int bake_texture_size; - Vector<Color> _get_bake_texture(Ref<Image> p_image, const Color &p_color); + Vector<Color> _get_bake_texture(Ref<Image> p_image, const Color &p_color_mul, const Color &p_color_add); Baker::MaterialCache _get_material_cache(Ref<Material> p_material, Baker *p_baker); - void _plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const Rect3 &p_aabb, Baker *p_baker); + void _plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const AABB &p_aabb, Baker *p_baker); void _plot_mesh(const Transform &p_xform, Ref<Mesh> &p_mesh, Baker *p_baker, const Vector<Ref<Material> > &p_materials, const Ref<Material> &p_override_material); void _find_meshes(Node *p_at_node, Baker *p_baker); void _fixup_plot(int p_idx, int p_level, int p_x, int p_y, int p_z, Baker *p_baker); - void _debug_mesh(int p_idx, int p_level, const Rect3 &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker); + void _debug_mesh(int p_idx, int p_level, const AABB &p_aabb, Ref<MultiMesh> &p_multimesh, int &idx, Baker *p_baker); void _create_debug_mesh(Baker *p_baker); void _debug_bake(); @@ -230,7 +230,7 @@ public: void bake(Node *p_from_node = NULL, bool p_create_visual_debug = false); - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; GIProbe(); diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp index 11f7efe066..092ed8f0b2 100644 --- a/scene/3d/immediate_geometry.cpp +++ b/scene/3d/immediate_geometry.cpp @@ -85,7 +85,7 @@ void ImmediateGeometry::clear() { cached_textures.clear(); } -Rect3 ImmediateGeometry::get_aabb() const { +AABB ImmediateGeometry::get_aabb() const { return aabb; } diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h index 93ef726c6d..1ff4e05e82 100644 --- a/scene/3d/immediate_geometry.h +++ b/scene/3d/immediate_geometry.h @@ -42,7 +42,7 @@ class ImmediateGeometry : public GeometryInstance { // in VisualServer from becoming invalid if the texture is no longer used List<Ref<Texture> > cached_textures; bool empty; - Rect3 aabb; + AABB aabb; protected: static void _bind_methods(); @@ -62,7 +62,7 @@ public: void add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv = true); - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; ImmediateGeometry(); diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 02d10523e7..126c07f0be 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -117,24 +117,24 @@ bool Light::get_shadow_reverse_cull_face() const { return reverse_cull; } -Rect3 Light::get_aabb() const { +AABB Light::get_aabb() const { if (type == VisualServer::LIGHT_DIRECTIONAL) { - return Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2)); + return AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); } else if (type == VisualServer::LIGHT_OMNI) { - return Rect3(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]); + return AABB(Vector3(-1, -1, -1) * param[PARAM_RANGE], Vector3(2, 2, 2) * param[PARAM_RANGE]); } else if (type == VisualServer::LIGHT_SPOT) { float len = param[PARAM_RANGE]; float size = Math::tan(Math::deg2rad(param[PARAM_SPOT_ANGLE])) * len; - return Rect3(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); + return AABB(Vector3(-size, -size, -len), Vector3(size * 2, size * 2, len)); } - return Rect3(); + return AABB(); } PoolVector<Face3> Light::get_faces(uint32_t p_usage_flags) const { @@ -222,6 +222,7 @@ void Light::_bind_methods() { ADD_GROUP("Light", "light_"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "light_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_color", "get_color"); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_ENERGY); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_indirect_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_param", "get_param", PARAM_INDIRECT_ENERGY); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "light_negative"), "set_negative", "is_negative"); ADD_PROPERTYI(PropertyInfo(Variant::REAL, "light_specular", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_param", "get_param", PARAM_SPECULAR); ADD_PROPERTY(PropertyInfo(Variant::INT, "light_cull_mask", PROPERTY_HINT_LAYERS_3D_RENDER), "set_cull_mask", "get_cull_mask"); @@ -236,6 +237,7 @@ void Light::_bind_methods() { ADD_GROUP("", ""); BIND_ENUM_CONSTANT(PARAM_ENERGY); + BIND_ENUM_CONSTANT(PARAM_INDIRECT_ENERGY); BIND_ENUM_CONSTANT(PARAM_SPECULAR); BIND_ENUM_CONSTANT(PARAM_RANGE); BIND_ENUM_CONSTANT(PARAM_ATTENUATION); @@ -255,7 +257,13 @@ void Light::_bind_methods() { Light::Light(VisualServer::LightType p_type) { type = p_type; - light = VisualServer::get_singleton()->light_create(p_type); + switch (p_type) { + case VS::LIGHT_DIRECTIONAL: light = VisualServer::get_singleton()->directional_light_create(); break; + case VS::LIGHT_OMNI: light = VisualServer::get_singleton()->omni_light_create(); break; + case VS::LIGHT_SPOT: light = VisualServer::get_singleton()->spot_light_create(); break; + default: {}; + } + VS::get_singleton()->instance_set_base(get_instance(), light); reverse_cull = false; @@ -267,6 +275,7 @@ Light::Light(VisualServer::LightType p_type) { set_cull_mask(0xFFFFFFFF); set_param(PARAM_ENERGY, 1); + set_param(PARAM_INDIRECT_ENERGY, 1); set_param(PARAM_SPECULAR, 0.5); set_param(PARAM_RANGE, 5); set_param(PARAM_ATTENUATION, 1); diff --git a/scene/3d/light.h b/scene/3d/light.h index 2f3ac8a5e7..8514b429ec 100644 --- a/scene/3d/light.h +++ b/scene/3d/light.h @@ -46,6 +46,7 @@ class Light : public VisualInstance { public: enum Param { PARAM_ENERGY = VS::LIGHT_PARAM_ENERGY, + PARAM_INDIRECT_ENERGY = VS::LIGHT_PARAM_INDIRECT_ENERGY, PARAM_SPECULAR = VS::LIGHT_PARAM_SPECULAR, PARAM_RANGE = VS::LIGHT_PARAM_RANGE, PARAM_ATTENUATION = VS::LIGHT_PARAM_ATTENUATION, @@ -113,7 +114,7 @@ public: void set_shadow_reverse_cull_face(bool p_enable); bool get_shadow_reverse_cull_face() const; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; Light(); diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index c8215971c4..1e52ccc6e0 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -165,12 +165,12 @@ NodePath MeshInstance::get_skeleton_path() { return skeleton_path; } -Rect3 MeshInstance::get_aabb() const { +AABB MeshInstance::get_aabb() const { if (!mesh.is_null()) return mesh->get_aabb(); - return Rect3(); + return AABB(); } PoolVector<Face3> MeshInstance::get_faces(uint32_t p_usage_flags) const { diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h index 8e8c12a592..970a10aaf3 100644 --- a/scene/3d/mesh_instance.h +++ b/scene/3d/mesh_instance.h @@ -85,7 +85,7 @@ public: void create_debug_tangents(); - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; MeshInstance(); diff --git a/scene/3d/multimesh_instance.cpp b/scene/3d/multimesh_instance.cpp index f90489f1f0..ce7b97be7f 100644 --- a/scene/3d/multimesh_instance.cpp +++ b/scene/3d/multimesh_instance.cpp @@ -55,10 +55,10 @@ PoolVector<Face3> MultiMeshInstance::get_faces(uint32_t p_usage_flags) const { return PoolVector<Face3>(); } -Rect3 MultiMeshInstance::get_aabb() const { +AABB MultiMeshInstance::get_aabb() const { if (multimesh.is_null()) - return Rect3(); + return AABB(); else return multimesh->get_aabb(); } diff --git a/scene/3d/multimesh_instance.h b/scene/3d/multimesh_instance.h index cd0e7b463c..9b2b1ff9a7 100644 --- a/scene/3d/multimesh_instance.h +++ b/scene/3d/multimesh_instance.h @@ -52,7 +52,7 @@ public: void set_multimesh(const Ref<MultiMesh> &p_multimesh); Ref<MultiMesh> get_multimesh() const; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; MultiMeshInstance(); ~MultiMeshInstance(); diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 4e19214c59..915a10328b 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -31,9 +31,9 @@ #include "scene/resources/surface_tool.h" #include "servers/visual_server.h" -Rect3 Particles::get_aabb() const { +AABB Particles::get_aabb() const { - return Rect3(); + return AABB(); } PoolVector<Face3> Particles::get_faces(uint32_t p_usage_flags) const { @@ -82,7 +82,7 @@ void Particles::set_randomness_ratio(float p_ratio) { randomness_ratio = p_ratio; VS::get_singleton()->particles_set_randomness_ratio(particles, randomness_ratio); } -void Particles::set_visibility_aabb(const Rect3 &p_aabb) { +void Particles::set_visibility_aabb(const AABB &p_aabb) { visibility_aabb = p_aabb; VS::get_singleton()->particles_set_custom_aabb(particles, visibility_aabb); @@ -140,7 +140,7 @@ float Particles::get_randomness_ratio() const { return randomness_ratio; } -Rect3 Particles::get_visibility_aabb() const { +AABB Particles::get_visibility_aabb() const { return visibility_aabb; } @@ -252,7 +252,7 @@ void Particles::restart() { VisualServer::get_singleton()->particles_restart(particles); } -Rect3 Particles::capture_aabb() const { +AABB Particles::capture_aabb() const { return VS::get_singleton()->particles_get_current_aabb(particles); } @@ -335,7 +335,7 @@ void Particles::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "fixed_fps", PROPERTY_HINT_RANGE, "0,1000,1"), "set_fixed_fps", "get_fixed_fps"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fract_delta"), "set_fractional_delta", "get_fractional_delta"); ADD_GROUP("Drawing", ""); - ADD_PROPERTY(PropertyInfo(Variant::RECT3, "visibility_aabb"), "set_visibility_aabb", "get_visibility_aabb"); + ADD_PROPERTY(PropertyInfo(Variant::AABB, "visibility_aabb"), "set_visibility_aabb", "get_visibility_aabb"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates"); ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime,View Depth"), "set_draw_order", "get_draw_order"); ADD_GROUP("Process Material", ""); @@ -367,7 +367,7 @@ Particles::Particles() { set_pre_process_time(0); set_explosiveness_ratio(0); set_randomness_ratio(0); - set_visibility_aabb(Rect3(Vector3(-4, -4, -4), Vector3(8, 8, 8))); + set_visibility_aabb(AABB(Vector3(-4, -4, -4), Vector3(8, 8, 8))); set_use_local_coordinates(true); set_draw_passes(1); set_draw_order(DRAW_ORDER_INDEX); @@ -642,7 +642,7 @@ void ParticlesMaterial::_update_shader() { code += " float angle1 = (rand_from_seed(alt_seed)*2.0-1.0)*spread/180.0*3.1416;\n"; code += " vec3 rot = vec3( cos(angle1), sin(angle1),0.0 );\n"; - code += " VELOCITY = (rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n"; + code += " VELOCITY = rot*initial_linear_velocity*mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);\n"; } else { //initiate velocity spread in 3D @@ -650,7 +650,7 @@ void ParticlesMaterial::_update_shader() { code += " float angle2 = rand_from_seed(alt_seed)*20.0*3.1416; // make it more random like\n"; code += " vec3 rot_xz = vec3( sin(angle1), 0.0, cos(angle1) );\n"; code += " vec3 rot = vec3( cos(angle2)*rot_xz.x,sin(angle2)*rot_xz.x, rot_xz.z);\n"; - code += " VELOCITY = (rot*initial_linear_velocity+rot*initial_linear_velocity_random*rand_from_seed(alt_seed));\n"; + code += " VELOCITY = rot*initial_linear_velocity*mix(1.0, rand_from_seed(alt_seed), initial_linear_velocity_random);\n"; } code += " float base_angle = (initial_angle+tex_angle)*mix(1.0,angle_rand,initial_angle_random);\n"; @@ -761,11 +761,11 @@ void ParticlesMaterial::_update_shader() { code += " force += length(diff) > 0.0 ? normalize(diff) * (radial_accel+tex_radial_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random) : vec3(0.0);\n"; code += " //apply tangential acceleration;\n"; if (flags[FLAG_DISABLE_Z]) { - code += " force += length(diff.yx) > 0.0 ? vec3(normalize(diff.yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n"; + code += " force += length(diff.yx) > 0.0 ? vec3(normalize(diff.yx * vec2(-1.0,1.0)),0.0) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),tangent_accel_random)) : vec3(0.0);\n"; } else { code += " vec3 crossDiff = cross(normalize(diff),normalize(gravity));\n"; - code += " force += length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random)) : vec3(0.0);\n"; + code += " force += length(crossDiff) > 0.0 ? normalize(crossDiff) * ((tangent_accel+tex_tangent_accel)*mix(1.0,rand_from_seed(alt_seed),tangent_accel_random)) : vec3(0.0);\n"; } code += " //apply attractor forces\n"; code += " VELOCITY += force * DELTA;\n"; diff --git a/scene/3d/particles.h b/scene/3d/particles.h index e3109f470f..30080360bb 100644 --- a/scene/3d/particles.h +++ b/scene/3d/particles.h @@ -65,7 +65,7 @@ private: float explosiveness_ratio; float randomness_ratio; float speed_scale; - Rect3 visibility_aabb; + AABB visibility_aabb; bool local_coords; int fixed_fps; bool fractional_delta; @@ -82,7 +82,7 @@ protected: virtual void _validate_property(PropertyInfo &property) const; public: - Rect3 get_aabb() const; + AABB get_aabb() const; PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; void set_emitting(bool p_emitting); @@ -92,7 +92,7 @@ public: void set_pre_process_time(float p_time); void set_explosiveness_ratio(float p_ratio); void set_randomness_ratio(float p_ratio); - void set_visibility_aabb(const Rect3 &p_aabb); + void set_visibility_aabb(const AABB &p_aabb); void set_use_local_coordinates(bool p_enable); void set_process_material(const Ref<Material> &p_material); void set_speed_scale(float p_scale); @@ -104,7 +104,7 @@ public: float get_pre_process_time() const; float get_explosiveness_ratio() const; float get_randomness_ratio() const; - Rect3 get_visibility_aabb() const; + AABB get_visibility_aabb() const; bool get_use_local_coordinates() const; Ref<Material> get_process_material() const; float get_speed_scale() const; @@ -128,7 +128,7 @@ public: void restart(); - Rect3 capture_aabb() const; + AABB capture_aabb() const; Particles(); ~Particles(); }; diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 4c661e6a88..4e06b272e2 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -938,7 +938,7 @@ bool KinematicBody::move_and_collide(const Vector3 &p_motion, Collision &r_colli Transform gt = get_global_transform(); PhysicsServer::MotionResult result; - bool colliding = PhysicsServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, margin, &result); + bool colliding = PhysicsServer::get_singleton()->body_test_motion(get_rid(), gt, p_motion, &result); if (colliding) { r_collision.collider_metadata = result.collider_metadata; @@ -988,12 +988,15 @@ Vector3 KinematicBody::move_and_slide(const Vector3 &p_linear_velocity, const Ve on_floor = true; floor_velocity = collision.collider_vel; - /*if (collision.travel.length() < 0.01 && ABS((lv.x - floor_velocity.x)) < p_slope_stop_min_velocity) { + Vector3 rel_v = lv - floor_velocity; + Vector3 hv = rel_v - p_floor_direction * p_floor_direction.dot(rel_v); + + if (collision.travel.length() < 0.05 && hv.length() < p_slope_stop_min_velocity) { Transform gt = get_global_transform(); - gt.elements[2] -= collision.travel; + gt.origin -= collision.travel; set_global_transform(gt); - return Vector3(); - }*/ + return floor_velocity - p_floor_direction * p_floor_direction.dot(floor_velocity); + } } else if (collision.normal.dot(-p_floor_direction) >= Math::cos(p_floor_max_angle)) { //ceiling on_ceiling = true; } else { @@ -1041,12 +1044,13 @@ bool KinematicBody::test_move(const Transform &p_from, const Vector3 &p_motion) ERR_FAIL_COND_V(!is_inside_tree(), false); - return PhysicsServer::get_singleton()->body_test_motion(get_rid(), p_from, p_motion, margin); + return PhysicsServer::get_singleton()->body_test_motion(get_rid(), p_from, p_motion); } void KinematicBody::set_safe_margin(float p_margin) { margin = p_margin; + PhysicsServer::get_singleton()->body_set_kinematic_safe_margin(get_rid(), margin); } float KinematicBody::get_safe_margin() const { diff --git a/scene/3d/portal.cpp b/scene/3d/portal.cpp index 6c14f7dbc9..4fde29aab9 100644 --- a/scene/3d/portal.cpp +++ b/scene/3d/portal.cpp @@ -98,7 +98,7 @@ void Portal::_get_property_list(List<PropertyInfo> *p_list) const { p_list->push_back(PropertyInfo(Variant::REAL, "connect_range", PROPERTY_HINT_RANGE, "0.1,4096,0.01")); } -Rect3 Portal::get_aabb() const { +AABB Portal::get_aabb() const { return aabb; } diff --git a/scene/3d/portal.h b/scene/3d/portal.h index 6de3df8553..4ea208a718 100644 --- a/scene/3d/portal.h +++ b/scene/3d/portal.h @@ -53,7 +53,7 @@ class Portal : public VisualInstance { Color disabled_color; float connect_range; - Rect3 aabb; + AABB aabb; protected: bool _set(const StringName &p_name, const Variant &p_value); @@ -63,7 +63,7 @@ protected: static void _bind_methods(); public: - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; void set_enabled(bool p_enabled); diff --git a/scene/3d/reflection_probe.cpp b/scene/3d/reflection_probe.cpp index 46b105cd21..0e575ec152 100644 --- a/scene/3d/reflection_probe.cpp +++ b/scene/3d/reflection_probe.cpp @@ -178,9 +178,9 @@ ReflectionProbe::UpdateMode ReflectionProbe::get_update_mode() const { return update_mode; } -Rect3 ReflectionProbe::get_aabb() const { +AABB ReflectionProbe::get_aabb() const { - Rect3 aabb; + AABB aabb; aabb.position = -origin_offset; aabb.size = origin_offset + extents; return aabb; diff --git a/scene/3d/reflection_probe.h b/scene/3d/reflection_probe.h index 7c328a8f16..26f17fdcf9 100644 --- a/scene/3d/reflection_probe.h +++ b/scene/3d/reflection_probe.h @@ -101,7 +101,7 @@ public: void set_update_mode(UpdateMode p_mode); UpdateMode get_update_mode() const; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; ReflectionProbe(); diff --git a/scene/3d/room_instance.cpp b/scene/3d/room_instance.cpp index 439b6bfdf8..47a7b8bfb9 100644 --- a/scene/3d/room_instance.cpp +++ b/scene/3d/room_instance.cpp @@ -66,12 +66,12 @@ void Room::_notification(int p_what) { } } -Rect3 Room::get_aabb() const { +AABB Room::get_aabb() const { if (room.is_null()) - return Rect3(); + return AABB(); - return Rect3(); + return AABB(); } PoolVector<Face3> Room::get_faces(uint32_t p_usage_flags) const { diff --git a/scene/3d/room_instance.h b/scene/3d/room_instance.h index b9a64b6670..3069ea2eba 100644 --- a/scene/3d/room_instance.h +++ b/scene/3d/room_instance.h @@ -71,7 +71,7 @@ public: NOTIFICATION_AREA_CHANGED = 60 }; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; void set_room(const Ref<RoomBounds> &p_room); diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 0dfd80ca90..588aa2881a 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -233,7 +233,7 @@ void Spatial::set_transform(const Transform &p_transform) { data.dirty |= DIRTY_VECTORS; _change_notify("translation"); _change_notify("rotation"); - _change_notify("rotation_deg"); + _change_notify("rotation_degrees"); _change_notify("scale"); _propagate_transform_changed(this); if (data.notify_local_transform) { @@ -327,17 +327,11 @@ void Spatial::set_rotation(const Vector3 &p_euler_rad) { } } -void Spatial::set_rotation_in_degrees(const Vector3 &p_euler_deg) { +void Spatial::set_rotation_degrees(const Vector3 &p_euler_deg) { set_rotation(p_euler_deg * Math_PI / 180.0); } -void Spatial::_set_rotation_deg(const Vector3 &p_euler_deg) { - - WARN_PRINT("Deprecated method Spatial._set_rotation_deg(): This method was renamed to set_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotation_in_degrees(p_euler_deg); -} - void Spatial::set_scale(const Vector3 &p_scale) { if (data.dirty & DIRTY_VECTORS) { @@ -370,19 +364,11 @@ Vector3 Spatial::get_rotation() const { return data.rotation; } -Vector3 Spatial::get_rotation_in_degrees() const { +Vector3 Spatial::get_rotation_degrees() const { return get_rotation() * 180.0 / Math_PI; } -// Kept for compatibility after rename to set_rotd. -// Could be removed after a couple releases. -Vector3 Spatial::_get_rotation_deg() const { - - WARN_PRINT("Deprecated method Spatial._get_rotation_deg(): This method was renamed to get_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotation_in_degrees(); -} - Vector3 Spatial::get_scale() const { if (data.dirty & DIRTY_VECTORS) { @@ -691,10 +677,10 @@ void Spatial::_bind_methods() { ClassDB::bind_method(D_METHOD("get_transform"), &Spatial::get_transform); ClassDB::bind_method(D_METHOD("set_translation", "translation"), &Spatial::set_translation); ClassDB::bind_method(D_METHOD("get_translation"), &Spatial::get_translation); - ClassDB::bind_method(D_METHOD("set_rotation", "rotation_rad"), &Spatial::set_rotation); + ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Spatial::set_rotation); ClassDB::bind_method(D_METHOD("get_rotation"), &Spatial::get_rotation); - ClassDB::bind_method(D_METHOD("set_rotation_deg", "rotation_deg"), &Spatial::set_rotation_in_degrees); - ClassDB::bind_method(D_METHOD("get_rotation_deg"), &Spatial::get_rotation_in_degrees); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Spatial::set_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Spatial::get_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Spatial::set_scale); ClassDB::bind_method(D_METHOD("get_scale"), &Spatial::get_scale); ClassDB::bind_method(D_METHOD("set_global_transform", "global"), &Spatial::set_global_transform); @@ -705,10 +691,6 @@ void Spatial::_bind_methods() { ClassDB::bind_method(D_METHOD("is_set_as_toplevel"), &Spatial::is_set_as_toplevel); ClassDB::bind_method(D_METHOD("get_world"), &Spatial::get_world); - // TODO: Obsolete those two methods (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_set_rotation_deg", "rotation_deg"), &Spatial::_set_rotation_deg); - ClassDB::bind_method(D_METHOD("_get_rotation_deg"), &Spatial::_get_rotation_deg); - #ifdef TOOLS_ENABLED ClassDB::bind_method(D_METHOD("_update_gizmo"), &Spatial::_update_gizmo); #endif @@ -764,7 +746,7 @@ void Spatial::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::TRANSFORM, "transform", PROPERTY_HINT_NONE, ""), "set_transform", "get_transform"); ADD_PROPERTYNZ(PropertyInfo(Variant::TRANSFORM, "global_transform", PROPERTY_HINT_NONE, "", 0), "set_global_transform", "get_global_transform"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "translation", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_translation", "get_translation"); - ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_deg", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_deg", "get_rotation_deg"); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation_degrees", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "rotation", PROPERTY_HINT_NONE, "", 0), "set_rotation", "get_rotation"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "scale", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_scale", "get_scale"); ADD_GROUP("Visibility", ""); diff --git a/scene/3d/spatial.h b/scene/3d/spatial.h index b912d1f906..8f53b4a066 100644 --- a/scene/3d/spatial.h +++ b/scene/3d/spatial.h @@ -106,10 +106,6 @@ class Spatial : public Node { void _notify_dirty(); void _propagate_transform_changed(Spatial *p_origin); - // Deprecated, should be removed in a future version. - void _set_rotation_deg(const Vector3 &p_euler_deg); - Vector3 _get_rotation_deg() const; - void _propagate_visibility_changed(); protected: @@ -136,12 +132,12 @@ public: void set_translation(const Vector3 &p_translation); void set_rotation(const Vector3 &p_euler_rad); - void set_rotation_in_degrees(const Vector3 &p_euler_deg); + void set_rotation_degrees(const Vector3 &p_euler_deg); void set_scale(const Vector3 &p_scale); Vector3 get_translation() const; Vector3 get_rotation() const; - Vector3 get_rotation_in_degrees() const; + Vector3 get_rotation_degrees() const; Vector3 get_scale() const; void set_transform(const Transform &p_transform); diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp index 49a3205f21..18ebc22c8b 100644 --- a/scene/3d/sprite_3d.cpp +++ b/scene/3d/sprite_3d.cpp @@ -188,7 +188,7 @@ void SpriteBase3D::_queue_update() { call_deferred(SceneStringNames::get_singleton()->_im_update); } -Rect3 SpriteBase3D::get_aabb() const { +AABB SpriteBase3D::get_aabb() const { return aabb; } @@ -407,7 +407,7 @@ void Sprite3D::_draw() { } } - Rect3 aabb; + AABB aabb; for (int i = 0; i < 4; i++) { VS::get_singleton()->immediate_normal(immediate, normal); @@ -698,7 +698,7 @@ void AnimatedSprite3D::_draw() { } } - Rect3 aabb; + AABB aabb; for (int i = 0; i < 4; i++) { VS::get_singleton()->immediate_normal(immediate, normal); diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h index 1165392cb2..d18553a504 100644 --- a/scene/3d/sprite_3d.h +++ b/scene/3d/sprite_3d.h @@ -71,7 +71,7 @@ private: Vector3::Axis axis; float pixel_size; - Rect3 aabb; + AABB aabb; RID immediate; @@ -87,7 +87,7 @@ protected: void _notification(int p_what); static void _bind_methods(); virtual void _draw() = 0; - _FORCE_INLINE_ void set_aabb(const Rect3 &p_aabb) { aabb = p_aabb; } + _FORCE_INLINE_ void set_aabb(const AABB &p_aabb) { aabb = p_aabb; } _FORCE_INLINE_ RID &get_immediate() { return immediate; } void _queue_update(); @@ -130,7 +130,7 @@ public: virtual Rect2 get_item_rect() const = 0; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const; SpriteBase3D(); diff --git a/scene/3d/visibility_notifier.cpp b/scene/3d/visibility_notifier.cpp index e60b32a92a..47144c4b78 100644 --- a/scene/3d/visibility_notifier.cpp +++ b/scene/3d/visibility_notifier.cpp @@ -60,7 +60,7 @@ void VisibilityNotifier::_exit_camera(Camera *p_camera) { } } -void VisibilityNotifier::set_aabb(const Rect3 &p_aabb) { +void VisibilityNotifier::set_aabb(const AABB &p_aabb) { if (aabb == p_aabb) return; @@ -74,7 +74,7 @@ void VisibilityNotifier::set_aabb(const Rect3 &p_aabb) { update_gizmo(); } -Rect3 VisibilityNotifier::get_aabb() const { +AABB VisibilityNotifier::get_aabb() const { return aabb; } @@ -108,7 +108,7 @@ void VisibilityNotifier::_bind_methods() { ClassDB::bind_method(D_METHOD("get_aabb"), &VisibilityNotifier::get_aabb); ClassDB::bind_method(D_METHOD("is_on_screen"), &VisibilityNotifier::is_on_screen); - ADD_PROPERTY(PropertyInfo(Variant::RECT3, "aabb"), "set_aabb", "get_aabb"); + ADD_PROPERTY(PropertyInfo(Variant::AABB, "aabb"), "set_aabb", "get_aabb"); ADD_SIGNAL(MethodInfo("camera_entered", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"))); ADD_SIGNAL(MethodInfo("camera_exited", PropertyInfo(Variant::OBJECT, "camera", PROPERTY_HINT_RESOURCE_TYPE, "Camera"))); @@ -118,7 +118,7 @@ void VisibilityNotifier::_bind_methods() { VisibilityNotifier::VisibilityNotifier() { - aabb = Rect3(Vector3(-1, -1, -1), Vector3(2, 2, 2)); + aabb = AABB(Vector3(-1, -1, -1), Vector3(2, 2, 2)); set_notify_transform(true); } diff --git a/scene/3d/visibility_notifier.h b/scene/3d/visibility_notifier.h index 0b83e0534e..fc06cf5aec 100644 --- a/scene/3d/visibility_notifier.h +++ b/scene/3d/visibility_notifier.h @@ -39,7 +39,7 @@ class VisibilityNotifier : public Spatial { Set<Camera *> cameras; - Rect3 aabb; + AABB aabb; protected: virtual void _screen_enter() {} @@ -53,8 +53,8 @@ protected: void _exit_camera(Camera *p_camera); public: - void set_aabb(const Rect3 &p_aabb); - Rect3 get_aabb() const; + void set_aabb(const AABB &p_aabb); + AABB get_aabb() const; bool is_on_screen() const; VisibilityNotifier(); diff --git a/scene/3d/visual_instance.cpp b/scene/3d/visual_instance.cpp index fa35d982eb..b92e7ead04 100644 --- a/scene/3d/visual_instance.cpp +++ b/scene/3d/visual_instance.cpp @@ -33,7 +33,7 @@ #include "servers/visual_server.h" #include "skeleton.h" -Rect3 VisualInstance::get_transformed_aabb() const { +AABB VisualInstance::get_transformed_aabb() const { return get_global_transform().xform(get_aabb()); } diff --git a/scene/3d/visual_instance.h b/scene/3d/visual_instance.h index c405236d2c..5827f1e1fb 100644 --- a/scene/3d/visual_instance.h +++ b/scene/3d/visual_instance.h @@ -62,10 +62,10 @@ public: }; RID get_instance() const; - virtual Rect3 get_aabb() const = 0; + virtual AABB get_aabb() const = 0; virtual PoolVector<Face3> get_faces(uint32_t p_usage_flags) const = 0; - virtual Rect3 get_transformed_aabb() const; // helper + virtual AABB get_transformed_aabb() const; // helper void set_base(const RID &p_base); diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 80b7748078..6be3ff88d9 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -545,7 +545,14 @@ void AnimationPlayer::_animation_process_data(PlaybackData &cd, float p_delta, f } else { - next_pos = Math::fposmod(next_pos, len); + float looped_next_pos = Math::fposmod(next_pos, len); + if (looped_next_pos == 0 && next_pos != 0) { + // Loop multiples of the length to it, rather than 0 + // so state at time=length is previewable in the editor + next_pos = len; + } else { + next_pos = looped_next_pos; + } } cd.pos = next_pos; diff --git a/scene/animation/tween.cpp b/scene/animation/tween.cpp index e0508cf147..40d06dc756 100644 --- a/scene/animation/tween.cpp +++ b/scene/animation/tween.cpp @@ -416,10 +416,10 @@ Variant Tween::_run_equation(InterpolateData &p_data) { result = r; } break; - case Variant::RECT3: { - Rect3 i = initial_val; - Rect3 d = delta_val; - Rect3 r; + case Variant::AABB: { + AABB i = initial_val; + AABB d = delta_val; + AABB r; APPLY_EQUATION(position.x); APPLY_EQUATION(position.y); @@ -956,10 +956,10 @@ bool Tween::_calc_delta_val(const Variant &p_initial_val, const Variant &p_final case Variant::QUAT: delta_val = final_val.operator Quat() - initial_val.operator Quat(); break; - case Variant::RECT3: { - Rect3 i = initial_val; - Rect3 f = final_val; - delta_val = Rect3(f.position - i.position, f.size - i.size); + case Variant::AABB: { + AABB i = initial_val; + AABB f = final_val; + delta_val = AABB(f.position - i.position, f.size - i.size); } break; case Variant::TRANSFORM: { Transform i = initial_val; diff --git a/scene/audio/audio_player.cpp b/scene/audio/audio_player.cpp index 058b162e83..08b01c6a4c 100644 --- a/scene/audio/audio_player.cpp +++ b/scene/audio/audio_player.cpp @@ -31,20 +31,7 @@ #include "engine.h" -void AudioStreamPlayer::_mix_audio() { - - if (!stream_playback.is_valid()) { - return; - } - - if (!active) { - return; - } - - if (setseek >= 0.0) { - stream_playback->start(setseek); - setseek = -1.0; //reset seek - } +void AudioStreamPlayer::_mix_internal(bool p_fadeout) { int bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus); @@ -52,19 +39,24 @@ void AudioStreamPlayer::_mix_audio() { AudioFrame *buffer = mix_buffer.ptr(); int buffer_size = mix_buffer.size(); + if (p_fadeout) { + buffer_size = MIN(buffer_size, 16); //short fadeout ramp + } + //mix stream_playback->mix(buffer, 1.0, buffer_size); //multiply volume interpolating to avoid clicks if this changes + float target_volume = p_fadeout ? -80.0 : volume_db; float vol = Math::db2linear(mix_volume_db); - float vol_inc = (Math::db2linear(volume_db) - vol) / float(buffer_size); + float vol_inc = (Math::db2linear(target_volume) - vol) / float(buffer_size); for (int i = 0; i < buffer_size; i++) { buffer[i] *= vol; vol += vol_inc; } //set volume for next mix - mix_volume_db = volume_db; + mix_volume_db = target_volume; AudioFrame *targets[4] = { NULL, NULL, NULL, NULL }; @@ -95,6 +87,30 @@ void AudioStreamPlayer::_mix_audio() { } } +void AudioStreamPlayer::_mix_audio() { + + if (!stream_playback.is_valid()) { + return; + } + + if (!active) { + return; + } + + if (setseek >= 0.0) { + if (stream_playback->is_playing()) { + + //fade out to avoid pops + _mix_internal(true); + } + stream_playback->start(setseek); + setseek = -1.0; //reset seek + mix_volume_db = volume_db; //reset ramp + } + + _mix_internal(false); +} + void AudioStreamPlayer::_notification(int p_what) { if (p_what == NOTIFICATION_ENTER_TREE) { @@ -163,7 +179,7 @@ float AudioStreamPlayer::get_volume_db() const { void AudioStreamPlayer::play(float p_from_pos) { if (stream_playback.is_valid()) { - mix_volume_db = volume_db; //reset volume ramp + //mix_volume_db = volume_db; do not reset volume ramp here, can cause clicks setseek = p_from_pos; active = true; set_process_internal(true); diff --git a/scene/audio/audio_player.h b/scene/audio/audio_player.h index 4bfc44730d..6e9d623433 100644 --- a/scene/audio/audio_player.h +++ b/scene/audio/audio_player.h @@ -59,6 +59,7 @@ private: MixTarget mix_target; + void _mix_internal(bool p_fadeout); void _mix_audio(); static void _mix_audios(void *self) { reinterpret_cast<AudioStreamPlayer *>(self)->_mix_audio(); } diff --git a/scene/gui/check_button.cpp b/scene/gui/check_button.cpp index e68159e27f..77fdedd5e5 100644 --- a/scene/gui/check_button.cpp +++ b/scene/gui/check_button.cpp @@ -32,6 +32,23 @@ #include "print_string.h" #include "servers/visual_server.h" +Size2 CheckButton::get_minimum_size() const { + + Size2 minsize = Button::get_minimum_size(); + + Ref<Texture> on = Control::get_icon("on"); + Ref<Texture> off = Control::get_icon("off"); + Size2 tex_size = Size2(0, 0); + if (!on.is_null()) + tex_size = Size2(on->get_width(), on->get_height()); + if (!off.is_null()) + tex_size = Size2(MAX(tex_size.width, off->get_width()), MAX(tex_size.height, off->get_height())); + minsize += Size2(tex_size.width + get_constant("hseparation"), 0); + minsize.height = MAX(minsize.height, tex_size.height); + + return get_stylebox("normal")->get_minimum_size() + minsize; +} + void CheckButton::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { @@ -41,9 +58,11 @@ void CheckButton::_notification(int p_what) { Ref<Texture> on = Control::get_icon("on"); Ref<Texture> off = Control::get_icon("off"); + Ref<StyleBox> sb = get_stylebox("normal"); + Size2 sb_ofs = Size2(sb->get_margin(MARGIN_RIGHT), sb->get_margin(MARGIN_TOP)); Vector2 ofs; - ofs.x = get_size().width - on->get_width(); - ofs.y = int((get_size().height - on->get_height()) / 2); + ofs.x = get_minimum_size().width - (on->get_width() + sb_ofs.width); + ofs.y = sb_ofs.height; if (is_pressed()) on->draw(ci, ofs); diff --git a/scene/gui/check_button.h b/scene/gui/check_button.h index af3b80fe04..eb68943fe7 100644 --- a/scene/gui/check_button.h +++ b/scene/gui/check_button.h @@ -39,6 +39,7 @@ class CheckButton : public Button { GDCLASS(CheckButton, Button); protected: + virtual Size2 get_minimum_size() const; void _notification(int p_what); public: diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index 54a58159ac..adca78d1d4 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -45,7 +45,7 @@ #endif #include <stdio.h> -Variant Control::edit_get_state() const { +Dictionary Control::_edit_get_state() const { Dictionary s; s["rect"] = get_rect(); @@ -59,22 +59,78 @@ Variant Control::edit_get_state() const { s["anchors"] = anchors; return s; } -void Control::edit_set_state(const Variant &p_state) { +void Control::_edit_set_state(const Dictionary &p_state) { - Dictionary s = p_state; + Dictionary state = p_state; - Rect2 state = s["rect"]; - set_position(state.position); - set_size(state.size); - set_rotation(s["rotation"]); - set_scale(s["scale"]); - Array anchors = s["anchors"]; + Rect2 rect = state["rect"]; + set_position(rect.position); + set_size(rect.size); + set_rotation(state["rotation"]); + set_scale(state["scale"]); + Array anchors = state["anchors"]; set_anchor(MARGIN_LEFT, anchors[0]); set_anchor(MARGIN_TOP, anchors[1]); set_anchor(MARGIN_RIGHT, anchors[2]); set_anchor(MARGIN_BOTTOM, anchors[3]); } +void Control::_edit_set_position(const Point2 &p_position) { + set_position(p_position); +}; + +Point2 Control::_edit_get_position() const { + return get_position(); +}; + +void Control::_edit_set_rect(const Rect2 &p_edit_rect) { + + Transform2D xform = _get_internal_transform(); + + Vector2 new_pos = xform.basis_xform(p_edit_rect.position); + + Vector2 pos = get_position() + new_pos; + + Rect2 new_rect = get_rect(); + new_rect.position = pos.snapped(Vector2(1, 1)); + new_rect.size = p_edit_rect.size.snapped(Vector2(1, 1)); + + set_position(new_rect.position); + set_size(new_rect.size); +} + +Rect2 Control::_edit_get_rect() const { + return Rect2(Point2(), get_size()); +} + +bool Control::_edit_use_rect() const { + return true; +} + +void Control::_edit_set_rotation(float p_rotation) { + set_rotation(p_rotation); +} + +float Control::_edit_get_rotation() const { + return get_rotation(); +} + +bool Control::_edit_use_rotation() const { + return true; +} + +void Control::_edit_set_pivot(const Point2 &p_pivot) { + set_pivot_offset(p_pivot); +} + +Point2 Control::_edit_get_pivot() const { + return get_pivot_offset(); +} + +bool Control::_edit_use_pivot() const { + return true; +} + void Control::set_custom_minimum_size(const Size2 &p_custom) { if (p_custom == data.custom_minimum_size) @@ -96,7 +152,7 @@ Size2 Control::get_combined_minimum_size() const { return minsize; } -Size2 Control::edit_get_minimum_size() const { +Size2 Control::_edit_get_minimum_size() const { return get_combined_minimum_size(); } @@ -110,23 +166,6 @@ Transform2D Control::_get_internal_transform() const { return offset.affine_inverse() * (rot_scale * offset); } -void Control::edit_set_rect(const Rect2 &p_edit_rect) { - - Transform2D xform = _get_internal_transform(); - - // xform[2] += get_position(); - - Vector2 new_pos = xform.basis_xform(p_edit_rect.position); - - Vector2 pos = get_position() + new_pos; - - Rect2 new_rect = get_rect(); - new_rect.position = pos.snapped(Vector2(1, 1)); - new_rect.size = p_edit_rect.size.snapped(Vector2(1, 1)); - - set_position(new_rect.position); - set_size(new_rect.size); -} bool Control::_set(const StringName &p_name, const Variant &p_value) { @@ -1210,7 +1249,7 @@ Size2 Control::get_parent_area_size() const { if (data.parent_canvas_item) { - parent_size = data.parent_canvas_item->get_item_rect().size; + parent_size = data.parent_canvas_item->_edit_get_rect().size; } else { parent_size = get_viewport()->get_visible_rect().size; @@ -1289,7 +1328,7 @@ float Control::_get_parent_range(int p_idx) const { } if (data.parent_canvas_item) { - return data.parent_canvas_item->get_item_rect().size[p_idx & 1]; + return data.parent_canvas_item->_edit_get_rect().size[p_idx & 1]; } else { return get_viewport()->get_visible_rect().size[p_idx & 1]; } @@ -1751,11 +1790,6 @@ Rect2 Control::get_rect() const { return Rect2(get_position(), get_size()); } -Rect2 Control::get_item_rect() const { - - return Rect2(Point2(), get_size()); -} - void Control::add_icon_override(const StringName &p_name, const Ref<Texture> &p_icon) { ERR_FAIL_COND(p_icon.is_null()); @@ -1847,6 +1881,25 @@ Control *Control::find_next_valid_focus() const { while (true) { + // If the focus property is manually overwritten, attempt to use it. + + if (!data.focus_next.is_empty()) { + Node *n = get_node(data.focus_next); + if (n) { + from = Object::cast_to<Control>(n); + + if (!from) { + + ERR_EXPLAIN("Next focus node is not a control: " + n->get_name()); + ERR_FAIL_V(NULL); + } + } else { + return NULL; + } + if (from->is_visible() && from->get_focus_mode() != FOCUS_NONE) + return from; + } + // find next child Control *next_child = NULL; @@ -1926,6 +1979,25 @@ Control *Control::find_prev_valid_focus() const { while (true) { + // If the focus property is manually overwritten, attempt to use it. + + if (!data.focus_prev.is_empty()) { + Node *n = get_node(data.focus_prev); + if (n) { + from = Object::cast_to<Control>(n); + + if (!from) { + + ERR_EXPLAIN("Prev focus node is not a control: " + n->get_name()); + ERR_FAIL_V(NULL); + } + } else { + return NULL; + } + if (from->is_visible() && from->get_focus_mode() != FOCUS_NONE) + return from; + } + // find prev child Control *prev_child = NULL; @@ -2157,6 +2229,26 @@ NodePath Control::get_focus_neighbour(Margin p_margin) const { return data.focus_neighbour[p_margin]; } +void Control::set_focus_next(const NodePath &p_next) { + + data.focus_next = p_next; +} + +NodePath Control::get_focus_next() const { + + return data.focus_next; +} + +void Control::set_focus_previous(const NodePath &p_prev) { + + data.focus_prev = p_prev; +} + +NodePath Control::get_focus_previous() const { + + return data.focus_prev; +} + #define MAX_NEIGHBOUR_SEARCH_COUNT 512 Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { @@ -2172,7 +2264,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { if (!c) { - ERR_EXPLAIN("Next focus node is not a control: " + n->get_name()); + ERR_EXPLAIN("Neighbour focus node is not a control: " + n->get_name()); ERR_FAIL_V(NULL); } } else { @@ -2196,7 +2288,7 @@ Control *Control::_get_focus_neighbour(Margin p_margin, int p_count) { Point2 points[4]; Transform2D xform = get_global_transform(); - Rect2 rect = get_item_rect(); + Rect2 rect = _edit_get_rect(); points[0] = xform.xform(rect.position); points[1] = xform.xform(rect.position + Point2(rect.size.x, 0)); @@ -2255,7 +2347,7 @@ void Control::_window_find_focus_neighbour(const Vector2 &p_dir, Node *p_at, con Point2 points[4]; Transform2D xform = c->get_global_transform(); - Rect2 rect = c->get_item_rect(); + Rect2 rect = c->_edit_get_rect(); points[0] = xform.xform(rect.position); points[1] = xform.xform(rect.position + Point2(rect.size.x, 0)); @@ -2416,24 +2508,14 @@ float Control::get_rotation() const { return data.rotation; } -void Control::set_rotation_deg(float p_degrees) { +void Control::set_rotation_degrees(float p_degrees) { set_rotation(Math::deg2rad(p_degrees)); } -float Control::get_rotation_deg() const { +float Control::get_rotation_degrees() const { return Math::rad2deg(get_rotation()); } -// Kept for compatibility after rename to {s,g}et_rotation_deg. -// Could be removed after a couple releases. -void Control::_set_rotation_deg(float p_degrees) { - WARN_PRINT("Deprecated method Control._set_rotation_deg(): This method was renamed to set_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotation_deg(p_degrees); -} -float Control::_get_rotation_deg() const { - WARN_PRINT("Deprecated method Control._get_rotation_deg(): This method was renamed to get_rotation_deg. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotation_deg(); -} //needed to update the control if the font changes.. void Control::_ref_font(Ref<Font> p_sc) { @@ -2606,9 +2688,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("set_custom_minimum_size", "size"), &Control::set_custom_minimum_size); ClassDB::bind_method(D_METHOD("set_global_position", "position"), &Control::set_global_position); ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &Control::set_rotation); - ClassDB::bind_method(D_METHOD("set_rotation_deg", "degrees"), &Control::set_rotation_deg); - // TODO: Obsolete this method (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_set_rotation_deg", "degrees"), &Control::_set_rotation_deg); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &Control::set_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &Control::set_scale); ClassDB::bind_method(D_METHOD("set_pivot_offset", "pivot_offset"), &Control::set_pivot_offset); ClassDB::bind_method(D_METHOD("get_margin", "margin"), &Control::get_margin); @@ -2617,9 +2697,7 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("get_position"), &Control::get_position); ClassDB::bind_method(D_METHOD("get_size"), &Control::get_size); ClassDB::bind_method(D_METHOD("get_rotation"), &Control::get_rotation); - ClassDB::bind_method(D_METHOD("get_rotation_deg"), &Control::get_rotation_deg); - // TODO: Obsolete this method (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_get_rotation_deg"), &Control::_get_rotation_deg); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &Control::get_rotation_degrees); ClassDB::bind_method(D_METHOD("get_scale"), &Control::get_scale); ClassDB::bind_method(D_METHOD("get_pivot_offset"), &Control::get_pivot_offset); ClassDB::bind_method(D_METHOD("get_custom_minimum_size"), &Control::get_custom_minimum_size); @@ -2691,6 +2769,12 @@ void Control::_bind_methods() { ClassDB::bind_method(D_METHOD("set_focus_neighbour", "margin", "neighbour"), &Control::set_focus_neighbour); ClassDB::bind_method(D_METHOD("get_focus_neighbour", "margin"), &Control::get_focus_neighbour); + ClassDB::bind_method(D_METHOD("set_focus_next", "next"), &Control::set_focus_next); + ClassDB::bind_method(D_METHOD("get_focus_next"), &Control::get_focus_next); + + ClassDB::bind_method(D_METHOD("set_focus_previous", "previous"), &Control::set_focus_previous); + ClassDB::bind_method(D_METHOD("get_focus_previous"), &Control::get_focus_previous); + ClassDB::bind_method(D_METHOD("force_drag", "data", "preview"), &Control::force_drag); ClassDB::bind_method(D_METHOD("set_mouse_filter", "filter"), &Control::set_mouse_filter); @@ -2738,7 +2822,7 @@ void Control::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_position", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_position", "get_position"); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_size", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_EDITOR), "set_size", "get_size"); ADD_PROPERTYNZ(PropertyInfo(Variant::VECTOR2, "rect_min_size"), "set_custom_minimum_size", "get_custom_minimum_size"); - ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rect_rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.01"), "set_rotation_deg", "get_rotation_deg"); + ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "rect_rotation", PROPERTY_HINT_RANGE, "-1080,1080,0.01"), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "rect_scale"), "set_scale", "get_scale"); ADD_PROPERTYNO(PropertyInfo(Variant::VECTOR2, "rect_pivot_offset"), "set_pivot_offset", "get_pivot_offset"); ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "rect_clip_content"), "set_clip_contents", "is_clipping_contents"); @@ -2751,6 +2835,8 @@ void Control::_bind_methods() { ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour_top"), "set_focus_neighbour", "get_focus_neighbour", MARGIN_TOP); ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour_right"), "set_focus_neighbour", "get_focus_neighbour", MARGIN_RIGHT); ADD_PROPERTYINZ(PropertyInfo(Variant::NODE_PATH, "focus_neighbour_bottom"), "set_focus_neighbour", "get_focus_neighbour", MARGIN_BOTTOM); + ADD_PROPERTYNZ(PropertyInfo(Variant::NODE_PATH, "focus_next"), "set_focus_next", "get_focus_next"); + ADD_PROPERTYNZ(PropertyInfo(Variant::NODE_PATH, "focus_previous"), "set_focus_previous", "get_focus_previous"); ADD_GROUP("Mouse", "mouse_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "mouse_filter", PROPERTY_HINT_ENUM, "Stop,Pass,Ignore"), "set_mouse_filter", "get_mouse_filter"); diff --git a/scene/gui/control.h b/scene/gui/control.h index 5b146b4454..92d1c969fc 100644 --- a/scene/gui/control.h +++ b/scene/gui/control.h @@ -191,6 +191,8 @@ private: ObjectID modal_prev_focus_owner; NodePath focus_neighbour[4]; + NodePath focus_next; + NodePath focus_prev; HashMap<StringName, Ref<Texture>, StringNameHasher> icon_override; HashMap<StringName, Ref<Shader>, StringNameHasher> shader_override; @@ -226,10 +228,6 @@ private: void _size_changed(); String _get_tooltip() const; - // Deprecated, should be removed in a future version. - void _set_rotation_deg(float p_degrees); - float _get_rotation_deg() const; - void _ref_font(Ref<Font> p_sc); void _unref_font(Ref<Font> p_sc); void _font_changed(); @@ -273,10 +271,25 @@ public: }; - virtual Variant edit_get_state() const; - virtual void edit_set_state(const Variant &p_state); - virtual void edit_set_rect(const Rect2 &p_edit_rect); - virtual Size2 edit_get_minimum_size() const; + virtual Dictionary _edit_get_state() const; + virtual void _edit_set_state(const Dictionary &p_state); + + virtual void _edit_set_position(const Point2 &p_position); + virtual Point2 _edit_get_position() const; + + virtual void _edit_set_rect(const Rect2 &p_edit_rect); + virtual Rect2 _edit_get_rect() const; + virtual bool _edit_use_rect() const; + + virtual void _edit_set_rotation(float p_rotation); + virtual float _edit_get_rotation() const; + virtual bool _edit_use_rotation() const; + + virtual void _edit_set_pivot(const Point2 &p_pivot); + virtual Point2 _edit_get_pivot() const; + virtual bool _edit_use_pivot() const; + + virtual Size2 _edit_get_minimum_size() const; void accept_event(); @@ -332,9 +345,9 @@ public: Rect2 get_window_rect() const; ///< use with care, as it blocks waiting for the visual server void set_rotation(float p_radians); - void set_rotation_deg(float p_degrees); + void set_rotation_degrees(float p_degrees); float get_rotation() const; - float get_rotation_deg() const; + float get_rotation_degrees() const; void set_h_grow_direction(GrowDirection p_direction); GrowDirection get_h_grow_direction() const; @@ -378,6 +391,11 @@ public: void set_focus_neighbour(Margin p_margin, const NodePath &p_neighbour); NodePath get_focus_neighbour(Margin p_margin) const; + void set_focus_next(const NodePath &p_next); + NodePath get_focus_next() const; + void set_focus_previous(const NodePath &p_prev); + NodePath get_focus_previous() const; + Control *get_focus_owner() const; void set_mouse_filter(MouseFilter p_filter); @@ -424,7 +442,6 @@ public: CursorShape get_default_cursor_shape() const; virtual CursorShape get_cursor_shape(const Point2 &p_pos = Point2i()) const; - virtual Rect2 get_item_rect() const; virtual Transform2D get_transform() const; bool is_toplevel_control() const; diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp index 623a110263..e9e9dcc859 100644 --- a/scene/gui/item_list.cpp +++ b/scene/gui/item_list.cpp @@ -754,7 +754,7 @@ void ItemList::_notification(int p_what) { int width = size.width - bg->get_minimum_size().width; if (scroll_bar->is_visible()) { - width -= mw + bg->get_margin(MARGIN_RIGHT); + width -= mw; } draw_style_box(bg, Rect2(Point2(), size)); @@ -1107,7 +1107,7 @@ void ItemList::_notification(int p_what) { } for (int i = 0; i < separators.size(); i++) { - draw_line(Vector2(bg->get_margin(MARGIN_LEFT), base_ofs.y + separators[i]), Vector2(size.width - bg->get_margin(MARGIN_RIGHT), base_ofs.y + separators[i]), guide_color); + draw_line(Vector2(bg->get_margin(MARGIN_LEFT), base_ofs.y + separators[i]), Vector2(width, base_ofs.y + separators[i]), guide_color); } } } diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 40e2dba6c2..f7bf1cd9ea 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -48,7 +48,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { if (b.is_valid()) { - if (b->is_pressed() && b->get_button_index() == BUTTON_RIGHT) { + if (b->is_pressed() && b->get_button_index() == BUTTON_RIGHT && context_menu_enabled) { menu->set_position(get_global_transform().xform(get_local_mouse_position())); menu->set_size(Vector2(1, 1)); menu->popup(); @@ -1286,6 +1286,14 @@ void LineEdit::menu_option(int p_option) { } } +void LineEdit::set_context_menu_enabled(bool p_enable) { + context_menu_enabled = p_enable; +} + +bool LineEdit::is_context_menu_enabled() { + return context_menu_enabled; +} + PopupMenu *LineEdit::get_menu() const { return menu; } @@ -1301,6 +1309,7 @@ void LineEdit::set_expand_to_text_length(bool p_enabled) { expand_to_text_length = p_enabled; minimum_size_changed(); + set_window_pos(0); } bool LineEdit::get_expand_to_text_length() const { @@ -1395,6 +1404,8 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("select", "from", "to"), &LineEdit::select, DEFVAL(0), DEFVAL(-1)); ClassDB::bind_method(D_METHOD("menu_option", "option"), &LineEdit::menu_option); ClassDB::bind_method(D_METHOD("get_menu"), &LineEdit::get_menu); + ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &LineEdit::set_context_menu_enabled); + ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &LineEdit::is_context_menu_enabled); ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "text"))); ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "text"))); @@ -1418,7 +1429,7 @@ void LineEdit::_bind_methods() { ADD_PROPERTYNZ(PropertyInfo(Variant::INT, "max_length"), "set_max_length", "get_max_length"); ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "editable"), "set_editable", "is_editable"); ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "secret"), "set_secret", "is_secret"); - ADD_PROPERTYNO(PropertyInfo(Variant::BOOL, "expand_to_len"), "set_expand_to_text_length", "get_expand_to_text_length"); + ADD_PROPERTYNZ(PropertyInfo(Variant::BOOL, "expand_to_text_length"), "set_expand_to_text_length", "get_expand_to_text_length"); ADD_PROPERTY(PropertyInfo(Variant::INT, "focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), "set_focus_mode", "get_focus_mode"); ADD_GROUP("Placeholder", "placeholder_"); ADD_PROPERTYNZ(PropertyInfo(Variant::STRING, "placeholder_text"), "set_placeholder", "get_placeholder"); @@ -1426,6 +1437,7 @@ void LineEdit::_bind_methods() { ADD_GROUP("Caret", "caret_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_blink"), "cursor_set_blink_enabled", "cursor_get_blink_enabled"); ADD_PROPERTYNZ(PropertyInfo(Variant::REAL, "caret_blink_speed", PROPERTY_HINT_RANGE, "0.1,10,0.1"), "cursor_set_blink_speed", "cursor_get_blink_speed"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled"); } LineEdit::LineEdit() { @@ -1455,6 +1467,7 @@ LineEdit::LineEdit() { caret_blink_timer->connect("timeout", this, "_toggle_draw_caret"); cursor_set_blink_enabled(false); + context_menu_enabled = true; menu = memnew(PopupMenu); add_child(menu); menu->add_item(TTR("Cut"), MENU_CUT, KEY_MASK_CMD | KEY_X); diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index bece29a37d..c3a299c2f5 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -74,6 +74,7 @@ private: String ime_text; Point2 ime_selection; + bool context_menu_enabled; PopupMenu *menu; int cursor_pos; @@ -150,6 +151,8 @@ public: virtual void drop_data(const Point2 &p_point, const Variant &p_data); void menu_option(int p_option); + void set_context_menu_enabled(bool p_enable); + bool is_context_menu_enabled(); PopupMenu *get_menu() const; void select_all(); diff --git a/scene/gui/scroll_container.cpp b/scene/gui/scroll_container.cpp index 1ad1e3f638..9022d67a4a 100644 --- a/scene/gui/scroll_container.cpp +++ b/scene/gui/scroll_container.cpp @@ -347,12 +347,11 @@ void ScrollContainer::update_scrollbars() { } else { v_scroll->show(); + v_scroll->set_max(min.height); + v_scroll->set_page(size.height - hmin.height); scroll.y = v_scroll->get_value(); } - v_scroll->set_max(min.height); - v_scroll->set_page(size.height - hmin.height); - if (!scroll_h || min.width <= size.width - vmin.width) { h_scroll->hide(); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 7d200a799b..c9af7eed0d 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -274,6 +274,7 @@ void TextEdit::Text::insert(int p_at, const String &p_text) { Line line; line.marked = false; line.breakpoint = false; + line.hidden = false; line.width_cache = -1; line.data = p_text; text.insert(p_at, line); @@ -297,9 +298,11 @@ void TextEdit::_update_scrollbars() { int hscroll_rows = ((hmin.height - 1) / get_row_height()) + 1; int visible_rows = get_visible_rows(); - int total_rows = text.size(); + int num_rows = MAX(visible_rows, num_lines_from(CLAMP(cursor.line_ofs, 0, text.size() - 1), MIN(visible_rows, text.size() - 1 - cursor.line_ofs))); + + int total_rows = (is_hiding_enabled() ? get_total_unhidden_rows() : text.size()); if (scroll_past_end_of_file_enabled) { - total_rows += get_visible_rows() - 1; + total_rows += visible_rows - 1; } int vscroll_pixels = v_scroll->get_combined_minimum_size().width; @@ -313,6 +316,10 @@ void TextEdit::_update_scrollbars() { total_width += cache.breakpoint_gutter_width; } + if (draw_fold_gutter) { + total_width += cache.fold_gutter_width; + } + bool use_hscroll = true; bool use_vscroll = true; @@ -347,12 +354,11 @@ void TextEdit::_update_scrollbars() { v_scroll->set_step(1); } - if (fabs(v_scroll->get_value() - (double)cursor.line_ofs) >= 1) { - v_scroll->set_value(cursor.line_ofs); - } - + update_line_scroll_pos(); } else { cursor.line_ofs = 0; + line_scroll_pos = 0; + v_scroll->set_value(0); v_scroll->hide(); } @@ -551,6 +557,13 @@ void TextEdit::_notification(int p_what) { cache.breakpoint_gutter_width = 0; } + if (draw_fold_gutter) { + fold_gutter_width = (get_row_height() * 55) / 100; + cache.fold_gutter_width = fold_gutter_width; + } else { + cache.fold_gutter_width = 0; + } + int line_number_char_count = 0; { @@ -573,7 +586,7 @@ void TextEdit::_notification(int p_what) { RID ci = get_canvas_item(); VisualServer::get_singleton()->canvas_item_set_clip(get_canvas_item(), true); - int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width; + int xmargin_beg = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width; int xmargin_end = cache.size.width - cache.style_normal->get_margin(MARGIN_RIGHT); //let's do it easy for now: cache.style_normal->draw(ci, Rect2(Point2(), cache.size)); @@ -780,10 +793,22 @@ void TextEdit::_notification(int p_what) { String highlighted_text = get_selection_text(); String line_num_padding = line_numbers_zero_padded ? "0" : " "; + update_line_scroll_pos(); + int line = cursor.line_ofs - 1; for (int i = 0; i < visible_rows; i++) { - int line = i + cursor.line_ofs; + line++; + + if (line < 0 || line >= (int)text.size()) + continue; + + while (is_line_hidden(line)) { + line++; + if (line < 0 || line >= (int)text.size()) { + break; + } + } if (line < 0 || line >= (int)text.size()) continue; @@ -794,7 +819,7 @@ void TextEdit::_notification(int p_what) { int char_ofs = 0; int ofs_y = (i * get_row_height() + cache.line_spacing / 2); if (smooth_scroll_enabled) { - ofs_y -= (v_scroll->get_value() - cursor.line_ofs) * get_row_height(); + ofs_y -= (v_scroll->get_value() - get_line_scroll_pos()) * get_row_height(); } bool prev_is_char = false; @@ -857,6 +882,21 @@ void TextEdit::_notification(int p_what) { } } + // draw fold markers + if (draw_fold_gutter) { + int horizontal_gap = (cache.fold_gutter_width * 30) / 100; + int gutter_left = cache.style_normal->get_margin(MARGIN_LEFT) + cache.breakpoint_gutter_width + cache.line_number_w; + if (is_folded(line)) { + int xofs = horizontal_gap - (cache.can_fold_icon->get_width()) / 2; + int yofs = (get_row_height() - cache.folded_icon->get_height()) / 2; + cache.folded_icon->draw(ci, Point2(gutter_left + xofs, ofs_y + yofs), Color(0.8f, 0.8f, 0.8f, 0.8f)); + } else if (can_fold(line)) { + int xofs = -cache.can_fold_icon->get_width() / 2 - horizontal_gap + 3; + int yofs = (get_row_height() - cache.can_fold_icon->get_height()) / 2; + cache.can_fold_icon->draw(ci, Point2(gutter_left + xofs, ofs_y + yofs), Color(0.8f, 0.8f, 0.8f, 0.8f)); + } + } + if (cache.line_number_w) { String fc = String::num(line + 1); while (fc.length() < line_number_char_count) { @@ -894,17 +934,18 @@ void TextEdit::_notification(int p_what) { is_hex_notation = false; } - // check for dot or 'x' for hex notation in floating point number - if ((str[j] == '.' || str[j] == 'x') && !in_word && prev_is_number && !is_number) { + // check for dot or underscore or 'x' for hex notation in floating point number + if ((str[j] == '.' || str[j] == 'x' || str[j] == '_') && !in_word && prev_is_number && !is_number) { is_number = true; is_symbol = false; + is_char = false; if (str[j] == 'x' && str[j - 1] == '0') { is_hex_notation = true; } } - if (!in_word && _is_char(str[j])) { + if (!in_word && _is_char(str[j]) && !is_number) { in_word = true; } @@ -1195,6 +1236,10 @@ void TextEdit::_notification(int p_what) { } char_ofs += char_w; + + if (j == str.length() - 1 && is_folded(line)) { + cache.folded_eol_icon->draw(ci, Point2(char_ofs + char_margin, ofs_y), Color(1, 1, 1, 1), true); + } } if (cursor.column == str.length() && cursor.line == line && (char_ofs + char_margin) >= xmargin_beg) { @@ -1537,6 +1582,12 @@ void TextEdit::backspace_at_cursor() { int prev_line = cursor.column ? cursor.line : cursor.line - 1; int prev_column = cursor.column ? (cursor.column - 1) : (text[cursor.line - 1].length()); + + if (is_line_hidden(cursor.line)) + set_line_as_hidden(prev_line, true); + if (is_line_set_as_breakpoint(cursor.line)) + set_line_as_breakpoint(prev_line, true); + if (auto_brace_completion_enabled && cursor.column > 0 && _is_pair_left_symbol(text[cursor.line][cursor.column - 1])) { @@ -1576,7 +1627,7 @@ void TextEdit::backspace_at_cursor() { } } - cursor_set_line(prev_line); + cursor_set_line(prev_line, true, true); cursor_set_column(prev_column); } @@ -1650,10 +1701,18 @@ void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) co float rows = p_mouse.y; rows -= cache.style_normal->get_margin(MARGIN_TOP); rows /= get_row_height(); - int row = cursor.line_ofs + (rows + (v_scroll->get_value() - cursor.line_ofs)); + int lsp = get_line_scroll_pos(true); + int row = cursor.line_ofs + (rows + (v_scroll->get_value() - lsp)); + + if (is_hiding_enabled()) { + // row will be offset by the hidden rows + int f_ofs = num_lines_from(CLAMP(cursor.line_ofs, 0, text.size() - 1), MIN(rows + 1, text.size() - cursor.line_ofs)) - 1; + row = cursor.line_ofs + (f_ofs + (v_scroll->get_value() - lsp)); + row = CLAMP(row, 0, text.size() - num_lines_from(text.size() - 1, -1)); + } if (row < 0) - row = 0; + row = 0; //todo int col = 0; @@ -1663,7 +1722,7 @@ void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) co col = text[row].size(); } else { - col = p_mouse.x - (cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width); + col = p_mouse.x - (cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width); col += cursor.x_ofs; col = get_char_pos_for(col, get_line(row)); } @@ -1716,10 +1775,11 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (mb->is_pressed()) { if (mb->get_button_index() == BUTTON_WHEEL_UP && !mb->get_command()) { + float scroll_factor = 3 * mb->get_factor(); if (scrolling) { - target_v_scroll = (target_v_scroll - (3 * mb->get_factor())); + target_v_scroll = (target_v_scroll - scroll_factor); } else { - target_v_scroll = (v_scroll->get_value() - (3 * mb->get_factor())); + target_v_scroll = (v_scroll->get_value() - scroll_factor); } if (smooth_scroll_enabled) { @@ -1733,16 +1793,18 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } } if (mb->get_button_index() == BUTTON_WHEEL_DOWN && !mb->get_command()) { + float scroll_factor = 3 * mb->get_factor(); if (scrolling) { - target_v_scroll = (target_v_scroll + (3 * mb->get_factor())); + target_v_scroll = (target_v_scroll + scroll_factor); } else { - target_v_scroll = (v_scroll->get_value() + (3 * mb->get_factor())); + target_v_scroll = (v_scroll->get_value() + scroll_factor); } if (smooth_scroll_enabled) { - int max_v_scroll = get_line_count() - 1; + int max_v_scroll = get_total_unhidden_rows(); if (!scroll_past_end_of_file_enabled) { - max_v_scroll -= get_visible_rows() - 1; + max_v_scroll -= get_visible_rows(); + max_v_scroll = CLAMP(max_v_scroll, 0, get_total_unhidden_rows()); } if (target_v_scroll > max_v_scroll) { @@ -1765,6 +1827,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { _reset_caret_blink_timer(); int row, col; + update_line_scroll_pos(); _get_mouse_pos(Point2i(mb->get_position().x, mb->get_position().y), row, col); if (mb->get_command() && highlighted_word != String()) { @@ -1783,10 +1846,35 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } } + // toggle fold on gutter click if can + if (draw_fold_gutter) { + + int left_margin = cache.style_normal->get_margin(MARGIN_LEFT); + int gutter_left = left_margin + cache.breakpoint_gutter_width + cache.line_number_w; + if (mb->get_position().x > gutter_left - 6 && mb->get_position().x <= gutter_left + cache.fold_gutter_width - 3) { + if (is_folded(row)) { + unfold_line(row); + } else if (can_fold(row)) { + fold_line(row); + } + return; + } + } + + // unfold on folded icon click + if (is_folded(row)) { + int line_width = text.get_line_width(row); + line_width += cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width - cursor.x_ofs; + if (mb->get_position().x > line_width - 3 && mb->get_position().x <= line_width + cache.folded_eol_icon->get_width() + 3) { + unfold_line(row); + return; + } + } + int prev_col = cursor.column; int prev_line = cursor.line; - cursor_set_line(row); + cursor_set_line(row, true, false); cursor_set_column(col); if (mb->get_shift() && (cursor.column != prev_col || cursor.line != prev_line)) { @@ -2025,17 +2113,6 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { return; } - if (k->get_scancode() == KEY_DOWN) { - - if (completion_index < completion_options.size() - 1) { - completion_index++; - completion_current = completion_options[completion_index]; - update(); - } - accept_event(); - return; - } - if (k->get_scancode() == KEY_KP_ENTER || k->get_scancode() == KEY_ENTER || k->get_scancode() == KEY_TAB) { _confirm_completion(); @@ -2189,7 +2266,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { selection.active = false; update(); _remove_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column); - cursor_set_line(selection.from_line); + cursor_set_line(selection.from_line, true, false); cursor_set_column(selection.from_column); update(); } @@ -2239,6 +2316,9 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } } + if (is_folded(cursor.line)) + unfold_line(cursor.line); + bool brace_indent = false; // no need to indent if we are going upwards. @@ -2389,6 +2469,8 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { cursor_set_column(column); } else { + if (cursor.line > 0 && is_line_hidden(cursor.line - 1)) + unfold_line(cursor.line - 1); backspace_at_cursor(); } @@ -2447,7 +2529,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } else if (cursor.column == 0) { if (cursor.line > 0) { - cursor_set_line(cursor.line - 1); + cursor_set_line(cursor.line - num_lines_from(CLAMP(cursor.line - 1, 0, text.size() - 1), -1)); cursor_set_column(text[cursor.line].length()); } } else { @@ -2510,7 +2592,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } else if (cursor.column == text[cursor.line].length()) { if (cursor.line < text.size() - 1) { - cursor_set_line(cursor.line + 1); + cursor_set_line(cursor_get_line() + num_lines_from(CLAMP(cursor.line + 1, 0, text.size() - 1), 1), true, false); cursor_set_column(0); } } else { @@ -2551,7 +2633,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { cursor_set_line(0); else #endif - cursor_set_line(cursor_get_line() - 1); + cursor_set_line(cursor_get_line() - num_lines_from(CLAMP(cursor.line - 1, 0, text.size() - 1), -1)); if (k->get_shift()) _post_shift_selection(); @@ -2585,10 +2667,10 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } if (k->get_command()) - cursor_set_line(text.size() - 1); + cursor_set_line(text.size() - 1, true, false); else #endif - cursor_set_line(cursor_get_line() + 1); + cursor_set_line(cursor_get_line() + num_lines_from(CLAMP(cursor.line + 1, 0, text.size() - 1), 1), true, false); if (k->get_shift()) _post_shift_selection(); @@ -2735,7 +2817,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (k->get_shift()) _pre_shift_selection(); - cursor_set_line(text.size() - 1); + cursor_set_line(text.size() - 1, true, false); if (k->get_shift()) _post_shift_selection(); @@ -2750,7 +2832,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { _pre_shift_selection(); if (k->get_command()) - cursor_set_line(text.size() - 1); + cursor_set_line(text.size() - 1, true, false); cursor_set_column(text[cursor.line].length()); if (k->get_shift()) @@ -2775,7 +2857,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (k->get_shift()) _pre_shift_selection(); - cursor_set_line(cursor_get_line() - get_visible_rows()); + cursor_set_line(cursor_get_line() - num_lines_from(cursor.line, -get_visible_rows()), true, false); if (k->get_shift()) _post_shift_selection(); @@ -2796,7 +2878,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (k->get_shift()) _pre_shift_selection(); - cursor_set_line(cursor_get_line() + get_visible_rows()); + cursor_set_line(cursor_get_line() + num_lines_from(cursor.line, get_visible_rows()), true, false); if (k->get_shift()) _post_shift_selection(); @@ -3014,8 +3096,9 @@ void TextEdit::_scroll_lines_up() { } // adjust the cursor - if (cursor_get_line() >= (get_visible_rows() + get_v_scroll()) && !selection.active) { - cursor_set_line((get_visible_rows() + get_v_scroll()) - 1, false); + int num_lines = num_lines_from(CLAMP(cursor.line_ofs, 0, text.size() - 1), get_visible_rows()) - 1; + if (cursor.line >= cursor.line_ofs + num_lines && !selection.active) { + cursor_set_line(cursor.line_ofs + num_lines, false, false); } } @@ -3023,9 +3106,10 @@ void TextEdit::_scroll_lines_down() { scrolling = false; // calculate the maximum vertical scroll position - int max_v_scroll = get_line_count() - 1; + int max_v_scroll = get_total_unhidden_rows(); if (!scroll_past_end_of_file_enabled) { - max_v_scroll -= get_visible_rows() - 1; + max_v_scroll -= get_visible_rows(); + max_v_scroll = CLAMP(max_v_scroll, 0, get_total_unhidden_rows()); } // adjust the vertical scroll @@ -3034,8 +3118,8 @@ void TextEdit::_scroll_lines_down() { } // adjust the cursor - if ((cursor_get_line()) <= get_v_scroll() - 1 && !selection.active) { - cursor_set_line(get_v_scroll(), false); + if (cursor.line <= cursor.line_ofs - 1 && !selection.active) { + cursor_set_line(cursor.line_ofs, false, false); } } @@ -3080,6 +3164,15 @@ void TextEdit::_base_insert_text(int p_line, int p_char, const String &p_text, i } } + // if we are just making a new empty line, reset breakpoints and hidden status + if (p_char == 0 && p_text.replace("\r", "") == "\n") { + + text.set_breakpoint(p_line + 1, text.is_breakpoint(p_line)); + text.set_hidden(p_line + 1, text.is_hidden(p_line)); + text.set_breakpoint(p_line, false); + text.set_hidden(p_line, false); + } + r_end_line = p_line + substrings.size() - 1; r_end_column = text[r_end_line].length() - postinsert_text.length(); @@ -3278,6 +3371,7 @@ Size2 TextEdit::get_minimum_size() const { return cache.style_normal->get_minimum_size(); } + int TextEdit::get_visible_rows() const { int total = cache.size.height; @@ -3285,31 +3379,81 @@ int TextEdit::get_visible_rows() const { total /= get_row_height(); return total; } + +int TextEdit::get_total_unhidden_rows() const { + if (!is_hiding_enabled()) + return text.size(); + + int total_unhidden = 0; + for (int i = 0; i < text.size(); i++) { + if (!text.is_hidden(i)) + total_unhidden++; + } + return total_unhidden; +} + +double TextEdit::get_line_scroll_pos(bool p_recalculate) const { + + if (!is_hiding_enabled()) + return cursor.line_ofs; + if (!p_recalculate) + return line_scroll_pos; + + // count num unhidden lines to the cursor line ofs + double new_line_scroll_pos = 0; + int to = CLAMP(cursor.line_ofs, 0, text.size() - 1); + for (int i = 0; i < to; i++) { + if (!text.is_hidden(i)) + new_line_scroll_pos++; + } + return new_line_scroll_pos; +} + +void TextEdit::update_line_scroll_pos() { + + if (!is_hiding_enabled()) { + line_scroll_pos = cursor.line_ofs; + return; + } + + // count num unhidden lines to the cursor line ofs + double new_line_scroll_pos = 0; + int to = CLAMP(cursor.line_ofs, 0, text.size() - 1); + for (int i = 0; i < to; i++) { + if (!text.is_hidden(i)) + new_line_scroll_pos++; + } + line_scroll_pos = new_line_scroll_pos; +} + void TextEdit::adjust_viewport_to_cursor() { scrolling = false; - if (cursor.line_ofs > cursor.line) + if (cursor.line_ofs > cursor.line) { cursor.line_ofs = cursor.line; + } - int visible_width = cache.size.width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width; + int visible_width = cache.size.width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width; if (v_scroll->is_visible_in_tree()) visible_width -= v_scroll->get_combined_minimum_size().width; visible_width -= 20; // give it a little more space - //printf("rowofs %i, visrows %i, cursor.line %i\n",cursor.line_ofs,get_visible_rows(),cursor.line); - int visible_rows = get_visible_rows(); if (h_scroll->is_visible_in_tree()) visible_rows -= ((h_scroll->get_combined_minimum_size().height - 1) / get_row_height()); + int num_rows = num_lines_from(CLAMP(cursor.line_ofs, 0, text.size() - 1), MIN(visible_rows, text.size() - 1 - cursor.line_ofs)); - if (cursor.line >= (cursor.line_ofs + visible_rows)) - cursor.line_ofs = cursor.line - visible_rows; - if (cursor.line < cursor.line_ofs) + // if the cursor is off the screen + if (cursor.line >= (cursor.line_ofs + MAX(num_rows, visible_rows))) { + cursor.line_ofs = cursor.line - (num_lines_from(CLAMP(cursor.line, 0, text.size() - 1), -visible_rows) - 1); + } + if (cursor.line < cursor.line_ofs) { cursor.line_ofs = cursor.line; + } - if (cursor.line_ofs + visible_rows > text.size() && !scroll_past_end_of_file_enabled) { - cursor.line_ofs = text.size() - visible_rows; - v_scroll->set_value(text.size() - visible_rows); + // fixes deleting lines from moving the line ofs in a bad way + if (!scroll_past_end_of_file_enabled && get_total_unhidden_rows() > visible_rows && num_rows < visible_rows) { + cursor.line_ofs = text.size() - 1 - (num_lines_from(text.size() - 1, -visible_rows) - 1); } int cursor_x = get_column_x_offset(cursor.column, text[cursor.line]); @@ -3320,6 +3464,8 @@ void TextEdit::adjust_viewport_to_cursor() { if (cursor_x < cursor.x_ofs) cursor.x_ofs = cursor_x; + update_line_scroll_pos(); + v_scroll->set_value(get_line_scroll_pos() + 1); update(); /* get_range()->set_max(text.size()); @@ -3336,7 +3482,10 @@ void TextEdit::center_viewport_to_cursor() { if (cursor.line_ofs > cursor.line) cursor.line_ofs = cursor.line; - int visible_width = cache.size.width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width; + if (is_line_hidden(cursor.line)) + unfold_line(cursor.line); + + int visible_width = cache.size.width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width; if (v_scroll->is_visible_in_tree()) visible_width -= v_scroll->get_combined_minimum_size().width; visible_width -= 20; // give it a little more space @@ -3345,9 +3494,8 @@ void TextEdit::center_viewport_to_cursor() { if (h_scroll->is_visible_in_tree()) visible_rows -= ((h_scroll->get_combined_minimum_size().height - 1) / get_row_height()); - int max_ofs = text.size() - (scroll_past_end_of_file_enabled ? 1 : visible_rows); - cursor.line_ofs = CLAMP(cursor.line - (visible_rows / 2), 0, max_ofs); - + int max_ofs = text.size() - (scroll_past_end_of_file_enabled ? 1 : num_lines_from(text.size() - 1, -visible_rows)); + cursor.line_ofs = CLAMP(cursor.line - num_lines_from(cursor.line - visible_rows / 2, -visible_rows / 2), 0, max_ofs); int cursor_x = get_column_x_offset(cursor.column, text[cursor.line]); if (cursor_x > (cursor.x_ofs + visible_width)) @@ -3356,6 +3504,9 @@ void TextEdit::center_viewport_to_cursor() { if (cursor_x < cursor.x_ofs) cursor.x_ofs = cursor_x; + update_line_scroll_pos(); + v_scroll->set_value(get_line_scroll_pos()); + update(); } @@ -3380,7 +3531,7 @@ void TextEdit::cursor_set_column(int p_col, bool p_adjust_viewport) { } } -void TextEdit::cursor_set_line(int p_row, bool p_adjust_viewport) { +void TextEdit::cursor_set_line(int p_row, bool p_adjust_viewport, bool p_can_be_hidden) { if (setting_row) return; @@ -3392,6 +3543,21 @@ void TextEdit::cursor_set_line(int p_row, bool p_adjust_viewport) { if (p_row >= (int)text.size()) p_row = (int)text.size() - 1; + if (!p_can_be_hidden) { + if (is_line_hidden(CLAMP(p_row, 0, text.size() - 1))) { + int move_down = num_lines_from(p_row, 1) - 1; + if (p_row + move_down <= text.size() - 1 && !is_line_hidden(p_row + move_down)) { + p_row += move_down; + } else { + int move_up = num_lines_from(p_row, -1) - 1; + if (p_row - move_up > 0 && !is_line_hidden(p_row - move_up)) { + p_row -= move_up; + } else { + WARN_PRINTS(("Cursor set to hidden line " + itos(p_row) + " and there are no nonhidden lines.")); + } + } + } + } cursor.line = p_row; cursor.column = get_char_pos_for(cursor.last_fit_x, get_line(cursor.line)); @@ -3461,8 +3627,11 @@ void TextEdit::_scroll_moved(double p_to_val) { if (h_scroll->is_visible_in_tree()) cursor.x_ofs = h_scroll->get_value(); - if (v_scroll->is_visible_in_tree()) - cursor.line_ofs = v_scroll->get_value(); + if (v_scroll->is_visible_in_tree()) { + double val = v_scroll->get_value(); + cursor.line_ofs = num_lines_from(0, (int)floor(val)) - 1; + line_scroll_pos = (int)floor(val); + } update(); } @@ -3551,10 +3720,43 @@ Control::CursorShape TextEdit::get_cursor_shape(const Point2 &p_pos) const { if (highlighted_word != String()) return CURSOR_POINTING_HAND; - int gutter = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width; - if ((completion_active && completion_rect.has_point(p_pos)) || p_pos.x < gutter) { + int gutter = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width; + if ((completion_active && completion_rect.has_point(p_pos))) { return CURSOR_ARROW; } + if (p_pos.x < gutter) { + + int row, col; + _get_mouse_pos(p_pos, row, col); + int left_margin = cache.style_normal->get_margin(MARGIN_LEFT); + + // breakpoint icon + if (draw_breakpoint_gutter && p_pos.x > left_margin && p_pos.x <= left_margin + cache.breakpoint_gutter_width + 3) { + return CURSOR_POINTING_HAND; + } + + // fold icon + int gutter_left = left_margin + cache.breakpoint_gutter_width + cache.line_number_w; + if (draw_fold_gutter && p_pos.x > gutter_left - 6 && p_pos.x <= gutter_left + cache.fold_gutter_width - 3) { + if (is_folded(row) || can_fold(row)) + return CURSOR_POINTING_HAND; + else + return CURSOR_ARROW; + } + return CURSOR_ARROW; + } else { + int row, col; + _get_mouse_pos(p_pos, row, col); + // eol fold icon + if (is_folded(row)) { + int line_width = text.get_line_width(row); + line_width += cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width - cursor.x_ofs; + if (p_pos.x > line_width - 3 && p_pos.x <= line_width + cache.folded_eol_icon->get_width() + 3) { + return CURSOR_POINTING_HAND; + } + } + } + return CURSOR_IBEAM; } @@ -3568,6 +3770,7 @@ void TextEdit::set_text(String p_text) { cursor.line = 0; cursor.x_ofs = 0; cursor.line_ofs = 0; + line_scroll_pos = 0; cursor.last_fit_x = 0; cursor_set_line(0); cursor_set_column(0); @@ -3653,6 +3856,7 @@ void TextEdit::_clear() { cursor.line = 0; cursor.x_ofs = 0; cursor.line_ofs = 0; + line_scroll_pos = 0; cursor.last_fit_x = 0; } @@ -3668,6 +3872,11 @@ void TextEdit::set_readonly(bool p_readonly) { readonly = p_readonly; } +bool TextEdit::is_readonly() const { + + return readonly; +} + void TextEdit::set_wrap(bool p_wrap) { wrap = p_wrap; @@ -3726,6 +3935,9 @@ void TextEdit::_update_caches() { cache.line_spacing = get_constant("line_spacing"); cache.row_height = cache.font->get_height() + cache.line_spacing; cache.tab_icon = get_icon("tab"); + cache.folded_icon = get_icon("GuiTreeArrowRight", "EditorIcons"); + cache.can_fold_icon = get_icon("GuiTreeArrowDown", "EditorIcons"); + cache.folded_eol_icon = get_icon("GuiTabMenu", "EditorIcons"); text.set_font(cache.font); } @@ -3900,7 +4112,12 @@ void TextEdit::select(int p_from_line, int p_from_column, int p_to_line, int p_t update(); } - +void TextEdit::swap_lines(int line1, int line2) { + String tmp = get_line(line1); + String tmp2 = get_line(line2); + set_line(line2, tmp); + set_line(line1, tmp2); +} bool TextEdit::is_selection_active() const { return selection.active; @@ -4167,6 +4384,198 @@ void TextEdit::get_breakpoints(List<int> *p_breakpoints) const { } } +void TextEdit::set_line_as_hidden(int p_line, bool p_hidden) { + + ERR_FAIL_INDEX(p_line, text.size()); + if (is_hiding_enabled() || !p_hidden) + text.set_hidden(p_line, p_hidden); + update(); +} + +bool TextEdit::is_line_hidden(int p_line) const { + + ERR_FAIL_INDEX_V(p_line, text.size(), false); + return text.is_hidden(p_line); +} + +void TextEdit::fold_all_lines() { + + for (int i = 0; i < text.size(); i++) { + fold_line(i); + } + _update_scrollbars(); + update(); +} + +void TextEdit::unhide_all_lines() { + + for (int i = 0; i < text.size(); i++) { + text.set_hidden(i, false); + } + _update_scrollbars(); + update(); +} + +int TextEdit::num_lines_from(int p_line_from, int unhidden_amount) const { + + // returns the number of hidden and unhidden lines from p_line_from to p_line_from + amount of visible lines + ERR_FAIL_INDEX_V(p_line_from, text.size(), ABS(unhidden_amount)); + + if (!is_hiding_enabled()) + return unhidden_amount; + int num_visible = 0; + int num_total = 0; + if (unhidden_amount >= 0) { + for (int i = p_line_from; i < text.size(); i++) { + num_total++; + if (!is_line_hidden(i)) + num_visible++; + if (num_visible >= unhidden_amount) + break; + } + } else { + unhidden_amount = ABS(unhidden_amount); + for (int i = p_line_from; i >= 0; i--) { + num_total++; + if (!is_line_hidden(i)) + num_visible++; + if (num_visible >= unhidden_amount) + break; + } + } + return num_total; +} + +int TextEdit::get_whitespace_level(int p_line) const { + + ERR_FAIL_INDEX_V(p_line, text.size(), 0); + + // counts number of tabs and spaces before line starts + int whitespace_count = 0; + int line_length = text[p_line].size(); + for (int i = 0; i < line_length - 1; i++) { + if (text[p_line][i] == '\t') { + whitespace_count++; + } else if (text[p_line][i] == ' ') { + whitespace_count++; + } else if (text[p_line][i] == '#') { + break; + } else { + break; + } + } + return whitespace_count; +} + +bool TextEdit::can_fold(int p_line) const { + + ERR_FAIL_INDEX_V(p_line, text.size(), false); + if (!is_hiding_enabled()) + return false; + if (p_line + 1 >= text.size()) + return false; + if (text[p_line].size() == 0) + return false; + if (is_folded(p_line)) + return false; + if (is_line_hidden(p_line)) + return false; + + int start_indent = get_whitespace_level(p_line); + + for (int i = p_line + 1; i < text.size(); i++) { + if (text[i].size() == 0) + continue; + int next_indent = get_whitespace_level(i); + if (next_indent > start_indent) + return true; + else + return false; + } + + return false; +} + +bool TextEdit::is_folded(int p_line) const { + + ERR_FAIL_INDEX_V(p_line, text.size(), false); + if (p_line + 1 >= text.size() - 1) + return false; + if (!is_line_hidden(p_line) && is_line_hidden(p_line + 1)) + return true; + return false; +} + +void TextEdit::fold_line(int p_line) { + + ERR_FAIL_INDEX(p_line, text.size()); + if (!is_hiding_enabled()) + return; + if (!can_fold(p_line)) + return; + + // hide lines below this one + int start_indent = get_whitespace_level(p_line); + for (int i = p_line + 1; i < text.size(); i++) { + int cur_indent = get_whitespace_level(i); + if (text[i].size() == 0 || cur_indent > start_indent) { + set_line_as_hidden(i, true); + } else { + // exclude trailing empty lines + for (int trail_i = i - 1; trail_i > p_line; trail_i--) { + if (text[trail_i].size() == 0) + set_line_as_hidden(trail_i, false); + else + break; + } + break; + } + } + + // fix selection + if (is_selection_active()) { + if (is_line_hidden(selection.from_line) && is_line_hidden(selection.to_line)) { + deselect(); + } else if (is_line_hidden(selection.from_line)) { + select(p_line, 9999, selection.to_line, selection.to_column); + } else if (is_line_hidden(selection.to_line)) { + select(selection.from_line, selection.from_column, p_line, 9999); + } + } + + // reset cursor + if (is_line_hidden(cursor.line)) { + cursor_set_line(p_line, false, false); + cursor_set_column(get_line(p_line).length(), false); + } + _update_scrollbars(); + update(); +} + +void TextEdit::unfold_line(int p_line) { + + ERR_FAIL_INDEX(p_line, text.size()); + + if (!is_folded(p_line) && !is_line_hidden(p_line)) + return; + int fold_start = p_line; + for (fold_start = p_line; fold_start > 0; fold_start--) { + if (is_folded(fold_start)) + break; + } + fold_start = is_folded(fold_start) ? fold_start : p_line; + + for (int i = fold_start + 1; i < text.size(); i++) { + if (is_line_hidden(i)) { + set_line_as_hidden(i, false); + } else { + break; + } + } + _update_scrollbars(); + update(); +} + int TextEdit::get_line_count() const { return text.size(); @@ -4393,12 +4802,14 @@ void TextEdit::set_v_scroll(int p_scroll) { p_scroll = 0; } if (!scroll_past_end_of_file_enabled) { - if (p_scroll + get_visible_rows() > get_line_count()) { - p_scroll = get_line_count() - get_visible_rows(); + if (p_scroll + get_visible_rows() > get_total_unhidden_rows()) { + int num_rows = num_lines_from(CLAMP(p_scroll, 0, text.size() - 1), MIN(get_visible_rows(), text.size() - 1 - p_scroll)); + p_scroll = text.size() - num_rows; } } v_scroll->set_value(p_scroll); - cursor.line_ofs = p_scroll; + cursor.line_ofs = num_lines_from(0, p_scroll); + line_scroll_pos = p_scroll; } int TextEdit::get_h_scroll() const { @@ -4760,7 +5171,7 @@ void TextEdit::set_line(int line, String new_text) { void TextEdit::insert_at(const String &p_text, int at) { cursor_set_column(0); - cursor_set_line(at); + cursor_set_line(at, false, true); _insert_text(at, 0, p_text + "\n"); } @@ -4808,6 +5219,35 @@ int TextEdit::get_breakpoint_gutter_width() const { return cache.breakpoint_gutter_width; } +void TextEdit::set_draw_fold_gutter(bool p_draw) { + draw_fold_gutter = p_draw; + update(); +} + +bool TextEdit::is_drawing_fold_gutter() const { + return draw_fold_gutter; +} + +void TextEdit::set_fold_gutter_width(int p_gutter_width) { + fold_gutter_width = p_gutter_width; + update(); +} + +int TextEdit::get_fold_gutter_width() const { + return cache.fold_gutter_width; +} + +void TextEdit::set_hiding_enabled(int p_enabled) { + if (!p_enabled) + unhide_all_lines(); + hiding_enabled = p_enabled; + update(); +} + +int TextEdit::is_hiding_enabled() const { + return hiding_enabled; +} + void TextEdit::set_highlight_current_line(bool p_enabled) { highlight_current_line = p_enabled; update(); @@ -4866,6 +5306,10 @@ void TextEdit::set_context_menu_enabled(bool p_enable) { context_menu_enabled = p_enable; } +bool TextEdit::is_context_menu_enabled() { + return context_menu_enabled; +} + PopupMenu *TextEdit::get_menu() const { return menu; } @@ -4898,7 +5342,7 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("get_line", "line"), &TextEdit::get_line); ClassDB::bind_method(D_METHOD("cursor_set_column", "column", "adjust_viewport"), &TextEdit::cursor_set_column, DEFVAL(true)); - ClassDB::bind_method(D_METHOD("cursor_set_line", "line", "adjust_viewport"), &TextEdit::cursor_set_line, DEFVAL(true)); + ClassDB::bind_method(D_METHOD("cursor_set_line", "line", "adjust_viewport", "can_be_hidden"), &TextEdit::cursor_set_line, DEFVAL(true), DEFVAL(true)); ClassDB::bind_method(D_METHOD("cursor_get_column"), &TextEdit::cursor_get_column); ClassDB::bind_method(D_METHOD("cursor_get_line"), &TextEdit::cursor_get_line); @@ -4910,8 +5354,12 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("cursor_is_block_mode"), &TextEdit::cursor_is_block_mode); ClassDB::bind_method(D_METHOD("set_readonly", "enable"), &TextEdit::set_readonly); + ClassDB::bind_method(D_METHOD("is_readonly"), &TextEdit::is_readonly); + ClassDB::bind_method(D_METHOD("set_wrap", "enable"), &TextEdit::set_wrap); ClassDB::bind_method(D_METHOD("set_max_chars", "amount"), &TextEdit::set_max_chars); + ClassDB::bind_method(D_METHOD("set_context_menu_enabled", "enable"), &TextEdit::set_context_menu_enabled); + ClassDB::bind_method(D_METHOD("is_context_menu_enabled"), &TextEdit::is_context_menu_enabled); ClassDB::bind_method(D_METHOD("cut"), &TextEdit::cut); ClassDB::bind_method(D_METHOD("copy"), &TextEdit::copy); @@ -4935,6 +5383,17 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("set_show_line_numbers", "enable"), &TextEdit::set_show_line_numbers); ClassDB::bind_method(D_METHOD("is_show_line_numbers_enabled"), &TextEdit::is_show_line_numbers_enabled); + ClassDB::bind_method(D_METHOD("set_hiding_enabled", "enable"), &TextEdit::set_hiding_enabled); + ClassDB::bind_method(D_METHOD("is_hiding_enabled"), &TextEdit::is_hiding_enabled); + ClassDB::bind_method(D_METHOD("set_line_as_hidden", "line", "enable"), &TextEdit::set_line_as_hidden); + ClassDB::bind_method(D_METHOD("is_line_hidden"), &TextEdit::is_line_hidden); + ClassDB::bind_method(D_METHOD("fold_all_lines"), &TextEdit::fold_all_lines); + ClassDB::bind_method(D_METHOD("unhide_all_lines"), &TextEdit::unhide_all_lines); + ClassDB::bind_method(D_METHOD("fold_line", "line"), &TextEdit::fold_line); + ClassDB::bind_method(D_METHOD("unfold_line", "line"), &TextEdit::unfold_line); + ClassDB::bind_method(D_METHOD("can_fold", "line"), &TextEdit::can_fold); + ClassDB::bind_method(D_METHOD("is_folded", "line"), &TextEdit::is_folded); + ClassDB::bind_method(D_METHOD("set_highlight_all_occurrences", "enable"), &TextEdit::set_highlight_all_occurrences); ClassDB::bind_method(D_METHOD("is_highlight_all_occurrences_enabled"), &TextEdit::is_highlight_all_occurrences_enabled); @@ -4958,13 +5417,17 @@ void TextEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("menu_option", "option"), &TextEdit::menu_option); ClassDB::bind_method(D_METHOD("get_menu"), &TextEdit::get_menu); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "text", PROPERTY_HINT_MULTILINE_TEXT), "set_text", "get_text"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "readonly"), "set_readonly", "is_readonly"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_current_line"), "set_highlight_current_line", "is_highlight_current_line_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "syntax_highlighting"), "set_syntax_coloring", "is_syntax_coloring_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_line_numbers"), "set_show_line_numbers", "is_show_line_numbers_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "highlight_all_occurrences"), "set_highlight_all_occurrences", "is_highlight_all_occurrences_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "override_selected_font_color"), "set_override_selected_font_color", "is_overriding_selected_font_color"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "smooth_scrolling"), "set_smooth_scroll_enable", "is_smooth_scroll_enabled"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "v_scroll_speed"), "set_v_scroll_speed", "get_v_scroll_speed"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "hiding_enabled"), "set_hiding_enabled", "is_hiding_enabled"); ADD_GROUP("Caret", "caret_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "caret_block_mode"), "cursor_set_block_mode", "cursor_is_block_mode"); @@ -5006,6 +5469,8 @@ TextEdit::TextEdit() { cache.line_number_w = 1; cache.breakpoint_gutter_width = 0; breakpoint_gutter_width = 0; + cache.fold_gutter_width = 0; + fold_gutter_width = 0; indent_size = 4; text.set_indent_size(indent_size); @@ -5075,6 +5540,8 @@ TextEdit::TextEdit() { line_length_guideline = false; line_length_guideline_col = 80; draw_breakpoint_gutter = false; + draw_fold_gutter = false; + hiding_enabled = false; next_operation_is_complex = false; scroll_past_end_of_file_enabled = false; auto_brace_completion_enabled = false; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index 81310b7c10..b1c7b14e58 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -73,6 +73,9 @@ class TextEdit : public Control { struct Cache { Ref<Texture> tab_icon; + Ref<Texture> can_fold_icon; + Ref<Texture> folded_icon; + Ref<Texture> folded_eol_icon; Ref<StyleBox> style_normal; Ref<StyleBox> style_focus; Ref<Font> font; @@ -105,6 +108,7 @@ class TextEdit : public Control { int line_spacing; int line_number_w; int breakpoint_gutter_width; + int fold_gutter_width; Size2 size; } cache; @@ -136,6 +140,7 @@ class TextEdit : public Control { int width_cache : 24; bool marked : 1; bool breakpoint : 1; + bool hidden : 1; Map<int, ColorRegionInfo> region_info; String data; }; @@ -160,6 +165,8 @@ class TextEdit : public Control { bool is_marked(int p_line) const { return text[p_line].marked; } void set_breakpoint(int p_line, bool p_breakpoint) { text[p_line].breakpoint = p_breakpoint; } bool is_breakpoint(int p_line) const { return text[p_line].breakpoint; } + void set_hidden(int p_line, bool p_hidden) { text[p_line].hidden = p_hidden; } + bool is_hidden(int p_line) const { return text[p_line].hidden; } void insert(int p_at, const String &p_text); void remove(int p_at); int size() const { return text.size(); } @@ -251,6 +258,9 @@ class TextEdit : public Control { int line_length_guideline_col; bool draw_breakpoint_gutter; int breakpoint_gutter_width; + bool draw_fold_gutter; + int fold_gutter_width; + bool hiding_enabled; bool highlight_all_occurrences; bool scroll_past_end_of_file_enabled; @@ -293,9 +303,14 @@ class TextEdit : public Control { int search_result_line; int search_result_col; + double line_scroll_pos; + bool context_menu_enabled; int get_visible_rows() const; + int get_total_unhidden_rows() const; + double get_line_scroll_pos(bool p_recalculate = false) const; + void update_line_scroll_pos(); int get_char_count(); @@ -303,6 +318,7 @@ class TextEdit : public Control { int get_column_x_offset(int p_char, String p_str); void adjust_viewport_to_cursor(); + double get_scroll_line_diff() const; void _scroll_moved(double); void _update_scrollbars(); void _v_scroll_input(); @@ -405,6 +421,18 @@ public: void set_line_as_breakpoint(int p_line, bool p_breakpoint); bool is_line_set_as_breakpoint(int p_line) const; void get_breakpoints(List<int> *p_breakpoints) const; + + void set_line_as_hidden(int p_line, bool p_hidden); + bool is_line_hidden(int p_line) const; + void fold_all_lines(); + void unhide_all_lines(); + int num_lines_from(int p_line_from, int unhidden_amount) const; + int get_whitespace_level(int p_line) const; + bool can_fold(int p_line) const; + bool is_folded(int p_line) const; + void fold_line(int p_line); + void unfold_line(int p_line); + String get_text(); String get_line(int line) const; void set_line(int line, String new_text); @@ -433,7 +461,7 @@ public: void center_viewport_to_cursor(); void cursor_set_column(int p_col, bool p_adjust_viewport = true); - void cursor_set_line(int p_row, bool p_adjust_viewport = true); + void cursor_set_line(int p_row, bool p_adjust_viewport = true, bool p_can_be_hidden = true); int cursor_get_column() const; int cursor_get_line() const; @@ -448,6 +476,7 @@ public: bool cursor_is_block_mode() const; void set_readonly(bool p_readonly); + bool is_readonly() const; void set_max_chars(int p_max_chars); void set_wrap(bool p_wrap); @@ -463,6 +492,7 @@ public: void select_all(); void select(int p_from_line, int p_from_column, int p_to_line, int p_to_column); void deselect(); + void swap_lines(int line1, int line2); void set_search_text(const String &p_search_text); void set_search_flags(uint32_t p_flags); @@ -536,6 +566,15 @@ public: void set_breakpoint_gutter_width(int p_gutter_width); int get_breakpoint_gutter_width() const; + void set_draw_fold_gutter(bool p_draw); + bool is_drawing_fold_gutter() const; + + void set_fold_gutter_width(int p_gutter_width); + int get_fold_gutter_width() const; + + void set_hiding_enabled(int p_enabled); + int is_hiding_enabled() const; + void set_tooltip_request_func(Object *p_obj, const StringName &p_function, const Variant &p_udata); void set_completion(bool p_enabled, const Vector<String> &p_prefixes); @@ -547,6 +586,8 @@ public: bool is_selecting_identifiers_on_hover_enabled() const; void set_context_menu_enabled(bool p_enable); + bool is_context_menu_enabled(); + PopupMenu *get_menu() const; String get_text_for_completion(); diff --git a/scene/gui/video_player.cpp b/scene/gui/video_player.cpp index 190ccd50d5..1b6bd30b58 100644 --- a/scene/gui/video_player.cpp +++ b/scene/gui/video_player.cpp @@ -42,44 +42,127 @@ void VideoPlayer::sp_set_mix_rate(int p_rate) { server_mix_rate = p_rate; } -bool VideoPlayer::sp_mix(int32_t *p_buffer, int p_frames) { - - if (resampler.is_ready()) { +bool VideoPlayer::mix(AudioFrame *p_buffer, int p_frames) { + + // Check the amount resampler can really handle. + // If it cannot, wait "wait_resampler_phase_limit" times. + // This mechanism contributes to smoother pause/unpause operation. + if (p_frames <= resampler.get_num_of_ready_frames() || + wait_resampler_limit <= wait_resampler) { + wait_resampler = 0; return resampler.mix(p_buffer, p_frames); } - + wait_resampler++; return false; } -int VideoPlayer::_audio_mix_callback(void *p_udata, const int16_t *p_data, int p_frames) { +// Called from main thread (eg VideoStreamPlaybackWebm::update) +int VideoPlayer::_audio_mix_callback(void *p_udata, const float *p_data, int p_frames) { VideoPlayer *vp = (VideoPlayer *)p_udata; - int todo = MIN(vp->resampler.get_todo(), p_frames); + int todo = MIN(vp->resampler.get_writer_space(), p_frames); - int16_t *wb = vp->resampler.get_write_buffer(); + float *wb = vp->resampler.get_write_buffer(); int c = vp->resampler.get_channel_count(); for (int i = 0; i < todo * c; i++) { wb[i] = p_data[i]; } vp->resampler.write(todo); + return todo; } +// Called from audio thread +void VideoPlayer::_mix_audio() { + + if (!stream.is_valid()) { + return; + } + if (!playback.is_valid() || !playback->is_playing() || playback->is_paused()) { + return; + } + + AudioFrame *buffer = mix_buffer.ptr(); + int buffer_size = mix_buffer.size(); + + // Resample + if (!mix(buffer, buffer_size)) + return; + + AudioFrame vol = AudioFrame(volume, volume); + + // Copy to server's audio buffer + switch (AudioServer::get_singleton()->get_speaker_mode()) { + + case AudioServer::SPEAKER_MODE_STEREO: { + AudioFrame *target = AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 0); + + for (int j = 0; j < buffer_size; j++) { + + target[j] += buffer[j] * vol; + } + + } break; + case AudioServer::SPEAKER_SURROUND_51: { + + AudioFrame *targets[2] = { + AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 1), + AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 2), + }; + + for (int j = 0; j < buffer_size; j++) { + + AudioFrame frame = buffer[j] * vol; + targets[0][j] = frame; + targets[1][j] = frame; + } + } break; + case AudioServer::SPEAKER_SURROUND_71: { + + AudioFrame *targets[3] = { + AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 1), + AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 2), + AudioServer::get_singleton()->thread_get_channel_mix_buffer(bus_index, 3) + }; + + for (int j = 0; j < buffer_size; j++) { + + AudioFrame frame = buffer[j] * vol; + targets[0][j] += frame; + targets[1][j] += frame; + targets[2][j] += frame; + } + + } break; + } +} + void VideoPlayer::_notification(int p_notification) { switch (p_notification) { case NOTIFICATION_ENTER_TREE: { + AudioServer::get_singleton()->add_callback(_mix_audios, this); + if (stream.is_valid() && autoplay && !Engine::get_singleton()->is_editor_hint()) { play(); } + + } break; + + case NOTIFICATION_EXIT_TREE: { + + AudioServer::get_singleton()->remove_callback(_mix_audios, this); + } break; case NOTIFICATION_INTERNAL_PROCESS: { + bus_index = AudioServer::get_singleton()->thread_find_bus_index(bus); + if (stream.is_null()) return; if (paused) @@ -87,10 +170,11 @@ void VideoPlayer::_notification(int p_notification) { if (!playback->is_playing()) return; - double audio_time = USEC_TO_SEC(OS::get_singleton()->get_ticks_usec()); //AudioServer::get_singleton()->get_mix_time(); + double audio_time = USEC_TO_SEC(OS::get_singleton()->get_ticks_usec()); double delta = last_audio_time == 0 ? 0 : audio_time - last_audio_time; last_audio_time = audio_time; + if (delta == 0) return; @@ -135,6 +219,9 @@ bool VideoPlayer::has_expand() const { void VideoPlayer::set_stream(const Ref<VideoStream> &p_stream) { stop(); + AudioServer::get_singleton()->lock(); + mix_buffer.resize(AudioServer::get_singleton()->thread_get_mix_buffer_size()); + AudioServer::get_singleton()->unlock(); stream = p_stream; if (stream.is_valid()) { @@ -309,6 +396,40 @@ bool VideoPlayer::has_autoplay() const { return autoplay; }; +void VideoPlayer::set_bus(const StringName &p_bus) { + + //if audio is active, must lock this + AudioServer::get_singleton()->lock(); + bus = p_bus; + AudioServer::get_singleton()->unlock(); +} + +StringName VideoPlayer::get_bus() const { + + for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { + if (AudioServer::get_singleton()->get_bus_name(i) == bus) { + return bus; + } + } + return "Master"; +} + +void VideoPlayer::_validate_property(PropertyInfo &property) const { + + if (property.name == "bus") { + + String options; + for (int i = 0; i < AudioServer::get_singleton()->get_bus_count(); i++) { + if (i > 0) + options += ","; + String name = AudioServer::get_singleton()->get_bus_name(i); + options += name; + } + + property.hint_string = options; + } +} + void VideoPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_stream", "stream"), &VideoPlayer::set_stream); @@ -345,6 +466,9 @@ void VideoPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_buffering_msec", "msec"), &VideoPlayer::set_buffering_msec); ClassDB::bind_method(D_METHOD("get_buffering_msec"), &VideoPlayer::get_buffering_msec); + ClassDB::bind_method(D_METHOD("set_bus", "bus"), &VideoPlayer::set_bus); + ClassDB::bind_method(D_METHOD("get_bus"), &VideoPlayer::get_bus); + ClassDB::bind_method(D_METHOD("get_video_texture"), &VideoPlayer::get_video_texture); ADD_PROPERTY(PropertyInfo(Variant::INT, "audio_track", PROPERTY_HINT_RANGE, "0,128,1"), "set_audio_track", "get_audio_track"); @@ -354,6 +478,7 @@ void VideoPlayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "autoplay"), "set_autoplay", "has_autoplay"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "paused"), "set_paused", "is_paused"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "expand"), "set_expand", "has_expand"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "bus", PROPERTY_HINT_ENUM, ""), "set_bus", "get_bus"); } VideoPlayer::VideoPlayer() { @@ -372,6 +497,9 @@ VideoPlayer::VideoPlayer() { // internal_stream.player=this; // stream_rid=AudioServer::get_singleton()->audio_stream_create(&internal_stream); last_audio_time = 0; + + wait_resampler = 0; + wait_resampler_limit = 2; }; VideoPlayer::~VideoPlayer() { diff --git a/scene/gui/video_player.h b/scene/gui/video_player.h index f04e90365f..74e2f14e58 100644 --- a/scene/gui/video_player.h +++ b/scene/gui/video_player.h @@ -33,17 +33,24 @@ #include "scene/gui/control.h" #include "scene/resources/video_stream.h" #include "servers/audio/audio_rb_resampler.h" +#include "servers/audio_server.h" class VideoPlayer : public Control { GDCLASS(VideoPlayer, Control); + struct Output { + + AudioFrame vol; + int bus_index; + Viewport *viewport; //pointer only used for reference to previous mix + }; Ref<VideoStreamPlayback> playback; Ref<VideoStream> stream; int sp_get_channel_count() const; void sp_set_mix_rate(int p_rate); //notify the stream of the mix rate - bool sp_mix(int32_t *p_buffer, int p_frames); + bool mix(AudioFrame *p_buffer, int p_frames); RID stream_rid; @@ -51,6 +58,8 @@ class VideoPlayer : public Control { Ref<Image> last_frame; AudioRBResampler resampler; + Vector<AudioFrame> mix_buffer; + int wait_resampler, wait_resampler_limit; bool paused; bool autoplay; @@ -61,12 +70,18 @@ class VideoPlayer : public Control { int buffering_ms; int server_mix_rate; int audio_track; + int bus_index; + + StringName bus; - static int _audio_mix_callback(void *p_udata, const int16_t *p_data, int p_frames); + void _mix_audio(); + static int _audio_mix_callback(void *p_udata, const float *p_data, int p_frames); + static void _mix_audios(void *self) { reinterpret_cast<VideoPlayer *>(self)->_mix_audio(); } protected: static void _bind_methods(); void _notification(int p_notification); + void _validate_property(PropertyInfo &property) const; public: Size2 get_minimum_size() const; @@ -104,6 +119,9 @@ public: void set_buffering_msec(int p_msec); int get_buffering_msec() const; + void set_bus(const StringName &p_bus); + StringName get_bus() const; + VideoPlayer(); ~VideoPlayer(); }; diff --git a/scene/main/canvas_layer.cpp b/scene/main/canvas_layer.cpp index ce8714e574..5a3814ef35 100644 --- a/scene/main/canvas_layer.cpp +++ b/scene/main/canvas_layer.cpp @@ -105,30 +105,16 @@ real_t CanvasLayer::get_rotation() const { return rot; } -void CanvasLayer::set_rotationd(real_t p_degrees) { +void CanvasLayer::set_rotation_degrees(real_t p_degrees) { set_rotation(Math::deg2rad(p_degrees)); } -real_t CanvasLayer::get_rotationd() const { +real_t CanvasLayer::get_rotation_degrees() const { return Math::rad2deg(get_rotation()); } -// Kept for compatibility after rename to {s,g}et_rotationd. -// Could be removed after a couple releases. -void CanvasLayer::_set_rotationd(real_t p_degrees) { - - WARN_PRINT("Deprecated method CanvasLayer._set_rotationd(): This method was renamed to set_rotationd. Please adapt your code accordingly, as the old method will be obsoleted."); - set_rotationd(p_degrees); -} - -real_t CanvasLayer::_get_rotationd() const { - - WARN_PRINT("Deprecated method CanvasLayer._get_rotationd(): This method was renamed to get_rotationd. Please adapt your code accordingly, as the old method will be obsoleted."); - return get_rotationd(); -} - void CanvasLayer::set_scale(const Vector2 &p_scale) { if (locrotscale_dirty) @@ -252,12 +238,8 @@ void CanvasLayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_rotation", "radians"), &CanvasLayer::set_rotation); ClassDB::bind_method(D_METHOD("get_rotation"), &CanvasLayer::get_rotation); - ClassDB::bind_method(D_METHOD("set_rotationd", "degrees"), &CanvasLayer::set_rotationd); - ClassDB::bind_method(D_METHOD("get_rotationd"), &CanvasLayer::get_rotationd); - - // TODO: Obsolete those two methods (old name) properly (GH-4397) - ClassDB::bind_method(D_METHOD("_set_rotationd", "degrees"), &CanvasLayer::_set_rotationd); - ClassDB::bind_method(D_METHOD("_get_rotationd"), &CanvasLayer::_get_rotationd); + ClassDB::bind_method(D_METHOD("set_rotation_degrees", "degrees"), &CanvasLayer::set_rotation_degrees); + ClassDB::bind_method(D_METHOD("get_rotation_degrees"), &CanvasLayer::get_rotation_degrees); ClassDB::bind_method(D_METHOD("set_scale", "scale"), &CanvasLayer::set_scale); ClassDB::bind_method(D_METHOD("get_scale"), &CanvasLayer::get_scale); @@ -271,7 +253,7 @@ void CanvasLayer::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "layer", PROPERTY_HINT_RANGE, "-128,128,1"), "set_layer", "get_layer"); //ADD_PROPERTY( PropertyInfo(Variant::MATRIX32,"transform",PROPERTY_HINT_RANGE),"set_transform","get_transform") ; ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); - ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation"), "set_rotationd", "get_rotationd"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "rotation"), "set_rotation_degrees", "get_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "scale"), "set_scale", "get_scale"); } diff --git a/scene/main/canvas_layer.h b/scene/main/canvas_layer.h index fbee87f487..db2c8e1273 100644 --- a/scene/main/canvas_layer.h +++ b/scene/main/canvas_layer.h @@ -54,10 +54,6 @@ class CanvasLayer : public Node { int sort_index; - // Deprecated, should be removed in a future version. - void _set_rotationd(real_t p_degrees); - real_t _get_rotationd() const; - void _update_xform(); void _update_locrotscale(); @@ -78,8 +74,8 @@ public: void set_rotation(real_t p_radians); real_t get_rotation() const; - void set_rotationd(real_t p_degrees); - real_t get_rotationd() const; + void set_rotation_degrees(real_t p_degrees); + real_t get_rotation_degrees() const; void set_scale(const Size2 &p_scale); Size2 get_scale() const; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index e6e11de177..253084dd99 100755 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -2067,7 +2067,7 @@ int Node::get_position_in_parent() const { return data.pos; } -Node *Node::_duplicate(int p_flags) const { +Node *Node::_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap) const { Node *node = NULL; @@ -2084,7 +2084,12 @@ Node *Node::_duplicate(int p_flags) const { Ref<PackedScene> res = ResourceLoader::load(get_filename()); ERR_FAIL_COND_V(res.is_null(), NULL); - node = res->instance(); + PackedScene::GenEditState ges = PackedScene::GEN_EDIT_STATE_DISABLED; +#ifdef TOOLS_ENABLED + if (p_flags & DUPLICATE_FROM_EDITOR) + ges = PackedScene::GEN_EDIT_STATE_INSTANCE; +#endif + node = res->instance(ges); ERR_FAIL_COND_V(!node, NULL); instanced = true; @@ -2099,10 +2104,6 @@ Node *Node::_duplicate(int p_flags) const { ERR_FAIL_COND_V(!node, NULL); } - if (get_filename() != "") { //an instance - node->set_filename(get_filename()); - } - List<PropertyInfo> plist; get_property_list(&plist); @@ -2138,18 +2139,25 @@ Node *Node::_duplicate(int p_flags) const { node->set_name(get_name()); +#ifdef TOOLS_ENABLED + if ((p_flags & DUPLICATE_FROM_EDITOR) && r_duplimap) + r_duplimap->insert(this, node); +#endif + if (p_flags & DUPLICATE_GROUPS) { List<GroupInfo> gi; get_groups(&gi); for (List<GroupInfo>::Element *E = gi.front(); E; E = E->next()) { +#ifdef TOOLS_ENABLED + if ((p_flags & DUPLICATE_FROM_EDITOR) && !E->get().persistent) + continue; +#endif + node->add_to_group(E->get().name, E->get().persistent); } } - if (p_flags & DUPLICATE_SIGNALS) - _duplicate_signals(this, node); - for (int i = 0; i < get_child_count(); i++) { if (get_child(i)->data.parent_owned) @@ -2157,7 +2165,7 @@ Node *Node::_duplicate(int p_flags) const { if (instanced && get_child(i)->data.owner == this) continue; //part of instance - Node *dup = get_child(i)->duplicate(p_flags); + Node *dup = get_child(i)->_duplicate(p_flags, r_duplimap); if (!dup) { memdelete(node); @@ -2181,6 +2189,20 @@ Node *Node::duplicate(int p_flags) const { return dupe; } +#ifdef TOOLS_ENABLED +Node *Node::duplicate_from_editor(Map<const Node *, Node *> &r_duplimap) const { + + Node *dupe = _duplicate(DUPLICATE_SIGNALS | DUPLICATE_GROUPS | DUPLICATE_SCRIPTS | DUPLICATE_USE_INSTANCING | DUPLICATE_FROM_EDITOR, &r_duplimap); + + // Duplication of signals must happen after all the node descendants have been copied, + // because re-targeting of connections from some descendant to another is not possible + // if the emitter node comes later in tree order than the receiver + _duplicate_signals(this, dupe); + + return dupe; +} +#endif + void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p_reown_map) const { if (get_owner() != get_parent()->get_owner()) @@ -2251,6 +2273,9 @@ void Node::_duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p } } +// Duplication of signals must happen after all the node descendants have been copied, +// because re-targeting of connections from some descendant to another is not possible +// if the emitter node comes later in tree order than the receiver void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { if (this != p_original && (get_owner() != p_original && get_owner() != p_original->get_owner())) @@ -2273,6 +2298,12 @@ void Node::_duplicate_signals(const Node *p_original, Node *p_copy) const { NodePath ptarget = p_original->get_path_to(target); Node *copytarget = p_copy->get_node(ptarget); + // Cannot find a path to the duplicate target, so it seems it's not part + // of the duplicated and not yet parented hierarchy, so at least try to connect + // to the same target as the original + if (!copytarget) + copytarget = target; + if (copy && copytarget) { copy->connect(E->get().signal, copytarget, E->get().method, E->get().binds, CONNECT_PERSIST); } @@ -2319,6 +2350,9 @@ Node *Node::duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const { get_child(i)->_duplicate_and_reown(node, p_reown_map); } + // Duplication of signals must happen after all the node descendants have been copied, + // because re-targeting of connections from some descendant to another is not possible + // if the emitter node comes later in tree order than the receiver _duplicate_signals(this, node); return node; } @@ -2422,7 +2456,9 @@ void Node::_replace_connections_target(Node *p_new_target) { if (c.flags & CONNECT_PERSIST) { c.source->disconnect(c.signal, this, c.method); - ERR_CONTINUE(!p_new_target->has_method(c.method)); + bool valid = p_new_target->has_method(c.method) || p_new_target->get_script().is_null() || Ref<Script>(p_new_target->get_script())->has_method(c.method); + ERR_EXPLAIN("Attempt to connect signal \'" + c.source->get_class() + "." + c.signal + "\' to nonexistent method \'" + c.target->get_class() + "." + c.method + "\'"); + ERR_CONTINUE(!valid); c.source->connect(c.signal, p_new_target, c.method, c.binds, c.flags); } } diff --git a/scene/main/node.h b/scene/main/node.h index c43e96063f..bd0b18c87a 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -58,7 +58,10 @@ public: DUPLICATE_SIGNALS = 1, DUPLICATE_GROUPS = 2, DUPLICATE_SCRIPTS = 4, - DUPLICATE_USE_INSTANCING = 8 + DUPLICATE_USE_INSTANCING = 8, +#ifdef TOOLS_ENABLED + DUPLICATE_FROM_EDITOR = 16, +#endif }; enum RPCMode { @@ -169,7 +172,7 @@ private: void _duplicate_signals(const Node *p_original, Node *p_copy) const; void _duplicate_and_reown(Node *p_new_parent, const Map<Node *, Node *> &p_reown_map) const; - Node *_duplicate(int p_flags) const; + Node *_duplicate(int p_flags, Map<const Node *, Node *> *r_duplimap = NULL) const; Array _get_children() const; Array _get_groups() const; @@ -326,6 +329,9 @@ public: Node *duplicate(int p_flags = DUPLICATE_GROUPS | DUPLICATE_SIGNALS | DUPLICATE_SCRIPTS) const; Node *duplicate_and_reown(const Map<Node *, Node *> &p_reown_map) const; +#ifdef TOOLS_ENABLED + Node *duplicate_from_editor(Map<const Node *, Node *> &r_duplimap) const; +#endif //Node *clone_tree() const; diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index eaa16069cf..c99bc3c9ef 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -83,10 +83,10 @@ #include "scene/gui/link_button.h" #include "scene/gui/margin_container.h" #include "scene/gui/menu_button.h" +#include "scene/gui/nine_patch_rect.h" #include "scene/gui/option_button.h" #include "scene/gui/panel.h" #include "scene/gui/panel_container.h" -#include "scene/gui/nine_patch_rect.h" #include "scene/gui/popup_menu.h" #include "scene/gui/progress_bar.h" #include "scene/gui/reference_rect.h" diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 21e4a85cd1..8192074c17 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1125,14 +1125,14 @@ Variant Animation::_cubic_interpolate(const Variant &p_pre_a, const Variant &p_a return a.cubic_slerp(b, pa, pb, p_c); } break; - case Variant::RECT3: { + case Variant::AABB: { - Rect3 a = p_a; - Rect3 b = p_b; - Rect3 pa = p_pre_a; - Rect3 pb = p_post_b; + AABB a = p_a; + AABB b = p_b; + AABB pa = p_pre_a; + AABB pb = p_post_b; - return Rect3( + return AABB( a.position.cubic_interpolate(b.position, pa.position, pb.position, p_c), a.size.cubic_interpolate(b.size, pa.size, pb.size, p_c)); } break; diff --git a/scene/resources/audio_stream_sample.cpp b/scene/resources/audio_stream_sample.cpp index fdc3b79db6..f81f460521 100644 --- a/scene/resources/audio_stream_sample.cpp +++ b/scene/resources/audio_stream_sample.cpp @@ -31,17 +31,23 @@ void AudioStreamPlaybackSample::start(float p_from_pos) { - for (int i = 0; i < 2; i++) { - ima_adpcm[i].step_index = 0; - ima_adpcm[i].predictor = 0; - ima_adpcm[i].loop_step_index = 0; - ima_adpcm[i].loop_predictor = 0; - ima_adpcm[i].last_nibble = -1; - ima_adpcm[i].loop_pos = 0x7FFFFFFF; - ima_adpcm[i].window_ofs = 0; + if (base->format == AudioStreamSample::FORMAT_IMA_ADPCM) { + //no seeking in IMA_ADPCM + for (int i = 0; i < 2; i++) { + ima_adpcm[i].step_index = 0; + ima_adpcm[i].predictor = 0; + ima_adpcm[i].loop_step_index = 0; + ima_adpcm[i].loop_predictor = 0; + ima_adpcm[i].last_nibble = -1; + ima_adpcm[i].loop_pos = 0x7FFFFFFF; + ima_adpcm[i].window_ofs = 0; + } + + offset = 0; + } else { + seek(p_from_pos); } - seek(p_from_pos); sign = 1; active = true; } @@ -373,6 +379,14 @@ void AudioStreamPlaybackSample::mix(AudioFrame *p_buffer, float p_rate_scale, in dst_buff += target; } + + if (todo) { + //bit was missing from mix + int todo_ofs = p_frames - todo; + for (int i = todo_ofs; i < p_frames; i++) { + p_buffer[i] = AudioFrame(0, 0); + } + } } float AudioStreamPlaybackSample::get_length() const { diff --git a/scene/resources/box_shape.cpp b/scene/resources/box_shape.cpp index bbc85ce0f6..4b9843f3f5 100644 --- a/scene/resources/box_shape.cpp +++ b/scene/resources/box_shape.cpp @@ -33,7 +33,7 @@ Vector<Vector3> BoxShape::_gen_debug_mesh_lines() { Vector<Vector3> lines; - Rect3 aabb; + AABB aabb; aabb.position = -get_extents(); aabb.size = aabb.position * -2; diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp index 56a09bc3bf..912150b939 100644 --- a/scene/resources/capsule_shape_2d.cpp +++ b/scene/resources/capsule_shape_2d.cpp @@ -98,7 +98,7 @@ void CapsuleShape2D::_bind_methods() { } CapsuleShape2D::CapsuleShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CAPSULE)) { + : Shape2D(Physics2DServer::get_singleton()->capsule_shape_create()) { radius = 10; height = 20; diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp index ecfc98ea60..287bde4bfb 100644 --- a/scene/resources/circle_shape_2d.cpp +++ b/scene/resources/circle_shape_2d.cpp @@ -77,7 +77,7 @@ void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) { } CircleShape2D::CircleShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CIRCLE)) { + : Shape2D(Physics2DServer::get_singleton()->circle_shape_create()) { radius = 10; _update_shape(); diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp index 7f4abf7ae0..bb91e33ec2 100644 --- a/scene/resources/concave_polygon_shape_2d.cpp +++ b/scene/resources/concave_polygon_shape_2d.cpp @@ -85,5 +85,5 @@ void ConcavePolygonShape2D::_bind_methods() { } ConcavePolygonShape2D::ConcavePolygonShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONCAVE_POLYGON)) { + : Shape2D(Physics2DServer::get_singleton()->concave_polygon_shape_create()) { } diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp index 7588909d90..a76b6a7cf4 100644 --- a/scene/resources/convex_polygon_shape_2d.cpp +++ b/scene/resources/convex_polygon_shape_2d.cpp @@ -87,7 +87,7 @@ Rect2 ConvexPolygonShape2D::get_rect() const { } ConvexPolygonShape2D::ConvexPolygonShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_CONVEX_POLYGON)) { + : Shape2D(Physics2DServer::get_singleton()->convex_polygon_shape_create()) { int pcount = 3; for (int i = 0; i < pcount; i++) diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index ce439fece6..cd28c9d203 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -836,39 +836,6 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_constant("autohide", "HSplitContainer", 1 * scale); theme->set_constant("autohide", "VSplitContainer", 1 * scale); - // HButtonArray - theme->set_stylebox("normal", "HButtonArray", sb_button_normal); - theme->set_stylebox("selected", "HButtonArray", sb_button_pressed); - theme->set_stylebox("hover", "HButtonArray", sb_button_hover); - - theme->set_font("font", "HButtonArray", default_font); - theme->set_font("font_selected", "HButtonArray", default_font); - - theme->set_color("font_color", "HButtonArray", control_font_color_low); - theme->set_color("font_color_selected", "HButtonArray", control_font_color_hover); - - theme->set_constant("icon_separator", "HButtonArray", 2 * scale); - theme->set_constant("button_separator", "HButtonArray", 4 * scale); - - theme->set_stylebox("focus", "HButtonArray", focus); - - // VButtonArray - - theme->set_stylebox("normal", "VButtonArray", sb_button_normal); - theme->set_stylebox("selected", "VButtonArray", sb_button_pressed); - theme->set_stylebox("hover", "VButtonArray", sb_button_hover); - - theme->set_font("font", "VButtonArray", default_font); - theme->set_font("font_selected", "VButtonArray", default_font); - - theme->set_color("font_color", "VButtonArray", control_font_color_low); - theme->set_color("font_color_selected", "VButtonArray", control_font_color_hover); - - theme->set_constant("icon_separator", "VButtonArray", 2 * scale); - theme->set_constant("button_separator", "VButtonArray", 4 * scale); - - theme->set_stylebox("focus", "VButtonArray", focus); - // ReferenceRect Ref<StyleBoxTexture> ttnc = make_stylebox(full_panel_bg_png, 8, 8, 8, 8); diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp index 1ee76a4216..48c6add586 100644 --- a/scene/resources/dynamic_font.cpp +++ b/scene/resources/dynamic_font.cpp @@ -571,7 +571,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { wr[ofs + 0] = 255; //grayscale as 1 wr[ofs + 1] = slot->bitmap.buffer[i * slot->bitmap.pitch + j]; break; - // TODO: FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_BGRA + // TODO: FT_PIXEL_MODE_LCD, FT_PIXEL_MODE_BGRA default: ERR_EXPLAIN("Font uses unsupported pixel format: " + itos(slot->bitmap.pixel_mode)); ERR_FAIL(); diff --git a/scene/resources/dynamic_font_stb.cpp b/scene/resources/dynamic_font_stb.cpp index 91263fb125..4aa47cb664 100644 --- a/scene/resources/dynamic_font_stb.cpp +++ b/scene/resources/dynamic_font_stb.cpp @@ -333,8 +333,7 @@ void DynamicFontAtSize::_update_char(CharType p_char) { //blit to image and texture { - - Image img(tex.texture_size, tex.texture_size, 0, Image::FORMAT_LA8, tex.imgdata); + Ref<Image> img = memnew(Image(tex.texture_size, tex.texture_size, 0, Image::FORMAT_LA8, tex.imgdata)); if (tex.texture.is_null()) { tex.texture.instance(); @@ -518,7 +517,7 @@ bool ResourceFormatLoaderDynamicFont::handles_type(const String &p_type) const { String ResourceFormatLoaderDynamicFont::get_resource_type(const String &p_path) const { - String el = p_path.extension().to_lower(); + String el = p_path.get_extension().to_lower(); if (el == "ttf") return "DynamicFontData"; return ""; diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp index 232f690074..fe59450f2e 100644 --- a/scene/resources/environment.cpp +++ b/scene/resources/environment.cpp @@ -1184,7 +1184,8 @@ Environment::Environment() { bg_energy = 1.0; bg_canvas_max_layer = 0; ambient_energy = 1.0; - ambient_sky_contribution = 1.0; + //ambient_sky_contribution = 1.0; + set_ambient_light_sky_contribution(1.0); tone_mapper = TONE_MAPPER_LINEAR; tonemap_exposure = 1.0; diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 12434b39fa..286840656b 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -723,7 +723,11 @@ void SpatialMaterial::_update_shader() { } else { code += "\tvec3 emission_tex = texture(texture_emission,base_uv).rgb;\n"; } - code += "\tEMISSION = (emission.rgb+emission_tex)*emission_energy;\n"; + if (emission_op == EMISSION_OP_ADD) { + code += "\tEMISSION = (emission.rgb+emission_tex)*emission_energy;\n"; + } else { + code += "\tEMISSION = (emission.rgb*emission_tex)*emission_energy;\n"; + } } if (features[FEATURE_REFRACTION] && !flags[FLAG_UV1_USE_TRIPLANAR]) { //refraction not supported with triplanar @@ -1635,6 +1639,19 @@ float SpatialMaterial::get_distance_fade_min_distance() const { return distance_fade_min_distance; } +void SpatialMaterial::set_emission_operator(EmissionOperator p_op) { + + if (emission_op == p_op) + return; + emission_op = p_op; + _queue_shader_change(); +} + +SpatialMaterial::EmissionOperator SpatialMaterial::get_emission_operator() const { + + return emission_op; +} + RID SpatialMaterial::get_shader_rid() const { ERR_FAIL_COND_V(!shader_map.has(current_key), RID()); @@ -1769,6 +1786,9 @@ void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_grow", "amount"), &SpatialMaterial::set_grow); ClassDB::bind_method(D_METHOD("get_grow"), &SpatialMaterial::get_grow); + ClassDB::bind_method(D_METHOD("set_emission_operator", "operator"), &SpatialMaterial::set_emission_operator); + ClassDB::bind_method(D_METHOD("get_emission_operator"), &SpatialMaterial::get_emission_operator); + ClassDB::bind_method(D_METHOD("set_ao_light_affect", "amount"), &SpatialMaterial::set_ao_light_affect); ClassDB::bind_method(D_METHOD("get_ao_light_affect"), &SpatialMaterial::get_ao_light_affect); @@ -1854,6 +1874,7 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "emission_enabled"), "set_feature", "get_feature", FEATURE_EMISSION); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "emission", PROPERTY_HINT_COLOR_NO_ALPHA), "set_emission", "get_emission"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "emission_energy", PROPERTY_HINT_RANGE, "0,16,0.01"), "set_emission_energy", "get_emission_energy"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_operator", PROPERTY_HINT_ENUM, "Add,Multiply"), "set_emission_operator", "get_emission_operator"); ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "emission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_EMISSION); ADD_GROUP("NormalMap", "normal_"); @@ -2022,6 +2043,9 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(TEXTURE_CHANNEL_BLUE); BIND_ENUM_CONSTANT(TEXTURE_CHANNEL_ALPHA); BIND_ENUM_CONSTANT(TEXTURE_CHANNEL_GRAYSCALE); + + BIND_ENUM_CONSTANT(EMISSION_OP_ADD); + BIND_ENUM_CONSTANT(EMISSION_OP_MULTIPLY); } SpatialMaterial::SpatialMaterial() @@ -2057,6 +2081,7 @@ SpatialMaterial::SpatialMaterial() set_particles_anim_v_frames(1); set_particles_anim_loop(false); set_alpha_scissor_threshold(0.98); + emission_op = EMISSION_OP_ADD; proximity_fade_enabled = false; distance_fade_enabled = false; diff --git a/scene/resources/material.h b/scene/resources/material.h index 2425f1a174..877d4dfd41 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -215,6 +215,11 @@ public: TEXTURE_CHANNEL_GRAYSCALE }; + enum EmissionOperator { + EMISSION_OP_ADD, + EMISSION_OP_MULTIPLY + }; + private: union MaterialKey { @@ -234,6 +239,7 @@ private: uint64_t grow : 1; uint64_t proximity_fade : 1; uint64_t distance_fade : 1; + uint64_t emission_op : 1; }; uint64_t key; @@ -278,6 +284,7 @@ private: mk.grow = grow_enabled; mk.proximity_fade = proximity_fade_enabled; mk.distance_fade = distance_fade_enabled; + mk.emission_op = emission_op; return mk; } @@ -394,6 +401,7 @@ private: SpecularMode specular_mode; DiffuseMode diffuse_mode; BillboardMode billboard_mode; + EmissionOperator emission_op; TextureChannel metallic_texture_channel; TextureChannel roughness_texture_channel; @@ -571,6 +579,9 @@ public: void set_distance_fade_min_distance(float p_distance); float get_distance_fade_min_distance() const; + void set_emission_operator(EmissionOperator p_op); + EmissionOperator get_emission_operator() const; + void set_metallic_texture_channel(TextureChannel p_channel); TextureChannel get_metallic_texture_channel() const; void set_roughness_texture_channel(TextureChannel p_channel); @@ -603,6 +614,7 @@ VARIANT_ENUM_CAST(SpatialMaterial::DiffuseMode) VARIANT_ENUM_CAST(SpatialMaterial::SpecularMode) VARIANT_ENUM_CAST(SpatialMaterial::BillboardMode) VARIANT_ENUM_CAST(SpatialMaterial::TextureChannel) +VARIANT_ENUM_CAST(SpatialMaterial::EmissionOperator) ////////////////////// diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp index db5d87d703..0a886c25b1 100644 --- a/scene/resources/mesh.cpp +++ b/scene/resources/mesh.cpp @@ -574,7 +574,6 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { ERR_FAIL_COND_V(!d.has("format"), false); uint32_t format = d["format"]; - ERR_FAIL_COND_V(!d.has("primitive"), false); uint32_t primitive = d["primitive"]; ERR_FAIL_COND_V(!d.has("vertex_count"), false); @@ -595,11 +594,11 @@ bool ArrayMesh::_set(const StringName &p_name, const Variant &p_value) { } ERR_FAIL_COND_V(!d.has("aabb"), false); - Rect3 aabb = d["aabb"]; + AABB aabb = d["aabb"]; - Vector<Rect3> bone_aabb; - if (d.has("bone_aabb")) { - Array baabb = d["bone_aabb"]; + Vector<AABB> bone_aabb; + if (d.has("skeleton_aabb")) { + Array baabb = d["skeleton_aabb"]; bone_aabb.resize(baabb.size()); for (int i = 0; i < baabb.size(); i++) { @@ -677,7 +676,7 @@ bool ArrayMesh::_get(const StringName &p_name, Variant &r_ret) const { d["format"] = VS::get_singleton()->mesh_surface_get_format(mesh, idx); d["aabb"] = VS::get_singleton()->mesh_surface_get_aabb(mesh, idx); - Vector<Rect3> skel_aabb = VS::get_singleton()->mesh_surface_get_skeleton_aabb(mesh, idx); + Vector<AABB> skel_aabb = VS::get_singleton()->mesh_surface_get_skeleton_aabb(mesh, idx); Array arr; for (int i = 0; i < skel_aabb.size(); i++) { arr[i] = skel_aabb[i]; @@ -726,13 +725,13 @@ void ArrayMesh::_get_property_list(List<PropertyInfo> *p_list) const { } } - p_list->push_back(PropertyInfo(Variant::RECT3, "custom_aabb/custom_aabb")); + p_list->push_back(PropertyInfo(Variant::AABB, "custom_aabb/custom_aabb")); } void ArrayMesh::_recompute_aabb() { // regenerate AABB - aabb = Rect3(); + aabb = AABB(); for (int i = 0; i < surfaces.size(); i++) { @@ -743,7 +742,7 @@ void ArrayMesh::_recompute_aabb() { } } -void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<Rect3> &p_bone_aabbs) { +void ArrayMesh::add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes, const Vector<AABB> &p_bone_aabbs) { Surface s; s.aabb = p_aabb; @@ -773,7 +772,7 @@ void ArrayMesh::add_surface_from_arrays(PrimitiveType p_primitive, const Array & const Vector3 *vtx = r.ptr(); // check AABB - Rect3 aabb; + AABB aabb; for (int i = 0; i < len; i++) { if (i == 0) @@ -921,7 +920,13 @@ String ArrayMesh::surface_get_name(int p_idx) const { return surfaces[p_idx].name; } -void ArrayMesh::surface_set_custom_aabb(int p_idx, const Rect3 &p_aabb) { +void ArrayMesh::surface_update_region(int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) { + + ERR_FAIL_INDEX(p_surface, surfaces.size()); + VS::get_singleton()->mesh_surface_update_region(mesh, p_surface, p_offset, p_data); +} + +void ArrayMesh::surface_set_custom_aabb(int p_idx, const AABB &p_aabb) { ERR_FAIL_INDEX(p_idx, surfaces.size()); surfaces[p_idx].aabb = p_aabb; @@ -937,7 +942,7 @@ Ref<Material> ArrayMesh::surface_get_material(int p_idx) const { void ArrayMesh::add_surface_from_mesh_data(const Geometry::MeshData &p_mesh_data) { VisualServer::get_singleton()->mesh_add_surface_from_mesh_data(mesh, p_mesh_data); - Rect3 aabb; + AABB aabb; for (int i = 0; i < p_mesh_data.vertices.size(); i++) { if (i == 0) @@ -965,18 +970,18 @@ RID ArrayMesh::get_rid() const { return mesh; } -Rect3 ArrayMesh::get_aabb() const { +AABB ArrayMesh::get_aabb() const { return aabb; } -void ArrayMesh::set_custom_aabb(const Rect3 &p_custom) { +void ArrayMesh::set_custom_aabb(const AABB &p_custom) { custom_aabb = p_custom; VS::get_singleton()->mesh_set_custom_aabb(mesh, custom_aabb); } -Rect3 ArrayMesh::get_custom_aabb() const { +AABB ArrayMesh::get_custom_aabb() const { return custom_aabb; } @@ -1042,6 +1047,7 @@ void ArrayMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("add_surface_from_arrays", "primitive", "arrays", "blend_shapes", "compress_flags"), &ArrayMesh::add_surface_from_arrays, DEFVAL(Array()), DEFVAL(ARRAY_COMPRESS_DEFAULT)); ClassDB::bind_method(D_METHOD("get_surface_count"), &ArrayMesh::get_surface_count); ClassDB::bind_method(D_METHOD("surface_remove", "surf_idx"), &ArrayMesh::surface_remove); + ClassDB::bind_method(D_METHOD("surface_update_region", "surf_idx", "offset", "data"), &ArrayMesh::surface_update_region); ClassDB::bind_method(D_METHOD("surface_get_array_len", "surf_idx"), &ArrayMesh::surface_get_array_len); ClassDB::bind_method(D_METHOD("surface_get_array_index_len", "surf_idx"), &ArrayMesh::surface_get_array_index_len); ClassDB::bind_method(D_METHOD("surface_get_format", "surf_idx"), &ArrayMesh::surface_get_format); @@ -1090,6 +1096,16 @@ void ArrayMesh::_bind_methods() { BIND_ENUM_CONSTANT(ARRAY_FORMAT_INDEX); } +void ArrayMesh::reload_from_file() { + VisualServer::get_singleton()->mesh_clear(mesh); + surfaces.clear(); + clear_blend_shapes(); + + Resource::reload_from_file(); + + _change_notify(); +} + ArrayMesh::ArrayMesh() { mesh = VisualServer::get_singleton()->mesh_create(); diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h index f4edb258b6..b85a6a84af 100644 --- a/scene/resources/mesh.h +++ b/scene/resources/mesh.h @@ -95,6 +95,7 @@ public: ARRAY_FLAG_USE_2D_VERTICES = ARRAY_COMPRESS_INDEX << 1, ARRAY_FLAG_USE_16_BIT_BONES = ARRAY_COMPRESS_INDEX << 2, + ARRAY_FLAG_USE_DYNAMIC_UPDATE = ARRAY_COMPRESS_INDEX << 3, ARRAY_COMPRESS_DEFAULT = ARRAY_COMPRESS_VERTEX | ARRAY_COMPRESS_NORMAL | ARRAY_COMPRESS_TANGENT | ARRAY_COMPRESS_COLOR | ARRAY_COMPRESS_TEX_UV | ARRAY_COMPRESS_TEX_UV2 | ARRAY_COMPRESS_WEIGHTS @@ -135,7 +136,7 @@ public: Ref<Mesh> create_outline(float p_margin) const; - virtual Rect3 get_aabb() const = 0; + virtual AABB get_aabb() const = 0; Mesh(); }; @@ -148,16 +149,16 @@ class ArrayMesh : public Mesh { private: struct Surface { String name; - Rect3 aabb; + AABB aabb; Ref<Material> material; bool is_2d; }; Vector<Surface> surfaces; RID mesh; - Rect3 aabb; + AABB aabb; BlendShapeMode blend_shape_mode; Vector<StringName> blend_shapes; - Rect3 custom_aabb; + AABB custom_aabb; void _recompute_aabb(); @@ -172,7 +173,7 @@ protected: public: void add_surface_from_arrays(PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), uint32_t p_flags = ARRAY_COMPRESS_DEFAULT); - void add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()); + void add_surface(uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()); Array surface_get_arrays(int p_surface) const; Array surface_get_blend_shape_arrays(int p_surface) const; @@ -185,10 +186,12 @@ public: void set_blend_shape_mode(BlendShapeMode p_mode); BlendShapeMode get_blend_shape_mode() const; + void surface_update_region(int p_surface, int p_offset, const PoolVector<uint8_t> &p_data); + int get_surface_count() const; void surface_remove(int p_idx); - void surface_set_custom_aabb(int p_idx, const Rect3 &p_aabb); //only recognized by driver + void surface_set_custom_aabb(int p_idx, const AABB &p_aabb); //only recognized by driver int surface_get_array_len(int p_idx) const; int surface_get_array_index_len(int p_idx) const; @@ -204,15 +207,17 @@ public: void add_surface_from_mesh_data(const Geometry::MeshData &p_mesh_data); - void set_custom_aabb(const Rect3 &p_custom); - Rect3 get_custom_aabb() const; + void set_custom_aabb(const AABB &p_custom); + AABB get_custom_aabb() const; - Rect3 get_aabb() const; + AABB get_aabb() const; virtual RID get_rid() const; void center_geometry(); void regen_normalmaps(); + virtual void reload_from_file(); + ArrayMesh(); ~ArrayMesh(); diff --git a/scene/resources/multimesh.cpp b/scene/resources/multimesh.cpp index 15f1e15542..ee6efa6e85 100644 --- a/scene/resources/multimesh.cpp +++ b/scene/resources/multimesh.cpp @@ -155,7 +155,7 @@ Color MultiMesh::get_instance_color(int p_instance) const { return VisualServer::get_singleton()->multimesh_instance_get_color(multimesh, p_instance); } -Rect3 MultiMesh::get_aabb() const { +AABB MultiMesh::get_aabb() const { return VisualServer::get_singleton()->multimesh_get_aabb(multimesh); } diff --git a/scene/resources/multimesh.h b/scene/resources/multimesh.h index 7ca66b0b46..0a5310f641 100644 --- a/scene/resources/multimesh.h +++ b/scene/resources/multimesh.h @@ -84,7 +84,7 @@ public: void set_instance_color(int p_instance, const Color &p_color); Color get_instance_color(int p_instance) const; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual RID get_rid() const; diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index ba356d89b1..3b80db291c 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -42,7 +42,7 @@ void PrimitiveMesh::_update() const { PoolVector<Vector3> points = arr[VS::ARRAY_VERTEX]; - aabb = Rect3(); + aabb = AABB(); int pc = points.size(); ERR_FAIL_COND(pc == 0); @@ -141,7 +141,7 @@ StringName PrimitiveMesh::get_blend_shape_name(int p_index) const { return StringName(); } -Rect3 PrimitiveMesh::get_aabb() const { +AABB PrimitiveMesh::get_aabb() const { if (pending_request) { _update(); } @@ -1299,14 +1299,16 @@ void QuadMesh::_create_mesh_array(Array &p_arr) const { tangents.resize(4 * 4); uvs.resize(4); - for (int i = 0; i < 4; i++) { + Vector2 _size = Vector2(size.x / 2.0f, size.y / 2.0f); - static const Vector3 quad_faces[4] = { - Vector3(-1, -1, 0), - Vector3(-1, 1, 0), - Vector3(1, 1, 0), - Vector3(1, -1, 0), - }; + Vector3 quad_faces[4] = { + Vector3(-_size.x, -_size.y, 0), + Vector3(-_size.x, _size.y, 0), + Vector3(_size.x, _size.y, 0), + Vector3(_size.x, -_size.y, 0), + }; + + for (int i = 0; i < 4; i++) { faces.set(i, quad_faces[i]); normals.set(i, Vector3(0, 0, 1)); @@ -1325,18 +1327,30 @@ void QuadMesh::_create_mesh_array(Array &p_arr) const { uvs.set(i, quad_uv[i]); } - p_arr[ARRAY_VERTEX] = faces; - p_arr[ARRAY_NORMAL] = normals; - p_arr[ARRAY_TANGENT] = tangents; - p_arr[ARRAY_TEX_UV] = uvs; + p_arr[VS::ARRAY_VERTEX] = faces; + p_arr[VS::ARRAY_NORMAL] = normals; + p_arr[VS::ARRAY_TANGENT] = tangents; + p_arr[VS::ARRAY_TEX_UV] = uvs; }; void QuadMesh::_bind_methods() { - // nothing here yet... + ClassDB::bind_method(D_METHOD("set_size", "size"), &QuadMesh::set_size); + ClassDB::bind_method(D_METHOD("get_size"), &QuadMesh::get_size); + ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size"); } QuadMesh::QuadMesh() { primitive_type = PRIMITIVE_TRIANGLE_FAN; + size = Size2(1.0, 1.0); +} + +void QuadMesh::set_size(const Size2 &p_size) { + size = p_size; + _request_update(); +} + +Size2 QuadMesh::get_size() const { + return size; } /** diff --git a/scene/resources/primitive_meshes.h b/scene/resources/primitive_meshes.h index 38a5695883..b38c247827 100644 --- a/scene/resources/primitive_meshes.h +++ b/scene/resources/primitive_meshes.h @@ -47,7 +47,7 @@ class PrimitiveMesh : public Mesh { private: RID mesh; - mutable Rect3 aabb; + mutable AABB aabb; Ref<Material> material; @@ -73,7 +73,7 @@ public: virtual Ref<Material> surface_get_material(int p_idx) const; virtual int get_blend_shape_count() const; virtual StringName get_blend_shape_name(int p_index) const; - virtual Rect3 get_aabb() const; + virtual AABB get_aabb() const; virtual RID get_rid() const; void set_material(const Ref<Material> &p_material); @@ -263,7 +263,7 @@ class QuadMesh : public PrimitiveMesh { GDCLASS(QuadMesh, PrimitiveMesh) private: - // nothing? really? Maybe add size some day atleast... :) + Size2 size; protected: static void _bind_methods(); @@ -271,6 +271,9 @@ protected: public: QuadMesh(); + + void set_size(const Size2 &p_size); + Size2 get_size() const; }; /** diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp index 507dbce861..69dbb76744 100644 --- a/scene/resources/rectangle_shape_2d.cpp +++ b/scene/resources/rectangle_shape_2d.cpp @@ -67,7 +67,7 @@ void RectangleShape2D::_bind_methods() { } RectangleShape2D::RectangleShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RECTANGLE)) { + : Shape2D(Physics2DServer::get_singleton()->rectangle_shape_create()) { extents = Vector2(10, 10); _update_shape(); diff --git a/scene/resources/scene_format_text.cpp b/scene/resources/scene_format_text.cpp index f0304bfaa5..fe23fbf6b3 100644 --- a/scene/resources/scene_format_text.cpp +++ b/scene/resources/scene_format_text.cpp @@ -33,7 +33,7 @@ #include "project_settings.h" #include "version.h" -//version 2: changed names for basis, rect3, poolvectors, etc. +//version 2: changed names for basis, aabb, poolvectors, etc. #define FORMAT_VERSION 2 #include "os/dir_access.h" diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp index 1171db5c02..7c7ec0d112 100644 --- a/scene/resources/segment_shape_2d.cpp +++ b/scene/resources/segment_shape_2d.cpp @@ -87,7 +87,7 @@ void SegmentShape2D::_bind_methods() { } SegmentShape2D::SegmentShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_SEGMENT)) { + : Shape2D(Physics2DServer::get_singleton()->segment_shape_create()) { a = Vector2(); b = Vector2(0, 10); @@ -146,7 +146,7 @@ real_t RayShape2D::get_length() const { } RayShape2D::RayShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_RAY)) { + : Shape2D(Physics2DServer::get_singleton()->ray_shape_create()) { length = 20; _update_shape(); diff --git a/scene/resources/shape_line_2d.cpp b/scene/resources/shape_line_2d.cpp index 4dcc5ac981..d046ce876c 100644 --- a/scene/resources/shape_line_2d.cpp +++ b/scene/resources/shape_line_2d.cpp @@ -96,7 +96,7 @@ void LineShape2D::_bind_methods() { } LineShape2D::LineShape2D() - : Shape2D(Physics2DServer::get_singleton()->shape_create(Physics2DServer::SHAPE_LINE)) { + : Shape2D(Physics2DServer::get_singleton()->line_shape_create()) { normal = Vector2(0, -1); d = 0; diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp index 50e8c28c22..29ac7852bf 100644 --- a/scene/resources/tile_set.cpp +++ b/scene/resources/tile_set.cpp @@ -57,11 +57,9 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) { tile_set_region(id, p_value); else if (what == "shape") tile_set_shape(id, 0, p_value); - else if (what == "shape_offset") { - Transform2D xform = tile_get_shape_transform(id, 0); - xform.set_origin(p_value); - tile_set_shape_transform(id, 0, xform); - } else if (what == "shape_transform") + else if (what == "shape_offset") + tile_set_shape_offset(id, 0, p_value); + else if (what == "shape_transform") tile_set_shape_transform(id, 0, p_value); else if (what == "shape_one_way") tile_set_shape_one_way(id, 0, p_value); @@ -110,7 +108,7 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const { else if (what == "shape") r_ret = tile_get_shape(id, 0); else if (what == "shape_offset") - r_ret = tile_get_shape_transform(id, 0).get_origin(); + r_ret = tile_get_shape_offset(id, 0); else if (what == "shape_transform") r_ret = tile_get_shape_transform(id, 0); else if (what == "shape_one_way") @@ -313,6 +311,16 @@ Transform2D TileSet::tile_get_shape_transform(int p_id, int p_shape_id) const { return Transform2D(); } +void TileSet::tile_set_shape_offset(int p_id, int p_shape_id, const Vector2 &p_offset) { + Transform2D transform = tile_get_shape_transform(p_id, p_shape_id); + transform.set_origin(p_offset); + tile_set_shape_transform(p_id, p_shape_id, transform); +} + +Vector2 TileSet::tile_get_shape_offset(int p_id, int p_shape_id) const { + return tile_get_shape_transform(p_id, p_shape_id).get_origin(); +} + void TileSet::tile_set_shape_one_way(int p_id, int p_shape_id, const bool p_one_way) { ERR_FAIL_COND(!tile_map.has(p_id)); diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index fe782ff987..3ef3f00cef 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -108,6 +108,9 @@ public: void tile_set_shape_transform(int p_id, int p_shape_id, const Transform2D &p_offset); Transform2D tile_get_shape_transform(int p_id, int p_shape_id) const; + void tile_set_shape_offset(int p_id, int p_shape_id, const Vector2 &p_offset); + Vector2 tile_get_shape_offset(int p_id, int p_shape_id) const; + void tile_set_shape_one_way(int p_id, int p_shape_id, bool p_one_way); bool tile_get_shape_one_way(int p_id, int p_shape_id) const; diff --git a/scene/resources/video_stream.h b/scene/resources/video_stream.h index 3f79858056..fbe52909e7 100644 --- a/scene/resources/video_stream.h +++ b/scene/resources/video_stream.h @@ -40,7 +40,7 @@ protected: static void _bind_methods(); public: - typedef int (*AudioMixCallback)(void *p_udata, const int16_t *p_data, int p_frames); + typedef int (*AudioMixCallback)(void *p_udata, const float *p_data, int p_frames); virtual void stop() = 0; virtual void play() = 0; @@ -48,7 +48,7 @@ public: virtual bool is_playing() const = 0; virtual void set_paused(bool p_paused) = 0; - virtual bool is_paused(bool p_paused) const = 0; + virtual bool is_paused() const = 0; virtual void set_loop(bool p_enable) = 0; virtual bool has_loop() const = 0; diff --git a/scene/resources/world.cpp b/scene/resources/world.cpp index af159975ca..86b32a5cdd 100644 --- a/scene/resources/world.cpp +++ b/scene/resources/world.cpp @@ -41,7 +41,7 @@ struct SpatialIndexer { struct NotifierData { - Rect3 aabb; + AABB aabb; OctreeElementID id; }; @@ -63,7 +63,7 @@ struct SpatialIndexer { uint64_t pass; uint64_t last_frame; - void _notifier_add(VisibilityNotifier *p_notifier, const Rect3 &p_rect) { + void _notifier_add(VisibilityNotifier *p_notifier, const AABB &p_rect) { ERR_FAIL_COND(notifiers.has(p_notifier)); notifiers[p_notifier].aabb = p_rect; @@ -71,7 +71,7 @@ struct SpatialIndexer { changed = true; } - void _notifier_update(VisibilityNotifier *p_notifier, const Rect3 &p_rect) { + void _notifier_update(VisibilityNotifier *p_notifier, const AABB &p_rect) { Map<VisibilityNotifier *, NotifierData>::Element *E = notifiers.find(p_notifier); ERR_FAIL_COND(!E); @@ -229,14 +229,14 @@ void World::_remove_camera(Camera *p_camera) { #endif } -void World::_register_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect) { +void World::_register_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect) { #ifndef _3D_DISABLED indexer->_notifier_add(p_notifier, p_rect); #endif } -void World::_update_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect) { +void World::_update_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect) { #ifndef _3D_DISABLED indexer->_notifier_update(p_notifier, p_rect); diff --git a/scene/resources/world.h b/scene/resources/world.h index 767d1b5b6e..e0f1de1fd0 100644 --- a/scene/resources/world.h +++ b/scene/resources/world.h @@ -60,8 +60,8 @@ protected: void _update_camera(Camera *p_camera); void _remove_camera(Camera *p_camera); - void _register_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect); - void _update_notifier(VisibilityNotifier *p_notifier, const Rect3 &p_rect); + void _register_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect); + void _update_notifier(VisibilityNotifier *p_notifier, const AABB &p_rect); void _remove_notifier(VisibilityNotifier *p_notifier); friend class Viewport; void _update(uint64_t p_frame); diff --git a/scene/scene_string_names.cpp b/scene/scene_string_names.cpp index d9770ec3f3..52b8e35d5e 100644 --- a/scene/scene_string_names.cpp +++ b/scene/scene_string_names.cpp @@ -143,7 +143,7 @@ SceneStringNames::SceneStringNames() { v_offset = StaticCString::create("v_offset"); transform_pos = StaticCString::create("position"); - transform_rot = StaticCString::create("rotation_deg"); + transform_rot = StaticCString::create("rotation_degrees"); transform_scale = StaticCString::create("scale"); _update_remote = StaticCString::create("_update_remote"); diff --git a/servers/arvr/arvr_interface.cpp b/servers/arvr/arvr_interface.cpp index 55707def7c..458459a843 100644 --- a/servers/arvr/arvr_interface.cpp +++ b/servers/arvr/arvr_interface.cpp @@ -43,7 +43,7 @@ void ARVRInterface::_bind_methods() { 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("get_render_targetsize"), &ARVRInterface::get_render_targetsize); ClassDB::bind_method(D_METHOD("is_stereo"), &ARVRInterface::is_stereo); ADD_GROUP("Interface", "interface_"); diff --git a/servers/arvr/arvr_interface.h b/servers/arvr/arvr_interface.h index 880f6e4595..1599c1a64f 100644 --- a/servers/arvr/arvr_interface.h +++ b/servers/arvr/arvr_interface.h @@ -103,7 +103,7 @@ public: /** rendering and internal **/ - virtual Size2 get_recommended_render_targetsize() = 0; /* returns the recommended render target size per eye for this device */ + virtual Size2 get_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 */ virtual CameraMatrix get_projection_for_eye(ARVRInterface::Eyes p_eye, real_t p_aspect, real_t p_z_near, real_t p_z_far) = 0; /* get each eyes projection matrix */ diff --git a/servers/arvr_server.cpp b/servers/arvr_server.cpp index ede080b424..1e73d6753c 100644 --- a/servers/arvr_server.cpp +++ b/servers/arvr_server.cpp @@ -49,15 +49,13 @@ void ARVRServer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_interface_count"), &ARVRServer::get_interface_count); ClassDB::bind_method(D_METHOD("get_interface", "idx"), &ARVRServer::get_interface); + ClassDB::bind_method(D_METHOD("get_interfaces"), &ARVRServer::get_interfaces); ClassDB::bind_method(D_METHOD("find_interface", "name"), &ARVRServer::find_interface); ClassDB::bind_method(D_METHOD("get_tracker_count"), &ARVRServer::get_tracker_count); ClassDB::bind_method(D_METHOD("get_tracker", "idx"), &ARVRServer::get_tracker); ClassDB::bind_method(D_METHOD("set_primary_interface", "interface"), &ARVRServer::set_primary_interface); - ClassDB::bind_method(D_METHOD("add_interface", "interface"), &ARVRServer::add_interface); - ClassDB::bind_method(D_METHOD("remove_interface", "interface"), &ARVRServer::remove_interface); - BIND_ENUM_CONSTANT(TRACKER_CONTROLLER); BIND_ENUM_CONSTANT(TRACKER_BASESTATION); BIND_ENUM_CONSTANT(TRACKER_ANCHOR); @@ -191,6 +189,21 @@ Ref<ARVRInterface> ARVRServer::find_interface(const String &p_name) const { return interfaces[idx]; }; +Array ARVRServer::get_interfaces() const { + Array ret; + + for (int i = 0; i < interfaces.size(); i++) { + Dictionary iface_info; + + iface_info["id"] = i; + iface_info["name"] = interfaces[i]->get_name(); + + ret.push_back(iface_info); + }; + + return ret; +}; + /* A little extra info on the tracker ids, these are unique per tracker type so we get soem consistency in recognising our trackers, specifically controllers. diff --git a/servers/arvr_server.h b/servers/arvr_server.h index 948895cb27..9b84ee2e99 100644 --- a/servers/arvr_server.h +++ b/servers/arvr_server.h @@ -137,6 +137,7 @@ public: int get_interface_count() const; Ref<ARVRInterface> get_interface(int p_index) const; Ref<ARVRInterface> find_interface(const String &p_name) const; + Array get_interfaces() const; /* note, more then one interface can technically be active, especially on mobile, but only one interface is used for diff --git a/servers/audio/audio_rb_resampler.cpp b/servers/audio/audio_rb_resampler.cpp index 113e356612..b0b94a1f49 100644 --- a/servers/audio/audio_rb_resampler.cpp +++ b/servers/audio/audio_rb_resampler.cpp @@ -28,6 +28,9 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "audio_rb_resampler.h" +#include "core/math/math_funcs.h" +#include "os/os.h" +#include "servers/audio_server.h" int AudioRBResampler::get_channel_count() const { @@ -37,8 +40,11 @@ int AudioRBResampler::get_channel_count() const { return channels; } +// Linear interpolation based sample rate convertion (low quality) +// Note that AudioStreamPlaybackResampled::mix has better algorithm, +// but it wasn't obvious to integrate that with VideoPlayer template <int C> -uint32_t AudioRBResampler::_resample(int32_t *p_dest, int p_todo, int32_t p_increment) { +uint32_t AudioRBResampler::_resample(AudioFrame *p_dest, int p_todo, int32_t p_increment) { uint32_t read = offset & MIX_FRAC_MASK; @@ -47,186 +53,128 @@ uint32_t AudioRBResampler::_resample(int32_t *p_dest, int p_todo, int32_t p_incr offset = (offset + p_increment) & (((1 << (rb_bits + MIX_FRAC_BITS)) - 1)); read += p_increment; uint32_t pos = offset >> MIX_FRAC_BITS; - uint32_t frac = offset & MIX_FRAC_MASK; -#ifndef FAST_AUDIO + float frac = float(offset & MIX_FRAC_MASK) / float(MIX_FRAC_LEN); ERR_FAIL_COND_V(pos >= rb_len, 0); -#endif uint32_t pos_next = (pos + 1) & rb_mask; - //printf("rb pos %i\n",pos); // since this is a template with a known compile time value (C), conditionals go away when compiling. if (C == 1) { - int32_t v0 = rb[pos]; - int32_t v0n = rb[pos_next]; -#ifndef FAST_AUDIO - v0 += (v0n - v0) * (int32_t)frac >> MIX_FRAC_BITS; -#endif - v0 <<= 16; - p_dest[i] = v0; + float v0 = rb[pos]; + float v0n = rb[pos_next]; + v0 += (v0n - v0) * frac; + p_dest[i] = AudioFrame(v0, v0); } + if (C == 2) { - int32_t v0 = rb[(pos << 1) + 0]; - int32_t v1 = rb[(pos << 1) + 1]; - int32_t v0n = rb[(pos_next << 1) + 0]; - int32_t v1n = rb[(pos_next << 1) + 1]; - -#ifndef FAST_AUDIO - v0 += (v0n - v0) * (int32_t)frac >> MIX_FRAC_BITS; - v1 += (v1n - v1) * (int32_t)frac >> MIX_FRAC_BITS; -#endif - v0 <<= 16; - v1 <<= 16; - p_dest[(i << 1) + 0] = v0; - p_dest[(i << 1) + 1] = v1; + float v0 = rb[(pos << 1) + 0]; + float v1 = rb[(pos << 1) + 1]; + float v0n = rb[(pos_next << 1) + 0]; + float v1n = rb[(pos_next << 1) + 1]; + + v0 += (v0n - v0) * frac; + v1 += (v1n - v1) * frac; + p_dest[i] = AudioFrame(v0, v1); } + // For now, channels higher than stereo are almost ignored if (C == 4) { - int32_t v0 = rb[(pos << 2) + 0]; - int32_t v1 = rb[(pos << 2) + 1]; - int32_t v2 = rb[(pos << 2) + 2]; - int32_t v3 = rb[(pos << 2) + 3]; - int32_t v0n = rb[(pos_next << 2) + 0]; - int32_t v1n = rb[(pos_next << 2) + 1]; - int32_t v2n = rb[(pos_next << 2) + 2]; - int32_t v3n = rb[(pos_next << 2) + 3]; - -#ifndef FAST_AUDIO - v0 += (v0n - v0) * (int32_t)frac >> MIX_FRAC_BITS; - v1 += (v1n - v1) * (int32_t)frac >> MIX_FRAC_BITS; - v2 += (v2n - v2) * (int32_t)frac >> MIX_FRAC_BITS; - v3 += (v3n - v3) * (int32_t)frac >> MIX_FRAC_BITS; -#endif - v0 <<= 16; - v1 <<= 16; - v2 <<= 16; - v3 <<= 16; - p_dest[(i << 2) + 0] = v0; - p_dest[(i << 2) + 1] = v1; - p_dest[(i << 2) + 2] = v2; - p_dest[(i << 2) + 3] = v3; + float v0 = rb[(pos << 2) + 0]; + float v1 = rb[(pos << 2) + 1]; + float v2 = rb[(pos << 2) + 2]; + float v3 = rb[(pos << 2) + 3]; + float v0n = rb[(pos_next << 2) + 0]; + float v1n = rb[(pos_next << 2) + 1]; + float v2n = rb[(pos_next << 2) + 2]; + float v3n = rb[(pos_next << 2) + 3]; + + v0 += (v0n - v0) * frac; + v1 += (v1n - v1) * frac; + v2 += (v2n - v2) * frac; + v3 += (v3n - v3) * frac; + p_dest[i] = AudioFrame(v0, v1); } if (C == 6) { - int32_t v0 = rb[(pos * 6) + 0]; - int32_t v1 = rb[(pos * 6) + 1]; - int32_t v2 = rb[(pos * 6) + 2]; - int32_t v3 = rb[(pos * 6) + 3]; - int32_t v4 = rb[(pos * 6) + 4]; - int32_t v5 = rb[(pos * 6) + 5]; - int32_t v0n = rb[(pos_next * 6) + 0]; - int32_t v1n = rb[(pos_next * 6) + 1]; - int32_t v2n = rb[(pos_next * 6) + 2]; - int32_t v3n = rb[(pos_next * 6) + 3]; - int32_t v4n = rb[(pos_next * 6) + 4]; - int32_t v5n = rb[(pos_next * 6) + 5]; - -#ifndef FAST_AUDIO - v0 += (v0n - v0) * (int32_t)frac >> MIX_FRAC_BITS; - v1 += (v1n - v1) * (int32_t)frac >> MIX_FRAC_BITS; - v2 += (v2n - v2) * (int32_t)frac >> MIX_FRAC_BITS; - v3 += (v3n - v3) * (int32_t)frac >> MIX_FRAC_BITS; - v4 += (v4n - v4) * (int32_t)frac >> MIX_FRAC_BITS; - v5 += (v5n - v5) * (int32_t)frac >> MIX_FRAC_BITS; -#endif - v0 <<= 16; - v1 <<= 16; - v2 <<= 16; - v3 <<= 16; - v4 <<= 16; - v5 <<= 16; - p_dest[(i * 6) + 0] = v0; - p_dest[(i * 6) + 1] = v1; - p_dest[(i * 6) + 2] = v2; - p_dest[(i * 6) + 3] = v3; - p_dest[(i * 6) + 4] = v4; - p_dest[(i * 6) + 5] = v5; + float v0 = rb[(pos * 6) + 0]; + float v1 = rb[(pos * 6) + 1]; + float v2 = rb[(pos * 6) + 2]; + float v3 = rb[(pos * 6) + 3]; + float v4 = rb[(pos * 6) + 4]; + float v5 = rb[(pos * 6) + 5]; + float v0n = rb[(pos_next * 6) + 0]; + float v1n = rb[(pos_next * 6) + 1]; + float v2n = rb[(pos_next * 6) + 2]; + float v3n = rb[(pos_next * 6) + 3]; + float v4n = rb[(pos_next * 6) + 4]; + float v5n = rb[(pos_next * 6) + 5]; + + p_dest[i] = AudioFrame(v0, v1); } } - return read >> MIX_FRAC_BITS; //rb_read_pos=offset>>MIX_FRAC_BITS; + return read >> MIX_FRAC_BITS; //rb_read_pos = offset >> MIX_FRAC_BITS; } -bool AudioRBResampler::mix(int32_t *p_dest, int p_frames) { +bool AudioRBResampler::mix(AudioFrame *p_dest, int p_frames) { if (!rb) return false; - int write_pos_cache = rb_write_pos; - int32_t increment = (src_mix_rate * MIX_FRAC_LEN) / target_mix_rate; - - int rb_todo; - - if (write_pos_cache == rb_read_pos) { - return false; //out of buffer - - } else if (rb_read_pos < write_pos_cache) { - - rb_todo = write_pos_cache - rb_read_pos; //-1? - } else { - - rb_todo = (rb_len - rb_read_pos) + write_pos_cache; //-1? - } - - int todo = MIN(((int64_t(rb_todo) << MIX_FRAC_BITS) / increment) + 1, p_frames); + int read_space = get_reader_space(); + int target_todo = MIN(get_num_of_ready_frames(), p_frames); { - - int read = 0; + int src_read = 0; switch (channels) { - case 1: read = _resample<1>(p_dest, todo, increment); break; - case 2: read = _resample<2>(p_dest, todo, increment); break; - case 4: read = _resample<4>(p_dest, todo, increment); break; - case 6: read = _resample<6>(p_dest, todo, increment); break; + case 1: src_read = _resample<1>(p_dest, target_todo, increment); break; + case 2: src_read = _resample<2>(p_dest, target_todo, increment); break; + case 4: src_read = _resample<4>(p_dest, target_todo, increment); break; + case 6: src_read = _resample<6>(p_dest, target_todo, increment); break; } - //end of stream, fadeout - int remaining = p_frames - todo; - if (remaining && todo > 0) { - - //print_line("fadeout"); - for (uint32_t c = 0; c < channels; c++) { + if (src_read > read_space) + src_read = read_space; - for (int i = 0; i < todo; i++) { + rb_read_pos = (rb_read_pos + src_read) & rb_mask; - int32_t samp = p_dest[i * channels + c] >> 8; - uint32_t mul = (todo - i) * 256 / todo; - //print_line("mul: "+itos(i)+" "+itos(mul)); - p_dest[i * channels + c] = samp * mul; - } + // Create fadeout effect for the end of stream (note that it can be because of slow writer) + if (p_frames - target_todo > 0) { + for (int i = 0; i < target_todo; i++) { + p_dest[i] = p_dest[i] * float(target_todo - i) / float(target_todo); } } - //zero out what remains there to avoid glitches - for (uint32_t i = todo * channels; i < int(p_frames) * channels; i++) { - - p_dest[i] = 0; + // Fill zeros (silence) for the rest of frames + for (uint32_t i = target_todo; i < p_frames; i++) { + p_dest[i] = AudioFrame(0, 0); } - - if (read > rb_todo) - read = rb_todo; - - rb_read_pos = (rb_read_pos + read) & rb_mask; } return true; } +int AudioRBResampler::get_num_of_ready_frames() { + if (!is_ready()) + return 0; + int32_t increment = (src_mix_rate * MIX_FRAC_LEN) / target_mix_rate; + int read_space = get_reader_space(); + return (int64_t(read_space) << MIX_FRAC_BITS) / increment; +} + Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_mix_rate, int p_buffer_msec, int p_minbuff_needed) { ERR_FAIL_COND_V(p_channels != 1 && p_channels != 2 && p_channels != 4 && p_channels != 6, ERR_INVALID_PARAMETER); - //float buffering_sec = int(GLOBAL_DEF("audio/stream_buffering_ms",500))/1000.0; int desired_rb_bits = nearest_shift(MAX((p_buffer_msec / 1000.0) * p_src_mix_rate, p_minbuff_needed)); bool recreate = !rb; if (rb && (uint32_t(desired_rb_bits) != rb_bits || channels != uint32_t(p_channels))) { - //recreate memdelete_arr(rb); memdelete_arr(read_buf); @@ -239,8 +187,8 @@ Error AudioRBResampler::setup(int p_channels, int p_src_mix_rate, int p_target_m rb_bits = desired_rb_bits; rb_len = (1 << rb_bits); rb_mask = rb_len - 1; - rb = memnew_arr(int16_t, rb_len * p_channels); - read_buf = memnew_arr(int16_t, rb_len * p_channels); + rb = memnew_arr(float, rb_len *p_channels); + read_buf = memnew_arr(float, rb_len *p_channels); } src_mix_rate = p_src_mix_rate; diff --git a/servers/audio/audio_rb_resampler.h b/servers/audio/audio_rb_resampler.h index bc1f924ab5..08c7a5a668 100644 --- a/servers/audio/audio_rb_resampler.h +++ b/servers/audio/audio_rb_resampler.h @@ -31,6 +31,7 @@ #define AUDIO_RB_RESAMPLER_H #include "os/memory.h" +#include "servers/audio_server.h" #include "typedefs.h" struct AudioRBResampler { @@ -53,11 +54,11 @@ struct AudioRBResampler { MIX_FRAC_MASK = MIX_FRAC_LEN - 1, }; - int16_t *read_buf; - int16_t *rb; + float *read_buf; + float *rb; template <int C> - uint32_t _resample(int32_t *p_dest, int p_todo, int32_t p_increment); + uint32_t _resample(AudioFrame *p_dest, int p_todo, int32_t p_increment); public: _FORCE_INLINE_ void flush() { @@ -71,33 +72,48 @@ public: } _FORCE_INLINE_ int get_total() const { - return rb_len - 1; } - _FORCE_INLINE_ int get_todo() const { //return amount of frames to mix - - int todo; - int read_pos_cache = rb_read_pos; + _FORCE_INLINE_ int get_writer_space() const { + int space, r, w; - if (read_pos_cache == rb_write_pos) { - todo = rb_len - 1; - } else if (read_pos_cache > rb_write_pos) { + r = rb_read_pos; + w = rb_write_pos; - todo = read_pos_cache - rb_write_pos - 1; + if (r == w) { + space = rb_len - 1; + } else if (w < r) { + space = r - w - 1; } else { + space = (rb_len - r) + w - 1; + } + + return space; + } + + _FORCE_INLINE_ int get_reader_space() const { + int space, r, w; - todo = (rb_len - rb_write_pos) + read_pos_cache - 1; + r = rb_read_pos; + w = rb_write_pos; + + if (r == w) { + space = 0; + } else if (w < r) { + space = rb_len - r + w; + } else { + space = w - r; } - return todo; + return space; } _FORCE_INLINE_ bool has_data() const { return rb && rb_read_pos != rb_write_pos; } - _FORCE_INLINE_ int16_t *get_write_buffer() { return read_buf; } + _FORCE_INLINE_ float *get_write_buffer() { return read_buf; } _FORCE_INLINE_ void write(uint32_t p_frames) { ERR_FAIL_COND(p_frames >= rb_len); @@ -151,7 +167,8 @@ public: Error setup(int p_channels, int p_src_mix_rate, int p_target_mix_rate, int p_buffer_msec, int p_minbuff_needed = -1); void clear(); - bool mix(int32_t *p_dest, int p_frames); + bool mix(AudioFrame *p_dest, int p_frames); + int get_num_of_ready_frames(); AudioRBResampler(); ~AudioRBResampler(); diff --git a/servers/audio_server.cpp b/servers/audio_server.cpp index 697abead68..6a10d7539d 100644 --- a/servers/audio_server.cpp +++ b/servers/audio_server.cpp @@ -876,6 +876,8 @@ void AudioServer::init() { #ifdef TOOLS_ENABLED set_edited(false); //avoid editors from thinking this was edited #endif + + GLOBAL_DEF("audio/video_delay_compensation_ms", 0); } void AudioServer::load_default_bus_layout() { diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics/body_pair_sw.cpp index a289b4b0ca..ef54eb58cf 100644 --- a/servers/physics/body_pair_sw.cpp +++ b/servers/physics/body_pair_sw.cpp @@ -46,6 +46,7 @@ //#define ALLOWED_PENETRATION 0.01 #define RELAXATION_TIMESTEPS 3 #define MIN_VELOCITY 0.0001 +#define MAX_BIAS_ROTATION (Math_PI / 8) void BodyPairSW::_contact_added_callback(const Vector3 &p_point_A, const Vector3 &p_point_B, void *p_userdata) { @@ -71,6 +72,7 @@ void BodyPairSW::contact_added_callback(const Vector3 &p_point_A, const Vector3 contact.acc_normal_impulse = 0; contact.acc_bias_impulse = 0; + contact.acc_bias_impulse_center_of_mass = 0; contact.acc_tangent_impulse = Vector3(); contact.local_A = local_A; contact.local_B = local_B; @@ -82,12 +84,12 @@ void BodyPairSW::contact_added_callback(const Vector3 &p_point_A, const Vector3 for (int i = 0; i < contact_count; i++) { Contact &c = contacts[i]; - if ( - c.local_A.distance_squared_to(local_A) < (contact_recycle_radius * contact_recycle_radius) && + if (c.local_A.distance_squared_to(local_A) < (contact_recycle_radius * contact_recycle_radius) && c.local_B.distance_squared_to(local_B) < (contact_recycle_radius * contact_recycle_radius)) { contact.acc_normal_impulse = c.acc_normal_impulse; contact.acc_bias_impulse = c.acc_bias_impulse; + contact.acc_bias_impulse_center_of_mass = c.acc_bias_impulse_center_of_mass; contact.acc_tangent_impulse = c.acc_tangent_impulse; new_index = i; break; @@ -325,9 +327,7 @@ bool BodyPairSW::setup(real_t p_step) { A->apply_impulse(c.rA + A->get_center_of_mass(), -j_vec); B->apply_impulse(c.rB + B->get_center_of_mass(), j_vec); c.acc_bias_impulse = 0; - Vector3 jb_vec = c.normal * c.acc_bias_impulse; - A->apply_bias_impulse(c.rA + A->get_center_of_mass(), -jb_vec); - B->apply_bias_impulse(c.rB + B->get_center_of_mass(), jb_vec); + c.acc_bias_impulse_center_of_mass = 0; c.bounce = MAX(A->get_bounce(), B->get_bounce()); if (c.bounce) { @@ -356,7 +356,7 @@ void BodyPairSW::solve(real_t p_step) { c.active = false; //try to deactivate, will activate itself if still needed - //bias impule + //bias impulse Vector3 crbA = A->get_biased_angular_velocity().cross(c.rA); Vector3 crbB = B->get_biased_angular_velocity().cross(c.rB); @@ -372,8 +372,26 @@ void BodyPairSW::solve(real_t p_step) { Vector3 jb = c.normal * (c.acc_bias_impulse - jbnOld); - A->apply_bias_impulse(c.rA + A->get_center_of_mass(), -jb); - B->apply_bias_impulse(c.rB + B->get_center_of_mass(), jb); + A->apply_bias_impulse(c.rA + A->get_center_of_mass(), -jb, MAX_BIAS_ROTATION / p_step); + B->apply_bias_impulse(c.rB + B->get_center_of_mass(), jb, MAX_BIAS_ROTATION / p_step); + + crbA = A->get_biased_angular_velocity().cross(c.rA); + crbB = B->get_biased_angular_velocity().cross(c.rB); + dbv = B->get_biased_linear_velocity() + crbB - A->get_biased_linear_velocity() - crbA; + + vbn = dbv.dot(c.normal); + + if (Math::abs(-vbn + c.bias) > MIN_VELOCITY) { + + real_t jbn_com = (-vbn + c.bias) / (A->get_inv_mass() + B->get_inv_mass()); + real_t jbnOld_com = c.acc_bias_impulse_center_of_mass; + c.acc_bias_impulse_center_of_mass = MAX(jbnOld_com + jbn_com, 0.0f); + + Vector3 jb_com = c.normal * (c.acc_bias_impulse_center_of_mass - jbnOld_com); + + A->apply_bias_impulse(A->get_center_of_mass(), -jb_com, 0.0f); + B->apply_bias_impulse(B->get_center_of_mass(), jb_com, 0.0f); + } c.active = true; } @@ -382,7 +400,7 @@ void BodyPairSW::solve(real_t p_step) { Vector3 crB = B->get_angular_velocity().cross(c.rB); Vector3 dv = B->get_linear_velocity() + crB - A->get_linear_velocity() - crA; - //normal impule + //normal impulse real_t vn = dv.dot(c.normal); if (Math::abs(vn) > MIN_VELOCITY) { @@ -399,7 +417,7 @@ void BodyPairSW::solve(real_t p_step) { c.active = true; } - //friction impule + //friction impulse real_t friction = A->get_friction() * B->get_friction(); diff --git a/servers/physics/body_pair_sw.h b/servers/physics/body_pair_sw.h index f09c977950..74fda60998 100644 --- a/servers/physics/body_pair_sw.h +++ b/servers/physics/body_pair_sw.h @@ -59,6 +59,7 @@ class BodyPairSW : public ConstraintSW { real_t acc_normal_impulse; // accumulated normal impulse (Pn) Vector3 acc_tangent_impulse; // accumulated tangent impulse (Pt) real_t acc_bias_impulse; // accumulated normal impulse for position bias (Pnb) + real_t acc_bias_impulse_center_of_mass; // accumulated normal impulse for position bias applied to com real_t mass_normal; real_t bias; real_t bounce; diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index 6ced004118..f8cd6ca858 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -736,6 +736,10 @@ void BodySW::set_force_integration_callback(ObjectID p_id, const StringName &p_m } } +void BodySW::set_kinematic_margin(real_t p_margin) { + kinematic_safe_margin = p_margin; +} + BodySW::BodySW() : CollisionObjectSW(TYPE_BODY), active_list(this), inertia_update_list(this), direct_state_query_list(this) { @@ -743,6 +747,7 @@ BodySW::BodySW() active = true; mass = 1; + kinematic_safe_margin = 0.01; //_inv_inertia=Transform(); _inv_mass = 1; bounce = 0; diff --git a/servers/physics/body_sw.h b/servers/physics/body_sw.h index 782bf14a4b..738d99c764 100644 --- a/servers/physics/body_sw.h +++ b/servers/physics/body_sw.h @@ -55,6 +55,7 @@ class BodySW : public CollisionObjectSW { PhysicsServer::BodyAxisLock axis_lock; + real_t kinematic_safe_margin; real_t _inv_mass; Vector3 _inv_inertia; // Relative to the principal axes of inertia @@ -149,6 +150,9 @@ class BodySW : public CollisionObjectSW { public: void set_force_integration_callback(ObjectID p_id, const StringName &p_method, const Variant &p_udata = Variant()); + void set_kinematic_margin(real_t p_margin); + _FORCE_INLINE_ real_t get_kinematic_margin() { return kinematic_safe_margin; } + _FORCE_INLINE_ void add_area(AreaSW *p_area) { int index = areas.find(AreaCMP(p_area)); if (index > -1) { @@ -223,10 +227,16 @@ public: angular_velocity += _inv_inertia_tensor.xform(p_j); } - _FORCE_INLINE_ void apply_bias_impulse(const Vector3 &p_pos, const Vector3 &p_j) { + _FORCE_INLINE_ void apply_bias_impulse(const Vector3 &p_pos, const Vector3 &p_j, real_t p_max_delta_av = -1.0) { biased_linear_velocity += p_j * _inv_mass; - biased_angular_velocity += _inv_inertia_tensor.xform((p_pos - center_of_mass).cross(p_j)); + if (p_max_delta_av != 0.0) { + Vector3 delta_av = _inv_inertia_tensor.xform((p_pos - center_of_mass).cross(p_j)); + if (p_max_delta_av > 0 && delta_av.length() > p_max_delta_av) { + delta_av = delta_av.normalized() * p_max_delta_av; + } + biased_angular_velocity += delta_av; + } } _FORCE_INLINE_ void apply_bias_torque_impulse(const Vector3 &p_j) { diff --git a/servers/physics/broad_phase_basic.cpp b/servers/physics/broad_phase_basic.cpp index c6565ac2e9..e4eae09c61 100644 --- a/servers/physics/broad_phase_basic.cpp +++ b/servers/physics/broad_phase_basic.cpp @@ -46,7 +46,7 @@ BroadPhaseSW::ID BroadPhaseBasic::create(CollisionObjectSW *p_object, int p_subi return current; } -void BroadPhaseBasic::move(ID p_id, const Rect3 &p_aabb) { +void BroadPhaseBasic::move(ID p_id, const AABB &p_aabb) { Map<ID, Element>::Element *E = element_map.find(p_id); ERR_FAIL_COND(!E); @@ -109,7 +109,7 @@ int BroadPhaseBasic::cull_point(const Vector3 &p_point, CollisionObjectSW **p_re for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) { - const Rect3 aabb = E->get().aabb; + const AABB aabb = E->get().aabb; if (aabb.has_point(p_point)) { p_results[rc] = E->get().owner; @@ -129,7 +129,7 @@ int BroadPhaseBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, Co for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) { - const Rect3 aabb = E->get().aabb; + const AABB aabb = E->get().aabb; if (aabb.intersects_segment(p_from, p_to)) { p_results[rc] = E->get().owner; @@ -142,13 +142,13 @@ int BroadPhaseBasic::cull_segment(const Vector3 &p_from, const Vector3 &p_to, Co return rc; } -int BroadPhaseBasic::cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { +int BroadPhaseBasic::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { int rc = 0; for (Map<ID, Element>::Element *E = element_map.front(); E; E = E->next()) { - const Rect3 aabb = E->get().aabb; + const AABB aabb = E->get().aabb; if (aabb.intersects(p_aabb)) { p_results[rc] = E->get().owner; diff --git a/servers/physics/broad_phase_basic.h b/servers/physics/broad_phase_basic.h index 5c124c1792..ee683ed840 100644 --- a/servers/physics/broad_phase_basic.h +++ b/servers/physics/broad_phase_basic.h @@ -39,7 +39,7 @@ class BroadPhaseBasic : public BroadPhaseSW { CollisionObjectSW *owner; bool _static; - Rect3 aabb; + AABB aabb; int subindex; }; @@ -83,7 +83,7 @@ class BroadPhaseBasic : public BroadPhaseSW { public: // 0 is an invalid ID virtual ID create(CollisionObjectSW *p_object, int p_subindex = 0); - virtual void move(ID p_id, const Rect3 &p_aabb); + virtual void move(ID p_id, const AABB &p_aabb); virtual void set_static(ID p_id, bool p_static); virtual void remove(ID p_id); @@ -93,7 +93,7 @@ public: virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); - virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); + virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata); virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata); diff --git a/servers/physics/broad_phase_octree.cpp b/servers/physics/broad_phase_octree.cpp index e7111d9580..3b18a270f0 100644 --- a/servers/physics/broad_phase_octree.cpp +++ b/servers/physics/broad_phase_octree.cpp @@ -32,11 +32,11 @@ BroadPhaseSW::ID BroadPhaseOctree::create(CollisionObjectSW *p_object, int p_subindex) { - ID oid = octree.create(p_object, Rect3(), p_subindex, false, 1 << p_object->get_type(), 0); + ID oid = octree.create(p_object, AABB(), p_subindex, false, 1 << p_object->get_type(), 0); return oid; } -void BroadPhaseOctree::move(ID p_id, const Rect3 &p_aabb) { +void BroadPhaseOctree::move(ID p_id, const AABB &p_aabb) { octree.move(p_id, p_aabb); } @@ -76,7 +76,7 @@ int BroadPhaseOctree::cull_segment(const Vector3 &p_from, const Vector3 &p_to, C return octree.cull_segment(p_from, p_to, p_results, p_max_results, p_result_indices); } -int BroadPhaseOctree::cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { +int BroadPhaseOctree::cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices) { return octree.cull_aabb(p_aabb, p_results, p_max_results, p_result_indices); } diff --git a/servers/physics/broad_phase_octree.h b/servers/physics/broad_phase_octree.h index d28f2da13f..f894d6ca5a 100644 --- a/servers/physics/broad_phase_octree.h +++ b/servers/physics/broad_phase_octree.h @@ -48,7 +48,7 @@ class BroadPhaseOctree : public BroadPhaseSW { public: // 0 is an invalid ID virtual ID create(CollisionObjectSW *p_object, int p_subindex = 0); - virtual void move(ID p_id, const Rect3 &p_aabb); + virtual void move(ID p_id, const AABB &p_aabb); virtual void set_static(ID p_id, bool p_static); virtual void remove(ID p_id); @@ -58,7 +58,7 @@ public: virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); - virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); + virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL); virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata); virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata); diff --git a/servers/physics/broad_phase_sw.h b/servers/physics/broad_phase_sw.h index 2b5ed629fe..5ad3f9a261 100644 --- a/servers/physics/broad_phase_sw.h +++ b/servers/physics/broad_phase_sw.h @@ -30,8 +30,8 @@ #ifndef BROAD_PHASE_SW_H #define BROAD_PHASE_SW_H +#include "aabb.h" #include "math_funcs.h" -#include "rect3.h" class CollisionObjectSW; @@ -49,7 +49,7 @@ public: // 0 is an invalid ID virtual ID create(CollisionObjectSW *p_object_, int p_subindex = 0) = 0; - virtual void move(ID p_id, const Rect3 &p_aabb) = 0; + virtual void move(ID p_id, const AABB &p_aabb) = 0; virtual void set_static(ID p_id, bool p_static) = 0; virtual void remove(ID p_id) = 0; @@ -59,7 +59,7 @@ public: virtual int cull_point(const Vector3 &p_point, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; virtual int cull_segment(const Vector3 &p_from, const Vector3 &p_to, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; - virtual int cull_aabb(const Rect3 &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; + virtual int cull_aabb(const AABB &p_aabb, CollisionObjectSW **p_results, int p_max_results, int *p_result_indices = NULL) = 0; virtual void set_pair_callback(PairCallback p_pair_callback, void *p_userdata) = 0; virtual void set_unpair_callback(UnpairCallback p_unpair_callback, void *p_userdata) = 0; diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp index 3af8b542fa..126f8141ff 100644 --- a/servers/physics/collision_object_sw.cpp +++ b/servers/physics/collision_object_sw.cpp @@ -149,7 +149,7 @@ void CollisionObjectSW::_update_shapes() { } //not quite correct, should compute the next matrix.. - Rect3 shape_aabb = s.shape->get_aabb(); + AABB shape_aabb = s.shape->get_aabb(); Transform xform = transform * s.xform; shape_aabb = xform.xform(shape_aabb); s.aabb_cache = shape_aabb; @@ -176,10 +176,10 @@ void CollisionObjectSW::_update_shapes_with_motion(const Vector3 &p_motion) { } //not quite correct, should compute the next matrix.. - Rect3 shape_aabb = s.shape->get_aabb(); + AABB shape_aabb = s.shape->get_aabb(); Transform xform = transform * s.xform; shape_aabb = xform.xform(shape_aabb); - shape_aabb = shape_aabb.merge(Rect3(shape_aabb.position + p_motion, shape_aabb.size)); //use motion + shape_aabb = shape_aabb.merge(AABB(shape_aabb.position + p_motion, shape_aabb.size)); //use motion s.aabb_cache = shape_aabb; space->get_broadphase()->move(s.bpid, shape_aabb); diff --git a/servers/physics/collision_object_sw.h b/servers/physics/collision_object_sw.h index 67a8a44944..254947060b 100644 --- a/servers/physics/collision_object_sw.h +++ b/servers/physics/collision_object_sw.h @@ -61,7 +61,7 @@ private: Transform xform; Transform xform_inv; BroadPhaseSW::ID bpid; - Rect3 aabb_cache; //for rayqueries + AABB aabb_cache; //for rayqueries real_t area_cache; ShapeSW *shape; bool disabled; @@ -123,7 +123,7 @@ public: _FORCE_INLINE_ ShapeSW *get_shape(int p_index) const { return shapes[p_index].shape; } _FORCE_INLINE_ const Transform &get_shape_transform(int p_index) const { return shapes[p_index].xform; } _FORCE_INLINE_ const Transform &get_shape_inv_transform(int p_index) const { return shapes[p_index].xform_inv; } - _FORCE_INLINE_ const Rect3 &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; } + _FORCE_INLINE_ const AABB &get_shape_aabb(int p_index) const { return shapes[p_index].aabb_cache; } _FORCE_INLINE_ const real_t get_shape_area(int p_index) const { return shapes[p_index].area_cache; } _FORCE_INLINE_ Transform get_transform() const { return transform; } diff --git a/servers/physics/collision_solver_sw.cpp b/servers/physics/collision_solver_sw.cpp index 7bef208237..a9431dc6d8 100644 --- a/servers/physics/collision_solver_sw.cpp +++ b/servers/physics/collision_solver_sw.cpp @@ -152,7 +152,7 @@ bool CollisionSolverSW::solve_concave(const ShapeSW *p_shape_A, const Transform //quickly compute a local AABB - Rect3 local_aabb; + AABB local_aabb; for (int i = 0; i < 3; i++) { Vector3 axis(p_transform_B.basis.get_axis(i)); @@ -291,7 +291,7 @@ bool CollisionSolverSW::solve_distance_plane(const ShapeSW *p_shape_A, const Tra return collided; } -bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const Rect3 &p_concave_hint, Vector3 *r_sep_axis) { +bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis) { if (p_shape_A->is_concave()) return false; @@ -328,14 +328,14 @@ bool CollisionSolverSW::solve_distance(const ShapeSW *p_shape_A, const Transform //quickly compute a local AABB - bool use_cc_hint = p_concave_hint != Rect3(); - Rect3 cc_hint_aabb; + bool use_cc_hint = p_concave_hint != AABB(); + AABB cc_hint_aabb; if (use_cc_hint) { cc_hint_aabb = p_concave_hint; cc_hint_aabb.position -= p_transform_B.origin; } - Rect3 local_aabb; + AABB local_aabb; for (int i = 0; i < 3; i++) { Vector3 axis(p_transform_B.basis.get_axis(i)); diff --git a/servers/physics/collision_solver_sw.h b/servers/physics/collision_solver_sw.h index 1e38b1b54e..a40b665ff0 100644 --- a/servers/physics/collision_solver_sw.h +++ b/servers/physics/collision_solver_sw.h @@ -46,7 +46,7 @@ private: public: static bool solve_static(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, CallbackResult p_result_callback, void *p_userdata, Vector3 *r_sep_axis = NULL, real_t p_margin_A = 0, real_t p_margin_B = 0); - static bool solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const Rect3 &p_concave_hint, Vector3 *r_sep_axis = NULL); + static bool solve_distance(const ShapeSW *p_shape_A, const Transform &p_transform_A, const ShapeSW *p_shape_B, const Transform &p_transform_B, Vector3 &r_point_A, Vector3 &r_point_B, const AABB &p_concave_hint, Vector3 *r_sep_axis = NULL); }; #endif // COLLISION_SOLVER__SW_H diff --git a/servers/physics/physics_server_sw.cpp b/servers/physics/physics_server_sw.cpp index 5ba935d47c..ce63d84617 100644 --- a/servers/physics/physics_server_sw.cpp +++ b/servers/physics/physics_server_sw.cpp @@ -695,6 +695,19 @@ real_t PhysicsServerSW::body_get_param(RID p_body, BodyParameter p_param) const return body->get_param(p_param); }; +void PhysicsServerSW::body_set_kinematic_safe_margin(RID p_body, real_t p_margin) { + BodySW *body = body_owner.get(p_body); + ERR_FAIL_COND(!body); + body->set_kinematic_margin(p_margin); +} + +real_t PhysicsServerSW::body_get_kinematic_safe_margin(RID p_body) const { + BodySW *body = body_owner.get(p_body); + ERR_FAIL_COND_V(!body, 0); + + return body->get_kinematic_margin(); +} + void PhysicsServerSW::body_set_state(RID p_body, BodyState p_state, const Variant &p_variant) { BodySW *body = body_owner.get(p_body); @@ -888,7 +901,7 @@ bool PhysicsServerSW::body_is_ray_pickable(RID p_body) const { return body->is_ray_pickable(); } -bool PhysicsServerSW::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, float p_margin, MotionResult *r_result) { +bool PhysicsServerSW::body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, MotionResult *r_result) { BodySW *body = body_owner.get(p_body); ERR_FAIL_COND_V(!body, false); @@ -897,7 +910,7 @@ bool PhysicsServerSW::body_test_motion(RID p_body, const Transform &p_from, cons _update_shapes(); - return body->get_space()->test_body_motion(body, p_from, p_motion, p_margin, r_result); + return body->get_space()->test_body_motion(body, p_from, p_motion, body->get_kinematic_margin(), r_result); } PhysicsDirectBodyState *PhysicsServerSW::body_get_direct_state(RID p_body) { diff --git a/servers/physics/physics_server_sw.h b/servers/physics/physics_server_sw.h index f9eb8fa454..fa754a1c8f 100644 --- a/servers/physics/physics_server_sw.h +++ b/servers/physics/physics_server_sw.h @@ -187,6 +187,9 @@ public: virtual void body_set_param(RID p_body, BodyParameter p_param, real_t p_value); virtual real_t body_get_param(RID p_body, BodyParameter p_param) const; + virtual void body_set_kinematic_safe_margin(RID p_body, real_t p_margin); + virtual real_t body_get_kinematic_safe_margin(RID p_body) const; + virtual void body_set_state(RID p_body, BodyState p_state, const Variant &p_variant); virtual Variant body_get_state(RID p_body, BodyState p_state) const; @@ -221,7 +224,7 @@ public: virtual void body_set_ray_pickable(RID p_body, bool p_enable); virtual bool body_is_ray_pickable(RID p_body) const; - virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, float p_margin = 0.001, MotionResult *r_result = NULL); + virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, MotionResult *r_result = NULL); // this function only works on physics process, errors and returns null otherwise virtual PhysicsDirectBodyState *body_get_direct_state(RID p_body); diff --git a/servers/physics/shape_sw.cpp b/servers/physics/shape_sw.cpp index 6dafaac115..b204ff7a33 100644 --- a/servers/physics/shape_sw.cpp +++ b/servers/physics/shape_sw.cpp @@ -37,7 +37,7 @@ #define _EDGE_IS_VALID_SUPPORT_THRESHOLD 0.0002 #define _FACE_IS_VALID_SUPPORT_THRESHOLD 0.9998 -void ShapeSW::configure(const Rect3 &p_aabb) { +void ShapeSW::configure(const AABB &p_aabb) { aabb = p_aabb; configured = true; for (Map<ShapeOwnerSW *, int>::Element *E = owners.front(); E; E = E->next()) { @@ -141,7 +141,7 @@ Vector3 PlaneShapeSW::get_moment_of_inertia(real_t p_mass) const { void PlaneShapeSW::_setup(const Plane &p_plane) { plane = p_plane; - configure(Rect3(Vector3(-1e4, -1e4, -1e4), Vector3(1e4 * 2, 1e4 * 2, 1e4 * 2))); + configure(AABB(Vector3(-1e4, -1e4, -1e4), Vector3(1e4 * 2, 1e4 * 2, 1e4 * 2))); } void PlaneShapeSW::set_data(const Variant &p_data) { @@ -223,7 +223,7 @@ Vector3 RayShapeSW::get_moment_of_inertia(real_t p_mass) const { void RayShapeSW::_setup(real_t p_length) { length = p_length; - configure(Rect3(Vector3(0, 0, 0), Vector3(0.1, 0.1, length))); + configure(AABB(Vector3(0, 0, 0), Vector3(0.1, 0.1, length))); } void RayShapeSW::set_data(const Variant &p_data) { @@ -299,7 +299,7 @@ Vector3 SphereShapeSW::get_moment_of_inertia(real_t p_mass) const { void SphereShapeSW::_setup(real_t p_radius) { radius = p_radius; - configure(Rect3(Vector3(-radius, -radius, -radius), Vector3(radius * 2.0, radius * 2.0, radius * 2.0))); + configure(AABB(Vector3(-radius, -radius, -radius), Vector3(radius * 2.0, radius * 2.0, radius * 2.0))); } void SphereShapeSW::set_data(const Variant &p_data) { @@ -430,7 +430,7 @@ void BoxShapeSW::get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_sup bool BoxShapeSW::intersect_segment(const Vector3 &p_begin, const Vector3 &p_end, Vector3 &r_result, Vector3 &r_normal) const { - Rect3 aabb(-half_extents, half_extents * 2.0); + AABB aabb(-half_extents, half_extents * 2.0); return aabb.intersects_segment(p_begin, p_end, &r_result, &r_normal); } @@ -504,7 +504,7 @@ void BoxShapeSW::_setup(const Vector3 &p_half_extents) { half_extents = p_half_extents.abs(); - configure(Rect3(-half_extents, half_extents * 2)); + configure(AABB(-half_extents, half_extents * 2)); } void BoxShapeSW::set_data(const Variant &p_data) { @@ -684,7 +684,7 @@ void CapsuleShapeSW::_setup(real_t p_height, real_t p_radius) { height = p_height; radius = p_radius; - configure(Rect3(Vector3(-radius, -radius, -height * 0.5 - radius), Vector3(radius * 2, radius * 2, height + radius * 2.0))); + configure(AABB(Vector3(-radius, -radius, -height * 0.5 - radius), Vector3(radius * 2, radius * 2, height + radius * 2.0))); } void CapsuleShapeSW::set_data(const Variant &p_data) { @@ -957,7 +957,7 @@ void ConvexPolygonShapeSW::_setup(const Vector<Vector3> &p_vertices) { if (err != OK) ERR_PRINT("Failed to build QuickHull"); - Rect3 _aabb; + AABB _aabb; for (int i = 0; i < mesh.vertices.size(); i++) { @@ -1102,7 +1102,7 @@ Vector3 FaceShapeSW::get_moment_of_inertia(real_t p_mass) const { FaceShapeSW::FaceShapeSW() { - configure(Rect3()); + configure(AABB()); } PoolVector<Vector3> ConcavePolygonShapeSW::get_faces() const { @@ -1300,13 +1300,13 @@ void ConcavePolygonShapeSW::_cull(int p_idx, _CullParams *p_params) const { } } -void ConcavePolygonShapeSW::cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const { +void ConcavePolygonShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const { // make matrix local to concave if (faces.size() == 0) return; - Rect3 local_aabb = p_local_aabb; + AABB local_aabb = p_local_aabb; // unlock data PoolVector<Face>::Read fr = faces.read(); @@ -1341,7 +1341,7 @@ Vector3 ConcavePolygonShapeSW::get_moment_of_inertia(real_t p_mass) const { struct _VolumeSW_BVH_Element { - Rect3 aabb; + AABB aabb; Vector3 center; int face_index; }; @@ -1372,7 +1372,7 @@ struct _VolumeSW_BVH_CompareZ { struct _VolumeSW_BVH { - Rect3 aabb; + AABB aabb; _VolumeSW_BVH *left; _VolumeSW_BVH *right; @@ -1396,7 +1396,7 @@ _VolumeSW_BVH *_volume_sw_build_bvh(_VolumeSW_BVH_Element *p_elements, int p_siz bvh->face_index = -1; } - Rect3 aabb; + AABB aabb; for (int i = 0; i < p_size; i++) { if (i == 0) @@ -1467,7 +1467,7 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) { int src_face_count = p_faces.size(); if (src_face_count == 0) { - configure(Rect3()); + configure(AABB()); return; } ERR_FAIL_COND(src_face_count % 3); @@ -1491,7 +1491,7 @@ void ConcavePolygonShapeSW::_setup(PoolVector<Vector3> p_faces) { PoolVector<Vector3>::Write vw = vertices.write(); Vector3 *verticesw = vw.ptr(); - Rect3 _aabb; + AABB _aabb; for (int i = 0; i < src_face_count; i++) { @@ -1588,7 +1588,7 @@ Vector3 HeightMapShapeSW::get_closest_point_to(const Vector3 &p_point) const { return Vector3(); } -void HeightMapShapeSW::cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const { +void HeightMapShapeSW::cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const { } Vector3 HeightMapShapeSW::get_moment_of_inertia(real_t p_mass) const { @@ -1611,7 +1611,7 @@ void HeightMapShapeSW::_setup(PoolVector<real_t> p_heights, int p_width, int p_d PoolVector<real_t>::Read r = heights.read(); - Rect3 aabb; + AABB aabb; for (int i = 0; i < depth; i++) { diff --git a/servers/physics/shape_sw.h b/servers/physics/shape_sw.h index 151b84c054..48832affc9 100644 --- a/servers/physics/shape_sw.h +++ b/servers/physics/shape_sw.h @@ -58,14 +58,14 @@ public: class ShapeSW : public RID_Data { RID self; - Rect3 aabb; + AABB aabb; bool configured; real_t custom_bias; Map<ShapeOwnerSW *, int> owners; protected: - void configure(const Rect3 &p_aabb); + void configure(const AABB &p_aabb); public: enum { @@ -79,7 +79,7 @@ public: virtual PhysicsServer::ShapeType get_type() const = 0; - _FORCE_INLINE_ Rect3 get_aabb() const { return aabb; } + _FORCE_INLINE_ AABB get_aabb() const { return aabb; } _FORCE_INLINE_ bool is_configured() const { return configured; } virtual bool is_concave() const { return false; } @@ -114,7 +114,7 @@ public: typedef void (*Callback)(void *p_userdata, ShapeSW *p_convex); virtual void get_supports(const Vector3 &p_normal, int p_max, Vector3 *r_supports, int &r_amount) const { r_amount = 0; } - virtual void cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const = 0; + virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const = 0; ConcaveShapeSW() {} }; @@ -299,7 +299,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW { struct BVH { - Rect3 aabb; + AABB aabb; int left; int right; @@ -310,7 +310,7 @@ struct ConcavePolygonShapeSW : public ConcaveShapeSW { struct _CullParams { - Rect3 aabb; + AABB aabb; Callback callback; void *userdata; const Face *faces; @@ -353,7 +353,7 @@ public: virtual bool intersect_point(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; - virtual void cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const; + virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const; @@ -389,7 +389,7 @@ public: virtual bool intersect_point(const Vector3 &p_point) const; virtual Vector3 get_closest_point_to(const Vector3 &p_point) const; - virtual void cull(const Rect3 &p_local_aabb, Callback p_callback, void *p_userdata) const; + virtual void cull(const AABB &p_local_aabb, Callback p_callback, void *p_userdata) const; virtual Vector3 get_moment_of_inertia(real_t p_mass) const; @@ -462,7 +462,7 @@ struct MotionShapeSW : public ShapeSW { virtual void set_data(const Variant &p_data) {} virtual Variant get_data() const { return Variant(); } - MotionShapeSW() { configure(Rect3()); } + MotionShapeSW() { configure(AABB()); } }; struct _ShapeTestConvexBSPSW { diff --git a/servers/physics/space_sw.cpp b/servers/physics/space_sw.cpp index 7e68d54bfa..a6426b7ee0 100644 --- a/servers/physics/space_sw.cpp +++ b/servers/physics/space_sw.cpp @@ -176,7 +176,7 @@ int PhysicsDirectSpaceStateSW::intersect_shape(const RID &p_shape, const Transfo ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, 0); - Rect3 aabb = p_xform.xform(shape->get_aabb()); + AABB aabb = p_xform.xform(shape->get_aabb()); int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); @@ -224,8 +224,8 @@ bool PhysicsDirectSpaceStateSW::cast_motion(const RID &p_shape, const Transform ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, false); - Rect3 aabb = p_xform.xform(shape->get_aabb()); - aabb = aabb.merge(Rect3(aabb.position + p_motion, aabb.size)); //motion + AABB aabb = p_xform.xform(shape->get_aabb()); + aabb = aabb.merge(AABB(aabb.position + p_motion, aabb.size)); //motion aabb = aabb.grow(p_margin); /* @@ -341,7 +341,7 @@ bool PhysicsDirectSpaceStateSW::collide_shape(RID p_shape, const Transform &p_sh ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, 0); - Rect3 aabb = p_shape_xform.xform(shape->get_aabb()); + AABB aabb = p_shape_xform.xform(shape->get_aabb()); aabb = aabb.grow(p_margin); int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); @@ -417,7 +417,7 @@ bool PhysicsDirectSpaceStateSW::rest_info(RID p_shape, const Transform &p_shape_ ShapeSW *shape = static_cast<PhysicsServerSW *>(PhysicsServer::get_singleton())->shape_owner.get(p_shape); ERR_FAIL_COND_V(!shape, 0); - Rect3 aabb = p_shape_xform.xform(shape->get_aabb()); + AABB aabb = p_shape_xform.xform(shape->get_aabb()); aabb = aabb.grow(p_margin); int amount = space->broadphase->cull_aabb(aabb, space->intersection_query_results, SpaceSW::INTERSECTION_QUERY_MAX, space->intersection_query_subindex_results); @@ -514,7 +514,7 @@ PhysicsDirectSpaceStateSW::PhysicsDirectSpaceStateSW() { //////////////////////////////////////////////////////////////////////////////////////////////////////////// -int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const Rect3 &p_aabb) { +int SpaceSW::_cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb) { int amount = broadphase->cull_aabb(p_aabb, intersection_query_results, INTERSECTION_QUERY_MAX, intersection_query_subindex_results); @@ -561,7 +561,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve r_result->collider_id = 0; r_result->collider_shape = 0; } - Rect3 body_aabb; + AABB body_aabb; for (int i = 0; i < p_body->get_shape_count(); i++) { @@ -648,7 +648,7 @@ bool SpaceSW::test_body_motion(BodySW *p_body, const Transform &p_from, const Ve { // STEP 2 ATTEMPT MOTION - Rect3 motion_aabb = body_aabb; + AABB motion_aabb = body_aabb; motion_aabb.position += p_motion; motion_aabb = motion_aabb.merge(body_aabb); @@ -956,15 +956,15 @@ void SpaceSW::call_queries() { while (state_query_list.first()) { BodySW *b = state_query_list.first()->self(); - b->call_queries(); state_query_list.remove(state_query_list.first()); + b->call_queries(); } while (monitor_query_list.first()) { AreaSW *a = monitor_query_list.first()->self(); - a->call_queries(); monitor_query_list.remove(monitor_query_list.first()); + a->call_queries(); } } diff --git a/servers/physics/space_sw.h b/servers/physics/space_sw.h index 270e4ef1bd..fd7e6d16a9 100644 --- a/servers/physics/space_sw.h +++ b/servers/physics/space_sw.h @@ -122,7 +122,7 @@ private: friend class PhysicsDirectSpaceStateSW; - int _cull_aabb_for_body(BodySW *p_body, const Rect3 &p_aabb); + int _cull_aabb_for_body(BodySW *p_body, const AABB &p_aabb); public: _FORCE_INLINE_ void set_self(const RID &p_self) { self = p_self; } diff --git a/servers/physics_2d/physics_2d_server_sw.cpp b/servers/physics_2d/physics_2d_server_sw.cpp index 5d3305c82d..475a3fe3b3 100644 --- a/servers/physics_2d/physics_2d_server_sw.cpp +++ b/servers/physics_2d/physics_2d_server_sw.cpp @@ -35,7 +35,7 @@ #include "project_settings.h" #include "script_language.h" -RID Physics2DServerSW::shape_create(ShapeType p_shape) { +RID Physics2DServerSW::_shape_create(ShapeType p_shape) { Shape2DSW *shape = NULL; switch (p_shape) { @@ -83,7 +83,42 @@ RID Physics2DServerSW::shape_create(ShapeType p_shape) { shape->set_self(id); return id; -}; +} + +RID Physics2DServerSW::line_shape_create() { + + return _shape_create(SHAPE_LINE); +} + +RID Physics2DServerSW::ray_shape_create() { + + return _shape_create(SHAPE_RAY); +} +RID Physics2DServerSW::segment_shape_create() { + + return _shape_create(SHAPE_SEGMENT); +} +RID Physics2DServerSW::circle_shape_create() { + + return _shape_create(SHAPE_CIRCLE); +} +RID Physics2DServerSW::rectangle_shape_create() { + + return _shape_create(SHAPE_RECTANGLE); +} +RID Physics2DServerSW::capsule_shape_create() { + + return _shape_create(SHAPE_CAPSULE); +} + +RID Physics2DServerSW::convex_polygon_shape_create() { + + return _shape_create(SHAPE_CONVEX_POLYGON); +} +RID Physics2DServerSW::concave_polygon_shape_create() { + + return _shape_create(SHAPE_CONCAVE_POLYGON); +} void Physics2DServerSW::shape_set_data(RID p_shape, const Variant &p_data) { @@ -519,17 +554,13 @@ void Physics2DServerSW::area_set_area_monitor_callback(RID p_area, Object *p_rec /* BODY API */ -RID Physics2DServerSW::body_create(BodyMode p_mode, bool p_init_sleeping) { +RID Physics2DServerSW::body_create() { Body2DSW *body = memnew(Body2DSW); - if (p_mode != BODY_MODE_RIGID) - body->set_mode(p_mode); - if (p_init_sleeping) - body->set_state(BODY_STATE_SLEEPING, p_init_sleeping); RID rid = body_owner.make_rid(body); body->set_self(rid); return rid; -}; +} void Physics2DServerSW::body_set_space(RID p_body, RID p_space) { diff --git a/servers/physics_2d/physics_2d_server_sw.h b/servers/physics_2d/physics_2d_server_sw.h index c40cf0e3e0..171a0b7a81 100644 --- a/servers/physics_2d/physics_2d_server_sw.h +++ b/servers/physics_2d/physics_2d_server_sw.h @@ -67,6 +67,9 @@ class Physics2DServerSW : public Physics2DServer { static Physics2DServerSW *singletonsw; //void _clear_query(Query2DSW *p_query); + + RID _shape_create(ShapeType p_shape); + public: struct CollCbkData { @@ -78,9 +81,17 @@ public: Vector2 *ptr; }; + virtual RID line_shape_create(); + virtual RID ray_shape_create(); + virtual RID segment_shape_create(); + virtual RID circle_shape_create(); + virtual RID rectangle_shape_create(); + virtual RID capsule_shape_create(); + virtual RID convex_polygon_shape_create(); + virtual RID concave_polygon_shape_create(); + static void _shape_col_cbk(const Vector2 &p_point_A, const Vector2 &p_point_B, void *p_userdata); - virtual RID shape_create(ShapeType p_shape); virtual void shape_set_data(RID p_shape, const Variant &p_data); virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias); @@ -149,7 +160,7 @@ public: /* BODY API */ // create a body of a given type - virtual RID body_create(BodyMode p_mode = BODY_MODE_RIGID, bool p_init_sleeping = false); + virtual RID body_create(); virtual void body_set_space(RID p_body, RID p_space); virtual RID body_get_space(RID p_body) const; diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp index f8f3b620d4..f92ed18de2 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp +++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp @@ -130,19 +130,23 @@ void Physics2DServerWrapMT::finish() { Thread::wait_to_finish(thread); memdelete(thread); - /* - shape_free_cached_ids(); - area_free_cached_ids(); - body_free_cached_ids(); - pin_joint_free_cached_ids(); - groove_joint_free_cached_ids(); - damped_string_free_cached_ids(); -*/ thread = NULL; } else { physics_2d_server->finish(); } + line_shape_free_cached_ids(); + ray_shape_free_cached_ids(); + segment_shape_free_cached_ids(); + circle_shape_free_cached_ids(); + rectangle_shape_free_cached_ids(); + convex_polygon_shape_free_cached_ids(); + concave_polygon_shape_free_cached_ids(); + + space_free_cached_ids(); + area_free_cached_ids(); + body_free_cached_ids(); + if (step_sem) memdelete(step_sem); } @@ -158,12 +162,7 @@ Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool step_thread_up = false; alloc_mutex = Mutex::create(); - shape_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); - area_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); - body_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); - pin_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); - groove_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); - damped_spring_joint_pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); + pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc"); if (!p_create_thread) { server_thread = Thread::get_caller_id(); diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.h b/servers/physics_2d/physics_2d_server_wrap_mt.h index 50e9ab1005..cbc316cb7a 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.h +++ b/servers/physics_2d/physics_2d_server_wrap_mt.h @@ -64,21 +64,10 @@ class Physics2DServerWrapMT : public Physics2DServer { void thread_exit(); - Mutex *alloc_mutex; bool first_frame; - int shape_pool_max_size; - List<RID> shape_id_pool; - int area_pool_max_size; - List<RID> area_id_pool; - int body_pool_max_size; - List<RID> body_id_pool; - int pin_joint_pool_max_size; - List<RID> pin_joint_id_pool; - int groove_joint_pool_max_size; - List<RID> groove_joint_id_pool; - int damped_spring_joint_pool_max_size; - List<RID> damped_spring_joint_id_pool; + Mutex *alloc_mutex; + int pool_max_size; public: #define ServerName Physics2DServer @@ -87,7 +76,15 @@ public: #include "servers/server_wrap_mt_common.h" //FUNC1RID(shape,ShapeType); todo fix - FUNC1R(RID, shape_create, ShapeType); + FUNCRID(line_shape) + FUNCRID(ray_shape) + FUNCRID(segment_shape) + FUNCRID(circle_shape) + FUNCRID(rectangle_shape) + FUNCRID(capsule_shape) + FUNCRID(convex_polygon_shape) + FUNCRID(concave_polygon_shape) + FUNC2(shape_set_data, RID, const Variant &); FUNC2(shape_set_custom_solver_bias, RID, real_t); @@ -104,7 +101,7 @@ public: /* SPACE API */ - FUNC0R(RID, space_create); + FUNCRID(space); FUNC2(space_set_active, RID, bool); FUNC1RC(bool, space_is_active, RID); @@ -134,7 +131,7 @@ public: /* AREA API */ //FUNC0RID(area); - FUNC0R(RID, area_create); + FUNCRID(area); FUNC2(area_set_space, RID, RID); FUNC1RC(RID, area_get_space, RID); @@ -174,7 +171,7 @@ public: /* BODY API */ //FUNC2RID(body,BodyMode,bool); - FUNC2R(RID, body_create, BodyMode, bool) + FUNCRID(body) FUNC2(body_set_space, RID, RID); FUNC1RC(RID, body_get_space, RID); @@ -269,6 +266,8 @@ public: ///FUNC5RID(groove_joint,const Vector2&,const Vector2&,const Vector2&,RID,RID); ///FUNC4RID(damped_spring_joint,const Vector2&,const Vector2&,RID,RID); + //TODO need to convert this to FUNCRID, but it's a hassle.. + FUNC3R(RID, pin_joint_create, const Vector2 &, RID, RID); FUNC5R(RID, groove_joint_create, const Vector2 &, const Vector2 &, const Vector2 &, RID, RID); FUNC4R(RID, damped_spring_joint_create, const Vector2 &, const Vector2 &, RID, RID); diff --git a/servers/physics_2d/space_2d_sw.cpp b/servers/physics_2d/space_2d_sw.cpp index 6eaaaa777b..3b8eb19dd1 100644 --- a/servers/physics_2d/space_2d_sw.cpp +++ b/servers/physics_2d/space_2d_sw.cpp @@ -626,13 +626,13 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co int amount = _cull_aabb_for_body(p_body, motion_aabb); - for (int j = 0; j < p_body->get_shape_count(); j++) { + for (int body_shape_idx = 0; body_shape_idx < p_body->get_shape_count(); body_shape_idx++) { - if (p_body->is_shape_set_as_disabled(j)) + if (p_body->is_shape_set_as_disabled(body_shape_idx)) continue; - Transform2D body_shape_xform = body_transform * p_body->get_shape_transform(j); - Shape2DSW *body_shape = p_body->get_shape(j); + Transform2D body_shape_xform = body_transform * p_body->get_shape_transform(body_shape_idx); + Shape2DSW *body_shape = p_body->get_shape(body_shape_idx); bool stuck = false; @@ -642,14 +642,14 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co for (int i = 0; i < amount; i++) { const CollisionObject2DSW *col_obj = intersection_query_results[i]; - int shape_idx = intersection_query_subindex_results[i]; - Shape2DSW *against_shape = col_obj->get_shape(shape_idx); + int col_shape_idx = intersection_query_subindex_results[i]; + Shape2DSW *against_shape = col_obj->get_shape(col_shape_idx); bool excluded = false; for (int k = 0; k < excluded_shape_pair_count; k++) { - if (excluded_shape_pairs[k].local_shape == body_shape && excluded_shape_pairs[k].against_object == col_obj && excluded_shape_pairs[k].against_shape_index == shape_idx) { + if (excluded_shape_pairs[k].local_shape == body_shape && excluded_shape_pairs[k].against_object == col_obj && excluded_shape_pairs[k].against_shape_index == col_shape_idx) { excluded = true; break; } @@ -660,7 +660,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co continue; } - Transform2D col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(shape_idx); + Transform2D col_obj_xform = col_obj->get_transform() * col_obj->get_shape_transform(col_shape_idx); //test initial overlap, does it collide if going all the way? if (!CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion, against_shape, col_obj_xform, Vector2(), NULL, NULL, NULL, 0)) { continue; @@ -669,7 +669,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co //test initial overlap if (CollisionSolver2DSW::solve(body_shape, body_shape_xform, Vector2(), against_shape, col_obj_xform, Vector2(), NULL, NULL, NULL, 0)) { - if (col_obj->is_shape_set_as_one_way_collision(j)) { + if (col_obj->is_shape_set_as_one_way_collision(col_shape_idx)) { continue; } @@ -698,7 +698,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co } } - if (col_obj->is_shape_set_as_one_way_collision(j)) { + if (col_obj->is_shape_set_as_one_way_collision(col_shape_idx)) { Vector2 cd[2]; Physics2DServerSW::CollCbkData cbk; @@ -710,7 +710,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co cbk.valid_depth = 10e20; Vector2 sep = mnormal; //important optimization for this to work fast enough - bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * (hi + contact_max_allowed_penetration), col_obj->get_shape(shape_idx), col_obj_xform, Vector2(), Physics2DServerSW::_shape_col_cbk, &cbk, &sep, 0); + bool collided = CollisionSolver2DSW::solve(body_shape, body_shape_xform, p_motion * (hi + contact_max_allowed_penetration), col_obj->get_shape(col_shape_idx), col_obj_xform, Vector2(), Physics2DServerSW::_shape_col_cbk, &cbk, &sep, 0); if (!collided || cbk.amount == 0) { continue; } @@ -726,7 +726,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co safe = 0; unsafe = 0; - best_shape = j; //sadly it's the best + best_shape = body_shape_idx; //sadly it's the best break; } if (best_safe == 1.0) { @@ -736,7 +736,7 @@ bool Space2DSW::test_body_motion(Body2DSW *p_body, const Transform2D &p_from, co safe = best_safe; unsafe = best_unsafe; - best_shape = j; + best_shape = body_shape_idx; } } } @@ -969,15 +969,15 @@ void Space2DSW::call_queries() { while (state_query_list.first()) { Body2DSW *b = state_query_list.first()->self(); - b->call_queries(); state_query_list.remove(state_query_list.first()); + b->call_queries(); } while (monitor_query_list.first()) { Area2DSW *a = monitor_query_list.first()->self(); - a->call_queries(); monitor_query_list.remove(monitor_query_list.first()); + a->call_queries(); } } diff --git a/servers/physics_2d_server.cpp b/servers/physics_2d_server.cpp index 130c0583dc..650d3d0f62 100644 --- a/servers/physics_2d_server.cpp +++ b/servers/physics_2d_server.cpp @@ -475,7 +475,15 @@ bool Physics2DServer::_body_test_motion(RID p_body, const Transform2D &p_from, c void Physics2DServer::_bind_methods() { - ClassDB::bind_method(D_METHOD("shape_create", "type"), &Physics2DServer::shape_create); + ClassDB::bind_method(D_METHOD("line_shape_create"), &Physics2DServer::line_shape_create); + ClassDB::bind_method(D_METHOD("ray_shape_create"), &Physics2DServer::ray_shape_create); + ClassDB::bind_method(D_METHOD("segment_shape_create"), &Physics2DServer::segment_shape_create); + ClassDB::bind_method(D_METHOD("circle_shape_create"), &Physics2DServer::circle_shape_create); + ClassDB::bind_method(D_METHOD("rectangle_shape_create"), &Physics2DServer::rectangle_shape_create); + ClassDB::bind_method(D_METHOD("capsule_shape_create"), &Physics2DServer::capsule_shape_create); + ClassDB::bind_method(D_METHOD("convex_polygon_shape_create"), &Physics2DServer::convex_polygon_shape_create); + ClassDB::bind_method(D_METHOD("concave_polygon_shape_create"), &Physics2DServer::concave_polygon_shape_create); + ClassDB::bind_method(D_METHOD("shape_set_data", "shape", "data"), &Physics2DServer::shape_set_data); ClassDB::bind_method(D_METHOD("shape_get_type", "shape"), &Physics2DServer::shape_get_type); @@ -521,7 +529,7 @@ void Physics2DServer::_bind_methods() { ClassDB::bind_method(D_METHOD("area_set_monitor_callback", "area", "receiver", "method"), &Physics2DServer::area_set_monitor_callback); - ClassDB::bind_method(D_METHOD("body_create", "mode", "init_sleeping"), &Physics2DServer::body_create, DEFVAL(BODY_MODE_RIGID), DEFVAL(false)); + ClassDB::bind_method(D_METHOD("body_create"), &Physics2DServer::body_create); ClassDB::bind_method(D_METHOD("body_set_space", "body", "space"), &Physics2DServer::body_set_space); ClassDB::bind_method(D_METHOD("body_get_space", "body"), &Physics2DServer::body_get_space); diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h index ddd1555768..241255bdb5 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_2d_server.h @@ -252,7 +252,15 @@ public: SHAPE_CUSTOM, ///< Server-Implementation based custom shape, calling shape_create() with this value will result in an error }; - virtual RID shape_create(ShapeType p_shape) = 0; + virtual RID line_shape_create() = 0; + virtual RID ray_shape_create() = 0; + virtual RID segment_shape_create() = 0; + virtual RID circle_shape_create() = 0; + virtual RID rectangle_shape_create() = 0; + virtual RID capsule_shape_create() = 0; + virtual RID convex_polygon_shape_create() = 0; + virtual RID concave_polygon_shape_create() = 0; + virtual void shape_set_data(RID p_shape, const Variant &p_data) = 0; virtual void shape_set_custom_solver_bias(RID p_shape, real_t p_bias) = 0; @@ -366,7 +374,7 @@ public: //BODY_MODE_SOFT ?? }; - virtual RID body_create(BodyMode p_mode = BODY_MODE_RIGID, bool p_init_sleeping = false) = 0; + virtual RID body_create() = 0; virtual void body_set_space(RID p_body, RID p_space) = 0; virtual RID body_get_space(RID p_body) const = 0; diff --git a/servers/physics_server.cpp b/servers/physics_server.cpp index a3efe76e13..88cd728a94 100644 --- a/servers/physics_server.cpp +++ b/servers/physics_server.cpp @@ -481,6 +481,9 @@ void PhysicsServer::_bind_methods() { ClassDB::bind_method(D_METHOD("body_set_param", "body", "param", "value"), &PhysicsServer::body_set_param); ClassDB::bind_method(D_METHOD("body_get_param", "body", "param"), &PhysicsServer::body_get_param); + ClassDB::bind_method(D_METHOD("body_set_kinematic_safe_margin", "body", "margin"), &PhysicsServer::body_set_kinematic_safe_margin); + ClassDB::bind_method(D_METHOD("body_get_kinematic_safe_margin", "body"), &PhysicsServer::body_get_kinematic_safe_margin); + ClassDB::bind_method(D_METHOD("body_set_state", "body", "state", "value"), &PhysicsServer::body_set_state); ClassDB::bind_method(D_METHOD("body_get_state", "body", "state"), &PhysicsServer::body_get_state); @@ -675,6 +678,7 @@ void PhysicsServer::_bind_methods() { BIND_ENUM_CONSTANT(BODY_MODE_STATIC); BIND_ENUM_CONSTANT(BODY_MODE_KINEMATIC); BIND_ENUM_CONSTANT(BODY_MODE_RIGID); + BIND_ENUM_CONSTANT(BODY_MODE_SOFT); BIND_ENUM_CONSTANT(BODY_MODE_CHARACTER); BIND_ENUM_CONSTANT(BODY_PARAM_BOUNCE); diff --git a/servers/physics_server.h b/servers/physics_server.h index 7cccd9b4cb..64c67eae2a 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -411,6 +411,9 @@ public: virtual void body_set_param(RID p_body, BodyParameter p_param, float p_value) = 0; virtual float body_get_param(RID p_body, BodyParameter p_param) const = 0; + virtual void body_set_kinematic_safe_margin(RID p_body, real_t p_margin) = 0; + virtual real_t body_get_kinematic_safe_margin(RID p_body) const = 0; + //state enum BodyState { BODY_STATE_TRANSFORM, @@ -482,7 +485,7 @@ public: Variant collider_metadata; }; - virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, float p_margin = 0.001, MotionResult *r_result = NULL) = 0; + virtual bool body_test_motion(RID p_body, const Transform &p_from, const Vector3 &p_motion, MotionResult *r_result = NULL) = 0; /* JOINT API */ diff --git a/servers/register_server_types.cpp b/servers/register_server_types.cpp index 1ba9e7b174..99493afc40 100644 --- a/servers/register_server_types.cpp +++ b/servers/register_server_types.cpp @@ -28,6 +28,7 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "register_server_types.h" +#include "engine.h" #include "project_settings.h" #include "arvr/arvr_interface.h" @@ -171,9 +172,9 @@ void unregister_server_types() { } void register_server_singletons() { - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("VisualServer", VisualServer::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("AudioServer", AudioServer::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("PhysicsServer", PhysicsServer::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("Physics2DServer", Physics2DServer::get_singleton())); - ProjectSettings::get_singleton()->add_singleton(ProjectSettings::Singleton("ARVRServer", ARVRServer::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("VisualServer", VisualServer::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("AudioServer", AudioServer::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("PhysicsServer", PhysicsServer::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("Physics2DServer", Physics2DServer::get_singleton())); + Engine::get_singleton()->add_singleton(Engine::Singleton("ARVRServer", ARVRServer::get_singleton())); } diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index cd4b465d79..21d059c48e 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -234,7 +234,7 @@ public: virtual RID mesh_create() = 0; - virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()) = 0; + virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, VS::PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) = 0; virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount) = 0; virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0; @@ -242,6 +242,8 @@ public: virtual void mesh_set_blend_shape_mode(RID p_mesh, VS::BlendShapeMode p_mode) = 0; virtual VS::BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0; + virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) = 0; + virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0; virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const = 0; @@ -254,17 +256,17 @@ public: virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const = 0; virtual VS::PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const = 0; - virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0; + virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0; virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const = 0; - virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0; + virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0; virtual void mesh_remove_surface(RID p_mesh, int p_index) = 0; virtual int mesh_get_surface_count(RID p_mesh) const = 0; - virtual void mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb) = 0; - virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const = 0; + virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) = 0; + virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0; - virtual Rect3 mesh_get_aabb(RID p_mesh, RID p_skeleton) const = 0; + virtual AABB mesh_get_aabb(RID p_mesh, RID p_skeleton) const = 0; virtual void mesh_clear(RID p_mesh) = 0; /* MULTIMESH API */ @@ -288,7 +290,7 @@ public: virtual void multimesh_set_visible_instances(RID p_multimesh, int p_visible) = 0; virtual int multimesh_get_visible_instances(RID p_multimesh) const = 0; - virtual Rect3 multimesh_get_aabb(RID p_multimesh) const = 0; + virtual AABB multimesh_get_aabb(RID p_multimesh) const = 0; /* IMMEDIATE API */ @@ -304,7 +306,7 @@ public: virtual void immediate_clear(RID p_immediate) = 0; virtual void immediate_set_material(RID p_immediate, RID p_material) = 0; virtual RID immediate_get_material(RID p_immediate) const = 0; - virtual Rect3 immediate_get_aabb(RID p_immediate) const = 0; + virtual AABB immediate_get_aabb(RID p_immediate) const = 0; /* SKELETON API */ @@ -320,6 +322,10 @@ public: virtual RID light_create(VS::LightType p_type) = 0; + RID directional_light_create() { return light_create(VS::LIGHT_DIRECTIONAL); } + RID omni_light_create() { return light_create(VS::LIGHT_OMNI); } + RID spot_light_create() { return light_create(VS::LIGHT_SPOT); } + virtual void light_set_color(RID p_light, const Color &p_color) = 0; virtual void light_set_param(RID p_light, VS::LightParam p_param, float p_value) = 0; virtual void light_set_shadow(RID p_light, bool p_enabled) = 0; @@ -344,7 +350,7 @@ public: virtual bool light_has_shadow(RID p_light) const = 0; virtual VS::LightType light_get_type(RID p_light) const = 0; - virtual Rect3 light_get_aabb(RID p_light) const = 0; + virtual AABB light_get_aabb(RID p_light) const = 0; virtual float light_get_param(RID p_light, VS::LightParam p_param) = 0; virtual Color light_get_color(RID p_light) = 0; virtual uint64_t light_get_version(RID p_light) const = 0; @@ -366,7 +372,7 @@ public: virtual void reflection_probe_set_enable_shadows(RID p_probe, bool p_enable) = 0; virtual void reflection_probe_set_cull_mask(RID p_probe, uint32_t p_layers) = 0; - virtual Rect3 reflection_probe_get_aabb(RID p_probe) const = 0; + virtual AABB reflection_probe_get_aabb(RID p_probe) const = 0; virtual VS::ReflectionProbeUpdateMode reflection_probe_get_update_mode(RID p_probe) const = 0; virtual uint32_t reflection_probe_get_cull_mask(RID p_probe) const = 0; virtual Vector3 reflection_probe_get_extents(RID p_probe) const = 0; @@ -384,8 +390,8 @@ public: virtual RID gi_probe_create() = 0; - virtual void gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds) = 0; - virtual Rect3 gi_probe_get_bounds(RID p_probe) const = 0; + virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) = 0; + virtual AABB gi_probe_get_bounds(RID p_probe) const = 0; virtual void gi_probe_set_cell_size(RID p_probe, float p_range) = 0; virtual float gi_probe_get_cell_size(RID p_probe) const = 0; @@ -440,7 +446,7 @@ public: virtual void particles_set_pre_process_time(RID p_particles, float p_time) = 0; virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) = 0; virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio) = 0; - virtual void particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb) = 0; + virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) = 0; virtual void particles_set_speed_scale(RID p_particles, float p_scale) = 0; virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable) = 0; virtual void particles_set_process_material(RID p_particles, RID p_material) = 0; @@ -454,8 +460,8 @@ public: virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) = 0; virtual void particles_request_process(RID p_particles) = 0; - virtual Rect3 particles_get_current_aabb(RID p_particles) = 0; - virtual Rect3 particles_get_aabb(RID p_particles) const = 0; + virtual AABB particles_get_current_aabb(RID p_particles) = 0; + virtual AABB particles_get_aabb(RID p_particles) const = 0; virtual void particles_set_emission_transform(RID p_particles, const Transform &p_transform) = 0; @@ -876,7 +882,7 @@ public: case Item::Command::TYPE_MESH: { const Item::CommandMesh *mesh = static_cast<const Item::CommandMesh *>(c); - Rect3 aabb = RasterizerStorage::base_singleton->mesh_get_aabb(mesh->mesh, mesh->skeleton); + AABB aabb = RasterizerStorage::base_singleton->mesh_get_aabb(mesh->mesh, mesh->skeleton); r = Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y); @@ -884,7 +890,7 @@ public: case Item::Command::TYPE_MULTIMESH: { const Item::CommandMultiMesh *multimesh = static_cast<const Item::CommandMultiMesh *>(c); - Rect3 aabb = RasterizerStorage::base_singleton->multimesh_get_aabb(multimesh->multimesh); + AABB aabb = RasterizerStorage::base_singleton->multimesh_get_aabb(multimesh->multimesh); r = Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y); @@ -893,7 +899,7 @@ public: const Item::CommandParticles *particles_cmd = static_cast<const Item::CommandParticles *>(c); if (particles_cmd->particles.is_valid()) { - Rect3 aabb = RasterizerStorage::base_singleton->particles_get_aabb(particles_cmd->particles); + AABB aabb = RasterizerStorage::base_singleton->particles_get_aabb(particles_cmd->particles); r = Rect2(aabb.position.x, aabb.position.y, aabb.size.x, aabb.size.y); } diff --git a/servers/visual/visual_server_canvas.h b/servers/visual/visual_server_canvas.h index 09ac9959f9..a92370f1f0 100644 --- a/servers/visual/visual_server_canvas.h +++ b/servers/visual/visual_server_canvas.h @@ -175,7 +175,7 @@ public: void canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color); void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color); void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID()); - void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = true); + void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = false); void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID()); void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID()); void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false); diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 69e2d1c162..9432d3fdd9 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -120,6 +120,8 @@ void VisualServerRaster::draw() { frame_drawn_callbacks.pop_front(); } + + emit_signal("frame_drawn_in_thread"); } void VisualServerRaster::sync() { } diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 425381550e..08a0cfa269 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -73,527 +73,12 @@ class VisualServerRaster : public VisualServer { List<FrameDrawnCallbacks> frame_drawn_callbacks; -// FIXME: Kept as reference for future implementation -#if 0 - struct Room { - - bool occlude_exterior; - BSP_Tree bounds; - Room() { occlude_exterior=true; } - }; - - - BalloonAllocator<> octree_allocator; - - struct OctreeAllocator { - - static BalloonAllocator<> *allocator; - - _FORCE_INLINE_ static void *alloc(size_t p_size) { return allocator->alloc(p_size); } - _FORCE_INLINE_ static void free(void *p_ptr) { return allocator->free(p_ptr); } - - }; - - struct Portal { - - bool enabled; - float disable_distance; - Color disable_color; - float connect_range; - Vector<Point2> shape; - Rect2 bounds; - - - Portal() { enabled=true; disable_distance=50; disable_color=Color(); connect_range=0.8; } - }; - - struct BakedLight { - - Rasterizer::BakedLightData data; - PoolVector<int> sampler; - Rect3 octree_aabb; - Size2i octree_tex_size; - Size2i light_tex_size; - - }; - - struct BakedLightSampler { - - float params[BAKED_LIGHT_SAMPLER_MAX]; - int resolution; - Vector<Vector3> dp_cache; - - BakedLightSampler() { - params[BAKED_LIGHT_SAMPLER_STRENGTH]=1.0; - params[BAKED_LIGHT_SAMPLER_ATTENUATION]=1.0; - params[BAKED_LIGHT_SAMPLER_RADIUS]=1.0; - params[BAKED_LIGHT_SAMPLER_DETAIL_RATIO]=0.1; - resolution=16; - } - }; - - void _update_baked_light_sampler_dp_cache(BakedLightSampler * blsamp); - struct Camera { - - enum Type { - PERSPECTIVE, - ORTHOGONAL - }; - Type type; - float fov; - float znear,zfar; - float size; - uint32_t visible_layers; - bool vaspect; - RID env; - - Transform transform; - - Camera() { - - visible_layers=0xFFFFFFFF; - fov=60; - type=PERSPECTIVE; - znear=0.1; zfar=100; - size=1.0; - vaspect=false; - - } - }; - - - struct Instance; - typedef Set<Instance*,Comparator<Instance*>,OctreeAllocator> InstanceSet; - struct Scenario; - - struct Instance { - - enum { - - MAX_LIGHTS=4 - }; - - RID self; - OctreeElementID octree_id; - Scenario *scenario; - bool update; - bool update_aabb; - bool update_materials; - Instance *update_next; - InstanceType base_type; - - RID base_rid; - - Rect3 aabb; - Rect3 transformed_aabb; - uint32_t object_ID; - bool visible; - bool visible_in_all_rooms; - uint32_t layer_mask; - float draw_range_begin; - float draw_range_end; - float extra_margin; - - - - Rasterizer::InstanceData data; - - - Set<Instance*> auto_rooms; - Set<Instance*> valid_auto_rooms; - Instance *room; - List<Instance*>::Element *RE; - Instance *baked_light; - List<Instance*>::Element *BLE; - Instance *sampled_light; - bool exterior; - - uint64_t last_render_pass; - uint64_t last_frame_pass; - - uint64_t version; // changes to this, and changes to base increase version - - InstanceSet lights; - bool light_cache_dirty; - - - - struct RoomInfo { - - Transform affine_inverse; - Room *room; - List<Instance*> owned_geometry_instances; - List<Instance*> owned_portal_instances; - List<Instance*> owned_room_instances; - List<Instance*> owned_light_instances; //not used, but just for the sake of it - Set<Instance*> disconnected_child_portals; - Set<Instance*> owned_autoroom_geometry; - uint64_t last_visited_pass; - RoomInfo() { last_visited_pass=0; } - - }; - - struct PortalInfo { - - Portal *portal; - Set<Instance*> candidate_set; - Instance *connected; - uint64_t last_visited_pass; - - Plane plane_cache; - Vector<Vector3> transformed_point_cache; - - - PortalInfo() { connected=NULL; last_visited_pass=0;} - }; - - struct LightInfo { - - RID instance; - int light_set_index; - uint64_t last_version; - uint64_t last_add_pass; - List<RID>::Element *D; // directional light in scenario - InstanceSet affected; - bool enabled; - float dtc; //distance to camera, used for sorting - - - LightInfo() { - - D=NULL; - light_set_index=-1; - last_add_pass=0; - enabled=true; - } - }; - - struct BakedLightInfo { - - BakedLight *baked_light; - Transform affine_inverse; - List<Instance*> owned_instances; - }; - - struct BakedLightSamplerInfo { - - Set<Instance*> baked_lights; - Set<Instance*> owned_instances; - BakedLightSampler *sampler; - int resolution; - Vector<Color> light_buffer; - RID sampled_light; - uint64_t last_pass; - Transform xform; // viewspace normal to lightspace, might not use one. - BakedLightSamplerInfo() { - sampler=NULL; - last_pass=0; - resolution=0; - } - }; - - struct ParticlesInfo { - - RID instance; - }; - - - RoomInfo *room_info; - LightInfo *light_info; - ParticlesInfo *particles_info; - PortalInfo * portal_info; - BakedLightInfo * baked_light_info; - BakedLightSamplerInfo * baked_light_sampler_info; - - - Instance() { - octree_id=0; - update_next=0; - object_ID=0; - last_render_pass=0; - last_frame_pass=0; - light_info=0; - particles_info=0; - update_next=NULL; - update=false; - visible=true; - data.cast_shadows=SHADOW_CASTING_SETTING_ON; - data.receive_shadows=true; - data.depth_scale=false; - data.billboard=false; - data.billboard_y=false; - data.baked_light=NULL; - data.baked_light_octree_xform=NULL; - data.baked_lightmap_id=-1; - version=1; - room_info=NULL; - room=NULL; - RE=NULL; - portal_info=NULL; - exterior=false; - layer_mask=1; - draw_range_begin=0; - draw_range_end=0; - extra_margin=0; - visible_in_all_rooms=false; - update_aabb=false; - update_materials=false; - - baked_light=NULL; - baked_light_info=NULL; - baked_light_sampler_info=NULL; - sampled_light=NULL; - BLE=NULL; - - light_cache_dirty=true; - - } - - ~Instance() { - - if (light_info) - memdelete(light_info); - if (particles_info) - memdelete(particles_info); - if (room_info) - memdelete(room_info); - if (portal_info) - memdelete(portal_info); - if (baked_light_info) - memdelete(baked_light_info); - }; - }; - - struct _InstanceLightsort { - - bool operator()(const Instance* p_A, const Instance* p_B) const { return p_A->light_info->dtc < p_B->light_info->dtc; } - }; - - struct Scenario { - - - ScenarioDebugMode debug; - RID self; - // well wtf, balloon allocator is slower? - typedef ::Octree<Instance,true> Octree; - - Octree octree; - - List<RID> directional_lights; - RID environment; - RID fallback_environment; - - Instance *dirty_instances; - - Scenario() { dirty_instances=NULL; debug=SCENARIO_DEBUG_DISABLED; } - }; - - - - mutable RID_Owner<Rasterizer::ShaderMaterial> canvas_item_material_owner; - - - - struct Viewport { - - RID self; - RID parent; - - VisualServer::ViewportRect rect; - RID camera; - RID scenario; - RID viewport_data; - - RenderTargetUpdateMode render_target_update_mode; - RID render_target; - RID render_target_texture; - - Rect2 rt_to_screen_rect; - - bool hide_scenario; - bool hide_canvas; - bool transparent_bg; - bool queue_capture; - bool render_target_vflip; - bool render_target_clear_on_new_frame; - bool render_target_clear; - bool disable_environment; - - Image capture; - - bool rendered_in_prev_frame; - - struct CanvasKey { - - int layer; - RID canvas; - bool operator<(const CanvasKey& p_canvas) const { if (layer==p_canvas.layer) return canvas < p_canvas.canvas; return layer<p_canvas.layer; } - CanvasKey() { layer=0; } - CanvasKey(const RID& p_canvas, int p_layer) { canvas=p_canvas; layer=p_layer; } - }; - - struct CanvasData { - - Canvas *canvas; - Transform2D transform; - int layer; - }; - - Transform2D global_transform; - - Map<RID,CanvasData> canvas_map; - - SelfList<Viewport> update_list; - - Viewport() : update_list(this) { transparent_bg=false; render_target_update_mode=RENDER_TARGET_UPDATE_WHEN_VISIBLE; queue_capture=false; rendered_in_prev_frame=false; render_target_vflip=false; render_target_clear_on_new_frame=true; render_target_clear=true; disable_environment=false; } - }; - - SelfList<Viewport>::List viewport_update_list; - - Map<RID,int> screen_viewports; - - struct CullRange { - - Plane nearp; - float min,max; - float z_near,z_far; - - void add_aabb(const Rect3& p_aabb) { - - - } - }; - - struct Cursor { - - Point2 pos; - float rot; - RID texture; - Point2 center; - bool visible; - Rect2 region; - Cursor() { - - rot = 0; - visible = false; - region = Rect2(); - }; - }; - - Rect2 canvas_clip; - Color clear_color; - Cursor cursors[MAX_CURSORS]; - RID default_cursor_texture; - - static void* instance_pair(void *p_self, OctreeElementID,Instance *p_A,int, OctreeElementID,Instance *p_B,int); - static void instance_unpair(void *p_self, OctreeElementID,Instance *p_A,int, OctreeElementID,Instance *p_B,int,void*); - - Instance *instance_cull_result[MAX_INSTANCE_CULL]; - Instance *instance_shadow_cull_result[MAX_INSTANCE_CULL]; //used for generating shadowmaps - Instance *light_cull_result[MAX_LIGHTS_CULLED]; - int light_cull_count; - - Instance *exterior_portal_cull_result[MAX_EXTERIOR_PORTALS]; - int exterior_portal_cull_count; - bool exterior_visited; - - Instance *light_sampler_cull_result[MAX_LIGHT_SAMPLERS]; - int light_samplers_culled; - - Instance *room_cull_result[MAX_ROOM_CULL]; - int room_cull_count; - bool room_cull_enabled; - bool light_discard_enabled; - bool shadows_enabled; - int black_margin[4]; - RID black_image[4]; - - Vector<Vector3> aabb_random_points; - Vector<Vector3> transformed_aabb_random_points; - - void _instance_validate_autorooms(Instance *p_geometry); - - void _portal_disconnect(Instance *p_portal,bool p_cleanup=false); - void _portal_attempt_connect(Instance *p_portal); - void _dependency_queue_update(RID p_rid, bool p_update_aabb=false, bool p_update_materials=false); - _FORCE_INLINE_ void _instance_queue_update(Instance *p_instance,bool p_update_aabb=false,bool p_update_materials=false); - void _update_instances(); - void _update_instance_aabb(Instance *p_instance); - void _update_instance(Instance *p_instance); - void _free_attached_instances(RID p_rid,bool p_free_scenario=false); - void _clean_up_owner(RID_OwnerBase *p_owner,String p_type); - - Instance *instance_update_list; - - //RID default_scenario; - //RID default_viewport; - - RID test_cube; - - - mutable RID_Owner<Room> room_owner; - mutable RID_Owner<Portal> portal_owner; - - mutable RID_Owner<BakedLight> baked_light_owner; - mutable RID_Owner<BakedLightSampler> baked_light_sampler_owner; - - mutable RID_Owner<Camera> camera_owner; - mutable RID_Owner<Viewport> viewport_owner; - - mutable RID_Owner<Scenario> scenario_owner; - mutable RID_Owner<Instance> instance_owner; - - mutable RID_Owner<Canvas> canvas_owner; - mutable RID_Owner<CanvasItem> canvas_item_owner; - - Map< RID, Set<RID> > instance_dependency_map; - Map< RID, Set<Instance*> > skeleton_dependency_map; - - - ViewportRect viewport_rect; - _FORCE_INLINE_ void _instance_draw(Instance *p_instance); - - bool _test_portal_cull(Camera *p_camera, Instance *p_portal_from, Instance *p_portal_to); - void _cull_portal(Camera *p_camera, Instance *p_portal,Instance *p_from_portal); - void _cull_room(Camera *p_camera, Instance *p_room,Instance *p_from_portal=NULL); - void _process_sampled_light(const Transform &p_camera, Instance *p_sampled_light, bool p_linear_colorspace); - - void _render_no_camera(Viewport *p_viewport,Camera *p_camera, Scenario *p_scenario); - void _render_camera(Viewport *p_viewport,Camera *p_camera, Scenario *p_scenario); - static void _render_canvas_item_viewport(VisualServer* p_self,void *p_vp,const Rect2& p_rect); - void _render_canvas_item_tree(CanvasItem *p_canvas_item, const Transform2D& p_transform, const Rect2& p_clip_rect, const Color &p_modulate, Rasterizer::CanvasLight *p_lights); - void _render_canvas_item(CanvasItem *p_canvas_item, const Transform2D& p_transform, const Rect2& p_clip_rect, float p_opacity, int p_z, Rasterizer::CanvasItem **z_list, Rasterizer::CanvasItem **z_last_list, CanvasItem *p_canvas_clip, CanvasItem *p_material_owner); - void _render_canvas(Canvas *p_canvas, const Transform2D &p_transform, Rasterizer::CanvasLight *p_lights, Rasterizer::CanvasLight *p_masked_lights); - void _light_mask_canvas_items(int p_z,Rasterizer::CanvasItem *p_canvas_item,Rasterizer::CanvasLight *p_masked_lights); - - Vector<Vector3> _camera_generate_endpoints(Instance *p_light,Camera *p_camera,float p_range_min, float p_range_max); - Vector<Plane> _camera_generate_orthogonal_planes(Instance *p_light,Camera *p_camera,float p_range_min, float p_range_max); - - void _light_instance_update_lispsm_shadow(Instance *p_light,Scenario *p_scenario,Camera *p_camera,const CullRange& p_cull_range); - void _light_instance_update_pssm_shadow(Instance *p_light,Scenario *p_scenario,Camera *p_camera,const CullRange& p_cull_range); - - void _light_instance_update_shadow(Instance *p_light,Scenario *p_scenario,Camera *p_camera,const CullRange& p_cull_range); - - uint64_t render_pass; - int changes; - bool draw_extra_frame; - - void _draw_viewport_camera(Viewport *p_viewport, bool p_ignore_camera); - void _draw_viewport(Viewport *p_viewport,int p_ofs_x, int p_ofs_y,int p_parent_w,int p_parent_h); - void _draw_viewports(); - void _draw_cursors_and_margins(); - - - Rasterizer *rasterizer; - -#endif - void _draw_margins(); static void _changes_changed() {} public: -//if editor is redrawing when it shouldn't, enable this and put a breakpoint in _changes_changed() -//#define DEBUG_CHANGES + //if editor is redrawing when it shouldn't, enable this and put a breakpoint in _changes_changed() + //#define DEBUG_CHANGES #ifdef DEBUG_CHANGES _FORCE_INLINE_ static void redraw_request() { @@ -611,7 +96,7 @@ public: #define DISPLAY_CHANGED \ changes++; #endif -// print_line(String("CHANGED: ") + __FUNCTION__); + // print_line(String("CHANGED: ") + __FUNCTION__); #define BIND0R(m_r, m_name) \ m_r m_name() { return BINDBASE->m_name(); } @@ -718,7 +203,7 @@ public: BIND0R(RID, mesh_create) - BIND10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const Rect3 &, const Vector<PoolVector<uint8_t> > &, const Vector<Rect3> &) + BIND10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const AABB &, const Vector<PoolVector<uint8_t> > &, const Vector<AABB> &) BIND2(mesh_set_blend_shape_count, RID, int) BIND1RC(int, mesh_get_blend_shape_count, RID) @@ -726,6 +211,8 @@ public: BIND2(mesh_set_blend_shape_mode, RID, BlendShapeMode) BIND1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID) + BIND4(mesh_surface_update_region, RID, int, int, const PoolVector<uint8_t> &) + BIND3(mesh_surface_set_material, RID, int, RID) BIND2RC(RID, mesh_surface_get_material, RID, int) @@ -738,15 +225,15 @@ public: BIND2RC(uint32_t, mesh_surface_get_format, RID, int) BIND2RC(PrimitiveType, mesh_surface_get_primitive_type, RID, int) - BIND2RC(Rect3, mesh_surface_get_aabb, RID, int) + BIND2RC(AABB, mesh_surface_get_aabb, RID, int) BIND2RC(Vector<PoolVector<uint8_t> >, mesh_surface_get_blend_shapes, RID, int) - BIND2RC(Vector<Rect3>, mesh_surface_get_skeleton_aabb, RID, int) + BIND2RC(Vector<AABB>, mesh_surface_get_skeleton_aabb, RID, int) BIND2(mesh_remove_surface, RID, int) BIND1RC(int, mesh_get_surface_count, RID) - BIND2(mesh_set_custom_aabb, RID, const Rect3 &) - BIND1RC(Rect3, mesh_get_custom_aabb, RID) + BIND2(mesh_set_custom_aabb, RID, const AABB &) + BIND1RC(AABB, mesh_get_custom_aabb, RID) BIND1(mesh_clear, RID) @@ -763,7 +250,7 @@ public: BIND3(multimesh_instance_set_color, RID, int, const Color &) BIND1RC(RID, multimesh_get_mesh, RID) - BIND1RC(Rect3, multimesh_get_aabb, RID) + BIND1RC(AABB, multimesh_get_aabb, RID) BIND2RC(Transform, multimesh_instance_get_transform, RID, int) BIND2RC(Transform2D, multimesh_instance_get_transform_2d, RID, int) @@ -799,7 +286,9 @@ public: /* Light API */ - BIND1R(RID, light_create, LightType) + BIND0R(RID, directional_light_create) + BIND0R(RID, omni_light_create) + BIND0R(RID, spot_light_create) BIND2(light_set_color, RID, const Color &) BIND3(light_set_param, RID, LightParam, float) @@ -838,8 +327,8 @@ public: BIND0R(RID, gi_probe_create) - BIND2(gi_probe_set_bounds, RID, const Rect3 &) - BIND1RC(Rect3, gi_probe_get_bounds, RID) + BIND2(gi_probe_set_bounds, RID, const AABB &) + BIND1RC(AABB, gi_probe_get_bounds, RID) BIND2(gi_probe_set_cell_size, RID, float) BIND1RC(float, gi_probe_get_cell_size, RID) @@ -882,7 +371,7 @@ public: BIND2(particles_set_pre_process_time, RID, float) BIND2(particles_set_explosiveness_ratio, RID, float) BIND2(particles_set_randomness_ratio, RID, float) - BIND2(particles_set_custom_aabb, RID, const Rect3 &) + BIND2(particles_set_custom_aabb, RID, const AABB &) BIND2(particles_set_speed_scale, RID, float) BIND2(particles_set_use_local_coordinates, RID, bool) BIND2(particles_set_process_material, RID, RID) @@ -895,7 +384,7 @@ public: BIND2(particles_set_draw_passes, RID, int) BIND3(particles_set_draw_pass_mesh, RID, int, RID) - BIND1R(Rect3, particles_get_current_aabb, RID) + BIND1R(AABB, particles_get_current_aabb, RID) BIND2(particles_set_emission_transform, RID, const Transform &) #undef BINDBASE @@ -960,7 +449,7 @@ public: BIND2R(int, viewport_get_render_info, RID, ViewportRenderInfo) BIND2(viewport_set_debug_draw, RID, ViewportDebugDraw) -/* ENVIRONMENT API */ + /* ENVIRONMENT API */ #undef BINDBASE //from now on, calls forwarded to this singleton @@ -990,7 +479,7 @@ public: BIND6(environment_set_fog_depth, RID, bool, float, float, bool, float) BIND5(environment_set_fog_height, RID, bool, float, float, float) -/* SCENARIO API */ + /* SCENARIO API */ #undef BINDBASE #define BINDBASE VSG::scene @@ -1021,7 +510,7 @@ public: BIND2(instance_set_extra_visibility_margin, RID, real_t) // don't use these in a game! - BIND2RC(Vector<ObjectID>, instances_cull_aabb, const Rect3 &, RID) + BIND2RC(Vector<ObjectID>, instances_cull_aabb, const AABB &, RID) BIND3RC(Vector<ObjectID>, instances_cull_ray, const Vector3 &, const Vector3 &, RID) BIND2RC(Vector<ObjectID>, instances_cull_convex, const Vector<Plane> &, RID) diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index e49baf0763..4febd1a61b 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -614,7 +614,7 @@ void VisualServerScene::instance_set_exterior(RID p_instance, bool p_enabled) { void VisualServerScene::instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) { } -Vector<ObjectID> VisualServerScene::instances_cull_aabb(const Rect3 &p_aabb, RID p_scenario) const { +Vector<ObjectID> VisualServerScene::instances_cull_aabb(const AABB &p_aabb, RID p_scenario) const { Vector<ObjectID> instances; Scenario *scenario = scenario_owner.get(p_scenario); @@ -772,7 +772,7 @@ void VisualServerScene::_update_instance(Instance *p_instance) { p_instance->mirror = p_instance->transform.basis.determinant() < 0.0; - Rect3 new_aabb; + AABB new_aabb; new_aabb = p_instance->transform.xform(p_instance->aabb); @@ -817,7 +817,7 @@ void VisualServerScene::_update_instance(Instance *p_instance) { void VisualServerScene::_update_instance_aabb(Instance *p_instance) { - Rect3 new_aabb; + AABB new_aabb; ERR_FAIL_COND(p_instance->base_type != VS::INSTANCE_NONE && !p_instance->base.is_valid()); @@ -1863,7 +1863,7 @@ void VisualServerScene::_setup_gi_probe(Instance *p_instance) { probe->dynamic.enabled = true; Transform cell_to_xform = VSG::storage->gi_probe_get_to_cell_xform(p_instance->base); - Rect3 bounds = VSG::storage->gi_probe_get_bounds(p_instance->base); + AABB bounds = VSG::storage->gi_probe_get_bounds(p_instance->base); float cell_size = VSG::storage->gi_probe_get_cell_size(p_instance->base); probe->dynamic.light_to_cell_xform = cell_to_xform * p_instance->transform.affine_inverse(); @@ -2562,7 +2562,7 @@ bool VisualServerScene::_check_gi_probe(Instance *p_gi_probe) { InstanceGIProbeData::LightCache lc; lc.type = VSG::storage->light_get_type(E->get()->base); lc.color = VSG::storage->light_get_color(E->get()->base); - lc.energy = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_ENERGY); + lc.energy = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_ENERGY) * VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_INDIRECT_ENERGY); lc.radius = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_RANGE); lc.attenuation = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_ATTENUATION); lc.spot_angle = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_SPOT_ANGLE); @@ -2582,7 +2582,7 @@ bool VisualServerScene::_check_gi_probe(Instance *p_gi_probe) { InstanceGIProbeData::LightCache lc; lc.type = VSG::storage->light_get_type(E->get()->base); lc.color = VSG::storage->light_get_color(E->get()->base); - lc.energy = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_ENERGY); + lc.energy = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_ENERGY) * VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_INDIRECT_ENERGY); lc.radius = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_RANGE); lc.attenuation = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_ATTENUATION); lc.spot_angle = VSG::storage->light_get_param(E->get()->base, VS::LIGHT_PARAM_SPOT_ANGLE); diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h index d30a2108a5..2738fa058d 100644 --- a/servers/visual/visual_server_scene.h +++ b/servers/visual/visual_server_scene.h @@ -195,8 +195,8 @@ public: SelfList<Instance> update_item; - Rect3 aabb; - Rect3 transformed_aabb; + AABB aabb; + AABB transformed_aabb; float extra_margin; uint32_t object_ID; @@ -466,7 +466,7 @@ public: virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin); // don't use these in a game! - virtual Vector<ObjectID> instances_cull_aabb(const Rect3 &p_aabb, RID p_scenario = RID()) const; + virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const; virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const; virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const; diff --git a/servers/visual/visual_server_viewport.cpp b/servers/visual/visual_server_viewport.cpp index 92c431e393..fbf593f5b9 100644 --- a/servers/visual/visual_server_viewport.cpp +++ b/servers/visual/visual_server_viewport.cpp @@ -268,7 +268,7 @@ void VisualServerViewport::draw_viewports() { if (vp->use_arvr && arvr_interface.is_valid()) { // override our size, make sure it matches our required size - Size2 size = arvr_interface->get_recommended_render_targetsize(); + Size2 size = arvr_interface->get_render_targetsize(); VSG::storage->render_target_set_size(vp->render_target, size.x, size.y); // render mono or left eye first diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp index d9a0077e60..1a03c72529 100644 --- a/servers/visual/visual_server_wrap_mt.cpp +++ b/servers/visual/visual_server_wrap_mt.cpp @@ -154,14 +154,34 @@ void VisualServerWrapMT::finish() { Thread::wait_to_finish(thread); memdelete(thread); - texture_free_cached_ids(); - //mesh_free_cached_ids(); - thread = NULL; } else { visual_server->finish(); } + texture_free_cached_ids(); + shader_free_cached_ids(); + material_free_cached_ids(); + mesh_free_cached_ids(); + multimesh_free_cached_ids(); + immediate_free_cached_ids(); + skeleton_free_cached_ids(); + directional_light_free_cached_ids(); + omni_light_free_cached_ids(); + spot_light_free_cached_ids(); + reflection_probe_free_cached_ids(); + gi_probe_free_cached_ids(); + particles_free_cached_ids(); + camera_free_cached_ids(); + viewport_free_cached_ids(); + environment_free_cached_ids(); + scenario_free_cached_ids(); + instance_free_cached_ids(); + canvas_free_cached_ids(); + canvas_item_free_cached_ids(); + canvas_light_occluder_free_cached_ids(); + canvas_occluder_polygon_free_cached_ids(); + if (draw_mutex) memdelete(draw_mutex); } diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 67d503dfca..509b77cf9c 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -63,7 +63,7 @@ class VisualServerWrapMT : public VisualServer { int pool_max_size; -//#define DEBUG_SYNC + //#define DEBUG_SYNC #ifdef DEBUG_SYNC #define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__)); @@ -103,12 +103,12 @@ public: /* SKY API */ - FUNC0R(RID, sky_create) + FUNCRID(sky) FUNC3(sky_set_texture, RID, RID, int) /* SHADER API */ - FUNC0R(RID, shader_create) + FUNCRID(shader) FUNC2(shader_set_code, RID, const String &) FUNC1RC(String, shader_get_code, RID) @@ -120,7 +120,7 @@ public: /* COMMON MATERIAL API */ - FUNC0R(RID, material_create) + FUNCRID(material) FUNC2(material_set_shader, RID, RID) FUNC1RC(RID, material_get_shader, RID) @@ -134,9 +134,9 @@ public: /* MESH API */ - FUNC0R(RID, mesh_create) + FUNCRID(mesh) - FUNC10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const Rect3 &, const Vector<PoolVector<uint8_t> > &, const Vector<Rect3> &) + FUNC10(mesh_add_surface, RID, uint32_t, PrimitiveType, const PoolVector<uint8_t> &, int, const PoolVector<uint8_t> &, int, const AABB &, const Vector<PoolVector<uint8_t> > &, const Vector<AABB> &) FUNC2(mesh_set_blend_shape_count, RID, int) FUNC1RC(int, mesh_get_blend_shape_count, RID) @@ -144,6 +144,8 @@ public: FUNC2(mesh_set_blend_shape_mode, RID, BlendShapeMode) FUNC1RC(BlendShapeMode, mesh_get_blend_shape_mode, RID) + FUNC4(mesh_surface_update_region, RID, int, int, const PoolVector<uint8_t> &) + FUNC3(mesh_surface_set_material, RID, int, RID) FUNC2RC(RID, mesh_surface_get_material, RID, int) @@ -156,21 +158,21 @@ public: FUNC2RC(uint32_t, mesh_surface_get_format, RID, int) FUNC2RC(PrimitiveType, mesh_surface_get_primitive_type, RID, int) - FUNC2RC(Rect3, mesh_surface_get_aabb, RID, int) + FUNC2RC(AABB, mesh_surface_get_aabb, RID, int) FUNC2RC(Vector<PoolVector<uint8_t> >, mesh_surface_get_blend_shapes, RID, int) - FUNC2RC(Vector<Rect3>, mesh_surface_get_skeleton_aabb, RID, int) + FUNC2RC(Vector<AABB>, mesh_surface_get_skeleton_aabb, RID, int) FUNC2(mesh_remove_surface, RID, int) FUNC1RC(int, mesh_get_surface_count, RID) - FUNC2(mesh_set_custom_aabb, RID, const Rect3 &) - FUNC1RC(Rect3, mesh_get_custom_aabb, RID) + FUNC2(mesh_set_custom_aabb, RID, const AABB &) + FUNC1RC(AABB, mesh_get_custom_aabb, RID) FUNC1(mesh_clear, RID) /* MULTIMESH API */ - FUNC0R(RID, multimesh_create) + FUNCRID(multimesh) FUNC4(multimesh_allocate, RID, int, MultimeshTransformFormat, MultimeshColorFormat) FUNC1RC(int, multimesh_get_instance_count, RID) @@ -181,7 +183,7 @@ public: FUNC3(multimesh_instance_set_color, RID, int, const Color &) FUNC1RC(RID, multimesh_get_mesh, RID) - FUNC1RC(Rect3, multimesh_get_aabb, RID) + FUNC1RC(AABB, multimesh_get_aabb, RID) FUNC2RC(Transform, multimesh_instance_get_transform, RID, int) FUNC2RC(Transform2D, multimesh_instance_get_transform_2d, RID, int) @@ -192,7 +194,7 @@ public: /* IMMEDIATE API */ - FUNC0R(RID, immediate_create) + FUNCRID(immediate) FUNC3(immediate_begin, RID, PrimitiveType, RID) FUNC2(immediate_vertex, RID, const Vector3 &) FUNC2(immediate_normal, RID, const Vector3 &) @@ -207,7 +209,7 @@ public: /* SKELETON API */ - FUNC0R(RID, skeleton_create) + FUNCRID(skeleton) FUNC3(skeleton_allocate, RID, int, bool) FUNC1RC(int, skeleton_get_bone_count, RID) FUNC3(skeleton_bone_set_transform, RID, int, const Transform &) @@ -217,7 +219,9 @@ public: /* Light API */ - FUNC1R(RID, light_create, LightType) + FUNCRID(directional_light) + FUNCRID(omni_light) + FUNCRID(spot_light) FUNC2(light_set_color, RID, const Color &) FUNC3(light_set_param, RID, LightParam, float) @@ -237,7 +241,7 @@ public: /* PROBE API */ - FUNC0R(RID, reflection_probe_create) + FUNCRID(reflection_probe) FUNC2(reflection_probe_set_update_mode, RID, ReflectionProbeUpdateMode) FUNC2(reflection_probe_set_intensity, RID, float) @@ -254,10 +258,10 @@ public: /* BAKED LIGHT API */ - FUNC0R(RID, gi_probe_create) + FUNCRID(gi_probe) - FUNC2(gi_probe_set_bounds, RID, const Rect3 &) - FUNC1RC(Rect3, gi_probe_get_bounds, RID) + FUNC2(gi_probe_set_bounds, RID, const AABB &) + FUNC1RC(AABB, gi_probe_get_bounds, RID) FUNC2(gi_probe_set_cell_size, RID, float) FUNC1RC(float, gi_probe_get_cell_size, RID) @@ -291,7 +295,7 @@ public: /* PARTICLES */ - FUNC0R(RID, particles_create) + FUNCRID(particles) FUNC2(particles_set_emitting, RID, bool) FUNC2(particles_set_amount, RID, int) @@ -300,7 +304,7 @@ public: FUNC2(particles_set_pre_process_time, RID, float) FUNC2(particles_set_explosiveness_ratio, RID, float) FUNC2(particles_set_randomness_ratio, RID, float) - FUNC2(particles_set_custom_aabb, RID, const Rect3 &) + FUNC2(particles_set_custom_aabb, RID, const AABB &) FUNC2(particles_set_speed_scale, RID, float) FUNC2(particles_set_use_local_coordinates, RID, bool) FUNC2(particles_set_process_material, RID, RID) @@ -314,11 +318,11 @@ public: FUNC3(particles_set_draw_pass_mesh, RID, int, RID) FUNC2(particles_set_emission_transform, RID, const Transform &) - FUNC1R(Rect3, particles_get_current_aabb, RID) + FUNC1R(AABB, particles_get_current_aabb, RID) /* CAMERA API */ - FUNC0R(RID, camera_create) + FUNCRID(camera) FUNC4(camera_set_perspective, RID, float, float, float) FUNC4(camera_set_orthogonal, RID, float, float, float) FUNC2(camera_set_transform, RID, const Transform &) @@ -328,7 +332,7 @@ public: /* VIEWPORT TARGET API */ - FUNC0R(RID, viewport_create) + FUNCRID(viewport) FUNC2(viewport_set_use_arvr, RID, bool) @@ -377,7 +381,7 @@ public: /* ENVIRONMENT API */ - FUNC0R(RID, environment_create) + FUNCRID(environment) FUNC2(environment_set_background, RID, EnvironmentBG) FUNC2(environment_set_sky, RID, RID) @@ -401,7 +405,7 @@ public: FUNC6(environment_set_fog_depth, RID, bool, float, float, bool, float) FUNC5(environment_set_fog_height, RID, bool, float, float, float) - FUNC0R(RID, scenario_create) + FUNCRID(scenario) FUNC2(scenario_set_debug, RID, ScenarioDebugMode) FUNC2(scenario_set_environment, RID, RID) @@ -410,7 +414,7 @@ public: /* INSTANCING API */ // from can be mesh, light, area and portal so far. - FUNC0R(RID, instance_create) + FUNCRID(instance) FUNC2(instance_set_base, RID, RID) // from can be mesh, light, poly, area and portal so far. FUNC2(instance_set_scenario, RID, RID) // from can be mesh, light, poly, area and portal so far. @@ -427,7 +431,7 @@ public: FUNC2(instance_set_extra_visibility_margin, RID, real_t) // don't use these in a game! - FUNC2RC(Vector<ObjectID>, instances_cull_aabb, const Rect3 &, RID) + FUNC2RC(Vector<ObjectID>, instances_cull_aabb, const AABB &, RID) FUNC3RC(Vector<ObjectID>, instances_cull_ray, const Vector3 &, const Vector3 &, RID) FUNC2RC(Vector<ObjectID>, instances_cull_convex, const Vector<Plane> &, RID) @@ -440,11 +444,11 @@ public: /* CANVAS (2D) */ - FUNC0R(RID, canvas_create) + FUNCRID(canvas) FUNC3(canvas_set_item_mirroring, RID, RID, const Point2 &) FUNC2(canvas_set_modulate, RID, const Color &) - FUNC0R(RID, canvas_item_create) + FUNCRID(canvas_item) FUNC2(canvas_item_set_parent, RID, RID) FUNC2(canvas_item_set_visible, RID, bool) @@ -510,14 +514,14 @@ public: FUNC2(canvas_light_set_shadow_color, RID, const Color &) FUNC2(canvas_light_set_shadow_smooth, RID, float) - FUNC0R(RID, canvas_light_occluder_create) + FUNCRID(canvas_light_occluder) FUNC2(canvas_light_occluder_attach_to_canvas, RID, RID) FUNC2(canvas_light_occluder_set_enabled, RID, bool) FUNC2(canvas_light_occluder_set_polygon, RID, RID) FUNC2(canvas_light_occluder_set_transform, RID, const Transform2D &) FUNC2(canvas_light_occluder_set_light_mask, RID, int) - FUNC0R(RID, canvas_occluder_polygon_create) + FUNCRID(canvas_occluder_polygon) FUNC3(canvas_occluder_polygon_set_shape, RID, const PoolVector<Vector2> &, bool) FUNC2(canvas_occluder_polygon_set_shape_as_lines, RID, const PoolVector<Vector2> &) diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 2234ddda0d..10f350d667 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -308,7 +308,7 @@ RID VisualServer::get_white_texture() { #define SMALL_VEC2 Vector2(0.00001, 0.00001) #define SMALL_VEC3 Vector3(0.00001, 0.00001, 0.00001) -Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, Rect3 &r_aabb, Vector<Rect3> r_bone_aabb) { +Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> r_bone_aabb) { PoolVector<uint8_t>::Write vw = r_vertex_array.write(); @@ -373,7 +373,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ } } - r_aabb = Rect3(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0)); + r_aabb = AABB(Vector3(aabb.position.x, aabb.position.y, 0), Vector3(aabb.size.x, aabb.size.y, 0)); } else { PoolVector<Vector3> array = p_arrays[ai]; @@ -383,7 +383,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ const Vector3 *src = read.ptr(); // setting vertices means regenerating the AABB - Rect3 aabb; + AABB aabb; if (p_format & ARRAY_COMPRESS_VERTEX) { @@ -395,7 +395,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect3(src[i], SMALL_VEC3); + aabb = AABB(src[i], SMALL_VEC3); } else { aabb.expand_to(src[i]); @@ -411,7 +411,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (i == 0) { - aabb = Rect3(src[i], SMALL_VEC3); + aabb = AABB(src[i], SMALL_VEC3); } else { aabb.expand_to(src[i]); @@ -728,7 +728,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ PoolVector<int>::Read rb = bones.read(); PoolVector<float>::Read rw = weights.read(); - Rect3 *bptr = r_bone_aabb.ptr(); + AABB *bptr = r_bone_aabb.ptr(); for (int i = 0; i < vs; i++) { @@ -743,7 +743,7 @@ Error VisualServer::_surface_set_data(Array p_arrays, uint32_t p_format, uint32_ if (bptr->size.x < 0) { //first - bptr[idx] = Rect3(v, SMALL_VEC3); + bptr[idx] = AABB(v, SMALL_VEC3); any_valid = true; } else { bptr[idx].expand_to(v); @@ -975,8 +975,8 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim PoolVector<uint8_t> index_array; index_array.resize(index_array_size); - Rect3 aabb; - Vector<Rect3> bone_aabb; + AABB aabb; + Vector<AABB> bone_aabb; Error err = _surface_set_data(p_arrays, format, offsets, total_elem_size, vertex_array, array_len, index_array, index_array_len, aabb, bone_aabb); @@ -993,7 +993,7 @@ void VisualServer::mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_prim vertex_array_shape.resize(array_size); PoolVector<uint8_t> noindex; - Rect3 laabb; + AABB laabb; Error err = _surface_set_data(p_blend_shapes[i], format & ~ARRAY_FORMAT_INDEX, offsets, total_elem_size, vertex_array_shape, array_len, noindex, 0, laabb, bone_aabb); aabb.merge_with(laabb); if (err) { @@ -1470,7 +1470,7 @@ Array VisualServer::mesh_surface_get_blend_shape_arrays(RID p_mesh, int p_surfac Array VisualServer::_mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const { - Vector<Rect3> vec = VS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface); + Vector<AABB> vec = VS::get_singleton()->mesh_surface_get_skeleton_aabb(p_mesh, p_surface); Array arr; for (int i = 0; i < vec.size(); i++) { arr[i] = vec[i]; @@ -1856,6 +1856,8 @@ void VisualServer::_bind_methods() { BIND_ENUM_CONSTANT(FEATURE_SHADERS); BIND_ENUM_CONSTANT(FEATURE_MULTITHREADED); + + ADD_SIGNAL(MethodInfo("frame_drawn_in_thread")); } void VisualServer::_canvas_item_add_style_box(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector<float> &p_margins, const Color &p_modulate) { diff --git a/servers/visual_server.h b/servers/visual_server.h index 64ed540501..3edde7ec85 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -60,7 +60,7 @@ protected: RID white_texture; RID test_material; - Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, Rect3 &r_aabb, Vector<Rect3> r_bone_aabb); + Error _surface_set_data(Array p_arrays, uint32_t p_format, uint32_t *p_offsets, uint32_t p_stride, PoolVector<uint8_t> &r_vertex_array, int p_vertex_array_len, PoolVector<uint8_t> &r_index_array, int p_index_array_len, AABB &r_aabb, Vector<AABB> r_bone_aabb); static VisualServer *(*create_func)(); static void _bind_methods(); @@ -227,6 +227,7 @@ public: ARRAY_FLAG_USE_2D_VERTICES = ARRAY_COMPRESS_INDEX << 1, ARRAY_FLAG_USE_16_BIT_BONES = ARRAY_COMPRESS_INDEX << 2, + ARRAY_FLAG_USE_DYNAMIC_UPDATE = ARRAY_COMPRESS_INDEX << 3, ARRAY_COMPRESS_DEFAULT = ARRAY_COMPRESS_VERTEX | ARRAY_COMPRESS_NORMAL | ARRAY_COMPRESS_TANGENT | ARRAY_COMPRESS_COLOR | ARRAY_COMPRESS_TEX_UV | ARRAY_COMPRESS_TEX_UV2 | ARRAY_COMPRESS_WEIGHTS @@ -246,7 +247,7 @@ public: virtual RID mesh_create() = 0; virtual void mesh_add_surface_from_arrays(RID p_mesh, PrimitiveType p_primitive, const Array &p_arrays, const Array &p_blend_shapes = Array(), uint32_t p_compress_format = ARRAY_COMPRESS_DEFAULT); - virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const Rect3 &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<Rect3> &p_bone_aabbs = Vector<Rect3>()) = 0; + virtual void mesh_add_surface(RID p_mesh, uint32_t p_format, PrimitiveType p_primitive, const PoolVector<uint8_t> &p_array, int p_vertex_count, const PoolVector<uint8_t> &p_index_array, int p_index_count, const AABB &p_aabb, const Vector<PoolVector<uint8_t> > &p_blend_shapes = Vector<PoolVector<uint8_t> >(), const Vector<AABB> &p_bone_aabbs = Vector<AABB>()) = 0; virtual void mesh_set_blend_shape_count(RID p_mesh, int p_amount) = 0; virtual int mesh_get_blend_shape_count(RID p_mesh) const = 0; @@ -259,6 +260,8 @@ public: virtual void mesh_set_blend_shape_mode(RID p_mesh, BlendShapeMode p_mode) = 0; virtual BlendShapeMode mesh_get_blend_shape_mode(RID p_mesh) const = 0; + virtual void mesh_surface_update_region(RID p_mesh, int p_surface, int p_offset, const PoolVector<uint8_t> &p_data) = 0; + virtual void mesh_surface_set_material(RID p_mesh, int p_surface, RID p_material) = 0; virtual RID mesh_surface_get_material(RID p_mesh, int p_surface) const = 0; @@ -274,16 +277,16 @@ public: virtual uint32_t mesh_surface_get_format(RID p_mesh, int p_surface) const = 0; virtual PrimitiveType mesh_surface_get_primitive_type(RID p_mesh, int p_surface) const = 0; - virtual Rect3 mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0; + virtual AABB mesh_surface_get_aabb(RID p_mesh, int p_surface) const = 0; virtual Vector<PoolVector<uint8_t> > mesh_surface_get_blend_shapes(RID p_mesh, int p_surface) const = 0; - virtual Vector<Rect3> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0; + virtual Vector<AABB> mesh_surface_get_skeleton_aabb(RID p_mesh, int p_surface) const = 0; Array _mesh_surface_get_skeleton_aabb_bind(RID p_mesh, int p_surface) const; virtual void mesh_remove_surface(RID p_mesh, int p_index) = 0; virtual int mesh_get_surface_count(RID p_mesh) const = 0; - virtual void mesh_set_custom_aabb(RID p_mesh, const Rect3 &p_aabb) = 0; - virtual Rect3 mesh_get_custom_aabb(RID p_mesh) const = 0; + virtual void mesh_set_custom_aabb(RID p_mesh, const AABB &p_aabb) = 0; + virtual AABB mesh_get_custom_aabb(RID p_mesh) const = 0; virtual void mesh_clear(RID p_mesh) = 0; @@ -311,7 +314,7 @@ public: virtual void multimesh_instance_set_color(RID p_multimesh, int p_index, const Color &p_color) = 0; virtual RID multimesh_get_mesh(RID p_multimesh) const = 0; - virtual Rect3 multimesh_get_aabb(RID p_multimesh) const = 0; + virtual AABB multimesh_get_aabb(RID p_multimesh) const = 0; virtual Transform multimesh_instance_get_transform(RID p_multimesh, int p_index) const = 0; virtual Transform2D multimesh_instance_get_transform_2d(RID p_multimesh, int p_index) const = 0; @@ -357,6 +360,7 @@ public: enum LightParam { LIGHT_PARAM_ENERGY, + LIGHT_PARAM_INDIRECT_ENERGY, LIGHT_PARAM_SPECULAR, LIGHT_PARAM_RANGE, LIGHT_PARAM_ATTENUATION, @@ -373,7 +377,9 @@ public: LIGHT_PARAM_MAX }; - virtual RID light_create(LightType p_type) = 0; + virtual RID directional_light_create() = 0; + virtual RID omni_light_create() = 0; + virtual RID spot_light_create() = 0; virtual void light_set_color(RID p_light, const Color &p_color) = 0; virtual void light_set_param(RID p_light, LightParam p_param, float p_value) = 0; @@ -444,8 +450,8 @@ public: virtual RID gi_probe_create() = 0; - virtual void gi_probe_set_bounds(RID p_probe, const Rect3 &p_bounds) = 0; - virtual Rect3 gi_probe_get_bounds(RID p_probe) const = 0; + virtual void gi_probe_set_bounds(RID p_probe, const AABB &p_bounds) = 0; + virtual AABB gi_probe_get_bounds(RID p_probe) const = 0; virtual void gi_probe_set_cell_size(RID p_probe, float p_range) = 0; virtual float gi_probe_get_cell_size(RID p_probe) const = 0; @@ -488,7 +494,7 @@ public: virtual void particles_set_pre_process_time(RID p_particles, float p_time) = 0; virtual void particles_set_explosiveness_ratio(RID p_particles, float p_ratio) = 0; virtual void particles_set_randomness_ratio(RID p_particles, float p_ratio) = 0; - virtual void particles_set_custom_aabb(RID p_particles, const Rect3 &p_aabb) = 0; + virtual void particles_set_custom_aabb(RID p_particles, const AABB &p_aabb) = 0; virtual void particles_set_speed_scale(RID p_particles, float p_scale) = 0; virtual void particles_set_use_local_coordinates(RID p_particles, bool p_enable) = 0; virtual void particles_set_process_material(RID p_particles, RID p_material) = 0; @@ -507,7 +513,7 @@ public: virtual void particles_set_draw_passes(RID p_particles, int p_count) = 0; virtual void particles_set_draw_pass_mesh(RID p_particles, int p_pass, RID p_mesh) = 0; - virtual Rect3 particles_get_current_aabb(RID p_particles) = 0; + virtual AABB particles_get_current_aabb(RID p_particles) = 0; virtual void particles_set_emission_transform(RID p_particles, const Transform &p_transform) = 0; //this is only used for 2D, in 3D it's automatic @@ -753,7 +759,7 @@ public: virtual void instance_set_extra_visibility_margin(RID p_instance, real_t p_margin) = 0; // don't use these in a game! - virtual Vector<ObjectID> instances_cull_aabb(const Rect3 &p_aabb, RID p_scenario = RID()) const = 0; + virtual Vector<ObjectID> instances_cull_aabb(const AABB &p_aabb, RID p_scenario = RID()) const = 0; virtual Vector<ObjectID> instances_cull_ray(const Vector3 &p_from, const Vector3 &p_to, RID p_scenario = RID()) const = 0; virtual Vector<ObjectID> instances_cull_convex(const Vector<Plane> &p_convex, RID p_scenario = RID()) const = 0; @@ -808,7 +814,7 @@ public: virtual void canvas_item_add_rect(RID p_item, const Rect2 &p_rect, const Color &p_color) = 0; virtual void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) = 0; virtual void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID()) = 0; - virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = true) = 0; + virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = false) = 0; virtual void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, NinePatchAxisMode p_x_axis_mode = NINE_PATCH_STRETCH, NinePatchAxisMode p_y_axis_mode = NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID()) = 0; virtual void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID()) = 0; virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false) = 0; diff --git a/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp b/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp index 06447aca57..c9e71eb733 100644 --- a/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp +++ b/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp @@ -122,6 +122,43 @@ bool OpusVorbisDecoder::getPCMS16(WebMFrame &frame, short *buffer, int &numOutSa return false; } +bool OpusVorbisDecoder::getPCMF(WebMFrame &frame, float *buffer, int &numOutSamples) { + if (m_vorbis) { + m_vorbis->op.packet = frame.buffer; + m_vorbis->op.bytes = frame.bufferSize; + + if (vorbis_synthesis(&m_vorbis->block, &m_vorbis->op)) + return false; + if (vorbis_synthesis_blockin(&m_vorbis->dspState, &m_vorbis->block)) + return false; + + const int maxSamples = getBufferSamples(); + int samplesCount, count = 0; + float **pcm; + while ((samplesCount = vorbis_synthesis_pcmout(&m_vorbis->dspState, &pcm))) { + const int toConvert = samplesCount <= maxSamples ? samplesCount : maxSamples; + for (int c = 0; c < m_channels; ++c) { + float *samples = pcm[c]; + for (int i = 0, j = c; i < toConvert; ++i, j += m_channels) { + buffer[count + j] = samples[i]; + } + } + vorbis_synthesis_read(&m_vorbis->dspState, toConvert); + count += toConvert; + } + + numOutSamples = count; + return true; + } else if (m_opus) { + const int samples = opus_decode_float(m_opus, frame.buffer, frame.bufferSize, buffer, m_numSamples, 0); + if (samples >= 0) { + numOutSamples = samples; + return true; + } + } + return false; +} + bool OpusVorbisDecoder::openVorbis(const WebMDemuxer &demuxer) { size_t extradataSize = 0; diff --git a/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp b/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp index bcdca731ee..b7619d6a25 100644 --- a/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp +++ b/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp @@ -44,7 +44,7 @@ public: { return m_numSamples; } - + bool getPCMF(WebMFrame &frame, float *buffer, int &numOutSamples); bool getPCMS16(WebMFrame &frame, short *buffer, int &numOutSamples); private: diff --git a/thirdparty/openssl/uwp.cpp b/thirdparty/openssl/uwp.cpp index dcfd22b77f..e00c9d59db 100644 --- a/thirdparty/openssl/uwp.cpp +++ b/thirdparty/openssl/uwp.cpp @@ -103,12 +103,14 @@ extern "C" { return 0; } +#ifndef STD_ERROR_HANDLE int __cdecl GetStdHandle( _In_ DWORD nStdHandle ) { return 0; } +#endif BOOL DeregisterEventSource( _Inout_ HANDLE hEventLog ) |