diff options
284 files changed, 4175 insertions, 1610 deletions
diff --git a/core/array.cpp b/core/array.cpp index 108d9f7386..ac30df08bc 100644 --- a/core/array.cpp +++ b/core/array.cpp @@ -222,6 +222,63 @@ Array Array::duplicate(bool p_deep) const { return new_arr; } + +int Array::_fix_slice_index(int p_index, int p_arr_len, int p_top_mod) { + p_index = CLAMP(p_index, -p_arr_len, p_arr_len + p_top_mod); + if (p_index < 0) { + p_index = (p_index % p_arr_len + p_arr_len) % p_arr_len; // positive modulo + } + return p_index; +} + +int Array::_clamp_index(int p_index) const { + return CLAMP(p_index, -size() + 1, size() - 1); +} + +#define ARRAY_GET_DEEP(idx, is_deep) is_deep ? get(idx).duplicate(is_deep) : get(idx) + +Array Array::slice(int p_begin, int p_end, int p_step, bool p_deep) const { // like python, but inclusive on upper bound + Array new_arr; + + p_begin = Array::_fix_slice_index(p_begin, size(), -1); // can't start out of range + p_end = Array::_fix_slice_index(p_end, size(), 0); + + int x = p_begin; + int new_arr_i = 0; + + ERR_FAIL_COND_V(p_step == 0, new_arr); + if (Array::_clamp_index(p_begin) == Array::_clamp_index(p_end)) { // don't include element twice + new_arr.resize(1); + // new_arr[0] = 1; + new_arr[0] = ARRAY_GET_DEEP(Array::_clamp_index(p_begin), p_deep); + return new_arr; + } else { + int element_count = ceil((int)MAX(0, (p_end - p_begin) / p_step)) + 1; + if (element_count == 1) { // delta going in wrong direction to reach end + new_arr.resize(0); + return new_arr; + } + new_arr.resize(element_count); + } + + // if going backwards, have to have a different terminating condition + if (p_step < 0) { + while (x >= p_end) { + new_arr[new_arr_i] = ARRAY_GET_DEEP(Array::_clamp_index(x), p_deep); + x += p_step; + new_arr_i += 1; + } + } else if (p_step > 0) { + while (x <= p_end) { + new_arr[new_arr_i] = ARRAY_GET_DEEP(Array::_clamp_index(x), p_deep); + x += p_step; + new_arr_i += 1; + } + } + + return new_arr; +} + struct _ArrayVariantSort { _FORCE_INLINE_ bool operator()(const Variant &p_l, const Variant &p_r) const { diff --git a/core/array.h b/core/array.h index d4e937a486..7a754d53ea 100644 --- a/core/array.h +++ b/core/array.h @@ -44,6 +44,9 @@ class Array { void _ref(const Array &p_from) const; void _unref() const; + int _clamp_index(int p_index) const; + static int _fix_slice_index(int p_index, int p_arr_len, int p_top_mod); + public: Variant &operator[](int p_idx); const Variant &operator[](int p_idx) const; @@ -91,6 +94,8 @@ public: Array duplicate(bool p_deep = false) const; + Array slice(int p_begin, int p_end, int p_step = 1, bool p_deep = false) const; + Variant min() const; Variant max() const; diff --git a/core/crypto/hashing_context.cpp b/core/crypto/hashing_context.cpp index bdccb258dd..bd863f546b 100644 --- a/core/crypto/hashing_context.cpp +++ b/core/crypto/hashing_context.cpp @@ -103,7 +103,7 @@ void HashingContext::_create_ctx(HashType p_type) { } void HashingContext::_delete_ctx() { - return; + switch (type) { case HASH_MD5: memdelete((CryptoCore::MD5Context *)ctx); diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index 77decc107d..0eef0ee79f 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -176,6 +176,22 @@ bool FileAccessEncrypted::is_open() const { return file != NULL; } +String FileAccessEncrypted::get_path() const { + + if (file) + return file->get_path(); + else + return ""; +} + +String FileAccessEncrypted::get_path_absolute() const { + + if (file) + return file->get_path_absolute(); + else + return ""; +} + void FileAccessEncrypted::seek(size_t p_position) { if (p_position > (size_t)data.size()) diff --git a/core/io/file_access_encrypted.h b/core/io/file_access_encrypted.h index d779a150ac..c3be0f7de8 100644 --- a/core/io/file_access_encrypted.h +++ b/core/io/file_access_encrypted.h @@ -60,6 +60,9 @@ public: virtual void close(); ///< close a file virtual bool is_open() const; ///< true when file is open + virtual String get_path() const; /// returns the path for the current open file + virtual String get_path_absolute() const; /// returns the absolute path for the current open file + virtual void seek(size_t p_position); ///< seek to a given position virtual void seek_end(int64_t p_position = 0); ///< seek from the end of file virtual size_t get_position() const; ///< get position in the file diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index be28c9a877..abc0bd064d 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -194,7 +194,7 @@ bool ZipArchive::try_open_pack(const String &p_path) { packages.push_back(pkg); int pkg_num = packages.size() - 1; - for (unsigned int i = 0; i < gi.number_entry; i++) { + for (uint64_t i = 0; i < gi.number_entry; i++) { char filename_inzip[256]; diff --git a/core/math/disjoint_set.cpp b/core/math/disjoint_set.cpp new file mode 100644 index 0000000000..c9d47aa0ae --- /dev/null +++ b/core/math/disjoint_set.cpp @@ -0,0 +1,31 @@ +/*************************************************************************/ +/* disjoint_set.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 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 "disjoint_set.h" diff --git a/core/math/disjoint_set.h b/core/math/disjoint_set.h new file mode 100644 index 0000000000..c9b3d0b65d --- /dev/null +++ b/core/math/disjoint_set.h @@ -0,0 +1,155 @@ +/*************************************************************************/ +/* disjoint_set.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 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 DISJOINT_SET_H +#define DISJOINT_SET_H + +#include "core/map.h" +#include "core/vector.h" + +/** + @author Marios Staikopoulos <marios@staik.net> +*/ + +/* This DisjointSet class uses Find with path compression and Union by rank */ +template <typename T, class C = Comparator<T>, class AL = DefaultAllocator> +class DisjointSet { + + struct Element { + T object; + Element *parent = nullptr; + int rank = 0; + }; + + typedef Map<T, Element *, C, AL> MapT; + + MapT elements; + + Element *get_parent(Element *element); + + _FORCE_INLINE_ Element *insert_or_get(T object); + +public: + ~DisjointSet(); + + _FORCE_INLINE_ void insert(T object) { (void)insert_or_get(object); } + + void create_union(T a, T b); + + void get_representatives(Vector<T> &out_roots); + + void get_members(Vector<T> &out_members, T representative); +}; + +/* FUNCTIONS */ + +template <typename T, class C, class AL> +DisjointSet<T, C, AL>::~DisjointSet() { + for (typename MapT::Element *itr = elements.front(); itr != nullptr; itr = itr->next()) { + memdelete_allocator<Element, AL>(itr->value()); + } +} + +template <typename T, class C, class AL> +typename DisjointSet<T, C, AL>::Element *DisjointSet<T, C, AL>::get_parent(Element *element) { + if (element->parent != element) { + element->parent = get_parent(element->parent); + } + + return element->parent; +} + +template <typename T, class C, class AL> +typename DisjointSet<T, C, AL>::Element *DisjointSet<T, C, AL>::insert_or_get(T object) { + typename MapT::Element *itr = elements.find(object); + if (itr != nullptr) { + return itr->value(); + } + + Element *new_element = memnew_allocator(Element, AL); + new_element->object = object; + new_element->parent = new_element; + elements.insert(object, new_element); + + return new_element; +} + +template <typename T, class C, class AL> +void DisjointSet<T, C, AL>::create_union(T a, T b) { + + Element *x = insert_or_get(a); + Element *y = insert_or_get(b); + + Element *x_root = get_parent(x); + Element *y_root = get_parent(y); + + // Already in the same set + if (x_root == y_root) + return; + + // Not in the same set, merge + if (x_root->rank < y_root->rank) { + SWAP(x_root, y_root); + } + + // Merge y_root into x_root + y_root->parent = x_root; + if (x_root->rank == y_root->rank) { + ++x_root->rank; + } +} + +template <typename T, class C, class AL> +void DisjointSet<T, C, AL>::get_representatives(Vector<T> &out_representatives) { + for (typename MapT::Element *itr = elements.front(); itr != nullptr; itr = itr->next()) { + Element *element = itr->value(); + if (element->parent == element) { + out_representatives.push_back(element->object); + } + } +} + +template <typename T, class C, class AL> +void DisjointSet<T, C, AL>::get_members(Vector<T> &out_members, T representative) { + typename MapT::Element *rep_itr = elements.find(representative); + ERR_FAIL_COND(rep_itr == nullptr); + + Element *rep_element = rep_itr->value(); + ERR_FAIL_COND(rep_element->parent != rep_element); + + for (typename MapT::Element *itr = elements.front(); itr != nullptr; itr = itr->next()) { + Element *parent = get_parent(itr->value()); + if (parent == rep_element) { + out_members.push_back(itr->key()); + } + } +} + +#endif diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp index f37db90929..77383e2839 100644 --- a/core/math/geometry.cpp +++ b/core/math/geometry.cpp @@ -715,7 +715,7 @@ Vector<Vector<Vector2> > Geometry::decompose_polygon_in_convex(Vector<Point2> po decomp.write[idx].resize(tp.GetNumPoints()); - for (int i = 0; i < tp.GetNumPoints(); i++) { + for (int64_t i = 0; i < tp.GetNumPoints(); i++) { decomp.write[idx].write[i] = tp.GetPoint(i); } diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp index eca3b2a7f4..5587e827ba 100644 --- a/core/os/main_loop.cpp +++ b/core/os/main_loop.cpp @@ -63,6 +63,8 @@ void MainLoop::_bind_methods() { BIND_CONSTANT(NOTIFICATION_WM_ABOUT); BIND_CONSTANT(NOTIFICATION_CRASH); BIND_CONSTANT(NOTIFICATION_OS_IME_UPDATE); + BIND_CONSTANT(NOTIFICATION_APP_RESUMED); + BIND_CONSTANT(NOTIFICATION_APP_PAUSED); }; void MainLoop::set_init_script(const Ref<Script> &p_init_script) { diff --git a/core/script_language.cpp b/core/script_language.cpp index ee8589d76a..7201773ea5 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -114,7 +114,7 @@ void Script::_bind_methods() { ClassDB::bind_method(D_METHOD("get_script_method_list"), &Script::_get_script_method_list); ClassDB::bind_method(D_METHOD("get_script_signal_list"), &Script::_get_script_signal_list); ClassDB::bind_method(D_METHOD("get_script_constant_map"), &Script::_get_script_constant_map); - ClassDB::bind_method(D_METHOD("get_property_default_value"), &Script::_get_property_default_value); + ClassDB::bind_method(D_METHOD("get_property_default_value", "property"), &Script::_get_property_default_value); ClassDB::bind_method(D_METHOD("is_tool"), &Script::is_tool); diff --git a/core/ustring.cpp b/core/ustring.cpp index fb4bd6d802..07caa3a018 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -2147,13 +2147,13 @@ int64_t String::to_int(const CharType *p_str, int p_len) { if (c >= '0' && c <= '9') { - if (integer > INT32_MAX / 10) { + if (integer > INT64_MAX / 10) { String number(""); str = p_str; while (*str && str != limit) { number += *(str++); } - ERR_FAIL_V_MSG(sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + number + " as integer, provided value is " + (sign == 1 ? "too big." : "too small.")); + ERR_FAIL_V_MSG(sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + number + " as integer, provided value is " + (sign == 1 ? "too big." : "too small.")); } integer *= 10; integer += c - '0'; @@ -3049,6 +3049,22 @@ String String::replacen(const String &p_key, const String &p_with) const { return new_string; } +String String::repeat(int p_count) const { + + ERR_FAIL_COND_V_MSG(p_count < 0, "", "Parameter count should be a positive number."); + + String new_string; + const CharType *src = this->c_str(); + + new_string.resize(length() * p_count + 1); + + for (int i = 0; i < p_count; i++) + for (int j = 0; j < length(); j++) + new_string[i * length() + j] = src[j]; + + return new_string; +} + String String::left(int p_pos) const { if (p_pos <= 0) @@ -3285,18 +3301,26 @@ static int _humanize_digits(int p_num) { String String::humanize_size(size_t p_size) { uint64_t _div = 1; - static const char *prefix[] = { " B", " KiB", " MiB", " GiB", " TiB", " PiB", " EiB", "" }; + Vector<String> prefixes; + prefixes.push_back(RTR("B")); + prefixes.push_back(RTR("KiB")); + prefixes.push_back(RTR("MiB")); + prefixes.push_back(RTR("GiB")); + prefixes.push_back(RTR("TiB")); + prefixes.push_back(RTR("PiB")); + prefixes.push_back(RTR("EiB")); + int prefix_idx = 0; - while (p_size > (_div * 1024) && prefix[prefix_idx][0]) { + while (prefix_idx < prefixes.size() && p_size > (_div * 1024)) { _div *= 1024; prefix_idx++; } - int digits = prefix_idx > 0 ? _humanize_digits(p_size / _div) : 0; - double divisor = prefix_idx > 0 ? _div : 1; + const int digits = prefix_idx > 0 ? _humanize_digits(p_size / _div) : 0; + const double divisor = prefix_idx > 0 ? _div : 1; - return String::num(p_size / divisor).pad_decimals(digits) + RTR(prefix[prefix_idx]); + return String::num(p_size / divisor).pad_decimals(digits) + " " + prefixes[prefix_idx]; } bool String::is_abs_path() const { diff --git a/core/ustring.h b/core/ustring.h index bbd0bcceb5..87a14bfad7 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -223,6 +223,7 @@ public: String replace(const String &p_key, const String &p_with) const; String replace(const char *p_key, const char *p_with) const; String replacen(const String &p_key, const String &p_with) const; + String repeat(int p_count) const; String insert(int p_at_pos, const String &p_string) const; String pad_decimals(int p_digits) const; String pad_zeros(int p_digits) const; diff --git a/core/variant.cpp b/core/variant.cpp index e7d0e58367..16bbf94c54 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -910,7 +910,15 @@ bool Variant::is_one() const { void Variant::reference(const Variant &p_variant) { - clear(); + switch (type) { + case NIL: + case BOOL: + case INT: + case REAL: + break; + default: + clear(); + } type = p_variant.type; diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 5e3876d6a4..53f64fcde6 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -256,6 +256,7 @@ struct _VariantCall { VCALL_LOCALMEM2R(String, format); VCALL_LOCALMEM2R(String, replace); VCALL_LOCALMEM2R(String, replacen); + VCALL_LOCALMEM1R(String, repeat); VCALL_LOCALMEM2R(String, insert); VCALL_LOCALMEM0R(String, capitalize); VCALL_LOCALMEM3R(String, split); @@ -534,6 +535,7 @@ struct _VariantCall { VCALL_LOCALMEM2R(Array, bsearch); VCALL_LOCALMEM4R(Array, bsearch_custom); VCALL_LOCALMEM1R(Array, duplicate); + VCALL_LOCALMEM4R(Array, slice); VCALL_LOCALMEM0(Array, invert); VCALL_LOCALMEM0R(Array, max); VCALL_LOCALMEM0R(Array, min); @@ -1529,6 +1531,7 @@ void register_variant_methods() { ADDFUNC2R(STRING, STRING, String, format, NIL, "values", STRING, "placeholder", varray("{_}")); ADDFUNC2R(STRING, STRING, String, replace, STRING, "what", STRING, "forwhat", varray()); ADDFUNC2R(STRING, STRING, String, replacen, STRING, "what", STRING, "forwhat", varray()); + ADDFUNC1R(STRING, STRING, String, repeat, INT, "count", varray()); ADDFUNC2R(STRING, STRING, String, insert, INT, "position", STRING, "what", varray()); ADDFUNC0R(STRING, STRING, String, capitalize, varray()); ADDFUNC3R(STRING, POOL_STRING_ARRAY, String, split, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0)); @@ -1759,6 +1762,7 @@ void register_variant_methods() { ADDFUNC4R(ARRAY, INT, Array, bsearch_custom, NIL, "value", OBJECT, "obj", STRING, "func", BOOL, "before", varray(true)); ADDFUNC0NC(ARRAY, NIL, Array, invert, varray()); ADDFUNC1R(ARRAY, ARRAY, Array, duplicate, BOOL, "deep", varray(false)); + ADDFUNC4R(ARRAY, ARRAY, Array, slice, INT, "begin", INT, "end", INT, "step", BOOL, "deep", varray(1, false)); ADDFUNC0R(ARRAY, NIL, Array, max, varray()); ADDFUNC0R(ARRAY, NIL, Array, min, varray()); diff --git a/core/variant_parser.cpp b/core/variant_parser.cpp index 07212ec669..fe2c981c3c 100644 --- a/core/variant_parser.cpp +++ b/core/variant_parser.cpp @@ -1522,7 +1522,7 @@ Error VariantParser::parse_tag_assign_eof(Stream *p_stream, int &line, String &r return err; if (tk.type != TK_STRING) { r_err_str = "Error reading quoted string"; - return err; + return ERR_INVALID_DATA; } what = tk.value; diff --git a/doc/classes/AcceptDialog.xml b/doc/classes/AcceptDialog.xml index 980adb4fca..8acaaa4819 100644 --- a/doc/classes/AcceptDialog.xml +++ b/doc/classes/AcceptDialog.xml @@ -67,6 +67,7 @@ <member name="dialog_text" type="String" setter="set_text" getter="get_text" default=""""> The text displayed by the dialog. </member> + <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Alert!"" /> </members> <signals> <signal name="confirmed"> diff --git a/doc/classes/AnimatedTexture.xml b/doc/classes/AnimatedTexture.xml index 2d3ebac78c..5c43ce4d74 100644 --- a/doc/classes/AnimatedTexture.xml +++ b/doc/classes/AnimatedTexture.xml @@ -61,6 +61,7 @@ </method> </methods> <members> + <member name="flags" type="int" setter="set_flags" getter="get_flags" override="true" default="0" /> <member name="fps" type="float" setter="set_fps" getter="get_fps" default="4.0"> Animation speed in frames per second. This value defines the default time interval between two frames of the animation, and thus the overall duration of the animation loop based on the [member frames] property. A value of 0 means no predefined number of frames per second, the animation will play according to each frame's frame delay (see [method set_frame_delay]). For example, an animation with 8 frames, no frame delay and a [code]fps[/code] value of 2 will run for 4 seconds, with each frame lasting 0.5 seconds. diff --git a/doc/classes/AnimationNodeStateMachinePlayback.xml b/doc/classes/AnimationNodeStateMachinePlayback.xml index ab9652fcd8..09cd369bc4 100644 --- a/doc/classes/AnimationNodeStateMachinePlayback.xml +++ b/doc/classes/AnimationNodeStateMachinePlayback.xml @@ -60,6 +60,9 @@ </description> </method> </methods> + <members> + <member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" override="true" default="true" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/Array.xml b/doc/classes/Array.xml index 130908b842..a1529f3eb3 100644 --- a/doc/classes/Array.xml +++ b/doc/classes/Array.xml @@ -304,6 +304,21 @@ Returns the number of elements in the array. </description> </method> + <method name="slice"> + <return type="Array"> + </return> + <argument index="0" name="begin" type="int"> + </argument> + <argument index="1" name="end" type="int"> + </argument> + <argument index="2" name="step" type="int" default="1"> + </argument> + <argument index="3" name="deep" type="bool" default="False"> + </argument> + <description> + Duplicates the subset described in the function and returns it in an array, deeply copying the array if [code]deep[/code] is true. Lower and upper index are inclusive, with the [code]step[/code] describing the change between indices while slicing. + </description> + </method> <method name="sort"> <description> Sorts the array. diff --git a/doc/classes/AtlasTexture.xml b/doc/classes/AtlasTexture.xml index b270c7e279..db6ac1bc6d 100644 --- a/doc/classes/AtlasTexture.xml +++ b/doc/classes/AtlasTexture.xml @@ -17,6 +17,7 @@ <member name="filter_clip" type="bool" setter="set_filter_clip" getter="has_filter_clip" default="false"> If [code]true[/code], clips the area outside of the region to avoid bleeding of the surrounding texture pixels. </member> + <member name="flags" type="int" setter="set_flags" getter="get_flags" override="true" default="0" /> <member name="margin" type="Rect2" setter="set_margin" getter="get_margin" default="Rect2( 0, 0, 0, 0 )"> The margin around the region. The [Rect2]'s [member Rect2.size] parameter ("w" and "h" in the editor) resizes the texture so it fits within the margin. </member> diff --git a/doc/classes/BaseButton.xml b/doc/classes/BaseButton.xml index 9d1c80d3be..b4f4b21afd 100644 --- a/doc/classes/BaseButton.xml +++ b/doc/classes/BaseButton.xml @@ -54,6 +54,7 @@ <member name="enabled_focus_mode" type="int" setter="set_enabled_focus_mode" getter="get_enabled_focus_mode" enum="Control.FocusMode" default="2"> Focus access mode to use when switching between enabled/disabled (see [member Control.focus_mode] and [member disabled]). </member> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> <member name="group" type="ButtonGroup" setter="set_button_group" getter="get_button_group"> [ButtonGroup] associated to the button. </member> diff --git a/doc/classes/BoxContainer.xml b/doc/classes/BoxContainer.xml index 77db8b74db..ae0a20b8f6 100644 --- a/doc/classes/BoxContainer.xml +++ b/doc/classes/BoxContainer.xml @@ -23,6 +23,7 @@ <member name="alignment" type="int" setter="set_alignment" getter="get_alignment" enum="BoxContainer.AlignMode" default="0"> The alignment of the container's children (must be one of [constant ALIGN_BEGIN], [constant ALIGN_CENTER] or [constant ALIGN_END]). </member> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="1" /> </members> <constants> <constant name="ALIGN_BEGIN" value="0" enum="AlignMode"> diff --git a/doc/classes/ButtonGroup.xml b/doc/classes/ButtonGroup.xml index cd2a8d7307..2c1f3163e0 100644 --- a/doc/classes/ButtonGroup.xml +++ b/doc/classes/ButtonGroup.xml @@ -25,6 +25,9 @@ </description> </method> </methods> + <members> + <member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" override="true" default="true" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/CameraTexture.xml b/doc/classes/CameraTexture.xml index 15da46885f..e2bff76998 100644 --- a/doc/classes/CameraTexture.xml +++ b/doc/classes/CameraTexture.xml @@ -17,6 +17,7 @@ <member name="camera_is_active" type="bool" setter="set_camera_active" getter="get_camera_active" default="false"> Convenience property that gives access to the active property of the [CameraFeed]. </member> + <member name="flags" type="int" setter="set_flags" getter="get_flags" override="true" default="0" /> <member name="which_feed" type="int" setter="set_which_feed" getter="get_which_feed" enum="CameraServer.FeedImage" default="0"> Which image within the [CameraFeed] we want access to, important if the camera image is split in a Y and CbCr component. </member> diff --git a/doc/classes/CharFXTransform.xml b/doc/classes/CharFXTransform.xml new file mode 100644 index 0000000000..e03229abe1 --- /dev/null +++ b/doc/classes/CharFXTransform.xml @@ -0,0 +1,41 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="CharFXTransform" inherits="Reference" category="Core" version="3.2"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_value_or"> + <return type="Variant"> + </return> + <argument index="0" name="key" type="String"> + </argument> + <argument index="1" name="default_value" type="Variant"> + </argument> + <description> + </description> + </method> + </methods> + <members> + <member name="absolute_index" type="int" setter="set_absolute_index" getter="get_absolute_index" default="0"> + </member> + <member name="character" type="int" setter="set_character" getter="get_character" default="0"> + </member> + <member name="color" type="Color" setter="set_color" getter="get_color" default="Color( 0, 0, 0, 1 )"> + </member> + <member name="elapsed_time" type="float" setter="set_elapsed_time" getter="get_elapsed_time" default="0.0"> + </member> + <member name="env" type="Dictionary" setter="set_environment" getter="get_environment" default="{}"> + </member> + <member name="offset" type="Vector2" setter="set_offset" getter="get_offset" default="Vector2( 0, 0 )"> + </member> + <member name="relative_index" type="int" setter="set_relative_index" getter="get_relative_index" default="0"> + </member> + <member name="visible" type="bool" setter="set_visibility" getter="is_visible" default="true"> + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/CheckBox.xml b/doc/classes/CheckBox.xml index 93c42a85a3..97ef4dbe95 100644 --- a/doc/classes/CheckBox.xml +++ b/doc/classes/CheckBox.xml @@ -10,6 +10,10 @@ </tutorials> <methods> </methods> + <members> + <member name="align" type="int" setter="set_text_align" getter="get_text_align" override="true" enum="Button.TextAlign" default="0" /> + <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> + </members> <constants> </constants> <theme_items> diff --git a/doc/classes/CheckButton.xml b/doc/classes/CheckButton.xml index 4744894fc1..5b867b6a3a 100644 --- a/doc/classes/CheckButton.xml +++ b/doc/classes/CheckButton.xml @@ -10,6 +10,10 @@ </tutorials> <methods> </methods> + <members> + <member name="align" type="int" setter="set_text_align" getter="get_text_align" override="true" enum="Button.TextAlign" default="0" /> + <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> + </members> <constants> </constants> <theme_items> diff --git a/doc/classes/ColorPickerButton.xml b/doc/classes/ColorPickerButton.xml index 7aeae61ebf..e8c78fb6bf 100644 --- a/doc/classes/ColorPickerButton.xml +++ b/doc/classes/ColorPickerButton.xml @@ -31,6 +31,7 @@ <member name="edit_alpha" type="bool" setter="set_edit_alpha" getter="is_editing_alpha" default="true"> If [code]true[/code], the alpha channel in the displayed [ColorPicker] will be visible. </member> + <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> </members> <signals> <signal name="color_changed"> @@ -40,6 +41,10 @@ Emitted when the color changes. </description> </signal> + <signal name="picker_created"> + <description> + </description> + </signal> <signal name="popup_closed"> <description> </description> diff --git a/doc/classes/ConfirmationDialog.xml b/doc/classes/ConfirmationDialog.xml index 6124bc29b0..8a8d1ed9e8 100644 --- a/doc/classes/ConfirmationDialog.xml +++ b/doc/classes/ConfirmationDialog.xml @@ -17,6 +17,10 @@ </description> </method> </methods> + <members> + <member name="rect_min_size" type="Vector2" setter="set_custom_minimum_size" getter="get_custom_minimum_size" override="true" default="Vector2( 200, 70 )" /> + <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Please Confirm..."" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/Crypto.xml b/doc/classes/Crypto.xml index bb852f5fff..4ec405f96c 100644 --- a/doc/classes/Crypto.xml +++ b/doc/classes/Crypto.xml @@ -1,8 +1,27 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="Crypto" inherits="Reference" category="Core" version="3.2"> <brief_description> + Access to advanced cryptographic functionalities. </brief_description> <description> + The Crypto class allows you to access some more advanced cryptographic functionalities in Godot. + For now, this includes generating cryptographically secure random bytes, and RSA keys and self-signed X509 certificates generation. More functionalities are planned for future releases. + [codeblock] + extends Node + + var crypto = Crypto.new() + var key = CryptoKey.new() + var cert = X509Certificate.new() + + func _ready(): + # Generate new RSA key. + key = crypto.generate_rsa(4096) + # Generate new self-signed certificate with the given key. + cert = crypto.generate_self_signed_certificate(key, "CN=mydomain.com,O=My Game Company,C=IT") + # Save key and certificate in the user folder. + key.save("user://generated.key") + cert.save("user://generated.crt") + [/codeblock] </description> <tutorials> </tutorials> @@ -13,6 +32,7 @@ <argument index="0" name="size" type="int"> </argument> <description> + Generates a [PoolByteArray] of cryptographically secure random bytes with given [code]size[/code]. </description> </method> <method name="generate_rsa"> @@ -21,6 +41,7 @@ <argument index="0" name="size" type="int"> </argument> <description> + Generates an RSA [CryptoKey] that can be used for creating self-signed certificates and passed to [method StreamPeerSSL.acccept_stream]. </description> </method> <method name="generate_self_signed_certificate"> @@ -35,6 +56,15 @@ <argument index="3" name="not_after" type="String" default=""20340101000000""> </argument> <description> + Generates a self-signed [X509Certificate] from the given [CryptoKey] and [code]issuer_name[/code]. The certificate validity will be defined by [code]not_before[/code] and [code]not_after[/code] (first valid date and last valid date). The [code]issuer_name[/code] must contain at least "CN=" (common name, i.e. the domain name), "O=" (organization, i.e. your company name), "C=" (country, i.e. 2 lettered ISO-3166 code of the country the organization is based in). + A small example to generate an RSA key and a X509 self-signed certificate. + [codeblock] + var crypto = Crypto.new() + # Generate 4096 bits RSA key. + var key = crypto.generate_rsa(4096) + # Generate self-signed certificate using the given key. + var cert = crypto.generate_self_signed_certificate(key, "CN=example.com,O=A Game Company,C=IT") + [/codeblock] </description> </method> </methods> diff --git a/doc/classes/CryptoKey.xml b/doc/classes/CryptoKey.xml index d3cd485a5f..6db6fea779 100644 --- a/doc/classes/CryptoKey.xml +++ b/doc/classes/CryptoKey.xml @@ -1,8 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="CryptoKey" inherits="Resource" category="Core" version="3.2"> <brief_description> + A cryptographic key (RSA). </brief_description> <description> + The CryptoKey class represents a cryptographic key. Keys can be loaded and saved like any other [Resource]. + They can be used to generate a self-signed [X509Certificate] via [method Crypto.generate_self_signed] and as private key in [method StreamPeerSSL.accept_stream] along with the appropriate certificate. </description> <tutorials> </tutorials> @@ -13,6 +16,7 @@ <argument index="0" name="path" type="String"> </argument> <description> + Loads a key from [code]path[/code] ("*.key" file). </description> </method> <method name="save"> @@ -21,6 +25,7 @@ <argument index="0" name="path" type="String"> </argument> <description> + Saves a key to the given [code]path[/code] (should be a "*.key" file). </description> </method> </methods> diff --git a/doc/classes/DirectionalLight.xml b/doc/classes/DirectionalLight.xml index 687e7519b2..502256ae63 100644 --- a/doc/classes/DirectionalLight.xml +++ b/doc/classes/DirectionalLight.xml @@ -39,6 +39,7 @@ <member name="directional_shadow_split_3" type="float" setter="set_param" getter="get_param" default="0.5"> The distance from shadow split 2 to split 3. Relative to [member directional_shadow_max_distance]. Only used when [member directional_shadow_mode] is [code]SHADOW_PARALLEL_4_SPLITS[/code]. </member> + <member name="shadow_bias" type="float" setter="set_param" getter="get_param" override="true" default="0.1" /> </members> <constants> <constant name="SHADOW_ORTHOGONAL" value="0" enum="ShadowMode"> diff --git a/doc/classes/EditorFeatureProfile.xml b/doc/classes/EditorFeatureProfile.xml index 21da9fd454..92622cc25d 100644 --- a/doc/classes/EditorFeatureProfile.xml +++ b/doc/classes/EditorFeatureProfile.xml @@ -36,7 +36,7 @@ </return> <argument index="0" name="class_name" type="String"> </argument> - <argument index="1" name="arg1" type="String"> + <argument index="1" name="property" type="String"> </argument> <description> </description> @@ -92,7 +92,7 @@ </argument> <argument index="1" name="property" type="String"> </argument> - <argument index="2" name="arg2" type="bool"> + <argument index="2" name="disable" type="bool"> </argument> <description> </description> diff --git a/doc/classes/EditorFileDialog.xml b/doc/classes/EditorFileDialog.xml index c9f55afbaf..6b1215949a 100644 --- a/doc/classes/EditorFileDialog.xml +++ b/doc/classes/EditorFileDialog.xml @@ -52,6 +52,7 @@ <member name="current_path" type="String" setter="set_current_path" getter="get_current_path" default=""res://""> The file system path in the address bar. </member> + <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" override="true" default="false" /> <member name="disable_overwrite_warning" type="bool" setter="set_disable_overwrite_warning" getter="is_overwrite_warning_disabled" default="false"> If [code]true[/code], the [EditorFileDialog] will not warn the user before overwriting files. </member> @@ -61,9 +62,11 @@ <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="EditorFileDialog.Mode" default="4"> The purpose of the [EditorFileDialog], which defines the allowed behaviors. </member> + <member name="resizable" type="bool" setter="set_resizable" getter="get_resizable" override="true" default="true" /> <member name="show_hidden_files" type="bool" setter="set_show_hidden_files" getter="is_showing_hidden_files" default="false"> If [code]true[/code], hidden files and directories will be visible in the [EditorFileDialog]. </member> + <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Save a File"" /> </members> <signals> <signal name="dir_selected"> diff --git a/doc/classes/EditorInspector.xml b/doc/classes/EditorInspector.xml index cf14183099..450d2bf64c 100644 --- a/doc/classes/EditorInspector.xml +++ b/doc/classes/EditorInspector.xml @@ -14,6 +14,9 @@ </description> </method> </methods> + <members> + <member name="scroll_horizontal_enabled" type="bool" setter="set_enable_h_scroll" getter="is_h_scroll_enabled" override="true" default="false" /> + </members> <signals> <signal name="object_id_selected"> <argument index="0" name="id" type="int"> diff --git a/doc/classes/EditorInterface.xml b/doc/classes/EditorInterface.xml index 4f7a6d89a9..20ae0f3391 100644 --- a/doc/classes/EditorInterface.xml +++ b/doc/classes/EditorInterface.xml @@ -25,6 +25,12 @@ Returns the main container of Godot editor's window. You can use it, for example, to retrieve the size of the container and place your controls accordingly. </description> </method> + <method name="get_current_path" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> <method name="get_edited_scene_root"> <return type="Node"> </return> diff --git a/doc/classes/EditorSpatialGizmo.xml b/doc/classes/EditorSpatialGizmo.xml index 03a274e23e..22e4a21757 100644 --- a/doc/classes/EditorSpatialGizmo.xml +++ b/doc/classes/EditorSpatialGizmo.xml @@ -62,7 +62,7 @@ </argument> <argument index="1" name="billboard" type="bool" default="false"> </argument> - <argument index="2" name="skeleton" type="RID"> + <argument index="2" name="skeleton" type="SkinReference" default="null"> </argument> <argument index="3" name="material" type="Material" default="null"> </argument> diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 4f1e8cc309..d8f4ca21c8 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -67,6 +67,7 @@ <member name="current_path" type="String" setter="set_current_path" getter="get_current_path" default=""res://""> The currently selected file path of the file dialog. </member> + <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" override="true" default="false" /> <member name="filters" type="PoolStringArray" setter="set_filters" getter="get_filters" default="PoolStringArray( )"> The available file type filters. For example, this shows only [code].png[/code] and [code].gd[/code] files: [code]set_filters(PoolStringArray(["*.png ; PNG Images","*.gd ; GDScript Files"]))[/code]. </member> @@ -79,6 +80,7 @@ <member name="show_hidden_files" type="bool" setter="set_show_hidden_files" getter="is_showing_hidden_files" default="false"> If [code]true[/code], the dialog will show hidden files. </member> + <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Save a File"" /> </members> <signals> <signal name="dir_selected"> diff --git a/doc/classes/GraphEdit.xml b/doc/classes/GraphEdit.xml index 3cc40b7cef..80e9b152ef 100644 --- a/doc/classes/GraphEdit.xml +++ b/doc/classes/GraphEdit.xml @@ -171,6 +171,8 @@ </method> </methods> <members> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> + <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" /> <member name="right_disconnects" type="bool" setter="set_right_disconnects" getter="is_right_disconnects_enabled" default="false"> If [code]true[/code], enables disconnection of existing connections in the GraphEdit by dragging the right end. </member> diff --git a/doc/classes/GridContainer.xml b/doc/classes/GridContainer.xml index 08832c08b4..7656a579af 100644 --- a/doc/classes/GridContainer.xml +++ b/doc/classes/GridContainer.xml @@ -14,6 +14,7 @@ <member name="columns" type="int" setter="set_columns" getter="get_columns" default="1"> The number of columns in the [GridContainer]. If modified, [GridContainer] reorders its children to accommodate the new layout. </member> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="1" /> </members> <constants> </constants> diff --git a/doc/classes/HashingContext.xml b/doc/classes/HashingContext.xml index 552a74eba4..802b186ef3 100644 --- a/doc/classes/HashingContext.xml +++ b/doc/classes/HashingContext.xml @@ -1,8 +1,32 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="HashingContext" inherits="Reference" category="Core" version="3.2"> <brief_description> + Context to compute cryptographic hashes over multiple iterations. </brief_description> <description> + The HashingContext class provides an interface for computing cryptographic hashes over multiple iterations. This is useful for example when computing hashes of big files (so you don't have to load them all in memory), network streams, and data streams in general (so you don't have to hold buffers). + The [enum HashType] enum shows the supported hashing algorithms. + [codeblock] + const CHUNK_SIZE = 1024 + + func hash_file(path): + var ctx = HashingContext.new() + var file = File.new() + # Start a SHA-256 context. + ctx.start(HashingContext.HASH_SHA256) + # Check that file exists. + if not file.file_exists(path): + return + # Open the file to hash. + file.open(path, File.READ) + # Update the context after reading each chunk. + while not file.eof_reached(): + ctx.update(file.get_buffer(CHUNK_SIZE)) + # Get the computed hash. + var res = ctx.finish() + # Print the result as hex string and array. + printt(res.hex_encode(), Array(res)) + [/codeblock] </description> <tutorials> </tutorials> @@ -11,6 +35,7 @@ <return type="PoolByteArray"> </return> <description> + Closes the current context, and return the computed hash. </description> </method> <method name="start"> @@ -19,6 +44,7 @@ <argument index="0" name="type" type="int" enum="HashingContext.HashType"> </argument> <description> + Starts a new hash computation of the given [code]type[/code] (e.g. [constant HASH_SHA256] to start computation of a SHA-256). </description> </method> <method name="update"> @@ -27,15 +53,19 @@ <argument index="0" name="chunk" type="PoolByteArray"> </argument> <description> + Updates the computation with the given [code]chunk[/code] of data. </description> </method> </methods> <constants> <constant name="HASH_MD5" value="0" enum="HashType"> + Hashing algorithm: MD5. </constant> <constant name="HASH_SHA1" value="1" enum="HashType"> + Hashing algorithm: SHA-1. </constant> <constant name="HASH_SHA256" value="2" enum="HashType"> + Hashing algorithm: SHA-256. </constant> </constants> </class> diff --git a/doc/classes/ImageTexture.xml b/doc/classes/ImageTexture.xml index 0a09b96ba7..03bf739760 100644 --- a/doc/classes/ImageTexture.xml +++ b/doc/classes/ImageTexture.xml @@ -72,6 +72,7 @@ </method> </methods> <members> + <member name="flags" type="int" setter="set_flags" getter="get_flags" override="true" default="7" /> <member name="lossy_quality" type="float" setter="set_lossy_storage_quality" getter="get_lossy_storage_quality" default="0.7"> The storage quality for [constant STORAGE_COMPRESS_LOSSY]. </member> diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index 8515d1063d..c82d6a27c0 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -414,6 +414,7 @@ <member name="fixed_icon_size" type="Vector2" setter="set_fixed_icon_size" getter="get_fixed_icon_size" default="Vector2( 0, 0 )"> Sets the default icon size in pixels. </member> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> <member name="icon_mode" type="int" setter="set_icon_mode" getter="get_icon_mode" enum="ItemList.IconMode" default="1"> Sets the default position of the icon to either [constant ICON_MODE_LEFT] or [constant ICON_MODE_TOP]. </member> @@ -425,6 +426,7 @@ </member> <member name="max_text_lines" type="int" setter="set_max_text_lines" getter="get_max_text_lines" default="1"> </member> + <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" /> <member name="same_column_width" type="bool" setter="set_same_column_width" getter="is_same_column_width" default="false"> If set to [code]true[/code], all columns will have the same width specified by [member fixed_column_width]. </member> diff --git a/doc/classes/JSONRPC.xml b/doc/classes/JSONRPC.xml index 921161afb4..10d9e5943e 100644 --- a/doc/classes/JSONRPC.xml +++ b/doc/classes/JSONRPC.xml @@ -81,15 +81,15 @@ </method> </methods> <constants> - <constant name="ParseError" value="-32700" enum="ErrorCode"> + <constant name="PARSE_ERROR" value="-32700" enum="ErrorCode"> </constant> - <constant name="InvalidRequest" value="-32600" enum="ErrorCode"> + <constant name="INVALID_REQUEST" value="-32600" enum="ErrorCode"> </constant> - <constant name="MethodNotFound" value="-32601" enum="ErrorCode"> + <constant name="METHOD_NOT_FOUND" value="-32601" enum="ErrorCode"> </constant> - <constant name="InvalidParams" value="-32602" enum="ErrorCode"> + <constant name="INVALID_PARAMS" value="-32602" enum="ErrorCode"> </constant> - <constant name="InternalError" value="-32603" enum="ErrorCode"> + <constant name="INTERNAL_ERROR" value="-32603" enum="ErrorCode"> </constant> </constants> </class> diff --git a/doc/classes/Label.xml b/doc/classes/Label.xml index 72e640adb6..4d1584e9de 100644 --- a/doc/classes/Label.xml +++ b/doc/classes/Label.xml @@ -55,9 +55,11 @@ <member name="max_lines_visible" type="int" setter="set_max_lines_visible" getter="get_max_lines_visible" default="-1"> Limits the lines of text the node shows on screen. </member> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="2" /> <member name="percent_visible" type="float" setter="set_percent_visible" getter="get_percent_visible" default="1.0"> Limits the count of visible characters. If you set [code]percent_visible[/code] to 50, only up to half of the text's characters will display on screen. Useful to animate the text in a dialog box. </member> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="4" /> <member name="text" type="String" setter="set_text" getter="get_text" default=""""> The text to display on screen. </member> diff --git a/doc/classes/LargeTexture.xml b/doc/classes/LargeTexture.xml index b4267f55f0..4dbda34a46 100644 --- a/doc/classes/LargeTexture.xml +++ b/doc/classes/LargeTexture.xml @@ -85,6 +85,9 @@ </description> </method> </methods> + <members> + <member name="flags" type="int" setter="set_flags" getter="get_flags" override="true" default="0" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/LineEdit.xml b/doc/classes/LineEdit.xml index d90a290fdc..de216563d3 100644 --- a/doc/classes/LineEdit.xml +++ b/doc/classes/LineEdit.xml @@ -107,24 +107,30 @@ <member name="expand_to_text_length" type="bool" setter="set_expand_to_text_length" getter="get_expand_to_text_length" default="false"> If [code]true[/code], the [LineEdit] width will increase to stay longer than the [member text]. It will [b]not[/b] compress if the [member text] is shortened. </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" enum="Control.FocusMode" default="2"> - Defines how the [LineEdit] can grab focus (Keyboard and mouse, only keyboard, or none). See [enum Control.FocusMode] for details. - </member> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> <member name="max_length" type="int" setter="set_max_length" getter="get_max_length" default="0"> Maximum amount of characters that can be entered inside the [LineEdit]. If [code]0[/code], there is no limit. </member> + <member name="mouse_default_cursor_shape" type="int" setter="set_default_cursor_shape" getter="get_default_cursor_shape" override="true" enum="Control.CursorShape" default="1" /> <member name="placeholder_alpha" type="float" setter="set_placeholder_alpha" getter="get_placeholder_alpha" default="0.6"> Opacity of the [member placeholder_text]. From [code]0[/code] to [code]1[/code]. </member> <member name="placeholder_text" type="String" setter="set_placeholder" getter="get_placeholder" default=""""> Text shown when the [LineEdit] is empty. It is [b]not[/b] the [LineEdit]'s default value (see [member text]). </member> + <member name="right_icon" type="Texture" setter="set_right_icon" getter="get_right_icon"> + Sets the icon that will appear in the right end of the [LineEdit] if there's no [member text], or always, if [member clear_button_enabled] is set to [code]false[/code]. + </member> <member name="secret" type="bool" setter="set_secret" getter="is_secret" default="false"> If [code]true[/code], every character is replaced with the secret character (see [member secret_character]). </member> <member name="secret_character" type="String" setter="set_secret_character" getter="get_secret_character" default=""*""> The character to use to mask secret input (defaults to "*"). Only a single character can be used as the secret character. </member> + <member name="selecting_enabled" type="bool" setter="set_selecting_enabled" getter="is_selecting_enabled" default="true"> + </member> + <member name="shortcut_keys_enabled" type="bool" setter="set_shortcut_keys_enabled" getter="is_shortcut_keys_enabled" default="true"> + </member> <member name="text" type="String" setter="set_text" getter="get_text" default=""""> String value of the [LineEdit]. </member> diff --git a/doc/classes/LinkButton.xml b/doc/classes/LinkButton.xml index 3e6b5e8c1a..af4c255b92 100644 --- a/doc/classes/LinkButton.xml +++ b/doc/classes/LinkButton.xml @@ -11,6 +11,9 @@ <methods> </methods> <members> + <member name="enabled_focus_mode" type="int" setter="set_enabled_focus_mode" getter="get_enabled_focus_mode" override="true" enum="Control.FocusMode" default="0" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="0" /> + <member name="mouse_default_cursor_shape" type="int" setter="set_default_cursor_shape" getter="get_default_cursor_shape" override="true" enum="Control.CursorShape" default="2" /> <member name="text" type="String" setter="set_text" getter="get_text" default=""""> </member> <member name="underline" type="int" setter="set_underline_mode" getter="get_underline_mode" enum="LinkButton.UnderlineMode" default="0"> diff --git a/doc/classes/MenuButton.xml b/doc/classes/MenuButton.xml index 40d2160baa..52fb4b9ca1 100644 --- a/doc/classes/MenuButton.xml +++ b/doc/classes/MenuButton.xml @@ -26,9 +26,14 @@ </method> </methods> <members> + <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" override="true" enum="BaseButton.ActionMode" default="0" /> + <member name="enabled_focus_mode" type="int" setter="set_enabled_focus_mode" getter="get_enabled_focus_mode" override="true" enum="Control.FocusMode" default="0" /> + <member name="flat" type="bool" setter="set_flat" getter="is_flat" override="true" default="true" /> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="0" /> <member name="switch_on_hover" type="bool" setter="set_switch_on_hover" getter="is_switch_on_hover" default="false"> If [code]true[/code], when the cursor hovers above another MenuButton within the same parent which also has [code]switch_on_hover[/code] enabled, it will close the current MenuButton and open the other one. </member> + <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> </members> <signals> <signal name="about_to_show"> diff --git a/doc/classes/MeshInstance.xml b/doc/classes/MeshInstance.xml index c577635c98..a4d2bb4295 100644 --- a/doc/classes/MeshInstance.xml +++ b/doc/classes/MeshInstance.xml @@ -65,6 +65,8 @@ <member name="skeleton" type="NodePath" setter="set_skeleton_path" getter="get_skeleton_path" default="NodePath("..")"> [NodePath] to the [Skeleton] associated with the instance. </member> + <member name="skin" type="Skin" setter="set_skin" getter="get_skin"> + </member> </members> <constants> </constants> diff --git a/doc/classes/MeshTexture.xml b/doc/classes/MeshTexture.xml index f8e02d1851..2c94014879 100644 --- a/doc/classes/MeshTexture.xml +++ b/doc/classes/MeshTexture.xml @@ -14,6 +14,7 @@ <member name="base_texture" type="Texture" setter="set_base_texture" getter="get_base_texture"> Sets the base texture that the Mesh will use to draw. </member> + <member name="flags" type="int" setter="set_flags" getter="get_flags" override="true" default="0" /> <member name="image_size" type="Vector2" setter="set_image_size" getter="get_image_size" default="Vector2( 0, 0 )"> Sets the size of the image, needed for reference. </member> diff --git a/doc/classes/NinePatchRect.xml b/doc/classes/NinePatchRect.xml index ce7a6ef54c..221a3c22c1 100644 --- a/doc/classes/NinePatchRect.xml +++ b/doc/classes/NinePatchRect.xml @@ -38,6 +38,7 @@ <member name="draw_center" type="bool" setter="set_draw_center" getter="is_draw_center_enabled" default="true"> If [code]true[/code], draw the panel's center. Else, only draw the 9-slice's borders. </member> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="2" /> <member name="patch_margin_bottom" type="int" setter="set_patch_margin" getter="get_patch_margin" default="0"> The height of the 9-slice's bottom row. A margin of 16 means the 9-slice's bottom corners and side will have a height of 16 pixels. You can set all 4 margin values individually to create panels with non-uniform borders. </member> diff --git a/doc/classes/OS.xml b/doc/classes/OS.xml index 938777a36b..9f61245819 100644 --- a/doc/classes/OS.xml +++ b/doc/classes/OS.xml @@ -820,6 +820,7 @@ </argument> <description> Sets the window title to the specified string. + [b]Note:[/b] This should be used sporadically. Don't set this every frame, as that will negatively affect performance on some window managers. </description> </method> <method name="shell_open"> @@ -828,9 +829,10 @@ <argument index="0" name="uri" type="String"> </argument> <description> - Requests the OS to open a resource with the most appropriate program. For example. - [code]OS.shell_open("C:\\Users\name\Downloads")[/code] on Windows opens the file explorer at the downloads folders of the user. - [code]OS.shell_open("https://godotengine.org")[/code] opens the default web browser on the official Godot website. + Requests the OS to open a resource with the most appropriate program. For example: + - [code]OS.shell_open("C:\\Users\name\Downloads")[/code] on Windows opens the file explorer at the user's Downloads folder. + - [code]OS.shell_open("https://godotengine.org")[/code] opens the default web browser on the official Godot website. + - [code]OS.shell_open("mailto:example@example.com")[/code] opens the default email client with the "To" field set to [code]example@example.com[/code]. See [url=https://blog.escapecreative.com/customizing-mailto-links/]Customizing [code]mailto:[/code] Links[/url] for a list of fields that can be added. </description> </method> <method name="show_virtual_keyboard"> diff --git a/doc/classes/OptionButton.xml b/doc/classes/OptionButton.xml index 0c2566e845..b3f1359e69 100644 --- a/doc/classes/OptionButton.xml +++ b/doc/classes/OptionButton.xml @@ -197,8 +197,11 @@ </method> </methods> <members> + <member name="action_mode" type="int" setter="set_action_mode" getter="get_action_mode" override="true" enum="BaseButton.ActionMode" default="0" /> + <member name="align" type="int" setter="set_text_align" getter="get_text_align" override="true" enum="Button.TextAlign" default="0" /> <member name="selected" type="int" setter="_select_int" getter="get_selected" default="-1"> </member> + <member name="toggle_mode" type="bool" setter="set_toggle_mode" getter="is_toggle_mode" override="true" default="true" /> </members> <signals> <signal name="item_focused"> diff --git a/doc/classes/ParallaxBackground.xml b/doc/classes/ParallaxBackground.xml index 2778707577..d4f3462016 100644 --- a/doc/classes/ParallaxBackground.xml +++ b/doc/classes/ParallaxBackground.xml @@ -11,6 +11,7 @@ <methods> </methods> <members> + <member name="layer" type="int" setter="set_layer" getter="get_layer" override="true" default="-100" /> <member name="scroll_base_offset" type="Vector2" setter="set_scroll_base_offset" getter="get_scroll_base_offset" default="Vector2( 0, 0 )"> The base position offset for all [ParallaxLayer] children. </member> diff --git a/doc/classes/Path2D.xml b/doc/classes/Path2D.xml index b49a3d928d..7b37f8e40d 100644 --- a/doc/classes/Path2D.xml +++ b/doc/classes/Path2D.xml @@ -15,6 +15,7 @@ <member name="curve" type="Curve2D" setter="set_curve" getter="get_curve"> A [Curve2D] describing the path. </member> + <member name="self_modulate" type="Color" setter="set_self_modulate" getter="get_self_modulate" override="true" default="Color( 0.5, 0.6, 1, 0.7 )" /> </members> <constants> </constants> diff --git a/doc/classes/PhysicsBody2D.xml b/doc/classes/PhysicsBody2D.xml index 076131357b..4fe7c329bd 100644 --- a/doc/classes/PhysicsBody2D.xml +++ b/doc/classes/PhysicsBody2D.xml @@ -85,6 +85,7 @@ <member name="collision_mask" type="int" setter="set_collision_mask" getter="get_collision_mask" default="1"> The physics layers this area scans for collisions. </member> + <member name="input_pickable" type="bool" setter="set_pickable" getter="is_pickable" override="true" default="false" /> <member name="layers" type="int" setter="_set_layers" getter="_get_layers"> Both [member collision_layer] and [member collision_mask]. Returns [member collision_layer] when accessed. Updates [member collision_layer] and [member collision_mask] when modified. </member> diff --git a/doc/classes/Popup.xml b/doc/classes/Popup.xml index fb8168c344..2357ee2469 100644 --- a/doc/classes/Popup.xml +++ b/doc/classes/Popup.xml @@ -68,6 +68,7 @@ <member name="popup_exclusive" type="bool" setter="set_exclusive" getter="is_exclusive" default="false"> If [code]true[/code], the popup will not be hidden when a click event occurs outside of it, or when it receives the [code]ui_cancel[/code] action event. </member> + <member name="visible" type="bool" setter="set_visible" getter="is_visible" override="true" default="false" /> </members> <signals> <signal name="about_to_show"> diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index d917f7d7f8..d9400088dd 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -553,6 +553,7 @@ <member name="allow_search" type="bool" setter="set_allow_search" getter="get_allow_search" default="false"> If [code]true[/code], allows to navigate [PopupMenu] with letter keys. </member> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> <member name="hide_on_checkable_item_selection" type="bool" setter="set_hide_on_checkable_item_selection" getter="is_hide_on_checkable_item_selection" default="true"> If [code]true[/code], hides the [PopupMenu] when a checkbox or radio button is selected. </member> diff --git a/doc/classes/ProgressBar.xml b/doc/classes/ProgressBar.xml index 96d377fd5e..d489fd8bca 100644 --- a/doc/classes/ProgressBar.xml +++ b/doc/classes/ProgressBar.xml @@ -14,6 +14,8 @@ <member name="percent_visible" type="bool" setter="set_percent_visible" getter="is_percent_visible" default="true"> If [code]true[/code], the fill percentage is displayed on the bar. </member> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="0" /> + <member name="step" type="float" setter="set_step" getter="get_step" override="true" default="0.01" /> </members> <constants> </constants> diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index b42a10b13b..3da403c681 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -762,7 +762,7 @@ If [code]true[/code], performs a previous depth pass before rendering materials. This increases performance in scenes with high overdraw, when complex materials and lighting are used. </member> <member name="rendering/quality/directional_shadow/size" type="int" setter="" getter="" default="4096"> - The directional shadow's size in pixels. Higher values will result in sharper shadows, at the cost of performance. + The directional shadow's size in pixels. Higher values will result in sharper shadows, at the cost of performance. The value will be rounded up to the nearest power of 2. </member> <member name="rendering/quality/directional_shadow/size.mobile" type="int" setter="" getter="" default="2048"> </member> diff --git a/doc/classes/ProxyTexture.xml b/doc/classes/ProxyTexture.xml index a36f670c42..36c65f1096 100644 --- a/doc/classes/ProxyTexture.xml +++ b/doc/classes/ProxyTexture.xml @@ -11,6 +11,7 @@ <members> <member name="base" type="Texture" setter="set_base" getter="get_base"> </member> + <member name="flags" type="int" setter="set_flags" getter="get_flags" override="true" default="0" /> </members> <constants> </constants> diff --git a/doc/classes/RichTextEffect.xml b/doc/classes/RichTextEffect.xml new file mode 100644 index 0000000000..5c3ffd9cff --- /dev/null +++ b/doc/classes/RichTextEffect.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="RichTextEffect" inherits="Resource" category="Core" version="3.2"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="_process_custom_fx" qualifiers="virtual"> + <return type="bool"> + </return> + <argument index="0" name="char_fx" type="CharFXTransform"> + </argument> + <description> + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/RichTextLabel.xml b/doc/classes/RichTextLabel.xml index 81f5f44866..faf2ac1ff9 100644 --- a/doc/classes/RichTextLabel.xml +++ b/doc/classes/RichTextLabel.xml @@ -80,6 +80,14 @@ Returns the number of visible lines. </description> </method> + <method name="install_effect"> + <return type="void"> + </return> + <argument index="0" name="effect" type="Variant"> + </argument> + <description> + </description> + </method> <method name="newline"> <return type="void"> </return> @@ -96,6 +104,14 @@ The assignment version of [method append_bbcode]. Clears the tag stack and inserts the new content. Returns [constant OK] if parses [code]bbcode[/code] successfully. </description> </method> + <method name="parse_expressions_for_values"> + <return type="Dictionary"> + </return> + <argument index="0" name="expressions" type="PoolStringArray"> + </argument> + <description> + </description> + </method> <method name="pop"> <return type="void"> </return> @@ -228,6 +244,8 @@ <member name="bbcode_text" type="String" setter="set_bbcode" getter="get_bbcode" default=""""> 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="custom_effects" type="Array" setter="set_effects" getter="get_effects" default="[ ]"> + </member> <member name="meta_underlined" type="bool" setter="set_meta_underline" getter="is_meta_underlined" default="true"> If [code]true[/code], the label underlines meta tags such as [code][url]{text}[/url][/code]. </member> @@ -237,6 +255,7 @@ <member name="percent_visible" type="float" setter="set_percent_visible" getter="get_percent_visible" default="1.0"> The text's visibility, as a [float] between 0.0 and 1.0. </member> + <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" /> <member name="scroll_active" type="bool" setter="set_scroll_active" getter="is_scroll_active" default="true"> If [code]true[/code], the scrollbar is visible. Does not block scrolling completely. See [method scroll_to_line]. </member> @@ -319,7 +338,19 @@ </constant> <constant name="ITEM_TABLE" value="11" enum="ItemType"> </constant> - <constant name="ITEM_META" value="12" enum="ItemType"> + <constant name="ITEM_FADE" value="12" enum="ItemType"> + </constant> + <constant name="ITEM_SHAKE" value="13" enum="ItemType"> + </constant> + <constant name="ITEM_WAVE" value="14" enum="ItemType"> + </constant> + <constant name="ITEM_TORNADO" value="15" enum="ItemType"> + </constant> + <constant name="ITEM_RAINBOW" value="16" enum="ItemType"> + </constant> + <constant name="ITEM_CUSTOMFX" value="18" enum="ItemType"> + </constant> + <constant name="ITEM_META" value="17" enum="ItemType"> </constant> </constants> <theme_items> diff --git a/doc/classes/Script.xml b/doc/classes/Script.xml index fca73e3ea7..e8a88acdb5 100644 --- a/doc/classes/Script.xml +++ b/doc/classes/Script.xml @@ -32,6 +32,38 @@ Returns the script's base type. </description> </method> + <method name="get_property_default_value"> + <return type="Variant"> + </return> + <argument index="0" name="property" type="String"> + </argument> + <description> + </description> + </method> + <method name="get_script_constant_map"> + <return type="Dictionary"> + </return> + <description> + </description> + </method> + <method name="get_script_method_list"> + <return type="Array"> + </return> + <description> + </description> + </method> + <method name="get_script_property_list"> + <return type="Array"> + </return> + <description> + </description> + </method> + <method name="get_script_signal_list"> + <return type="Array"> + </return> + <description> + </description> + </method> <method name="has_script_signal" qualifiers="const"> <return type="bool"> </return> diff --git a/doc/classes/ScriptCreateDialog.xml b/doc/classes/ScriptCreateDialog.xml index def2fa944a..30d67d47f3 100644 --- a/doc/classes/ScriptCreateDialog.xml +++ b/doc/classes/ScriptCreateDialog.xml @@ -29,6 +29,13 @@ </description> </method> </methods> + <members> + <member name="dialog_hide_on_ok" type="bool" setter="set_hide_on_ok" getter="get_hide_on_ok" override="true" default="false" /> + <member name="margin_bottom" type="float" setter="set_margin" getter="get_margin" override="true" default="76.0" /> + <member name="margin_right" type="float" setter="set_margin" getter="get_margin" override="true" default="200.0" /> + <member name="rect_size" type="Vector2" setter="_set_size" getter="get_size" override="true" default="Vector2( 200, 76 )" /> + <member name="window_title" type="String" setter="set_title" getter="get_title" override="true" default=""Attach Node Script"" /> + </members> <signals> <signal name="script_created"> <argument index="0" name="script" type="Script"> diff --git a/doc/classes/ScrollBar.xml b/doc/classes/ScrollBar.xml index 29bc85cc56..ea30b9d48c 100644 --- a/doc/classes/ScrollBar.xml +++ b/doc/classes/ScrollBar.xml @@ -13,6 +13,8 @@ <members> <member name="custom_step" type="float" setter="set_custom_step" getter="get_custom_step" default="-1.0"> </member> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="0" /> + <member name="step" type="float" setter="set_step" getter="get_step" override="true" default="0.0" /> </members> <signals> <signal name="scrolling"> diff --git a/doc/classes/ScrollContainer.xml b/doc/classes/ScrollContainer.xml index 59e8d566cf..5218b65886 100644 --- a/doc/classes/ScrollContainer.xml +++ b/doc/classes/ScrollContainer.xml @@ -23,6 +23,7 @@ </method> </methods> <members> + <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" /> <member name="scroll_deadzone" type="int" setter="set_deadzone" getter="get_deadzone" default="0"> </member> <member name="scroll_horizontal" type="int" setter="set_h_scroll" getter="get_h_scroll" default="0"> diff --git a/doc/classes/Skeleton.xml b/doc/classes/Skeleton.xml index 8b17928f90..27a78cd7d1 100644 --- a/doc/classes/Skeleton.xml +++ b/doc/classes/Skeleton.xml @@ -54,15 +54,6 @@ Returns the amount of bones in the skeleton. </description> </method> - <method name="get_bone_custom_pose" qualifiers="const"> - <return type="Transform"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> - <description> - Returns the custom pose of the specified bone. Custom pose is applied on top of the rest pose. - </description> - </method> <method name="get_bone_global_pose" qualifiers="const"> <return type="Transform"> </return> @@ -109,15 +100,6 @@ Returns the rest transform for a bone [code]bone_idx[/code]. </description> </method> - <method name="get_bone_transform" qualifiers="const"> - <return type="Transform"> - </return> - <argument index="0" name="bone_idx" type="int"> - </argument> - <description> - Returns the combination of custom pose and pose. The returned transform is in skeleton's reference frame. - </description> - </method> <method name="get_bound_child_nodes_to_bone" qualifiers="const"> <return type="Array"> </return> @@ -171,12 +153,10 @@ <description> </description> </method> - <method name="set_bone_custom_pose"> - <return type="void"> + <method name="register_skin"> + <return type="SkinReference"> </return> - <argument index="0" name="bone_idx" type="int"> - </argument> - <argument index="1" name="custom_pose" type="Transform"> + <argument index="0" name="skin" type="Skin"> </argument> <description> </description> @@ -191,22 +171,16 @@ <description> </description> </method> - <method name="set_bone_global_pose"> + <method name="set_bone_global_pose_override"> <return type="void"> </return> <argument index="0" name="bone_idx" type="int"> </argument> <argument index="1" name="pose" type="Transform"> </argument> - <description> - </description> - </method> - <method name="set_bone_ignore_animation"> - <return type="void"> - </return> - <argument index="0" name="bone" type="int"> + <argument index="2" name="amount" type="float"> </argument> - <argument index="1" name="ignore" type="bool"> + <argument index="3" name="persistent" type="bool" default="false"> </argument> <description> </description> @@ -265,10 +239,6 @@ </description> </method> </methods> - <members> - <member name="bones_in_world_transform" type="bool" setter="set_use_bones_in_world_transform" getter="is_using_bones_in_world_transform" default="false"> - </member> - </members> <constants> <constant name="NOTIFICATION_UPDATE_SKELETON" value="50"> </constant> diff --git a/doc/classes/Skin.xml b/doc/classes/Skin.xml new file mode 100644 index 0000000000..174febc883 --- /dev/null +++ b/doc/classes/Skin.xml @@ -0,0 +1,79 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="Skin" inherits="Resource" category="Core" version="3.2"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="add_bind"> + <return type="void"> + </return> + <argument index="0" name="bone" type="int"> + </argument> + <argument index="1" name="pose" type="Transform"> + </argument> + <description> + </description> + </method> + <method name="clear_binds"> + <return type="void"> + </return> + <description> + </description> + </method> + <method name="get_bind_bone" qualifiers="const"> + <return type="int"> + </return> + <argument index="0" name="bind_index" type="int"> + </argument> + <description> + </description> + </method> + <method name="get_bind_count" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> + <method name="get_bind_pose" qualifiers="const"> + <return type="Transform"> + </return> + <argument index="0" name="bind_index" type="int"> + </argument> + <description> + </description> + </method> + <method name="set_bind_bone"> + <return type="void"> + </return> + <argument index="0" name="bind_index" type="int"> + </argument> + <argument index="1" name="bone" type="int"> + </argument> + <description> + </description> + </method> + <method name="set_bind_count"> + <return type="void"> + </return> + <argument index="0" name="bind_count" type="int"> + </argument> + <description> + </description> + </method> + <method name="set_bind_pose"> + <return type="void"> + </return> + <argument index="0" name="bind_index" type="int"> + </argument> + <argument index="1" name="pose" type="Transform"> + </argument> + <description> + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/SkinReference.xml b/doc/classes/SkinReference.xml new file mode 100644 index 0000000000..c12957654f --- /dev/null +++ b/doc/classes/SkinReference.xml @@ -0,0 +1,25 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="SkinReference" inherits="Reference" category="Core" version="3.2"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + <method name="get_skeleton" qualifiers="const"> + <return type="RID"> + </return> + <description> + </description> + </method> + <method name="get_skin" qualifiers="const"> + <return type="Skin"> + </return> + <description> + </description> + </method> + </methods> + <constants> + </constants> +</class> diff --git a/doc/classes/Slider.xml b/doc/classes/Slider.xml index 24ddb95c96..14176da44f 100644 --- a/doc/classes/Slider.xml +++ b/doc/classes/Slider.xml @@ -14,11 +14,11 @@ <member name="editable" type="bool" setter="set_editable" getter="is_editable" default="true"> If [code]true[/code], the slider can be interacted with. If [code]false[/code], the value can be changed only by code. </member> - <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" enum="Control.FocusMode" default="2"> - </member> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> <member name="scrollable" type="bool" setter="set_scrollable" getter="is_scrollable" default="true"> If [code]true[/code], the value can be changed using the mouse wheel. </member> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="0" /> <member name="tick_count" type="int" setter="set_ticks" getter="get_ticks" default="0"> Number of ticks displayed on the slider, including border ticks. Ticks are uniformly-distributed value markers. </member> diff --git a/doc/classes/StreamPeerSSL.xml b/doc/classes/StreamPeerSSL.xml index c960a794e2..b34d8d1b25 100644 --- a/doc/classes/StreamPeerSSL.xml +++ b/doc/classes/StreamPeerSSL.xml @@ -4,7 +4,7 @@ SSL stream peer. </brief_description> <description> - SSL stream peer. This object can be used to connect to SSL servers. + SSL stream peer. This object can be used to connect to an SSL server or accept a single SSL client connection. </description> <tutorials> <link>https://docs.godotengine.org/en/latest/tutorials/networking/ssl_certificates.html</link> @@ -22,6 +22,7 @@ <argument index="3" name="chain" type="X509Certificate" default="null"> </argument> <description> + Accepts a peer connection as a server using the given [code]private_key[/code] and providing the given [code]certificate[/code] to the client. You can pass the optional [code]chain[/code] parameter to provide additional CA chain information along with the certificate. </description> </method> <method name="connect_to_stream"> diff --git a/doc/classes/StreamTexture.xml b/doc/classes/StreamTexture.xml index 9c7adea079..9cc3511b68 100644 --- a/doc/classes/StreamTexture.xml +++ b/doc/classes/StreamTexture.xml @@ -19,6 +19,7 @@ </method> </methods> <members> + <member name="flags" type="int" setter="set_flags" getter="get_flags" override="true" default="0" /> <member name="load_path" type="String" setter="load" getter="get_load_path" default=""""> The StreamTexture's file path to a [code].stex[/code] file. </member> diff --git a/doc/classes/String.xml b/doc/classes/String.xml index f6ec85c87d..03bc2095c0 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -655,6 +655,15 @@ If the string is a path, this concatenates [code]file[/code] at the end of the string as a subpath. E.g. [code]"this/is".plus_file("path") == "this/is/path"[/code]. </description> </method> + <method name="repeat"> + <return type="String"> + </return> + <argument index="0" name="count" type="int"> + </argument> + <description> + Returns original string repeated a number of times. The number of repetitions is given by the argument. + </description> + </method> <method name="replace"> <return type="String"> </return> diff --git a/doc/classes/TabContainer.xml b/doc/classes/TabContainer.xml index 22b009a15a..1b9f38fc54 100644 --- a/doc/classes/TabContainer.xml +++ b/doc/classes/TabContainer.xml @@ -149,6 +149,8 @@ <member name="tabs_visible" type="bool" setter="set_tabs_visible" getter="are_tabs_visible" default="true"> If [code]true[/code], tabs are visible. If [code]false[/code], tabs' content and titles are hidden. </member> + <member name="use_hidden_tabs_for_min_size" type="bool" setter="set_use_hidden_tabs_for_min_size" getter="get_use_hidden_tabs_for_min_size" default="false"> + </member> </members> <signals> <signal name="pre_popup_pressed"> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index fb5f20361b..8a114efd34 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -406,6 +406,7 @@ <member name="draw_tabs" type="bool" setter="set_draw_tabs" getter="is_drawing_tabs" default="false"> If [code]true[/code], the "tab" character will have a visible representation. </member> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> <member name="fold_gutter" type="bool" setter="set_draw_fold_gutter" getter="is_drawing_fold_gutter" default="false"> If [code]true[/code], the fold gutter is visible. This enables folding groups of indented lines. </member> @@ -422,11 +423,16 @@ </member> <member name="minimap_width" type="int" setter="set_minimap_width" getter="get_minimap_width" default="80"> </member> + <member name="mouse_default_cursor_shape" type="int" setter="set_default_cursor_shape" getter="get_default_cursor_shape" override="true" enum="Control.CursorShape" default="1" /> <member name="override_selected_font_color" type="bool" setter="set_override_selected_font_color" getter="is_overriding_selected_font_color" default="false"> </member> <member name="readonly" type="bool" setter="set_readonly" getter="is_readonly" default="false"> If [code]true[/code], read-only mode is enabled. Existing text cannot be modified and new text cannot be added. </member> + <member name="selecting_enabled" type="bool" setter="set_selecting_enabled" getter="is_selecting_enabled" default="true"> + </member> + <member name="shortcut_keys_enabled" type="bool" setter="set_shortcut_keys_enabled" getter="is_shortcut_keys_enabled" default="true"> + </member> <member name="show_line_numbers" type="bool" setter="set_show_line_numbers" getter="is_show_line_numbers_enabled" default="false"> If [code]true[/code], line numbers are displayed to the left of the text. </member> diff --git a/doc/classes/Texture3D.xml b/doc/classes/Texture3D.xml index 30724eed50..c11a48137f 100644 --- a/doc/classes/Texture3D.xml +++ b/doc/classes/Texture3D.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="data" type="Dictionary" setter="_set_data" getter="_get_data" override="true" default="{"depth": 0,"flags": 4,"format": 37,"height": 0,"layers": [ ],"width": 0}" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/TextureProgress.xml b/doc/classes/TextureProgress.xml index 4f8ea6438b..21b294cf90 100644 --- a/doc/classes/TextureProgress.xml +++ b/doc/classes/TextureProgress.xml @@ -32,6 +32,7 @@ <member name="fill_mode" type="int" setter="set_fill_mode" getter="get_fill_mode" default="0"> The fill direction. See [enum FillMode] for possible values. </member> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="1" /> <member name="nine_patch_stretch" type="bool" setter="set_nine_patch_stretch" getter="get_nine_patch_stretch" default="false"> If [code]true[/code], Godot treats the bar's textures like in [NinePatchRect]. Use the [code]stretch_margin_*[/code] properties like [member stretch_margin_bottom] to set up the nine patch's 3×3 grid. </member> diff --git a/doc/classes/TextureRect.xml b/doc/classes/TextureRect.xml index be46459b21..997a686e82 100644 --- a/doc/classes/TextureRect.xml +++ b/doc/classes/TextureRect.xml @@ -20,6 +20,7 @@ <member name="flip_v" type="bool" setter="set_flip_v" getter="is_flipped_v" default="false"> If [code]true[/code], texture is flipped vertically. </member> + <member name="mouse_filter" type="int" setter="set_mouse_filter" getter="get_mouse_filter" override="true" enum="Control.MouseFilter" default="1" /> <member name="stretch_mode" type="int" setter="set_stretch_mode" getter="get_stretch_mode" enum="TextureRect.StretchMode" default="0"> Controls the texture's behavior when resizing the node's bounding rectangle. See [enum StretchMode]. </member> diff --git a/doc/classes/TileMap.xml b/doc/classes/TileMap.xml index efb7a0d900..75eb8b5862 100644 --- a/doc/classes/TileMap.xml +++ b/doc/classes/TileMap.xml @@ -256,7 +256,7 @@ <members> <member name="cell_clip_uv" type="bool" setter="set_clip_uv" getter="get_clip_uv" default="false"> </member> - <member name="cell_custom_transform" type="Transform2D" setter="set_custom_transform" getter="get_custom_transform" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> + <member name="cell_custom_transform" type="Transform2D" setter="set_custom_transform" getter="get_custom_transform" default="Transform2D( 64, 0, 0, 64, 0, 0 )"> The custom [Transform2D] to be applied to the TileMap's cells. </member> <member name="cell_half_offset" type="int" setter="set_half_offset" getter="get_half_offset" enum="TileMap.HalfOffset" default="2"> diff --git a/doc/classes/ToolButton.xml b/doc/classes/ToolButton.xml index f617c2a94f..d5edbe3972 100644 --- a/doc/classes/ToolButton.xml +++ b/doc/classes/ToolButton.xml @@ -14,6 +14,9 @@ </tutorials> <methods> </methods> + <members> + <member name="flat" type="bool" setter="set_flat" getter="is_flat" override="true" default="true" /> + </members> <constants> </constants> <theme_items> diff --git a/doc/classes/Tree.xml b/doc/classes/Tree.xml index 82f948c54d..e0c8d0b0e8 100644 --- a/doc/classes/Tree.xml +++ b/doc/classes/Tree.xml @@ -231,12 +231,14 @@ <member name="drop_mode_flags" type="int" setter="set_drop_mode_flags" getter="get_drop_mode_flags" default="0"> The drop mode as an OR combination of flags. See [code]DROP_MODE_*[/code] constants. Once dropping is done, reverts to [constant DROP_MODE_DISABLED]. Setting this during [method Control.can_drop_data] is recommended. </member> + <member name="focus_mode" type="int" setter="set_focus_mode" getter="get_focus_mode" override="true" enum="Control.FocusMode" default="2" /> <member name="hide_folding" type="bool" setter="set_hide_folding" getter="is_folding_hidden" default="false"> If [code]true[/code], the folding arrow is hidden. </member> <member name="hide_root" type="bool" setter="set_hide_root" getter="is_root_hidden" default="false"> If [code]true[/code], the tree's root is hidden. </member> + <member name="rect_clip_content" type="bool" setter="set_clip_contents" getter="is_clipping_contents" override="true" default="true" /> <member name="select_mode" type="int" setter="set_select_mode" getter="get_select_mode" enum="Tree.SelectMode" default="0"> Allows single or multiple selection. See the [code]SELECT_*[/code] constants. </member> diff --git a/doc/classes/VScrollBar.xml b/doc/classes/VScrollBar.xml index 0f46654bc2..4c06195d5c 100644 --- a/doc/classes/VScrollBar.xml +++ b/doc/classes/VScrollBar.xml @@ -9,6 +9,10 @@ </tutorials> <methods> </methods> + <members> + <member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags" override="true" default="0" /> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="1" /> + </members> <constants> </constants> <theme_items> diff --git a/doc/classes/VSlider.xml b/doc/classes/VSlider.xml index 550bd16074..fc62e5c892 100644 --- a/doc/classes/VSlider.xml +++ b/doc/classes/VSlider.xml @@ -10,6 +10,10 @@ </tutorials> <methods> </methods> + <members> + <member name="size_flags_horizontal" type="int" setter="set_h_size_flags" getter="get_h_size_flags" override="true" default="0" /> + <member name="size_flags_vertical" type="int" setter="set_v_size_flags" getter="get_v_size_flags" override="true" default="1" /> + </members> <constants> </constants> <theme_items> diff --git a/doc/classes/VehicleBody.xml b/doc/classes/VehicleBody.xml index 956144b54c..1803d4e197 100644 --- a/doc/classes/VehicleBody.xml +++ b/doc/classes/VehicleBody.xml @@ -20,9 +20,11 @@ [b]Note:[/b] The simulation does not take the effect of gears into account, you will need to add logic for this if you wish to simulate gears. A negative value will result in the vehicle reversing. </member> + <member name="mass" type="float" setter="set_mass" getter="get_mass" override="true" default="40.0" /> <member name="steering" type="float" setter="set_steering" getter="get_steering" default="0.0"> The steering angle for the vehicle. Setting this to a non-zero value will result in the vehicle turning when it's moving. Wheels that have [member VehicleWheel.use_as_steering] set to [code]true[/code] will automatically be rotated. </member> + <member name="weight" type="float" setter="set_weight" getter="get_weight" override="true" default="392.0" /> </members> <constants> </constants> diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 117c4835eb..9bc46881f9 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -281,7 +281,8 @@ The subdivision amount of fourth quadrant on shadow atlas. </member> <member name="shadow_atlas_size" type="int" setter="set_shadow_atlas_size" getter="get_shadow_atlas_size" default="0"> - The resolution of shadow atlas. Both width and height is equal to one value. + The shadow atlas' resolution (used for omni and spot lights). The value will be rounded up to the nearest power of 2. + [b]Note:[/b] If this is set to 0, shadows won't be visible. Since user-created viewports default to a value of 0, this value must be set above 0 manually. </member> <member name="size" type="Vector2" setter="set_size" getter="get_size" default="Vector2( 0, 0 )"> The width and height of viewport. diff --git a/doc/classes/ViewportTexture.xml b/doc/classes/ViewportTexture.xml index 5b9eb6a8cb..f4994699a3 100644 --- a/doc/classes/ViewportTexture.xml +++ b/doc/classes/ViewportTexture.xml @@ -12,6 +12,8 @@ <methods> </methods> <members> + <member name="flags" type="int" setter="set_flags" getter="get_flags" override="true" default="0" /> + <member name="resource_local_to_scene" type="bool" setter="set_local_to_scene" getter="is_local_to_scene" override="true" default="true" /> <member name="viewport_path" type="NodePath" setter="set_viewport_path_in_scene" getter="get_viewport_path_in_scene" default="NodePath("")"> The path to the [Viewport] node to display. This is relative to the scene root, not to the node which uses the texture. </member> diff --git a/doc/classes/VisibilityEnabler2D.xml b/doc/classes/VisibilityEnabler2D.xml index 0f25c00489..96f6a42cdf 100644 --- a/doc/classes/VisibilityEnabler2D.xml +++ b/doc/classes/VisibilityEnabler2D.xml @@ -4,7 +4,7 @@ Enables certain nodes only when visible. </brief_description> <description> - The VisibilityEnabler2D will disable [RigidBody2D], [AnimationPlayer], and other nodes when they are not visible. It will only affect other nodes within the same scene as the VisibilityEnabler2D itself. + The VisibilityEnabler2D will disable [RigidBody2D], [AnimationPlayer], and other nodes when they are not visible. It will only affect nodes with the same root node as the VisibilityEnabler2D, and the root node itself. </description> <tutorials> </tutorials> diff --git a/doc/classes/VisualServer.xml b/doc/classes/VisualServer.xml index 5e054ce7ce..b95b970816 100644 --- a/doc/classes/VisualServer.xml +++ b/doc/classes/VisualServer.xml @@ -189,13 +189,13 @@ </argument> <argument index="1" name="mesh" type="RID"> </argument> - <argument index="2" name="texture" type="Transform2D"> + <argument index="2" name="transform" type="Transform2D" default="Transform2D( 1, 0, 0, 1, 0, 0 )"> </argument> - <argument index="3" name="normal_map" type="Color"> + <argument index="3" name="modulate" type="Color" default="Color( 1, 1, 1, 1 )"> </argument> - <argument index="4" name="arg4" type="RID"> + <argument index="4" name="texture" type="RID"> </argument> - <argument index="5" name="arg5" type="RID"> + <argument index="5" name="normal_map" type="RID"> </argument> <description> </description> @@ -3855,7 +3855,7 @@ <argument index="1" name="size" type="int"> </argument> <description> - Sets the size of the shadow atlas's images. + Sets the size of the shadow atlas's images (used for omni and spot lights). The value will be rounded up to the nearest power of 2. </description> </method> <method name="viewport_set_size"> diff --git a/doc/classes/VisualShader.xml b/doc/classes/VisualShader.xml index 4bd3de4fc8..7d7002e752 100644 --- a/doc/classes/VisualShader.xml +++ b/doc/classes/VisualShader.xml @@ -183,6 +183,7 @@ </method> </methods> <members> + <member name="code" type="String" setter="set_code" getter="get_code" override="true" default=""shader_type spatial;void vertex() {// Output:0}void fragment() {// Output:0}void light() {// Output:0}"" /> <member name="graph_offset" type="Vector2" setter="set_graph_offset" getter="get_graph_offset" default="Vector2( 0, 0 )"> </member> </members> diff --git a/doc/classes/VisualShaderNodeBooleanConstant.xml b/doc/classes/VisualShaderNodeBooleanConstant.xml index b46905cfea..2490dbbcc0 100644 --- a/doc/classes/VisualShaderNodeBooleanConstant.xml +++ b/doc/classes/VisualShaderNodeBooleanConstant.xml @@ -11,6 +11,7 @@ <members> <member name="constant" type="bool" setter="set_constant" getter="get_constant" default="false"> </member> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> </members> <constants> </constants> diff --git a/doc/classes/VisualShaderNodeColorConstant.xml b/doc/classes/VisualShaderNodeColorConstant.xml index 282966a9ca..f58d1d8e76 100644 --- a/doc/classes/VisualShaderNodeColorConstant.xml +++ b/doc/classes/VisualShaderNodeColorConstant.xml @@ -11,6 +11,7 @@ <members> <member name="constant" type="Color" setter="set_constant" getter="get_constant" default="Color( 1, 1, 1, 1 )"> </member> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> </members> <constants> </constants> diff --git a/doc/classes/VisualShaderNodeColorOp.xml b/doc/classes/VisualShaderNodeColorOp.xml index 77c5361f4d..9997e9c83c 100644 --- a/doc/classes/VisualShaderNodeColorOp.xml +++ b/doc/classes/VisualShaderNodeColorOp.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ) ]" /> <member name="operator" type="int" setter="set_operator" getter="get_operator" enum="VisualShaderNodeColorOp.Operator" default="0"> </member> </members> diff --git a/doc/classes/VisualShaderNodeCompare.xml b/doc/classes/VisualShaderNodeCompare.xml index 7edad5294d..b1106998e9 100644 --- a/doc/classes/VisualShaderNodeCompare.xml +++ b/doc/classes/VisualShaderNodeCompare.xml @@ -11,6 +11,7 @@ <members> <member name="condition" type="int" setter="set_condition" getter="get_condition" enum="VisualShaderNodeCompare.Condition" default="0"> </member> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0, 1, 0.0, 2, 1e-05 ]" /> <member name="function" type="int" setter="set_function" getter="get_function" enum="VisualShaderNodeCompare.Function" default="0"> </member> <member name="type" type="int" setter="set_comparsion_type" getter="get_comparsion_type" enum="VisualShaderNodeCompare.ComparsionType" default="0"> diff --git a/doc/classes/VisualShaderNodeCubeMap.xml b/doc/classes/VisualShaderNodeCubeMap.xml index b695297f07..36465a6b4d 100644 --- a/doc/classes/VisualShaderNodeCubeMap.xml +++ b/doc/classes/VisualShaderNodeCubeMap.xml @@ -11,6 +11,7 @@ <members> <member name="cube_map" type="CubeMap" setter="set_cube_map" getter="get_cube_map"> </member> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> <member name="texture_type" type="int" setter="set_texture_type" getter="get_texture_type" enum="VisualShaderNodeCubeMap.TextureType" default="0"> </member> </members> diff --git a/doc/classes/VisualShaderNodeCubeMapUniform.xml b/doc/classes/VisualShaderNodeCubeMapUniform.xml index b06fc97b14..ad34e7d30c 100644 --- a/doc/classes/VisualShaderNodeCubeMapUniform.xml +++ b/doc/classes/VisualShaderNodeCubeMapUniform.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeCustom.xml b/doc/classes/VisualShaderNodeCustom.xml index 9e58abae97..5219dcb77b 100644 --- a/doc/classes/VisualShaderNodeCustom.xml +++ b/doc/classes/VisualShaderNodeCustom.xml @@ -144,6 +144,9 @@ </description> </method> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeDeterminant.xml b/doc/classes/VisualShaderNodeDeterminant.xml index a86db216c4..4ea7e5ed6e 100644 --- a/doc/classes/VisualShaderNodeDeterminant.xml +++ b/doc/classes/VisualShaderNodeDeterminant.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeDotProduct.xml b/doc/classes/VisualShaderNodeDotProduct.xml index f07827db29..4c2bae39a1 100644 --- a/doc/classes/VisualShaderNodeDotProduct.xml +++ b/doc/classes/VisualShaderNodeDotProduct.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeExpression.xml b/doc/classes/VisualShaderNodeExpression.xml index ddb85d7e43..9727b8698b 100644 --- a/doc/classes/VisualShaderNodeExpression.xml +++ b/doc/classes/VisualShaderNodeExpression.xml @@ -15,6 +15,7 @@ </method> </methods> <members> + <member name="editable" type="bool" setter="set_editable" getter="is_editable" override="true" default="true" /> <member name="expression" type="String" setter="set_expression" getter="get_expression" default=""""> </member> </members> diff --git a/doc/classes/VisualShaderNodeFaceForward.xml b/doc/classes/VisualShaderNodeFaceForward.xml index ea8589e6cb..9c755cc6de 100644 --- a/doc/classes/VisualShaderNodeFaceForward.xml +++ b/doc/classes/VisualShaderNodeFaceForward.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ), 2, Vector3( 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeFresnel.xml b/doc/classes/VisualShaderNodeFresnel.xml index 2484a44fcd..f79ae04abf 100644 --- a/doc/classes/VisualShaderNodeFresnel.xml +++ b/doc/classes/VisualShaderNodeFresnel.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ), 2, false, 3, 1.0 ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeGlobalExpression.xml b/doc/classes/VisualShaderNodeGlobalExpression.xml index 3c5a26bf47..f008c639cf 100644 --- a/doc/classes/VisualShaderNodeGlobalExpression.xml +++ b/doc/classes/VisualShaderNodeGlobalExpression.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="editable" type="bool" setter="set_editable" getter="is_editable" override="true" default="false" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeGroupBase.xml b/doc/classes/VisualShaderNodeGroupBase.xml index d32a63d605..511a56b7a6 100644 --- a/doc/classes/VisualShaderNodeGroupBase.xml +++ b/doc/classes/VisualShaderNodeGroupBase.xml @@ -146,9 +146,9 @@ <method name="set_input_port_name"> <return type="void"> </return> - <argument index="0" name="arg0" type="int"> + <argument index="0" name="id" type="int"> </argument> - <argument index="1" name="arg1" type="String"> + <argument index="1" name="name" type="String"> </argument> <description> </description> @@ -156,9 +156,9 @@ <method name="set_input_port_type"> <return type="void"> </return> - <argument index="0" name="arg0" type="int"> + <argument index="0" name="id" type="int"> </argument> - <argument index="1" name="arg1" type="int"> + <argument index="1" name="type" type="int"> </argument> <description> </description> @@ -174,9 +174,9 @@ <method name="set_output_port_name"> <return type="void"> </return> - <argument index="0" name="arg0" type="int"> + <argument index="0" name="id" type="int"> </argument> - <argument index="1" name="arg1" type="String"> + <argument index="1" name="name" type="String"> </argument> <description> </description> @@ -184,9 +184,9 @@ <method name="set_output_port_type"> <return type="void"> </return> - <argument index="0" name="arg0" type="int"> + <argument index="0" name="id" type="int"> </argument> - <argument index="1" name="arg1" type="int"> + <argument index="1" name="type" type="int"> </argument> <description> </description> @@ -209,6 +209,7 @@ </method> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> <member name="editable" type="bool" setter="set_editable" getter="is_editable" default="false"> </member> </members> diff --git a/doc/classes/VisualShaderNodeIf.xml b/doc/classes/VisualShaderNodeIf.xml index 374a1e379a..6900cdf81b 100644 --- a/doc/classes/VisualShaderNodeIf.xml +++ b/doc/classes/VisualShaderNodeIf.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0, 1, 0.0, 2, 1e-05, 3, Vector3( 0, 0, 0 ), 4, Vector3( 0, 0, 0 ), 5, Vector3( 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeInput.xml b/doc/classes/VisualShaderNodeInput.xml index 25fd2ec8d8..302c8dff71 100644 --- a/doc/classes/VisualShaderNodeInput.xml +++ b/doc/classes/VisualShaderNodeInput.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> <member name="input_name" type="String" setter="set_input_name" getter="get_input_name" default=""[None]""> </member> </members> diff --git a/doc/classes/VisualShaderNodeIs.xml b/doc/classes/VisualShaderNodeIs.xml index 8db64b7cde..c221e60b75 100644 --- a/doc/classes/VisualShaderNodeIs.xml +++ b/doc/classes/VisualShaderNodeIs.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0 ]" /> <member name="function" type="int" setter="set_function" getter="get_function" enum="VisualShaderNodeIs.Function" default="0"> </member> </members> diff --git a/doc/classes/VisualShaderNodeOuterProduct.xml b/doc/classes/VisualShaderNodeOuterProduct.xml index 3debde0634..6111084b44 100644 --- a/doc/classes/VisualShaderNodeOuterProduct.xml +++ b/doc/classes/VisualShaderNodeOuterProduct.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeScalarClamp.xml b/doc/classes/VisualShaderNodeScalarClamp.xml index 4c5309d1e7..927aeb01ce 100644 --- a/doc/classes/VisualShaderNodeScalarClamp.xml +++ b/doc/classes/VisualShaderNodeScalarClamp.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0, 1, 0.0, 2, 1.0 ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeScalarConstant.xml b/doc/classes/VisualShaderNodeScalarConstant.xml index 0af09e74e3..c4ac65aa48 100644 --- a/doc/classes/VisualShaderNodeScalarConstant.xml +++ b/doc/classes/VisualShaderNodeScalarConstant.xml @@ -11,6 +11,7 @@ <members> <member name="constant" type="float" setter="set_constant" getter="get_constant" default="0.0"> </member> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> </members> <constants> </constants> diff --git a/doc/classes/VisualShaderNodeScalarDerivativeFunc.xml b/doc/classes/VisualShaderNodeScalarDerivativeFunc.xml index 09e2d2fa72..795054637e 100644 --- a/doc/classes/VisualShaderNodeScalarDerivativeFunc.xml +++ b/doc/classes/VisualShaderNodeScalarDerivativeFunc.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0 ]" /> <member name="function" type="int" setter="set_function" getter="get_function" enum="VisualShaderNodeScalarDerivativeFunc.Function" default="0"> </member> </members> diff --git a/doc/classes/VisualShaderNodeScalarFunc.xml b/doc/classes/VisualShaderNodeScalarFunc.xml index ef52086d6e..81ccf8aeb6 100644 --- a/doc/classes/VisualShaderNodeScalarFunc.xml +++ b/doc/classes/VisualShaderNodeScalarFunc.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0 ]" /> <member name="function" type="int" setter="set_function" getter="get_function" enum="VisualShaderNodeScalarFunc.Function" default="13"> </member> </members> diff --git a/doc/classes/VisualShaderNodeScalarInterp.xml b/doc/classes/VisualShaderNodeScalarInterp.xml index 9d01e20b8d..7e40304b04 100644 --- a/doc/classes/VisualShaderNodeScalarInterp.xml +++ b/doc/classes/VisualShaderNodeScalarInterp.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0, 1, 1.0, 2, 0.5 ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeScalarOp.xml b/doc/classes/VisualShaderNodeScalarOp.xml index 0aa692c228..3ff56bffaa 100644 --- a/doc/classes/VisualShaderNodeScalarOp.xml +++ b/doc/classes/VisualShaderNodeScalarOp.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0, 1, 0.0 ]" /> <member name="operator" type="int" setter="set_operator" getter="get_operator" enum="VisualShaderNodeScalarOp.Operator" default="0"> </member> </members> diff --git a/doc/classes/VisualShaderNodeScalarSmoothStep.xml b/doc/classes/VisualShaderNodeScalarSmoothStep.xml index 737c535659..e71bb16f6f 100644 --- a/doc/classes/VisualShaderNodeScalarSmoothStep.xml +++ b/doc/classes/VisualShaderNodeScalarSmoothStep.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0, 1, 0.0, 2, 0.0 ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeScalarSwitch.xml b/doc/classes/VisualShaderNodeScalarSwitch.xml new file mode 100644 index 0000000000..2828f42b47 --- /dev/null +++ b/doc/classes/VisualShaderNodeScalarSwitch.xml @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="VisualShaderNodeScalarSwitch" inherits="VisualShaderNodeSwitch" category="Core" version="3.2"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <methods> + </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, false, 1, 1.0, 2, 0.0 ]" /> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/VisualShaderNodeSwitch.xml b/doc/classes/VisualShaderNodeSwitch.xml index 930d914035..704ac08adb 100644 --- a/doc/classes/VisualShaderNodeSwitch.xml +++ b/doc/classes/VisualShaderNodeSwitch.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, false, 1, Vector3( 1, 1, 1 ), 2, Vector3( 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeTexture.xml b/doc/classes/VisualShaderNodeTexture.xml index f3bade9303..a94b798745 100644 --- a/doc/classes/VisualShaderNodeTexture.xml +++ b/doc/classes/VisualShaderNodeTexture.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> <member name="source" type="int" setter="set_source" getter="get_source" enum="VisualShaderNodeTexture.Source" default="0"> </member> <member name="texture" type="Texture" setter="set_texture" getter="get_texture"> diff --git a/doc/classes/VisualShaderNodeTransformCompose.xml b/doc/classes/VisualShaderNodeTransformCompose.xml index 0939eb393d..0c44e6b3c5 100644 --- a/doc/classes/VisualShaderNodeTransformCompose.xml +++ b/doc/classes/VisualShaderNodeTransformCompose.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ), 2, Vector3( 0, 0, 0 ), 3, Vector3( 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeTransformConstant.xml b/doc/classes/VisualShaderNodeTransformConstant.xml index b184a3d337..737961f8ec 100644 --- a/doc/classes/VisualShaderNodeTransformConstant.xml +++ b/doc/classes/VisualShaderNodeTransformConstant.xml @@ -11,6 +11,7 @@ <members> <member name="constant" type="Transform" setter="set_constant" getter="get_constant" default="Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 )"> </member> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> </members> <constants> </constants> diff --git a/doc/classes/VisualShaderNodeTransformDecompose.xml b/doc/classes/VisualShaderNodeTransformDecompose.xml index d986e6b7a8..911d2e953a 100644 --- a/doc/classes/VisualShaderNodeTransformDecompose.xml +++ b/doc/classes/VisualShaderNodeTransformDecompose.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeTransformFunc.xml b/doc/classes/VisualShaderNodeTransformFunc.xml index 7fb17b1a79..53b7c9f1ab 100644 --- a/doc/classes/VisualShaderNodeTransformFunc.xml +++ b/doc/classes/VisualShaderNodeTransformFunc.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) ]" /> <member name="function" type="int" setter="set_function" getter="get_function" enum="VisualShaderNodeTransformFunc.Function" default="0"> </member> </members> diff --git a/doc/classes/VisualShaderNodeTransformMult.xml b/doc/classes/VisualShaderNodeTransformMult.xml index 0406050025..f5368b3b1c 100644 --- a/doc/classes/VisualShaderNodeTransformMult.xml +++ b/doc/classes/VisualShaderNodeTransformMult.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ), 1, Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) ]" /> <member name="operator" type="int" setter="set_operator" getter="get_operator" enum="VisualShaderNodeTransformMult.Operator" default="0"> </member> </members> diff --git a/doc/classes/VisualShaderNodeTransformVecMult.xml b/doc/classes/VisualShaderNodeTransformVecMult.xml index 881d0cf3cf..9ab9c08562 100644 --- a/doc/classes/VisualShaderNodeTransformVecMult.xml +++ b/doc/classes/VisualShaderNodeTransformVecMult.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ), 1, Vector3( 0, 0, 0 ) ]" /> <member name="operator" type="int" setter="set_operator" getter="get_operator" enum="VisualShaderNodeTransformVecMult.Operator" default="0"> </member> </members> diff --git a/doc/classes/VisualShaderNodeUniform.xml b/doc/classes/VisualShaderNodeUniform.xml index 6835a30baa..05539294a0 100644 --- a/doc/classes/VisualShaderNodeUniform.xml +++ b/doc/classes/VisualShaderNodeUniform.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> <member name="uniform_name" type="String" setter="set_uniform_name" getter="get_uniform_name" default=""""> </member> </members> diff --git a/doc/classes/VisualShaderNodeVec3Constant.xml b/doc/classes/VisualShaderNodeVec3Constant.xml index b17f56e1f8..06e033cd9d 100644 --- a/doc/classes/VisualShaderNodeVec3Constant.xml +++ b/doc/classes/VisualShaderNodeVec3Constant.xml @@ -11,6 +11,7 @@ <members> <member name="constant" type="Vector3" setter="set_constant" getter="get_constant" default="Vector3( 0, 0, 0 )"> </member> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ ]" /> </members> <constants> </constants> diff --git a/doc/classes/VisualShaderNodeVectorClamp.xml b/doc/classes/VisualShaderNodeVectorClamp.xml index a5d1e94e2f..8b9a0cacff 100644 --- a/doc/classes/VisualShaderNodeVectorClamp.xml +++ b/doc/classes/VisualShaderNodeVectorClamp.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ), 2, Vector3( 1, 1, 1 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeVectorCompose.xml b/doc/classes/VisualShaderNodeVectorCompose.xml index b7f650c82e..11eb4d2778 100644 --- a/doc/classes/VisualShaderNodeVectorCompose.xml +++ b/doc/classes/VisualShaderNodeVectorCompose.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0, 1, 0.0, 2, 0.0 ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeVectorDistance.xml b/doc/classes/VisualShaderNodeVectorDistance.xml index f7c9acecf7..3b7f743864 100644 --- a/doc/classes/VisualShaderNodeVectorDistance.xml +++ b/doc/classes/VisualShaderNodeVectorDistance.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeVectorInterp.xml b/doc/classes/VisualShaderNodeVectorInterp.xml index 2a398c653d..7aa525cd0e 100644 --- a/doc/classes/VisualShaderNodeVectorInterp.xml +++ b/doc/classes/VisualShaderNodeVectorInterp.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 1, 1, 1 ), 2, Vector3( 0.5, 0.5, 0.5 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeVectorOp.xml b/doc/classes/VisualShaderNodeVectorOp.xml index 0ec49a3845..d237ee56b0 100644 --- a/doc/classes/VisualShaderNodeVectorOp.xml +++ b/doc/classes/VisualShaderNodeVectorOp.xml @@ -9,6 +9,7 @@ <methods> </methods> <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ) ]" /> <member name="operator" type="int" setter="set_operator" getter="get_operator" enum="VisualShaderNodeVectorOp.Operator" default="0"> </member> </members> diff --git a/doc/classes/VisualShaderNodeVectorRefract.xml b/doc/classes/VisualShaderNodeVectorRefract.xml index 4df072040a..453c2bf02f 100644 --- a/doc/classes/VisualShaderNodeVectorRefract.xml +++ b/doc/classes/VisualShaderNodeVectorRefract.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ), 2, 0.0 ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeVectorScalarMix.xml b/doc/classes/VisualShaderNodeVectorScalarMix.xml index d83c2e7d44..4ab396a14b 100644 --- a/doc/classes/VisualShaderNodeVectorScalarMix.xml +++ b/doc/classes/VisualShaderNodeVectorScalarMix.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 1, 1, 1 ), 2, 0.5 ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeVectorScalarSmoothStep.xml b/doc/classes/VisualShaderNodeVectorScalarSmoothStep.xml index 4334eee7c1..2aeb8c1b53 100644 --- a/doc/classes/VisualShaderNodeVectorScalarSmoothStep.xml +++ b/doc/classes/VisualShaderNodeVectorScalarSmoothStep.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0, 1, 0.0, 2, Vector3( 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeVectorScalarStep.xml b/doc/classes/VisualShaderNodeVectorScalarStep.xml index ad8cac059b..c448404b7f 100644 --- a/doc/classes/VisualShaderNodeVectorScalarStep.xml +++ b/doc/classes/VisualShaderNodeVectorScalarStep.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, 0.0, 1, Vector3( 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/VisualShaderNodeVectorSmoothStep.xml b/doc/classes/VisualShaderNodeVectorSmoothStep.xml index 59acff7d05..bb80832c3c 100644 --- a/doc/classes/VisualShaderNodeVectorSmoothStep.xml +++ b/doc/classes/VisualShaderNodeVectorSmoothStep.xml @@ -8,6 +8,9 @@ </tutorials> <methods> </methods> + <members> + <member name="default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values" override="true" default="[ 0, Vector3( 0, 0, 0 ), 1, Vector3( 0, 0, 0 ), 2, Vector3( 0, 0, 0 ) ]" /> + </members> <constants> </constants> </class> diff --git a/doc/classes/X509Certificate.xml b/doc/classes/X509Certificate.xml index 013f768843..8066f65391 100644 --- a/doc/classes/X509Certificate.xml +++ b/doc/classes/X509Certificate.xml @@ -1,8 +1,11 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="X509Certificate" inherits="Resource" category="Core" version="3.2"> <brief_description> + An X509 certificate (e.g. for SSL). </brief_description> <description> + The X509Certificate class represents an X509 certificate. Certificates can be loaded and saved like any other [Resource]. + They can be used as the server certificate in [StreamPeerSSL.accept_stream] (along with the proper [CryptoKey]), and to specify the only certificate that should be accepted when connecting to an SSL server via [StreamPeerSSL.connect_to_stream]. </description> <tutorials> </tutorials> @@ -13,6 +16,7 @@ <argument index="0" name="path" type="String"> </argument> <description> + Loads a certificate from [code]path[/code] ("*.crt" file). </description> </method> <method name="save"> @@ -21,6 +25,7 @@ <argument index="0" name="path" type="String"> </argument> <description> + Saves a certificate to the given [code]path[/code] (should be a "*.crt" file). </description> </method> </methods> diff --git a/doc/tools/makerst.py b/doc/tools/makerst.py index b42ae3ce01..8eddc35352 100755 --- a/doc/tools/makerst.py +++ b/doc/tools/makerst.py @@ -37,13 +37,14 @@ class TypeName: class PropertyDef: - def __init__(self, name, type_name, setter, getter, text, default_value): # type: (str, TypeName, Optional[str], Optional[str], Optional[str], Optional[str]) -> None + def __init__(self, name, type_name, setter, getter, text, default_value, overridden): # type: (str, TypeName, Optional[str], Optional[str], Optional[str], Optional[str], Optional[bool]) -> None self.name = name self.type_name = type_name self.setter = setter self.getter = getter self.text = text self.default_value = default_value + self.overridden = overridden class ParameterDef: def __init__(self, name, type_name, default_value): # type: (str, TypeName, Optional[str]) -> None @@ -147,8 +148,9 @@ class State: setter = property.get("setter") or None # Use or None so '' gets turned into None. getter = property.get("getter") or None default_value = property.get("default") or None + overridden = property.get("override") or False - property_def = PropertyDef(property_name, type_name, setter, getter, property.text, default_value) + property_def = PropertyDef(property_name, type_name, setter, getter, property.text, default_value, overridden) class_def.properties[property_name] = property_def methods = class_root.find("methods") @@ -401,12 +403,15 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S # Properties overview if len(class_def.properties) > 0: f.write(make_heading('Properties', '-')) - ml = [] # type: List[Tuple[str, str]] + ml = [] # type: List[Tuple[str, str, str]] for property_def in class_def.properties.values(): type_rst = property_def.type_name.to_rst(state) - ref = ":ref:`{0}<class_{1}_property_{0}>`".format(property_def.name, class_name) default = property_def.default_value - ml.append((type_rst, ref, default)) + if property_def.overridden: + ml.append((type_rst, property_def.name, "**O:** " + default)) + else: + ref = ":ref:`{0}<class_{1}_property_{0}>`".format(property_def.name, class_name) + ml.append((type_rst, ref, default)) format_table(f, ml, True) # Methods overview @@ -487,9 +492,12 @@ def make_rst_class(class_def, state, dry_run, output_dir): # type: (ClassDef, S f.write("- " + make_url(link) + "\n\n") # Property descriptions - if len(class_def.properties) > 0: + if any(not p.overridden for p in class_def.properties.values()) > 0: f.write(make_heading('Property Descriptions', '-')) for property_def in class_def.properties.values(): + if property_def.overridden: + continue + #f.write(".. _class_{}_{}:\n\n".format(class_name, property_def.name)) f.write(".. _class_{}_property_{}:\n\n".format(class_name, property_def.name)) f.write('- {} **{}**\n\n'.format(property_def.type_name.to_rst(state), property_def.name)) diff --git a/drivers/alsa/audio_driver_alsa.cpp b/drivers/alsa/audio_driver_alsa.cpp index 0611d7d4e0..42899c0f76 100644 --- a/drivers/alsa/audio_driver_alsa.cpp +++ b/drivers/alsa/audio_driver_alsa.cpp @@ -171,14 +171,14 @@ void AudioDriverALSA::thread_func(void *p_udata) { ad->start_counting_ticks(); if (!ad->active) { - for (unsigned int i = 0; i < ad->period_size * ad->channels; i++) { + for (uint64_t i = 0; i < ad->period_size * ad->channels; i++) { ad->samples_out.write[i] = 0; } } else { ad->audio_server_process(ad->period_size, ad->samples_in.ptrw()); - for (unsigned int i = 0; i < ad->period_size * ad->channels; i++) { + for (uint64_t i = 0; i < ad->period_size * ad->channels; i++) { ad->samples_out.write[i] = ad->samples_in[i] >> 16; } } diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index cc414c26af..a8fa30c709 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -1432,11 +1432,11 @@ void RasterizerSceneGLES2::_setup_geometry(RenderList::Element *p_element, Raste } } - bool clear_skeleton_buffer = !storage->config.float_texture_supported; + bool clear_skeleton_buffer = storage->config.use_skeleton_software; if (p_skeleton) { - if (storage->config.float_texture_supported) { + if (!storage->config.use_skeleton_software) { //use float texture workflow glActiveTexture(GL_TEXTURE0 + storage->config.max_texture_image_units - 1); glBindTexture(GL_TEXTURE_2D, p_skeleton->tex_id); @@ -2452,7 +2452,7 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, if (skeleton) { state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON, true); - state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON_SOFTWARE, !storage->config.float_texture_supported); + state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON_SOFTWARE, storage->config.use_skeleton_software); } else { state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON, false); state.scene_shader.set_conditional(SceneShaderGLES2::USE_SKELETON_SOFTWARE, false); @@ -2570,12 +2570,6 @@ void RasterizerSceneGLES2::_render_render_list(RenderList::Element **p_elements, state.scene_shader.set_uniform(SceneShaderGLES2::WORLD_TRANSFORM, e->instance->transform); - if (skeleton) { - state.scene_shader.set_uniform(SceneShaderGLES2::SKELETON_IN_WORLD_COORDS, skeleton->use_world_transform); - state.scene_shader.set_uniform(SceneShaderGLES2::SKELETON_TRANSFORM, skeleton->world_transform); - state.scene_shader.set_uniform(SceneShaderGLES2::SKELETON_TRANSFORM_INVERSE, skeleton->world_transform_inverse); - } - if (use_lightmap_capture) { //this is per instance, must be set always if present glUniform4fv(state.scene_shader.get_uniform_location(SceneShaderGLES2::LIGHTMAP_CAPTURES), 12, (const GLfloat *)e->instance->lightmap_capture_data.ptr()); state.scene_shader.set_uniform(SceneShaderGLES2::LIGHTMAP_CAPTURE_SKY, false); diff --git a/drivers/gles2/rasterizer_storage_gles2.cpp b/drivers/gles2/rasterizer_storage_gles2.cpp index 5c02d8096d..9f511cd787 100644 --- a/drivers/gles2/rasterizer_storage_gles2.cpp +++ b/drivers/gles2/rasterizer_storage_gles2.cpp @@ -2432,7 +2432,7 @@ void RasterizerStorageGLES2::mesh_add_surface(RID p_mesh, uint32_t p_format, VS: // from surface->data. // if USE_SKELETON_SOFTWARE is active - if (!config.float_texture_supported) { + if (config.use_skeleton_software) { // if this geometry is used specifically for skinning if (p_format & (VS::ARRAY_FORMAT_BONES | VS::ARRAY_FORMAT_WEIGHTS)) surface->data = array; @@ -3514,7 +3514,7 @@ void RasterizerStorageGLES2::skeleton_allocate(RID p_skeleton, int p_bones, bool skeleton->size = p_bones; skeleton->use_2d = p_2d_skeleton; - if (config.float_texture_supported) { + if (!config.use_skeleton_software) { glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, skeleton->tex_id); @@ -3663,23 +3663,6 @@ void RasterizerStorageGLES2::skeleton_set_base_transform_2d(RID p_skeleton, cons skeleton->base_transform_2d = p_base_transform; } -void RasterizerStorageGLES2::skeleton_set_world_transform(RID p_skeleton, bool p_enable, const Transform &p_world_transform) { - - Skeleton *skeleton = skeleton_owner.getornull(p_skeleton); - - ERR_FAIL_COND(skeleton->use_2d); - - skeleton->world_transform = p_world_transform; - skeleton->use_world_transform = p_enable; - if (p_enable) { - skeleton->world_transform_inverse = skeleton->world_transform.affine_inverse(); - } - - if (!skeleton->update_list.in_list()) { - skeleton_update_list.add(&skeleton->update_list); - } -} - void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const PoolVector<float> &p_data, size_t p_size) { glBindBuffer(GL_ARRAY_BUFFER, resources.skeleton_transform_buffer); @@ -3699,7 +3682,7 @@ void RasterizerStorageGLES2::_update_skeleton_transform_buffer(const PoolVector< void RasterizerStorageGLES2::update_dirty_skeletons() { - if (!config.float_texture_supported) + if (config.use_skeleton_software) return; glActiveTexture(GL_TEXTURE0); @@ -5751,9 +5734,14 @@ void RasterizerStorageGLES2::initialize() { frame.current_rt = NULL; frame.clear_request = false; + glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &config.max_vertex_texture_image_units); glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &config.max_texture_image_units); glGetIntegerv(GL_MAX_TEXTURE_SIZE, &config.max_texture_size); + // the use skeleton software path should be used if either float texture is not supported, + // OR max_vertex_texture_image_units is zero + config.use_skeleton_software = (config.float_texture_supported == false) || (config.max_vertex_texture_image_units == 0); + shaders.copy.init(); shaders.cubemap_filter.init(); bool ggx_hq = GLOBAL_GET("rendering/quality/reflections/high_quality_ggx"); diff --git a/drivers/gles2/rasterizer_storage_gles2.h b/drivers/gles2/rasterizer_storage_gles2.h index d139697b86..ba9274b576 100644 --- a/drivers/gles2/rasterizer_storage_gles2.h +++ b/drivers/gles2/rasterizer_storage_gles2.h @@ -60,7 +60,9 @@ public: bool shrink_textures_x2; bool use_fast_texture_filter; + bool use_skeleton_software; + int max_vertex_texture_image_units; int max_texture_image_units; int max_texture_size; @@ -868,16 +870,12 @@ public: Set<RasterizerScene::InstanceBase *> instances; Transform2D base_transform_2d; - Transform world_transform; - Transform world_transform_inverse; - bool use_world_transform; Skeleton() : use_2d(false), size(0), tex_id(0), - update_list(this), - use_world_transform(false) { + update_list(this) { } }; @@ -895,7 +893,6 @@ public: virtual void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform); virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const; virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform); - virtual void skeleton_set_world_transform(RID p_skeleton, bool p_enable, const Transform &p_world_transform); void _update_skeleton_transform_buffer(const PoolVector<float> &p_data, size_t p_size); diff --git a/drivers/gles2/shaders/copy.glsl b/drivers/gles2/shaders/copy.glsl index 195db7c45f..aa967115da 100644 --- a/drivers/gles2/shaders/copy.glsl +++ b/drivers/gles2/shaders/copy.glsl @@ -144,11 +144,11 @@ void main() { #elif defined(USE_ASYM_PANO) // When an asymmetrical projection matrix is used (applicable for stereoscopic rendering i.e. VR) we need to do this calculation per fragment to get a perspective correct result. - // Note that we're ignoring the x-offset for IPD, with Z sufficiently in the distance it becomes neglectible, as a result we could probably just set cube_normal.z to -1. + // Asymmetrical projection means the center of projection is no longer in the center of the screen but shifted. // The Matrix[2][0] (= asym_proj.x) and Matrix[2][1] (= asym_proj.z) values are what provide the right shift in the image. vec3 cube_normal; - cube_normal.z = -1000000.0; + cube_normal.z = -1.0; cube_normal.x = (cube_normal.z * (-uv_interp.x - asym_proj.x)) / asym_proj.y; cube_normal.y = (cube_normal.z * (-uv_interp.y - asym_proj.z)) / asym_proj.a; cube_normal = mat3(sky_transform) * mat3(pano_transform) * cube_normal; diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl index 8a9387f0b3..57c2d886b3 100644 --- a/drivers/gles2/shaders/scene.glsl +++ b/drivers/gles2/shaders/scene.glsl @@ -61,10 +61,6 @@ uniform ivec2 skeleton_texture_size; #endif -uniform highp mat4 skeleton_transform; -uniform highp mat4 skeleton_transform_inverse; -uniform bool skeleton_in_world_coords; - #endif #ifdef USE_INSTANCING @@ -410,12 +406,7 @@ void main() { #endif - if (skeleton_in_world_coords) { - bone_transform = skeleton_transform * (bone_transform * skeleton_transform_inverse); - world_matrix = bone_transform * world_matrix; - } else { - world_matrix = world_matrix * bone_transform; - } + world_matrix = world_matrix * bone_transform; #endif diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 1472954ebc..35f414cf09 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -2260,11 +2260,6 @@ void RasterizerSceneGLES3::_render_list(RenderList::Element **p_elements, int p_ _set_cull(e->sort_key & RenderList::SORT_KEY_MIRROR_FLAG, e->sort_key & RenderList::SORT_KEY_CULL_DISABLED_FLAG, p_reverse_cull); - if (skeleton) { - state.scene_shader.set_uniform(SceneShaderGLES3::SKELETON_TRANSFORM, skeleton->world_transform); - state.scene_shader.set_uniform(SceneShaderGLES3::SKELETON_IN_WORLD_COORDS, skeleton->use_world_transform); - } - state.scene_shader.set_uniform(SceneShaderGLES3::WORLD_TRANSFORM, e->instance->transform); _render_geometry(e); @@ -4335,6 +4330,10 @@ void RasterizerSceneGLES3::render_scene(const Transform &p_cam_transform, const if (storage->frame.current_rt->buffers.active) { current_fbo = storage->frame.current_rt->buffers.fbo; } else { + if (storage->frame.current_rt->effects.mip_maps[0].sizes.size() == 0) { + ERR_PRINT_ONCE("Can't use canvas background mode in a render target configured without sampling"); + return; + } current_fbo = storage->frame.current_rt->effects.mip_maps[0].sizes[0].fbo; } diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index 3b6bb81ac5..a29831e3f5 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -5162,20 +5162,6 @@ void RasterizerStorageGLES3::skeleton_set_base_transform_2d(RID p_skeleton, cons skeleton->base_transform_2d = p_base_transform; } -void RasterizerStorageGLES3::skeleton_set_world_transform(RID p_skeleton, bool p_enable, const Transform &p_world_transform) { - - Skeleton *skeleton = skeleton_owner.getornull(p_skeleton); - - ERR_FAIL_COND(skeleton->use_2d); - - skeleton->world_transform = p_world_transform; - skeleton->use_world_transform = p_enable; - - if (!skeleton->update_list.in_list()) { - skeleton_update_list.add(&skeleton->update_list); - } -} - void RasterizerStorageGLES3::update_dirty_skeletons() { glActiveTexture(GL_TEXTURE0); diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index 0a7e47e304..84632308b4 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -892,15 +892,12 @@ public: SelfList<Skeleton> update_list; Set<RasterizerScene::InstanceBase *> instances; //instances using skeleton Transform2D base_transform_2d; - bool use_world_transform; - Transform world_transform; Skeleton() : use_2d(false), size(0), texture(0), - update_list(this), - use_world_transform(false) { + update_list(this) { } }; @@ -918,7 +915,6 @@ public: virtual void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform); virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const; virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform); - virtual void skeleton_set_world_transform(RID p_skeleton, bool p_enable, const Transform &p_world_transform); /* Light API */ diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index f08d3f4d23..403de25dd0 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -302,8 +302,6 @@ out highp float dp_clip; #ifdef USE_SKELETON uniform highp sampler2D skeleton_texture; // texunit:-1 -uniform highp mat4 skeleton_transform; -uniform bool skeleton_in_world_coords; #endif out highp vec4 position_interp; @@ -432,14 +430,7 @@ void main() { vec4(0.0, 0.0, 0.0, 1.0)) * bone_weights.w; - if (skeleton_in_world_coords) { - highp mat4 bone_matrix = skeleton_transform * (transpose(m) * inverse(skeleton_transform)); - world_matrix = bone_matrix * world_matrix; - - } else { - - world_matrix = world_matrix * transpose(m); - } + world_matrix = world_matrix * transpose(m); } #endif diff --git a/editor/animation_bezier_editor.cpp b/editor/animation_bezier_editor.cpp index 6728f60e06..9194da654c 100644 --- a/editor/animation_bezier_editor.cpp +++ b/editor/animation_bezier_editor.cpp @@ -929,13 +929,6 @@ void AnimationBezierTrackEdit::_gui_input(const Ref<InputEvent> &p_event) { undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, 1); } - // 6-(undo) reinsert overlapped keys - for (List<AnimMoveRestore>::Element *E = to_restore.front(); E; E = E->next()) { - - AnimMoveRestore &amr = E->get(); - undo_redo->add_undo_method(animation.ptr(), "track_insert_key", amr.track, amr.time, amr.key, 1); - } - undo_redo->add_do_method(this, "_clear_selection_for_anim", animation); undo_redo->add_undo_method(this, "_clear_selection_for_anim", animation); diff --git a/editor/animation_track_editor.cpp b/editor/animation_track_editor.cpp index 285cea7d0a..fa773b17c2 100644 --- a/editor/animation_track_editor.cpp +++ b/editor/animation_track_editor.cpp @@ -3470,20 +3470,18 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { if (p_id.track_idx == -1) { if (bool(EDITOR_DEF("editors/animation/confirm_insert_track", true))) { //potential new key, does not exist - if (insert_data.size() == 1) - insert_confirm_text->set_text(vformat(TTR("Create NEW track for %s and insert key?"), p_id.query)); - else - insert_confirm_text->set_text(vformat(TTR("Create %d NEW tracks and insert keys?"), insert_data.size())); - + int num_tracks = 0; bool all_bezier = true; for (int i = 0; i < insert_data.size(); i++) { - if (insert_data[i].type != Animation::TYPE_VALUE && insert_data[i].type != Animation::TYPE_BEZIER) { + if (insert_data[i].type != Animation::TYPE_VALUE && insert_data[i].type != Animation::TYPE_BEZIER) all_bezier = false; - } - if (insert_data[i].type != Animation::TYPE_VALUE) { + if (insert_data[i].track_idx == -1) + ++num_tracks; + + if (insert_data[i].type != Animation::TYPE_VALUE) continue; - } + switch (insert_data[i].value.get_type()) { case Variant::INT: case Variant::REAL: @@ -3500,6 +3498,11 @@ void AnimationTrackEditor::_query_insert(const InsertData &p_id) { } } + if (num_tracks == 1) + insert_confirm_text->set_text(vformat(TTR("Create NEW track for %s and insert key?"), p_id.query)); + else + insert_confirm_text->set_text(vformat(TTR("Create %d NEW tracks and insert keys?"), num_tracks)); + insert_confirm_bezier->set_visible(all_bezier); insert_confirm->get_ok()->set_text(TTR("Create")); insert_confirm->popup_centered_minsize(); @@ -3686,16 +3689,20 @@ void AnimationTrackEditor::insert_node_value_key(Node *p_node, const String &p_p } else if (animation->track_get_type(i) == Animation::TYPE_BEZIER) { Variant value; - if (animation->track_get_path(i) == np) { + String track_path = animation->track_get_path(i); + if (track_path == np) { value = p_value; //all good } else { - String tpath = animation->track_get_path(i); - if (NodePath(tpath.get_basename()) == np) { - String subindex = tpath.get_extension(); - value = p_value.get(subindex); - } else { + int sep = track_path.find_last(":"); + if (sep != -1) { + String base_path = track_path.substr(0, sep); + if (base_path == np) { + String value_name = track_path.substr(sep + 1); + value = p_value.get(value_name); + } else + continue; + } else continue; - } } InsertData id; @@ -3955,25 +3962,20 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo bool created = false; if (p_id.track_idx < 0) { - if (p_create_beziers && (p_id.value.get_type() == Variant::INT || - p_id.value.get_type() == Variant::REAL || - p_id.value.get_type() == Variant::VECTOR2 || - p_id.value.get_type() == Variant::VECTOR3 || - p_id.value.get_type() == Variant::QUAT || - p_id.value.get_type() == Variant::COLOR || - p_id.value.get_type() == Variant::PLANE)) { - - Vector<String> subindices = _get_bezier_subindices_for_type(p_id.value.get_type()); - - for (int i = 0; i < subindices.size(); i++) { - InsertData id = p_id; - id.type = Animation::TYPE_BEZIER; - id.value = p_id.value.get(subindices[i].substr(1, subindices[i].length())); - id.path = String(p_id.path) + subindices[i]; - _confirm_insert(id, p_last_track + i); - } + if (p_create_beziers) { + bool valid; + Vector<String> subindices = _get_bezier_subindices_for_type(p_id.value.get_type(), &valid); + if (valid) { + for (int i = 0; i < subindices.size(); i++) { + InsertData id = p_id; + id.type = Animation::TYPE_BEZIER; + id.value = p_id.value.get(subindices[i].substr(1, subindices[i].length())); + id.path = String(p_id.path) + subindices[i]; + _confirm_insert(id, p_last_track + i); + } - return p_last_track + subindices.size() - 1; + return p_last_track + subindices.size(); + } } created = true; undo_redo->create_action(TTR("Anim Insert Track & Key")); @@ -4064,7 +4066,7 @@ int AnimationTrackEditor::_confirm_insert(InsertData p_id, int p_last_track, boo // Just remove the track. undo_redo->add_undo_method(this, "_clear_selection", false); - undo_redo->add_undo_method(animation.ptr(), "remove_track", p_last_track); + undo_redo->add_undo_method(animation.ptr(), "remove_track", animation->get_track_count()); p_last_track++; } else { @@ -4590,7 +4592,7 @@ void AnimationTrackEditor::_new_track_property_selected(String p_name) { for (int i = 0; i < subindices.size(); i++) { undo_redo->add_do_method(animation.ptr(), "add_track", adding_track_type); undo_redo->add_do_method(animation.ptr(), "track_set_path", base_track + i, full_path + subindices[i]); - undo_redo->add_undo_method(animation.ptr(), "remove_track", base_track + i); + undo_redo->add_undo_method(animation.ptr(), "remove_track", base_track); } undo_redo->commit_action(); } diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp index d5f0dc01ee..5344658223 100644 --- a/editor/create_dialog.cpp +++ b/editor/create_dialog.cpp @@ -811,6 +811,4 @@ CreateDialog::CreateDialog() { type_blacklist.insert("PluginScript"); // PluginScript must be initialized before use, which is not possible here type_blacklist.insert("ScriptCreateDialog"); // This is an exposed editor Node that doesn't have an Editor prefix. - - EDITOR_DEF("interface/editors/derive_script_globals_by_name", true); } diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 0f99e2ba1e..d472b41f2e 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -205,6 +205,29 @@ static void argument_doc_from_arginfo(DocData::ArgumentDoc &p_argument, const Pr } } +static Variant get_documentation_default_value(const StringName &p_class_name, const StringName &p_property_name, bool &r_default_value_valid) { + + Variant default_value = Variant(); + r_default_value_valid = false; + + if (ClassDB::can_instance(p_class_name)) { + default_value = ClassDB::class_get_default_property_value(p_class_name, p_property_name, &r_default_value_valid); + } else { + // Cannot get default value of classes that can't be instanced + List<StringName> inheriting_classes; + ClassDB::get_direct_inheriters_from_class(p_class_name, &inheriting_classes); + for (List<StringName>::Element *E2 = inheriting_classes.front(); E2; E2 = E2->next()) { + if (ClassDB::can_instance(E2->get())) { + default_value = ClassDB::class_get_default_property_value(E2->get(), p_property_name, &r_default_value_valid); + if (r_default_value_valid) + break; + } + } + } + + return default_value; +} + void DocData::generate(bool p_basic_types) { List<StringName> classes; @@ -229,47 +252,53 @@ void DocData::generate(bool p_basic_types) { c.category = ClassDB::get_category(name); List<PropertyInfo> properties; + List<PropertyInfo> own_properties; if (name == "ProjectSettings") { //special case for project settings, so settings can be documented ProjectSettings::get_singleton()->get_property_list(&properties); + own_properties = properties; } else { - ClassDB::get_property_list(name, &properties, true); + ClassDB::get_property_list(name, &properties); + ClassDB::get_property_list(name, &own_properties, true); } + List<PropertyInfo>::Element *EO = own_properties.front(); for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { + bool inherited = EO == NULL; + if (EO && EO->get() == E->get()) { + inherited = false; + EO = EO->next(); + } + if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL) continue; PropertyDoc prop; - StringName setter = ClassDB::get_property_setter(name, E->get().name); - StringName getter = ClassDB::get_property_getter(name, E->get().name); prop.name = E->get().name; - prop.setter = setter; - prop.getter = getter; - Variant default_value = Variant(); + prop.overridden = inherited; + bool default_value_valid = false; + Variant default_value = get_documentation_default_value(name, E->get().name, default_value_valid); - if (ClassDB::can_instance(name)) { - default_value = ClassDB::class_get_default_property_value(name, E->get().name, &default_value_valid); - } else { - // Cannot get default value of classes that can't be instanced - List<StringName> inheriting_classes; - ClassDB::get_direct_inheriters_from_class(name, &inheriting_classes); - for (List<StringName>::Element *E2 = inheriting_classes.front(); E2; E2 = E2->next()) { - if (ClassDB::can_instance(E2->get())) { - default_value = ClassDB::class_get_default_property_value(E2->get(), E->get().name, &default_value_valid); - if (default_value_valid) - break; - } - } + if (inherited) { + bool base_default_value_valid = false; + Variant base_default_value = get_documentation_default_value(ClassDB::get_parent_class(name), E->get().name, base_default_value_valid); + if (!default_value_valid || !base_default_value_valid || default_value == base_default_value) + continue; } if (default_value_valid && default_value.get_type() != Variant::OBJECT) { prop.default_value = default_value.get_construct_string().replace("\n", ""); } + StringName setter = ClassDB::get_property_setter(name, E->get().name); + StringName getter = ClassDB::get_property_getter(name, E->get().name); + + prop.setter = setter; + prop.getter = getter; + bool found_type = false; if (getter != StringName()) { MethodBind *mb = ClassDB::get_method(name, getter); @@ -843,7 +872,7 @@ Error DocData::_load(Ref<XMLParser> parser) { ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + "."); } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "tutorials") - break; //end of <tutorials> + break; // End of <tutorials>. } } else if (name2 == "methods") { @@ -876,16 +905,18 @@ Error DocData::_load(Ref<XMLParser> parser) { prop2.getter = parser->get_attribute_value("getter"); if (parser->has_attribute("enum")) prop2.enumeration = parser->get_attribute_value("enum"); - parser->read(); - if (parser->get_node_type() == XMLParser::NODE_TEXT) - prop2.description = parser->get_node_data(); + if (!parser->is_empty()) { + parser->read(); + if (parser->get_node_type() == XMLParser::NODE_TEXT) + prop2.description = parser->get_node_data(); + } c.properties.push_back(prop2); } else { ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + "."); } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "members") - break; //end of <constants> + break; // End of <members>. } } else if (name2 == "theme_items") { @@ -904,16 +935,18 @@ Error DocData::_load(Ref<XMLParser> parser) { prop2.name = parser->get_attribute_value("name"); ERR_FAIL_COND_V(!parser->has_attribute("type"), ERR_FILE_CORRUPT); prop2.type = parser->get_attribute_value("type"); - parser->read(); - if (parser->get_node_type() == XMLParser::NODE_TEXT) - prop2.description = parser->get_node_data(); + if (!parser->is_empty()) { + parser->read(); + if (parser->get_node_type() == XMLParser::NODE_TEXT) + prop2.description = parser->get_node_data(); + } c.theme_properties.push_back(prop2); } else { ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + "."); } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "theme_items") - break; //end of <constants> + break; // End of <theme_items>. } } else if (name2 == "constants") { @@ -934,16 +967,18 @@ Error DocData::_load(Ref<XMLParser> parser) { if (parser->has_attribute("enum")) { constant2.enumeration = parser->get_attribute_value("enum"); } - parser->read(); - if (parser->get_node_type() == XMLParser::NODE_TEXT) - constant2.description = parser->get_node_data(); + if (!parser->is_empty()) { + parser->read(); + if (parser->get_node_type() == XMLParser::NODE_TEXT) + constant2.description = parser->get_node_data(); + } c.constants.push_back(constant2); } else { ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Invalid tag in doc file: " + name3 + "."); } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "constants") - break; //end of <constants> + break; // End of <constants>. } } else { @@ -952,7 +987,7 @@ Error DocData::_load(Ref<XMLParser> parser) { } } else if (parser->get_node_type() == XMLParser::NODE_ELEMENT_END && parser->get_node_name() == "class") - break; //end of <asset> + break; // End of <class>. } } @@ -1076,10 +1111,16 @@ Error DocData::save_classes(const String &p_default_path, const Map<String, Stri if (c.properties[i].default_value != String()) { additional_attributes += " default=\"" + c.properties[i].default_value.xml_escape(true) + "\""; } + const PropertyDoc &p = c.properties[i]; - _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + additional_attributes + ">"); - _write_string(f, 3, p.description.strip_edges().xml_escape()); - _write_string(f, 2, "</member>"); + + if (c.properties[i].overridden) { + _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\" override=\"true\"" + additional_attributes + " />"); + } else { + _write_string(f, 2, "<member name=\"" + p.name + "\" type=\"" + p.type + "\" setter=\"" + p.setter + "\" getter=\"" + p.getter + "\"" + additional_attributes + ">"); + _write_string(f, 3, p.description.strip_edges().xml_escape()); + _write_string(f, 2, "</member>"); + } } _write_string(f, 1, "</members>"); } diff --git a/editor/doc/doc_data.h b/editor/doc/doc_data.h index 3d5867dcca..6d601f0dce 100644 --- a/editor/doc/doc_data.h +++ b/editor/doc/doc_data.h @@ -74,6 +74,7 @@ public: String description; String setter, getter; String default_value; + bool overridden; bool operator<(const PropertyDoc &p_prop) const { return name < p_prop.name; } diff --git a/editor/editor_audio_buses.cpp b/editor/editor_audio_buses.cpp index 2180742bbb..31095b1100 100644 --- a/editor/editor_audio_buses.cpp +++ b/editor/editor_audio_buses.cpp @@ -31,6 +31,7 @@ #include "editor_audio_buses.h" #include "core/io/resource_saver.h" +#include "core/os/input.h" #include "core/os/keyboard.h" #include "editor_node.h" #include "filesystem_dock.h" @@ -321,7 +322,13 @@ void EditorAudioBus::_volume_changed(float p_normalized) { updating_bus = true; - float p_db = this->_normalized_volume_to_scaled_db(p_normalized); + const float p_db = this->_normalized_volume_to_scaled_db(p_normalized); + + if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { + // Snap the value when holding Ctrl for easier editing. + // To do so, it needs to be converted back to normalized volume (as the slider uses that unit). + slider->set_value(_scaled_db_to_normalized_volume(Math::round(p_db))); + } UndoRedo *ur = EditorNode::get_undo_redo(); ur->create_action(TTR("Change Audio Bus Volume"), UndoRedo::MERGE_ENDS); @@ -376,14 +383,24 @@ float EditorAudioBus::_scaled_db_to_normalized_volume(float db) { } void EditorAudioBus::_show_value(float slider_value) { - String text = vformat("%10.1f dB", _normalized_volume_to_scaled_db(slider_value)); + float db; + if (Input::get_singleton()->is_key_pressed(KEY_CONTROL)) { + // Display the correct (snapped) value when holding Ctrl + db = Math::round(_normalized_volume_to_scaled_db(slider_value)); + } else { + db = _normalized_volume_to_scaled_db(slider_value); + } + + String text = vformat("%10.1f dB", db); + + slider->set_tooltip(text); audio_value_preview_label->set_text(text); Vector2 slider_size = slider->get_size(); Vector2 slider_position = slider->get_global_position(); float left_padding = 5.0f; float vert_padding = 10.0f; - Vector2 box_position = Vector2(slider_size.x + left_padding, (slider_size.y - vert_padding) * (1.0f - slider_value) - vert_padding); + Vector2 box_position = Vector2(slider_size.x + left_padding, (slider_size.y - vert_padding) * (1.0f - slider->get_value()) - vert_padding); audio_value_preview_box->set_position(slider_position + box_position); audio_value_preview_box->set_size(audio_value_preview_label->get_size()); if (slider->has_focus() && !audio_value_preview_box->is_visible()) { @@ -773,7 +790,7 @@ EditorAudioBus::EditorAudioBus(EditorAudioBuses *p_buses, bool p_is_master) { is_master = p_is_master; hovering_drop = false; - set_tooltip(TTR("Audio Bus, Drag and Drop to rearrange.")); + set_tooltip(TTR("Drag & drop to rearrange.")); VBoxContainer *vb = memnew(VBoxContainer); add_child(vb); @@ -1439,7 +1456,7 @@ Size2 EditorAudioMeterNotches::get_minimum_size() const { float width = 0; float height = top_padding + btm_padding; - for (uint8_t i = 0; i < notches.size(); i++) { + for (int i = 0; i < notches.size(); i++) { if (notches[i].render_db_value) { width = MAX(width, font->get_string_size(String::num(Math::abs(notches[i].db_value)) + "dB").x); height += font_height; @@ -1473,7 +1490,7 @@ void EditorAudioMeterNotches::_draw_audio_notches() { Ref<Font> font = get_font("font", "Label"); float font_height = font->get_height(); - for (uint8_t i = 0; i < notches.size(); i++) { + for (int i = 0; i < notches.size(); i++) { AudioNotch n = notches[i]; draw_line(Vector2(0, (1.0f - n.relative_position) * (get_size().y - btm_padding - top_padding) + top_padding), Vector2(line_length, (1.0f - n.relative_position) * (get_size().y - btm_padding - top_padding) + top_padding), diff --git a/editor/editor_feature_profile.cpp b/editor/editor_feature_profile.cpp index c6646eb28b..ee533d13c4 100644 --- a/editor/editor_feature_profile.cpp +++ b/editor/editor_feature_profile.cpp @@ -254,8 +254,8 @@ void EditorFeatureProfile::_bind_methods() { ClassDB::bind_method(D_METHOD("set_disable_class_editor", "class_name", "disable"), &EditorFeatureProfile::set_disable_class_editor); ClassDB::bind_method(D_METHOD("is_class_editor_disabled", "class_name"), &EditorFeatureProfile::is_class_editor_disabled); - ClassDB::bind_method(D_METHOD("set_disable_class_property", "class_name", "property"), &EditorFeatureProfile::set_disable_class_property); - ClassDB::bind_method(D_METHOD("is_class_property_disabled", "class_name"), &EditorFeatureProfile::is_class_property_disabled); + ClassDB::bind_method(D_METHOD("set_disable_class_property", "class_name", "property", "disable"), &EditorFeatureProfile::set_disable_class_property); + ClassDB::bind_method(D_METHOD("is_class_property_disabled", "class_name", "property"), &EditorFeatureProfile::is_class_property_disabled); ClassDB::bind_method(D_METHOD("set_disable_feature", "feature", "disable"), &EditorFeatureProfile::set_disable_feature); ClassDB::bind_method(D_METHOD("is_feature_disabled", "feature"), &EditorFeatureProfile::is_feature_disabled); diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index e6df00b48c..2b58d105de 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -30,6 +30,7 @@ #include "editor_help.h" +#include "core/os/input.h" #include "core/os/keyboard.h" #include "doc_data_compressed.gen.h" #include "editor/plugins/script_editor_plugin.h" @@ -257,16 +258,17 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview } class_desc->push_color(symbol_color); - class_desc->add_text(p_method.arguments.size() || is_vararg ? "( " : "("); + class_desc->add_text("("); class_desc->pop(); for (int j = 0; j < p_method.arguments.size(); j++) { class_desc->push_color(text_color); if (j > 0) class_desc->add_text(", "); - _add_type(p_method.arguments[j].type, p_method.arguments[j].enumeration); - class_desc->add_text(" "); + _add_text(p_method.arguments[j].name); + class_desc->add_text(": "); + _add_type(p_method.arguments[j].type, p_method.arguments[j].enumeration); if (p_method.arguments[j].default_value != "") { class_desc->push_color(symbol_color); @@ -291,7 +293,7 @@ void EditorHelp::_add_method(const DocData::MethodDoc &p_method, bool p_overview } class_desc->push_color(symbol_color); - class_desc->add_text(p_method.arguments.size() || is_vararg ? " )" : ")"); + class_desc->add_text(")"); class_desc->pop(); if (p_method.qualifiers != "") { @@ -424,7 +426,7 @@ void EditorHelp::_update_doc() { class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Brief Description:")); + class_desc->add_text(TTR("Brief Description")); class_desc->pop(); class_desc->pop(); @@ -451,7 +453,7 @@ void EditorHelp::_update_doc() { section_line.push_back(Pair<String, int>(TTR("Properties"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Properties:")); + class_desc->add_text(TTR("Properties")); class_desc->pop(); class_desc->pop(); @@ -487,6 +489,10 @@ void EditorHelp::_update_doc() { describe = true; } + if (cd.properties[i].overridden) { + describe = false; + } + class_desc->push_cell(); class_desc->push_font(doc_code_font); class_desc->push_color(headline_color); @@ -504,7 +510,7 @@ void EditorHelp::_update_doc() { if (cd.properties[i].default_value != "") { class_desc->push_color(symbol_color); - class_desc->add_text(" [default: "); + class_desc->add_text(cd.properties[i].overridden ? " [override: " : " [default: "); class_desc->pop(); class_desc->push_color(value_color); _add_text(_fix_constant(cd.properties[i].default_value)); @@ -547,7 +553,7 @@ void EditorHelp::_update_doc() { section_line.push_back(Pair<String, int>(TTR("Methods"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Methods:")); + class_desc->add_text(TTR("Methods")); class_desc->pop(); class_desc->pop(); @@ -618,7 +624,7 @@ void EditorHelp::_update_doc() { section_line.push_back(Pair<String, int>(TTR("Theme Properties"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Theme Properties:")); + class_desc->add_text(TTR("Theme Properties")); class_desc->pop(); class_desc->pop(); @@ -685,7 +691,7 @@ void EditorHelp::_update_doc() { section_line.push_back(Pair<String, int>(TTR("Signals"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Signals:")); + class_desc->add_text(TTR("Signals")); class_desc->pop(); class_desc->pop(); @@ -702,15 +708,16 @@ void EditorHelp::_update_doc() { _add_text(cd.signals[i].name); class_desc->pop(); class_desc->push_color(symbol_color); - class_desc->add_text(cd.signals[i].arguments.size() ? "( " : "("); + class_desc->add_text("("); class_desc->pop(); for (int j = 0; j < cd.signals[i].arguments.size(); j++) { class_desc->push_color(text_color); if (j > 0) class_desc->add_text(", "); - _add_type(cd.signals[i].arguments[j].type); - class_desc->add_text(" "); + _add_text(cd.signals[i].arguments[j].name); + class_desc->add_text(": "); + _add_type(cd.signals[i].arguments[j].type); if (cd.signals[i].arguments[j].default_value != "") { class_desc->push_color(symbol_color); @@ -723,7 +730,7 @@ void EditorHelp::_update_doc() { } class_desc->push_color(symbol_color); - class_desc->add_text(cd.signals[i].arguments.size() ? " )" : ")"); + class_desc->add_text(")"); class_desc->pop(); class_desc->pop(); // end monofont if (cd.signals[i].description != "") { @@ -770,7 +777,7 @@ void EditorHelp::_update_doc() { section_line.push_back(Pair<String, int>(TTR("Enumerations"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Enumerations:")); + class_desc->add_text(TTR("Enumerations")); class_desc->pop(); class_desc->pop(); class_desc->push_indent(1); @@ -856,7 +863,7 @@ void EditorHelp::_update_doc() { section_line.push_back(Pair<String, int>(TTR("Constants"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Constants:")); + class_desc->add_text(TTR("Constants")); class_desc->pop(); class_desc->pop(); class_desc->push_indent(1); @@ -916,7 +923,7 @@ void EditorHelp::_update_doc() { description_line = class_desc->get_line_count() - 2; class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Class Description:")); + class_desc->add_text(TTR("Class Description")); class_desc->pop(); class_desc->pop(); @@ -938,7 +945,7 @@ void EditorHelp::_update_doc() { { class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Online Tutorials:")); + class_desc->add_text(TTR("Online Tutorials")); class_desc->pop(); class_desc->pop(); class_desc->push_indent(1); @@ -980,7 +987,7 @@ void EditorHelp::_update_doc() { section_line.push_back(Pair<String, int>(TTR("Property Descriptions"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Property Descriptions:")); + class_desc->add_text(TTR("Property Descriptions")); class_desc->pop(); class_desc->pop(); @@ -989,6 +996,9 @@ void EditorHelp::_update_doc() { for (int i = 0; i < cd.properties.size(); i++) { + if (cd.properties[i].overridden) + continue; + property_line[cd.properties[i].name] = class_desc->get_line_count() - 2; class_desc->push_table(2); @@ -1090,7 +1100,7 @@ void EditorHelp::_update_doc() { section_line.push_back(Pair<String, int>(TTR("Method Descriptions"), class_desc->get_line_count() - 2)); class_desc->push_color(title_color); class_desc->push_font(doc_title_font); - class_desc->add_text(TTR("Method Descriptions:")); + class_desc->add_text(TTR("Method Descriptions")); class_desc->pop(); class_desc->pop(); @@ -1807,5 +1817,9 @@ void FindBar::_search_text_changed(const String &p_text) { void FindBar::_search_text_entered(const String &p_text) { - search_next(); + if (Input::get_singleton()->is_key_pressed(KEY_SHIFT)) { + search_prev(); + } else { + search_next(); + } } diff --git a/editor/editor_help_search.cpp b/editor/editor_help_search.cpp index af79c21f85..27e61362ed 100644 --- a/editor/editor_help_search.cpp +++ b/editor/editor_help_search.cpp @@ -338,10 +338,15 @@ bool EditorHelpSearch::Runner::_phase_match_classes() { if (search_flags & SEARCH_METHODS) for (int i = 0; i < class_doc.methods.size(); i++) { String method_name = (search_flags & SEARCH_CASE_SENSITIVE) ? class_doc.methods[i].name : class_doc.methods[i].name.to_lower(); - if (method_name.find(term) > -1 || - (term.begins_with(".") && method_name.begins_with(term.right(1))) || - (term.ends_with("(") && method_name.ends_with(term.left(term.length() - 1).strip_edges())) || - (term.begins_with(".") && term.ends_with("(") && method_name == term.substr(1, term.length() - 2).strip_edges())) + String aux_term = (search_flags & SEARCH_CASE_SENSITIVE) ? term : term.to_lower(); + + if (aux_term.begins_with(".")) + aux_term = aux_term.right(1); + + if (aux_term.ends_with("(")) + aux_term = aux_term.left(aux_term.length() - 1).strip_edges(); + + if (aux_term.is_subsequence_of(method_name)) match.methods.push_back(const_cast<DocData::MethodDoc *>(&class_doc.methods[i])); } if (search_flags & SEARCH_SIGNALS) @@ -431,9 +436,9 @@ bool EditorHelpSearch::Runner::_phase_select_match() { bool EditorHelpSearch::Runner::_match_string(const String &p_term, const String &p_string) const { if (search_flags & SEARCH_CASE_SENSITIVE) - return p_string.find(p_term) > -1; + return p_term.is_subsequence_of(p_string); else - return p_string.findn(p_term) > -1; + return p_term.is_subsequence_ofi(p_string); } void EditorHelpSearch::Runner::_match_item(TreeItem *p_item, const String &p_text) { diff --git a/editor/editor_network_profiler.cpp b/editor/editor_network_profiler.cpp index b90fe96cee..8482c4e38a 100644 --- a/editor/editor_network_profiler.cpp +++ b/editor/editor_network_profiler.cpp @@ -43,9 +43,15 @@ void EditorNetworkProfiler::_bind_methods() { void EditorNetworkProfiler::_notification(int p_what) { - if (p_what == NOTIFICATION_ENTER_TREE) { + if (p_what == NOTIFICATION_ENTER_TREE || p_what == NOTIFICATION_THEME_CHANGED) { activate->set_icon(get_icon("Play", "EditorIcons")); clear_button->set_icon(get_icon("Clear", "EditorIcons")); + incoming_bandwidth_text->set_right_icon(get_icon("ArrowDown", "EditorIcons")); + outgoing_bandwidth_text->set_right_icon(get_icon("ArrowUp", "EditorIcons")); + + // This needs to be done here to set the faded color when the profiler is first opened + incoming_bandwidth_text->add_color_override("font_color_uneditable", get_color("font_color", "Editor") * Color(1, 1, 1, 0.5)); + outgoing_bandwidth_text->add_color_override("font_color_uneditable", get_color("font_color", "Editor") * Color(1, 1, 1, 0.5)); } } @@ -113,6 +119,14 @@ void EditorNetworkProfiler::set_bandwidth(int p_incoming, int p_outgoing) { incoming_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_incoming))); outgoing_bandwidth_text->set_text(vformat(TTR("%s/s"), String::humanize_size(p_outgoing))); + + // Make labels more prominent when the bandwidth is greater than 0 to attract user attention + incoming_bandwidth_text->add_color_override( + "font_color_uneditable", + get_color("font_color", "Editor") * Color(1, 1, 1, p_incoming > 0 ? 1 : 0.5)); + outgoing_bandwidth_text->add_color_override( + "font_color_uneditable", + get_color("font_color", "Editor") * Color(1, 1, 1, p_outgoing > 0 ? 1 : 0.5)); } bool EditorNetworkProfiler::is_profiling() { @@ -139,27 +153,32 @@ EditorNetworkProfiler::EditorNetworkProfiler() { hb->add_spacer(); Label *lb = memnew(Label); - lb->set_text("Down "); + lb->set_text(TTR("Down")); hb->add_child(lb); incoming_bandwidth_text = memnew(LineEdit); incoming_bandwidth_text->set_editable(false); - incoming_bandwidth_text->set_custom_minimum_size(Size2(100, 0)); + incoming_bandwidth_text->set_custom_minimum_size(Size2(120, 0) * EDSCALE); incoming_bandwidth_text->set_align(LineEdit::Align::ALIGN_RIGHT); - incoming_bandwidth_text->set_text("0.0 B/s"); hb->add_child(incoming_bandwidth_text); + Control *down_up_spacer = memnew(Control); + down_up_spacer->set_custom_minimum_size(Size2(30, 0) * EDSCALE); + hb->add_child(down_up_spacer); + lb = memnew(Label); - lb->set_text("Up "); + lb->set_text(TTR("Up")); hb->add_child(lb); outgoing_bandwidth_text = memnew(LineEdit); outgoing_bandwidth_text->set_editable(false); - outgoing_bandwidth_text->set_custom_minimum_size(Size2(100, 0)); + outgoing_bandwidth_text->set_custom_minimum_size(Size2(120, 0) * EDSCALE); outgoing_bandwidth_text->set_align(LineEdit::Align::ALIGN_RIGHT); - outgoing_bandwidth_text->set_text("0.0 B/s"); hb->add_child(outgoing_bandwidth_text); + // Set initial texts in the incoming/outgoing bandwidth labels + set_bandwidth(0, 0); + counters_display = memnew(Tree); counters_display->set_custom_minimum_size(Size2(300, 0) * EDSCALE); counters_display->set_v_size_flags(SIZE_EXPAND_FILL); @@ -169,7 +188,7 @@ EditorNetworkProfiler::EditorNetworkProfiler() { counters_display->set_column_titles_visible(true); counters_display->set_column_title(0, TTR("Node")); counters_display->set_column_expand(0, true); - counters_display->set_column_min_width(0, 60); + counters_display->set_column_min_width(0, 60 * EDSCALE); counters_display->set_column_title(1, TTR("Incoming RPC")); counters_display->set_column_expand(1, false); counters_display->set_column_min_width(1, 120 * EDSCALE); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index 1d22de7679..1196a26882 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -2519,7 +2519,7 @@ void EditorNode::_menu_option_confirm(int p_option, bool p_confirmed) { bool was_visible = OS::get_singleton()->is_console_visible(); OS::get_singleton()->set_console_visible(!was_visible); - EditorSettings::get_singleton()->set_setting("interface/editor/hide_console_window", !was_visible); + EditorSettings::get_singleton()->set_setting("interface/editor/hide_console_window", was_visible); } break; case EDITOR_SCREENSHOT: { @@ -3133,7 +3133,14 @@ void EditorNode::_clear_undo_history() { void EditorNode::set_current_scene(int p_idx) { + //Save the folding in case the scene gets reloaded. + if (editor_data.get_scene_path(p_idx) != "") + editor_folding.save_scene_folding(editor_data.get_edited_scene_root(p_idx), editor_data.get_scene_path(p_idx)); + if (editor_data.check_and_update_scene(p_idx)) { + if (editor_data.get_scene_path(p_idx) != "") + editor_folding.load_scene_folding(editor_data.get_edited_scene_root(p_idx), editor_data.get_scene_path(p_idx)); + call_deferred("_clear_undo_history"); } diff --git a/editor/editor_path.cpp b/editor/editor_path.cpp index 12510e27de..f487a3048b 100644 --- a/editor/editor_path.cpp +++ b/editor/editor_path.cpp @@ -74,7 +74,12 @@ void EditorPath::_about_to_show() { objects.clear(); get_popup()->clear(); get_popup()->set_size(Size2(get_size().width, 1)); + _add_children_to_popup(obj); + if (get_popup()->get_item_count() == 0) { + get_popup()->add_item(TTR("No sub-resources found.")); + get_popup()->set_item_disabled(0, true); + } } void EditorPath::update_path() { diff --git a/editor/editor_properties.cpp b/editor/editor_properties.cpp index 30fb561fbe..f456cf7233 100644 --- a/editor/editor_properties.cpp +++ b/editor/editor_properties.cpp @@ -922,16 +922,29 @@ EditorPropertyFloat::EditorPropertyFloat() { void EditorPropertyEasing::_drag_easing(const Ref<InputEvent> &p_ev) { - Ref<InputEventMouseButton> mb = p_ev; - if (mb.is_valid() && mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) { - preset->set_global_position(easing_draw->get_global_transform().xform(mb->get_position())); - preset->popup(); - } - if (mb.is_valid() && mb->is_doubleclick() && mb->get_button_index() == BUTTON_LEFT) { - _setup_spin(); + const Ref<InputEventMouseButton> mb = p_ev; + if (mb.is_valid()) { + if (mb->is_doubleclick() && mb->get_button_index() == BUTTON_LEFT) { + _setup_spin(); + } + + if (mb->is_pressed() && mb->get_button_index() == BUTTON_RIGHT) { + preset->set_global_position(easing_draw->get_global_transform().xform(mb->get_position())); + preset->popup(); + + // Ensure the easing doesn't appear as being dragged + dragging = false; + easing_draw->update(); + } + + if (mb->get_button_index() == BUTTON_LEFT) { + dragging = mb->is_pressed(); + // Update to display the correct dragging color + easing_draw->update(); + } } - Ref<InputEventMouseMotion> mm = p_ev; + const Ref<InputEventMouseMotion> mm = p_ev; if (mm.is_valid() && mm->get_button_mask() & BUTTON_MASK_LEFT) { @@ -969,13 +982,19 @@ void EditorPropertyEasing::_draw_easing() { Rect2 r(Point2(), s); r = r.grow(3); - int points = 48; + const int points = 48; float prev = 1.0; - float exp = get_edited_object()->get(get_edited_property()); + const float exp = get_edited_object()->get(get_edited_property()); - Ref<Font> f = get_font("font", "Label"); - Color color = get_color("font_color", "Label"); + const Ref<Font> f = get_font("font", "Label"); + const Color font_color = get_color("font_color", "Label"); + Color line_color; + if (dragging) { + line_color = get_color("accent_color", "Editor"); + } else { + line_color = get_color("font_color", "Label") * Color(1, 1, 1, 0.9); + } Vector<Point2> lines; for (int i = 1; i <= points; i++) { @@ -983,7 +1002,7 @@ void EditorPropertyEasing::_draw_easing() { float ifl = i / float(points); float iflp = (i - 1) / float(points); - float h = 1.0 - Math::ease(ifl, exp); + const float h = 1.0 - Math::ease(ifl, exp); if (flip) { ifl = 1.0 - ifl; @@ -995,8 +1014,8 @@ void EditorPropertyEasing::_draw_easing() { prev = h; } - easing_draw->draw_multiline(lines, color, 1.0, true); - f->draw(ci, Point2(10, 10 + f->get_ascent()), String::num(exp, 2), color); + easing_draw->draw_multiline(lines, line_color, 1.0, true); + f->draw(ci, Point2(10, 10 + f->get_ascent()), String::num(exp, 2), font_color); } void EditorPropertyEasing::update_property() { @@ -1033,6 +1052,9 @@ void EditorPropertyEasing::_spin_value_changed(double p_value) { void EditorPropertyEasing::_spin_focus_exited() { spin->hide(); + // Ensure the easing doesn't appear as being dragged + dragging = false; + easing_draw->update(); } void EditorPropertyEasing::setup(bool p_full, bool p_flip) { @@ -1095,6 +1117,7 @@ EditorPropertyEasing::EditorPropertyEasing() { spin->hide(); add_child(spin); + dragging = false; flip = false; full = false; } diff --git a/editor/editor_properties.h b/editor/editor_properties.h index adf7779dc4..b8d6aa00c2 100644 --- a/editor/editor_properties.h +++ b/editor/editor_properties.h @@ -311,6 +311,7 @@ class EditorPropertyEasing : public EditorProperty { EditorSpinSlider *spin; bool setting; + bool dragging; bool full; bool flip; diff --git a/editor/editor_properties_array_dict.cpp b/editor/editor_properties_array_dict.cpp index ff19be8bd5..8abe91bdc1 100644 --- a/editor/editor_properties_array_dict.cpp +++ b/editor/editor_properties_array_dict.cpp @@ -264,7 +264,9 @@ void EditorPropertyArray::update_property() { edit->set_text(String("(Nil) ") + arrtype); edit->set_pressed(false); if (vbox) { + set_bottom_editor(NULL); memdelete(vbox); + vbox = NULL; } return; } @@ -631,7 +633,9 @@ void EditorPropertyDictionary::update_property() { edit->set_text("Dictionary (Nil)"); //This provides symmetry with the array property. edit->set_pressed(false); if (vbox) { + set_bottom_editor(NULL); memdelete(vbox); + vbox = NULL; } return; } diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index 42c55681ae..32b57e0d65 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -785,7 +785,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("font_color_fg", "Tabs", font_color); theme->set_color("font_color_bg", "Tabs", font_color_disabled); theme->set_icon("menu", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons")); - theme->set_icon("menu_hl", "TabContainer", theme->get_icon("GuiTabMenu", "EditorIcons")); + theme->set_icon("menu_highlight", "TabContainer", theme->get_icon("GuiTabMenuHl", "EditorIcons")); theme->set_stylebox("SceneTabFG", "EditorStyles", style_tab_selected); theme->set_stylebox("SceneTabBG", "EditorStyles", style_tab_unselected); theme->set_icon("close", "Tabs", theme->get_icon("GuiClose", "EditorIcons")); @@ -795,10 +795,10 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_icon("decrement", "TabContainer", theme->get_icon("GuiScrollArrowLeft", "EditorIcons")); theme->set_icon("increment", "Tabs", theme->get_icon("GuiScrollArrowRight", "EditorIcons")); theme->set_icon("decrement", "Tabs", theme->get_icon("GuiScrollArrowLeft", "EditorIcons")); - theme->set_icon("increment_highlight", "Tabs", theme->get_icon("GuiScrollArrowRight", "EditorIcons")); - theme->set_icon("decrement_highlight", "Tabs", theme->get_icon("GuiScrollArrowLeft", "EditorIcons")); - theme->set_icon("increment_highlight", "TabContainer", theme->get_icon("GuiScrollArrowRight", "EditorIcons")); - theme->set_icon("decrement_highlight", "TabContainer", theme->get_icon("GuiScrollArrowLeft", "EditorIcons")); + theme->set_icon("increment_highlight", "Tabs", theme->get_icon("GuiScrollArrowRightHl", "EditorIcons")); + theme->set_icon("decrement_highlight", "Tabs", theme->get_icon("GuiScrollArrowLeftHl", "EditorIcons")); + theme->set_icon("increment_highlight", "TabContainer", theme->get_icon("GuiScrollArrowRightHl", "EditorIcons")); + theme->set_icon("decrement_highlight", "TabContainer", theme->get_icon("GuiScrollArrowLeftHl", "EditorIcons")); theme->set_constant("hseparation", "Tabs", 4 * EDSCALE); // Content of each tab diff --git a/editor/editor_vcs_interface.cpp b/editor/editor_vcs_interface.cpp index 8da1777871..4df2a06736 100644 --- a/editor/editor_vcs_interface.cpp +++ b/editor/editor_vcs_interface.cpp @@ -78,18 +78,12 @@ Dictionary EditorVCSInterface::_get_modified_files_data() { } void EditorVCSInterface::_stage_file(String p_file_path) { - - return; } void EditorVCSInterface::_unstage_file(String p_file_path) { - - return; } void EditorVCSInterface::_commit(String p_msg) { - - return; } Array EditorVCSInterface::_get_file_diff(String p_file_path) { @@ -134,7 +128,6 @@ void EditorVCSInterface::stage_file(String p_file_path) { call("_stage_file", p_file_path); } - return; } void EditorVCSInterface::unstage_file(String p_file_path) { @@ -143,7 +136,6 @@ void EditorVCSInterface::unstage_file(String p_file_path) { call("_unstage_file", p_file_path); } - return; } bool EditorVCSInterface::is_addon_ready() { @@ -157,7 +149,6 @@ void EditorVCSInterface::commit(String p_msg) { call("_commit", p_msg); } - return; } Array EditorVCSInterface::get_file_diff(String p_file_path) { diff --git a/editor/icons/icon_GUI_mini_tab_menu.svg b/editor/icons/icon_GUI_mini_tab_menu.svg deleted file mode 100644 index 8aeb85277c..0000000000 --- a/editor/icons/icon_GUI_mini_tab_menu.svg +++ /dev/null @@ -1,5 +0,0 @@ -<svg width="6" height="16" version="1.1" viewBox="0 0 6 16" xmlns="http://www.w3.org/2000/svg"> -<g transform="translate(0 -1036.4)"> -<path transform="translate(0 1036.4)" d="m3 0a2 2 0 0 0 -2 2 2 2 0 0 0 2 2 2 2 0 0 0 2 -2 2 2 0 0 0 -2 -2zm0 6a2 2 0 0 0 -2 2 2 2 0 0 0 2 2 2 2 0 0 0 2 -2 2 2 0 0 0 -2 -2zm0 6a2 2 0 0 0 -2 2 2 2 0 0 0 2 2 2 2 0 0 0 2 -2 2 2 0 0 0 -2 -2z" fill="#fff" fill-opacity=".39216"/> -</g> -</svg> diff --git a/editor/icons/icon_GUI_scroll_arrow_left_hl.svg b/editor/icons/icon_GUI_scroll_arrow_left_hl.svg new file mode 100644 index 0000000000..c4ce1c4432 --- /dev/null +++ b/editor/icons/icon_GUI_scroll_arrow_left_hl.svg @@ -0,0 +1,3 @@ +<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> +<path d="m8 2a6 6 0 0 1 6 6 6 6 0 0 1-6 6 6 6 0 0 1-6-6 6 6 0 0 1 6-6zm1.0137 2a1 1 0 0 0-0.7207 0.29297l-3 3a1.0001 1.0001 0 0 0 0 1.4141l3 3a1 1 0 0 0 1.4141 0 1 1 0 0 0 0-1.4141l-2.293-2.293 2.293-2.293a1 1 0 0 0 0-1.4141 1 1 0 0 0-0.69336-0.29297z" fill="#e0e0e0" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> +</svg> diff --git a/editor/icons/icon_GUI_scroll_arrow_right_hl.svg b/editor/icons/icon_GUI_scroll_arrow_right_hl.svg new file mode 100644 index 0000000000..0727b684eb --- /dev/null +++ b/editor/icons/icon_GUI_scroll_arrow_right_hl.svg @@ -0,0 +1,3 @@ +<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> +<path d="m8 2a6 6 0 0 0-6 6 6 6 0 0 0 6 6 6 6 0 0 0 6-6 6 6 0 0 0-6-6zm-1.0137 2a1 1 0 0 1 0.7207 0.29297l3 3a1.0001 1.0001 0 0 1 0 1.4141l-3 3a1 1 0 0 1-1.4141 0 1 1 0 0 1 0-1.4141l2.293-2.293-2.293-2.293a1 1 0 0 1 0-1.4141 1 1 0 0 1 0.69336-0.29297z" fill="#e0e0e0" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"/> +</svg> diff --git a/editor/icons/icon_GUI_tab_menu_hl.svg b/editor/icons/icon_GUI_tab_menu_hl.svg new file mode 100644 index 0000000000..e7be7c9154 --- /dev/null +++ b/editor/icons/icon_GUI_tab_menu_hl.svg @@ -0,0 +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)" fill="#e0e0e0"> +<path transform="translate(0 1036.4)" d="m8 0a2 2 0 0 0-2 2 2 2 0 0 0 2 2 2 2 0 0 0 2-2 2 2 0 0 0-2-2zm0 6a2 2 0 0 0-2 2 2 2 0 0 0 2 2 2 2 0 0 0 2-2 2 2 0 0 0-2-2zm0 6a2 2 0 0 0-2 2 2 2 0 0 0 2 2 2 2 0 0 0 2-2 2 2 0 0 0-2-2z" fill="#e0e0e0"/> +</g> +</svg> diff --git a/editor/icons/icon_arrow_down.svg b/editor/icons/icon_arrow_down.svg new file mode 100644 index 0000000000..49a93e6e28 --- /dev/null +++ b/editor/icons/icon_arrow_down.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8 3.002a1 1 0 0 0 -.69336.29102 1 1 0 0 0 0 1.4141l2.293 2.293h-4.5859c-.55228 0-1 .4477-1 1s.44772 1 1 1h4.5859l-2.293 2.293a1 1 0 0 0 0 1.4141 1 1 0 0 0 1.4141 0l4-4a1.0001 1.0001 0 0 0 0-1.4141l-4-4a1 1 0 0 0 -.7207-.29102z" fill="#e0e0e0" fill-opacity=".99608" transform="matrix(0 1 -1 0 16.0021 -.00004)"/></svg>
\ No newline at end of file diff --git a/editor/icons/icon_arrow_up.svg b/editor/icons/icon_arrow_up.svg new file mode 100644 index 0000000000..9bf19a6a12 --- /dev/null +++ b/editor/icons/icon_arrow_up.svg @@ -0,0 +1 @@ +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m8.00008 1049.4022a1 1 0 0 0 .69336-.291 1 1 0 0 0 0-1.4141l-2.293-2.293h4.5859c.55228 0 1-.4477 1-1s-.44772-1-1-1h-4.5859l2.293-2.293a1 1 0 0 0 0-1.4141 1 1 0 0 0 -1.4141 0l-4 4a1.0001 1.0001 0 0 0 0 1.4141l4 4a1 1 0 0 0 .7207.291z" fill="#e0e0e0" fill-opacity=".99608" transform="matrix(0 1 -1 0 1052.4021 -.00004)"/></svg>
\ No newline at end of file diff --git a/editor/icons/icon_bus_vu_db.svg b/editor/icons/icon_bus_vu_db.svg deleted file mode 100644 index 236e41e1f5..0000000000 --- a/editor/icons/icon_bus_vu_db.svg +++ /dev/null @@ -1,12 +0,0 @@ -<svg width="32" height="128" version="1.1" viewBox="0 0 32 128" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> -<defs> -<linearGradient id="a" x1="16" x2="16" y2="128" gradientUnits="userSpaceOnUse"> -<stop stop-color="#ff7a7a" offset="0"/> -<stop stop-color="#e1dc7a" offset=".5"/> -<stop stop-color="#66ff9e" offset="1"/> -</linearGradient> -</defs> -<g transform="translate(0 -924.36)"> -<path transform="translate(0 924.36)" d="m1.5 0c-0.831 0-1.5 0.669-1.5 1.5 0 0.831 0.669 1.5 1.5 1.5h2c0.831 0 1.5-0.669 1.5-1.5 0-0.831-0.669-1.5-1.5-1.5h-2zm0 7c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5 1.5-0.669 1.5-1.5-0.669-1.5-1.5-1.5zm22.5 3.75c-1.5 0-3 1.3056-3 3.25-0.01912 1.3523 2.0191 1.3523 2 0 0-1.0556 0.5-1.25 1-1.25s1 0.19444 1 1.25c0 0.59157-0.35893 1.156-1.1914 1.8633-0.83248 0.70724-2.0616 1.4518-3.3574 2.3008-0.82974 0.54516-0.44398 1.8356 0.54883 1.8359h5c1.3523 0.01912 1.3523-2.0191 0-2h-1.7852c0.28375-0.20667 0.63106-0.39443 0.88867-0.61328 1.0302-0.87519 1.8965-1.9783 1.8965-3.3867 0-1.9444-1.5-3.25-3-3.25zm-7.0293 0.25195c-0.14519 0.0037-0.28782 0.03907-0.41797 0.10352l-2 1c-1.1924 0.59646-0.29787 2.3855 0.89453 1.7891l0.55273-0.27539v5.3809c-0.01913 1.3523 2.0191 1.3523 2 0v-7c-9.16e-4 -0.56314-0.4664-1.0145-1.0293-0.99805zm-15.471 2.998c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5h2c0.831 0 1.5-0.669 1.5-1.5s-0.669-1.5-1.5-1.5h-2zm0 7c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5 1.5-0.669 1.5-1.5-0.669-1.5-1.5-1.5zm21.5 3c-0.554 0-1 0.446-1 1v1 2h-0.92969c-0.02343-8.24e-4 -0.046882-8.24e-4 -0.070312 0-1.0702 0-2.0626 0.57318-2.5977 1.5-0.5351 0.92681-0.5351 2.0732 0 3 0.5351 0.92681 1.5275 1.5 2.5977 1.5h2c0.554 0 1-0.446 1-1v-8c0-0.554-0.446-1-1-1zm4 0c-0.554 0-1 0.446-1 1v8c0 0.554 0.446 1 1 1h2c1.0702 0 2.0626-0.57319 2.5977-1.5 0.5351-0.92682 0.5351-2.0732 0-3-0.10504-0.18193-0.23173-0.34698-0.36914-0.5 0.1378-0.15331 0.26385-0.31764 0.36914-0.5 0.5351-0.92682 0.5351-2.0732 0-3-0.5351-0.92682-1.5275-1.5-2.5977-1.5h-2zm-14 1c-1.6447 0-3 1.3553-3 3v3c0 1.6447 1.3553 3 3 3s3-1.3553 3-3v-3c0-1.6447-1.3553-3-3-3zm15 1h1c0.35887 0 0.6858 0.18921 0.86523 0.5 0.17944 0.31079 0.17944 0.68921 0 1-0.17943 0.31079-0.50636 0.5-0.86523 0.5h-0.070312-0.92969v-2zm-15 1c0.5713 0 1 0.4287 1 1v3c0 0.5713-0.4287 1-1 1s-1-0.4287-1-1v-3c0-0.5713 0.4287-1 1-1zm-11.5 1c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5h2c0.831 0 1.5-0.669 1.5-1.5s-0.669-1.5-1.5-1.5h-2zm19.5 2h1v2h-0.92969c-0.02343-8.24e-4 -0.046882-8.24e-4 -0.070312 0-0.35887 0-0.6858-0.18921-0.86523-0.5-0.17944-0.31079-0.17944-0.68921 0-1 0.17943-0.31079 0.50636-0.5 0.86523-0.5zm7 0h1c0.35887 0 0.6858 0.18921 0.86523 0.5 0.17944 0.31079 0.17944 0.68921 0 1-0.17943 0.31079-0.50636 0.5-0.86523 0.5h-1v-2zm-26.5 5c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5 1.5-0.669 1.5-1.5-0.669-1.5-1.5-1.5zm22.5 2.75c-1.5 0-3 1.3056-3 3.25-0.01912 1.3523 2.0191 1.3523 2 0 0-1.0556 0.5-1.25 1-1.25s1 0.19444 1 1.25c0 0.59157-0.35893 1.156-1.1914 1.8633-0.83248 0.70724-2.0616 1.4518-3.3574 2.3008-0.82974 0.54516-0.44398 1.8356 0.54883 1.8359h5c1.3523 0.01913 1.3523-2.0191 0-2h-1.7852c0.28375-0.20667 0.63106-0.39443 0.88867-0.61328 1.0302-0.87519 1.8965-1.9783 1.8965-3.3867 0-1.9444-1.5-3.25-3-3.25zm-7.0293 0.25195c-0.14519 0.0037-0.28782 0.03907-0.41797 0.10352l-2 1c-1.1924 0.59646-0.29787 2.3855 0.89453 1.7891l0.55273-0.27539v5.3809c-0.01913 1.3523 2.0191 1.3523 2 0v-7c-9.16e-4 -0.56314-0.4664-1.0145-1.0293-0.99805zm-15.471 3.998c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5h2c0.831 0 1.5-0.669 1.5-1.5s-0.669-1.5-1.5-1.5h-2zm7.5 1v2h3v-2h-3zm-7 6c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5 1.5-0.669 1.5-1.5-0.669-1.5-1.5-1.5zm15.986 3.75c-1.5 0-3 1.3056-3 3.25-0.01913 1.3523 2.0191 1.3523 2 0 0-1.0556 0.5-1.25 1-1.25s1 0.19444 1 1.25c0 0.59157-0.35893 1.156-1.1914 1.8633s-2.0616 1.4518-3.3574 2.3008c-0.82974 0.54516-0.44398 1.8356 0.54883 1.8359h5c1.3523 0.01913 1.3523-2.0191 0-2h-1.7871c0.2841-0.20689 0.63273-0.39419 0.89062-0.61328 1.0302-0.87519 1.8965-1.9783 1.8965-3.3867 0-1.9444-1.5-3.25-3-3.25zm7.0469 0.23828c-0.36561-0.0093-0.70715 0.18167-0.89062 0.49805l-3 5c-0.39877 0.66633 0.080888 1.5131 0.85742 1.5137h3v1c-0.01912 1.3523 2.0191 1.3523 2 0v-2c-5.5e-5 -0.55226-0.44774-0.99994-1-1h-2.2324l2.0898-3.4844c0.40768-0.65656-0.05163-1.5077-0.82422-1.5273zm-23.533 3.0117c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5h2c0.831 0 1.5-0.669 1.5-1.5s-0.669-1.5-1.5-1.5h-2zm7.5 2v2h3v-2h-3zm-7.5 5c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5 1.5-0.669 1.5-1.5-0.669-1.5-1.5-1.5zm24.547 4.9961c-0.12355-0.0037-0.24673 0.01547-0.36328 0.05664 0 0-0.98349 0.3331-1.8906 1.2402-0.90714 0.90717-1.793 2.457-1.793 4.707-6.13e-4 0.07218 0.006604 0.14421 0.021484 0.21484 0.11389 1.5445 1.4072 2.7852 2.9785 2.7852 1.645 0 3-1.355 3-3 0-1.645-1.355-3-3-3-0.01533 0-0.029642 0.003706-0.044922 0.003906 0.084-0.10099 0.16695-0.21188 0.25195-0.29688 0.59286-0.59287 1.1094-0.75781 1.1094-0.75781 1.0726-0.33926 0.85487-1.9171-0.26953-1.9531zm-9.0605 0.005859c-1.0407 0.006928-2.0405 0.55674-2.584 1.498a1 1 0 0 0 0.36523 1.3672 1 1 0 0 0 1.3672 -0.36719c0.24596-0.42602 0.74477-0.6077 1.207-0.43945 0.46226 0.16824 0.728 0.62882 0.64258 1.1133-0.085422 0.48445-0.49245 0.82617-0.98438 0.82617a1 1 0 0 0 -1 1 1 1 0 0 0 1 1c0.49193 0 0.89896 0.34368 0.98438 0.82812 0.085422 0.48446-0.18032 0.94508-0.64258 1.1133-0.46226 0.1683-0.96107-0.015436-1.207-0.44141-0.27644-0.47871-0.88884-0.6423-1.3672-0.36523-0.47752 0.27639-0.64095 0.88733-0.36523 1.3652 0.72462 1.2553 2.2612 1.816 3.623 1.3203 1.3618-0.4956 2.1813-1.9126 1.9297-3.3398-0.1003-0.56884-0.37254-1.0676-0.74023-1.4746 0.37098-0.40777 0.63937-0.91234 0.74023-1.4844 0.25166-1.4272-0.56786-2.8442-1.9297-3.3398-0.34046-0.12392-0.69218-0.182-1.0391-0.17969zm-15.486 1.998c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5h2c0.831 0 1.5-0.669 1.5-1.5s-0.669-1.5-1.5-1.5h-2zm7.5 2v2h3v-2h-3zm16 1c0.56413 0 1 0.43587 1 1s-0.43587 1-1 1-1-0.43587-1-1 0.43587-1 1-1zm-23.5 4c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5 1.5-0.669 1.5-1.5-0.669-1.5-1.5-1.5zm16.533 3.9883c-0.36561-0.0093-0.70715 0.18167-0.89062 0.49805l-3 5c-0.39877 0.66633 0.080888 1.5131 0.85742 1.5137h3v1c-0.01912 1.3523 2.0191 1.3523 2 0v-2c-5.5e-5 -0.55226-0.44774-0.99994-1-1h-2.2324l2.0898-3.4844c0.40768-0.65656-0.05163-1.5077-0.82422-1.5273zm6.9668 0.011719c-1.645 0-3 1.355-3 3 0 0.769 0.30369 1.4666 0.78711 2-0.48282 0.53332-0.78711 1.2315-0.78711 2 0 1.645 1.355 3 3 3s3-1.355 3-3c0-0.76846-0.30429-1.4667-0.78711-2 0.48342-0.53345 0.78711-1.231 0.78711-2 0-1.645-1.355-3-3-3zm0 2c0.56413 0 1 0.4359 1 1 0 0.5642-0.43587 1-1 1s-1-0.4358-1-1c0-0.5641 0.43587-1 1-1zm-23.5 1c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5h2c0.831 0 1.5-0.669 1.5-1.5s-0.669-1.5-1.5-1.5h-2zm7.5 2v2h3v-2h-3zm16 1c0.56413 0 1 0.4359 1 1 0 0.5642-0.43587 1-1 1s-1-0.4358-1-1c0-0.5641 0.43587-1 1-1zm-23.5 4c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5 1.5-0.669 1.5-1.5-0.669-1.5-1.5-1.5zm16.447 3.9824c-0.08995 0.0063-0.17865 0.024647-0.26367 0.054687 0 0-0.98349 0.33509-1.8906 1.2422-0.90714 0.9068-1.793 2.457-1.793 4.707-6.13e-4 0.0722 0.006604 0.14421 0.021484 0.21484 0.11389 1.5445 1.4072 2.7852 2.9785 2.7852 1.645 0 3-1.355 3-3 0-1.6451-1.355-3-3-3-0.01533 0-0.029642 0.003706-0.044922 0.003906 0.084-0.10099 0.16695-0.21187 0.25195-0.29688 0.59286-0.5929 1.1094-0.75781 1.1094-0.75781 1.0726-0.33926 0.85487-1.9171-0.26953-1.9531-0.03318-0.0017-0.066429-0.0017-0.099609 0zm7.0527 0.017578c-1.6447 0-3 1.3553-3 3v3c0 1.6447 1.3553 3 3 3s3-1.3553 3-3v-3c0-1.6447-1.3553-3-3-3zm0 2c0.5713 0 1 0.4287 1 1v3c0 0.5713-0.4287 1-1 1s-1-0.4287-1-1v-3c0-0.5713 0.4287-1 1-1zm-23.5 1c-0.831 0-1.5 0.669-1.5 1.5 0 0.831 0.669 1.5 1.5 1.5h2c0.831 0 1.5-0.669 1.5-1.5 0-0.831-0.669-1.5-1.5-1.5h-2zm15.5 1.9863c0.56413 0 1 0.4358 1 1 0 0.5641-0.43587 1-1 1s-1-0.4359-1-1c0-0.5642 0.43587-1 1-1zm-8 0.013672v2h3v-2h-3zm-7.5 5c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5 1.5-0.669 1.5-1.5-0.669-1.5-1.5-1.5zm22.5 3.75c-1.5 0-3 1.3056-3 3.25-0.01912 1.3523 2.0191 1.3523 2 0 0-1.0555 0.5-1.25 1-1.25s1 0.1945 1 1.25c0 0.5916-0.35893 1.1561-1.1914 1.8633-0.83248 0.7072-2.0616 1.4518-3.3574 2.3008-0.82975 0.54515-0.44398 1.8356 0.54883 1.8359h5c1.3523 0.0191 1.3523-2.0191 0-2h-1.7852c0.28375-0.2066 0.63106-0.39438 0.88867-0.61328 1.0302-0.8751 1.8965-1.9782 1.8965-3.3867 0-1.9444-1.5-3.25-3-3.25zm-10 0.25c-1.3523-0.0191-1.3523 2.0191 0 2h3.3828l-3.2773 6.5527c-0.59596 1.1926 1.1931 2.0871 1.7891 0.89454l4-8c0.33239-0.66495-0.15113-1.4472-0.89453-1.4473h-5zm-12.5 3c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5h2c0.831 0 1.5-0.669 1.5-1.5s-0.669-1.5-1.5-1.5h-2zm7.5 2v2h3v-2h-3zm-7.5 5c-0.831 0-1.5 0.669-1.5 1.5s0.669 1.5 1.5 1.5 1.5-0.669 1.5-1.5-0.669-1.5-1.5-1.5z" fill="url(#a)"/> -</g> -</svg> diff --git a/editor/icons/icon_camera_texture.svg b/editor/icons/icon_camera_texture.svg new file mode 100644 index 0000000000..5629487451 --- /dev/null +++ b/editor/icons/icon_camera_texture.svg @@ -0,0 +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="m2 1c-0.55228 0-1 0.44772-1 1v12c0 0.55228 0.44772 1 1 1h12c0.55228 0 1-0.44772 1-1v-12c0-0.55228-0.44772-1-1-1h-12zm1 2h10v8h-10v-8zm5.8184 1.0039c-0.85534 9.758e-4 -1.5654 0.66069-1.6289 1.5137-0.30036-0.27229-0.69029-0.4234-1.0957-0.42383-0.90315 0-1.6367 0.73162-1.6367 1.6348 9.732e-4 0.69217 0.43922 1.3103 1.0918 1.541v1.1855c0 0.30198 0.24293 0.54492 0.54492 0.54492h3.2695c0.30199 0 0.54492-0.24294 0.54492-0.54492v-0.54492l1.6367 1.0898v-3.2715l-1.6367 1.0918v-0.96484c0.34606-0.30952 0.54406-0.75251 0.54492-1.2168 0-0.90315-0.73162-1.6348-1.6348-1.6348z" fill="#e0e0e0" fill-opacity=".99608"/> +</g> +</svg> diff --git a/editor/icons/icon_clipped_camera.svg b/editor/icons/icon_clipped_camera.svg new file mode 100644 index 0000000000..dd26abc638 --- /dev/null +++ b/editor/icons/icon_clipped_camera.svg @@ -0,0 +1,3 @@ +<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> +<path d="m6.5 12v4h3v-1h-2v-3zm-1 0h-2c-0.5 0-1 0.5-1 1v2c-0.01829 0.53653 0.5 1 1 1h2v-1h-2v-2h2zm4-12c-1.5691 0.0017903-2.8718 1.2125-2.9883 2.7773-0.55103-0.49952-1.268-0.77655-2.0117-0.77734-1.6569 0-3 1.3431-3 3 0.00179 1.2698 0.80282 2.4009 2 2.8242v2.1758c0 0.554 0.44599 1 1 1h6c0.55401 0 1-0.446 1-1v-1l3 2v-6l-3 2v-1.7695c0.63486-0.56783 0.99842-1.3788 1-2.2305 0-1.6569-1.3431-3-3-3zm1 12v4h1v-1h1c0.55228 0 1-0.44772 1-1v-1c0-0.55228-0.44775-0.99374-1-1h-1zm1 1h1v1h-1z" fill="#fc9c9c"/> +</svg> diff --git a/editor/icons/icon_height_map_shape.svg b/editor/icons/icon_height_map_shape.svg new file mode 100644 index 0000000000..09d129a273 --- /dev/null +++ b/editor/icons/icon_height_map_shape.svg @@ -0,0 +1,12 @@ +<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> +<defs> +<linearGradient id="a" x1="8" x2="8" y1="8" y2="11" gradientUnits="userSpaceOnUse"> +<stop stop-color="#68b6ff" offset="0"/> +<stop stop-color="#a2d2ff" offset="1"/> +</linearGradient> +</defs> +<g transform="translate(0,-1)"> +<path transform="translate(0,-1033.4)" d="m1 1044.4 7 3 7-3-7-3z" fill="#a2d2ff" fill-rule="evenodd"/> +<path d="m3 11c1-1 2-2 2-4s1-3 3-3 3 1 3 3 1 3 2 4z" fill="url(#a)"/> +</g> +</svg> diff --git a/editor/icons/icon_interpolated_camera.svg b/editor/icons/icon_interpolated_camera.svg index 7a33c64ca2..24b4832105 100644 --- a/editor/icons/icon_interpolated_camera.svg +++ b/editor/icons/icon_interpolated_camera.svg @@ -1,5 +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="m9 0a3 3 0 0 0 -2.9883 2.7773 3 3 0 0 0 -2.0117 -0.77734 3 3 0 0 0 -3 3 3 3 0 0 0 2 2.8242v2.1758c0 0.554 0.44599 1 1 1h6c0.55401 0 1-0.446 1-1v-1l3 2v-6l-3 2v-1.7695a3 3 0 0 0 1 -2.2305 3 3 0 0 0 -3 -3zm-6 12v4h1v-4h-1zm3 0v4h1v-1h1a1 1 0 0 0 1 -1v-1a1 1 0 0 0 -1 -1h-1-1zm5 0a1 1 0 0 0 -1 1v2a1 1 0 0 0 1 1h1a1 1 0 0 0 1 -1v-2a1 1 0 0 0 -1 -1h-1zm-4 1h1v1h-1v-1zm4 0h1v2h-1v-2z" fill="#fc9c9c"/> +<path transform="translate(0,1036.4)" d="m9.5 4e-5c-1.5691 0.0017903-2.8718 1.2125-2.9883 2.7773-0.55103-0.49952-1.268-0.77655-2.0117-0.77734-1.6569 0-3 1.3431-3 3 0.00179 1.2698 0.80282 2.4009 2 2.8242v2.1758c0 0.554 0.44599 1 1 1h6c0.55401 0 0.9853-0.4462 1-1v-1l3 2v-6l-3 2v-1.7695c0.63486-0.56783 0.99842-1.3788 1-2.2305 0-1.6569-1.3431-3-3-3zm-6 12v4h1v-4zm3 0v4h1v-1h1c0.55228 0 1-0.44772 1-1v-1c0-0.55228-0.44824-1.024-1-1h-1zm5 0c-0.55228 0-1 0.44772-1 1v2c0 0.55228 0.44772 1 1 1h1c0.55228 0 1-0.44772 1-1v-2c0-0.55228-0.44772-1-1-1zm-4 1h1v1h-1zm4 0h1v2h-1z" fill="#fc9c9c"/> </g> </svg> diff --git a/editor/icons/icon_mesh_texture.svg b/editor/icons/icon_mesh_texture.svg new file mode 100644 index 0000000000..a877877c36 --- /dev/null +++ b/editor/icons/icon_mesh_texture.svg @@ -0,0 +1,3 @@ +<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> +<path d="m3 1c-1.1046 0-2 0.89543-2 2 5.649e-4 0.71397 0.38169 1.3735 1 1.7305v6.541c-0.61771 0.35663-0.99874 1.0152-1 1.7285 0 1.1046 0.89543 2 2 2 0.71397-5.65e-4 1.3735-0.38169 1.7305-1h6.541c0.35663 0.61771 1.0152 0.99874 1.7285 1 1.1046 0 2-0.89543 2-2 1.01e-4 -0.72747-0.39481-1.3976-1.0312-1.75h0.03125v-6.5215c0.61771-0.35663 0.99874-1.0152 1-1.7285 0-1.1046-0.89543-2-2-2-0.71397 5.648e-4 -1.3735 0.38169-1.7305 1h-6.541c-0.35663-0.61771-1.0152-0.99874-1.7285-1zm1.7266 3h0.6875 5.168 0.68945c0.17478 0.30301 0.42598 0.55488 0.72852 0.73047v0.68359 5.1719 0.68555c-0.30301 0.17478-0.55488 0.42598-0.73047 0.72852h-0.68359-5.1719-0.68555c-0.17478-0.30301-0.42598-0.55488-0.72852-0.73047v-0.6875l-0.0039062 0.003907v-5.8574c0.30302-0.17478 0.55488-0.42598 0.73047-0.72852zm4.0859 2.25v0.70117h-0.8125v0.69922h-1.625v0.69922h-0.8125v0.69922h-0.8125v0.70117h1.625 1.625 1.625 1.625v-1.4004h-0.8125v-1.3984h-0.8125v-0.70117h-0.8125z" fill="#e0e0e0" fill-opacity=".99608"/> +</svg> diff --git a/editor/icons/icon_rich_text_effect.svg b/editor/icons/icon_rich_text_effect.svg new file mode 100644 index 0000000000..c2705ad8c4 --- /dev/null +++ b/editor/icons/icon_rich_text_effect.svg @@ -0,0 +1,6 @@ +<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> +<g> +<path d="m1 1v2h7v-2zm9 0v2h5v-2zm-9 4v2h11v-2zm0 4v2h4v-2zm6 0v2h1c-0.044949-0.094701-0.088906-0.20229-0.125-0.3418-0.077717-0.30039-0.10439-0.81722 0.16406-1.293 0.081489-0.1441 0.18202-0.26127 0.28906-0.36523zm-6 4v2h8.2812c-0.066517-0.011548-0.1231-0.014758-0.20117-0.037109-0.30195-0.08645-0.76491-0.33245-1.0352-0.80664-0.23366-0.4121-0.24101-0.84933-0.18945-1.1562z" fill="#e0e0e0"/> +<path d="m12.216 8.598a0.53334 3.2001 0 0 0-0.50976 2.2754 3.2001 0.53334 30 0 0-2.2656-0.71484 3.2001 0.53334 30 0 0 1.75 1.6016 0.53334 3.2001 60 0 0-1.7461 1.5996 0.53334 3.2001 60 0 0 2.2578-0.71094 0.53334 3.2001 0 0 0 0.51367 2.3496 0.53334 3.2001 0 0 0 0.51367-2.3516 3.2001 0.53334 30 0 0 2.2539 0.71094 3.2001 0.53334 30 0 0-1.7441-1.5977 0.53334 3.2001 60 0 0 1.748-1.5996 0.53334 3.2001 60 0 0-2.2617 0.71484 0.53334 3.2001 0 0 0-0.50977-2.2773z" fill="#cea4f1" stroke-width="1.0667"/> +</g> +</svg> diff --git a/editor/icons/icon_skeleton_i_k.svg b/editor/icons/icon_skeleton_i_k.svg new file mode 100644 index 0000000000..851023ab4d --- /dev/null +++ b/editor/icons/icon_skeleton_i_k.svg @@ -0,0 +1,3 @@ +<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> +<path d="m6 2a4 4 0 0 0-4 4 4 4 0 0 0 2 3.4531v3.5469a2 2 0 0 0 1 1.7324 2 2 0 0 0 1 0.26562v0.001953h4v-0.001953a2 2 0 0 0 1-0.26562 2 2 0 0 0 1-1.7324v-3.5469a4 4 0 0 0 2-3.4531 4 4 0 0 0-4-4h-4zm-1 3a1 1 0 0 1 1 1 1 1 0 0 1-1 1 1 1 0 0 1-1-1 1 1 0 0 1 1-1zm6 0a1 1 0 0 1 1 1 1 1 0 0 1-1 1 1 1 0 0 1-1-1 1 1 0 0 1 1-1zm-4 2h2v1h-2v-1zm-2 2h1v1h1v-1h1 1v1h1v-1h1v0.86719 3.1328h-1v-1h-1v1h-1-1v-1h-1v1h-1v-3.1309-0.86914z" fill="#e0e0e0"/> +</svg> diff --git a/editor/icons/icon_soft_body.svg b/editor/icons/icon_soft_body.svg index 9930026b61..2c907df847 100644 --- a/editor/icons/icon_soft_body.svg +++ b/editor/icons/icon_soft_body.svg @@ -1,56 +1 @@ -<?xml version="1.0" encoding="UTF-8" standalone="no"?> -<svg - xmlns:dc="http://purl.org/dc/elements/1.1/" - xmlns:cc="http://creativecommons.org/ns#" - xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" - xmlns:svg="http://www.w3.org/2000/svg" - xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - width="16" - height="16" - version="1.1" - viewBox="0 0 16 16" - id="svg2" - inkscape:version="0.91 r13725" - sodipodi:docname="icon_soft_body.svg"> - <metadata - id="metadata14"> - <rdf:RDF> - <cc:Work - rdf:about=""> - <dc:format>image/svg+xml</dc:format> - <dc:type - rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - </cc:Work> - </rdf:RDF> - </metadata> - <defs - id="defs12" /> - <sodipodi:namedview - pagecolor="#ffffff" - bordercolor="#666666" - borderopacity="1" - objecttolerance="10" - gridtolerance="10" - guidetolerance="10" - inkscape:pageopacity="0" - inkscape:pageshadow="2" - inkscape:window-width="1920" - inkscape:window-height="1027" - id="namedview10" - showgrid="false" - inkscape:zoom="18.792233" - inkscape:cx="2.8961304" - inkscape:cy="4.3816933" - inkscape:window-x="-8" - inkscape:window-y="-8" - inkscape:window-maximized="1" - inkscape:current-layer="svg2" /> - <path - style="opacity:1;fill:#fc9c9c;fill-opacity:0.99607843;fill-rule:nonzero;stroke:none;stroke-width:1.42799997;stroke-linecap:square;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" - d="m 2.3447105,1.6091897 c -0.011911,1.9816766 -1.4168958,3.9344766 0,5.9495986 1.4168957,2.0151221 0,6.6693597 0,6.6693597 l 10.9510055,0 c 0,0 1.780829,-4.4523824 0,-6.489075 -1.780829,-2.0366925 -0.183458,-4.119112 0,-6.1298833 z m 1.8894067,0.7549031 7.4390658,0 c -0.431995,1.5996085 -1.62289,4.0426807 0,5.3749802 1.622888,1.3322996 0,5.887932 0,5.887932 l -7.4390658,0 c 0,0 1.3903413,-4.3680495 0,-5.9780743 -1.3903412,-1.6100247 -0.3951213,-3.7149271 0,-5.2848379 z" - id="rect4142" - inkscape:connector-curvature="0" - sodipodi:nodetypes="czcczcccczcczc" /> -</svg> +<svg height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="m2 1s-3 5 0 7-1 7-1 7h13s3-6 0-8 1-6 1-6zm2 2h7s-2 3 1 5 0 5 0 5h-7s2-4-1-6 0-4 0-4z" fill="#fc9c9c" fill-opacity=".996078"/></svg>
\ No newline at end of file diff --git a/editor/icons/icon_spring_arm.svg b/editor/icons/icon_spring_arm.svg new file mode 100644 index 0000000000..0700966369 --- /dev/null +++ b/editor/icons/icon_spring_arm.svg @@ -0,0 +1,6 @@ +<svg width="16" height="16" version="1.1" viewBox="0 0 16 16" xmlns="http://www.w3.org/2000/svg"> +<path d="m8 14 6-6" fill="none" stroke="#fc9c9c" stroke-width="2"/> +<path d="m2 2 7 7" fill="none" stroke="#fc9c9c" stroke-width="2"/> +<path d="m10 9h-6" fill="none" stroke="#fc9c9c" stroke-width="2"/> +<path d="m9 9v-5" fill="none" stroke="#fc9c9c" stroke-width="2"/> +</svg> diff --git a/editor/icons/icon_style_box_line.svg b/editor/icons/icon_style_box_line.svg new file mode 100644 index 0000000000..28f2eec6c0 --- /dev/null +++ b/editor/icons/icon_style_box_line.svg @@ -0,0 +1,11 @@ +<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="m13.303 1c-0.4344 0-0.86973 0.16881-1.2012 0.50586l-1.4688 1.4941h4.3418c0.082839-0.52789-0.072596-1.0872-0.47266-1.4941-0.33144-0.33705-0.76482-0.50586-1.1992-0.50586z" fill="#ff7070"/> +<path transform="translate(0 1036.4)" d="m10.633 3-1.9668 2h4.8008l1.0352-1.0527c0.2628-0.2673 0.41824-0.60049 0.47266-0.94727h-4.3418z" fill="#ffeb70"/> +<path transform="translate(0,1036.4)" d="m8.666 5-1.9648 2h2.8809c0.25686-0.33847 0.49465-0.66934 0.68555-1 0.33885-0.5859 0.95098-0.96109 1.627-0.99609 0.44399-0.023642 0.86385 0.115 1.2188 0.35547l0.35352-0.35938h-4.8008z" fill="#9dff70"/> +</g> +<path d="m1.2617 13c-0.08284 0.52789 0.072596 1.0872 0.47266 1.4941 0.33144 0.33705 0.76484 0.50586 1.1992 0.50586 0.4344 0 0.8697-0.16881 1.2012-0.50586l1.4688-1.4941h-4.3418zm7.9219 0c0.41312 1.1628 1.5119 2 2.8164 2s2.4033-0.83718 2.8164-2h-5.6328z" fill="#ff70ac"/> +<path d="m2.7695 11-1.0352 1.0527c-0.2628 0.2673-0.41824 0.60049-0.47266 0.94727h4.3418l1.4238-1.4473c0.020288-0.18998 0.04923-0.37542 0.089844-0.55273h-4.3477zm6.4609 0c-0.13656 0.32585-0.23047 0.65576-0.23047 1 0 0.35235 0.072014 0.68593 0.18359 1h5.6328c0.11158-0.31407 0.18359-0.64765 0.18359-1 0-0.34424-0.093909-0.67415-0.23047-1h-5.5391z" fill="#9f70ff"/> +<path d="m4.7363 9-1.9668 2h4.3477c0.17955-0.78395 0.54577-1.4354 0.9375-2h-3.3184zm5.8281 0c-0.55248 0.69003-1.0583 1.3421-1.334 2h5.5391c-0.2757-0.65786-0.78149-1.31-1.334-2h-2.8711z" fill="#70deff"/> +<path d="m6.7012 7-1.9648 2h3.3184c0.14116-0.20345 0.28508-0.40233 0.42383-0.58398 0.38601-0.5053 0.7635-0.96796 1.1035-1.416h-2.8809zm5.2988 0c-0.43047 0.7456-0.94456 1.3867-1.4355 2h2.8711c-0.49104-0.6133-1.0051-1.2544-1.4355-2z" fill="#70ffb9"/> +</svg> diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 449124acec..adfdfee603 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -176,7 +176,6 @@ Error ColladaImport::_create_scene_skeletons(Collada::Node *p_node) { Skeleton *sk = memnew(Skeleton); int bone = 0; - sk->set_use_bones_in_world_transform(true); // This improves compatibility in Collada for (int i = 0; i < p_node->children.size(); i++) { _populate_skeleton(sk, p_node->children[i], bone, -1); diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index 9ea7c86e0c..79658c5a4c 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -31,9 +31,12 @@ #include "editor_scene_importer_gltf.h" #include "core/crypto/crypto_core.h" #include "core/io/json.h" +#include "core/math/disjoint_set.h" #include "core/math/math_defs.h" #include "core/os/file_access.h" #include "core/os/os.h" +#include "modules/regex/regex.h" +#include "scene/3d/bone_attachment.h" #include "scene/3d/camera.h" #include "scene/3d/mesh_instance.h" #include "scene/animation/animation_player.h" @@ -152,14 +155,21 @@ static Transform _arr_to_xform(const Array &p_array) { return xform; } +String EditorSceneImporterGLTF::_sanitize_scene_name(const String &name) { + RegEx regex("([^a-zA-Z0-9_ ]+)"); + String p_name = regex.sub(name, "", true); + return p_name; +} + String EditorSceneImporterGLTF::_gen_unique_name(GLTFState &state, const String &p_name) { - int index = 1; + const String s_name = _sanitize_scene_name(p_name); String name; + int index = 1; while (true) { + name = s_name; - name = p_name; if (index > 1) { name += " " + itos(index); } @@ -174,20 +184,63 @@ String EditorSceneImporterGLTF::_gen_unique_name(GLTFState &state, const String return name; } +String EditorSceneImporterGLTF::_sanitize_bone_name(const String &name) { + String p_name = name.camelcase_to_underscore(true); + + RegEx pattern_del("([^a-zA-Z0-9_ ])+"); + p_name = pattern_del.sub(p_name, "", true); + + RegEx pattern_nospace(" +"); + p_name = pattern_nospace.sub(p_name, "_", true); + + RegEx pattern_multiple("_+"); + p_name = pattern_multiple.sub(p_name, "_", true); + + RegEx pattern_padded("0+(\\d+)"); + p_name = pattern_padded.sub(p_name, "$1", true); + + return p_name; +} + +String EditorSceneImporterGLTF::_gen_unique_bone_name(GLTFState &state, const GLTFSkeletonIndex skel_i, const String &p_name) { + + const String s_name = _sanitize_bone_name(p_name); + + String name; + int index = 1; + while (true) { + name = s_name; + + if (index > 1) { + name += "_" + itos(index); + } + if (!state.skeletons[skel_i].unique_names.has(name)) { + break; + } + index++; + } + + state.skeletons.write[skel_i].unique_names.insert(name); + + return name; +} + Error EditorSceneImporterGLTF::_parse_scenes(GLTFState &state) { ERR_FAIL_COND_V(!state.json.has("scenes"), ERR_FILE_CORRUPT); - Array scenes = state.json["scenes"]; + const Array &scenes = state.json["scenes"]; for (int i = 0; i < 1; i++) { //only first scene is imported - Dictionary s = scenes[i]; + const Dictionary &s = scenes[i]; ERR_FAIL_COND_V(!s.has("nodes"), ERR_UNAVAILABLE); - Array nodes = s["nodes"]; + const Array &nodes = s["nodes"]; for (int j = 0; j < nodes.size(); j++) { state.root_nodes.push_back(nodes[j]); } - if (s.has("name")) { - state.scene_name = s["name"]; + if (s.has("name") && s["name"] != "") { + state.scene_name = _gen_unique_name(state, s["name"]); + } else { + state.scene_name = _gen_unique_name(state, "Scene"); } } @@ -197,11 +250,11 @@ Error EditorSceneImporterGLTF::_parse_scenes(GLTFState &state) { Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) { ERR_FAIL_COND_V(!state.json.has("nodes"), ERR_FILE_CORRUPT); - Array nodes = state.json["nodes"]; + const Array &nodes = state.json["nodes"]; for (int i = 0; i < nodes.size(); i++) { GLTFNode *node = memnew(GLTFNode); - Dictionary n = nodes[i]; + const Dictionary &n = nodes[i]; if (n.has("name")) { node->name = n["name"]; @@ -214,13 +267,6 @@ Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) { } if (n.has("skin")) { node->skin = n["skin"]; - /* - if (!state.skin_users.has(node->skin)) { - state.skin_users[node->skin] = Vector<int>(); - } - - state.skin_users[node->skin].push_back(i); - */ } if (n.has("matrix")) { node->xform = _arr_to_xform(n["matrix"]); @@ -242,7 +288,7 @@ Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) { } if (n.has("children")) { - Array children = n["children"]; + const Array &children = n["children"]; for (int j = 0; j < children.size(); j++) { node->children.push_back(children[j]); } @@ -251,22 +297,46 @@ Error EditorSceneImporterGLTF::_parse_nodes(GLTFState &state) { state.nodes.push_back(node); } - //build the hierarchy + // build the hierarchy + for (GLTFNodeIndex node_i = 0; node_i < state.nodes.size(); node_i++) { - for (int i = 0; i < state.nodes.size(); i++) { + for (int j = 0; j < state.nodes[node_i]->children.size(); j++) { + GLTFNodeIndex child_i = state.nodes[node_i]->children[j]; - for (int j = 0; j < state.nodes[i]->children.size(); j++) { - int child = state.nodes[i]->children[j]; - ERR_FAIL_INDEX_V(child, state.nodes.size(), ERR_FILE_CORRUPT); - ERR_CONTINUE(state.nodes[child]->parent != -1); //node already has a parent, wtf. + ERR_FAIL_INDEX_V(child_i, state.nodes.size(), ERR_FILE_CORRUPT); + ERR_CONTINUE(state.nodes[child_i]->parent != -1); //node already has a parent, wtf. - state.nodes[child]->parent = i; + state.nodes[child_i]->parent = node_i; } } + _compute_node_heights(state); + return OK; } +void EditorSceneImporterGLTF::_compute_node_heights(GLTFState &state) { + + state.root_nodes.clear(); + for (GLTFNodeIndex node_i = 0; node_i < state.nodes.size(); ++node_i) { + GLTFNode *node = state.nodes[node_i]; + node->height = 0; + + GLTFNodeIndex current_i = node_i; + while (current_i >= 0) { + const GLTFNodeIndex parent_i = state.nodes[current_i]->parent; + if (parent_i >= 0) { + ++node->height; + } + current_i = parent_i; + } + + if (node->height == 0) { + state.root_nodes.push_back(node_i); + } + } +} + static Vector<uint8_t> _parse_base64_uri(const String &uri) { int start = uri.find(","); @@ -292,14 +362,14 @@ Error EditorSceneImporterGLTF::_parse_buffers(GLTFState &state, const String &p_ if (!state.json.has("buffers")) return OK; - Array buffers = state.json["buffers"]; - for (int i = 0; i < buffers.size(); i++) { + const Array &buffers = state.json["buffers"]; + for (GLTFBufferIndex i = 0; i < buffers.size(); i++) { if (i == 0 && state.glb_data.size()) { state.buffers.push_back(state.glb_data); } else { - Dictionary buffer = buffers[i]; + const Dictionary &buffer = buffers[i]; if (buffer.has("uri")) { Vector<uint8_t> buffer_data; @@ -331,10 +401,10 @@ Error EditorSceneImporterGLTF::_parse_buffers(GLTFState &state, const String &p_ Error EditorSceneImporterGLTF::_parse_buffer_views(GLTFState &state) { ERR_FAIL_COND_V(!state.json.has("bufferViews"), ERR_FILE_CORRUPT); - Array buffers = state.json["bufferViews"]; - for (int i = 0; i < buffers.size(); i++) { + const Array &buffers = state.json["bufferViews"]; + for (GLTFBufferViewIndex i = 0; i < buffers.size(); i++) { - Dictionary d = buffers[i]; + const Dictionary &d = buffers[i]; GLTFBufferView buffer_view; @@ -352,7 +422,7 @@ Error EditorSceneImporterGLTF::_parse_buffer_views(GLTFState &state) { } if (d.has("target")) { - int target = d["target"]; + const int target = d["target"]; buffer_view.indices = target == ELEMENT_ARRAY_BUFFER; } @@ -389,10 +459,10 @@ EditorSceneImporterGLTF::GLTFType EditorSceneImporterGLTF::_get_type_from_str(co Error EditorSceneImporterGLTF::_parse_accessors(GLTFState &state) { ERR_FAIL_COND_V(!state.json.has("accessors"), ERR_FILE_CORRUPT); - Array accessors = state.json["accessors"]; - for (int i = 0; i < accessors.size(); i++) { + const Array &accessors = state.json["accessors"]; + for (GLTFAccessorIndex i = 0; i < accessors.size(); i++) { - Dictionary d = accessors[i]; + const Dictionary &d = accessors[i]; GLTFAccessor accessor; @@ -422,12 +492,12 @@ Error EditorSceneImporterGLTF::_parse_accessors(GLTFState &state) { if (d.has("sparse")) { //eeh.. - Dictionary s = d["sparse"]; + const Dictionary &s = d["sparse"]; ERR_FAIL_COND_V(!d.has("count"), ERR_PARSE_ERROR); accessor.sparse_count = d["count"]; ERR_FAIL_COND_V(!d.has("indices"), ERR_PARSE_ERROR); - Dictionary si = d["indices"]; + const Dictionary &si = d["indices"]; ERR_FAIL_COND_V(!si.has("bufferView"), ERR_PARSE_ERROR); accessor.sparse_indices_buffer_view = si["bufferView"]; @@ -439,7 +509,7 @@ Error EditorSceneImporterGLTF::_parse_accessors(GLTFState &state) { } ERR_FAIL_COND_V(!d.has("values"), ERR_PARSE_ERROR); - Dictionary sv = d["values"]; + const Dictionary &sv = d["values"]; ERR_FAIL_COND_V(!sv.has("bufferView"), ERR_PARSE_ERROR); accessor.sparse_values_buffer_view = sv["bufferView"]; @@ -456,7 +526,7 @@ Error EditorSceneImporterGLTF::_parse_accessors(GLTFState &state) { return OK; } -String EditorSceneImporterGLTF::_get_component_type_name(uint32_t p_component) { +String EditorSceneImporterGLTF::_get_component_type_name(const uint32_t p_component) { switch (p_component) { case COMPONENT_TYPE_BYTE: return "Byte"; @@ -470,7 +540,7 @@ String EditorSceneImporterGLTF::_get_component_type_name(uint32_t p_component) { return "<Error>"; } -String EditorSceneImporterGLTF::_get_type_name(GLTFType p_component) { +String EditorSceneImporterGLTF::_get_type_name(const GLTFType p_component) { static const char *names[] = { "float", @@ -485,7 +555,7 @@ String EditorSceneImporterGLTF::_get_type_name(GLTFType p_component) { return names[p_component]; } -Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffer_view, double *dst, int skip_every, int skip_bytes, int element_size, int count, GLTFType type, int component_count, int component_type, int component_size, bool normalized, int byte_offset, bool for_vertex) { +Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, double *dst, const GLTFBufferViewIndex p_buffer_view, const int skip_every, const int skip_bytes, const int element_size, const int count, const GLTFType type, const int component_count, const int component_type, const int component_size, const bool normalized, const int byte_offset, const bool for_vertex) { const GLTFBufferView &bv = state.buffer_views[p_buffer_view]; @@ -496,7 +566,7 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffe ERR_FAIL_INDEX_V(bv.buffer, state.buffers.size(), ERR_PARSE_ERROR); - uint32_t offset = bv.byte_offset + byte_offset; + const uint32_t offset = bv.byte_offset + byte_offset; Vector<uint8_t> buffer = state.buffers[bv.buffer]; //copy on write, so no performance hit const uint8_t *bufptr = buffer.ptr(); @@ -504,7 +574,7 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffe print_verbose("glTF: type " + _get_type_name(type) + " component type: " + _get_component_type_name(component_type) + " stride: " + itos(stride) + " amount " + itos(count)); print_verbose("glTF: accessor offset" + itos(byte_offset) + " view offset: " + itos(bv.byte_offset) + " total buffer len: " + itos(buffer.size()) + " view len " + itos(bv.byte_length)); - int buffer_end = (stride * (count - 1)) + element_size; + const int buffer_end = (stride * (count - 1)) + element_size; ERR_FAIL_COND_V(buffer_end > bv.byte_length, ERR_PARSE_ERROR); ERR_FAIL_COND_V((int)(offset + buffer_end) > buffer.size(), ERR_PARSE_ERROR); @@ -573,7 +643,7 @@ Error EditorSceneImporterGLTF::_decode_buffer_view(GLTFState &state, int p_buffe return OK; } -int EditorSceneImporterGLTF::_get_component_type_size(int component_type) { +int EditorSceneImporterGLTF::_get_component_type_size(const int component_type) { switch (component_type) { case COMPONENT_TYPE_BYTE: return 1; break; @@ -589,7 +659,7 @@ int EditorSceneImporterGLTF::_get_component_type_size(int component_type) { return 0; } -Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, int p_accessor, bool p_for_vertex) { +Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { //spec, for reference: //https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#data-alignment @@ -598,12 +668,12 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, int p const GLTFAccessor &a = state.accessors[p_accessor]; - int component_count_for_type[7] = { + const int component_count_for_type[7] = { 1, 2, 3, 4, 4, 9, 16 }; - int component_count = component_count_for_type[a.type]; - int component_size = _get_component_type_size(a.component_type); + const int component_count = component_count_for_type[a.type]; + const int component_size = _get_component_type_size(a.component_type); ERR_FAIL_COND_V(component_size == 0, Vector<double>()); int element_size = component_count * component_size; @@ -646,7 +716,7 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, int p ERR_FAIL_INDEX_V(a.buffer_view, state.buffer_views.size(), Vector<double>()); - Error err = _decode_buffer_view(state, a.buffer_view, dst, skip_every, skip_bytes, element_size, a.count, a.type, component_count, a.component_type, component_size, a.normalized, a.byte_offset, p_for_vertex); + const Error err = _decode_buffer_view(state, dst, a.buffer_view, skip_every, skip_bytes, element_size, a.count, a.type, component_count, a.component_type, component_size, a.normalized, a.byte_offset, p_for_vertex); if (err != OK) return Vector<double>(); @@ -661,20 +731,20 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, int p // I could not find any file using this, so this code is so far untested Vector<double> indices; indices.resize(a.sparse_count); - int indices_component_size = _get_component_type_size(a.sparse_indices_component_type); + const int indices_component_size = _get_component_type_size(a.sparse_indices_component_type); - Error err = _decode_buffer_view(state, a.sparse_indices_buffer_view, indices.ptrw(), 0, 0, indices_component_size, a.sparse_count, TYPE_SCALAR, 1, a.sparse_indices_component_type, indices_component_size, false, a.sparse_indices_byte_offset, false); + Error err = _decode_buffer_view(state, indices.ptrw(), a.sparse_indices_buffer_view, 0, 0, indices_component_size, a.sparse_count, TYPE_SCALAR, 1, a.sparse_indices_component_type, indices_component_size, false, a.sparse_indices_byte_offset, false); if (err != OK) return Vector<double>(); Vector<double> data; data.resize(component_count * a.sparse_count); - err = _decode_buffer_view(state, a.sparse_values_buffer_view, data.ptrw(), skip_every, skip_bytes, element_size, a.sparse_count, a.type, component_count, a.component_type, component_size, a.normalized, a.sparse_values_byte_offset, p_for_vertex); + err = _decode_buffer_view(state, data.ptrw(), a.sparse_values_buffer_view, skip_every, skip_bytes, element_size, a.sparse_count, a.type, component_count, a.component_type, component_size, a.normalized, a.sparse_values_byte_offset, p_for_vertex); if (err != OK) return Vector<double>(); for (int i = 0; i < indices.size(); i++) { - int write_offset = int(indices[i]) * component_count; + const int write_offset = int(indices[i]) * component_count; for (int j = 0; j < component_count; j++) { dst[write_offset + j] = data[i * component_count + j]; @@ -685,14 +755,16 @@ Vector<double> EditorSceneImporterGLTF::_decode_accessor(GLTFState &state, int p return dst_buffer; } -PoolVector<int> EditorSceneImporterGLTF::_decode_accessor_as_ints(GLTFState &state, int p_accessor, bool p_for_vertex) { +PoolVector<int> EditorSceneImporterGLTF::_decode_accessor_as_ints(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); + const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); PoolVector<int> ret; + if (attribs.size() == 0) return ret; + const double *attribs_ptr = attribs.ptr(); - int ret_size = attribs.size(); + const int ret_size = attribs.size(); ret.resize(ret_size); { PoolVector<int>::Write w = ret.write(); @@ -703,14 +775,16 @@ PoolVector<int> EditorSceneImporterGLTF::_decode_accessor_as_ints(GLTFState &sta return ret; } -PoolVector<float> EditorSceneImporterGLTF::_decode_accessor_as_floats(GLTFState &state, int p_accessor, bool p_for_vertex) { +PoolVector<float> EditorSceneImporterGLTF::_decode_accessor_as_floats(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); + const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); PoolVector<float> ret; + if (attribs.size() == 0) return ret; + const double *attribs_ptr = attribs.ptr(); - int ret_size = attribs.size(); + const int ret_size = attribs.size(); ret.resize(ret_size); { PoolVector<float>::Write w = ret.write(); @@ -721,15 +795,17 @@ PoolVector<float> EditorSceneImporterGLTF::_decode_accessor_as_floats(GLTFState return ret; } -PoolVector<Vector2> EditorSceneImporterGLTF::_decode_accessor_as_vec2(GLTFState &state, int p_accessor, bool p_for_vertex) { +PoolVector<Vector2> EditorSceneImporterGLTF::_decode_accessor_as_vec2(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); + const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); PoolVector<Vector2> ret; + if (attribs.size() == 0) return ret; + ERR_FAIL_COND_V(attribs.size() % 2 != 0, ret); const double *attribs_ptr = attribs.ptr(); - int ret_size = attribs.size() / 2; + const int ret_size = attribs.size() / 2; ret.resize(ret_size); { PoolVector<Vector2>::Write w = ret.write(); @@ -740,15 +816,17 @@ PoolVector<Vector2> EditorSceneImporterGLTF::_decode_accessor_as_vec2(GLTFState return ret; } -PoolVector<Vector3> EditorSceneImporterGLTF::_decode_accessor_as_vec3(GLTFState &state, int p_accessor, bool p_for_vertex) { +PoolVector<Vector3> EditorSceneImporterGLTF::_decode_accessor_as_vec3(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); + const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); PoolVector<Vector3> ret; + if (attribs.size() == 0) return ret; + ERR_FAIL_COND_V(attribs.size() % 3 != 0, ret); const double *attribs_ptr = attribs.ptr(); - int ret_size = attribs.size() / 3; + const int ret_size = attribs.size() / 3; ret.resize(ret_size); { PoolVector<Vector3>::Write w = ret.write(); @@ -758,13 +836,16 @@ PoolVector<Vector3> EditorSceneImporterGLTF::_decode_accessor_as_vec3(GLTFState } return ret; } -PoolVector<Color> EditorSceneImporterGLTF::_decode_accessor_as_color(GLTFState &state, int p_accessor, bool p_for_vertex) { - Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); +PoolVector<Color> EditorSceneImporterGLTF::_decode_accessor_as_color(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { + + const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); PoolVector<Color> ret; + if (attribs.size() == 0) return ret; - int type = state.accessors[p_accessor].type; + + const int type = state.accessors[p_accessor].type; ERR_FAIL_COND_V(!(type == TYPE_VEC3 || type == TYPE_VEC4), ret); int components; if (type == TYPE_VEC3) { @@ -772,9 +853,10 @@ PoolVector<Color> EditorSceneImporterGLTF::_decode_accessor_as_color(GLTFState & } else { // TYPE_VEC4 components = 4; } + ERR_FAIL_COND_V(attribs.size() % components != 0, ret); const double *attribs_ptr = attribs.ptr(); - int ret_size = attribs.size() / components; + const int ret_size = attribs.size() / components; ret.resize(ret_size); { PoolVector<Color>::Write w = ret.write(); @@ -784,15 +866,17 @@ PoolVector<Color> EditorSceneImporterGLTF::_decode_accessor_as_color(GLTFState & } return ret; } -Vector<Quat> EditorSceneImporterGLTF::_decode_accessor_as_quat(GLTFState &state, int p_accessor, bool p_for_vertex) { +Vector<Quat> EditorSceneImporterGLTF::_decode_accessor_as_quat(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); + const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<Quat> ret; + if (attribs.size() == 0) return ret; + ERR_FAIL_COND_V(attribs.size() % 4 != 0, ret); const double *attribs_ptr = attribs.ptr(); - int ret_size = attribs.size() / 4; + const int ret_size = attribs.size() / 4; ret.resize(ret_size); { for (int i = 0; i < ret_size; i++) { @@ -801,12 +885,14 @@ Vector<Quat> EditorSceneImporterGLTF::_decode_accessor_as_quat(GLTFState &state, } return ret; } -Vector<Transform2D> EditorSceneImporterGLTF::_decode_accessor_as_xform2d(GLTFState &state, int p_accessor, bool p_for_vertex) { +Vector<Transform2D> EditorSceneImporterGLTF::_decode_accessor_as_xform2d(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { - Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); + const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<Transform2D> ret; + if (attribs.size() == 0) return ret; + ERR_FAIL_COND_V(attribs.size() % 4 != 0, ret); ret.resize(attribs.size() / 4); for (int i = 0; i < ret.size(); i++) { @@ -816,12 +902,14 @@ Vector<Transform2D> EditorSceneImporterGLTF::_decode_accessor_as_xform2d(GLTFSta return ret; } -Vector<Basis> EditorSceneImporterGLTF::_decode_accessor_as_basis(GLTFState &state, int p_accessor, bool p_for_vertex) { +Vector<Basis> EditorSceneImporterGLTF::_decode_accessor_as_basis(GLTFState &state, const GLTFAccessorIndex p_accessor, bool p_for_vertex) { - Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); + const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<Basis> ret; + if (attribs.size() == 0) return ret; + ERR_FAIL_COND_V(attribs.size() % 9 != 0, ret); ret.resize(attribs.size() / 9); for (int i = 0; i < ret.size(); i++) { @@ -831,12 +919,15 @@ Vector<Basis> EditorSceneImporterGLTF::_decode_accessor_as_basis(GLTFState &stat } return ret; } -Vector<Transform> EditorSceneImporterGLTF::_decode_accessor_as_xform(GLTFState &state, int p_accessor, bool p_for_vertex) { - Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); +Vector<Transform> EditorSceneImporterGLTF::_decode_accessor_as_xform(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex) { + + const Vector<double> attribs = _decode_accessor(state, p_accessor, p_for_vertex); Vector<Transform> ret; + if (attribs.size() == 0) return ret; + ERR_FAIL_COND_V(attribs.size() % 16 != 0, ret); ret.resize(attribs.size() / 16); for (int i = 0; i < ret.size(); i++) { @@ -854,7 +945,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { return OK; Array meshes = state.json["meshes"]; - for (int i = 0; i < meshes.size(); i++) { + for (GLTFMeshIndex i = 0; i < meshes.size(); i++) { print_verbose("glTF: Parsing mesh: " + itos(i)); Dictionary d = meshes[i]; @@ -865,7 +956,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { ERR_FAIL_COND_V(!d.has("primitives"), ERR_PARSE_ERROR); Array primitives = d["primitives"]; - Dictionary extras = d.has("extras") ? (Dictionary)d["extras"] : Dictionary(); + const Dictionary &extras = d.has("extras") ? (Dictionary)d["extras"] : Dictionary(); for (int j = 0; j < primitives.size(); j++) { @@ -880,7 +971,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { Mesh::PrimitiveType primitive = Mesh::PRIMITIVE_TRIANGLES; if (p.has("mode")) { - int mode = p["mode"]; + const int mode = p["mode"]; ERR_FAIL_INDEX_V(mode, 7, ERR_FILE_CORRUPT); static const Mesh::PrimitiveType primitives2[7] = { Mesh::PRIMITIVE_POINTS, @@ -899,7 +990,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { if (a.has("POSITION")) { array[Mesh::ARRAY_VERTEX] = _decode_accessor_as_vec3(state, a["POSITION"], true); } - if (a.has("NORMAL")) { array[Mesh::ARRAY_NORMAL] = _decode_accessor_as_vec3(state, a["NORMAL"], true); } @@ -924,9 +1014,6 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { int wc = weights.size(); PoolVector<float>::Write w = weights.write(); - //PoolVector<int> v = array[Mesh::ARRAY_BONES]; - //PoolVector<int>::Read r = v.read(); - for (int k = 0; k < wc; k += 4) { float total = 0.0; total += w[k + 0]; @@ -939,36 +1026,34 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { w[k + 2] /= total; w[k + 3] /= total; } - - //print_verbose(itos(j / 4) + ": " + itos(r[j + 0]) + ":" + rtos(w[j + 0]) + ", " + itos(r[j + 1]) + ":" + rtos(w[j + 1]) + ", " + itos(r[j + 2]) + ":" + rtos(w[j + 2]) + ", " + itos(r[j + 3]) + ":" + rtos(w[j + 3])); } } array[Mesh::ARRAY_WEIGHTS] = weights; } if (p.has("indices")) { - PoolVector<int> indices = _decode_accessor_as_ints(state, p["indices"], false); if (primitive == Mesh::PRIMITIVE_TRIANGLES) { //swap around indices, convert ccw to cw for front face - int is = indices.size(); - PoolVector<int>::Write w = indices.write(); + const int is = indices.size(); + const PoolVector<int>::Write w = indices.write(); for (int k = 0; k < is; k += 3) { SWAP(w[k + 1], w[k + 2]); } } array[Mesh::ARRAY_INDEX] = indices; + } else if (primitive == Mesh::PRIMITIVE_TRIANGLES) { //generate indices because they need to be swapped for CW/CCW - PoolVector<Vector3> vertices = array[Mesh::ARRAY_VERTEX]; + const PoolVector<Vector3> &vertices = array[Mesh::ARRAY_VERTEX]; ERR_FAIL_COND_V(vertices.size() == 0, ERR_PARSE_ERROR); PoolVector<int> indices; - int vs = vertices.size(); + const int vs = vertices.size(); indices.resize(vs); { - PoolVector<int>::Write w = indices.write(); + const PoolVector<int>::Write w = indices.write(); for (int k = 0; k < vs; k += 3) { w[k] = k; w[k + 1] = k + 2; @@ -1002,23 +1087,23 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { //blend shapes if (p.has("targets")) { print_verbose("glTF: Mesh has targets"); - Array targets = p["targets"]; + const Array &targets = p["targets"]; //ideally BLEND_SHAPE_MODE_RELATIVE since gltf2 stores in displacement //but it could require a larger refactor? mesh.mesh->set_blend_shape_mode(Mesh::BLEND_SHAPE_MODE_NORMALIZED); if (j == 0) { - Array target_names = extras.has("targetNames") ? (Array)extras["targetNames"] : Array(); + const Array &target_names = extras.has("targetNames") ? (Array)extras["targetNames"] : Array(); for (int k = 0; k < targets.size(); k++) { - String name = k < target_names.size() ? (String)target_names[k] : String("morph_") + itos(k); + const String name = k < target_names.size() ? (String)target_names[k] : String("morph_") + itos(k); mesh.mesh->add_blend_shape(name); } } for (int k = 0; k < targets.size(); k++) { - Dictionary t = targets[k]; + const Dictionary &t = targets[k]; Array array_copy; array_copy.resize(Mesh::ARRAY_MAX); @@ -1031,17 +1116,17 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { if (t.has("POSITION")) { PoolVector<Vector3> varr = _decode_accessor_as_vec3(state, t["POSITION"], true); - PoolVector<Vector3> src_varr = array[Mesh::ARRAY_VERTEX]; - int size = src_varr.size(); + const PoolVector<Vector3> src_varr = array[Mesh::ARRAY_VERTEX]; + const int size = src_varr.size(); ERR_FAIL_COND_V(size == 0, ERR_PARSE_ERROR); { - int max_idx = varr.size(); + const int max_idx = varr.size(); varr.resize(size); - PoolVector<Vector3>::Write w_varr = varr.write(); - PoolVector<Vector3>::Read r_varr = varr.read(); - PoolVector<Vector3>::Read r_src_varr = src_varr.read(); + const PoolVector<Vector3>::Write w_varr = varr.write(); + const PoolVector<Vector3>::Read r_varr = varr.read(); + const PoolVector<Vector3>::Read r_src_varr = src_varr.read(); for (int l = 0; l < size; l++) { if (l < max_idx) { w_varr[l] = r_varr[l] + r_src_varr[l]; @@ -1054,16 +1139,16 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { } if (t.has("NORMAL")) { PoolVector<Vector3> narr = _decode_accessor_as_vec3(state, t["NORMAL"], true); - PoolVector<Vector3> src_narr = array[Mesh::ARRAY_NORMAL]; + const PoolVector<Vector3> src_narr = array[Mesh::ARRAY_NORMAL]; int size = src_narr.size(); ERR_FAIL_COND_V(size == 0, ERR_PARSE_ERROR); { int max_idx = narr.size(); narr.resize(size); - PoolVector<Vector3>::Write w_narr = narr.write(); - PoolVector<Vector3>::Read r_narr = narr.read(); - PoolVector<Vector3>::Read r_src_narr = src_narr.read(); + const PoolVector<Vector3>::Write w_narr = narr.write(); + const PoolVector<Vector3>::Read r_narr = narr.read(); + const PoolVector<Vector3>::Read r_src_narr = src_narr.read(); for (int l = 0; l < size; l++) { if (l < max_idx) { w_narr[l] = r_narr[l] + r_src_narr[l]; @@ -1075,21 +1160,22 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { array_copy[Mesh::ARRAY_NORMAL] = narr; } if (t.has("TANGENT")) { - PoolVector<Vector3> tangents_v3 = _decode_accessor_as_vec3(state, t["TANGENT"], true); - PoolVector<float> tangents_v4; - PoolVector<float> src_tangents = array[Mesh::ARRAY_TANGENT]; + const PoolVector<Vector3> tangents_v3 = _decode_accessor_as_vec3(state, t["TANGENT"], true); + const PoolVector<float> src_tangents = array[Mesh::ARRAY_TANGENT]; ERR_FAIL_COND_V(src_tangents.size() == 0, ERR_PARSE_ERROR); + PoolVector<float> tangents_v4; + { int max_idx = tangents_v3.size(); int size4 = src_tangents.size(); tangents_v4.resize(size4); - PoolVector<float>::Write w4 = tangents_v4.write(); + const PoolVector<float>::Write w4 = tangents_v4.write(); - PoolVector<Vector3>::Read r3 = tangents_v3.read(); - PoolVector<float>::Read r4 = src_tangents.read(); + const PoolVector<Vector3>::Read r3 = tangents_v3.read(); + const PoolVector<float>::Read r4 = src_tangents.read(); for (int l = 0; l < size4 / 4; l++) { @@ -1127,16 +1213,16 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) { mesh.mesh->add_surface_from_arrays(primitive, array, morphs); if (p.has("material")) { - int material = p["material"]; + const int material = p["material"]; ERR_FAIL_INDEX_V(material, state.materials.size(), ERR_FILE_CORRUPT); - Ref<Material> mat = state.materials[material]; + const Ref<Material> &mat = state.materials[material]; mesh.mesh->surface_set_material(mesh.mesh->get_surface_count() - 1, mat); } } if (d.has("weights")) { - Array weights = d["weights"]; + const Array &weights = d["weights"]; ERR_FAIL_COND_V(mesh.mesh->get_blend_shape_count() != weights.size(), ERR_PARSE_ERROR); mesh.blend_weights.resize(weights.size()); for (int j = 0; j < weights.size(); j++) { @@ -1157,10 +1243,10 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b if (!state.json.has("images")) return OK; - Array images = state.json["images"]; + const Array &images = state.json["images"]; for (int i = 0; i < images.size(); i++) { - Dictionary d = images[i]; + const Dictionary &d = images[i]; String mimetype; if (d.has("mimeType")) { @@ -1190,13 +1276,13 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b } if (d.has("bufferView")) { - int bvi = d["bufferView"]; + const GLTFBufferViewIndex bvi = d["bufferView"]; ERR_FAIL_INDEX_V(bvi, state.buffer_views.size(), ERR_PARAMETER_RANGE_ERROR); const GLTFBufferView &bv = state.buffer_views[bvi]; - int bi = bv.buffer; + const GLTFBufferIndex bi = bv.buffer; ERR_FAIL_INDEX_V(bi, state.buffers.size(), ERR_PARAMETER_RANGE_ERROR); ERR_FAIL_COND_V(bv.byte_offset + bv.byte_length > state.buffers[bi].size(), ERR_FILE_CORRUPT); @@ -1209,7 +1295,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b if (mimetype.findn("png") != -1) { //is a png - Ref<Image> img = Image::_png_mem_loader_func(data_ptr, data_size); + const Ref<Image> img = Image::_png_mem_loader_func(data_ptr, data_size); ERR_FAIL_COND_V(img.is_null(), ERR_FILE_CORRUPT); @@ -1223,7 +1309,7 @@ Error EditorSceneImporterGLTF::_parse_images(GLTFState &state, const String &p_b if (mimetype.findn("jpeg") != -1) { //is a jpg - Ref<Image> img = Image::_jpg_mem_loader_func(data_ptr, data_size); + const Ref<Image> img = Image::_jpg_mem_loader_func(data_ptr, data_size); ERR_FAIL_COND_V(img.is_null(), ERR_FILE_CORRUPT); @@ -1249,10 +1335,10 @@ Error EditorSceneImporterGLTF::_parse_textures(GLTFState &state) { if (!state.json.has("textures")) return OK; - Array textures = state.json["textures"]; - for (int i = 0; i < textures.size(); i++) { + const Array &textures = state.json["textures"]; + for (GLTFTextureIndex i = 0; i < textures.size(); i++) { - Dictionary d = textures[i]; + const Dictionary &d = textures[i]; ERR_FAIL_COND_V(!d.has("source"), ERR_PARSE_ERROR); @@ -1264,9 +1350,9 @@ Error EditorSceneImporterGLTF::_parse_textures(GLTFState &state) { return OK; } -Ref<Texture> EditorSceneImporterGLTF::_get_texture(GLTFState &state, int p_texture) { +Ref<Texture> EditorSceneImporterGLTF::_get_texture(GLTFState &state, const GLTFTextureIndex p_texture) { ERR_FAIL_INDEX_V(p_texture, state.textures.size(), Ref<Texture>()); - int image = state.textures[p_texture].src_image; + const GLTFImageIndex image = state.textures[p_texture].src_image; ERR_FAIL_INDEX_V(image, state.images.size(), Ref<Texture>()); @@ -1278,10 +1364,10 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (!state.json.has("materials")) return OK; - Array materials = state.json["materials"]; - for (int i = 0; i < materials.size(); i++) { + const Array &materials = state.json["materials"]; + for (GLTFMaterialIndex i = 0; i < materials.size(); i++) { - Dictionary d = materials[i]; + const Dictionary &d = materials[i]; Ref<SpatialMaterial> material; material.instance(); @@ -1291,17 +1377,17 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { if (d.has("pbrMetallicRoughness")) { - Dictionary mr = d["pbrMetallicRoughness"]; + const Dictionary &mr = d["pbrMetallicRoughness"]; if (mr.has("baseColorFactor")) { - Array arr = mr["baseColorFactor"]; + const Array &arr = mr["baseColorFactor"]; ERR_FAIL_COND_V(arr.size() != 4, ERR_PARSE_ERROR); - Color c = Color(arr[0], arr[1], arr[2], arr[3]).to_srgb(); + const Color c = Color(arr[0], arr[1], arr[2], arr[3]).to_srgb(); material->set_albedo(c); } if (mr.has("baseColorTexture")) { - Dictionary bct = mr["baseColorTexture"]; + const Dictionary &bct = mr["baseColorTexture"]; if (bct.has("index")) { material->set_texture(SpatialMaterial::TEXTURE_ALBEDO, _get_texture(state, bct["index"])); } @@ -1323,9 +1409,9 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { } if (mr.has("metallicRoughnessTexture")) { - Dictionary bct = mr["metallicRoughnessTexture"]; + const Dictionary &bct = mr["metallicRoughnessTexture"]; if (bct.has("index")) { - Ref<Texture> t = _get_texture(state, bct["index"]); + const Ref<Texture> t = _get_texture(state, bct["index"]); material->set_texture(SpatialMaterial::TEXTURE_METALLIC, t); material->set_metallic_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_BLUE); material->set_texture(SpatialMaterial::TEXTURE_ROUGHNESS, t); @@ -1341,7 +1427,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { } if (d.has("normalTexture")) { - Dictionary bct = d["normalTexture"]; + const Dictionary &bct = d["normalTexture"]; if (bct.has("index")) { material->set_texture(SpatialMaterial::TEXTURE_NORMAL, _get_texture(state, bct["index"])); material->set_feature(SpatialMaterial::FEATURE_NORMAL_MAPPING, true); @@ -1351,7 +1437,7 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { } } if (d.has("occlusionTexture")) { - Dictionary bct = d["occlusionTexture"]; + const Dictionary &bct = d["occlusionTexture"]; if (bct.has("index")) { material->set_texture(SpatialMaterial::TEXTURE_AMBIENT_OCCLUSION, _get_texture(state, bct["index"])); material->set_ao_texture_channel(SpatialMaterial::TEXTURE_CHANNEL_RED); @@ -1360,16 +1446,16 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { } if (d.has("emissiveFactor")) { - Array arr = d["emissiveFactor"]; + const Array &arr = d["emissiveFactor"]; ERR_FAIL_COND_V(arr.size() != 3, ERR_PARSE_ERROR); - Color c = Color(arr[0], arr[1], arr[2]).to_srgb(); + const Color c = Color(arr[0], arr[1], arr[2]).to_srgb(); material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); material->set_emission(c); } if (d.has("emissiveTexture")) { - Dictionary bct = d["emissiveTexture"]; + const Dictionary &bct = d["emissiveTexture"]; if (bct.has("index")) { material->set_texture(SpatialMaterial::TEXTURE_EMISSION, _get_texture(state, bct["index"])); material->set_feature(SpatialMaterial::FEATURE_EMISSION, true); @@ -1378,16 +1464,17 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { } if (d.has("doubleSided")) { - bool ds = d["doubleSided"]; + const bool ds = d["doubleSided"]; if (ds) { material->set_cull_mode(SpatialMaterial::CULL_DISABLED); } } if (d.has("alphaMode")) { - String am = d["alphaMode"]; + const String &am = d["alphaMode"]; if (am != "OPAQUE") { material->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); + material->set_depth_draw_mode(SpatialMaterial::DEPTH_DRAW_ALPHA_OPAQUE_PREPASS); } } @@ -1399,131 +1486,764 @@ Error EditorSceneImporterGLTF::_parse_materials(GLTFState &state) { return OK; } +EditorSceneImporterGLTF::GLTFNodeIndex EditorSceneImporterGLTF::_find_highest_node(GLTFState &state, const Vector<GLTFNodeIndex> &subset) { + int heighest = -1; + GLTFNodeIndex best_node = -1; + + for (int i = 0; i < subset.size(); ++i) { + const GLTFNodeIndex node_i = subset[i]; + const GLTFNode *node = state.nodes[node_i]; + + if (heighest == -1 || node->height < heighest) { + heighest = node->height; + best_node = node_i; + } + } + + return best_node; +} + +bool EditorSceneImporterGLTF::_capture_nodes_in_skin(GLTFState &state, GLTFSkin &skin, const GLTFNodeIndex node_index) { + + bool found_joint = false; + + for (int i = 0; i < state.nodes[node_index]->children.size(); ++i) { + found_joint |= _capture_nodes_in_skin(state, skin, state.nodes[node_index]->children[i]); + } + + if (found_joint) { + // Mark it if we happen to find another skins joint... + if (state.nodes[node_index]->joint && skin.joints.find(node_index) < 0) { + skin.joints.push_back(node_index); + } else if (skin.non_joints.find(node_index) < 0) { + skin.non_joints.push_back(node_index); + } + } + + if (skin.joints.find(node_index) > 0) { + return true; + } + + return false; +} + +void EditorSceneImporterGLTF::_capture_nodes_for_multirooted_skin(GLTFState &state, GLTFSkin &skin) { + + DisjointSet<GLTFNodeIndex> disjoint_set; + + for (int i = 0; i < skin.joints.size(); ++i) { + const GLTFNodeIndex node_index = skin.joints[i]; + const GLTFNodeIndex parent = state.nodes[node_index]->parent; + disjoint_set.insert(node_index); + + if (skin.joints.find(parent) >= 0) { + disjoint_set.create_union(parent, node_index); + } + } + + Vector<GLTFNodeIndex> roots; + disjoint_set.get_representatives(roots); + + if (roots.size() <= 1) { + return; + } + + int maxHeight = -1; + + // Determine the max height rooted tree + for (int i = 0; i < roots.size(); ++i) { + const GLTFNodeIndex root = roots[i]; + + if (maxHeight == -1 || state.nodes[root]->height < maxHeight) { + maxHeight = state.nodes[root]->height; + } + } + + // Go up the tree till all of the multiple roots of the skin are at the same hierarchy level. + // This sucks, but 99% of all game engines (not just Godot) would have this same issue. + for (int i = 0; i < roots.size(); ++i) { + + GLTFNodeIndex current_node = roots[i]; + while (state.nodes[current_node]->height > maxHeight) { + GLTFNodeIndex parent = state.nodes[current_node]->parent; + + if (state.nodes[parent]->joint && skin.joints.find(parent) < 0) { + skin.joints.push_back(parent); + } else if (skin.non_joints.find(parent) < 0) { + skin.non_joints.push_back(parent); + } + + current_node = parent; + } + + // replace the roots + roots.write[i] = current_node; + } + + // Climb up the tree until they all have the same parent + bool all_same; + + do { + all_same = true; + const GLTFNodeIndex first_parent = state.nodes[roots[0]]->parent; + + for (int i = 1; i < roots.size(); ++i) { + all_same &= (first_parent == state.nodes[roots[i]]->parent); + } + + if (!all_same) { + for (int i = 0; i < roots.size(); ++i) { + const GLTFNodeIndex current_node = roots[i]; + const GLTFNodeIndex parent = state.nodes[current_node]->parent; + + if (state.nodes[parent]->joint && skin.joints.find(parent) < 0) { + skin.joints.push_back(parent); + } else if (skin.non_joints.find(parent) < 0) { + skin.non_joints.push_back(parent); + } + + roots.write[i] = parent; + } + } + + } while (!all_same); +} + +Error EditorSceneImporterGLTF::_expand_skin(GLTFState &state, GLTFSkin &skin) { + + _capture_nodes_for_multirooted_skin(state, skin); + + // Grab all nodes that lay in between skin joints/nodes + DisjointSet<GLTFNodeIndex> disjoint_set; + + Vector<GLTFNodeIndex> all_skin_nodes; + all_skin_nodes.append_array(skin.joints); + all_skin_nodes.append_array(skin.non_joints); + + for (int i = 0; i < all_skin_nodes.size(); ++i) { + const GLTFNodeIndex node_index = all_skin_nodes[i]; + const GLTFNodeIndex parent = state.nodes[node_index]->parent; + disjoint_set.insert(node_index); + + if (all_skin_nodes.find(parent) >= 0) { + disjoint_set.create_union(parent, node_index); + } + } + + Vector<GLTFNodeIndex> out_owners; + disjoint_set.get_representatives(out_owners); + + Vector<GLTFNodeIndex> out_roots; + + for (int i = 0; i < out_owners.size(); ++i) { + Vector<GLTFNodeIndex> set; + disjoint_set.get_members(set, out_owners[i]); + + const GLTFNodeIndex root = _find_highest_node(state, set); + ERR_FAIL_COND_V(root < 0, FAILED); + out_roots.push_back(root); + } + + out_roots.sort(); + + for (int i = 0; i < out_roots.size(); ++i) { + _capture_nodes_in_skin(state, skin, out_roots[i]); + } + + skin.roots = out_roots; + + return OK; +} + +Error EditorSceneImporterGLTF::_verify_skin(GLTFState &state, GLTFSkin &skin) { + // Grab all nodes that lay in between skin joints/nodes + DisjointSet<GLTFNodeIndex> disjoint_set; + + Vector<GLTFNodeIndex> all_skin_nodes; + all_skin_nodes.append_array(skin.joints); + all_skin_nodes.append_array(skin.non_joints); + + for (int i = 0; i < all_skin_nodes.size(); ++i) { + const GLTFNodeIndex node_index = all_skin_nodes[i]; + const GLTFNodeIndex parent = state.nodes[node_index]->parent; + disjoint_set.insert(node_index); + + if (all_skin_nodes.find(parent) >= 0) { + disjoint_set.create_union(parent, node_index); + } + } + + Vector<GLTFNodeIndex> out_roots; + disjoint_set.get_representatives(out_roots); + out_roots.sort(); + + ERR_FAIL_COND_V(out_roots.size() == 0, FAILED); + + ERR_FAIL_COND_V(out_roots.size() != skin.roots.size(), FAILED); + for (int i = 0; i < out_roots.size(); ++i) { + ERR_FAIL_COND_V(out_roots.size() != skin.roots.size(), FAILED); + } + + // Single rooted skin? Perfectly ok! + if (out_roots.size() == 1) { + return OK; + } + + // Make sure all parents of a multi-rooted skin are the SAME + const GLTFNodeIndex parent = state.nodes[out_roots[0]]->parent; + for (int i = 1; i < out_roots.size(); ++i) { + if (state.nodes[out_roots[i]]->parent != parent) { + return FAILED; + } + } + + return OK; +} + Error EditorSceneImporterGLTF::_parse_skins(GLTFState &state) { if (!state.json.has("skins")) return OK; - Array skins = state.json["skins"]; + const Array &skins = state.json["skins"]; + + // Create the base skins, and mark nodes that are joints for (int i = 0; i < skins.size(); i++) { - Dictionary d = skins[i]; + const Dictionary &d = skins[i]; GLTFSkin skin; ERR_FAIL_COND_V(!d.has("joints"), ERR_PARSE_ERROR); - Array joints = d["joints"]; - Vector<Transform> bind_matrices; + const Array &joints = d["joints"]; if (d.has("inverseBindMatrices")) { - bind_matrices = _decode_accessor_as_xform(state, d["inverseBindMatrices"], false); - ERR_FAIL_COND_V(bind_matrices.size() != joints.size(), ERR_PARSE_ERROR); + skin.inverse_binds = _decode_accessor_as_xform(state, d["inverseBindMatrices"], false); + ERR_FAIL_COND_V(skin.inverse_binds.size() != joints.size(), ERR_PARSE_ERROR); } for (int j = 0; j < joints.size(); j++) { - int index = joints[j]; - ERR_FAIL_INDEX_V(index, state.nodes.size(), ERR_PARSE_ERROR); - GLTFNode::Joint joint; - joint.skin = state.skins.size(); - joint.bone = j; - state.nodes[index]->joints.push_back(joint); - GLTFSkin::Bone bone; - bone.node = index; - if (bind_matrices.size()) { - bone.inverse_bind = bind_matrices[j]; - } + const GLTFNodeIndex node = joints[j]; + ERR_FAIL_INDEX_V(node, state.nodes.size(), ERR_PARSE_ERROR); - skin.bones.push_back(bone); + skin.joints.push_back(node); + skin.joints_original.push_back(node); + + state.nodes[node]->joint = true; + } + + if (d.has("name")) { + skin.name = d["name"]; } - print_verbose("glTF: Skin has skeleton? " + itos(d.has("skeleton"))); if (d.has("skeleton")) { - int skeleton = d["skeleton"]; - ERR_FAIL_INDEX_V(skeleton, state.nodes.size(), ERR_PARSE_ERROR); - print_verbose("glTF: Setting skeleton skin to" + itos(skeleton)); - skin.skeleton = skeleton; - if (!state.skeleton_nodes.has(skeleton)) { - state.skeleton_nodes[skeleton] = Vector<int>(); + skin.skin_root = d["skeleton"]; + } + + state.skins.push_back(skin); + } + + for (GLTFSkinIndex i = 0; i < state.skins.size(); ++i) { + GLTFSkin &skin = state.skins.write[i]; + + // Expand the skin to capture all the extra non-joints that lie in between the actual joints, + // and expand the hierarchy to ensure multi-rooted trees lie on the same height level + ERR_FAIL_COND_V(_expand_skin(state, skin), ERR_PARSE_ERROR); + ERR_FAIL_COND_V(_verify_skin(state, skin), ERR_PARSE_ERROR); + } + + print_verbose("glTF: Total skins: " + itos(state.skins.size())); + + return OK; +} + +Error EditorSceneImporterGLTF::_determine_skeletons(GLTFState &state) { + + // Using a disjoint set, we are going to potentially combine all skins that are actually branches + // of a main skeleton, or treat skins defining the same set of nodes as ONE skeleton. + // This is another unclear issue caused by the current glTF specification. + + DisjointSet<GLTFNodeIndex> skeleton_sets; + + for (GLTFSkinIndex skin_i = 0; skin_i < state.skins.size(); ++skin_i) { + const GLTFSkin &skin = state.skins[skin_i]; + + Vector<GLTFNodeIndex> all_skin_nodes; + all_skin_nodes.append_array(skin.joints); + all_skin_nodes.append_array(skin.non_joints); + + for (int i = 0; i < all_skin_nodes.size(); ++i) { + const GLTFNodeIndex node_index = all_skin_nodes[i]; + const GLTFNodeIndex parent = state.nodes[node_index]->parent; + skeleton_sets.insert(node_index); + + if (all_skin_nodes.find(parent) >= 0) { + skeleton_sets.create_union(parent, node_index); } - state.skeleton_nodes[skeleton].push_back(i); } - if (d.has("name")) { - skin.name = d["name"]; + // We are going to connect the separate skin subtrees in each skin together + // so that the final roots are entire sets of valid skin trees + for (int i = 1; i < skin.roots.size(); ++i) { + skeleton_sets.create_union(skin.roots[0], skin.roots[i]); } + } - //locate the right place to put a Skeleton node - /* - if (state.skin_users.has(i)) { - Vector<int> users = state.skin_users[i]; - int skin_node = -1; - for (int j = 0; j < users.size(); j++) { - int user = state.nodes[users[j]]->parent; //always go from parent - if (j == 0) { - skin_node = user; - } else if (skin_node != -1) { - bool found = false; - while (skin_node >= 0) { - - int cuser = user; - while (cuser != -1) { - if (cuser == skin_node) { - found = true; - break; - } - cuser = state.nodes[skin_node]->parent; - } - if (found) - break; - skin_node = state.nodes[skin_node]->parent; - } + { // attempt to joint all touching subsets (siblings/parent are part of another skin) + Vector<GLTFNodeIndex> groups_representatives; + skeleton_sets.get_representatives(groups_representatives); + + Vector<GLTFNodeIndex> highest_group_members; + Vector<Vector<GLTFNodeIndex> > groups; + for (int i = 0; i < groups_representatives.size(); ++i) { + Vector<GLTFNodeIndex> group; + skeleton_sets.get_members(group, groups_representatives[i]); + highest_group_members.push_back(_find_highest_node(state, group)); + groups.push_back(group); + } + + for (int i = 0; i < highest_group_members.size(); ++i) { + const GLTFNodeIndex node_i = highest_group_members[i]; + + // Attach any siblings together (this needs to be done n^2/2 times) + for (int j = i + 1; j < highest_group_members.size(); ++j) { + const GLTFNodeIndex node_j = highest_group_members[j]; + + // Even if they are siblings under the root! :) + if (state.nodes[node_i]->parent == state.nodes[node_j]->parent) { + skeleton_sets.create_union(node_i, node_j); + } + } - if (!found) { - skin_node = -1; //just leave where it is + // Attach any parenting going on together (we need to do this n^2 times) + const GLTFNodeIndex node_i_parent = state.nodes[node_i]->parent; + if (node_i_parent >= 0) { + for (int j = 0; j < groups.size() && i != j; ++j) { + const Vector<GLTFNodeIndex> &group = groups[j]; + + if (group.find(node_i_parent) >= 0) { + const GLTFNodeIndex node_j = highest_group_members[j]; + skeleton_sets.create_union(node_i, node_j); } + } + } + } + } + + // At this point, the skeleton groups should be finalized + Vector<GLTFNodeIndex> skeleton_owners; + skeleton_sets.get_representatives(skeleton_owners); + + // Mark all the skins actual skeletons, after we have merged them + for (GLTFSkeletonIndex skel_i = 0; skel_i < skeleton_owners.size(); ++skel_i) { - //find a common parent + const GLTFNodeIndex skeleton_owner = skeleton_owners[skel_i]; + GLTFSkeleton skeleton; + + Vector<GLTFNodeIndex> skeleton_nodes; + skeleton_sets.get_members(skeleton_nodes, skeleton_owner); + + for (GLTFSkinIndex skin_i = 0; skin_i < state.skins.size(); ++skin_i) { + GLTFSkin &skin = state.skins.write[skin_i]; + + // If any of the the skeletons nodes exist in a skin, that skin now maps to the skeleton + for (int i = 0; i < skeleton_nodes.size(); ++i) { + GLTFNodeIndex skel_node_i = skeleton_nodes[i]; + if (skin.joints.find(skel_node_i) >= 0 || skin.non_joints.find(skel_node_i) >= 0) { + skin.skeleton = skel_i; + continue; } } + } + + Vector<GLTFNodeIndex> non_joints; + for (int i = 0; i < skeleton_nodes.size(); ++i) { + const GLTFNodeIndex node_i = skeleton_nodes[i]; + + if (state.nodes[node_i]->joint) { + skeleton.joints.push_back(node_i); + } else { + non_joints.push_back(node_i); + } + } + + state.skeletons.push_back(skeleton); + + _reparent_non_joint_skeleton_subtrees(state, state.skeletons.write[skel_i], non_joints); + } + + for (GLTFSkeletonIndex skel_i = 0; skel_i < state.skeletons.size(); ++skel_i) { + GLTFSkeleton &skeleton = state.skeletons.write[skel_i]; + + for (int i = 0; i < skeleton.joints.size(); ++i) { + const GLTFNodeIndex node_i = skeleton.joints[i]; + GLTFNode *node = state.nodes[node_i]; + + ERR_FAIL_COND_V(!node->joint, ERR_PARSE_ERROR); + ERR_FAIL_COND_V(node->skeleton >= 0, ERR_PARSE_ERROR); + node->skeleton = skel_i; + } + + ERR_FAIL_COND_V(_determine_skeleton_roots(state, skel_i), ERR_PARSE_ERROR); + } + + return OK; +} + +Error EditorSceneImporterGLTF::_reparent_non_joint_skeleton_subtrees(GLTFState &state, GLTFSkeleton &skeleton, const Vector<GLTFNodeIndex> &non_joints) { + + DisjointSet<GLTFNodeIndex> subtree_set; + + // Populate the disjoint set with ONLY non joints that are in the skeleton hierarchy (non_joints vector) + // This way we can find any joints that lie in between joints, as the current glTF specification + // mentions nothing about non-joints being in between joints of the same skin. Hopefully one day we + // can remove this code. + + // skinD depicted here explains this issue: + // https://github.com/KhronosGroup/glTF-Asset-Generator/blob/master/Output/Positive/Animation_Skin + + for (int i = 0; i < non_joints.size(); ++i) { + const GLTFNodeIndex node_i = non_joints[i]; + + subtree_set.insert(node_i); + + const GLTFNodeIndex parent_i = state.nodes[node_i]->parent; + if (parent_i >= 0 && non_joints.find(parent_i) >= 0 && !state.nodes[parent_i]->joint) { + subtree_set.create_union(parent_i, node_i); + } + } + + // Find all the non joint subtrees and re-parent them to a new "fake" joint + + Vector<GLTFNodeIndex> non_joint_subtree_roots; + subtree_set.get_representatives(non_joint_subtree_roots); + + for (int root_i = 0; root_i < non_joint_subtree_roots.size(); ++root_i) { + const GLTFNodeIndex subtree_root = non_joint_subtree_roots[root_i]; + + Vector<GLTFNodeIndex> subtree_nodes; + subtree_set.get_members(subtree_nodes, subtree_root); + + for (int subtree_i = 0; subtree_i < subtree_nodes.size(); ++subtree_i) { + ERR_FAIL_COND_V(_reparent_to_fake_joint(state, skeleton, subtree_nodes[subtree_i]), FAILED); + + // We modified the tree, recompute all the heights + _compute_node_heights(state); + } + } + + return OK; +} + +Error EditorSceneImporterGLTF::_reparent_to_fake_joint(GLTFState &state, GLTFSkeleton &skeleton, const GLTFNodeIndex node_index) { + GLTFNode *node = state.nodes[node_index]; + + // Can we just "steal" this joint if it is just a spatial node? + if (node->skin < 0 && node->mesh < 0 && node->camera < 0) { + node->joint = true; + // Add the joint to the skeletons joints + skeleton.joints.push_back(node_index); + return OK; + } + + GLTFNode *fake_joint = memnew(GLTFNode); + const GLTFNodeIndex fake_joint_index = state.nodes.size(); + state.nodes.push_back(fake_joint); + + // We better not be a joint, or we messed up in our logic + if (node->joint == true) + return FAILED; + + fake_joint->translation = node->translation; + fake_joint->rotation = node->rotation; + fake_joint->scale = node->scale; + fake_joint->xform = node->xform; + fake_joint->joint = true; + + // We can use the exact same name here, because the joint will be inside a skeleton and not the scene + fake_joint->name = node->name; + + // Clear the nodes transforms, since it will be parented to the fake joint + node->translation = Vector3(0, 0, 0); + node->rotation = Quat(); + node->scale = Vector3(1, 1, 1); + node->xform = Transform(); + + // Transfer the node children to the fake joint + for (int child_i = 0; child_i < node->children.size(); ++child_i) { + GLTFNode *child = state.nodes[node->children[child_i]]; + child->parent = fake_joint_index; + } + + fake_joint->children = node->children; + node->children.clear(); + + // add the fake joint to the parent and remove the original joint + if (node->parent >= 0) { + GLTFNode *parent = state.nodes[node->parent]; + parent->children.erase(node_index); + parent->children.push_back(fake_joint_index); + fake_joint->parent = node->parent; + } + + // Add the node to the fake joint + fake_joint->children.push_back(node_index); + node->parent = fake_joint_index; + node->fake_joint_parent = fake_joint_index; + + // Add the fake joint to the skeletons joints + skeleton.joints.push_back(fake_joint_index); + + // Replace skin_skeletons with fake joints if we must. + for (GLTFSkinIndex skin_i = 0; skin_i < state.skins.size(); ++skin_i) { + GLTFSkin &skin = state.skins.write[skin_i]; + if (skin.skin_root == node_index) { + skin.skin_root = fake_joint_index; + } + } + + return OK; +} + +Error EditorSceneImporterGLTF::_determine_skeleton_roots(GLTFState &state, const GLTFSkeletonIndex skel_i) { + + DisjointSet<GLTFNodeIndex> disjoint_set; + + for (GLTFNodeIndex i = 0; i < state.nodes.size(); ++i) { + const GLTFNode *node = state.nodes[i]; + + if (node->skeleton != skel_i) { + continue; + } + + disjoint_set.insert(i); + + if (node->parent >= 0 && state.nodes[node->parent]->skeleton == skel_i) { + disjoint_set.create_union(node->parent, i); + } + } + + GLTFSkeleton &skeleton = state.skeletons.write[skel_i]; + + Vector<GLTFNodeIndex> owners; + disjoint_set.get_representatives(owners); + + Vector<GLTFNodeIndex> roots; + + for (int i = 0; i < owners.size(); ++i) { + Vector<GLTFNodeIndex> set; + disjoint_set.get_members(set, owners[i]); + const GLTFNodeIndex root = _find_highest_node(state, set); + ERR_FAIL_COND_V(root < 0, FAILED); + roots.push_back(root); + } + + roots.sort(); + + skeleton.roots = roots; + + if (roots.size() == 0) { + return FAILED; + } else if (roots.size() == 1) { + return OK; + } + + // Check that the subtrees have the same parent root + const GLTFNodeIndex parent = state.nodes[roots[0]]->parent; + for (int i = 1; i < roots.size(); ++i) { + if (state.nodes[roots[i]]->parent != parent) { + return FAILED; + } + } + + return OK; +} + +Error EditorSceneImporterGLTF::_create_skeletons(GLTFState &state) { + for (GLTFSkeletonIndex skel_i = 0; skel_i < state.skeletons.size(); ++skel_i) { + + GLTFSkeleton &gltf_skeleton = state.skeletons.write[skel_i]; + + Skeleton *skeleton = memnew(Skeleton); + gltf_skeleton.godot_skeleton = skeleton; + + // Make a unique name, no gltf node represents this skeleton + skeleton->set_name(_gen_unique_name(state, "Skeleton")); + + List<GLTFNodeIndex> bones; - if (skin_node != -1) { - for (int j = 0; j < users.size(); j++) { - state.nodes[users[j]]->child_of_skeleton = i; + for (int i = 0; i < gltf_skeleton.roots.size(); ++i) { + bones.push_back(gltf_skeleton.roots[i]); + } + + // Make the skeleton creation deterministic by going through the roots in + // a sorted order, and DEPTH FIRST + bones.sort(); + + while (!bones.empty()) { + const GLTFNodeIndex node_i = bones.front()->get(); + bones.pop_front(); + + GLTFNode *node = state.nodes[node_i]; + ERR_FAIL_COND_V(node->skeleton != skel_i, FAILED); + + { // Add all child nodes to the stack (deterministically) + Vector<GLTFNodeIndex> child_nodes; + for (int i = 0; i < node->children.size(); ++i) { + const GLTFNodeIndex child_i = node->children[i]; + if (state.nodes[child_i]->skeleton == skel_i) { + child_nodes.push_back(child_i); + } } - state.nodes[skin_node]->skeleton_children.push_back(i); + // Depth first insertion + child_nodes.sort(); + for (int i = child_nodes.size() - 1; i >= 0; --i) { + bones.push_front(child_nodes[i]); + } } + + const int bone_index = skeleton->get_bone_count(); + + if (node->name.empty()) { + node->name = "bone"; + } + + node->name = _gen_unique_bone_name(state, skel_i, node->name); + + skeleton->add_bone(node->name); + skeleton->set_bone_rest(bone_index, node->xform); + skeleton->set_bone_pose(bone_index, node->xform); + + if (node->parent >= 0 && state.nodes[node->parent]->skeleton == skel_i) { + const int bone_parent = skeleton->find_bone(state.nodes[node->parent]->name); + ERR_FAIL_COND_V(bone_parent < 0, FAILED); + skeleton->set_bone_parent(bone_index, skeleton->find_bone(state.nodes[node->parent]->name)); + } + + state.scene_nodes.insert(node_i, skeleton); } - */ - state.skins.push_back(skin); } - print_verbose("glTF: Total skins: " + itos(state.skins.size())); - //now + ERR_FAIL_COND_V(_map_skin_joints_indices_to_skeleton_bone_indices(state), ERR_PARSE_ERROR); + + return OK; +} + +Error EditorSceneImporterGLTF::_map_skin_joints_indices_to_skeleton_bone_indices(GLTFState &state) { + for (GLTFSkinIndex skin_i = 0; skin_i < state.skins.size(); ++skin_i) { + GLTFSkin &skin = state.skins.write[skin_i]; + + const GLTFSkeleton &skeleton = state.skeletons[skin.skeleton]; + + for (int joint_index = 0; joint_index < skin.joints_original.size(); ++joint_index) { + const GLTFNodeIndex node_i = skin.joints_original[joint_index]; + const GLTFNode *node = state.nodes[node_i]; + + const int bone_index = skeleton.godot_skeleton->find_bone(node->name); + ERR_FAIL_COND_V(bone_index < 0, FAILED); + + skin.joint_i_to_bone_i.insert(joint_index, bone_index); + } + } + + return OK; +} + +Error EditorSceneImporterGLTF::_create_skins(GLTFState &state) { + for (GLTFSkinIndex skin_i = 0; skin_i < state.skins.size(); ++skin_i) { + GLTFSkin &gltf_skin = state.skins.write[skin_i]; + + Ref<Skin> skin; + skin.instance(); + + // Some skins don't have IBM's! What absolute monsters! + const bool has_ibms = !gltf_skin.inverse_binds.empty(); + + for (int joint_i = 0; joint_i < gltf_skin.joints_original.size(); ++joint_i) { + int bone_i = gltf_skin.joint_i_to_bone_i[joint_i]; + + if (has_ibms) { + skin->add_bind(bone_i, gltf_skin.inverse_binds[joint_i]); + } else { + skin->add_bind(bone_i, Transform()); + } + } + + gltf_skin.godot_skin = skin; + } + + // Purge the duplicates! + _remove_duplicate_skins(state); + + // Create unique names now, after removing duplicates + for (GLTFSkinIndex skin_i = 0; skin_i < state.skins.size(); ++skin_i) { + Ref<Skin> skin = state.skins[skin_i].godot_skin; + if (skin->get_name().empty()) { + // Make a unique name, no gltf node represents this skin + skin->set_name(_gen_unique_name(state, "Skin")); + } + } return OK; } +bool EditorSceneImporterGLTF::_skins_are_same(const Ref<Skin> &skin_a, const Ref<Skin> &skin_b) { + if (skin_a->get_bind_count() != skin_b->get_bind_count()) { + return false; + } + + for (int i = 0; i < skin_a->get_bind_count(); ++i) { + + if (skin_a->get_bind_bone(i) != skin_b->get_bind_bone(i)) { + return false; + } + + Transform a_xform = skin_a->get_bind_pose(i); + Transform b_xform = skin_b->get_bind_pose(i); + + if (a_xform != b_xform) { + return false; + } + } + + return true; +} + +void EditorSceneImporterGLTF::_remove_duplicate_skins(GLTFState &state) { + for (int i = 0; i < state.skins.size(); ++i) { + for (int j = i + 1; j < state.skins.size(); ++j) { + const Ref<Skin> &skin_i = state.skins[i].godot_skin; + const Ref<Skin> &skin_j = state.skins[j].godot_skin; + + if (_skins_are_same(skin_i, skin_j)) { + // replace it and delete the old + state.skins.write[j].godot_skin = skin_i; + } + } + } +} + Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) { if (!state.json.has("cameras")) return OK; - Array cameras = state.json["cameras"]; + const Array &cameras = state.json["cameras"]; - for (int i = 0; i < cameras.size(); i++) { + for (GLTFCameraIndex i = 0; i < cameras.size(); i++) { - Dictionary d = cameras[i]; + const Dictionary &d = cameras[i]; GLTFCamera camera; ERR_FAIL_COND_V(!d.has("type"), ERR_PARSE_ERROR); - String type = d["type"]; + const String &type = d["type"]; if (type == "orthographic") { camera.perspective = false; if (d.has("orthographic")) { - Dictionary og = d["orthographic"]; + const Dictionary &og = d["orthographic"]; camera.fov_size = og["ymag"]; camera.zfar = og["zfar"]; camera.znear = og["znear"]; @@ -1535,7 +2255,7 @@ Error EditorSceneImporterGLTF::_parse_cameras(GLTFState &state) { camera.perspective = true; if (d.has("perspective")) { - Dictionary ppt = d["perspective"]; + const Dictionary &ppt = d["perspective"]; // 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"]; @@ -1560,11 +2280,11 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { if (!state.json.has("animations")) return OK; - Array animations = state.json["animations"]; + const Array &animations = state.json["animations"]; - for (int i = 0; i < animations.size(); i++) { + for (GLTFAnimationIndex i = 0; i < animations.size(); i++) { - Dictionary d = animations[i]; + const Dictionary &d = animations[i]; GLTFAnimation animation; @@ -1580,25 +2300,25 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { for (int j = 0; j < channels.size(); j++) { - Dictionary c = channels[j]; + const Dictionary &c = channels[j]; if (!c.has("target")) continue; - Dictionary t = c["target"]; + const Dictionary &t = c["target"]; if (!t.has("node") || !t.has("path")) { continue; } ERR_FAIL_COND_V(!c.has("sampler"), ERR_PARSE_ERROR); - int sampler = c["sampler"]; + const int sampler = c["sampler"]; ERR_FAIL_INDEX_V(sampler, samplers.size(), ERR_PARSE_ERROR); - int node = t["node"]; + GLTFNodeIndex node = t["node"]; String path = t["path"]; ERR_FAIL_INDEX_V(node, state.nodes.size(), ERR_PARSE_ERROR); - GLTFAnimation::Track *track = NULL; + GLTFAnimation::Track *track = nullptr; if (!animation.tracks.has(node)) { animation.tracks[node] = GLTFAnimation::Track(); @@ -1606,17 +2326,17 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { track = &animation.tracks[node]; - Dictionary s = samplers[sampler]; + const Dictionary &s = samplers[sampler]; ERR_FAIL_COND_V(!s.has("input"), ERR_PARSE_ERROR); ERR_FAIL_COND_V(!s.has("output"), ERR_PARSE_ERROR); - int input = s["input"]; - int output = s["output"]; + const int input = s["input"]; + const int output = s["output"]; GLTFAnimation::Interpolation interp = GLTFAnimation::INTERP_LINEAR; if (s.has("interpolation")) { - String in = s["interpolation"]; + const String &in = s["interpolation"]; if (in == "STEP") { interp = GLTFAnimation::INTERP_STEP; } else if (in == "LINEAR") { @@ -1628,33 +2348,33 @@ Error EditorSceneImporterGLTF::_parse_animations(GLTFState &state) { } } - PoolVector<float> times = _decode_accessor_as_floats(state, input, false); + const PoolVector<float> times = _decode_accessor_as_floats(state, input, false); if (path == "translation") { - PoolVector<Vector3> translations = _decode_accessor_as_vec3(state, output, false); + const PoolVector<Vector3> translations = _decode_accessor_as_vec3(state, output, false); track->translation_track.interpolation = interp; track->translation_track.times = Variant(times); //convert via variant track->translation_track.values = Variant(translations); //convert via variant } else if (path == "rotation") { - Vector<Quat> rotations = _decode_accessor_as_quat(state, output, false); + const Vector<Quat> rotations = _decode_accessor_as_quat(state, output, false); track->rotation_track.interpolation = interp; track->rotation_track.times = Variant(times); //convert via variant track->rotation_track.values = rotations; //convert via variant } else if (path == "scale") { - PoolVector<Vector3> scales = _decode_accessor_as_vec3(state, output, false); + const PoolVector<Vector3> scales = _decode_accessor_as_vec3(state, output, false); track->scale_track.interpolation = interp; track->scale_track.times = Variant(times); //convert via variant track->scale_track.values = Variant(scales); //convert via variant } else if (path == "weights") { - PoolVector<float> weights = _decode_accessor_as_floats(state, output, false); + const PoolVector<float> weights = _decode_accessor_as_floats(state, output, false); ERR_FAIL_INDEX_V(state.nodes[node]->mesh, state.meshes.size(), ERR_PARSE_ERROR); const GLTFMesh *mesh = &state.meshes[state.nodes[node]->mesh]; ERR_FAIL_COND_V(mesh->blend_weights.size() == 0, ERR_PARSE_ERROR); - int wc = mesh->blend_weights.size(); + const int wc = mesh->blend_weights.size(); track->weight_tracks.resize(wc); - int wlen = weights.size() / wc; + const int wlen = weights.size() / wc; PoolVector<float>::Read r = weights.read(); for (int k = 0; k < wc; k++) { //separate tracks, having them together is not such a good idea GLTFAnimation::Channel<float> cf; @@ -1686,11 +2406,16 @@ void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) { for (int i = 0; i < state.nodes.size(); i++) { GLTFNode *n = state.nodes[i]; - if (n->name == "") { + + // Any joints get unique names generated when the skeleton is made, unique to the skeleton + if (n->skeleton >= 0) + continue; + + if (n->name.empty()) { if (n->mesh >= 0) { n->name = "Mesh"; - } else if (n->joints.size()) { - n->name = "Bone"; + } else if (n->camera >= 0) { + n->name = "Camera"; } else { n->name = "Node"; } @@ -1700,127 +2425,131 @@ void EditorSceneImporterGLTF::_assign_scene_names(GLTFState &state) { } } -void EditorSceneImporterGLTF::_reparent_skeleton(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, Node *p_parent_node) { - //reparent skeletons to proper place - Vector<int> nodes = state.skeleton_nodes[p_node]; - for (int i = 0; i < nodes.size(); i++) { - Skeleton *skeleton = skeletons[nodes[i]]; - Node *owner = skeleton->get_owner(); - skeleton->get_parent()->remove_child(skeleton); - p_parent_node->add_child(skeleton); - skeleton->set_owner(owner); - //may have meshes as children, set owner in them too - for (int j = 0; j < skeleton->get_child_count(); j++) { - skeleton->get_child(j)->set_owner(owner); - } - } -} +BoneAttachment *EditorSceneImporterGLTF::_generate_bone_attachment(GLTFState &state, Skeleton *skeleton, const GLTFNodeIndex node_index) { -void EditorSceneImporterGLTF::_generate_node(GLTFState &state, int p_node, Node *p_parent, Node *p_owner, Vector<Skeleton *> &skeletons) { - ERR_FAIL_INDEX(p_node, state.nodes.size()); + const GLTFNode *gltf_node = state.nodes[node_index]; + const GLTFNode *bone_node = state.nodes[gltf_node->parent]; - GLTFNode *n = state.nodes[p_node]; - Spatial *node; + BoneAttachment *bone_attachment = memnew(BoneAttachment); + print_verbose("glTF: Creating bone attachment for: " + gltf_node->name); - if (n->mesh >= 0) { - ERR_FAIL_INDEX(n->mesh, state.meshes.size()); - MeshInstance *mi = memnew(MeshInstance); - print_verbose("glTF: Creating mesh for: " + n->name); - GLTFMesh &mesh = state.meshes.write[n->mesh]; - mi->set_mesh(mesh.mesh); - if (mesh.mesh->get_name() == "") { - mesh.mesh->set_name(n->name); - } - for (int i = 0; i < mesh.blend_weights.size(); i++) { - mi->set("blend_shapes/" + mesh.mesh->get_blend_shape_name(i), mesh.blend_weights[i]); - } + ERR_FAIL_COND_V(!bone_node->joint, nullptr); - node = mi; + bone_attachment->set_bone_name(bone_node->name); - } else if (n->camera >= 0) { - ERR_FAIL_INDEX(n->camera, state.cameras.size()); - Camera *camera = memnew(Camera); + return bone_attachment; +} - const GLTFCamera &c = state.cameras[n->camera]; - if (c.perspective) { - camera->set_perspective(c.fov_size, c.znear, c.znear); - } else { - camera->set_orthogonal(c.fov_size, c.znear, c.znear); - } +MeshInstance *EditorSceneImporterGLTF::_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { + const GLTFNode *gltf_node = state.nodes[node_index]; - node = camera; - } else { - node = memnew(Spatial); + ERR_FAIL_INDEX_V(gltf_node->mesh, state.meshes.size(), nullptr); + + MeshInstance *mi = memnew(MeshInstance); + print_verbose("glTF: Creating mesh for: " + gltf_node->name); + + GLTFMesh &mesh = state.meshes.write[gltf_node->mesh]; + mi->set_mesh(mesh.mesh); + + if (mesh.mesh->get_name() == "") { + mesh.mesh->set_name(gltf_node->name); + } + + for (int i = 0; i < mesh.blend_weights.size(); i++) { + mi->set("blend_shapes/" + mesh.mesh->get_blend_shape_name(i), mesh.blend_weights[i]); } - node->set_name(n->name); + return mi; +} - n->godot_nodes.push_back(node); +Camera *EditorSceneImporterGLTF::_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { + const GLTFNode *gltf_node = state.nodes[node_index]; - if (n->skin >= 0 && n->skin < skeletons.size() && Object::cast_to<MeshInstance>(node)) { - MeshInstance *mi = Object::cast_to<MeshInstance>(node); + ERR_FAIL_INDEX_V(gltf_node->camera, state.cameras.size(), nullptr); - Skeleton *s = skeletons[n->skin]; - s->add_child(node); //According to spec, mesh should actually act as a child of the skeleton, as it inherits its transform - mi->set_skeleton_path(String("..")); + Camera *camera = memnew(Camera); + print_verbose("glTF: Creating camera for: " + gltf_node->name); + const GLTFCamera &c = state.cameras[gltf_node->camera]; + if (c.perspective) { + camera->set_perspective(c.fov_size, c.znear, c.znear); } else { - p_parent->add_child(node); - node->set_transform(n->xform); + camera->set_orthogonal(c.fov_size, c.znear, c.znear); } - node->set_owner(p_owner); + return camera; +} -#if 0 - for (int i = 0; i < n->skeleton_children.size(); i++) { +Spatial *EditorSceneImporterGLTF::_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index) { + const GLTFNode *gltf_node = state.nodes[node_index]; - Skeleton *s = skeletons[n->skeleton_children[i]]; - s->get_parent()->remove_child(s); - node->add_child(s); - s->set_owner(p_owner); - } -#endif - for (int i = 0; i < n->children.size(); i++) { - if (state.nodes[n->children[i]]->joints.size()) { - _generate_bone(state, n->children[i], skeletons, node); - } else { - _generate_node(state, n->children[i], node, p_owner, skeletons); - } - } + Spatial *spatial = memnew(Spatial); + print_verbose("glTF: Creating spatial for: " + gltf_node->name); - if (state.skeleton_nodes.has(p_node)) { - _reparent_skeleton(state, p_node, skeletons, node); - } + return spatial; } -void EditorSceneImporterGLTF::_generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, Node *p_parent_node) { - ERR_FAIL_INDEX(p_node, state.nodes.size()); +void EditorSceneImporterGLTF::_generate_scene_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index) { + + const GLTFNode *gltf_node = state.nodes[node_index]; + + Spatial *current_node = nullptr; + + // Is our parent a skeleton + Skeleton *active_skeleton = Object::cast_to<Skeleton>(scene_parent); + + if (gltf_node->skeleton >= 0) { + Skeleton *skeleton = state.skeletons[gltf_node->skeleton].godot_skeleton; - if (state.skeleton_nodes.has(p_node)) { - _reparent_skeleton(state, p_node, skeletons, p_parent_node); + if (active_skeleton != skeleton) { + ERR_FAIL_COND_MSG(active_skeleton != nullptr, "glTF: Generating scene detected direct parented Skeletons"); + + // Add it to the scene if it has not already been added + if (skeleton->get_parent() == nullptr) { + scene_parent->add_child(skeleton); + skeleton->set_owner(scene_root); + } + } + + active_skeleton = skeleton; + current_node = skeleton; } - GLTFNode *n = state.nodes[p_node]; + // If we have an active skeleton, and the node is node skinned, we need to create a bone attachment + if (current_node == nullptr && active_skeleton != nullptr && gltf_node->skin < 0) { + BoneAttachment *bone_attachment = _generate_bone_attachment(state, active_skeleton, node_index); - for (int i = 0; i < n->joints.size(); i++) { - const int skin = n->joints[i].skin; - ERR_FAIL_COND(skin < 0); + scene_parent->add_child(bone_attachment); + bone_attachment->set_owner(scene_root); - Skeleton *s = skeletons[skin]; - const GLTFNode *gltf_bone_node = state.nodes[state.skins[skin].bones[n->joints[i].bone].node]; - const String bone_name = gltf_bone_node->name; - const int parent = gltf_bone_node->parent; - const int parent_index = s->find_bone(state.nodes[parent]->name); + // There is no gltf_node that represent this, so just directly create a unique name + bone_attachment->set_name(_gen_unique_name(state, "BoneAttachment")); - const int bone_index = s->find_bone(bone_name); - s->set_bone_parent(bone_index, parent_index); + // We change the scene_parent to our bone attachment now. We do not set current_node because we want to make the node + // and attach it to the bone_attachment + scene_parent = bone_attachment; + } + + // We still have not managed to make a node + if (current_node == nullptr) { + if (gltf_node->mesh >= 0) { + current_node = _generate_mesh_instance(state, scene_parent, node_index); + } else if (gltf_node->camera >= 0) { + current_node = _generate_camera(state, scene_parent, node_index); + } else { + current_node = _generate_spatial(state, scene_parent, node_index); + } - n->godot_nodes.push_back(s); - n->joints.write[i].godot_bone_index = bone_index; + scene_parent->add_child(current_node); + current_node->set_owner(scene_root); + current_node->set_transform(gltf_node->xform); + current_node->set_name(gltf_node->name); } - for (int i = 0; i < n->children.size(); i++) { - _generate_bone(state, n->children[i], skeletons, p_parent_node); + state.scene_nodes.insert(node_index, current_node); + + for (int i = 0; i < gltf_node->children.size(); ++i) { + _generate_scene_node(state, current_node, scene_root, gltf_node->children[i]); } } @@ -1834,43 +2563,43 @@ struct EditorSceneImporterGLTFInterpolate { T catmull_rom(const T &p0, const T &p1, const T &p2, const T &p3, float t) { - float t2 = t * t; - float t3 = t2 * t; + const float t2 = t * t; + const float t3 = t2 * t; return 0.5f * ((2.0f * p1) + (-p0 + p2) * t + (2.0f * p0 - 5.0f * p1 + 4 * p2 - p3) * t2 + (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t3); } T bezier(T start, T control_1, T control_2, T end, float t) { /* Formula from Wikipedia article on Bezier curves. */ - real_t omt = (1.0 - t); - real_t omt2 = omt * omt; - real_t omt3 = omt2 * omt; - real_t t2 = t * t; - real_t t3 = t2 * t; + const real_t omt = (1.0 - t); + const real_t omt2 = omt * omt; + const real_t omt3 = omt2 * omt; + const real_t t2 = t * t; + const real_t t3 = t2 * t; return start * omt3 + control_1 * omt2 * t * 3.0 + control_2 * omt * t2 * 3.0 + end * t3; } }; -//thank you for existing, partial specialization +// thank you for existing, partial specialization template <> struct EditorSceneImporterGLTFInterpolate<Quat> { - Quat lerp(const Quat &a, const Quat &b, float c) const { + Quat lerp(const Quat &a, const Quat &b, const float c) const { ERR_FAIL_COND_V(!a.is_normalized(), Quat()); ERR_FAIL_COND_V(!b.is_normalized(), Quat()); return a.slerp(b, c).normalized(); } - Quat catmull_rom(const Quat &p0, const Quat &p1, const Quat &p2, const Quat &p3, float c) { + Quat catmull_rom(const Quat &p0, const Quat &p1, const Quat &p2, const Quat &p3, const float c) { ERR_FAIL_COND_V(!p1.is_normalized(), Quat()); ERR_FAIL_COND_V(!p2.is_normalized(), Quat()); return p1.slerp(p2, c).normalized(); } - Quat bezier(Quat start, Quat control_1, Quat control_2, Quat end, float t) { + Quat bezier(const Quat start, const Quat control_1, const Quat control_2, const Quat end, const float t) { ERR_FAIL_COND_V(!start.is_normalized(), Quat()); ERR_FAIL_COND_V(!end.is_normalized(), Quat()); @@ -1879,7 +2608,7 @@ struct EditorSceneImporterGLTFInterpolate<Quat> { }; template <class T> -T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time, GLTFAnimation::Interpolation p_interp) { +T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp) { //could use binary search, worth it? int idx = -1; @@ -1900,7 +2629,7 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons return p_values[p_times.size() - 1]; } - float c = (p_time - p_times[idx]) / (p_times[idx + 1] - p_times[idx]); + const float c = (p_time - p_times[idx]) / (p_times[idx + 1] - p_times[idx]); return interp.lerp(p_values[idx], p_values[idx + 1], c); @@ -1924,7 +2653,7 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons return p_values[1 + p_times.size() - 1]; } - float c = (p_time - p_times[idx]) / (p_times[idx + 1] - p_times[idx]); + const float c = (p_time - p_times[idx]) / (p_times[idx + 1] - p_times[idx]); return interp.catmull_rom(p_values[idx - 1], p_values[idx], p_values[idx + 1], p_values[idx + 3], c); @@ -1937,12 +2666,12 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons return p_values[(p_times.size() - 1) * 3 + 1]; } - float c = (p_time - p_times[idx]) / (p_times[idx + 1] - p_times[idx]); + const float c = (p_time - p_times[idx]) / (p_times[idx + 1] - p_times[idx]); - T from = p_values[idx * 3 + 1]; - T c1 = from + p_values[idx * 3 + 2]; - T to = p_values[idx * 3 + 4]; - T c2 = to + p_values[idx * 3 + 3]; + const T from = p_values[idx * 3 + 1]; + const T c1 = from + p_values[idx * 3 + 2]; + const T to = p_values[idx * 3 + 4]; + const T c2 = to + p_values[idx * 3 + 3]; return interp.bezier(from, c1, c2, to, c); @@ -1952,12 +2681,13 @@ T EditorSceneImporterGLTF::_interpolate_track(const Vector<float> &p_times, cons ERR_FAIL_V(p_values[0]); } -void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlayer *ap, int index, int bake_fps, Vector<Skeleton *> skeletons) { +void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlayer *ap, const GLTFAnimationIndex index, const int bake_fps) { const GLTFAnimation &anim = state.animations[index]; String name = anim.name; - if (name == "") { + if (name.empty()) { + // No node represent these, and they are not in the hierarchy, so just make a unique name name = _gen_unique_name(state, "Animation"); } @@ -1973,102 +2703,143 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye //need to find the path NodePath node_path; - GLTFNode *node = state.nodes[E->key()]; - for (int n = 0; n < node->godot_nodes.size(); n++) { + GLTFNodeIndex node_index = E->key(); + if (state.nodes[node_index]->fake_joint_parent >= 0) { + // Should be same as parent + node_index = state.nodes[node_index]->fake_joint_parent; + } - if (node->joints.size()) { - Skeleton *sk = (Skeleton *)node->godot_nodes[n]; - String path = ap->get_parent()->get_path_to(sk); - String bone = sk->get_bone_name(node->joints[n].godot_bone_index); - node_path = path + ":" + bone; - } else { - node_path = ap->get_parent()->get_path_to(node->godot_nodes[n]); - } + const GLTFNode *node = state.nodes[E->key()]; - for (int i = 0; i < track.rotation_track.times.size(); i++) { - length = MAX(length, track.rotation_track.times[i]); - } - for (int i = 0; i < track.translation_track.times.size(); i++) { - length = MAX(length, track.translation_track.times[i]); + if (node->skeleton >= 0) { + const Skeleton *sk = Object::cast_to<Skeleton>(state.scene_nodes.find(node_index)->get()); + ERR_FAIL_COND(sk == nullptr); + + const String path = ap->get_parent()->get_path_to(sk); + const String bone = node->name; + node_path = path + ":" + bone; + } else { + node_path = ap->get_parent()->get_path_to(state.scene_nodes.find(node_index)->get()); + } + + for (int i = 0; i < track.rotation_track.times.size(); i++) { + length = MAX(length, track.rotation_track.times[i]); + } + for (int i = 0; i < track.translation_track.times.size(); i++) { + length = MAX(length, track.translation_track.times[i]); + } + for (int i = 0; i < track.scale_track.times.size(); i++) { + length = MAX(length, track.scale_track.times[i]); + } + + for (int i = 0; i < track.weight_tracks.size(); i++) { + for (int j = 0; j < track.weight_tracks[i].times.size(); j++) { + length = MAX(length, track.weight_tracks[i].times[j]); } - for (int i = 0; i < track.scale_track.times.size(); i++) { - length = MAX(length, track.scale_track.times[i]); + } + + if (track.rotation_track.values.size() || track.translation_track.values.size() || track.scale_track.values.size()) { + //make transform track + int track_idx = animation->get_track_count(); + animation->add_track(Animation::TYPE_TRANSFORM); + animation->track_set_path(track_idx, node_path); + //first determine animation length + + const float increment = 1.0 / float(bake_fps); + float time = 0.0; + + Vector3 base_pos; + Quat base_rot; + Vector3 base_scale = Vector3(1, 1, 1); + + if (!track.rotation_track.values.size()) { + base_rot = state.nodes[E->key()]->rotation.normalized(); } - for (int i = 0; i < track.weight_tracks.size(); i++) { - for (int j = 0; j < track.weight_tracks[i].times.size(); j++) { - length = MAX(length, track.weight_tracks[i].times[j]); - } + if (!track.translation_track.values.size()) { + base_pos = state.nodes[E->key()]->translation; } - if (track.rotation_track.values.size() || track.translation_track.values.size() || track.scale_track.values.size()) { - //make transform track - int track_idx = animation->get_track_count(); - animation->add_track(Animation::TYPE_TRANSFORM); - animation->track_set_path(track_idx, node_path); - //first determine animation length + if (!track.scale_track.values.size()) { + base_scale = state.nodes[E->key()]->scale; + } - float increment = 1.0 / float(bake_fps); - float time = 0.0; + bool last = false; + while (true) { - Vector3 base_pos; - Quat base_rot; - Vector3 base_scale = Vector3(1, 1, 1); + Vector3 pos = base_pos; + Quat rot = base_rot; + Vector3 scale = base_scale; - if (!track.rotation_track.values.size()) { - base_rot = state.nodes[E->key()]->rotation.normalized(); + if (track.translation_track.times.size()) { + pos = _interpolate_track<Vector3>(track.translation_track.times, track.translation_track.values, time, track.translation_track.interpolation); } - if (!track.translation_track.values.size()) { - base_pos = state.nodes[E->key()]->translation; + if (track.rotation_track.times.size()) { + rot = _interpolate_track<Quat>(track.rotation_track.times, track.rotation_track.values, time, track.rotation_track.interpolation); } - if (!track.scale_track.values.size()) { - base_scale = state.nodes[E->key()]->scale; + if (track.scale_track.times.size()) { + scale = _interpolate_track<Vector3>(track.scale_track.times, track.scale_track.values, time, track.scale_track.interpolation); } - bool last = false; - while (true) { - - Vector3 pos = base_pos; - Quat rot = base_rot; - Vector3 scale = base_scale; - - if (track.translation_track.times.size()) { + if (node->skeleton >= 0) { - pos = _interpolate_track<Vector3>(track.translation_track.times, track.translation_track.values, time, track.translation_track.interpolation); - } - - if (track.rotation_track.times.size()) { - - rot = _interpolate_track<Quat>(track.rotation_track.times, track.rotation_track.values, time, track.rotation_track.interpolation); - } + Transform xform; + xform.basis.set_quat_scale(rot, scale); + xform.origin = pos; - if (track.scale_track.times.size()) { + const Skeleton *skeleton = state.skeletons[node->skeleton].godot_skeleton; + const int bone_idx = skeleton->find_bone(node->name); + xform = skeleton->get_bone_rest(bone_idx).affine_inverse() * xform; - scale = _interpolate_track<Vector3>(track.scale_track.times, track.scale_track.values, time, track.scale_track.interpolation); - } + rot = xform.basis.get_rotation_quat(); + rot.normalize(); + scale = xform.basis.get_scale(); + pos = xform.origin; + } - if (node->joints.size()) { + animation->transform_track_insert_key(track_idx, time, pos, rot, scale); - Transform xform; - //xform.basis = Basis(rot); - //xform.basis.scale(scale); - xform.basis.set_quat_scale(rot, scale); - xform.origin = pos; + if (last) { + break; + } + time += increment; + if (time >= length) { + last = true; + time = length; + } + } + } - Skeleton *skeleton = skeletons[node->joints[n].skin]; - int bone = node->joints[n].godot_bone_index; - xform = skeleton->get_bone_rest(bone).affine_inverse() * xform; + for (int i = 0; i < track.weight_tracks.size(); i++) { + ERR_CONTINUE(node->mesh < 0 || node->mesh >= state.meshes.size()); + const GLTFMesh &mesh = state.meshes[node->mesh]; + const String prop = "blend_shapes/" + mesh.mesh->get_blend_shape_name(i); - rot = xform.basis.get_rotation_quat(); - rot.normalize(); - scale = xform.basis.get_scale(); - pos = xform.origin; - } + const String blend_path = String(node_path) + ":" + prop; - animation->transform_track_insert_key(track_idx, time, pos, rot, scale); + const int track_idx = animation->get_track_count(); + animation->add_track(Animation::TYPE_VALUE); + animation->track_set_path(track_idx, blend_path); + // Only LINEAR and STEP (NEAREST) can be supported out of the box by Godot's Animation, + // the other modes have to be baked. + GLTFAnimation::Interpolation gltf_interp = track.weight_tracks[i].interpolation; + if (gltf_interp == GLTFAnimation::INTERP_LINEAR || gltf_interp == GLTFAnimation::INTERP_STEP) { + animation->track_set_interpolation_type(track_idx, gltf_interp == GLTFAnimation::INTERP_STEP ? Animation::INTERPOLATION_NEAREST : Animation::INTERPOLATION_LINEAR); + for (int j = 0; j < track.weight_tracks[i].times.size(); j++) { + const float t = track.weight_tracks[i].times[j]; + const float w = track.weight_tracks[i].values[j]; + animation->track_insert_key(track_idx, t, w); + } + } else { + // CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies. + const float increment = 1.0 / float(bake_fps); + float time = 0.0; + bool last = false; + while (true) { + _interpolate_track<float>(track.weight_tracks[i].times, track.weight_tracks[i].values, time, gltf_interp); if (last) { break; } @@ -2079,86 +2850,54 @@ void EditorSceneImporterGLTF::_import_animation(GLTFState &state, AnimationPlaye } } } - - for (int i = 0; i < track.weight_tracks.size(); i++) { - ERR_CONTINUE(node->mesh < 0 || node->mesh >= state.meshes.size()); - const GLTFMesh &mesh = state.meshes[node->mesh]; - String prop = "blend_shapes/" + mesh.mesh->get_blend_shape_name(i); - node_path = String(node_path) + ":" + prop; - - int track_idx = animation->get_track_count(); - animation->add_track(Animation::TYPE_VALUE); - animation->track_set_path(track_idx, node_path); - - // Only LINEAR and STEP (NEAREST) can be supported out of the box by Godot's Animation, - // the other modes have to be baked. - GLTFAnimation::Interpolation gltf_interp = track.weight_tracks[i].interpolation; - if (gltf_interp == GLTFAnimation::INTERP_LINEAR || gltf_interp == GLTFAnimation::INTERP_STEP) { - animation->track_set_interpolation_type(track_idx, gltf_interp == GLTFAnimation::INTERP_STEP ? Animation::INTERPOLATION_NEAREST : Animation::INTERPOLATION_LINEAR); - for (int j = 0; j < track.weight_tracks[i].times.size(); j++) { - float t = track.weight_tracks[i].times[j]; - float w = track.weight_tracks[i].values[j]; - animation->track_insert_key(track_idx, t, w); - } - } else { - // CATMULLROMSPLINE or CUBIC_SPLINE have to be baked, apologies. - float increment = 1.0 / float(bake_fps); - float time = 0.0; - bool last = false; - while (true) { - _interpolate_track<float>(track.weight_tracks[i].times, track.weight_tracks[i].values, time, gltf_interp); - if (last) { - break; - } - time += increment; - if (time >= length) { - last = true; - time = length; - } - } - } - } } } + animation->set_length(length); ap->add_animation(name, animation); } -Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, int p_bake_fps) { +void EditorSceneImporterGLTF::_process_mesh_instances(GLTFState &state, Spatial *scene_root) { + for (GLTFNodeIndex node_i = 0; node_i < state.nodes.size(); ++node_i) { + const GLTFNode *node = state.nodes[node_i]; - Spatial *root = memnew(Spatial); - root->set_name(state.scene_name); - //generate skeletons - Vector<Skeleton *> skeletons; - for (int i = 0; i < state.skins.size(); i++) { - Skeleton *s = memnew(Skeleton); - s->set_use_bones_in_world_transform(false); //GLTF does not need this since meshes are always local - String name = state.skins[i].name; - if (name == "") { - name = _gen_unique_name(state, "Skeleton"); - } - for (int j = 0; j < state.skins[i].bones.size(); j++) { - s->add_bone(state.nodes[state.skins[i].bones[j].node]->name); - s->set_bone_rest(j, state.skins[i].bones[j].inverse_bind.affine_inverse()); - } - s->set_name(name); - root->add_child(s); - s->set_owner(root); - skeletons.push_back(s); - } - for (int i = 0; i < state.root_nodes.size(); i++) { - if (state.nodes[state.root_nodes[i]]->joints.size()) { - _generate_bone(state, state.root_nodes[i], skeletons, root); - } else { - _generate_node(state, state.root_nodes[i], root, root, skeletons); + if (node->skin >= 0 && node->mesh >= 0) { + const GLTFSkinIndex skin_i = node->skin; + + Map<GLTFNodeIndex, Node *>::Element *mi_element = state.scene_nodes.find(node_i); + MeshInstance *mi = Object::cast_to<MeshInstance>(mi_element->get()); + ERR_FAIL_COND(mi == nullptr); + + const GLTFSkeletonIndex skel_i = state.skins[node->skin].skeleton; + const GLTFSkeleton &gltf_skeleton = state.skeletons[skel_i]; + Skeleton *skeleton = gltf_skeleton.godot_skeleton; + ERR_FAIL_COND(skeleton == nullptr); + + mi->get_parent()->remove_child(mi); + skeleton->add_child(mi); + mi->set_owner(scene_root); + + mi->set_skin(state.skins[skin_i].godot_skin); + mi->set_skeleton_path(mi->get_path_to(skeleton)); + mi->set_transform(Transform()); } } +} - for (int i = 0; i < skeletons.size(); i++) { - skeletons[i]->localize_rests(); +Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, const int p_bake_fps) { + + Spatial *root = memnew(Spatial); + + // scene_name is already unique + root->set_name(state.scene_name); + + for (int i = 0; i < state.root_nodes.size(); ++i) { + _generate_scene_node(state, root, root, state.root_nodes[i]); } + _process_mesh_instances(state, root); + if (state.animations.size()) { AnimationPlayer *ap = memnew(AnimationPlayer); ap->set_name("AnimationPlayer"); @@ -2166,7 +2905,7 @@ Spatial *EditorSceneImporterGLTF::_generate_scene(GLTFState &state, int p_bake_f ap->set_owner(root); for (int i = 0; i < state.animations.size(); i++) { - _import_animation(state, ap, i, p_bake_fps, skeletons); + _import_animation(state, ap, i, p_bake_fps); } } @@ -2241,30 +2980,45 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla if (err != OK) return NULL; - /* STEP 8 PARSE MESHES (we have enough info now) */ - err = _parse_meshes(state); + /* STEP 9 PARSE SKINS */ + err = _parse_skins(state); if (err != OK) return NULL; - /* STEP 9 PARSE SKINS */ - err = _parse_skins(state); + /* STEP 10 DETERMINE SKELETONS */ + err = _determine_skeletons(state); + if (err != OK) + return NULL; + + /* STEP 11 CREATE SKELETONS */ + err = _create_skeletons(state); + if (err != OK) + return NULL; + + /* STEP 12 CREATE SKINS */ + err = _create_skins(state); + if (err != OK) + return NULL; + + /* STEP 13 PARSE MESHES (we have enough info now) */ + err = _parse_meshes(state); if (err != OK) return NULL; - /* STEP 10 PARSE CAMERAS */ + /* STEP 14 PARSE CAMERAS */ err = _parse_cameras(state); if (err != OK) return NULL; - /* STEP 11 PARSE ANIMATIONS */ + /* STEP 15 PARSE ANIMATIONS */ err = _parse_animations(state); if (err != OK) return NULL; - /* STEP 12 ASSIGN SCENE NAMES */ + /* STEP 16 ASSIGN SCENE NAMES */ _assign_scene_names(state); - /* STEP 13 MAKE SCENE! */ + /* STEP 17 MAKE SCENE! */ Spatial *scene = _generate_scene(state, p_bake_fps); return scene; diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index ebf20e122a..6021bf10c8 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -36,11 +36,26 @@ #include "scene/3d/spatial.h" class AnimationPlayer; +class BoneAttachment; +class MeshInstance; class EditorSceneImporterGLTF : public EditorSceneImporter { GDCLASS(EditorSceneImporterGLTF, EditorSceneImporter); + typedef int GLTFAccessorIndex; + typedef int GLTFAnimationIndex; + typedef int GLTFBufferIndex; + typedef int GLTFBufferViewIndex; + typedef int GLTFCameraIndex; + typedef int GLTFImageIndex; + typedef int GLTFMaterialIndex; + typedef int GLTFMeshIndex; + typedef int GLTFNodeIndex; + typedef int GLTFSkeletonIndex; + typedef int GLTFSkinIndex; + typedef int GLTFTextureIndex; + enum { ARRAY_BUFFER = 34962, ELEMENT_ARRAY_BUFFER = 34963, @@ -61,8 +76,8 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { }; - String _get_component_type_name(uint32_t p_component); - int _get_component_type_size(int component_type); + String _get_component_type_name(const uint32_t p_component); + int _get_component_type_size(const int component_type); enum GLTFType { TYPE_SCALAR, @@ -74,60 +89,48 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { TYPE_MAT4, }; - String _get_type_name(GLTFType p_component); + String _get_type_name(const GLTFType p_component); struct GLTFNode { + //matrices need to be transformed to this - int parent; + GLTFNodeIndex parent; + int height; Transform xform; String name; - //Node *godot_node; - //int godot_bone_index; - - int mesh; - int camera; - int skin; - //int skeleton_skin; - //int child_of_skeleton; // put as children of skeleton - //Vector<int> skeleton_children; //skeleton put as children of this - - struct Joint { - int skin; - int bone; - int godot_bone_index; - - Joint() { - skin = -1; - bone = -1; - godot_bone_index = -1; - } - }; - Vector<Joint> joints; + GLTFMeshIndex mesh; + GLTFCameraIndex camera; + GLTFSkinIndex skin; + + GLTFSkeletonIndex skeleton; + bool joint; - //keep them for animation Vector3 translation; Quat rotation; Vector3 scale; Vector<int> children; - Vector<Node *> godot_nodes; + + GLTFNodeIndex fake_joint_parent; GLTFNode() : parent(-1), + height(-1), mesh(-1), camera(-1), skin(-1), - //skeleton_skin(-1), - //child_of_skeleton(-1), - scale(Vector3(1, 1, 1)) { - } + skeleton(-1), + joint(false), + translation(0, 0, 0), + scale(Vector3(1, 1, 1)), + fake_joint_parent(-1) {} }; struct GLTFBufferView { - int buffer; + GLTFBufferIndex buffer; int byte_offset; int byte_length; int byte_stride; @@ -135,7 +138,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { //matrices need to be transformed to this GLTFBufferView() : - buffer(0), + buffer(-1), byte_offset(0), byte_length(0), byte_stride(0), @@ -145,7 +148,7 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { struct GLTFAccessor { - int buffer_view; + GLTFBufferViewIndex buffer_view; int byte_offset; int component_type; bool normalized; @@ -160,8 +163,6 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { int sparse_values_buffer_view; int sparse_values_byte_offset; - //matrices need to be transformed to this - GLTFAccessor() { buffer_view = 0; byte_offset = 0; @@ -176,27 +177,67 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { } }; struct GLTFTexture { - int src_image; + GLTFImageIndex src_image; }; - struct GLTFSkin { + struct GLTFSkeleton { + // The *synthesized* skeletons joints + Vector<GLTFNodeIndex> joints; - String name; - struct Bone { - Transform inverse_bind; - int node; - }; + // The roots of the skeleton. If there are multiple, each root must have the same parent + // (ie roots are siblings) + Vector<GLTFNodeIndex> roots; - int skeleton; - Vector<Bone> bones; + // The created Skeleton for the scene + Skeleton *godot_skeleton; - //matrices need to be transformed to this + // Set of unique bone names for the skeleton + Set<String> unique_names; - GLTFSkin() { - skeleton = -1; + GLTFSkeleton() : + godot_skeleton(nullptr) { } }; + struct GLTFSkin { + String name; + + // The "skeleton" property defined in the gltf spec. -1 = Scene Root + GLTFNodeIndex skin_root; + + Vector<GLTFNodeIndex> joints_original; + Vector<Transform> inverse_binds; + + // Note: joints + non_joints should form a complete subtree, or subtrees with a common parent + + // All nodes that are skins that are caught in-between the original joints + // (inclusive of joints_original) + Vector<GLTFNodeIndex> joints; + + // All Nodes that are caught in-between skin joint nodes, and are not defined + // as joints by any skin + Vector<GLTFNodeIndex> non_joints; + + // The roots of the skin. In the case of multiple roots, their parent *must* + // be the same (the roots must be siblings) + Vector<GLTFNodeIndex> roots; + + // The GLTF Skeleton this Skin points to (after we determine skeletons) + GLTFSkeletonIndex skeleton; + + // A mapping from the joint indices (in the order of joints_original) to the + // Godot Skeleton's bone_indices + Map<int, int> joint_i_to_bone_i; + + // The Actual Skin that will be created as a mapping between the IBM's of this skin + // to the generated skeleton for the mesh instances. + Ref<Skin> godot_skin; + + GLTFSkin() : + skin_root(-1), + skeleton(-1) {} + }; + struct GLTFMesh { Ref<ArrayMesh> mesh; Vector<float> blend_weights; @@ -272,11 +313,10 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { Set<String> unique_names; + Vector<GLTFSkeleton> skeletons; Vector<GLTFAnimation> animations; - Map<int, Vector<int> > skeleton_nodes; - - //Map<int, Vector<int> > skin_users; //cache skin users + Map<GLTFNodeIndex, Node *> scene_nodes; ~GLTFState() { for (int i = 0; i < nodes.size(); i++) { @@ -285,37 +325,38 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { } }; + String _sanitize_scene_name(const String &name); String _gen_unique_name(GLTFState &state, const String &p_name); - Ref<Texture> _get_texture(GLTFState &state, int p_texture); + String _sanitize_bone_name(const String &name); + String _gen_unique_bone_name(GLTFState &state, const GLTFSkeletonIndex skel_i, const String &p_name); + + Ref<Texture> _get_texture(GLTFState &state, const GLTFTextureIndex p_texture); Error _parse_json(const String &p_path, GLTFState &state); Error _parse_glb(const String &p_path, GLTFState &state); Error _parse_scenes(GLTFState &state); Error _parse_nodes(GLTFState &state); + + void _compute_node_heights(GLTFState &state); + Error _parse_buffers(GLTFState &state, const String &p_base_path); Error _parse_buffer_views(GLTFState &state); GLTFType _get_type_from_str(const String &p_string); Error _parse_accessors(GLTFState &state); - Error _decode_buffer_view(GLTFState &state, int p_buffer_view, double *dst, int skip_every, int skip_bytes, int element_size, int count, GLTFType type, int component_count, int component_type, int component_size, bool normalized, int byte_offset, bool for_vertex); - Vector<double> _decode_accessor(GLTFState &state, int p_accessor, bool p_for_vertex); - PoolVector<float> _decode_accessor_as_floats(GLTFState &state, int p_accessor, bool p_for_vertex); - PoolVector<int> _decode_accessor_as_ints(GLTFState &state, int p_accessor, bool p_for_vertex); - PoolVector<Vector2> _decode_accessor_as_vec2(GLTFState &state, int p_accessor, bool p_for_vertex); - PoolVector<Vector3> _decode_accessor_as_vec3(GLTFState &state, int p_accessor, bool p_for_vertex); - PoolVector<Color> _decode_accessor_as_color(GLTFState &state, int p_accessor, bool p_for_vertex); - Vector<Quat> _decode_accessor_as_quat(GLTFState &state, int p_accessor, bool p_for_vertex); - Vector<Transform2D> _decode_accessor_as_xform2d(GLTFState &state, int p_accessor, bool p_for_vertex); - Vector<Basis> _decode_accessor_as_basis(GLTFState &state, int p_accessor, bool p_for_vertex); - Vector<Transform> _decode_accessor_as_xform(GLTFState &state, int p_accessor, bool p_for_vertex); - - void _reparent_skeleton(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, Node *p_parent_node); - void _generate_bone(GLTFState &state, int p_node, Vector<Skeleton *> &skeletons, Node *p_parent_node); - void _generate_node(GLTFState &state, int p_node, Node *p_parent, Node *p_owner, Vector<Skeleton *> &skeletons); - void _import_animation(GLTFState &state, AnimationPlayer *ap, int index, int bake_fps, Vector<Skeleton *> skeletons); - - Spatial *_generate_scene(GLTFState &state, int p_bake_fps); + Error _decode_buffer_view(GLTFState &state, double *dst, const GLTFBufferViewIndex p_buffer_view, const int skip_every, const int skip_bytes, const int element_size, const int count, const GLTFType type, const int component_count, const int component_type, const int component_size, const bool normalized, const int byte_offset, const bool for_vertex); + + Vector<double> _decode_accessor(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex); + PoolVector<float> _decode_accessor_as_floats(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex); + PoolVector<int> _decode_accessor_as_ints(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex); + PoolVector<Vector2> _decode_accessor_as_vec2(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex); + PoolVector<Vector3> _decode_accessor_as_vec3(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex); + PoolVector<Color> _decode_accessor_as_color(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex); + Vector<Quat> _decode_accessor_as_quat(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex); + Vector<Transform2D> _decode_accessor_as_xform2d(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex); + Vector<Basis> _decode_accessor_as_basis(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex); + Vector<Transform> _decode_accessor_as_xform(GLTFState &state, const GLTFAccessorIndex p_accessor, const bool p_for_vertex); Error _parse_meshes(GLTFState &state); Error _parse_images(GLTFState &state, const String &p_base_path); @@ -323,16 +364,46 @@ class EditorSceneImporterGLTF : public EditorSceneImporter { Error _parse_materials(GLTFState &state); + GLTFNodeIndex _find_highest_node(GLTFState &state, const Vector<GLTFNodeIndex> &subset); + + bool _capture_nodes_in_skin(GLTFState &state, GLTFSkin &skin, const GLTFNodeIndex node_index); + void _capture_nodes_for_multirooted_skin(GLTFState &state, GLTFSkin &skin); + Error _expand_skin(GLTFState &state, GLTFSkin &skin); + Error _verify_skin(GLTFState &state, GLTFSkin &skin); Error _parse_skins(GLTFState &state); + Error _determine_skeletons(GLTFState &state); + Error _reparent_non_joint_skeleton_subtrees(GLTFState &state, GLTFSkeleton &skeleton, const Vector<GLTFNodeIndex> &non_joints); + Error _reparent_to_fake_joint(GLTFState &state, GLTFSkeleton &skeleton, const GLTFNodeIndex node_index); + Error _determine_skeleton_roots(GLTFState &state, const GLTFSkeletonIndex skel_i); + + Error _create_skeletons(GLTFState &state); + Error _map_skin_joints_indices_to_skeleton_bone_indices(GLTFState &state); + + Error _create_skins(GLTFState &state); + bool _skins_are_same(const Ref<Skin> &skin_a, const Ref<Skin> &skin_b); + void _remove_duplicate_skins(GLTFState &state); + Error _parse_cameras(GLTFState &state); Error _parse_animations(GLTFState &state); + BoneAttachment *_generate_bone_attachment(GLTFState &state, Skeleton *skeleton, const GLTFNodeIndex node_index); + MeshInstance *_generate_mesh_instance(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); + Camera *_generate_camera(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); + Spatial *_generate_spatial(GLTFState &state, Node *scene_parent, const GLTFNodeIndex node_index); + + void _generate_scene_node(GLTFState &state, Node *scene_parent, Spatial *scene_root, const GLTFNodeIndex node_index); + Spatial *_generate_scene(GLTFState &state, const int p_bake_fps); + + void _process_mesh_instances(GLTFState &state, Spatial *scene_root); + void _assign_scene_names(GLTFState &state); template <class T> - T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, float p_time, GLTFAnimation::Interpolation p_interp); + T _interpolate_track(const Vector<float> &p_times, const Vector<T> &p_values, const float p_time, const GLTFAnimation::Interpolation p_interp); + + void _import_animation(GLTFState &state, AnimationPlayer *ap, const GLTFAnimationIndex index, const int bake_fps); public: virtual uint32_t get_import_flags() const; diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 64994e21b0..b111750992 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -1178,7 +1178,7 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/import", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/fps", PROPERTY_HINT_RANGE, "1,120,1"), 15)); r_options->push_back(ImportOption(PropertyInfo(Variant::STRING, "animation/filter_script", PROPERTY_HINT_MULTILINE_TEXT), "")); - r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "animation/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.anim),Files (.tres)"), animations_out ? true : false)); + r_options->push_back(ImportOption(PropertyInfo(Variant::INT, "animation/storage", PROPERTY_HINT_ENUM, "Built-In,Files (.anim),Files (.tres)"), animations_out)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/keep_custom_tracks"), animations_out)); r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/optimizer/enabled", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), true)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/optimizer/max_linear_error"), 0.05)); diff --git a/editor/inspector_dock.cpp b/editor/inspector_dock.cpp index 8ba7d9fba7..02b0159241 100644 --- a/editor/inspector_dock.cpp +++ b/editor/inspector_dock.cpp @@ -253,13 +253,11 @@ void InspectorDock::_prepare_history() { text = obj->get_class(); } - if (i == editor_history->get_history_pos()) { + if (i == editor_history->get_history_pos() && current) { text = "[" + text + "]"; } history_menu->get_popup()->add_icon_item(icon, text, i); } - - editor_path->update_path(); } void InspectorDock::_select_history(int p_idx) const { @@ -296,7 +294,7 @@ void InspectorDock::_edit_forward() { } void InspectorDock::_edit_back() { EditorHistory *editor_history = EditorNode::get_singleton()->get_editor_history(); - if (editor_history->previous() || editor_history->get_path_size() == 1) + if ((current && editor_history->previous()) || editor_history->get_path_size() == 1) editor->edit_current(); } @@ -408,6 +406,7 @@ void InspectorDock::update(Object *p_object) { warning->hide(); search->set_editable(false); + editor_path->set_disabled(true); editor_path->set_text(""); editor_path->set_tooltip(""); editor_path->set_icon(NULL); @@ -420,6 +419,7 @@ void InspectorDock::update(Object *p_object) { object_menu->set_disabled(false); search->set_editable(true); + editor_path->set_disabled(false); resource_save_button->set_disabled(!is_resource); PopupMenu *p = object_menu->get_popup(); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index 6f612b5c79..625ca5e603 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -1967,6 +1967,11 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { if (key_auto_insert_button->is_pressed()) { _insert_animation_keys(true, false, false, true); } + + //Make sure smart snapping lines disappear. + snap_target[0] = SNAP_TARGET_NONE; + snap_target[1] = SNAP_TARGET_NONE; + drag_type = DRAG_NONE; viewport->update(); return true; @@ -1975,6 +1980,8 @@ bool CanvasItemEditor::_gui_input_move(const Ref<InputEvent> &p_event) { // Cancel a drag if (b.is_valid() && b->get_button_index() == BUTTON_RIGHT && b->is_pressed()) { _restore_canvas_item_state(drag_selection, true); + snap_target[0] = SNAP_TARGET_NONE; + snap_target[1] = SNAP_TARGET_NONE; drag_type = DRAG_NONE; viewport->update(); return true; @@ -5044,6 +5051,8 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) { snap_rotation = false; snap_relative = false; snap_pixel = false; + snap_target[0] = SNAP_TARGET_NONE; + snap_target[1] = SNAP_TARGET_NONE; anchors_mode = false; diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index f79c9d5062..4c22138a20 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -3308,8 +3308,8 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { debug_menu->set_text(TTR("Debug")); debug_menu->set_switch_on_hover(true); debug_menu->get_popup()->set_hide_on_window_lose_focus(true); - debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/step_over", TTR("Step Over"), KEY_F10), DEBUG_NEXT); debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/step_into", TTR("Step Into"), KEY_F11), DEBUG_STEP); + debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/step_over", TTR("Step Over"), KEY_F10), DEBUG_NEXT); debug_menu->get_popup()->add_separator(); debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/break", TTR("Break")), DEBUG_BREAK); debug_menu->get_popup()->add_shortcut(ED_SHORTCUT("debugger/continue", TTR("Continue"), KEY_F12), DEBUG_CONTINUE); diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 3b300a7ad5..073e6f74e9 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -1532,93 +1532,98 @@ void ScriptTextEditor::drop_data_fw(const Point2 &p_point, const Variant &p_data void ScriptTextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { Ref<InputEventMouseButton> mb = ev; + Ref<InputEventKey> k = ev; + Point2 local_pos; + bool create_menu = false; - if (mb.is_valid()) { - - if (mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) { - int col, row; - TextEdit *tx = code_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(); - - tx->set_right_click_moves_caret(EditorSettings::get_singleton()->get("text_editor/cursor/right_click_moves_caret")); - if (tx->is_right_click_moving_caret()) { - if (tx->is_selection_active()) { + TextEdit *tx = code_editor->get_text_edit(); + if (mb.is_valid() && mb->get_button_index() == BUTTON_RIGHT && mb->is_pressed()) { + local_pos = mb->get_global_position() - tx->get_global_position(); + create_menu = true; + } else if (k.is_valid() && k->get_scancode() == KEY_MENU) { + local_pos = tx->_get_cursor_pixel_pos(); + create_menu = true; + } - int from_line = tx->get_selection_from_line(); - int to_line = tx->get_selection_to_line(); - int from_column = tx->get_selection_from_column(); - int to_column = tx->get_selection_to_column(); + if (create_menu) { + int col, row; + tx->_get_mouse_pos(local_pos, row, col); - if (row < from_line || row > to_line || (row == from_line && col < from_column) || (row == to_line && col > to_column)) { - // Right click is outside the selected text - tx->deselect(); - } - } - if (!tx->is_selection_active()) { - tx->cursor_set_line(row, true, false); - tx->cursor_set_column(col); + tx->set_right_click_moves_caret(EditorSettings::get_singleton()->get("text_editor/cursor/right_click_moves_caret")); + if (tx->is_right_click_moving_caret()) { + if (tx->is_selection_active()) { + int from_line = tx->get_selection_from_line(); + int to_line = tx->get_selection_to_line(); + int from_column = tx->get_selection_from_column(); + int to_column = tx->get_selection_to_column(); + + if (row < from_line || row > to_line || (row == from_line && col < from_column) || (row == to_line && col > to_column)) { + // Right click is outside the selected text + tx->deselect(); } } + if (!tx->is_selection_active()) { + tx->cursor_set_line(row, true, false); + tx->cursor_set_column(col); + } + } - String word_at_mouse = tx->get_word_at_pos(mpos); - if (word_at_mouse == "") - word_at_mouse = tx->get_word_under_cursor(); - if (word_at_mouse == "") - word_at_mouse = tx->get_selection_text(); + String word_at_pos = tx->get_word_at_pos(local_pos); + if (word_at_pos == "") + word_at_pos = tx->get_word_under_cursor(); + if (word_at_pos == "") + word_at_pos = tx->get_selection_text(); - bool has_color = (word_at_mouse == "Color"); - bool foldable = tx->can_fold(row) || tx->is_folded(row); - bool open_docs = false; - bool goto_definition = false; + bool has_color = (word_at_pos == "Color"); + bool foldable = tx->can_fold(row) || tx->is_folded(row); + bool open_docs = false; + bool goto_definition = false; - if (word_at_mouse.is_resource_file()) { + if (word_at_pos.is_resource_file()) { + open_docs = true; + } else { + Node *base = get_tree()->get_edited_scene_root(); + if (base) { + base = _find_node_for_script(base, base, script); + } + ScriptLanguage::LookupResult result; + if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), word_at_pos, script->get_path(), base, result) == OK) { open_docs = true; - } else { - - Node *base = get_tree()->get_edited_scene_root(); - if (base) { - base = _find_node_for_script(base, base, script); - } - ScriptLanguage::LookupResult result; - if (script->get_language()->lookup_code(code_editor->get_text_edit()->get_text_for_lookup_completion(), word_at_mouse, script->get_path(), base, result) == OK) { - open_docs = true; - } } + } - if (has_color) { - String line = tx->get_line(row); - color_position.x = row; - color_position.y = col; - - int begin = 0; - int end = 0; - bool valid = false; - for (int i = col; i < line.length(); i++) { - if (line[i] == '(') { - begin = i; - continue; - } else if (line[i] == ')') { - end = i + 1; - valid = true; - break; - } + if (has_color) { + String line = tx->get_line(row); + color_position.x = row; + color_position.y = col; + + int begin = 0; + int end = 0; + bool valid = false; + for (int i = col; i < line.length(); i++) { + if (line[i] == '(') { + begin = i; + continue; + } else if (line[i] == ')') { + end = i + 1; + valid = true; + break; } - if (valid) { - color_args = line.substr(begin, end - begin); - String stripped = color_args.replace(" ", "").replace("(", "").replace(")", ""); - Vector<float> color = stripped.split_floats(","); - if (color.size() > 2) { - float alpha = color.size() > 3 ? color[3] : 1.0f; - color_picker->set_pick_color(Color(color[0], color[1], color[2], alpha)); - } - color_panel->set_position(get_global_transform().xform(get_local_mouse_position())); - } else { - has_color = false; + } + if (valid) { + color_args = line.substr(begin, end - begin); + String stripped = color_args.replace(" ", "").replace("(", "").replace(")", ""); + Vector<float> color = stripped.split_floats(","); + if (color.size() > 2) { + float alpha = color.size() > 3 ? color[3] : 1.0f; + color_picker->set_pick_color(Color(color[0], color[1], color[2], alpha)); } + color_panel->set_position(get_global_transform().xform(local_pos)); + } else { + has_color = false; } - _make_context_menu(tx->is_selection_active(), has_color, foldable, open_docs, goto_definition); } + _make_context_menu(tx->is_selection_active(), has_color, foldable, open_docs, goto_definition, local_pos); } } @@ -1643,7 +1648,7 @@ void ScriptTextEditor::_color_changed(const Color &p_color) { code_editor->get_text_edit()->update(); } -void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition) { +void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition, Vector2 p_pos) { context_menu->clear(); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/undo"), EDIT_UNDO); @@ -1680,7 +1685,7 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p context_menu->add_item(TTR("Pick Color"), EDIT_PICK_COLOR); } - context_menu->set_position(get_global_transform().xform(get_local_mouse_position())); + context_menu->set_position(get_global_transform().xform(p_pos)); context_menu->set_size(Vector2(1, 1)); context_menu->popup(); } diff --git a/editor/plugins/script_text_editor.h b/editor/plugins/script_text_editor.h index 38c6da5c33..0ea8726ecc 100644 --- a/editor/plugins/script_text_editor.h +++ b/editor/plugins/script_text_editor.h @@ -169,7 +169,7 @@ protected: void _edit_option(int p_op); void _edit_option_toggle_inline_comment(); - void _make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition); + void _make_context_menu(bool p_selection, bool p_color, bool p_foldable, bool p_open_docs, bool p_goto_definition, Vector2 p_pos); 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 e81c97d5dd..df3e23a9e9 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -523,9 +523,16 @@ void ShaderEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { tx->cursor_set_column(col); } } - _make_context_menu(tx->is_selection_active()); + _make_context_menu(tx->is_selection_active(), get_local_mouse_position()); } } + + Ref<InputEventKey> k = ev; + if (k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_MENU) { + TextEdit *tx = shader_editor->get_text_edit(); + _make_context_menu(tx->is_selection_active(), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->_get_cursor_pixel_pos())); + context_menu->grab_focus(); + } } void ShaderEditor::_update_bookmark_list() { @@ -565,7 +572,7 @@ void ShaderEditor::_bookmark_item_pressed(int p_idx) { } } -void ShaderEditor::_make_context_menu(bool p_selection) { +void ShaderEditor::_make_context_menu(bool p_selection, Vector2 p_position) { context_menu->clear(); if (p_selection) { @@ -585,7 +592,7 @@ void ShaderEditor::_make_context_menu(bool p_selection) { context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_bookmark"), BOOKMARK_TOGGLE); - context_menu->set_position(get_global_transform().xform(get_local_mouse_position())); + context_menu->set_position(get_global_transform().xform(p_position)); context_menu->set_size(Vector2(1, 1)); context_menu->popup(); } diff --git a/editor/plugins/shader_editor_plugin.h b/editor/plugins/shader_editor_plugin.h index 8d3f4d4fe8..ca9f489713 100644 --- a/editor/plugins/shader_editor_plugin.h +++ b/editor/plugins/shader_editor_plugin.h @@ -122,7 +122,7 @@ class ShaderEditor : public PanelContainer { protected: void _notification(int p_what); static void _bind_methods(); - void _make_context_menu(bool p_selection); + void _make_context_menu(bool p_selection, Vector2 p_position); void _text_edit_gui_input(const Ref<InputEvent> &ev); void _update_bookmark_list(); diff --git a/editor/plugins/spatial_editor_plugin.cpp b/editor/plugins/spatial_editor_plugin.cpp index 18049e62b4..43d37a8edc 100644 --- a/editor/plugins/spatial_editor_plugin.cpp +++ b/editor/plugins/spatial_editor_plugin.cpp @@ -4061,7 +4061,10 @@ void _update_all_gizmos(Node *p_node) { } void SpatialEditor::update_all_gizmos(Node *p_node) { - if (!p_node) p_node = SceneTree::get_singleton()->get_root(); + if (!p_node) { + if (!SceneTree::get_singleton()) return; + p_node = SceneTree::get_singleton()->get_root(); + } _update_all_gizmos(p_node); } diff --git a/editor/plugins/spatial_editor_plugin.h b/editor/plugins/spatial_editor_plugin.h index 728b67f6fa..aa61f4bae1 100644 --- a/editor/plugins/spatial_editor_plugin.h +++ b/editor/plugins/spatial_editor_plugin.h @@ -58,6 +58,7 @@ public: RID instance; Ref<ArrayMesh> mesh; Ref<Material> material; + Ref<SkinReference> skin_reference; RID skeleton; bool billboard; bool unscaled; @@ -101,7 +102,7 @@ protected: public: 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(), const Ref<Material> &p_material = Ref<Material>()); + void add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard = false, const Ref<SkinReference> &p_skin_reference = Ref<SkinReference>(), const Ref<Material> &p_material = Ref<Material>()); void add_collision_segments(const Vector<Vector3> &p_lines); void add_collision_triangles(const Ref<TriangleMesh> &p_tmesh); void add_unscaled_billboard(const Ref<Material> &p_material, float p_scale = 1); diff --git a/editor/plugins/sprite_editor_plugin.cpp b/editor/plugins/sprite_editor_plugin.cpp index 2deb2090e2..69fd592652 100644 --- a/editor/plugins/sprite_editor_plugin.cpp +++ b/editor/plugins/sprite_editor_plugin.cpp @@ -102,7 +102,7 @@ Vector<Vector2> expand(const Vector<Vector2> &points, const Rect2i &rect, float int lasti = p2->Contour.size() - 1; Vector2 prev = Vector2(p2->Contour[lasti].X / PRECISION, p2->Contour[lasti].Y / PRECISION); - for (unsigned int i = 0; i < p2->Contour.size(); i++) { + for (uint64_t i = 0; i < p2->Contour.size(); i++) { Vector2 cur = Vector2(p2->Contour[i].X / PRECISION, p2->Contour[i].Y / PRECISION); if (cur.distance_to(prev) > 0.5) { diff --git a/editor/plugins/sprite_frames_editor_plugin.cpp b/editor/plugins/sprite_frames_editor_plugin.cpp index d91de6cbf6..394122d91d 100644 --- a/editor/plugins/sprite_frames_editor_plugin.cpp +++ b/editor/plugins/sprite_frames_editor_plugin.cpp @@ -464,9 +464,11 @@ void SpriteFramesEditor::_animation_select() { if (updating) return; - double value = anim_speed->get_line_edit()->get_text().to_double(); - if (!Math::is_equal_approx(value, frames->get_animation_speed(edited_anim))) - _animation_fps_changed(value); + if (frames->has_animation(edited_anim)) { + double value = anim_speed->get_line_edit()->get_text().to_double(); + if (!Math::is_equal_approx(value, frames->get_animation_speed(edited_anim))) + _animation_fps_changed(value); + } TreeItem *selected = animations->get_selected(); ERR_FAIL_COND(!selected); @@ -548,6 +550,7 @@ void SpriteFramesEditor::_animation_name_edited() { undo_redo->commit_action(); } + void SpriteFramesEditor::_animation_add() { String name = "New Anim"; @@ -578,13 +581,21 @@ void SpriteFramesEditor::_animation_add() { undo_redo->commit_action(); animations->grab_focus(); } + void SpriteFramesEditor::_animation_remove() { + if (updating) return; if (!frames->has_animation(edited_anim)) return; + delete_dialog->set_text(TTR("Delete Animation?")); + delete_dialog->popup_centered_minsize(); +} + +void SpriteFramesEditor::_animation_remove_confirmed() { + undo_redo->create_action(TTR("Remove Animation")); undo_redo->add_do_method(frames, "remove_animation", edited_anim); undo_redo->add_undo_method(frames, "add_animation", edited_anim); @@ -598,6 +609,8 @@ void SpriteFramesEditor::_animation_remove() { undo_redo->add_do_method(this, "_update_library"); undo_redo->add_undo_method(this, "_update_library"); + edited_anim = StringName(); + undo_redo->commit_action(); } @@ -743,7 +756,9 @@ Variant SpriteFramesEditor::get_drag_data_fw(const Point2 &p_point, Control *p_f if (frame.is_null()) return Variant(); - return EditorNode::get_singleton()->drag_resource(frame, p_from); + Dictionary drag_data = EditorNode::get_singleton()->drag_resource(frame, p_from); + drag_data["frame"] = idx; // store the frame, incase we want to reorder frames inside 'drop_data_fw' + return drag_data; } bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { @@ -753,8 +768,9 @@ bool SpriteFramesEditor::can_drop_data_fw(const Point2 &p_point, const Variant & if (!d.has("type")) return false; + // reordering frames if (d.has("from") && (Object *)(d["from"]) == tree) - return false; + return true; if (String(d["type"]) == "resource" && d.has("resource")) { RES r = d["resource"]; @@ -806,13 +822,31 @@ void SpriteFramesEditor::drop_data_fw(const Point2 &p_point, const Variant &p_da Ref<Texture> texture = r; if (texture.is_valid()) { - - undo_redo->create_action(TTR("Add Frame")); - undo_redo->add_do_method(frames, "add_frame", edited_anim, texture, at_pos == -1 ? -1 : at_pos); - undo_redo->add_undo_method(frames, "remove_frame", edited_anim, at_pos == -1 ? frames->get_frame_count(edited_anim) : at_pos); - undo_redo->add_do_method(this, "_update_library"); - undo_redo->add_undo_method(this, "_update_library"); - undo_redo->commit_action(); + bool reorder = false; + if (d.has("from") && (Object *)(d["from"]) == tree) + reorder = true; + + if (reorder) { //drop is from reordering frames + int from_frame = -1; + if (d.has("frame")) + from_frame = d["frame"]; + + undo_redo->create_action(TTR("Move Frame")); + undo_redo->add_do_method(frames, "remove_frame", edited_anim, from_frame == -1 ? frames->get_frame_count(edited_anim) : from_frame); + undo_redo->add_do_method(frames, "add_frame", edited_anim, texture, at_pos == -1 ? -1 : at_pos); + undo_redo->add_undo_method(frames, "remove_frame", edited_anim, at_pos == -1 ? frames->get_frame_count(edited_anim) - 1 : at_pos); + undo_redo->add_undo_method(frames, "add_frame", edited_anim, texture, from_frame); + undo_redo->add_do_method(this, "_update_library"); + undo_redo->add_undo_method(this, "_update_library"); + undo_redo->commit_action(); + } else { + undo_redo->create_action(TTR("Add Frame")); + undo_redo->add_do_method(frames, "add_frame", edited_anim, texture, at_pos == -1 ? -1 : at_pos); + undo_redo->add_undo_method(frames, "remove_frame", edited_anim, at_pos == -1 ? frames->get_frame_count(edited_anim) : at_pos); + undo_redo->add_do_method(this, "_update_library"); + undo_redo->add_undo_method(this, "_update_library"); + undo_redo->commit_action(); + } } } @@ -840,6 +874,7 @@ void SpriteFramesEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_animation_name_edited"), &SpriteFramesEditor::_animation_name_edited); ClassDB::bind_method(D_METHOD("_animation_add"), &SpriteFramesEditor::_animation_add); ClassDB::bind_method(D_METHOD("_animation_remove"), &SpriteFramesEditor::_animation_remove); + ClassDB::bind_method(D_METHOD("_animation_remove_confirmed"), &SpriteFramesEditor::_animation_remove_confirmed); ClassDB::bind_method(D_METHOD("_animation_loop_changed"), &SpriteFramesEditor::_animation_loop_changed); ClassDB::bind_method(D_METHOD("_animation_fps_changed"), &SpriteFramesEditor::_animation_fps_changed); ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &SpriteFramesEditor::get_drag_data_fw); @@ -870,7 +905,6 @@ SpriteFramesEditor::SpriteFramesEditor() { new_anim = memnew(ToolButton); new_anim->set_tooltip(TTR("New Animation")); hbc_animlist->add_child(new_anim); - new_anim->set_h_size_flags(SIZE_EXPAND_FILL); new_anim->connect("pressed", this, "_animation_add"); remove_anim = memnew(ToolButton); @@ -926,7 +960,7 @@ SpriteFramesEditor::SpriteFramesEditor() { paste->set_tooltip(TTR("Paste")); hbc->add_child(paste); - hbc->add_spacer(false); + hbc->add_child(memnew(VSeparator)); empty = memnew(ToolButton); empty->set_tooltip(TTR("Insert Empty (Before)")); @@ -987,6 +1021,10 @@ SpriteFramesEditor::SpriteFramesEditor() { edited_anim = "default"; + delete_dialog = memnew(ConfirmationDialog); + add_child(delete_dialog); + delete_dialog->connect("confirmed", this, "_animation_remove_confirmed"); + split_sheet_dialog = memnew(ConfirmationDialog); add_child(split_sheet_dialog); VBoxContainer *split_sheet_vb = memnew(VBoxContainer); diff --git a/editor/plugins/sprite_frames_editor_plugin.h b/editor/plugins/sprite_frames_editor_plugin.h index d64431cde7..f20b54f910 100644 --- a/editor/plugins/sprite_frames_editor_plugin.h +++ b/editor/plugins/sprite_frames_editor_plugin.h @@ -73,6 +73,8 @@ class SpriteFramesEditor : public HSplitContainer { StringName edited_anim; + ConfirmationDialog *delete_dialog; + ConfirmationDialog *split_sheet_dialog; ScrollContainer *splite_sheet_scroll; TextureRect *split_sheet_preview; @@ -98,6 +100,7 @@ class SpriteFramesEditor : public HSplitContainer { void _animation_name_edited(); void _animation_add(); void _animation_remove(); + void _animation_remove_confirmed(); void _animation_loop_changed(); void _animation_fps_changed(double p_value); diff --git a/editor/plugins/text_editor.cpp b/editor/plugins/text_editor.cpp index 89e419ede8..d0320bcd8b 100644 --- a/editor/plugins/text_editor.cpp +++ b/editor/plugins/text_editor.cpp @@ -30,6 +30,7 @@ #include "text_editor.h" +#include "core/os/keyboard.h" #include "editor_node.h" void TextEditor::add_syntax_highlighter(SyntaxHighlighter *p_highlighter) { @@ -577,13 +578,21 @@ void TextEditor::_text_edit_gui_input(const Ref<InputEvent> &ev) { } if (!mb->is_pressed()) { - _make_context_menu(tx->is_selection_active(), can_fold, is_folded); + _make_context_menu(tx->is_selection_active(), can_fold, is_folded, get_local_mouse_position()); } } } + + Ref<InputEventKey> k = ev; + if (k.is_valid() && k->is_pressed() && k->get_scancode() == KEY_MENU) { + TextEdit *tx = code_editor->get_text_edit(); + int line = tx->cursor_get_line(); + _make_context_menu(tx->is_selection_active(), tx->can_fold(line), tx->is_folded(line), (get_global_transform().inverse() * tx->get_global_transform()).xform(tx->_get_cursor_pixel_pos())); + context_menu->grab_focus(); + } } -void TextEditor::_make_context_menu(bool p_selection, bool p_can_fold, bool p_is_folded) { +void TextEditor::_make_context_menu(bool p_selection, bool p_can_fold, bool p_is_folded, Vector2 p_position) { context_menu->clear(); if (p_selection) { @@ -609,7 +618,7 @@ void TextEditor::_make_context_menu(bool p_selection, bool p_can_fold, bool p_is if (p_can_fold || p_is_folded) context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_fold_line"), EDIT_TOGGLE_FOLD_LINE); - context_menu->set_position(get_global_transform().xform(get_local_mouse_position())); + context_menu->set_position(get_global_transform().xform(p_position)); context_menu->set_size(Vector2(1, 1)); context_menu->popup(); } diff --git a/editor/plugins/text_editor.h b/editor/plugins/text_editor.h index c8b49a61e0..7d441a187d 100644 --- a/editor/plugins/text_editor.h +++ b/editor/plugins/text_editor.h @@ -101,7 +101,7 @@ protected: void _notification(int p_what); void _edit_option(int p_op); - void _make_context_menu(bool p_selection, bool p_can_fold, bool p_is_folded); + void _make_context_menu(bool p_selection, bool p_can_fold, bool p_is_folded, Vector2 p_position); void _text_edit_gui_input(const Ref<InputEvent> &ev); Map<String, SyntaxHighlighter *> highlighters; diff --git a/editor/plugins/tile_map_editor_plugin.cpp b/editor/plugins/tile_map_editor_plugin.cpp index 90276041a8..86d538e702 100644 --- a/editor/plugins/tile_map_editor_plugin.cpp +++ b/editor/plugins/tile_map_editor_plugin.cpp @@ -989,7 +989,7 @@ bool TileMapEditor::forward_gui_input(const Ref<InputEvent> &p_event) { if (mb->is_pressed()) { if (Input::get_singleton()->is_key_pressed(KEY_SPACE)) - return false; //drag + return false; // Drag. if (tool == TOOL_NONE) { @@ -1593,7 +1593,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { } } - int max_lines = 10000; //avoid crash if size too smal + int max_lines = 10000; //avoid crash if size too small if (node->get_half_offset() != TileMap::HALF_OFFSET_Y && node->get_half_offset() != TileMap::HALF_OFFSET_NEGATIVE_Y) { @@ -1645,7 +1645,7 @@ void TileMapEditor::forward_canvas_draw_over_viewport(Control *p_overlay) { p_overlay->draw_colored_polygon(points, Color(0.2, 0.8, 1, 0.4)); } - if (mouse_over) { + if (mouse_over && node->get_tileset().is_valid()) { Vector2 endpoints[4] = { node->map_to_world(over_tile, true), diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 701676a7f8..f70dcab931 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -1689,7 +1689,7 @@ void ProjectList::_panel_input(const Ref<InputEvent> &p_ev, Node *p_hb) { emit_signal(SIGNAL_SELECTION_CHANGED); - if (mb->is_doubleclick()) { + if (!mb->get_control() && mb->is_doubleclick()) { emit_signal(SIGNAL_PROJECT_ASK_OPEN); } } @@ -1757,6 +1757,12 @@ void ProjectManager::_notification(int p_what) { if (_project_list->get_project_count() == 0 && StreamPeerSSL::is_available()) open_templates->popup_centered_minsize(); + + if (_project_list->get_project_count() >= 1) { + // Focus on the search box immediately to allow the user + // to search without having to reach for their mouse + project_filter->search_box->grab_focus(); + } } break; case NOTIFICATION_VISIBILITY_CHANGED: { diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index f1e9420799..d42f15cce8 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -1007,8 +1007,12 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() { presets.insert("pvrtc"); presets.insert("debug"); presets.insert("release"); + presets.insert("editor"); + presets.insert("standalone"); presets.insert("32"); presets.insert("64"); + // Not available as an export platform yet, so it needs to be added manually + presets.insert("Server"); for (int i = 0; i < EditorExport::get_singleton()->get_export_platform_count(); i++) { List<String> p; @@ -1043,6 +1047,84 @@ void ProjectSettingsEditor::_copy_to_platform_about_to_show() { } } +Variant ProjectSettingsEditor::get_drag_data_fw(const Point2 &p_point, Control *p_from) { + + TreeItem *selected = input_editor->get_selected(); + if (!selected || selected->get_parent() != input_editor->get_root()) + return Variant(); + + String name = selected->get_text(0); + VBoxContainer *vb = memnew(VBoxContainer); + HBoxContainer *hb = memnew(HBoxContainer); + Label *label = memnew(Label(name)); + hb->set_modulate(Color(1, 1, 1, 1.0f)); + hb->add_child(label); + vb->add_child(hb); + set_drag_preview(vb); + + Dictionary drag_data; + drag_data["type"] = "nodes"; + + input_editor->set_drop_mode_flags(Tree::DROP_MODE_INBETWEEN); + + return drag_data; +} + +bool ProjectSettingsEditor::can_drop_data_fw(const Point2 &p_point, const Variant &p_data, Control *p_from) const { + + Dictionary d = p_data; + if (!d.has("type") || d["type"] != "nodes") + return false; + + TreeItem *selected = input_editor->get_selected(); + TreeItem *item = input_editor->get_item_at_position(p_point); + if (!selected || !item || item->get_parent() == selected) + return false; + + return true; +} + +void ProjectSettingsEditor::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; + + TreeItem *selected = input_editor->get_selected(); + TreeItem *item = input_editor->get_item_at_position(p_point); + TreeItem *target = item->get_parent() == input_editor->get_root() ? item : item->get_parent(); + + String selected_name = "input/" + selected->get_text(0); + int old_order = ProjectSettings::get_singleton()->get_order(selected_name); + String target_name = "input/" + target->get_text(0); + int target_order = ProjectSettings::get_singleton()->get_order(target_name); + + int order = old_order; + bool is_below = target_order > old_order; + TreeItem *iterator = is_below ? selected->get_next() : selected->get_prev(); + + undo_redo->create_action(TTR("Moved Input Action Event")); + while (iterator != target) { + + String iterator_name = "input/" + iterator->get_text(0); + int iterator_order = ProjectSettings::get_singleton()->get_order(iterator_name); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", iterator_name, order); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", iterator_name, iterator_order); + order = iterator_order; + iterator = is_below ? iterator->get_next() : iterator->get_prev(); + } + + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", target_name, order); + undo_redo->add_do_method(ProjectSettings::get_singleton(), "set_order", selected_name, target_order); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", target_name, target_order); + undo_redo->add_undo_method(ProjectSettings::get_singleton(), "set_order", selected_name, old_order); + + undo_redo->add_do_method(this, "_update_actions"); + undo_redo->add_undo_method(this, "_update_actions"); + undo_redo->add_do_method(this, "_settings_changed"); + undo_redo->add_undo_method(this, "_settings_changed"); + undo_redo->commit_action(); +} + void ProjectSettingsEditor::_copy_to_platform(int p_which) { String path = globals_editor->get_inspector()->get_selected_path(); @@ -1227,7 +1309,7 @@ void ProjectSettingsEditor::_translation_res_option_changed() { ERR_FAIL_COND(!remaps.has(key)); PoolStringArray r = remaps[key]; ERR_FAIL_INDEX(idx, r.size()); - if (translation_locales_idxs_remap.size() > 0) { + if (translation_locales_idxs_remap.size() > which) { r.set(idx, path + ":" + langs[translation_locales_idxs_remap[which]]); } else { r.set(idx, path + ":" + langs[which]); @@ -1662,6 +1744,10 @@ void ProjectSettingsEditor::_bind_methods() { ClassDB::bind_method(D_METHOD("_editor_restart_close"), &ProjectSettingsEditor::_editor_restart_close); ClassDB::bind_method(D_METHOD("get_tabs"), &ProjectSettingsEditor::get_tabs); + + ClassDB::bind_method(D_METHOD("get_drag_data_fw"), &ProjectSettingsEditor::get_drag_data_fw); + ClassDB::bind_method(D_METHOD("can_drop_data_fw"), &ProjectSettingsEditor::can_drop_data_fw); + ClassDB::bind_method(D_METHOD("drop_data_fw"), &ProjectSettingsEditor::drop_data_fw); } ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { @@ -1844,6 +1930,8 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { input_editor->connect("item_activated", this, "_action_activated"); input_editor->connect("cell_selected", this, "_action_selected"); input_editor->connect("button_pressed", this, "_action_button_pressed"); + input_editor->set_drag_forwarding(this); + popup_add = memnew(PopupMenu); add_child(popup_add); popup_add->connect("id_pressed", this, "_add_item"); diff --git a/editor/project_settings_editor.h b/editor/project_settings_editor.h index d302c0d34b..4dfd8ba602 100644 --- a/editor/project_settings_editor.h +++ b/editor/project_settings_editor.h @@ -158,6 +158,10 @@ class ProjectSettingsEditor : public AcceptDialog { void _toggle_search_bar(bool p_pressed); + 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 _copy_to_platform_about_to_show(); ProjectSettingsEditor(); diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index e45b08c992..ae91e7d79f 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1552,18 +1552,20 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V if (p_nodes.size() == 0) return; // Nothing to reparent. - bool same_parent = true; + p_nodes.sort_custom<Node::Comparator>(); //Makes result reliable. + + bool no_change = true; for (int ni = 0; ni < p_nodes.size(); ni++) { if (p_nodes[ni] == p_new_parent) return; // Attempt to reparent to itself. - if (p_nodes[ni]->get_parent() != p_new_parent) - same_parent = false; + if (p_nodes[ni]->get_parent() != p_new_parent || p_position_in_parent + ni != p_nodes[ni]->get_position_in_parent()) + no_change = false; } - if (same_parent) - return; // No new parent changes. + if (no_change) + return; // Position and parent didn't change. Node *validate = new_parent; while (validate) { @@ -2916,5 +2918,6 @@ SceneTreeDock::SceneTreeDock(EditorNode *p_editor, Node *p_scene_root, EditorSel profile_allow_script_editing = true; EDITOR_DEF("interface/editors/show_scene_tree_root_selection", true); + EDITOR_DEF("interface/editors/derive_script_globals_by_name", true); EDITOR_DEF("_use_favorites_root_selection", false); } diff --git a/editor/script_create_dialog.cpp b/editor/script_create_dialog.cpp index ffb3f5feab..01cb816556 100644 --- a/editor/script_create_dialog.cpp +++ b/editor/script_create_dialog.cpp @@ -55,6 +55,15 @@ void ScriptCreateDialog::_notification(int p_what) { String last_lang = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", ""); Ref<Texture> last_lang_icon; if (!last_lang.empty()) { + + for (int i = 0; i < language_menu->get_item_count(); i++) { + if (language_menu->get_item_text(i) == last_lang) { + language_menu->select(i); + current_language = i; + break; + } + } + last_lang_icon = get_icon(last_lang, "EditorIcons"); } else { last_lang_icon = language_menu->get_item_icon(default_language); @@ -757,7 +766,6 @@ ScriptCreateDialog::ScriptCreateDialog() { status_panel = memnew(PanelContainer); status_panel->set_h_size_flags(Control::SIZE_FILL); - status_panel->add_style_override("panel", EditorNode::get_singleton()->get_gui_base()->get_stylebox("bg", "Tree")); status_panel->add_child(vb); /* Spacing */ @@ -794,19 +802,8 @@ ScriptCreateDialog::ScriptCreateDialog() { } } - String last_selected_language = EditorSettings::get_singleton()->get_project_metadata("script_setup", "last_selected_language", ""); - if (last_selected_language != "") { - for (int i = 0; i < language_menu->get_item_count(); i++) { - if (language_menu->get_item_text(i) == last_selected_language) { - language_menu->select(i); - current_language = i; - break; - } - } - } else { - language_menu->select(default_language); - current_language = default_language; - } + language_menu->select(default_language); + current_language = default_language; language_menu->connect("item_selected", this, "_lang_changed"); diff --git a/editor/script_editor_debugger.cpp b/editor/script_editor_debugger.cpp index 26ca3726f5..6ba507fb9c 100644 --- a/editor/script_editor_debugger.cpp +++ b/editor/script_editor_debugger.cpp @@ -434,6 +434,15 @@ int ScriptEditorDebugger::_update_scene_tree(TreeItem *parent, const Array &node } item->set_metadata(0, id); + if (id == inspected_object_id) { + TreeItem *cti = item->get_parent(); + while (cti) { + cti->set_collapsed(false); + cti = cti->get_parent(); + } + item->select(0); + } + // Set current item as collapsed if necessary if (parent) { if (!unfold_cache.has(id)) { @@ -2139,11 +2148,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { step = memnew(ToolButton); hbc->add_child(step); step->set_tooltip(TTR("Step Into")); + step->set_shortcut(ED_GET_SHORTCUT("debugger/step_into")); step->connect("pressed", this, "debug_step"); next = memnew(ToolButton); hbc->add_child(next); next->set_tooltip(TTR("Step Over")); + next->set_shortcut(ED_GET_SHORTCUT("debugger/step_over")); next->connect("pressed", this, "debug_next"); hbc->add_child(memnew(VSeparator)); @@ -2151,11 +2162,13 @@ ScriptEditorDebugger::ScriptEditorDebugger(EditorNode *p_editor) { dobreak = memnew(ToolButton); hbc->add_child(dobreak); dobreak->set_tooltip(TTR("Break")); + dobreak->set_shortcut(ED_GET_SHORTCUT("debugger/break")); dobreak->connect("pressed", this, "debug_break"); docontinue = memnew(ToolButton); hbc->add_child(docontinue); docontinue->set_tooltip(TTR("Continue")); + docontinue->set_shortcut(ED_GET_SHORTCUT("debugger/continue")); docontinue->connect("pressed", this, "debug_continue"); back = memnew(Button); diff --git a/editor/spatial_editor_gizmos.cpp b/editor/spatial_editor_gizmos.cpp index 27f3b28b49..b9f26d666d 100644 --- a/editor/spatial_editor_gizmos.cpp +++ b/editor/spatial_editor_gizmos.cpp @@ -172,8 +172,8 @@ void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base, bool p_hidde instance = VS::get_singleton()->instance_create2(mesh->get_rid(), p_base->get_world()->get_scenario()); VS::get_singleton()->instance_attach_object_instance_id(instance, p_base->get_instance_id()); - if (skeleton.is_valid()) - VS::get_singleton()->instance_attach_skeleton(instance, skeleton); + if (skin_reference.is_valid()) + VS::get_singleton()->instance_attach_skeleton(instance, skin_reference->get_skeleton()); if (extra_margin) VS::get_singleton()->instance_set_extra_visibility_margin(instance, 1); VS::get_singleton()->instance_geometry_set_cast_shadows_setting(instance, VS::SHADOW_CASTING_SETTING_OFF); @@ -181,14 +181,14 @@ void EditorSpatialGizmo::Instance::create_instance(Spatial *p_base, bool p_hidde VS::get_singleton()->instance_set_layer_mask(instance, layer); //gizmos are 26 } -void EditorSpatialGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const RID &p_skeleton, const Ref<Material> &p_material) { +void EditorSpatialGizmo::add_mesh(const Ref<ArrayMesh> &p_mesh, bool p_billboard, const Ref<SkinReference> &p_skin_reference, const Ref<Material> &p_material) { ERR_FAIL_COND(!spatial_node); Instance ins; ins.billboard = p_billboard; ins.mesh = p_mesh; - ins.skeleton = p_skeleton; + ins.skin_reference = p_skin_reference; ins.material = p_material; if (valid) { ins.create_instance(spatial_node, hidden); @@ -729,7 +729,7 @@ void EditorSpatialGizmo::set_plugin(EditorSpatialGizmoPlugin *p_plugin) { void EditorSpatialGizmo::_bind_methods() { ClassDB::bind_method(D_METHOD("add_lines", "lines", "material", "billboard"), &EditorSpatialGizmo::add_lines, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "billboard", "skeleton", "material"), &EditorSpatialGizmo::add_mesh, DEFVAL(false), DEFVAL(RID()), DEFVAL(Variant())); + ClassDB::bind_method(D_METHOD("add_mesh", "mesh", "billboard", "skeleton", "material"), &EditorSpatialGizmo::add_mesh, DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("add_collision_segments", "segments"), &EditorSpatialGizmo::add_collision_segments); ClassDB::bind_method(D_METHOD("add_collision_triangles", "triangles"), &EditorSpatialGizmo::add_collision_triangles); ClassDB::bind_method(D_METHOD("add_unscaled_billboard", "material", "default_scale"), &EditorSpatialGizmo::add_unscaled_billboard, DEFVAL(1)); @@ -1802,7 +1802,7 @@ void SkeletonSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { } Ref<ArrayMesh> m = surface_tool->commit(); - p_gizmo->add_mesh(m, false, skel->get_skeleton()); + p_gizmo->add_mesh(m, false, skel->register_skin(Ref<Skin>())); } //// @@ -3725,7 +3725,7 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Ref<ConcavePolygonShape> cs2 = s; Ref<ArrayMesh> mesh = cs2->get_debug_mesh(); - p_gizmo->add_mesh(mesh, false, RID(), material); + p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material); } if (Object::cast_to<RayShape>(*s)) { @@ -3747,7 +3747,7 @@ void CollisionShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { Ref<HeightMapShape> hms = s; Ref<ArrayMesh> mesh = hms->get_debug_mesh(); - p_gizmo->add_mesh(mesh, false, RID(), material); + p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), material); } } diff --git a/misc/scripts/fix_style.sh b/misc/scripts/fix_style.sh index 7a335c21ea..19ca781535 100755 --- a/misc/scripts/fix_style.sh +++ b/misc/scripts/fix_style.sh @@ -41,7 +41,7 @@ if $run_clang_format; then echo -e "Formatting ${extension} files..." find \( -path "./.git" \ -o -path "./thirdparty" \ - -o -path "./platform/android/java/src/com" \ + -o -path "./platform/android/java/lib/src/com/google" \ \) -prune \ -o -name "*${extension}" \ -exec clang-format -i {} \; @@ -54,7 +54,7 @@ if $run_fix_headers; then find \( -path "./.git" -o -path "./thirdparty" \) -prune \ -o -regex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|m\|mm\|java\)' \ > tmp-files - cat tmp-files | grep -v ".git\|thirdparty\|theme_data.h\|platform/android/java/src/com\|platform/android/java/src/org/godotengine/godot/input/InputManager" > files + cat tmp-files | grep -v ".git\|thirdparty\|theme_data.h\|platform/android/java/lib/src/com/google\|platform/android/java/lib/src/org/godotengine/godot/input/InputManager" > files python misc/scripts/fix_headers.py rm -f tmp-files files fi diff --git a/modules/assimp/editor_scene_importer_assimp.cpp b/modules/assimp/editor_scene_importer_assimp.cpp index 6a95d355eb..f2f51d9dd3 100644 --- a/modules/assimp/editor_scene_importer_assimp.cpp +++ b/modules/assimp/editor_scene_importer_assimp.cpp @@ -1280,7 +1280,6 @@ void EditorSceneImporterAssimp::create_bone(ImportState &state, RecursiveState & // this transform is a bone recursive_state.skeleton->add_bone(recursive_state.node_name); - ERR_FAIL_COND(recursive_state.skeleton == NULL); // serious bug we must now exit. //ERR_FAIL_COND(recursive_state.skeleton->get_name() == ""); print_verbose("Bone added to lookup: " + AssimpUtils::get_assimp_string(recursive_state.bone->mName)); print_verbose("Skeleton attached to: " + recursive_state.skeleton->get_name()); diff --git a/modules/bmp/image_loader_bmp.cpp b/modules/bmp/image_loader_bmp.cpp index 5a32fa1c2c..8708430257 100644 --- a/modules/bmp/image_loader_bmp.cpp +++ b/modules/bmp/image_loader_bmp.cpp @@ -63,139 +63,137 @@ Error ImageLoaderBMP::convert_to_image(Ref<Image> p_image, ERR_FAIL_V(ERR_UNAVAILABLE); } - if (err == OK) { - // Image data (might be indexed) - PoolVector<uint8_t> data; - int data_len = 0; + // Image data (might be indexed) + PoolVector<uint8_t> data; + int data_len = 0; - if (bits_per_pixel <= 8) { // indexed - data_len = width * height; - } else { // color - data_len = width * height * 4; - } - ERR_FAIL_COND_V(data_len == 0, ERR_BUG); - err = data.resize(data_len); - - PoolVector<uint8_t>::Write data_w = data.write(); - uint8_t *write_buffer = data_w.ptr(); - - const uint32_t width_bytes = width * bits_per_pixel / 8; - const uint32_t line_width = (width_bytes + 3) & ~3; - - // The actual data traversal is determined by - // the data width in case of 8/4/1 bit images - const uint32_t w = bits_per_pixel >= 24 ? width : width_bytes; - const uint8_t *line = p_buffer + (line_width * (height - 1)); - - for (unsigned int i = 0; i < height; i++) { - const uint8_t *line_ptr = line; - - for (unsigned int j = 0; j < w; j++) { - switch (bits_per_pixel) { - case 1: { - uint8_t color_index = *line_ptr; - - write_buffer[index + 0] = (color_index >> 7) & 1; - write_buffer[index + 1] = (color_index >> 6) & 1; - write_buffer[index + 2] = (color_index >> 5) & 1; - write_buffer[index + 3] = (color_index >> 4) & 1; - write_buffer[index + 4] = (color_index >> 3) & 1; - write_buffer[index + 5] = (color_index >> 2) & 1; - write_buffer[index + 6] = (color_index >> 1) & 1; - write_buffer[index + 7] = (color_index >> 0) & 1; - - index += 8; - line_ptr += 1; - } break; - case 4: { - uint8_t color_index = *line_ptr; - - write_buffer[index + 0] = (color_index >> 4) & 0x0f; - write_buffer[index + 1] = color_index & 0x0f; - - index += 2; - line_ptr += 1; - } break; - case 8: { - uint8_t color_index = *line_ptr; - - write_buffer[index] = color_index; - - index += 1; - line_ptr += 1; - } break; - case 24: { - uint32_t color = *((uint32_t *)line_ptr); - - write_buffer[index + 2] = color & 0xff; - write_buffer[index + 1] = (color >> 8) & 0xff; - write_buffer[index + 0] = (color >> 16) & 0xff; - write_buffer[index + 3] = 0xff; - - index += 4; - line_ptr += 3; - } break; - case 32: { - uint32_t color = *((uint32_t *)line_ptr); - - write_buffer[index + 2] = color & 0xff; - write_buffer[index + 1] = (color >> 8) & 0xff; - write_buffer[index + 0] = (color >> 16) & 0xff; - write_buffer[index + 3] = color >> 24; - - index += 4; - line_ptr += 4; - } break; - } + if (bits_per_pixel <= 8) { // indexed + data_len = width * height; + } else { // color + data_len = width * height * 4; + } + ERR_FAIL_COND_V(data_len == 0, ERR_BUG); + err = data.resize(data_len); + + PoolVector<uint8_t>::Write data_w = data.write(); + uint8_t *write_buffer = data_w.ptr(); + + const uint32_t width_bytes = width * bits_per_pixel / 8; + const uint32_t line_width = (width_bytes + 3) & ~3; + + // The actual data traversal is determined by + // the data width in case of 8/4/1 bit images + const uint32_t w = bits_per_pixel >= 24 ? width : width_bytes; + const uint8_t *line = p_buffer + (line_width * (height - 1)); + + for (uint64_t i = 0; i < height; i++) { + const uint8_t *line_ptr = line; + + for (unsigned int j = 0; j < w; j++) { + switch (bits_per_pixel) { + case 1: { + uint8_t color_index = *line_ptr; + + write_buffer[index + 0] = (color_index >> 7) & 1; + write_buffer[index + 1] = (color_index >> 6) & 1; + write_buffer[index + 2] = (color_index >> 5) & 1; + write_buffer[index + 3] = (color_index >> 4) & 1; + write_buffer[index + 4] = (color_index >> 3) & 1; + write_buffer[index + 5] = (color_index >> 2) & 1; + write_buffer[index + 6] = (color_index >> 1) & 1; + write_buffer[index + 7] = (color_index >> 0) & 1; + + index += 8; + line_ptr += 1; + } break; + case 4: { + uint8_t color_index = *line_ptr; + + write_buffer[index + 0] = (color_index >> 4) & 0x0f; + write_buffer[index + 1] = color_index & 0x0f; + + index += 2; + line_ptr += 1; + } break; + case 8: { + uint8_t color_index = *line_ptr; + + write_buffer[index] = color_index; + + index += 1; + line_ptr += 1; + } break; + case 24: { + uint32_t color = *((uint32_t *)line_ptr); + + write_buffer[index + 2] = color & 0xff; + write_buffer[index + 1] = (color >> 8) & 0xff; + write_buffer[index + 0] = (color >> 16) & 0xff; + write_buffer[index + 3] = 0xff; + + index += 4; + line_ptr += 3; + } break; + case 32: { + uint32_t color = *((uint32_t *)line_ptr); + + write_buffer[index + 2] = color & 0xff; + write_buffer[index + 1] = (color >> 8) & 0xff; + write_buffer[index + 0] = (color >> 16) & 0xff; + write_buffer[index + 3] = color >> 24; + + index += 4; + line_ptr += 4; + } break; } - line -= line_width; } + line -= line_width; + } - if (p_color_buffer == NULL || color_table_size == 0) { // regular pixels + if (p_color_buffer == NULL || color_table_size == 0) { // regular pixels - p_image->create(width, height, 0, Image::FORMAT_RGBA8, data); + p_image->create(width, height, 0, Image::FORMAT_RGBA8, data); - } else { // data is in indexed format, extend it + } else { // data is in indexed format, extend it - // Palette data - PoolVector<uint8_t> palette_data; - palette_data.resize(color_table_size * 4); + // Palette data + PoolVector<uint8_t> palette_data; + palette_data.resize(color_table_size * 4); - PoolVector<uint8_t>::Write palette_data_w = palette_data.write(); - uint8_t *pal = palette_data_w.ptr(); + PoolVector<uint8_t>::Write palette_data_w = palette_data.write(); + uint8_t *pal = palette_data_w.ptr(); - const uint8_t *cb = p_color_buffer; + const uint8_t *cb = p_color_buffer; - for (unsigned int i = 0; i < color_table_size; ++i) { - uint32_t color = *((uint32_t *)cb); + for (unsigned int i = 0; i < color_table_size; ++i) { + uint32_t color = *((uint32_t *)cb); - pal[i * 4 + 0] = (color >> 16) & 0xff; - pal[i * 4 + 1] = (color >> 8) & 0xff; - pal[i * 4 + 2] = (color)&0xff; - pal[i * 4 + 3] = 0xff; + pal[i * 4 + 0] = (color >> 16) & 0xff; + pal[i * 4 + 1] = (color >> 8) & 0xff; + pal[i * 4 + 2] = (color)&0xff; + pal[i * 4 + 3] = 0xff; - cb += 4; - } - // Extend palette to image - PoolVector<uint8_t> extended_data; - extended_data.resize(data.size() * 4); + cb += 4; + } + // Extend palette to image + PoolVector<uint8_t> extended_data; + extended_data.resize(data.size() * 4); - PoolVector<uint8_t>::Write ex_w = extended_data.write(); - uint8_t *dest = ex_w.ptr(); + PoolVector<uint8_t>::Write ex_w = extended_data.write(); + uint8_t *dest = ex_w.ptr(); - const int num_pixels = width * height; + const int num_pixels = width * height; - for (int i = 0; i < num_pixels; i++) { - dest[0] = pal[write_buffer[i] * 4 + 0]; - dest[1] = pal[write_buffer[i] * 4 + 1]; - dest[2] = pal[write_buffer[i] * 4 + 2]; - dest[3] = pal[write_buffer[i] * 4 + 3]; + for (int i = 0; i < num_pixels; i++) { + dest[0] = pal[write_buffer[i] * 4 + 0]; + dest[1] = pal[write_buffer[i] * 4 + 1]; + dest[2] = pal[write_buffer[i] * 4 + 2]; + dest[3] = pal[write_buffer[i] * 4 + 3]; - dest += 4; - } - p_image->create(width, height, 0, Image::FORMAT_RGBA8, extended_data); + dest += 4; } + p_image->create(width, height, 0, Image::FORMAT_RGBA8, extended_data); } } return err; diff --git a/modules/csg/csg_gizmos.cpp b/modules/csg/csg_gizmos.cpp index e6bfa5525d..0d26943af6 100644 --- a/modules/csg/csg_gizmos.cpp +++ b/modules/csg/csg_gizmos.cpp @@ -377,7 +377,7 @@ void CSGShapeSpatialGizmoPlugin::redraw(EditorSpatialGizmo *p_gizmo) { break; } - p_gizmo->add_mesh(mesh, false, RID(), solid_material); + p_gizmo->add_mesh(mesh, false, Ref<SkinReference>(), solid_material); } if (Object::cast_to<CSGSphere>(cs)) { diff --git a/modules/csg/csg_shape.cpp b/modules/csg/csg_shape.cpp index 23725c4960..35c75e2a8a 100644 --- a/modules/csg/csg_shape.cpp +++ b/modules/csg/csg_shape.cpp @@ -1067,6 +1067,7 @@ void CSGSphere::set_radius(const float p_radius) { radius = p_radius; _make_dirty(); update_gizmo(); + _change_notify("radius"); } float CSGSphere::get_radius() const { @@ -1251,6 +1252,7 @@ void CSGBox::set_width(const float p_width) { width = p_width; _make_dirty(); update_gizmo(); + _change_notify("width"); } float CSGBox::get_width() const { @@ -1261,6 +1263,7 @@ void CSGBox::set_height(const float p_height) { height = p_height; _make_dirty(); update_gizmo(); + _change_notify("height"); } float CSGBox::get_height() const { @@ -1271,6 +1274,7 @@ void CSGBox::set_depth(const float p_depth) { depth = p_depth; _make_dirty(); update_gizmo(); + _change_notify("depth"); } float CSGBox::get_depth() const { @@ -1465,6 +1469,7 @@ void CSGCylinder::set_radius(const float p_radius) { radius = p_radius; _make_dirty(); update_gizmo(); + _change_notify("radius"); } float CSGCylinder::get_radius() const { @@ -1475,6 +1480,7 @@ void CSGCylinder::set_height(const float p_height) { height = p_height; _make_dirty(); update_gizmo(); + _change_notify("height"); } float CSGCylinder::get_height() const { @@ -1690,6 +1696,7 @@ void CSGTorus::set_inner_radius(const float p_inner_radius) { inner_radius = p_inner_radius; _make_dirty(); update_gizmo(); + _change_notify("inner_radius"); } float CSGTorus::get_inner_radius() const { @@ -1700,6 +1707,7 @@ void CSGTorus::set_outer_radius(const float p_outer_radius) { outer_radius = p_outer_radius; _make_dirty(); update_gizmo(); + _change_notify("outer_radius"); } float CSGTorus::get_outer_radius() const { diff --git a/modules/cvtt/SCsub b/modules/cvtt/SCsub index 142af0c800..746b23ca28 100644 --- a/modules/cvtt/SCsub +++ b/modules/cvtt/SCsub @@ -6,19 +6,18 @@ Import('env_modules') env_cvtt = env_modules.Clone() # Thirdparty source files -if env['builtin_squish']: - thirdparty_dir = "#thirdparty/cvtt/" - thirdparty_sources = [ - "ConvectionKernels.cpp" - ] +thirdparty_dir = "#thirdparty/cvtt/" +thirdparty_sources = [ + "ConvectionKernels.cpp" +] - thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] +thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources] - env_cvtt.Prepend(CPPPATH=[thirdparty_dir]) +env_cvtt.Prepend(CPPPATH=[thirdparty_dir]) - env_thirdparty = env_cvtt.Clone() - env_thirdparty.disable_warnings() - env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources) +env_thirdparty = env_cvtt.Clone() +env_thirdparty.disable_warnings() +env_thirdparty.add_source_files(env.modules_sources, thirdparty_sources) # Godot source files env_cvtt.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml index 84ed5fd9ee..4c10588aa6 100644 --- a/modules/enet/doc_classes/NetworkedMultiplayerENet.xml +++ b/modules/enet/doc_classes/NetworkedMultiplayerENet.xml @@ -115,9 +115,11 @@ <member name="compression_mode" type="int" setter="set_compression_mode" getter="get_compression_mode" enum="NetworkedMultiplayerENet.CompressionMode" default="0"> The compression method used for network packets. These have different tradeoffs of compression speed versus bandwidth, you may need to test which one works best for your use case if you use compression at all. </member> + <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" /> <member name="transfer_channel" type="int" setter="set_transfer_channel" getter="get_transfer_channel" default="-1"> Set the default channel to be used to transfer data. By default, this value is [code]-1[/code] which means that ENet will only use 2 channels, one for reliable and one for unreliable packets. Channel [code]0[/code] is reserved, and cannot be used. Setting this member to any value between [code]0[/code] and [member channel_count] (excluded) will force ENet to use that channel for sending data. </member> + <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="NetworkedMultiplayerPeer.TransferMode" default="2" /> </members> <constants> <constant name="COMPRESS_NONE" value="0" enum="CompressionMode"> diff --git a/modules/gdnative/gdnative/array.cpp b/modules/gdnative/gdnative/array.cpp index 1ef8e9f900..e97a75cca8 100644 --- a/modules/gdnative/gdnative/array.cpp +++ b/modules/gdnative/gdnative/array.cpp @@ -327,6 +327,15 @@ godot_array GDAPI godot_array_duplicate(const godot_array *p_self, const godot_b return res; } +godot_array GDAPI godot_array_slice(const godot_array *p_self, const godot_int p_begin, const godot_int p_end, const godot_int p_step, const godot_bool p_deep) { + const Array *self = (const Array *)p_self; + godot_array res; + Array *val = (Array *)&res; + memnew_placement(val, Array); + *val = self->slice(p_begin, p_end, p_step, p_deep); + return res; +} + godot_variant GDAPI godot_array_max(const godot_array *p_self) { const Array *self = (const Array *)p_self; godot_variant v; diff --git a/modules/gdnative/gdnative_api.json b/modules/gdnative/gdnative_api.json index 03258584ce..55ba4ecc1e 100644 --- a/modules/gdnative/gdnative_api.json +++ b/modules/gdnative/gdnative_api.json @@ -80,6 +80,17 @@ ["const godot_vector2 *", "p_self"], ["const godot_vector2 *", "p_to"] ] + }, + { + "name": "godot_array_slice", + "return_type": "godot_array", + "arguments": [ + ["const godot_array *", "p_self"], + ["const godot_int", "p_begin"], + ["const godot_int", "p_end"], + ["const godot_int", "p_step"], + ["const godot_bool", "p_deep"] + ] } ] }, diff --git a/modules/gdnative/include/gdnative/array.h b/modules/gdnative/include/gdnative/array.h index 10ef8a73d2..2e3ce58033 100644 --- a/modules/gdnative/include/gdnative/array.h +++ b/modules/gdnative/include/gdnative/array.h @@ -132,6 +132,8 @@ void GDAPI godot_array_destroy(godot_array *p_self); godot_array GDAPI godot_array_duplicate(const godot_array *p_self, const godot_bool p_deep); +godot_array GDAPI godot_array_slice(const godot_array *p_self, const godot_int p_begin, const godot_int p_end, const godot_int p_delta, const godot_bool p_deep); + godot_variant GDAPI godot_array_max(const godot_array *p_self); godot_variant GDAPI godot_array_min(const godot_array *p_self); diff --git a/modules/gdnative/videodecoder/video_stream_gdnative.cpp b/modules/gdnative/videodecoder/video_stream_gdnative.cpp index be131c5402..212ff51b80 100644 --- a/modules/gdnative/videodecoder/video_stream_gdnative.cpp +++ b/modules/gdnative/videodecoder/video_stream_gdnative.cpp @@ -149,7 +149,7 @@ void VideoStreamPlaybackGDNative::update(float p_delta) { if (mix_callback) { if (pcm_write_idx >= 0) { // Previous remains - int mixed = mix_callback(mix_udata, pcm, samples_decoded); + int mixed = mix_callback(mix_udata, pcm + pcm_write_idx * num_channels, samples_decoded); if (mixed == samples_decoded) { pcm_write_idx = -1; } else { diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 4efa90fd86..788db7fb86 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -694,6 +694,14 @@ [/codeblock] </description> </method> + <method name="ord"> + <return type="int"> + </return> + <argument index="0" name="char" type="String"> + </argument> + <description> + </description> + </method> <method name="parse_json"> <return type="Variant"> </return> diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index 8bb053b2bc..967b0c83ae 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -1399,9 +1399,6 @@ GDScriptParser::Node *GDScriptParser::_parse_expression(Node *p_parent, bool p_s unary = true; break; case OperatorNode::OP_NEG: - priority = 1; - unary = true; - break; case OperatorNode::OP_POS: priority = 1; unary = true; diff --git a/modules/gdscript/language_server/gdscript_extend_parser.cpp b/modules/gdscript/language_server/gdscript_extend_parser.cpp index 45f9ec9c6a..6db8cb2c88 100644 --- a/modules/gdscript/language_server/gdscript_extend_parser.cpp +++ b/modules/gdscript/language_server/gdscript_extend_parser.cpp @@ -189,6 +189,7 @@ void ExtendGDScriptParser::parse_class_symbol(const GDScriptParser::ClassNode *p lsp::DocumentSymbol symbol; const GDScriptParser::ClassNode::Constant &c = E->value(); const GDScriptParser::ConstantNode *node = dynamic_cast<const GDScriptParser::ConstantNode *>(c.expression); + ERR_FAIL_COND(!node); symbol.name = E->key(); symbol.kind = lsp::SymbolKind::Constant; symbol.deprecated = false; @@ -344,15 +345,13 @@ String ExtendGDScriptParser::marked_documentation(const String &p_bbcode) { if (block_start != -1) { code_block_indent = block_start; in_code_block = true; - line = "'''gdscript"; - line = "\n"; + line = "'''gdscript\n"; } else if (in_code_block) { line = "\t" + line.substr(code_block_indent, line.length()); } if (in_code_block && line.find("[/codeblock]") != -1) { - line = "'''\n"; - line = "\n"; + line = "'''\n\n"; in_code_block = false; } @@ -674,6 +673,7 @@ Dictionary ExtendGDScriptParser::dump_class_api(const GDScriptParser::ClassNode const GDScriptParser::ClassNode::Constant &c = E->value(); const GDScriptParser::ConstantNode *node = dynamic_cast<const GDScriptParser::ConstantNode *>(c.expression); + ERR_FAIL_COND_V(!node, class_api); Dictionary api; api["name"] = E->key(); diff --git a/modules/gdscript/language_server/gdscript_language_protocol.cpp b/modules/gdscript/language_server/gdscript_language_protocol.cpp index afe461b68e..ce3de9bc3b 100644 --- a/modules/gdscript/language_server/gdscript_language_protocol.cpp +++ b/modules/gdscript/language_server/gdscript_language_protocol.cpp @@ -100,9 +100,10 @@ Dictionary GDScriptLanguageProtocol::initialize(const Dictionary &p_params) { String root_uri = p_params["rootUri"]; String root = p_params["rootPath"]; - bool is_same_workspace = root == workspace->root; + bool is_same_workspace; +#ifndef WINDOWS_ENABLED is_same_workspace = root.to_lower() == workspace->root.to_lower(); -#ifdef WINDOWS_ENABLED +#else is_same_workspace = root.replace("\\", "/").to_lower() == workspace->root.to_lower(); #endif @@ -142,6 +143,7 @@ void GDScriptLanguageProtocol::poll() { Error GDScriptLanguageProtocol::start(int p_port) { if (server == NULL) { server = dynamic_cast<WebSocketServer *>(ClassDB::instance("WebSocketServer")); + ERR_FAIL_COND_V(!server, FAILED); server->set_buffers(8192, 1024, 8192, 1024); // 8mb should be way more than enough server->connect("data_received", this, "on_data_received"); server->connect("client_connected", this, "on_client_connected"); diff --git a/modules/gdscript/language_server/gdscript_text_document.cpp b/modules/gdscript/language_server/gdscript_text_document.cpp index f211fae526..7c58c7aa15 100644 --- a/modules/gdscript/language_server/gdscript_text_document.cpp +++ b/modules/gdscript/language_server/gdscript_text_document.cpp @@ -380,8 +380,8 @@ GDScriptTextDocument::~GDScriptTextDocument() { memdelete(file_checker); } -void GDScriptTextDocument::sync_script_content(const String &p_uri, const String &p_content) { - String path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(p_uri); +void GDScriptTextDocument::sync_script_content(const String &p_path, const String &p_content) { + String path = GDScriptLanguageProtocol::get_singleton()->get_workspace()->get_file_path(p_path); GDScriptLanguageProtocol::get_singleton()->get_workspace()->parse_script(path, p_content); } diff --git a/modules/gridmap/grid_map_editor_plugin.cpp b/modules/gridmap/grid_map_editor_plugin.cpp index 7e2986ca85..c97524a54d 100644 --- a/modules/gridmap/grid_map_editor_plugin.cpp +++ b/modules/gridmap/grid_map_editor_plugin.cpp @@ -385,8 +385,8 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo if (!p.intersects_segment(from, from + normal * settings_pick_distance->get_value(), &inters)) return false; - //make sure the intersection is inside the frustum planes, to avoid - //painting on invisible regions + // Make sure the intersection is inside the frustum planes, to avoid + // Painting on invisible regions. for (int i = 0; i < planes.size(); i++) { Plane fp = local_xform.xform(planes[i]); @@ -397,8 +397,6 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo int cell[3]; float cell_size[3] = { node->get_cell_size().x, node->get_cell_size().y, node->get_cell_size().z }; - last_mouseover = Vector3(-1, -1, -1); - for (int i = 0; i < 3; i++) { if (i == edit_axis) @@ -407,19 +405,11 @@ bool GridMapEditor::do_input_action(Camera *p_camera, const Point2 &p_point, boo cell[i] = inters[i] / node->get_cell_size()[i]; if (inters[i] < 0) - cell[i] -= 1; //compensate negative + cell[i] -= 1; // Compensate negative. grid_ofs[i] = cell[i] * cell_size[i]; } - - /*if (cell[i]<0 || cell[i]>=grid_size[i]) { - - cursor_visible=false; - _update_cursor_transform(); - return false; - }*/ } - last_mouseover = Vector3(cell[0], cell[1], cell[2]); VS::get_singleton()->instance_set_transform(grid_instance[edit_axis], node->get_global_transform() * edit_grid_xform); if (cursor_instance.is_valid()) { @@ -656,7 +646,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu if (mb->is_pressed()) floor->set_value(floor->get_value() + mb->get_factor()); - return true; //eaten + return true; // Eaten. } else if (mb->get_button_index() == BUTTON_WHEEL_DOWN && (mb->get_command() || mb->get_shift())) { if (mb->is_pressed()) floor->set_value(floor->get_value() - mb->get_factor()); @@ -702,9 +692,7 @@ bool GridMapEditor::forward_spatial_input_event(Camera *p_camera, const Ref<Inpu return do_input_action(p_camera, Point2(mb->get_position().x, mb->get_position().y), true); } else { - if ( - (mb->get_button_index() == BUTTON_RIGHT && input_action == INPUT_ERASE) || - (mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_PAINT)) { + if ((mb->get_button_index() == BUTTON_RIGHT && input_action == INPUT_ERASE) || (mb->get_button_index() == BUTTON_LEFT && input_action == INPUT_PAINT)) { if (set_items.size()) { undo_redo->create_action(TTR("GridMap Paint")); @@ -933,7 +921,7 @@ void GridMapEditor::update_palette() { item++; } - if (selected != -1) { + if (selected != -1 && mesh_library_palette->get_item_count() > 0) { mesh_library_palette->select(selected); } @@ -945,7 +933,6 @@ void GridMapEditor::edit(GridMap *p_gridmap) { node = p_gridmap; VS *vs = VS::get_singleton(); - last_mouseover = Vector3(-1, -1, -1); input_action = INPUT_NONE; selection.active = false; _update_selection_transform(); @@ -981,7 +968,7 @@ void GridMapEditor::edit(GridMap *p_gridmap) { { - //update grids + // Update grids. indicator_mat.instance(); indicator_mat->set_flag(SpatialMaterial::FLAG_UNSHADED, true); indicator_mat->set_feature(SpatialMaterial::FEATURE_TRANSPARENT, true); @@ -1052,9 +1039,7 @@ void GridMapEditor::_update_clip() { void GridMapEditor::update_grid() { - grid_xform.origin.x -= 1; //force update in hackish way.. what do i care - - //VS *vs = VS::get_singleton(); + grid_xform.origin.x -= 1; // Force update in hackish way. grid_ofs[edit_axis] = edit_floor[edit_axis] * node->get_cell_size()[edit_axis]; @@ -1140,7 +1125,6 @@ void GridMapEditor::_notification(int p_what) { 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; @@ -1358,7 +1342,6 @@ GridMapEditor::GridMapEditor(EditorNode *p_editor) { selected_palette = -1; lock_view = false; cursor_rot = 0; - last_mouseover = Vector3(-1, -1, -1); selection_mesh = VisualServer::get_singleton()->mesh_create(); paste_mesh = VisualServer::get_singleton()->mesh_create(); diff --git a/modules/gridmap/grid_map_editor_plugin.h b/modules/gridmap/grid_map_editor_plugin.h index 103913485f..48a07e9c7f 100644 --- a/modules/gridmap/grid_map_editor_plugin.h +++ b/modules/gridmap/grid_map_editor_plugin.h @@ -156,7 +156,6 @@ class GridMapEditor : public VBoxContainer { Transform cursor_transform; Vector3 cursor_origin; - Vector3 last_mouseover; int display_mode; int selected_palette; diff --git a/modules/mono/editor/bindings_generator.cpp b/modules/mono/editor/bindings_generator.cpp index 74710db224..22bfa14d5d 100644 --- a/modules/mono/editor/bindings_generator.cpp +++ b/modules/mono/editor/bindings_generator.cpp @@ -863,6 +863,8 @@ void BindingsGenerator::_generate_global_constants(StringBuilder &p_output) { Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir, Vector<String> &r_compile_items) { + ERR_FAIL_COND_V(!initialized, ERR_UNCONFIGURED); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); ERR_FAIL_COND_V(!da, ERR_CANT_CREATE); @@ -984,6 +986,8 @@ Error BindingsGenerator::generate_cs_core_project(const String &p_proj_dir, Vect Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir, Vector<String> &r_compile_items) { + ERR_FAIL_COND_V(!initialized, ERR_UNCONFIGURED); + DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); ERR_FAIL_COND_V(!da, ERR_CANT_CREATE); @@ -1064,6 +1068,8 @@ Error BindingsGenerator::generate_cs_editor_project(const String &p_proj_dir, Ve Error BindingsGenerator::generate_cs_api(const String &p_output_dir) { + ERR_FAIL_COND_V(!initialized, ERR_UNCONFIGURED); + String output_dir = path::abspath(path::realpath(p_output_dir)); DirAccessRef da = DirAccess::create(DirAccess::ACCESS_FILESYSTEM); @@ -1703,6 +1709,8 @@ Error BindingsGenerator::_generate_cs_method(const BindingsGenerator::TypeInterf Error BindingsGenerator::generate_glue(const String &p_output_dir) { + ERR_FAIL_COND_V(!initialized, ERR_UNCONFIGURED); + bool dir_exists = DirAccess::exists(p_output_dir); ERR_FAIL_COND_V_MSG(!dir_exists, ERR_FILE_BAD_PATH, "The output directory does not exist."); @@ -2151,7 +2159,7 @@ StringName BindingsGenerator::_get_float_type_name_from_meta(GodotTypeInfo::Meta } } -void BindingsGenerator::_populate_object_type_interfaces() { +bool BindingsGenerator::_populate_object_type_interfaces() { obj_types.clear(); @@ -2229,7 +2237,7 @@ void BindingsGenerator::_populate_object_type_interfaces() { bool valid = false; iprop.index = ClassDB::get_property_index(type_cname, iprop.cname, &valid); - ERR_FAIL_COND(!valid); + ERR_FAIL_COND_V(!valid, false); iprop.proxy_name = escape_csharp_keyword(snake_to_pascal_case(iprop.cname)); @@ -2293,7 +2301,7 @@ void BindingsGenerator::_populate_object_type_interfaces() { imethod.is_vararg = m && m->is_vararg(); if (!m && !imethod.is_virtual) { - ERR_FAIL_COND_MSG(!virtual_method_list.find(method_info), + ERR_FAIL_COND_V_MSG(!virtual_method_list.find(method_info), false, "Missing MethodBind for non-virtual method: '" + itype.name + "." + imethod.name + "'."); // A virtual method without the virtual flag. This is a special case. @@ -2310,9 +2318,9 @@ void BindingsGenerator::_populate_object_type_interfaces() { // which could actually will return something different. // Let's put this to notify us if that ever happens. if (itype.cname != name_cache.type_Object || imethod.name != "free") { - ERR_PRINTS("Notification: New unexpected virtual non-overridable method found." - " We only expected Object.free, but found '" + - itype.name + "." + imethod.name + "'."); + WARN_PRINTS("Notification: New unexpected virtual non-overridable method found." + " We only expected Object.free, but found '" + + itype.name + "." + imethod.name + "'."); } } else if (return_info.type == Variant::INT && return_info.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { imethod.return_type.cname = return_info.class_name; @@ -2324,7 +2332,7 @@ void BindingsGenerator::_populate_object_type_interfaces() { ERR_PRINTS("Return type is reference but hint is not '" _STR(PROPERTY_HINT_RESOURCE_TYPE) "'." " Are you returning a reference type by pointer? Method: '" + itype.name + "." + imethod.name + "'."); /* clang-format on */ - ERR_FAIL(); + ERR_FAIL_V(false); } } else if (return_info.hint == PROPERTY_HINT_RESOURCE_TYPE) { imethod.return_type.cname = return_info.hint_string; @@ -2345,8 +2353,10 @@ void BindingsGenerator::_populate_object_type_interfaces() { for (int i = 0; i < argc; i++) { PropertyInfo arginfo = method_info.arguments[i]; + String orig_arg_name = arginfo.name; + ArgumentInterface iarg; - iarg.name = arginfo.name; + iarg.name = orig_arg_name; if (arginfo.type == Variant::INT && arginfo.usage & PROPERTY_USAGE_CLASS_IS_ENUM) { iarg.type.cname = arginfo.class_name; @@ -2370,7 +2380,9 @@ void BindingsGenerator::_populate_object_type_interfaces() { iarg.name = escape_csharp_keyword(snake_to_camel_case(iarg.name)); if (m && m->has_default_argument(i)) { - _default_argument_from_variant(m->get_default_argument(i), iarg); + bool defval_ok = _arg_default_value_from_variant(m->get_default_argument(i), iarg); + ERR_FAIL_COND_V_MSG(!defval_ok, false, + "Cannot determine default value for argument '" + orig_arg_name + "' of method '" + itype.name + "." + imethod.name + "'."); } imethod.add_argument(iarg); @@ -2450,7 +2462,7 @@ void BindingsGenerator::_populate_object_type_interfaces() { const StringName &constant_cname = E->get(); String constant_name = constant_cname.operator String(); int *value = class_info->constant_map.getptr(constant_cname); - ERR_FAIL_NULL(value); + ERR_FAIL_NULL_V(value, false); constants.erase(constant_name); ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value); @@ -2486,7 +2498,7 @@ void BindingsGenerator::_populate_object_type_interfaces() { for (const List<String>::Element *E = constants.front(); E; E = E->next()) { const String &constant_name = E->get(); int *value = class_info->constant_map.getptr(StringName(E->get())); - ERR_FAIL_NULL(value); + ERR_FAIL_NULL_V(value, false); ConstantInterface iconstant(constant_name, snake_to_pascal_case(constant_name, true), *value); @@ -2507,9 +2519,11 @@ void BindingsGenerator::_populate_object_type_interfaces() { class_list.pop_front(); } + + return true; } -void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, ArgumentInterface &r_iarg) { +bool BindingsGenerator::_arg_default_value_from_variant(const Variant &p_val, ArgumentInterface &r_iarg) { r_iarg.default_argument = p_val; @@ -2555,16 +2569,24 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg r_iarg.def_param_mode = ArgumentInterface::NULLABLE_VAL; break; case Variant::OBJECT: - if (p_val.is_zero()) { - r_iarg.default_argument = "null"; - break; - } - FALLTHROUGH; + ERR_FAIL_COND_V_MSG(!p_val.is_zero(), false, + "Parameter of type '" + String(r_iarg.type.cname) + "' can only have null/zero as the default value."); + + r_iarg.default_argument = "null"; + break; case Variant::DICTIONARY: - case Variant::_RID: r_iarg.default_argument = "new %s()"; r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF; break; + case Variant::_RID: + ERR_FAIL_COND_V_MSG(r_iarg.type.cname != name_cache.type_RID, false, + "Parameter of type '" + String(r_iarg.type.cname) + "' cannot have a default value of type '" + String(name_cache.type_RID) + "'."); + + ERR_FAIL_COND_V_MSG(!p_val.is_zero(), false, + "Parameter of type '" + String(r_iarg.type.cname) + "' can only have null/zero as the default value."); + + r_iarg.default_argument = "null"; + break; case Variant::ARRAY: case Variant::POOL_BYTE_ARRAY: case Variant::POOL_INT_ARRAY: @@ -2588,6 +2610,8 @@ void BindingsGenerator::_default_argument_from_variant(const Variant &p_val, Arg if (r_iarg.def_param_mode == ArgumentInterface::CONSTANT && r_iarg.type.cname == name_cache.type_Variant && r_iarg.default_argument != "null") r_iarg.def_param_mode = ArgumentInterface::NULLABLE_REF; + + return true; } void BindingsGenerator::_populate_builtin_type_interfaces() { @@ -2973,13 +2997,17 @@ void BindingsGenerator::_log(const char *p_format, ...) { void BindingsGenerator::_initialize() { + initialized = false; + EditorHelp::generate_doc(); enum_types.clear(); _initialize_blacklisted_methods(); - _populate_object_type_interfaces(); + bool obj_type_ok = _populate_object_type_interfaces(); + ERR_FAIL_COND_MSG(!obj_type_ok, "Failed to generate object type interfaces"); + _populate_builtin_type_interfaces(); _populate_global_constants(); @@ -2991,6 +3019,8 @@ void BindingsGenerator::_initialize() { for (OrderedHashMap<StringName, TypeInterface>::Element E = obj_types.front(); E; E = E.next()) _generate_method_icalls(E.get()); + + initialized = true; } void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args) { @@ -3051,6 +3081,11 @@ void BindingsGenerator::handle_cmdline_args(const List<String> &p_cmdline_args) BindingsGenerator bindings_generator; bindings_generator.set_log_print_enabled(true); + if (!bindings_generator.initialized) { + ERR_PRINTS("Failed to initialize the bindings generator"); + ::exit(0); + } + if (glue_dir_path.length()) { if (bindings_generator.generate_glue(glue_dir_path) != OK) ERR_PRINTS(generate_all_glue_option + ": Failed to generate the C++ glue."); diff --git a/modules/mono/editor/bindings_generator.h b/modules/mono/editor/bindings_generator.h index 6f0c297575..26718f1d11 100644 --- a/modules/mono/editor/bindings_generator.h +++ b/modules/mono/editor/bindings_generator.h @@ -472,6 +472,7 @@ class BindingsGenerator { }; bool log_print_enabled; + bool initialized; OrderedHashMap<StringName, TypeInterface> obj_types; @@ -502,6 +503,7 @@ class BindingsGenerator { StringName type_VarArg; StringName type_Object; StringName type_Reference; + StringName type_RID; StringName type_String; StringName type_at_GlobalScope; StringName enum_Error; @@ -525,6 +527,7 @@ class BindingsGenerator { type_VarArg = StaticCString::create("VarArg"); type_Object = StaticCString::create("Object"); type_Reference = StaticCString::create("Reference"); + type_RID = StaticCString::create("RID"); type_String = StaticCString::create("String"); type_at_GlobalScope = StaticCString::create("@GlobalScope"); enum_Error = StaticCString::create("Error"); @@ -590,9 +593,9 @@ class BindingsGenerator { StringName _get_int_type_name_from_meta(GodotTypeInfo::Metadata p_meta); StringName _get_float_type_name_from_meta(GodotTypeInfo::Metadata p_meta); - void _default_argument_from_variant(const Variant &p_val, ArgumentInterface &r_iarg); + bool _arg_default_value_from_variant(const Variant &p_val, ArgumentInterface &r_iarg); - void _populate_object_type_interfaces(); + bool _populate_object_type_interfaces(); void _populate_builtin_type_interfaces(); void _populate_global_constants(); @@ -621,12 +624,15 @@ public: _FORCE_INLINE_ bool is_log_print_enabled() { return log_print_enabled; } _FORCE_INLINE_ void set_log_print_enabled(bool p_enabled) { log_print_enabled = p_enabled; } + _FORCE_INLINE_ bool is_initialized() { return initialized; } + static uint32_t get_version(); static void handle_cmdline_args(const List<String> &p_cmdline_args); BindingsGenerator() : - log_print_enabled(true) { + log_print_enabled(true), + initialized(false) { _initialize(); } }; diff --git a/modules/opensimplex/doc_classes/NoiseTexture.xml b/modules/opensimplex/doc_classes/NoiseTexture.xml index 4b59a380f5..07d5eb27d6 100644 --- a/modules/opensimplex/doc_classes/NoiseTexture.xml +++ b/modules/opensimplex/doc_classes/NoiseTexture.xml @@ -17,6 +17,7 @@ </member> <member name="bump_strength" type="float" setter="set_bump_strength" getter="get_bump_strength" default="8.0"> </member> + <member name="flags" type="int" setter="set_flags" getter="get_flags" override="true" default="7" /> <member name="height" type="int" setter="set_height" getter="get_height" default="512"> Height of the generated texture. </member> diff --git a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml index 9e3670ec35..b5b452ee47 100644 --- a/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml +++ b/modules/visual_script/doc_classes/VisualScriptBuiltinFunc.xml @@ -217,7 +217,9 @@ </constant> <constant name="MATH_LERP_ANGLE" value="66" enum="BuiltinFunc"> </constant> - <constant name="FUNC_MAX" value="67" enum="BuiltinFunc"> + <constant name="TEXT_ORD" value="67" enum="BuiltinFunc"> + </constant> + <constant name="FUNC_MAX" value="68" enum="BuiltinFunc"> Represents the size of the [enum BuiltinFunc] enum. </constant> </constants> diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 70389b6729..6bed1742eb 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -578,6 +578,10 @@ void VisualScript::get_data_connection_list(const StringName &p_func, List<DataC } } +void VisualScript::set_tool_enabled(bool p_enabled) { + is_tool_script = p_enabled; +} + void VisualScript::add_variable(const StringName &p_name, const Variant &p_default_value, bool p_export) { ERR_FAIL_COND(instances.size()); @@ -894,7 +898,7 @@ ScriptInstance *VisualScript::instance_create(Object *p_this) { #ifdef TOOLS_ENABLED - if (!ScriptServer::is_scripting_enabled()) { + if (!ScriptServer::is_scripting_enabled() && !is_tool_script) { PlaceHolderScriptInstance *sins = memnew(PlaceHolderScriptInstance(VisualScriptLanguage::singleton, Ref<Script>((Script *)this), p_this)); placeholders.insert(sins); @@ -958,7 +962,7 @@ Error VisualScript::reload(bool p_keep_state) { bool VisualScript::is_tool() const { - return false; + return is_tool_script; } bool VisualScript::is_valid() const { @@ -1164,6 +1168,11 @@ void VisualScript::_set_data(const Dictionary &p_data) { data_connect(name, data_connections[j + 0], data_connections[j + 1], data_connections[j + 2], data_connections[j + 3]); } } + + if (d.has("is_tool_script")) + is_tool_script = d["is_tool_script"]; + else + is_tool_script = false; } Dictionary VisualScript::_get_data() const { @@ -1246,6 +1255,8 @@ Dictionary VisualScript::_get_data() const { d["functions"] = funcs; + d["is_tool_script"] = is_tool_script; + return d; } diff --git a/modules/visual_script/visual_script.h b/modules/visual_script/visual_script.h index 098c28370d..14927c4363 100644 --- a/modules/visual_script/visual_script.h +++ b/modules/visual_script/visual_script.h @@ -247,6 +247,8 @@ private: Map<Object *, VisualScriptInstance *> instances; + bool is_tool_script; + #ifdef TOOLS_ENABLED Set<PlaceHolderScriptInstance *> placeholders; //void _update_placeholder(PlaceHolderScriptInstance *p_placeholder); @@ -273,6 +275,7 @@ public: Vector2 get_function_scroll(const StringName &p_name) const; void get_function_list(List<StringName> *r_functions) const; int get_function_node_id(const StringName &p_name) const; + void set_tool_enabled(bool p_enabled); void add_node(const StringName &p_func, int p_id, const Ref<VisualScriptNode> &p_node, const Point2 &p_pos = Point2()); void remove_node(const StringName &p_func, int p_id); diff --git a/modules/visual_script/visual_script_editor.cpp b/modules/visual_script/visual_script_editor.cpp index 8faa342bbe..7262dde359 100644 --- a/modules/visual_script/visual_script_editor.cpp +++ b/modules/visual_script/visual_script_editor.cpp @@ -2227,6 +2227,10 @@ void VisualScriptEditor::_change_base_type() { select_base_type->popup_create(true, true); } +void VisualScriptEditor::_toggle_tool_script() { + script->set_tool_enabled(!script->is_tool()); +} + void VisualScriptEditor::clear_edit_menu() { memdelete(edit_menu); memdelete(left_vsplit); @@ -3448,6 +3452,7 @@ void VisualScriptEditor::_bind_methods() { ClassDB::bind_method("_update_members", &VisualScriptEditor::_update_members); ClassDB::bind_method("_change_base_type", &VisualScriptEditor::_change_base_type); ClassDB::bind_method("_change_base_type_callback", &VisualScriptEditor::_change_base_type_callback); + ClassDB::bind_method("_toggle_tool_script", &VisualScriptEditor::_toggle_tool_script); ClassDB::bind_method("_node_selected", &VisualScriptEditor::_node_selected); ClassDB::bind_method("_node_moved", &VisualScriptEditor::_node_moved); ClassDB::bind_method("_move_node", &VisualScriptEditor::_move_node); @@ -3533,6 +3538,11 @@ VisualScriptEditor::VisualScriptEditor() { left_vb->set_v_size_flags(SIZE_EXPAND_FILL); //left_vb->set_custom_minimum_size(Size2(230, 1) * EDSCALE); + CheckButton *tool_script_check = memnew(CheckButton); + tool_script_check->set_text(TTR("Make Tool:")); + left_vb->add_child(tool_script_check); + tool_script_check->connect("pressed", this, "_toggle_tool_script"); + base_type_select = memnew(Button); left_vb->add_margin_child(TTR("Base Type:"), base_type_select); base_type_select->connect("pressed", this, "_change_base_type"); diff --git a/modules/visual_script/visual_script_editor.h b/modules/visual_script/visual_script_editor.h index 4f302d1d72..5df9b1a004 100644 --- a/modules/visual_script/visual_script_editor.h +++ b/modules/visual_script/visual_script_editor.h @@ -186,6 +186,7 @@ class VisualScriptEditor : public ScriptEditorBase { void _node_filter_changed(const String &p_text); void _change_base_type_callback(); void _change_base_type(); + void _toggle_tool_script(); void _member_selected(); void _member_edited(); diff --git a/modules/webrtc/doc_classes/WebRTCMultiplayer.xml b/modules/webrtc/doc_classes/WebRTCMultiplayer.xml index 2b0622fffa..605b1ef082 100644 --- a/modules/webrtc/doc_classes/WebRTCMultiplayer.xml +++ b/modules/webrtc/doc_classes/WebRTCMultiplayer.xml @@ -80,6 +80,10 @@ </description> </method> </methods> + <members> + <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" /> + <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="NetworkedMultiplayerPeer.TransferMode" default="2" /> + </members> <constants> </constants> </class> diff --git a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml index b80a28e648..7070cfbdab 100644 --- a/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml +++ b/modules/websocket/doc_classes/WebSocketMultiplayerPeer.xml @@ -37,6 +37,10 @@ </description> </method> </methods> + <members> + <member name="refuse_new_connections" type="bool" setter="set_refuse_new_connections" getter="is_refusing_new_connections" override="true" default="false" /> + <member name="transfer_mode" type="int" setter="set_transfer_mode" getter="get_transfer_mode" override="true" enum="NetworkedMultiplayerPeer.TransferMode" default="2" /> + </members> <signals> <signal name="peer_packet"> <argument index="0" name="peer_source" type="int"> diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp index 567f7e7b09..b37f04c4f8 100644 --- a/platform/android/export/export.cpp +++ b/platform/android/export/export.cpp @@ -1308,7 +1308,7 @@ public: r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/support_xlarge"), true)); r_options->push_back(ExportOption(PropertyInfo(Variant::BOOL, "screen/opengl_debug"), false)); - for (unsigned int i = 0; i < sizeof(launcher_icons) / sizeof(launcher_icons[0]); ++i) { + for (uint64_t i = 0; i < sizeof(launcher_icons) / sizeof(launcher_icons[0]); ++i) { r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, launcher_icons[i].option_id, PROPERTY_HINT_FILE, "*.png"), "")); } @@ -1537,7 +1537,7 @@ public: args.push_back("-a"); args.push_back("android.intent.action.MAIN"); args.push_back("-n"); - args.push_back(get_package_name(package_name) + "/org.godotengine.godot.Godot"); + args.push_back(get_package_name(package_name) + "/com.godot.game.GodotApp"); err = OS::get_singleton()->execute(adb, args, true, NULL, NULL, &rv); if (err || rv != 0) { @@ -2100,7 +2100,7 @@ public: if (file == "res/drawable-nodpi-v4/icon.png") { bool found = false; - for (unsigned int i = 0; i < sizeof(launcher_icons) / sizeof(launcher_icons[0]); ++i) { + for (uint64_t i = 0; i < sizeof(launcher_icons) / sizeof(launcher_icons[0]); ++i) { String icon_path = String(p_preset->get(launcher_icons[i].option_id)).strip_edges(); if (icon_path != "" && icon_path.ends_with(".png")) { FileAccess *f = FileAccess::open(icon_path, FileAccess::READ); @@ -2226,7 +2226,7 @@ public: APKExportData ed; ed.ep = &ep; ed.apk = unaligned_apk; - for (unsigned int i = 0; i < sizeof(launcher_icons) / sizeof(launcher_icons[0]); ++i) { + for (uint64_t i = 0; i < sizeof(launcher_icons) / sizeof(launcher_icons[0]); ++i) { String icon_path = String(p_preset->get(launcher_icons[i].option_id)).strip_edges(); if (icon_path != "" && icon_path.ends_with(".png") && FileAccess::exists(icon_path)) { Vector<uint8_t> data = FileAccess::get_file_as_array(icon_path); diff --git a/platform/android/java/app/src/com/godot/game/GodotApp.java b/platform/android/java/app/src/com/godot/game/GodotApp.java index fabd7b1dbb..d7469a8765 100644 --- a/platform/android/java/app/src/com/godot/game/GodotApp.java +++ b/platform/android/java/app/src/com/godot/game/GodotApp.java @@ -1,3 +1,33 @@ +/*************************************************************************/ +/* GodotApp.java */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 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. */ +/*************************************************************************/ + package com.godot.game; import org.godotengine.godot.Godot; diff --git a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java index a443a0ad90..2beca67922 100644 --- a/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java +++ b/platform/android/java/lib/src/org/godotengine/godot/input/GodotInputHandler.java @@ -96,7 +96,6 @@ public class GodotInputHandler implements InputDeviceListener { GodotLib.joybutton(device_id, button, false); } }); - return true; } } else { final int chr = event.getUnicodeChar(0); @@ -108,7 +107,7 @@ public class GodotInputHandler implements InputDeviceListener { }); }; - return false; + return true; } public boolean onKeyDown(final int keyCode, KeyEvent event) { @@ -142,7 +141,6 @@ public class GodotInputHandler implements InputDeviceListener { GodotLib.joybutton(device_id, button, true); } }); - return true; } } else { final int chr = event.getUnicodeChar(0); @@ -154,7 +152,7 @@ public class GodotInputHandler implements InputDeviceListener { }); }; - return false; + return true; } public boolean onGenericMotionEvent(MotionEvent event) { diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index 1cbf4d6a70..99fbe989df 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -287,7 +287,7 @@ void EditorExportPlatformIOS::get_export_options(List<ExportOption> *r_options) r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_40x40", PROPERTY_HINT_FILE, "*.png"), "")); // Spotlight r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, "optional_icons/spotlight_80x80", PROPERTY_HINT_FILE, "*.png"), "")); // Spotlight on devices with retina display - for (unsigned int i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) { + for (uint64_t i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) { r_options->push_back(ExportOption(PropertyInfo(Variant::STRING, loading_screen_infos[i].preset_key, PROPERTY_HINT_FILE, "*.png"), "")); } @@ -489,7 +489,7 @@ Error EditorExportPlatformIOS::_export_icons(const Ref<EditorExportPreset> &p_pr DirAccess *da = DirAccess::open(p_iconset_dir); ERR_FAIL_COND_V(!da, ERR_CANT_OPEN); - for (unsigned int i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) { + for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) { IconInfo info = icon_infos[i]; String icon_path = p_preset->get(info.preset_key); if (icon_path.length() == 0) { @@ -539,7 +539,7 @@ Error EditorExportPlatformIOS::_export_loading_screens(const Ref<EditorExportPre DirAccess *da = DirAccess::open(p_dest_dir); ERR_FAIL_COND_V(!da, ERR_CANT_OPEN); - for (unsigned int i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) { + for (uint64_t i = 0; i < sizeof(loading_screen_infos) / sizeof(loading_screen_infos[0]); ++i) { LoadingScreenInfo info = loading_screen_infos[i]; String loading_screen_file = p_preset->get(info.preset_key); if (loading_screen_file.size() > 0) { @@ -626,7 +626,7 @@ private: static String _hex_pad(uint32_t num) { Vector<char> ret; ret.resize(sizeof(num) * 2); - for (unsigned int i = 0; i < sizeof(num) * 2; ++i) { + for (uint64_t i = 0; i < sizeof(num) * 2; ++i) { uint8_t four_bits = (num >> (sizeof(num) * 8 - (i + 1) * 4)) & 0xF; ret.write[i] = _hex_char(four_bits); } @@ -1169,7 +1169,7 @@ bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset valid = false; } - for (unsigned int i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) { + for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) { IconInfo info = icon_infos[i]; String icon_path = p_preset->get(info.preset_key); if (icon_path.length() == 0) { diff --git a/platform/iphone/gl_view.mm b/platform/iphone/gl_view.mm index 4641b2c4ac..dfca2e3dd7 100644 --- a/platform/iphone/gl_view.mm +++ b/platform/iphone/gl_view.mm @@ -337,12 +337,9 @@ static void clear_touches() { // the same size as our display area. - (void)layoutSubviews { - //printf("HERE\n"); [EAGLContext setCurrentContext:context]; [self destroyFramebuffer]; [self createFramebuffer]; - [self drawView]; - [self drawView]; } - (BOOL)createFramebuffer { diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 56b0a44dbc..94090bcdc1 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -240,7 +240,7 @@ void EditorExportPlatformOSX::_make_icon(const Ref<Image> &p_icon, Vector<uint8_ { "is32", "s8mk", false, 16 } //16x16 24-bit RLE + 8-bit uncompressed mask }; - for (unsigned int i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) { + for (uint64_t i = 0; i < (sizeof(icon_infos) / sizeof(icon_infos[0])); ++i) { Ref<Image> copy = p_icon; // does this make sense? doesn't this just increase the reference count instead of making a copy? Do we even need a copy? copy->convert(Image::FORMAT_RGBA8); copy->resize(icon_infos[i].size, icon_infos[i].size); diff --git a/platform/uwp/export/export.cpp b/platform/uwp/export/export.cpp index ea110b11ca..bb18c2da8a 100644 --- a/platform/uwp/export/export.cpp +++ b/platform/uwp/export/export.cpp @@ -500,7 +500,7 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t size_t block_size = (p_len - step) > BLOCK_SIZE ? (size_t)BLOCK_SIZE : (p_len - step); - for (uint32_t i = 0; i < block_size; i++) { + for (uint64_t i = 0; i < block_size; i++) { strm_in.write[i] = p_buffer[step + i]; } @@ -524,14 +524,14 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t //package->store_buffer(strm_out.ptr(), strm.total_out - total_out_before); int start = file_buffer.size(); file_buffer.resize(file_buffer.size() + bh.compressed_size); - for (uint32_t i = 0; i < bh.compressed_size; i++) + for (uint64_t i = 0; i < bh.compressed_size; i++) file_buffer.write[start + i] = strm_out[i]; } else { bh.compressed_size = block_size; //package->store_buffer(strm_in.ptr(), block_size); int start = file_buffer.size(); file_buffer.resize(file_buffer.size() + block_size); - for (uint32_t i = 0; i < bh.compressed_size; i++) + for (uint64_t i = 0; i < bh.compressed_size; i++) file_buffer.write[start + i] = strm_in[i]; } @@ -554,7 +554,7 @@ Error AppxPackager::add_file(String p_file_name, const uint8_t *p_buffer, size_t //package->store_buffer(strm_out.ptr(), strm.total_out - total_out_before); int start = file_buffer.size(); file_buffer.resize(file_buffer.size() + (strm.total_out - total_out_before)); - for (uint32_t i = 0; i < (strm.total_out - total_out_before); i++) + for (uint64_t i = 0; i < (strm.total_out - total_out_before); i++) file_buffer.write[start + i] = strm_out[i]; deflateEnd(&strm); diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 20502b61d9..687981f32b 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -1566,7 +1566,7 @@ bool OS_X11::is_window_maximize_allowed() { bool found_wm_act_max_horz = false; bool found_wm_act_max_vert = false; - for (unsigned int i = 0; i < len; i++) { + for (uint64_t i = 0; i < len; i++) { if (atoms[i] == wm_act_max_horz) found_wm_act_max_horz = true; if (atoms[i] == wm_act_max_vert) @@ -1612,7 +1612,7 @@ bool OS_X11::is_window_maximized() const { bool found_wm_max_horz = false; bool found_wm_max_vert = false; - for (unsigned int i = 0; i < len; i++) { + for (uint64_t i = 0; i < len; i++) { if (atoms[i] == wm_max_horz) found_wm_max_horz = true; if (atoms[i] == wm_max_vert) @@ -3028,7 +3028,7 @@ void OS_X11::alert(const String &p_alert, const String &p_title) { String program; for (int i = 0; i < path_elems.size(); i++) { - for (unsigned int k = 0; k < sizeof(message_programs) / sizeof(char *); k++) { + for (uint64_t k = 0; k < sizeof(message_programs) / sizeof(char *); k++) { String tested_path = path_elems[i].plus_file(message_programs[k]); if (FileAccess::exists(tested_path)) { diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index fc5e5cbba2..b38fbfe981 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -602,9 +602,7 @@ void CanvasItem::_notification(int p_what) { } global_invalid = true; } break; - case NOTIFICATION_DRAW: { - - } break; + case NOTIFICATION_DRAW: case NOTIFICATION_TRANSFORM_CHANGED: { } break; diff --git a/scene/2d/navigation_polygon.cpp b/scene/2d/navigation_polygon.cpp index e389d5f98f..678db85ff0 100644 --- a/scene/2d/navigation_polygon.cpp +++ b/scene/2d/navigation_polygon.cpp @@ -271,7 +271,7 @@ void NavigationPolygon::make_polygons_from_outlines() { struct Polygon p; - for (int i = 0; i < tp.GetNumPoints(); i++) { + for (int64_t i = 0; i < tp.GetNumPoints(); i++) { Map<Vector2, int>::Element *E = points.find(tp[i]); if (!E) { diff --git a/scene/3d/audio_stream_player_3d.cpp b/scene/3d/audio_stream_player_3d.cpp index 27f16f7601..05ae281cc1 100644 --- a/scene/3d/audio_stream_player_3d.cpp +++ b/scene/3d/audio_stream_player_3d.cpp @@ -836,6 +836,7 @@ void AudioStreamPlayer3D::set_emission_angle(float p_angle) { ERR_FAIL_COND(p_angle < 0 || p_angle > 90); emission_angle = p_angle; update_gizmo(); + _change_notify("emission_angle"); } float AudioStreamPlayer3D::get_emission_angle() const { diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp index c5ff4dadbc..b70e6dbc5d 100644 --- a/scene/3d/baked_lightmap.cpp +++ b/scene/3d/baked_lightmap.cpp @@ -215,6 +215,7 @@ float BakedLightmap::get_capture_cell_size() const { void BakedLightmap::set_extents(const Vector3 &p_extents) { extents = p_extents; update_gizmo(); + _change_notify("bake_extents"); } Vector3 BakedLightmap::get_extents() const { diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index a04f156d80..ccc87b924c 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -243,6 +243,7 @@ void GIProbe::set_extents(const Vector3 &p_extents) { extents = p_extents; update_gizmo(); + _change_notify("extents"); } Vector3 GIProbe::get_extents() const { diff --git a/scene/3d/mesh_instance.cpp b/scene/3d/mesh_instance.cpp index 89072519d5..50ca466df3 100644 --- a/scene/3d/mesh_instance.cpp +++ b/scene/3d/mesh_instance.cpp @@ -149,12 +149,38 @@ Ref<Mesh> MeshInstance::get_mesh() const { void MeshInstance::_resolve_skeleton_path() { - if (skeleton_path.is_empty()) + Ref<SkinReference> new_skin_reference; + + if (!skeleton_path.is_empty()) { + Skeleton *skeleton = Object::cast_to<Skeleton>(get_node(skeleton_path)); + if (skeleton) { + new_skin_reference = skeleton->register_skin(skin); + if (skin.is_null()) { + //a skin was created for us + skin = new_skin_reference->get_skin(); + _change_notify(); + } + } + } + + skin_ref = new_skin_reference; + + if (skin_ref.is_valid()) { + VisualServer::get_singleton()->instance_attach_skeleton(get_instance(), skin_ref->get_skeleton()); + } else { + VisualServer::get_singleton()->instance_attach_skeleton(get_instance(), RID()); + } +} + +void MeshInstance::set_skin(const Ref<Skin> &p_skin) { + skin = p_skin; + if (!is_inside_tree()) return; + _resolve_skeleton_path(); +} - Skeleton *skeleton = Object::cast_to<Skeleton>(get_node(skeleton_path)); - if (skeleton) - VisualServer::get_singleton()->instance_attach_skeleton(get_instance(), skeleton->get_skeleton()); +Ref<Skin> MeshInstance::get_skin() const { + return skin; } void MeshInstance::set_skeleton_path(const NodePath &p_skeleton) { @@ -365,6 +391,8 @@ void MeshInstance::_bind_methods() { ClassDB::bind_method(D_METHOD("get_mesh"), &MeshInstance::get_mesh); ClassDB::bind_method(D_METHOD("set_skeleton_path", "skeleton_path"), &MeshInstance::set_skeleton_path); ClassDB::bind_method(D_METHOD("get_skeleton_path"), &MeshInstance::get_skeleton_path); + ClassDB::bind_method(D_METHOD("set_skin", "skin"), &MeshInstance::set_skin); + ClassDB::bind_method(D_METHOD("get_skin"), &MeshInstance::get_skin); ClassDB::bind_method(D_METHOD("get_surface_material_count"), &MeshInstance::get_surface_material_count); ClassDB::bind_method(D_METHOD("set_surface_material", "surface", "material"), &MeshInstance::set_surface_material); @@ -380,6 +408,7 @@ void MeshInstance::_bind_methods() { ClassDB::set_method_flags("MeshInstance", "create_debug_tangents", METHOD_FLAGS_DEFAULT | METHOD_FLAG_EDITOR); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "skin", PROPERTY_HINT_RESOURCE_TYPE, "Skin"), "set_skin", "get_skin"); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton"), "set_skeleton_path", "get_skeleton_path"); } diff --git a/scene/3d/mesh_instance.h b/scene/3d/mesh_instance.h index 8b690b0c21..77ead75dd3 100644 --- a/scene/3d/mesh_instance.h +++ b/scene/3d/mesh_instance.h @@ -31,8 +31,10 @@ #ifndef MESH_INSTANCE_H #define MESH_INSTANCE_H +#include "scene/3d/skeleton.h" #include "scene/3d/visual_instance.h" #include "scene/resources/mesh.h" +#include "scene/resources/skin.h" class MeshInstance : public GeometryInstance { @@ -40,6 +42,8 @@ class MeshInstance : public GeometryInstance { protected: Ref<Mesh> mesh; + Ref<Skin> skin; + Ref<SkinReference> skin_ref; NodePath skeleton_path; struct BlendShapeTrack { @@ -70,6 +74,9 @@ public: void set_mesh(const Ref<Mesh> &p_mesh); Ref<Mesh> get_mesh() const; + void set_skin(const Ref<Skin> &p_skin); + Ref<Skin> get_skin() const; + void set_skeleton_path(const NodePath &p_skeleton); NodePath get_skeleton_path(); diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 8db1e883e6..71040d2d68 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -2182,7 +2182,7 @@ void PhysicalBone::_notification(int p_what) { void PhysicalBone::_direct_state_changed(Object *p_state) { - if (!simulate_physics) { + if (!simulate_physics || !_internal_simulate_physics) { return; } @@ -2205,7 +2205,7 @@ void PhysicalBone::_direct_state_changed(Object *p_state) { // Update skeleton if (parent_skeleton) { if (-1 != bone_id) { - parent_skeleton->set_bone_global_pose(bone_id, parent_skeleton->get_global_transform().affine_inverse() * (global_transform * body_offset_inverse)); + parent_skeleton->set_bone_global_pose_override(bone_id, parent_skeleton->get_global_transform().affine_inverse() * (global_transform * body_offset_inverse), 1.0, true); } } } @@ -2716,7 +2716,6 @@ void PhysicalBone::_start_physics_simulation() { PhysicsServer::get_singleton()->body_set_collision_layer(get_rid(), get_collision_layer()); PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(), get_collision_mask()); PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), this, "_direct_state_changed"); - parent_skeleton->set_bone_ignore_animation(bone_id, true); _internal_simulate_physics = true; } @@ -2728,6 +2727,6 @@ void PhysicalBone::_stop_physics_simulation() { PhysicsServer::get_singleton()->body_set_collision_layer(get_rid(), 0); PhysicsServer::get_singleton()->body_set_collision_mask(get_rid(), 0); PhysicsServer::get_singleton()->body_set_force_integration_callback(get_rid(), NULL, ""); - parent_skeleton->set_bone_ignore_animation(bone_id, false); + parent_skeleton->set_bone_global_pose_override(bone_id, Transform(), 0.0, false); _internal_simulate_physics = false; } diff --git a/scene/3d/skeleton.cpp b/scene/3d/skeleton.cpp index e192e040f2..ead1e69f90 100644 --- a/scene/3d/skeleton.cpp +++ b/scene/3d/skeleton.cpp @@ -36,6 +36,34 @@ #include "scene/3d/physics_body.h" #include "scene/resources/surface_tool.h" +void SkinReference::_skin_changed() { + if (skeleton_node) { + skeleton_node->_make_dirty(); + } +} + +void SkinReference::_bind_methods() { + ClassDB::bind_method(D_METHOD("_skin_changed"), &SkinReference::_skin_changed); + ClassDB::bind_method(D_METHOD("get_skeleton"), &SkinReference::get_skeleton); + ClassDB::bind_method(D_METHOD("get_skin"), &SkinReference::get_skin); +} + +RID SkinReference::get_skeleton() const { + return skeleton; +} + +Ref<Skin> SkinReference::get_skin() const { + return skin; +} + +SkinReference::~SkinReference() { + if (skeleton_node) { + skeleton_node->skin_bindings.erase(this); + } + + VS::get_singleton()->free(skeleton); +} + bool Skeleton::_set(const StringName &p_path, const Variant &p_value) { String path = p_path; @@ -196,110 +224,77 @@ void Skeleton::_notification(int p_what) { switch (p_what) { - case NOTIFICATION_ENTER_WORLD: { - - VS::get_singleton()->skeleton_set_world_transform(skeleton, use_bones_in_world_transform, get_global_transform()); - - } break; - case NOTIFICATION_EXIT_WORLD: { - - } break; - case NOTIFICATION_TRANSFORM_CHANGED: { - - VS::get_singleton()->skeleton_set_world_transform(skeleton, use_bones_in_world_transform, get_global_transform()); - } break; case NOTIFICATION_UPDATE_SKELETON: { VisualServer *vs = VisualServer::get_singleton(); Bone *bonesptr = bones.ptrw(); int len = bones.size(); - vs->skeleton_allocate(skeleton, len); // if same size, nothing really happens - _update_process_order(); const int *order = process_order.ptr(); - // pose changed, rebuild cache of inverses - if (rest_global_inverse_dirty) { - - // calculate global rests and invert them - for (int i = 0; i < len; i++) { - Bone &b = bonesptr[order[i]]; - if (b.parent >= 0) - b.rest_global_inverse = bonesptr[b.parent].rest_global_inverse * b.rest; - else - b.rest_global_inverse = b.rest; - } - for (int i = 0; i < len; i++) { - Bone &b = bonesptr[order[i]]; - b.rest_global_inverse.affine_invert(); - } - - rest_global_inverse_dirty = false; - } - for (int i = 0; i < len; i++) { Bone &b = bonesptr[order[i]]; - if (b.disable_rest) { - if (b.enabled) { + if (b.global_pose_override_amount >= 0.999) { + b.pose_global = b.global_pose_override; + } else { + if (b.disable_rest) { + if (b.enabled) { - Transform pose = b.pose; - if (b.custom_pose_enable) { + Transform pose = b.pose; + if (b.parent >= 0) { - pose = b.custom_pose * pose; - } + b.pose_global = bonesptr[b.parent].pose_global * pose; + } else { - if (b.parent >= 0) { - - b.pose_global = bonesptr[b.parent].pose_global * pose; + b.pose_global = pose; + } } else { - b.pose_global = pose; - } - } else { - - if (b.parent >= 0) { + if (b.parent >= 0) { - b.pose_global = bonesptr[b.parent].pose_global; - } else { + b.pose_global = bonesptr[b.parent].pose_global; + } else { - b.pose_global = Transform(); + b.pose_global = Transform(); + } } - } - } else { - if (b.enabled) { + } else { + if (b.enabled) { - Transform pose = b.pose; - if (b.custom_pose_enable) { + Transform pose = b.pose; - pose = b.custom_pose * pose; - } + if (b.parent >= 0) { - if (b.parent >= 0) { + b.pose_global = bonesptr[b.parent].pose_global * (b.rest * pose); + } else { - b.pose_global = bonesptr[b.parent].pose_global * (b.rest * pose); + b.pose_global = b.rest * pose; + } } else { - b.pose_global = b.rest * pose; - } - } else { + if (b.parent >= 0) { - if (b.parent >= 0) { + b.pose_global = bonesptr[b.parent].pose_global * b.rest; + } else { - b.pose_global = bonesptr[b.parent].pose_global * b.rest; - } else { - - b.pose_global = b.rest; + b.pose_global = b.rest; + } } } + + if (b.global_pose_override_amount >= CMP_EPSILON) { + b.pose_global = b.pose_global.interpolate_with(b.global_pose_override, b.global_pose_override_amount); + } } - b.transform_final = b.pose_global * b.rest_global_inverse; - vs->skeleton_bone_set_transform(skeleton, order[i], b.transform_final); + if (b.global_pose_override_reset) { + b.global_pose_override_amount = 0.0; + } for (List<uint32_t>::Element *E = b.nodes_bound.front(); E; E = E->next()) { @@ -311,28 +306,37 @@ void Skeleton::_notification(int p_what) { } } + //update skins + for (Set<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) { + + const Skin *skin = E->get()->skin.operator->(); + RID skeleton = E->get()->skeleton; + uint32_t bind_count = skin->get_bind_count(); + + if (E->get()->bind_count != bind_count) { + VS::get_singleton()->skeleton_allocate(skeleton, bind_count); + E->get()->bind_count = bind_count; + } + + for (uint32_t i = 0; i < bind_count; i++) { + uint32_t bone_index = skin->get_bind_bone(i); + ERR_CONTINUE(bone_index >= (uint32_t)len); + vs->skeleton_bone_set_transform(skeleton, i, bonesptr[bone_index].pose_global * skin->get_bind_pose(i)); + } + } + dirty = false; } break; } } -Transform Skeleton::get_bone_transform(int p_bone) const { - ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); - if (dirty) - const_cast<Skeleton *>(this)->notification(NOTIFICATION_UPDATE_SKELETON); - return bones[p_bone].pose_global * bones[p_bone].rest_global_inverse; -} - -void Skeleton::set_bone_global_pose(int p_bone, const Transform &p_pose) { +void Skeleton::set_bone_global_pose_override(int p_bone, const Transform &p_pose, float p_amount, bool p_persistent) { ERR_FAIL_INDEX(p_bone, bones.size()); - if (bones[p_bone].parent == -1) { - - set_bone_pose(p_bone, bones[p_bone].rest_global_inverse * p_pose); //fast - } else { - - set_bone_pose(p_bone, bones[p_bone].rest.affine_inverse() * (get_bone_global_pose(bones[p_bone].parent).affine_inverse() * p_pose)); //slow - } + bones.write[p_bone].global_pose_override_amount = p_amount; + bones.write[p_bone].global_pose_override = p_pose; + bones.write[p_bone].global_pose_override_reset = !p_persistent; + _make_dirty(); } Transform Skeleton::get_bone_global_pose(int p_bone) const { @@ -343,11 +347,6 @@ Transform Skeleton::get_bone_global_pose(int p_bone) const { return bones[p_bone].pose_global; } -RID Skeleton::get_skeleton() const { - - return skeleton; -} - // skeleton creation api void Skeleton::add_bone(const String &p_name) { @@ -362,8 +361,6 @@ void Skeleton::add_bone(const String &p_name) { b.name = p_name; bones.push_back(b); process_order_dirty = true; - - rest_global_inverse_dirty = true; _make_dirty(); update_gizmo(); } @@ -408,7 +405,6 @@ void Skeleton::set_bone_parent(int p_bone, int p_parent) { ERR_FAIL_COND(p_parent != -1 && (p_parent < 0)); bones.write[p_bone].parent = p_parent; - rest_global_inverse_dirty = true; process_order_dirty = true; _make_dirty(); } @@ -426,23 +422,11 @@ void Skeleton::unparent_bone_and_rest(int p_bone) { } bones.write[p_bone].parent = -1; - bones.write[p_bone].rest_global_inverse = bones[p_bone].rest.affine_inverse(); //same thing process_order_dirty = true; _make_dirty(); } -void Skeleton::set_bone_ignore_animation(int p_bone, bool p_ignore) { - ERR_FAIL_INDEX(p_bone, bones.size()); - bones.write[p_bone].ignore_animation = p_ignore; -} - -bool Skeleton::is_bone_ignore_animation(int p_bone) const { - - ERR_FAIL_INDEX_V(p_bone, bones.size(), false); - return bones[p_bone].ignore_animation; -} - void Skeleton::set_bone_disable_rest(int p_bone, bool p_disable) { ERR_FAIL_INDEX(p_bone, bones.size()); @@ -467,7 +451,6 @@ void Skeleton::set_bone_rest(int p_bone, const Transform &p_rest) { ERR_FAIL_INDEX(p_bone, bones.size()); bones.write[p_bone].rest = p_rest; - rest_global_inverse_dirty = true; _make_dirty(); } Transform Skeleton::get_bone_rest(int p_bone) const { @@ -482,7 +465,6 @@ void Skeleton::set_bone_enabled(int p_bone, bool p_enabled) { ERR_FAIL_INDEX(p_bone, bones.size()); bones.write[p_bone].enabled = p_enabled; - rest_global_inverse_dirty = true; _make_dirty(); } bool Skeleton::is_bone_enabled(int p_bone) const { @@ -529,7 +511,6 @@ void Skeleton::get_bound_child_nodes_to_bone(int p_bone, List<Node *> *p_bound) void Skeleton::clear_bones() { bones.clear(); - rest_global_inverse_dirty = true; process_order_dirty = true; _make_dirty(); @@ -552,23 +533,6 @@ Transform Skeleton::get_bone_pose(int p_bone) const { return bones[p_bone].pose; } -void Skeleton::set_bone_custom_pose(int p_bone, const Transform &p_custom_pose) { - - ERR_FAIL_INDEX(p_bone, bones.size()); - //ERR_FAIL_COND( !is_inside_scene() ); - - bones.write[p_bone].custom_pose_enable = (p_custom_pose != Transform()); - bones.write[p_bone].custom_pose = p_custom_pose; - - _make_dirty(); -} - -Transform Skeleton::get_bone_custom_pose(int p_bone) const { - - ERR_FAIL_INDEX_V(p_bone, bones.size(), Transform()); - return bones[p_bone].custom_pose; -} - void Skeleton::_make_dirty() { if (dirty) @@ -747,14 +711,66 @@ void Skeleton::physical_bones_remove_collision_exception(RID p_exception) { #endif // _3D_DISABLED -void Skeleton::set_use_bones_in_world_transform(bool p_enable) { - use_bones_in_world_transform = p_enable; - if (is_inside_tree()) { - VS::get_singleton()->skeleton_set_world_transform(skeleton, use_bones_in_world_transform, get_global_transform()); - } +void Skeleton::_skin_changed() { + _make_dirty(); } -bool Skeleton::is_using_bones_in_world_transform() const { - return use_bones_in_world_transform; + +Ref<SkinReference> Skeleton::register_skin(const Ref<Skin> &p_skin) { + + for (Set<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) { + if (E->get()->skin == p_skin) { + return Ref<SkinReference>(E->get()); + } + } + + Ref<Skin> skin = p_skin; + + if (skin.is_null()) { + //need to create one from existing code, this is for compatibility only + //when skeletons did not support skins. It is also used by gizmo + //to display the skeleton. + + skin.instance(); + skin->set_bind_count(bones.size()); + _update_process_order(); //just in case + + // pose changed, rebuild cache of inverses + const Bone *bonesptr = bones.ptr(); + int len = bones.size(); + const int *order = process_order.ptr(); + + // calculate global rests and invert them + for (int i = 0; i < len; i++) { + const Bone &b = bonesptr[order[i]]; + if (b.parent >= 0) { + skin->set_bind_pose(order[i], skin->get_bind_pose(b.parent) * b.rest); + } else { + skin->set_bind_pose(order[i], b.rest); + } + } + + for (int i = 0; i < len; i++) { + //the inverse is what is actually required + skin->set_bind_bone(i, i); + skin->set_bind_pose(i, skin->get_bind_pose(i).affine_inverse()); + } + } + + ERR_FAIL_COND_V(skin.is_null(), Ref<SkinReference>()); + + Ref<SkinReference> skin_ref; + skin_ref.instance(); + + skin_ref->skeleton_node = this; + skin_ref->bind_count = 0; + skin_ref->skeleton = VisualServer::get_singleton()->skeleton_create(); + skin_ref->skeleton_node = this; + skin_ref->skin = skin; + + skin_bindings.insert(skin_ref.operator->()); + + skin->connect("changed", skin_ref.operator->(), "_skin_changed"); + return skin_ref; } void Skeleton::_bind_methods() { @@ -773,6 +789,8 @@ void Skeleton::_bind_methods() { ClassDB::bind_method(D_METHOD("get_bone_rest", "bone_idx"), &Skeleton::get_bone_rest); ClassDB::bind_method(D_METHOD("set_bone_rest", "bone_idx", "rest"), &Skeleton::set_bone_rest); + ClassDB::bind_method(D_METHOD("register_skin", "skin"), &Skeleton::register_skin); + ClassDB::bind_method(D_METHOD("localize_rests"), &Skeleton::localize_rests); ClassDB::bind_method(D_METHOD("set_bone_disable_rest", "bone_idx", "disable"), &Skeleton::set_bone_disable_rest); @@ -787,17 +805,9 @@ void Skeleton::_bind_methods() { ClassDB::bind_method(D_METHOD("get_bone_pose", "bone_idx"), &Skeleton::get_bone_pose); ClassDB::bind_method(D_METHOD("set_bone_pose", "bone_idx", "pose"), &Skeleton::set_bone_pose); - ClassDB::bind_method(D_METHOD("set_bone_global_pose", "bone_idx", "pose"), &Skeleton::set_bone_global_pose); + ClassDB::bind_method(D_METHOD("set_bone_global_pose_override", "bone_idx", "pose", "amount", "persistent"), &Skeleton::set_bone_global_pose_override, DEFVAL(false)); ClassDB::bind_method(D_METHOD("get_bone_global_pose", "bone_idx"), &Skeleton::get_bone_global_pose); - ClassDB::bind_method(D_METHOD("get_bone_custom_pose", "bone_idx"), &Skeleton::get_bone_custom_pose); - ClassDB::bind_method(D_METHOD("set_bone_custom_pose", "bone_idx", "custom_pose"), &Skeleton::set_bone_custom_pose); - - ClassDB::bind_method(D_METHOD("get_bone_transform", "bone_idx"), &Skeleton::get_bone_transform); - - ClassDB::bind_method(D_METHOD("set_use_bones_in_world_transform", "enable"), &Skeleton::set_use_bones_in_world_transform); - ClassDB::bind_method(D_METHOD("is_using_bones_in_world_transform"), &Skeleton::is_using_bones_in_world_transform); - #ifndef _3D_DISABLED ClassDB::bind_method(D_METHOD("physical_bones_stop_simulation"), &Skeleton::physical_bones_stop_simulation); @@ -807,22 +817,19 @@ void Skeleton::_bind_methods() { #endif // _3D_DISABLED - ClassDB::bind_method(D_METHOD("set_bone_ignore_animation", "bone", "ignore"), &Skeleton::set_bone_ignore_animation); - - ADD_PROPERTY(PropertyInfo(Variant::BOOL, "bones_in_world_transform"), "set_use_bones_in_world_transform", "is_using_bones_in_world_transform"); BIND_CONSTANT(NOTIFICATION_UPDATE_SKELETON); } Skeleton::Skeleton() { - rest_global_inverse_dirty = true; dirty = false; process_order_dirty = true; - skeleton = VisualServer::get_singleton()->skeleton_create(); - set_notify_transform(true); - use_bones_in_world_transform = false; } Skeleton::~Skeleton() { - VisualServer::get_singleton()->free(skeleton); + + //some skins may remain bound + for (Set<SkinReference *>::Element *E = skin_bindings.front(); E; E = E->next()) { + E->get()->skeleton_node = nullptr; + } } diff --git a/scene/3d/skeleton.h b/scene/3d/skeleton.h index 5b55dffbc8..f20c550055 100644 --- a/scene/3d/skeleton.h +++ b/scene/3d/skeleton.h @@ -33,6 +33,7 @@ #include "core/rid.h" #include "scene/3d/spatial.h" +#include "scene/resources/skin.h" #ifndef _3D_DISABLED typedef int BoneId; @@ -40,10 +41,38 @@ typedef int BoneId; class PhysicalBone; #endif // _3D_DISABLED +class Skeleton; + +class SkinReference : public Reference { + GDCLASS(SkinReference, Reference) + friend class Skeleton; + + Skeleton *skeleton_node; + RID skeleton; + Ref<Skin> skin; + uint32_t bind_count = 0; + void _skin_changed(); + +protected: + static void _bind_methods(); + +public: + RID get_skeleton() const; + Ref<Skin> get_skin() const; + ~SkinReference(); +}; + class Skeleton : public Spatial { GDCLASS(Skeleton, Spatial); +private: + friend class SkinReference; + + Set<SkinReference *> skin_bindings; + + void _skin_changed(); + struct Bone { String name; @@ -52,19 +81,15 @@ class Skeleton : public Spatial { int parent; int sort_index; //used for re-sorting process order - bool ignore_animation; - bool disable_rest; Transform rest; - Transform rest_global_inverse; Transform pose; Transform pose_global; - bool custom_pose_enable; - Transform custom_pose; - - Transform transform_final; + float global_pose_override_amount; + bool global_pose_override_reset; + Transform global_pose_override; #ifndef _3D_DISABLED PhysicalBone *physical_bone; @@ -76,9 +101,9 @@ class Skeleton : public Spatial { Bone() { parent = -1; enabled = true; - ignore_animation = false; - custom_pose_enable = false; disable_rest = false; + global_pose_override_amount = 0; + global_pose_override_reset = false; #ifndef _3D_DISABLED physical_bone = NULL; cache_parent_physical_bone = NULL; @@ -86,17 +111,12 @@ class Skeleton : public Spatial { } }; - bool rest_global_inverse_dirty; - Vector<Bone> bones; Vector<int> process_order; bool process_order_dirty; - RID skeleton; - void _make_dirty(); bool dirty; - bool use_bones_in_world_transform; // bind helpers Array _get_bound_child_nodes_to_bone(int p_bone) const { @@ -127,8 +147,6 @@ public: NOTIFICATION_UPDATE_SKELETON = 50 }; - RID get_skeleton() const; - // skeleton creation api void add_bone(const String &p_name); int find_bone(const String &p_name) const; @@ -141,9 +159,6 @@ public: void unparent_bone_and_rest(int p_bone); - void set_bone_ignore_animation(int p_bone, bool p_ignore); - bool is_bone_ignore_animation(int p_bone) const; - void set_bone_disable_rest(int p_bone, bool p_disable); bool is_bone_rest_disabled(int p_bone) const; @@ -151,10 +166,9 @@ public: void set_bone_rest(int p_bone, const Transform &p_rest); Transform get_bone_rest(int p_bone) const; - Transform get_bone_transform(int p_bone) const; Transform get_bone_global_pose(int p_bone) const; - void set_bone_global_pose(int p_bone, const Transform &p_pose); + void set_bone_global_pose_override(int p_bone, const Transform &p_pose, float p_amount, bool p_persistent = false); void set_bone_enabled(int p_bone, bool p_enabled); bool is_bone_enabled(int p_bone) const; @@ -170,14 +184,10 @@ public: void set_bone_pose(int p_bone, const Transform &p_pose); Transform get_bone_pose(int p_bone) const; - void set_bone_custom_pose(int p_bone, const Transform &p_custom_pose); - Transform get_bone_custom_pose(int p_bone) const; - void localize_rests(); // used for loaders and tools int get_process_order(int p_idx); - void set_use_bones_in_world_transform(bool p_enable); - bool is_using_bones_in_world_transform() const; + Ref<SkinReference> register_skin(const Ref<Skin> &p_skin); #ifndef _3D_DISABLED // Physical bone API diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 051f832882..728c23fbaa 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -256,7 +256,7 @@ void AnimationPlayer::_ensure_node_caches(AnimationData *p_anim) { Skeleton *sk = Object::cast_to<Skeleton>(child); bone_idx = sk->find_bone(a->track_get_path(i).get_subname(0)); - if (bone_idx == -1 || sk->is_bone_ignore_animation(bone_idx)) { + if (bone_idx == -1) { continue; } diff --git a/scene/animation/animation_tree.cpp b/scene/animation/animation_tree.cpp index bb7c400cfe..eb152bc41e 100644 --- a/scene/animation/animation_tree.cpp +++ b/scene/animation/animation_tree.cpp @@ -622,7 +622,7 @@ bool AnimationTree::_update_caches(AnimationPlayer *player) { Skeleton *sk = Object::cast_to<Skeleton>(spatial); int bone_idx = sk->find_bone(path.get_subname(0)); - if (bone_idx != -1 && !sk->is_bone_ignore_animation(bone_idx)) { + if (bone_idx != -1) { track_xform->skeleton = sk; track_xform->bone_idx = bone_idx; diff --git a/scene/animation/animation_tree_player.cpp b/scene/animation/animation_tree_player.cpp index 8f6d53c21c..ba5936562a 100644 --- a/scene/animation/animation_tree_player.cpp +++ b/scene/animation/animation_tree_player.cpp @@ -820,11 +820,7 @@ void AnimationTreePlayer::_process_animation(float p_delta) { t.value = t.object->get_indexed(t.subpath); t.value.zero(); - if (t.skeleton) { - t.skip = t.skeleton->is_bone_ignore_animation(t.bone_idx); - } else { - t.skip = false; - } + t.skip = false; } /* STEP 2 PROCESS ANIMATIONS */ diff --git a/scene/animation/skeleton_ik.cpp b/scene/animation/skeleton_ik.cpp index 7a1b10792b..4ec22cf3df 100644 --- a/scene/animation/skeleton_ik.cpp +++ b/scene/animation/skeleton_ik.cpp @@ -320,7 +320,7 @@ void FabrikInverseKinematic::solve(Task *p_task, real_t blending_delta, bool ove new_bone_pose.basis = new_bone_pose.basis * p_task->chain.tips[0].end_effector->goal_transform.basis; } - p_task->skeleton->set_bone_global_pose(ci->bone, new_bone_pose); + p_task->skeleton->set_bone_global_pose_override(ci->bone, new_bone_pose, 1.0); if (!ci->children.empty()) ci = &ci->children.write[0]; diff --git a/scene/gui/control.cpp b/scene/gui/control.cpp index d39f017cad..f8f29632b3 100644 --- a/scene/gui/control.cpp +++ b/scene/gui/control.cpp @@ -645,6 +645,7 @@ void Control::_notification(int p_notification) { } break; case NOTIFICATION_THEME_CHANGED: { + minimum_size_changed(); update(); } break; case NOTIFICATION_MODAL_CLOSE: { diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index 2445456a1f..bac14707fc 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -201,7 +201,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { switch (code) { - case (KEY_X): { // CUT + case (KEY_X): { // CUT. if (editable) { cut_text(); @@ -209,12 +209,13 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { } break; - case (KEY_C): { // COPY + case (KEY_C): { // COPY. + copy_text(); } break; - case (KEY_V): { // PASTE + case (KEY_V): { // PASTE. if (editable) { @@ -223,7 +224,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { } break; - case (KEY_Z): { // undo / redo + case (KEY_Z): { // Undo/redo. if (editable) { if (k->get_shift()) { redo(); @@ -233,7 +234,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { } } break; - case (KEY_U): { // Delete from start to cursor + case (KEY_U): { // Delete from start to cursor. if (editable) { @@ -254,7 +255,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { } break; - case (KEY_Y): { // PASTE (Yank for unix users) + case (KEY_Y): { // PASTE (Yank for unix users). if (editable) { @@ -262,7 +263,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { } } break; - case (KEY_K): { // Delete from cursor_pos to end + case (KEY_K): { // Delete from cursor_pos to end. if (editable) { @@ -272,15 +273,15 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { } } break; - case (KEY_A): { //Select All + case (KEY_A): { // Select all. select(); } break; #ifdef APPLE_STYLE_KEYS - case (KEY_LEFT): { // Go to start of text - like HOME key + case (KEY_LEFT): { // Go to start of text - like HOME key. set_cursor_position(0); } break; - case (KEY_RIGHT): { // Go to end of text - like END key + case (KEY_RIGHT): { // Go to end of text - like END key. set_cursor_position(text.length()); } break; #endif @@ -473,7 +474,7 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { int text_len = text.length(); if (cursor_pos == text_len) - break; // nothing to do + break; // Nothing to do. #ifdef APPLE_STYLE_KEYS if (k->get_alt()) { @@ -531,6 +532,16 @@ void LineEdit::_gui_input(Ref<InputEvent> p_event) { set_cursor_position(text.length()); shift_selection_check_post(k->get_shift()); } break; + case KEY_MENU: { + if (context_menu_enabled) { + Point2 pos = Point2(get_cursor_pixel_pos(), (get_size().y + get_font("font")->get_height()) / 2); + menu->set_position(get_global_transform().xform(pos)); + menu->set_size(Vector2(1, 1)); + menu->set_scale(get_global_transform().get_scale()); + menu->popup(); + menu->grab_focus(); + } + } break; default: { @@ -730,7 +741,7 @@ void LineEdit::_notification(int p_what) { Color cursor_color = get_color("cursor_color"); const String &t = using_placeholder ? placeholder_translated : text; - // draw placeholder color + // Draw placeholder color. if (using_placeholder) font_color.a *= placeholder_alpha; @@ -745,24 +756,28 @@ void LineEdit::_notification(int p_what) { color_icon = get_color("clear_button_color"); } } - r_icon->draw(ci, Point2(width - r_icon->get_width() - style->get_margin(MARGIN_RIGHT), height / 2 - r_icon->get_height() / 2), color_icon); + + float icon_width = MIN(r_icon->get_width(), r_icon->get_width() * (height - (style->get_margin(MARGIN_TOP) + style->get_margin(MARGIN_BOTTOM))) / r_icon->get_height()); + float icon_height = MIN(r_icon->get_height(), height - (style->get_margin(MARGIN_TOP) + style->get_margin(MARGIN_BOTTOM))); + Rect2 icon_region = Rect2(Point2(width - icon_width - style->get_margin(MARGIN_RIGHT), height / 2 - icon_height / 2), Size2(icon_width, icon_height)); + draw_texture_rect_region(r_icon, icon_region, Rect2(Point2(), r_icon->get_size()), color_icon); if (align == ALIGN_CENTER) { if (window_pos == 0) { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(size.width - cached_text_width - r_icon->get_width() - style->get_margin(MARGIN_RIGHT) * 2) / 2); + x_ofs = MAX(style->get_margin(MARGIN_LEFT), int(size.width - cached_text_width - icon_width - style->get_margin(MARGIN_RIGHT) * 2) / 2); } } else { - x_ofs = MAX(style->get_margin(MARGIN_LEFT), x_ofs - r_icon->get_width() - style->get_margin(MARGIN_RIGHT)); + x_ofs = MAX(style->get_margin(MARGIN_LEFT), x_ofs - icon_width - style->get_margin(MARGIN_RIGHT)); } - ofs_max -= r_icon->get_width(); + ofs_max -= icon_width; } int caret_height = font->get_height() > y_area ? y_area : font->get_height(); FontDrawer drawer(font, Color(1, 1, 1)); while (true) { - //end of string, break! + // End of string, break. if (char_ofs >= t.length()) break; @@ -799,7 +814,7 @@ void LineEdit::_notification(int p_what) { CharType next = (pass && !text.empty()) ? secret_character[0] : t[char_ofs + 1]; int char_width = font->get_char_size(cchar, next).width; - // end of widget, break! + // End of widget, break. if ((x_ofs + char_width) > ofs_max) break; @@ -854,7 +869,7 @@ void LineEdit::_notification(int p_what) { } } - if (char_ofs == cursor_pos && draw_caret) { //may be at the end + if (char_ofs == cursor_pos && draw_caret) { // May be at the end. if (ime_text.length() == 0) { #ifdef TOOLS_ENABLED VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(x_ofs, y_ofs), Size2(Math::round(EDSCALE), caret_height)), cursor_color); @@ -1043,7 +1058,7 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { } pixel_ofs += char_w; - if (pixel_ofs > p_x) { //found what we look for + if (pixel_ofs > p_x) { // Found what we look for. break; } @@ -1053,6 +1068,52 @@ void LineEdit::set_cursor_at_pixel_pos(int p_x) { set_cursor_position(ofs); } +int LineEdit::get_cursor_pixel_pos() { + + Ref<Font> font = get_font("font"); + int ofs = window_pos; + Ref<StyleBox> style = get_stylebox("normal"); + int pixel_ofs = 0; + Size2 size = get_size(); + bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled; + int r_icon_width = Control::get_icon("clear")->get_width(); + + switch (align) { + + case ALIGN_FILL: + case ALIGN_LEFT: { + + pixel_ofs = int(style->get_offset().x); + } break; + case ALIGN_CENTER: { + + if (window_pos != 0) + pixel_ofs = int(style->get_offset().x); + else + pixel_ofs = int(size.width - (cached_width)) / 2; + + if (display_clear_icon) + pixel_ofs -= int(r_icon_width / 2 + style->get_margin(MARGIN_RIGHT)); + } break; + case ALIGN_RIGHT: { + + pixel_ofs = int(size.width - style->get_margin(MARGIN_RIGHT) - (cached_width)); + + if (display_clear_icon) + pixel_ofs -= int(r_icon_width + style->get_margin(MARGIN_RIGHT)); + } break; + } + + while (ofs < cursor_pos) { + if (font != NULL) { + pixel_ofs += font->get_char_size(text[ofs]).width; + } + ofs++; + } + + return pixel_ofs; +} + bool LineEdit::cursor_get_blink_enabled() const { return caret_blink_enabled; } @@ -1210,15 +1271,18 @@ void LineEdit::set_cursor_position(int p_pos) { Ref<Font> font = get_font("font"); if (cursor_pos <= window_pos) { - /* Adjust window if cursor goes too much to the left */ + // Adjust window if cursor goes too much to the left. set_window_pos(MAX(0, cursor_pos - 1)); } else { - /* Adjust window if cursor goes too much to the right */ + // Adjust window if cursor goes too much to the right. int window_width = get_size().width - style->get_minimum_size().width; bool display_clear_icon = !text.empty() && is_editable() && clear_button_enabled; if (right_icon.is_valid() || display_clear_icon) { Ref<Texture> r_icon = display_clear_icon ? Control::get_icon("clear") : right_icon; - window_width -= r_icon->get_width(); + + float icon_width = MIN(r_icon->get_width(), r_icon->get_width() * (get_size().height - (style->get_margin(MARGIN_TOP) + style->get_margin(MARGIN_BOTTOM))) / r_icon->get_height()); + + window_width -= icon_width; } if (window_width < 0) @@ -1232,10 +1296,10 @@ void LineEdit::set_cursor_position(int p_pos) { for (int i = cursor_pos; i >= window_pos; i--) { if (i >= text.length()) { - //do not do this, because if the cursor is at the end, its just fine that it takes no space - //accum_width = font->get_char_size(' ').width; //anything should do + // Do not do this, because if the cursor is at the end, its just fine that it takes no space. + // accum_width = font->get_char_size(' ').width; } else { - accum_width += font->get_char_size(text[i], i + 1 < text.length() ? text[i + 1] : 0).width; //anything should do + accum_width += font->get_char_size(text[i], i + 1 < text.length() ? text[i + 1] : 0).width; // Anything should do. } if (accum_width > window_width) break; @@ -1300,12 +1364,13 @@ Size2 LineEdit::get_minimum_size() const { Size2 min = style->get_minimum_size(); min.height += font->get_height(); - //minimum size of text + // Minimum size of text. int space_size = font->get_char_size(' ').x; int mstext = get_constant("minimum_spaces") * space_size; if (expand_to_text_length) { - mstext = MAX(mstext, font->get_string_size(text).x + space_size); //add a spce because some fonts are too exact, and because cursor needs a bit more when at the end + // Add a space because some fonts are too exact, and because cursor needs a bit more when at the end. + mstext = MAX(mstext, font->get_string_size(text).x + space_size); } min.width += mstext; @@ -1313,8 +1378,6 @@ Size2 LineEdit::get_minimum_size() const { return min; } -/* selection */ - void LineEdit::deselect() { selection.begin = 0; @@ -1404,8 +1467,8 @@ bool LineEdit::is_secret() const { void LineEdit::set_secret_character(const String &p_string) { - // An empty string as the secret character would crash the engine - // It also wouldn't make sense to use multiple characters as the secret character + // An empty string as the secret character would crash the engine. + // It also wouldn't make sense to use multiple characters as the secret character. ERR_FAIL_COND_MSG(p_string.length() != 1, "Secret character must be exactly one character long (" + itos(p_string.length()) + " characters given)."); secret_character = p_string; @@ -1557,8 +1620,11 @@ void LineEdit::set_right_icon(const Ref<Texture> &p_icon) { update(); } -void LineEdit::_text_changed() { +Ref<Texture> LineEdit::get_right_icon() { + return right_icon; +} +void LineEdit::_text_changed() { if (expand_to_text_length) minimum_size_changed(); @@ -1679,6 +1745,8 @@ void LineEdit::_bind_methods() { ClassDB::bind_method(D_METHOD("is_shortcut_keys_enabled"), &LineEdit::is_shortcut_keys_enabled); ClassDB::bind_method(D_METHOD("set_selecting_enabled", "enable"), &LineEdit::set_selecting_enabled); ClassDB::bind_method(D_METHOD("is_selecting_enabled"), &LineEdit::is_selecting_enabled); + ClassDB::bind_method(D_METHOD("set_right_icon", "icon"), &LineEdit::set_right_icon); + ClassDB::bind_method(D_METHOD("get_right_icon"), &LineEdit::get_right_icon); ADD_SIGNAL(MethodInfo("text_changed", PropertyInfo(Variant::STRING, "new_text"))); ADD_SIGNAL(MethodInfo("text_entered", PropertyInfo(Variant::STRING, "new_text"))); @@ -1704,11 +1772,11 @@ void LineEdit::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "secret"), "set_secret", "is_secret"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "secret_character"), "set_secret_character", "get_secret_character"); ADD_PROPERTY(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_PROPERTY(PropertyInfo(Variant::BOOL, "context_menu_enabled"), "set_context_menu_enabled", "is_context_menu_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "clear_button_enabled"), "set_clear_button_enabled", "is_clear_button_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shortcut_keys_enabled"), "set_shortcut_keys_enabled", "is_shortcut_keys_enabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "selecting_enabled"), "set_selecting_enabled", "is_selecting_enabled"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "right_icon", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_right_icon", "get_right_icon"); ADD_GROUP("Placeholder", "placeholder_"); ADD_PROPERTY(PropertyInfo(Variant::STRING, "placeholder_text"), "set_placeholder", "get_placeholder"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "placeholder_alpha", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_placeholder_alpha", "get_placeholder_alpha"); @@ -1755,7 +1823,7 @@ LineEdit::LineEdit() { context_menu_enabled = true; menu = memnew(PopupMenu); add_child(menu); - editable = false; // initialise to opposite first, so we get past the early-out in set_editable + editable = false; // Initialise to opposite first, so we get past the early-out in set_editable. set_editable(true); menu->connect("id_pressed", this, "menu_option"); expand_to_text_length = false; diff --git a/scene/gui/line_edit.h b/scene/gui/line_edit.h index c8fe845e3e..3424131dad 100644 --- a/scene/gui/line_edit.h +++ b/scene/gui/line_edit.h @@ -82,7 +82,7 @@ private: int cursor_pos; int window_pos; - int max_length; // 0 for no maximum + int max_length; // 0 for no maximum. int cached_width; int cached_placeholder_width; @@ -143,6 +143,7 @@ private: void set_window_pos(int p_pos); void set_cursor_at_pixel_pos(int p_x); + int get_cursor_pixel_pos(); void _reset_caret_blink_timer(); void _toggle_draw_caret(); @@ -229,6 +230,7 @@ public: bool is_selecting_enabled() const; void set_right_icon(const Ref<Texture> &p_icon); + Ref<Texture> get_right_icon(); virtual bool is_text_field() const; LineEdit(); diff --git a/scene/gui/option_button.cpp b/scene/gui/option_button.cpp index d1840e43a3..de8df4215d 100644 --- a/scene/gui/option_button.cpp +++ b/scene/gui/option_button.cpp @@ -116,10 +116,16 @@ void OptionButton::add_item(const String &p_label, int p_id) { void OptionButton::set_item_text(int p_idx, const String &p_text) { popup->set_item_text(p_idx, p_text); + + if (current == p_idx) + set_text(p_text); } void OptionButton::set_item_icon(int p_idx, const Ref<Texture> &p_icon) { popup->set_item_icon(p_idx, p_icon); + + if (current == p_idx) + set_icon(p_icon); } void OptionButton::set_item_id(int p_idx, int p_id) { diff --git a/scene/gui/rich_text_label.h b/scene/gui/rich_text_label.h index 6755f9ef2a..481f8d9746 100644 --- a/scene/gui/rich_text_label.h +++ b/scene/gui/rich_text_label.h @@ -81,7 +81,7 @@ protected: static void _bind_methods(); private: - struct Item; + class Item; struct Line { @@ -103,8 +103,10 @@ private: } }; - struct Item : public Object { + class Item : public Object { + GDCLASS(Item, Object); + public: int index; Item *parent; ItemType type; @@ -127,8 +129,10 @@ private: virtual ~Item() { _clear_children(); } }; - struct ItemFrame : public Item { + class ItemFrame : public Item { + GDCLASS(ItemFrame, Item); + public: int parent_line; bool cell; Vector<Line> lines; @@ -143,71 +147,95 @@ private: } }; - struct ItemText : public Item { + class ItemText : public Item { + GDCLASS(ItemText, Item); + public: String text; ItemText() { type = ITEM_TEXT; } }; - struct ItemImage : public Item { + class ItemImage : public Item { + GDCLASS(ItemImage, Item); + public: Ref<Texture> image; ItemImage() { type = ITEM_IMAGE; } }; - struct ItemFont : public Item { + class ItemFont : public Item { + GDCLASS(ItemFont, Item); + public: Ref<Font> font; ItemFont() { type = ITEM_FONT; } }; - struct ItemColor : public Item { + class ItemColor : public Item { + GDCLASS(ItemColor, Item); + public: Color color; ItemColor() { type = ITEM_COLOR; } }; - struct ItemUnderline : public Item { + class ItemUnderline : public Item { + GDCLASS(ItemUnderline, Item); + public: ItemUnderline() { type = ITEM_UNDERLINE; } }; - struct ItemStrikethrough : public Item { + class ItemStrikethrough : public Item { + GDCLASS(ItemStrikethrough, Item); + public: ItemStrikethrough() { type = ITEM_STRIKETHROUGH; } }; - struct ItemMeta : public Item { + class ItemMeta : public Item { + GDCLASS(ItemMeta, Item); + public: Variant meta; ItemMeta() { type = ITEM_META; } }; - struct ItemAlign : public Item { + class ItemAlign : public Item { + GDCLASS(ItemAlign, Item); + public: Align align; ItemAlign() { type = ITEM_ALIGN; } }; - struct ItemIndent : public Item { + class ItemIndent : public Item { + GDCLASS(ItemIndent, Item); + public: int level; ItemIndent() { type = ITEM_INDENT; } }; - struct ItemList : public Item { + class ItemList : public Item { + GDCLASS(ItemList, Item); + public: ListType list_type; ItemList() { type = ITEM_LIST; } }; - struct ItemNewline : public Item { + class ItemNewline : public Item { + GDCLASS(ItemNewline, Item); + public: ItemNewline() { type = ITEM_NEWLINE; } }; - struct ItemTable : public Item { + class ItemTable : public Item { + GDCLASS(ItemTable, Item); + public: struct Column { bool expand; int expand_ratio; @@ -221,14 +249,20 @@ private: ItemTable() { type = ITEM_TABLE; } }; - struct ItemFade : public Item { + class ItemFade : public Item { + GDCLASS(ItemFade, Item); + + public: int starting_index; int length; ItemFade() { type = ITEM_FADE; } }; - struct ItemFX : public Item { + class ItemFX : public Item { + GDCLASS(ItemFX, Item); + + public: float elapsed_time; ItemFX() { @@ -236,7 +270,10 @@ private: } }; - struct ItemShake : public ItemFX { + class ItemShake : public ItemFX { + GDCLASS(ItemShake, ItemFX); + + public: int strength; float rate; uint64_t _current_rng; @@ -265,7 +302,10 @@ private: } }; - struct ItemWave : public ItemFX { + class ItemWave : public ItemFX { + GDCLASS(ItemWave, ItemFX); + + public: float frequency; float amplitude; @@ -276,7 +316,10 @@ private: } }; - struct ItemTornado : public ItemFX { + class ItemTornado : public ItemFX { + GDCLASS(ItemTornado, ItemFX); + + public: float radius; float frequency; @@ -287,7 +330,10 @@ private: } }; - struct ItemRainbow : public ItemFX { + class ItemRainbow : public ItemFX { + GDCLASS(ItemRainbow, ItemFX); + + public: float saturation; float value; float frequency; @@ -300,7 +346,10 @@ private: } }; - struct ItemCustomFX : public ItemFX { + class ItemCustomFX : public ItemFX { + GDCLASS(ItemCustomFX, ItemFX); + + public: String identifier; Dictionary environment; @@ -456,7 +505,7 @@ public: void push_meta(const Variant &p_meta); void push_table(int p_columns); void push_fade(int p_start_index, int p_length); - void push_shake(int p_level, float p_rate); + void push_shake(int p_strength, float p_rate); void push_wave(float p_frequency, float p_amplitude); void push_tornado(float p_frequency, float p_radius); void push_rainbow(float p_saturation, float p_value, float p_frequency); diff --git a/scene/gui/slider.cpp b/scene/gui/slider.cpp index b777e77bc3..9f853cf0c8 100644 --- a/scene/gui/slider.cpp +++ b/scene/gui/slider.cpp @@ -287,7 +287,6 @@ void Slider::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "scrollable"), "set_scrollable", "is_scrollable"); ADD_PROPERTY(PropertyInfo(Variant::INT, "tick_count", PROPERTY_HINT_RANGE, "0,4096,1"), "set_ticks", "get_ticks"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "ticks_on_borders"), "set_ticks_on_borders", "get_ticks_on_borders"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "focus_mode", PROPERTY_HINT_ENUM, "None,Click,All"), "set_focus_mode", "get_focus_mode"); } Slider::Slider(Orientation p_orientation) { diff --git a/scene/gui/tab_container.cpp b/scene/gui/tab_container.cpp index 292d80be9d..a29ba36bad 100644 --- a/scene/gui/tab_container.cpp +++ b/scene/gui/tab_container.cpp @@ -94,7 +94,7 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { return; } - // Do not activate tabs when tabs is empty + // Do not activate tabs when tabs is empty. if (get_tab_count() == 0) return; @@ -140,6 +140,76 @@ void TabContainer::_gui_input(const Ref<InputEvent> &p_event) { pos.x -= tab_width; } } + + Ref<InputEventMouseMotion> mm = p_event; + + if (mm.is_valid()) { + + Point2 pos(mm->get_position().x, mm->get_position().y); + Size2 size = get_size(); + + // Mouse must be on tabs in the tab header area. + if (pos.x < tabs_ofs_cache || pos.y > _get_top_margin()) { + + if (menu_hovered || highlight_arrow > -1) { + menu_hovered = false; + highlight_arrow = -1; + update(); + } + return; + } + + Ref<Texture> menu = get_icon("menu"); + if (popup) { + + if (pos.x >= size.width - menu->get_width()) { + if (!menu_hovered) { + menu_hovered = true; + highlight_arrow = -1; + update(); + return; + } + } else if (menu_hovered) { + menu_hovered = false; + update(); + } + + if (menu_hovered) { + return; + } + } + + // Do not activate tabs when tabs is empty. + if ((get_tab_count() == 0 || !buttons_visible_cache) && menu_hovered) { + highlight_arrow = -1; + update(); + return; + } + + int popup_ofs = 0; + if (popup) { + popup_ofs = menu->get_width(); + } + + Ref<Texture> increment = get_icon("increment"); + Ref<Texture> decrement = get_icon("decrement"); + if (pos.x >= size.width - increment->get_width() - popup_ofs) { + + if (highlight_arrow != 1) { + highlight_arrow = 1; + update(); + } + } else if (pos.x >= size.width - increment->get_width() - decrement->get_width() - popup_ofs) { + + if (highlight_arrow != 0) { + highlight_arrow = 0; + update(); + } + } else if (highlight_arrow > -1) { + highlight_arrow = -1; + update(); + } + } } void TabContainer::_notification(int p_what) { @@ -203,9 +273,11 @@ void TabContainer::_notification(int p_what) { Ref<StyleBox> tab_fg = get_stylebox("tab_fg"); Ref<StyleBox> tab_disabled = get_stylebox("tab_disabled"); Ref<Texture> increment = get_icon("increment"); + Ref<Texture> increment_hl = get_icon("increment_highlight"); Ref<Texture> decrement = get_icon("decrement"); + Ref<Texture> decrement_hl = get_icon("decrement_highlight"); Ref<Texture> menu = get_icon("menu"); - Ref<Texture> menu_hl = get_icon("menu_hl"); + Ref<Texture> menu_hl = get_icon("menu_highlight"); Ref<Font> font = get_font("font"); Color font_color_fg = get_color("font_color_fg"); Color font_color_bg = get_color("font_color_bg"); @@ -332,7 +404,7 @@ void TabContainer::_notification(int p_what) { x = get_size().width; if (popup) { x -= menu->get_width(); - if (mouse_x_cache > x) + if (menu_hovered) menu_hl->draw(get_canvas_item(), Size2(x, (header_height - menu_hl->get_height()) / 2)); else menu->draw(get_canvas_item(), Size2(x, (header_height - menu->get_height()) / 2)); @@ -340,23 +412,26 @@ void TabContainer::_notification(int p_what) { // Draw the navigation buttons. if (buttons_visible_cache) { - int y_center = header_height / 2; x -= increment->get_width(); - increment->draw(canvas, - Point2(x, y_center - (increment->get_height() / 2)), - Color(1, 1, 1, last_tab_cache < tabs.size() - 1 ? 1.0 : 0.5)); + if (last_tab_cache < tabs.size() - 1) { + draw_texture(highlight_arrow == 1 ? increment_hl : increment, Point2(x, (header_height - increment->get_height()) / 2)); + } else { + draw_texture(increment, Point2(x, (header_height - increment->get_height()) / 2), Color(1, 1, 1, 0.5)); + } x -= decrement->get_width(); - decrement->draw(canvas, - Point2(x, y_center - (decrement->get_height() / 2)), - Color(1, 1, 1, first_tab_cache > 0 ? 1.0 : 0.5)); + if (first_tab_cache > 0) { + draw_texture(highlight_arrow == 0 ? decrement_hl : decrement, Point2(x, (header_height - decrement->get_height()) / 2)); + } else { + draw_texture(decrement, Point2(x, (header_height - decrement->get_height()) / 2), Color(1, 1, 1, 0.5)); + } } } break; case NOTIFICATION_THEME_CHANGED: { minimum_size_changed(); - call_deferred("_on_theme_changed"); //wait until all changed theme + call_deferred("_on_theme_changed"); // Wait until all changed theme. } break; } } @@ -367,6 +442,14 @@ void TabContainer::_on_theme_changed() { } } +void TabContainer::_on_mouse_exited() { + if (menu_hovered || highlight_arrow > -1) { + menu_hovered = false; + highlight_arrow = -1; + update(); + } +} + int TabContainer::_get_tab_width(int p_index) const { ERR_FAIL_INDEX_V(p_index, get_tab_count(), 0); @@ -894,6 +977,7 @@ void TabContainer::set_use_hidden_tabs_for_min_size(bool p_use_hidden_tabs) { bool TabContainer::get_use_hidden_tabs_for_min_size() const { return use_hidden_tabs_for_min_size; } + void TabContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &TabContainer::_gui_input); @@ -925,6 +1009,7 @@ void TabContainer::_bind_methods() { ClassDB::bind_method(D_METHOD("_child_renamed_callback"), &TabContainer::_child_renamed_callback); ClassDB::bind_method(D_METHOD("_on_theme_changed"), &TabContainer::_on_theme_changed); + ClassDB::bind_method(D_METHOD("_on_mouse_exited"), &TabContainer::_on_mouse_exited); ClassDB::bind_method(D_METHOD("_update_current_tab"), &TabContainer::_update_current_tab); ADD_SIGNAL(MethodInfo("tab_changed", PropertyInfo(Variant::INT, "tab"))); @@ -947,14 +1032,17 @@ TabContainer::TabContainer() { first_tab_cache = 0; last_tab_cache = 0; buttons_visible_cache = false; + menu_hovered = false; + highlight_arrow = -1; tabs_ofs_cache = 0; current = 0; previous = 0; - mouse_x_cache = 0; align = ALIGN_CENTER; tabs_visible = true; popup = NULL; drag_to_rearrange_enabled = false; tabs_rearrange_group = -1; use_hidden_tabs_for_min_size = false; + + connect("mouse_exited", this, "_on_mouse_exited"); } diff --git a/scene/gui/tab_container.h b/scene/gui/tab_container.h index 0314f86837..0c17ebc3ae 100644 --- a/scene/gui/tab_container.h +++ b/scene/gui/tab_container.h @@ -46,7 +46,6 @@ public: }; private: - int mouse_x_cache; int first_tab_cache; int tabs_ofs_cache; int last_tab_cache; @@ -54,6 +53,8 @@ private: int previous; bool tabs_visible; bool buttons_visible_cache; + bool menu_hovered; + int highlight_arrow; TabAlign align; Control *_get_tab(int p_idx) const; int _get_top_margin() const; @@ -65,6 +66,7 @@ private: Vector<Control *> _get_tabs() const; int _get_tab_width(int p_index) const; void _on_theme_changed(); + void _on_mouse_exited(); void _update_current_tab(); protected: diff --git a/scene/gui/tabs.cpp b/scene/gui/tabs.cpp index 7b0836cd28..93b091e8d0 100644 --- a/scene/gui/tabs.cpp +++ b/scene/gui/tabs.cpp @@ -226,12 +226,6 @@ void Tabs::_notification(int p_what) { minimum_size_changed(); update(); } break; - case NOTIFICATION_MOUSE_EXIT: { - rb_hover = -1; - cb_hover = -1; - hover = -1; - update(); - } break; case NOTIFICATION_RESIZED: { _update_cache(); _ensure_no_over_offset(); @@ -597,6 +591,15 @@ void Tabs::_update_cache() { } } +void Tabs::_on_mouse_exited() { + + rb_hover = -1; + cb_hover = -1; + hover = -1; + highlight_arrow = -1; + update(); +} + void Tabs::add_tab(const String &p_str, const Ref<Texture> &p_icon) { Tab t; @@ -948,6 +951,7 @@ void Tabs::_bind_methods() { ClassDB::bind_method(D_METHOD("_gui_input"), &Tabs::_gui_input); ClassDB::bind_method(D_METHOD("_update_hover"), &Tabs::_update_hover); + ClassDB::bind_method(D_METHOD("_on_mouse_exited"), &Tabs::_on_mouse_exited); ClassDB::bind_method(D_METHOD("get_tab_count"), &Tabs::get_tab_count); ClassDB::bind_method(D_METHOD("set_current_tab", "tab_idx"), &Tabs::set_current_tab); ClassDB::bind_method(D_METHOD("get_current_tab"), &Tabs::get_current_tab); @@ -1024,4 +1028,6 @@ Tabs::Tabs() { hover = -1; drag_to_rearrange_enabled = false; tabs_rearrange_group = -1; + + connect("mouse_exited", this, "_on_mouse_exited"); } diff --git a/scene/gui/tabs.h b/scene/gui/tabs.h index 7c54f1acf2..a762b5b9cb 100644 --- a/scene/gui/tabs.h +++ b/scene/gui/tabs.h @@ -89,7 +89,7 @@ private: bool cb_pressing; CloseButtonDisplayPolicy cb_displaypolicy; - int hover; // hovered tab + int hover; // Hovered tab. int min_width; bool scrolling_enabled; bool drag_to_rearrange_enabled; @@ -101,6 +101,8 @@ private: void _update_hover(); void _update_cache(); + void _on_mouse_exited(); + protected: void _gui_input(const Ref<InputEvent> &p_event); void _notification(int p_what); diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 9678ebe6ea..d5f1d317c7 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -2081,6 +2081,44 @@ void TextEdit::_get_mouse_pos(const Point2i &p_mouse, int &r_row, int &r_col) co r_col = col; } +Vector2i TextEdit::_get_cursor_pixel_pos() { + adjust_viewport_to_cursor(); + int row = (cursor.line - get_first_visible_line() - cursor.wrap_ofs); + // Correct for hidden and wrapped lines + for (int i = get_first_visible_line(); i < cursor.line; i++) { + if (is_line_hidden(i)) { + row -= 1; + continue; + } + row += times_line_wraps(i); + } + // Row might be wrapped. Adjust row and r_column + Vector<String> rows2 = get_wrap_rows_text(cursor.line); + while (rows2.size() > 1) { + if (cursor.column >= rows2[0].length()) { + cursor.column -= rows2[0].length(); + rows2.remove(0); + row++; + } else { + break; + } + } + + // Calculate final pixel position + int y = (row - get_v_scroll_offset() + 1 /*Bottom of line*/) * get_row_height(); + int x = cache.style_normal->get_margin(MARGIN_LEFT) + cache.line_number_w + cache.breakpoint_gutter_width + cache.fold_gutter_width + cache.info_gutter_width - cursor.x_ofs; + int ix = 0; + while (ix < rows2[0].size() && ix < cursor.column) { + if (cache.font != NULL) { + x += cache.font->get_char_size(rows2[0].get(ix)).width; + } + ix++; + } + x += get_indent_level(cursor.line) * cache.font->get_char_size(' ').width; + + return Vector2i(x, y); +} + void TextEdit::_get_minimap_mouse_row(const Point2i &p_mouse, int &r_row) const { float rows = p_mouse.y; @@ -2417,7 +2455,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { if (mm.is_valid()) { if (select_identifiers_enabled) { - if (mm->get_command() && mm->get_button_mask() == 0) { + if (!dragging_minimap && !dragging_selection && mm->get_command() && mm->get_button_mask() == 0) { String new_word = get_word_at_pos(mm->get_position()); if (new_word != highlighted_word) { @@ -2475,7 +2513,7 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { #endif if (select_identifiers_enabled) { - if (k->is_pressed()) { + if (k->is_pressed() && !dragging_minimap && !dragging_selection) { highlighted_word = get_word_at_pos(get_local_mouse_position()); update(); @@ -3596,6 +3634,16 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) { } break; + case KEY_MENU: { + if (context_menu_enabled) { + menu->set_position(get_global_transform().xform(_get_cursor_pixel_pos())); + menu->set_size(Vector2(1, 1)); + menu->set_scale(get_global_transform().get_scale()); + menu->popup(); + menu->grab_focus(); + } + } break; + default: { scancode_handled = false; diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index e98201c1eb..e5d9b006fe 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -587,6 +587,7 @@ public: int cursor_get_column() const; int cursor_get_line() const; + Vector2i _get_cursor_pixel_pos(); bool cursor_get_blink_enabled() const; void cursor_set_blink_enabled(const bool p_enabled); diff --git a/scene/register_scene_types.cpp b/scene/register_scene_types.cpp index e3af521e8c..418ee6af0e 100644 --- a/scene/register_scene_types.cpp +++ b/scene/register_scene_types.cpp @@ -364,6 +364,9 @@ void register_scene_types() { /* REGISTER 3D */ + ClassDB::register_class<Skin>(); + ClassDB::register_virtual_class<SkinReference>(); + ClassDB::register_class<Spatial>(); ClassDB::register_virtual_class<SpatialGizmo>(); ClassDB::register_class<Skeleton>(); diff --git a/scene/resources/polygon_path_finder.cpp b/scene/resources/polygon_path_finder.cpp index 52fc21ac11..bd3236cb5b 100644 --- a/scene/resources/polygon_path_finder.cpp +++ b/scene/resources/polygon_path_finder.cpp @@ -466,11 +466,11 @@ Dictionary PolygonPathFinder::_get_data() const { PoolVector<Vector2> p; PoolVector<int> ind; Array connections; - p.resize(points.size() - 2); - connections.resize(points.size() - 2); + p.resize(MAX(0, points.size() - 2)); + connections.resize(MAX(0, points.size() - 2)); ind.resize(edges.size() * 2); PoolVector<float> penalties; - penalties.resize(points.size() - 2); + penalties.resize(MAX(0, points.size() - 2)); { PoolVector<Vector2>::Write wp = p.write(); PoolVector<float>::Write pw = penalties.write(); diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index cd229732ba..1c41f30a94 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1713,6 +1713,7 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r } if (groups.size()) { + groups.sort_custom<StringName::AlphCompare>(); String sgroups = " groups=[\n"; for (int j = 0; j < groups.size(); j++) { sgroups += "\"" + String(groups[j]).c_escape() + "\",\n"; diff --git a/scene/resources/skin.cpp b/scene/resources/skin.cpp new file mode 100644 index 0000000000..98c114e0e6 --- /dev/null +++ b/scene/resources/skin.cpp @@ -0,0 +1,132 @@ +/*************************************************************************/ +/* skin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 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 "skin.h" + +void Skin::set_bind_count(int p_size) { + ERR_FAIL_COND(p_size < 0); + binds.resize(p_size); + binds_ptr = binds.ptrw(); + bind_count = p_size; + emit_changed(); +} + +void Skin::add_bind(int p_bone, const Transform &p_pose) { + uint32_t index = bind_count; + set_bind_count(bind_count + 1); + set_bind_bone(index, p_bone); + set_bind_pose(index, p_pose); +} + +void Skin::set_bind_bone(int p_index, int p_bone) { + ERR_FAIL_INDEX(p_index, bind_count); + binds_ptr[p_index].bone = p_bone; + emit_changed(); +} + +void Skin::set_bind_pose(int p_index, const Transform &p_pose) { + ERR_FAIL_INDEX(p_index, bind_count); + binds_ptr[p_index].pose = p_pose; + emit_changed(); +} + +void Skin::clear_binds() { + binds.clear(); + binds_ptr = nullptr; + bind_count = 0; + emit_changed(); +} + +bool Skin::_set(const StringName &p_name, const Variant &p_value) { + String name = p_name; + if (name == "bind_count") { + set_bind_count(p_value); + return true; + } else if (name.begins_with("bind/")) { + int index = name.get_slicec('/', 1).to_int(); + String what = name.get_slicec('/', 2); + if (what == "bone") { + set_bind_bone(index, p_value); + return true; + } else if (what == "pose") { + set_bind_pose(index, p_value); + return true; + } + } + return false; +} + +bool Skin::_get(const StringName &p_name, Variant &r_ret) const { + + String name = p_name; + if (name == "bind_count") { + r_ret = get_bind_count(); + return true; + } else if (name.begins_with("bind/")) { + int index = name.get_slicec('/', 1).to_int(); + String what = name.get_slicec('/', 2); + if (what == "bone") { + r_ret = get_bind_bone(index); + return true; + } else if (what == "pose") { + r_ret = get_bind_pose(index); + return true; + } + } + return false; +} +void Skin::_get_property_list(List<PropertyInfo> *p_list) const { + p_list->push_back(PropertyInfo(Variant::INT, "bind_count", PROPERTY_HINT_RANGE, "0,16384,1,or_greater")); + for (int i = 0; i < get_bind_count(); i++) { + p_list->push_back(PropertyInfo(Variant::INT, "bind/" + itos(i) + "/bone", PROPERTY_HINT_RANGE, "0,16384,1,or_greater")); + p_list->push_back(PropertyInfo(Variant::TRANSFORM, "bind/" + itos(i) + "/pose")); + } +} + +void Skin::_bind_methods() { + + ClassDB::bind_method(D_METHOD("set_bind_count", "bind_count"), &Skin::set_bind_count); + ClassDB::bind_method(D_METHOD("get_bind_count"), &Skin::get_bind_count); + + ClassDB::bind_method(D_METHOD("add_bind", "bone", "pose"), &Skin::add_bind); + + ClassDB::bind_method(D_METHOD("set_bind_pose", "bind_index", "pose"), &Skin::set_bind_pose); + ClassDB::bind_method(D_METHOD("get_bind_pose", "bind_index"), &Skin::get_bind_pose); + + ClassDB::bind_method(D_METHOD("set_bind_bone", "bind_index", "bone"), &Skin::set_bind_bone); + ClassDB::bind_method(D_METHOD("get_bind_bone", "bind_index"), &Skin::get_bind_bone); + + ClassDB::bind_method(D_METHOD("clear_binds"), &Skin::clear_binds); +} + +Skin::Skin() { + bind_count = 0; + binds_ptr = nullptr; +} diff --git a/scene/resources/skin.h b/scene/resources/skin.h new file mode 100644 index 0000000000..7dd02eca5d --- /dev/null +++ b/scene/resources/skin.h @@ -0,0 +1,84 @@ +/*************************************************************************/ +/* skin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2019 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2019 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 SKIN_H +#define SKIN_H + +#include "core/resource.h" + +class Skin : public Resource { + GDCLASS(Skin, Resource) + + struct Bind { + int bone; + Transform pose; + }; + + Vector<Bind> binds; + + Bind *binds_ptr; + int bind_count; + +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; + + static void _bind_methods(); + +public: + void set_bind_count(int p_size); + inline int get_bind_count() const { return bind_count; } + + void add_bind(int p_bone, const Transform &p_pose); + + void set_bind_bone(int p_index, int p_bone); + void set_bind_pose(int p_index, const Transform &p_pose); + + inline int get_bind_bone(int p_index) const { +#ifdef DEBUG_ENABLED + ERR_FAIL_INDEX_V(p_index, bind_count, -1); +#endif + return binds_ptr[p_index].bone; + } + + inline Transform get_bind_pose(int p_index) const { +#ifdef DEBUG_ENABLED + ERR_FAIL_INDEX_V(p_index, bind_count, Transform()); +#endif + return binds_ptr[p_index].pose; + } + + void clear_binds(); + + Skin(); +}; + +#endif // SKIN_H diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp index f5ea6adc85..3f2261b043 100644 --- a/scene/resources/visual_shader.cpp +++ b/scene/resources/visual_shader.cpp @@ -2410,10 +2410,10 @@ void VisualShaderNodeGroupBase::_bind_methods() { ClassDB::bind_method(D_METHOD("has_output_port", "id"), &VisualShaderNodeGroupBase::has_output_port); ClassDB::bind_method(D_METHOD("clear_output_ports"), &VisualShaderNodeGroupBase::clear_output_ports); - ClassDB::bind_method(D_METHOD("set_input_port_name"), &VisualShaderNodeGroupBase::set_input_port_name); - ClassDB::bind_method(D_METHOD("set_input_port_type"), &VisualShaderNodeGroupBase::set_input_port_type); - ClassDB::bind_method(D_METHOD("set_output_port_name"), &VisualShaderNodeGroupBase::set_output_port_name); - ClassDB::bind_method(D_METHOD("set_output_port_type"), &VisualShaderNodeGroupBase::set_output_port_type); + ClassDB::bind_method(D_METHOD("set_input_port_name", "id", "name"), &VisualShaderNodeGroupBase::set_input_port_name); + ClassDB::bind_method(D_METHOD("set_input_port_type", "id", "type"), &VisualShaderNodeGroupBase::set_input_port_type); + ClassDB::bind_method(D_METHOD("set_output_port_name", "id", "name"), &VisualShaderNodeGroupBase::set_output_port_name); + ClassDB::bind_method(D_METHOD("set_output_port_type", "id", "type"), &VisualShaderNodeGroupBase::set_output_port_type); ClassDB::bind_method(D_METHOD("get_free_input_port_id"), &VisualShaderNodeGroupBase::get_free_input_port_id); ClassDB::bind_method(D_METHOD("get_free_output_port_id"), &VisualShaderNodeGroupBase::get_free_output_port_id); diff --git a/servers/camera_server.h b/servers/camera_server.h index 5a62af3d60..c76d046e58 100644 --- a/servers/camera_server.h +++ b/servers/camera_server.h @@ -81,7 +81,7 @@ public: void remove_feed(const Ref<CameraFeed> &p_feed); // get our feeds - Ref<CameraFeed> get_feed(int p_idx); + Ref<CameraFeed> get_feed(int p_index); int get_feed_count(); Array get_feeds(); diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 31b468b50b..9aaebefd80 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -357,7 +357,6 @@ public: virtual void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) = 0; virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const = 0; virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) = 0; - virtual void skeleton_set_world_transform(RID p_skeleton, bool p_enable, const Transform &p_world_transform) = 0; /* Light API */ diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index dcfbd28dd6..0df228457e 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -294,7 +294,6 @@ public: BIND3(skeleton_bone_set_transform_2d, RID, int, const Transform2D &) BIND2RC(Transform2D, skeleton_bone_get_transform_2d, RID, int) BIND2(skeleton_set_base_transform_2d, RID, const Transform2D &) - BIND3(skeleton_set_world_transform, RID, bool, const Transform &) /* Light API */ diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 41993d7c88..273cf728c1 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -230,7 +230,6 @@ public: FUNC3(skeleton_bone_set_transform_2d, RID, int, const Transform2D &) FUNC2RC(Transform2D, skeleton_bone_get_transform_2d, RID, int) FUNC2(skeleton_set_base_transform_2d, RID, const Transform2D &) - FUNC3(skeleton_set_world_transform, RID, bool, const Transform &) /* Light API */ diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 13fcda2402..2e1f524362 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -1973,7 +1973,7 @@ void VisualServer::_bind_methods() { ClassDB::bind_method(D_METHOD("canvas_item_add_primitive", "item", "points", "colors", "uvs", "texture", "width", "normal_map"), &VisualServer::canvas_item_add_primitive, DEFVAL(1.0), DEFVAL(RID())); ClassDB::bind_method(D_METHOD("canvas_item_add_polygon", "item", "points", "colors", "uvs", "texture", "normal_map", "antialiased"), &VisualServer::canvas_item_add_polygon, DEFVAL(Vector<Point2>()), DEFVAL(RID()), DEFVAL(RID()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("canvas_item_add_triangle_array", "item", "indices", "points", "colors", "uvs", "bones", "weights", "texture", "count", "normal_map"), &VisualServer::canvas_item_add_triangle_array, DEFVAL(Vector<Point2>()), DEFVAL(Vector<int>()), DEFVAL(Vector<float>()), DEFVAL(RID()), DEFVAL(-1), DEFVAL(RID())); - ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "texture", "normal_map"), &VisualServer::canvas_item_add_mesh, DEFVAL(RID())); + ClassDB::bind_method(D_METHOD("canvas_item_add_mesh", "item", "mesh", "transform", "modulate", "texture", "normal_map"), &VisualServer::canvas_item_add_mesh, DEFVAL(Transform2D()), DEFVAL(Color(1, 1, 1)), DEFVAL(RID()), DEFVAL(RID())); ClassDB::bind_method(D_METHOD("canvas_item_add_multimesh", "item", "mesh", "texture", "normal_map"), &VisualServer::canvas_item_add_multimesh, DEFVAL(RID())); ClassDB::bind_method(D_METHOD("canvas_item_add_particles", "item", "particles", "texture", "normal_map"), &VisualServer::canvas_item_add_particles); ClassDB::bind_method(D_METHOD("canvas_item_add_set_transform", "item", "transform"), &VisualServer::canvas_item_add_set_transform); diff --git a/servers/visual_server.h b/servers/visual_server.h index 1b0164e5ca..5e6c4d9b1e 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -391,7 +391,6 @@ public: virtual void skeleton_bone_set_transform_2d(RID p_skeleton, int p_bone, const Transform2D &p_transform) = 0; virtual Transform2D skeleton_bone_get_transform_2d(RID p_skeleton, int p_bone) const = 0; virtual void skeleton_set_base_transform_2d(RID p_skeleton, const Transform2D &p_base_transform) = 0; - virtual void skeleton_set_world_transform(RID p_skeleton, bool p_enable, const Transform &p_base_transform) = 0; /* Light API */ |