diff options
338 files changed, 3167 insertions, 1828 deletions
diff --git a/.clang-format b/.clang-format index 0407a7aeb3..bc69a6a3a6 100644 --- a/.clang-format +++ b/.clang-format @@ -1,15 +1,14 @@ ---- -BasedOnStyle: LLVM # Commented out parameters are those with the same value as base LLVM style # We can uncomment them if we want to change their value, or enforce the -# chosen value in case the base style changes (initial sync: Clang 3.9.1). -... -Language: Cpp +# chosen value in case the base style changes (last sync: Clang 5.0.0). +--- +### General config, applies to all languages ### +BasedOnStyle: LLVM AccessModifierOffset: -4 AlignAfterOpenBracket: DontAlign # AlignConsecutiveAssignments: false # AlignConsecutiveDeclarations: false -# AlignEscapedNewlinesLeft: false +# AlignEscapedNewlines: Right # AlignOperands: true AlignTrailingComments: false AllowAllParametersOfDeclarationOnNextLine: false @@ -36,22 +35,32 @@ AllowShortIfStatementsOnASingleLine: true # BeforeCatch: false # BeforeElse: false # IndentBraces: false +# SplitEmptyFunction: true +# SplitEmptyRecord: true +# SplitEmptyNamespace: true # BreakBeforeBinaryOperators: None # BreakBeforeBraces: Attach +# BreakBeforeInheritanceComma: false BreakBeforeTernaryOperators: false # BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializers: AfterColon # BreakAfterJavaFieldAnnotations: false # BreakStringLiterals: true ColumnLimit: 0 # CommentPragmas: '^ IWYU pragma:' -# ConstructorInitializerAllOnOneLineOrOnePerLine: false -# ConstructorInitializerIndentWidth: 4 +# CompactNamespaces: false +ConstructorInitializerAllOnOneLineOrOnePerLine: true +ConstructorInitializerIndentWidth: 8 ContinuationIndentWidth: 8 Cpp11BracedListStyle: false # DerivePointerAlignment: false # DisableFormat: false # ExperimentalAutoDetectBinPacking: false -# ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] +# FixNamespaceComments: true +# ForEachMacros: +# - foreach +# - Q_FOREACH +# - BOOST_FOREACH IncludeCategories: - Regex: '".*"' Priority: 1 @@ -59,7 +68,7 @@ IncludeCategories: Priority: 2 - Regex: '^<.*' Priority: 3 -# IncludeIsMainRegex: '$' +# IncludeIsMainRegex: '(Test)?$' IndentCaseLabels: true IndentWidth: 4 # IndentWrappedFunctionNames: false @@ -70,19 +79,19 @@ IndentWidth: 4 # MacroBlockEnd: '' # MaxEmptyLinesToKeep: 1 # NamespaceIndentation: None -ObjCBlockIndentWidth: 4 -# ObjCSpaceAfterProperty: false -# ObjCSpaceBeforeProtocolList: true +# PenaltyBreakAssignment: 2 # PenaltyBreakBeforeFirstCallParameter: 19 # PenaltyBreakComment: 300 # PenaltyBreakFirstLessLess: 120 # PenaltyBreakString: 1000 # PenaltyExcessCharacter: 1000000 # PenaltyReturnTypeOnItsOwnLine: 60 -PointerAlignment: Right +# PointerAlignment: Right # ReflowComments: true -SortIncludes: true +# SortIncludes: true +# SortUsingDeclarations: true # SpaceAfterCStyleCast: false +# SpaceAfterTemplateKeyword: true # SpaceBeforeAssignmentOperators: true # SpaceBeforeParens: ControlStatements # SpaceInEmptyParentheses: false @@ -92,7 +101,16 @@ SortIncludes: true # SpacesInCStyleCastParentheses: false # SpacesInParentheses: false # SpacesInSquareBrackets: false -Standard: Cpp03 TabWidth: 4 UseTab: Always +--- +### C++ specific config ### +Language: Cpp +Standard: Cpp03 +--- +### ObjC specific config ### +Language: ObjC +ObjCBlockIndentWidth: 4 +# ObjCSpaceAfterProperty: false +# ObjCSpaceBeforeProtocolList: true ... diff --git a/.travis.yml b/.travis.yml index acab89e516..c11a21aeef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,9 +30,9 @@ matrix: - env: GODOT_TARGET=android TOOLS=no CACHE_NAME=${GODOT_TARGET}-gcc os: linux compiler: gcc - - env: GODOT_TARGET=osx TOOLS=yes CACHE_NAME=${GODOT_TARGET}-clang-tools - os: osx - compiler: clang + #- env: GODOT_TARGET=osx TOOLS=yes CACHE_NAME=${GODOT_TARGET}-clang-tools + # os: osx + # compiler: clang #- env: GODOT_TARGET=iphone TOOLS=no CACHE_NAME=${GODOT_TARGET}-clang # os: osx # compiler: clang @@ -41,7 +41,7 @@ addons: apt: sources: - ubuntu-toolchain-r-test - - llvm-toolchain-trusty-3.9 + - llvm-toolchain-trusty-5.0 packages: - build-essential - scons @@ -55,6 +55,7 @@ addons: - libssl-dev - libxinerama-dev - libxrandr-dev + - libxi-dev # For cross-compiling to Windows. #- binutils-mingw-w64-i686 @@ -66,7 +67,7 @@ addons: #- mingw-w64 # For style checks. - - clang-format-3.9 + - clang-format-5.0 install: - if [ "$TRAVIS_OS_NAME" = "linux" ] && [ "$GODOT_TARGET" = "android" ]; then diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 999befaf67..f6011c3976 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -2694,12 +2694,12 @@ Variant JSONParseResult::get_result() const { } void _JSON::_bind_methods() { - ClassDB::bind_method(D_METHOD("print", "value"), &_JSON::print); + ClassDB::bind_method(D_METHOD("print", "value", "indent", "sort_keys"), &_JSON::print, DEFVAL(String()), DEFVAL(false)); ClassDB::bind_method(D_METHOD("parse", "json"), &_JSON::parse); } -String _JSON::print(const Variant &p_value) { - return JSON::print(p_value); +String _JSON::print(const Variant &p_value, const String &p_indent, bool p_sort_keys) { + return JSON::print(p_value, p_indent, p_sort_keys); } Ref<JSONParseResult> _JSON::parse(const String &p_json) { diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index 8163b08d76..b642a907fb 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -719,7 +719,7 @@ protected: public: static _JSON *get_singleton() { return singleton; } - String print(const Variant &p_value); + String print(const Variant &p_value, const String &p_indent = "", bool p_sort_keys = false); Ref<JSONParseResult> parse(const String &p_json); _JSON(); diff --git a/core/class_db.h b/core/class_db.h index 24db4c61bb..b8b681301d 100644 --- a/core/class_db.h +++ b/core/class_db.h @@ -49,10 +49,10 @@ struct MethodDefinition { StringName name; Vector<StringName> args; MethodDefinition() {} - MethodDefinition(const char *p_name) - : name(p_name) {} - MethodDefinition(const StringName &p_name) - : name(p_name) {} + MethodDefinition(const char *p_name) : + name(p_name) {} + MethodDefinition(const StringName &p_name) : + name(p_name) {} }; MethodDefinition D_METHOD(const char *p_name); diff --git a/core/core_string_names.cpp b/core/core_string_names.cpp index feee39225f..3091c80607 100644 --- a/core/core_string_names.cpp +++ b/core/core_string_names.cpp @@ -31,22 +31,22 @@ CoreStringNames *CoreStringNames::singleton = NULL; -CoreStringNames::CoreStringNames() - : _free(StaticCString::create("free")), - changed(StaticCString::create("changed")), - _meta(StaticCString::create("__meta__")), - _script(StaticCString::create("script")), - script_changed(StaticCString::create("script_changed")), - ___pdcdata(StaticCString::create("___pdcdata")), - __getvar(StaticCString::create("__getvar")), - _iter_init(StaticCString::create("_iter_init")), - _iter_next(StaticCString::create("_iter_next")), - _iter_get(StaticCString::create("_iter_get")), - get_rid(StaticCString::create("get_rid")), +CoreStringNames::CoreStringNames() : + _free(StaticCString::create("free")), + changed(StaticCString::create("changed")), + _meta(StaticCString::create("__meta__")), + _script(StaticCString::create("script")), + script_changed(StaticCString::create("script_changed")), + ___pdcdata(StaticCString::create("___pdcdata")), + __getvar(StaticCString::create("__getvar")), + _iter_init(StaticCString::create("_iter_init")), + _iter_next(StaticCString::create("_iter_next")), + _iter_get(StaticCString::create("_iter_get")), + get_rid(StaticCString::create("get_rid")), #ifdef TOOLS_ENABLED - _sections_unfolded(StaticCString::create("_sections_unfolded")), + _sections_unfolded(StaticCString::create("_sections_unfolded")), #endif - _custom_features(StaticCString::create("_custom_features")) { + _custom_features(StaticCString::create("_custom_features")) { x = StaticCString::create("x"); y = StaticCString::create("y"); diff --git a/core/dictionary.cpp b/core/dictionary.cpp index 48e65c734f..44fce2474f 100644 --- a/core/dictionary.cpp +++ b/core/dictionary.cpp @@ -204,7 +204,9 @@ const Variant *Dictionary::next(const Variant *p_key) const { if (p_key == NULL) { // caller wants to get the first element - return &_p->variant_map.front().key(); + if (_p->variant_map.front()) + return &_p->variant_map.front().key(); + return NULL; } OrderedHashMap<Variant, Variant, _DictionaryVariantHash>::Element E = _p->variant_map.find(*p_key); diff --git a/core/dvector.h b/core/dvector.h index 1b81ceec5e..66bf0e7862 100644 --- a/core/dvector.h +++ b/core/dvector.h @@ -149,7 +149,7 @@ class PoolVector { } if (old_alloc->refcount.unref() == true) { -//this should never happen but.. + //this should never happen but.. #ifdef DEBUG_ENABLED MemoryPool::alloc_mutex->lock(); diff --git a/core/engine.h b/core/engine.h index 4a573c1539..1becebe34a 100644 --- a/core/engine.h +++ b/core/engine.h @@ -41,9 +41,9 @@ public: struct Singleton { StringName name; Object *ptr; - Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL) - : name(p_name), - ptr(p_ptr) { + Singleton(const StringName &p_name = StringName(), Object *p_ptr = NULL) : + name(p_name), + ptr(p_ptr) { } }; diff --git a/core/global_constants.cpp b/core/global_constants.cpp index fb432b85db..a8f6e4da6c 100644 --- a/core/global_constants.cpp +++ b/core/global_constants.cpp @@ -45,15 +45,15 @@ struct _GlobalConstant { _GlobalConstant() {} #ifdef DEBUG_METHODS_ENABLED - _GlobalConstant(const StringName &p_enum_name, const char *p_name, int p_value) - : enum_name(p_enum_name), - name(p_name), - value(p_value) { + _GlobalConstant(const StringName &p_enum_name, const char *p_name, int p_value) : + enum_name(p_enum_name), + name(p_name), + value(p_value) { } #else - _GlobalConstant(const char *p_name, int p_value) - : name(p_name), - value(p_value) { + _GlobalConstant(const char *p_name, int p_value) : + name(p_name), + value(p_value) { } #endif }; diff --git a/core/hash_map.h b/core/hash_map.h index e100d7a904..a53cb53c84 100644 --- a/core/hash_map.h +++ b/core/hash_map.h @@ -63,9 +63,9 @@ public: TData data; Pair() {} - Pair(const TKey &p_key, const TData &p_data) - : key(p_key), - data(p_data) { + Pair(const TKey &p_key, const TData &p_data) : + key(p_key), + data(p_data) { } }; diff --git a/core/helper/math_fieldwise.cpp b/core/helper/math_fieldwise.cpp index 2cd8a4f392..9e5eab2ee8 100644 --- a/core/helper/math_fieldwise.cpp +++ b/core/helper/math_fieldwise.cpp @@ -44,10 +44,10 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const ERR_FAIL_COND_V(p_target.get_type() != p_source.get_type(), p_target); - switch (p_source.get_type()) { + /* clang-format makes a mess of this macro usage */ + /* clang-format off */ - /* clang-format makes a mess of this macro usage */ - /* clang-format off */ + switch (p_source.get_type()) { case Variant::VECTOR2: { @@ -174,9 +174,8 @@ Variant fieldwise_assign(const Variant &p_target, const Variant &p_source, const default: { ERR_FAIL_V(p_target); } - - /* clang-format on */ } + /* clang-format on */ } #endif // TOOLS_ENABLED diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index a7eb8ce6a9..c46e645ed8 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -313,9 +313,9 @@ bool FileAccessPack::file_exists(const String &p_name) { return false; } -FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) - : pf(p_file), - f(FileAccess::open(pf.pack, FileAccess::READ)) { +FileAccessPack::FileAccessPack(const String &p_path, const PackedData::PackedFile &p_file) : + pf(p_file), + f(FileAccess::open(pf.pack, FileAccess::READ)) { if (!f) { ERR_EXPLAIN("Can't open pack-referenced file: " + String(pf.pack)); ERR_FAIL_COND(!f); diff --git a/core/io/json.cpp b/core/io/json.cpp index 2e9170bc34..ddfc792cc7 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -43,7 +43,25 @@ const char *JSON::tk_name[TK_MAX] = { "EOF", }; -String JSON::_print_var(const Variant &p_var) { +static String _make_indent(const String& p_indent, int p_size) { + + String indent_text = ""; + if (!p_indent.empty()) { + for (int i = 0; i < p_size; i++) + indent_text += p_indent; + } + return indent_text; +} + +String JSON::_print_var(const Variant &p_var, const String& p_indent, int p_cur_indent, bool p_sort_keys) { + + String colon = ":"; + String end_statement = ""; + + if (!p_indent.empty()) { + colon += " "; + end_statement += "\n"; + } switch (p_var.get_type()) { @@ -57,41 +75,50 @@ String JSON::_print_var(const Variant &p_var) { case Variant::ARRAY: { String s = "["; + s += end_statement; Array a = p_var; for (int i = 0; i < a.size(); i++) { - if (i > 0) - s += ", "; - s += _print_var(a[i]); + if (i > 0) { + s += ","; + s += end_statement; + } + s += _make_indent(p_indent, p_cur_indent + 1) + _print_var(a[i], p_indent, p_cur_indent + 1, p_sort_keys); } - s += "]"; + s += end_statement + _make_indent(p_indent, p_cur_indent) + "]"; return s; }; case Variant::DICTIONARY: { String s = "{"; + s += end_statement; Dictionary d = p_var; List<Variant> keys; d.get_key_list(&keys); + if (p_sort_keys) + keys.sort(); + for (List<Variant>::Element *E = keys.front(); E; E = E->next()) { - if (E != keys.front()) - s += ", "; - s += _print_var(String(E->get())); - s += ":"; - s += _print_var(d[E->get()]); + if (E != keys.front()) { + s += ","; + s += end_statement; + } + s += _make_indent(p_indent, p_cur_indent + 1) + _print_var(String(E->get()), p_indent, p_cur_indent + 1, p_sort_keys); + s += colon; + s += _print_var(d[E->get()], p_indent, p_cur_indent + 1, p_sort_keys); } - s += "}"; + s += end_statement + _make_indent(p_indent, p_cur_indent) + "}"; return s; }; default: return "\"" + String(p_var).json_escape() + "\""; } } -String JSON::print(const Variant &p_var) { +String JSON::print(const Variant &p_var, const String& p_indent, bool p_sort_keys) { - return _print_var(p_var); + return _print_var(p_var, p_indent, 0, p_sort_keys); } Error JSON::_get_token(const CharType *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str) { diff --git a/core/io/json.h b/core/io/json.h index 893a88e264..5e1a89f069 100644 --- a/core/io/json.h +++ b/core/io/json.h @@ -64,7 +64,7 @@ class JSON { static const char *tk_name[TK_MAX]; - static String _print_var(const Variant &p_var); + static String _print_var(const Variant &p_var, const String& p_indent, int p_cur_indent, bool p_sort_keys); static Error _get_token(const CharType *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str); static Error _parse_value(Variant &value, Token &token, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str); @@ -72,7 +72,7 @@ class JSON { static Error _parse_object(Dictionary &object, const CharType *p_str, int &index, int p_len, int &line, String &r_err_str); public: - static String print(const Variant &p_var); + static String print(const Variant &p_var, const String& p_indent = "", bool p_sort_keys = true); static Error parse(const String &p_json, Variant &r_ret, String &r_err_str, int &r_err_line); }; diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 37320d7a77..7dd3468c48 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -159,8 +159,8 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int r_variant = str; } break; - // math types + // math types case Variant::VECTOR2: { ERR_FAIL_COND_V(len < (int)4 * 2, ERR_INVALID_DATA); @@ -959,8 +959,8 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo _encode_string(p_variant, buf, r_len); } break; - // math types + // math types case Variant::VECTOR2: { if (buf) { diff --git a/core/io/resource_import.h b/core/io/resource_import.h index 28489b5d34..166fff85cf 100644 --- a/core/io/resource_import.h +++ b/core/io/resource_import.h @@ -90,9 +90,9 @@ public: PropertyInfo option; Variant default_value; - ImportOption(const PropertyInfo &p_info, const Variant &p_default) - : option(p_info), - default_value(p_default) { + ImportOption(const PropertyInfo &p_info, const Variant &p_default) : + option(p_info), + default_value(p_default) { } ImportOption() {} }; diff --git a/core/math/a_star.h b/core/math/a_star.h index b7b7e54125..1f13f4fae8 100644 --- a/core/math/a_star.h +++ b/core/math/a_star.h @@ -59,8 +59,8 @@ class AStar : public Reference { Point *prev_point; real_t distance; - Point() - : list(this) {} + Point() : + list(this) {} }; Map<int, Point *> points; diff --git a/core/math/aabb.h b/core/math/aabb.h index c60213496a..c5ba79e172 100644 --- a/core/math/aabb.h +++ b/core/math/aabb.h @@ -101,9 +101,9 @@ public: operator String() const; _FORCE_INLINE_ AABB() {} - inline AABB(const Vector3 &p_pos, const Vector3 &p_size) - : position(p_pos), - size(p_size) { + inline AABB(const Vector3 &p_pos, const Vector3 &p_size) : + position(p_pos), + size(p_size) { } }; diff --git a/core/math/bsp_tree.cpp b/core/math/bsp_tree.cpp index bdc040160f..ecda777583 100644 --- a/core/math/bsp_tree.cpp +++ b/core/math/bsp_tree.cpp @@ -577,11 +577,11 @@ BSP_Tree::BSP_Tree(const PoolVector<Face3> &p_faces, real_t p_error_radius) { error_radius = p_error_radius; } -BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius) - : nodes(p_nodes), - planes(p_planes), - aabb(p_aabb), - error_radius(p_error_radius) { +BSP_Tree::BSP_Tree(const Vector<Node> &p_nodes, const Vector<Plane> &p_planes, const AABB &p_aabb, real_t p_error_radius) : + nodes(p_nodes), + planes(p_planes), + aabb(p_aabb), + error_radius(p_error_radius) { } BSP_Tree::~BSP_Tree() { diff --git a/core/math/face3.cpp b/core/math/face3.cpp index 070ce77db4..7e586a1fd2 100644 --- a/core/math/face3.cpp +++ b/core/math/face3.cpp @@ -195,9 +195,8 @@ bool Face3::intersects_aabb(const AABB &p_aabb) const { if (!p_aabb.intersects_plane(get_plane())) return false; - /** TEST FACE AXIS */ - #define TEST_AXIS(m_ax) \ + /** TEST FACE AXIS */ \ { \ real_t aabb_min = p_aabb.position.m_ax; \ real_t aabb_max = p_aabb.position.m_ax + p_aabb.size.m_ax; \ diff --git a/core/math/face3.h b/core/math/face3.h index 561fa31238..9a1f6b2c2e 100644 --- a/core/math/face3.h +++ b/core/math/face3.h @@ -256,6 +256,4 @@ bool Face3::intersects_aabb2(const AABB &p_aabb) const { return true; } - //this sucks... - #endif // FACE3_H diff --git a/core/math/math_2d.h b/core/math/math_2d.h index d215df8a43..d788318f5e 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -385,13 +385,13 @@ struct Rect2 { operator String() const { return String(position) + ", " + String(size); } Rect2() {} - Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height) - : position(Point2(p_x, p_y)), - size(Size2(p_width, p_height)) { + Rect2(real_t p_x, real_t p_y, real_t p_width, real_t p_height) : + position(Point2(p_x, p_y)), + size(Size2(p_width, p_height)) { } - Rect2(const Point2 &p_pos, const Size2 &p_size) - : position(p_pos), - size(p_size) { + Rect2(const Point2 &p_pos, const Size2 &p_size) : + position(p_pos), + size(p_size) { } }; @@ -578,18 +578,18 @@ struct Rect2i { operator String() const { return String(position) + ", " + String(size); } operator Rect2() const { return Rect2(position, size); } - Rect2i(const Rect2 &p_r2) - : position(p_r2.position), - size(p_r2.size) { + Rect2i(const Rect2 &p_r2) : + position(p_r2.position), + size(p_r2.size) { } Rect2i() {} - Rect2i(int p_x, int p_y, int p_width, int p_height) - : position(Point2(p_x, p_y)), - size(Size2(p_width, p_height)) { + Rect2i(int p_x, int p_y, int p_width, int p_height) : + position(Point2(p_x, p_y)), + size(Size2(p_width, p_height)) { } - Rect2i(const Point2 &p_pos, const Size2 &p_size) - : position(p_pos), - size(p_size) { + Rect2i(const Point2 &p_pos, const Size2 &p_size) : + position(p_pos), + size(p_size) { } }; diff --git a/core/math/math_funcs.h b/core/math/math_funcs.h index bc0b3717ed..80e5805451 100644 --- a/core/math/math_funcs.h +++ b/core/math/math_funcs.h @@ -272,7 +272,7 @@ public: #elif defined(_MSC_VER) && _MSC_VER < 1800 __asm fld a __asm fistp b -/*#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) + /*#elif defined( __GNUC__ ) && ( defined( __i386__ ) || defined( __x86_64__ ) ) // use AT&T inline assembly style, document that // we use memory as output (=m) and input (m) __asm__ __volatile__ ( diff --git a/core/math/plane.h b/core/math/plane.h index 559a735817..1d02b5d523 100644 --- a/core/math/plane.h +++ b/core/math/plane.h @@ -74,9 +74,9 @@ public: operator String() const; _FORCE_INLINE_ Plane() { d = 0; } - _FORCE_INLINE_ Plane(real_t p_a, real_t p_b, real_t p_c, real_t p_d) - : normal(p_a, p_b, p_c), - d(p_d){}; + _FORCE_INLINE_ Plane(real_t p_a, real_t p_b, real_t p_c, real_t p_d) : + normal(p_a, p_b, p_c), + d(p_d){}; _FORCE_INLINE_ Plane(const Vector3 &p_normal, real_t p_d); _FORCE_INLINE_ Plane(const Vector3 &p_point, const Vector3 &p_normal); @@ -100,14 +100,14 @@ bool Plane::has_point(const Vector3 &p_point, real_t _epsilon) const { return (dist <= _epsilon); } -Plane::Plane(const Vector3 &p_normal, real_t p_d) - : normal(p_normal), - d(p_d) { +Plane::Plane(const Vector3 &p_normal, real_t p_d) : + normal(p_normal), + d(p_d) { } -Plane::Plane(const Vector3 &p_point, const Vector3 &p_normal) - : normal(p_normal), - d(p_normal.dot(p_point)) { +Plane::Plane(const Vector3 &p_point, const Vector3 &p_normal) : + normal(p_normal), + d(p_normal.dot(p_point)) { } Plane::Plane(const Vector3 &p_point1, const Vector3 &p_point2, const Vector3 &p_point3, ClockDirection p_dir) { diff --git a/core/math/transform.cpp b/core/math/transform.cpp index 638a39ab73..fb4ca16565 100644 --- a/core/math/transform.cpp +++ b/core/math/transform.cpp @@ -208,7 +208,7 @@ Transform::operator String() const { return basis.operator String() + " - " + origin.operator String(); } -Transform::Transform(const Basis &p_basis, const Vector3 &p_origin) - : basis(p_basis), - origin(p_origin) { +Transform::Transform(const Basis &p_basis, const Vector3 &p_origin) : + basis(p_basis), + origin(p_origin) { } diff --git a/core/object.cpp b/core/object.cpp index 1be7337d96..cf1472243b 100644 --- a/core/object.cpp +++ b/core/object.cpp @@ -126,9 +126,9 @@ MethodInfo::operator Dictionary() const { return d; } -MethodInfo::MethodInfo() - : flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo() : + flags(METHOD_FLAG_NORMAL), + id(0) { } MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) { @@ -164,48 +164,48 @@ MethodInfo MethodInfo::from_dict(const Dictionary &p_dict) { return mi; } -MethodInfo::MethodInfo(const String &p_name) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(const String &p_name) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { } -MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { arguments.push_back(p_param1); } -MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { arguments.push_back(p_param1); arguments.push_back(p_param2); } -MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); } -MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); arguments.push_back(p_param4); } -MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); @@ -213,48 +213,48 @@ MethodInfo::MethodInfo(const String &p_name, const PropertyInfo &p_param1, const arguments.push_back(p_param5); } -MethodInfo::MethodInfo(Variant::Type ret) - : flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(Variant::Type ret) : + flags(METHOD_FLAG_NORMAL), + id(0) { return_val.type = ret; } -MethodInfo::MethodInfo(Variant::Type ret, const String &p_name) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(Variant::Type ret, const String &p_name) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { return_val.type = ret; } -MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { return_val.type = ret; arguments.push_back(p_param1); } -MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { return_val.type = ret; arguments.push_back(p_param1); arguments.push_back(p_param2); } -MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { return_val.type = ret; arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); } -MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { return_val.type = ret; arguments.push_back(p_param1); arguments.push_back(p_param2); @@ -262,10 +262,10 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn arguments.push_back(p_param4); } -MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + id(0) { return_val.type = ret; arguments.push_back(p_param1); arguments.push_back(p_param2); @@ -274,56 +274,56 @@ MethodInfo::MethodInfo(Variant::Type ret, const String &p_name, const PropertyIn arguments.push_back(p_param5); } -MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name) - : name(p_name), - flags(METHOD_FLAG_NORMAL), - return_val(p_ret), - id(0) { +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name) : + name(p_name), + flags(METHOD_FLAG_NORMAL), + return_val(p_ret), + id(0) { } -MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1) - : name(p_name), - return_val(p_ret), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1) : + name(p_name), + return_val(p_ret), + flags(METHOD_FLAG_NORMAL), + id(0) { arguments.push_back(p_param1); } -MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) - : name(p_name), - return_val(p_ret), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2) : + name(p_name), + return_val(p_ret), + flags(METHOD_FLAG_NORMAL), + id(0) { arguments.push_back(p_param1); arguments.push_back(p_param2); } -MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) - : name(p_name), - return_val(p_ret), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3) : + name(p_name), + return_val(p_ret), + flags(METHOD_FLAG_NORMAL), + id(0) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); } -MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) - : name(p_name), - return_val(p_ret), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4) : + name(p_name), + return_val(p_ret), + flags(METHOD_FLAG_NORMAL), + id(0) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); arguments.push_back(p_param4); } -MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) - : name(p_name), - return_val(p_ret), - flags(METHOD_FLAG_NORMAL), - id(0) { +MethodInfo::MethodInfo(const PropertyInfo &p_ret, const String &p_name, const PropertyInfo &p_param1, const PropertyInfo &p_param2, const PropertyInfo &p_param3, const PropertyInfo &p_param4, const PropertyInfo &p_param5) : + name(p_name), + return_val(p_ret), + flags(METHOD_FLAG_NORMAL), + id(0) { arguments.push_back(p_param1); arguments.push_back(p_param2); arguments.push_back(p_param3); diff --git a/core/object.h b/core/object.h index 3ac699f978..3d93953227 100644 --- a/core/object.h +++ b/core/object.h @@ -109,10 +109,11 @@ enum PropertyUsageFlags { PROPERTY_USAGE_SCRIPT_DEFAULT_VALUE = 1 << 17, PROPERTY_USAGE_CLASS_IS_ENUM = 1 << 18, PROPERTY_USAGE_NIL_IS_VARIANT = 1 << 19, + PROPERTY_USAGE_INTERNAL = 1 << 20, PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK, PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNATIONALIZED, - PROPERTY_USAGE_NOEDITOR = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_NETWORK, + PROPERTY_USAGE_NOEDITOR = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNAL, }; #define ADD_SIGNAL(m_signal) ClassDB::add_signal(get_class_static(), m_signal) @@ -143,18 +144,18 @@ struct PropertyInfo { static PropertyInfo from_dict(const Dictionary &p_dict); - PropertyInfo() - : type(Variant::NIL), - hint(PROPERTY_HINT_NONE), - usage(PROPERTY_USAGE_DEFAULT) { + PropertyInfo() : + type(Variant::NIL), + hint(PROPERTY_HINT_NONE), + usage(PROPERTY_USAGE_DEFAULT) { } - PropertyInfo(Variant::Type p_type, const String p_name, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", uint32_t p_usage = PROPERTY_USAGE_DEFAULT, const StringName &p_class_name = StringName()) - : type(p_type), - name(p_name), - hint(p_hint), - hint_string(p_hint_string), - usage(p_usage) { + PropertyInfo(Variant::Type p_type, const String p_name, PropertyHint p_hint = PROPERTY_HINT_NONE, const String &p_hint_string = "", uint32_t p_usage = PROPERTY_USAGE_DEFAULT, const StringName &p_class_name = StringName()) : + type(p_type), + name(p_name), + hint(p_hint), + hint_string(p_hint_string), + usage(p_usage) { if (hint == PROPERTY_HINT_RESOURCE_TYPE) { class_name = hint_string; @@ -163,11 +164,11 @@ struct PropertyInfo { } } - PropertyInfo(const StringName &p_class_name) - : type(Variant::OBJECT), - class_name(p_class_name), - hint(PROPERTY_HINT_NONE), - usage(PROPERTY_USAGE_DEFAULT) { + PropertyInfo(const StringName &p_class_name) : + type(Variant::OBJECT), + class_name(p_class_name), + hint(PROPERTY_HINT_NONE), + usage(PROPERTY_USAGE_DEFAULT) { } bool operator<(const PropertyInfo &p_info) const { @@ -427,9 +428,9 @@ private: _FORCE_INLINE_ bool operator<(const Target &p_target) const { return (_id == p_target._id) ? (method < p_target.method) : (_id < p_target._id); } - Target(const ObjectID &p_id, const StringName &p_method) - : _id(p_id), - method(p_method) { + Target(const ObjectID &p_id, const StringName &p_method) : + _id(p_id), + method(p_method) { } Target() { _id = 0; } }; diff --git a/core/ordered_hash_map.h b/core/ordered_hash_map.h index 1ed5a5d369..fed16809e6 100644 --- a/core/ordered_hash_map.h +++ b/core/ordered_hash_map.h @@ -68,8 +68,10 @@ public: } public: - _FORCE_INLINE_ Element() - : list_element(NULL), prev_element(NULL), next_element(NULL) { + _FORCE_INLINE_ Element() : + list_element(NULL), + prev_element(NULL), + next_element(NULL) { } Element next() const { @@ -80,10 +82,10 @@ public: return Element(prev_element); } - Element(const Element &other) - : list_element(other.list_element), - prev_element(other.prev_element), - next_element(other.next_element) { + Element(const Element &other) : + list_element(other.list_element), + prev_element(other.prev_element), + next_element(other.next_element) { } Element &operator=(const Element &other) { @@ -135,17 +137,17 @@ public: const typename InternalList::Element *list_element; - ConstElement(const typename InternalList::Element *p_element) - : list_element(p_element) { + ConstElement(const typename InternalList::Element *p_element) : + list_element(p_element) { } public: - _FORCE_INLINE_ ConstElement() - : list_element(NULL) { + _FORCE_INLINE_ ConstElement() : + list_element(NULL) { } - ConstElement(const ConstElement &other) - : list_element(other.list_element) { + ConstElement(const ConstElement &other) : + list_element(other.list_element) { } ConstElement &operator=(const ConstElement &other) { diff --git a/core/os/dir_access.cpp b/core/os/dir_access.cpp index 6d4b46f4da..e19c8e8ea5 100644 --- a/core/os/dir_access.cpp +++ b/core/os/dir_access.cpp @@ -333,6 +333,9 @@ Error DirAccess::copy(String p_from, String p_to, int chmod_flags) { if (err == OK && chmod_flags != -1) { fdst->close(); err = fdst->_chmod(p_to, chmod_flags); + // If running on a platform with no chmod support (i.e., Windows), don't fail + if (err == ERR_UNAVAILABLE) + err = OK; } memdelete(fsrc); diff --git a/core/os/file_access.h b/core/os/file_access.h index 455dd1ea99..6fda3d9668 100644 --- a/core/os/file_access.h +++ b/core/os/file_access.h @@ -141,7 +141,7 @@ public: virtual Error reopen(const String &p_path, int p_mode_flags); ///< does not change the AccessType - virtual Error _chmod(const String &p_path, int p_mod) { return FAILED; } + virtual Error _chmod(const String &p_path, int p_mod) { return ERR_UNAVAILABLE; } static FileAccess *create(AccessType p_access); /// Create a file access (for the current platform) this is the only portable way of accessing files. static FileAccess *create_for_path(const String &p_path); diff --git a/core/os/os.h b/core/os/os.h index 91fbf082bf..4f968020cc 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -195,7 +195,7 @@ public: virtual void set_ime_position(const Point2 &p_pos) {} virtual void set_ime_intermediate_text_callback(ImeCallback p_callback, void *p_inp) {} - virtual Error open_dynamic_library(const String p_path, void *&p_library_handle,bool p_also_set_library_path=false) { return ERR_UNAVAILABLE; } + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false) { return ERR_UNAVAILABLE; } virtual Error close_dynamic_library(void *p_library_handle) { return ERR_UNAVAILABLE; } virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false) { return ERR_UNAVAILABLE; } diff --git a/core/pair.h b/core/pair.h index 535c3355b6..aa51b77a4f 100644 --- a/core/pair.h +++ b/core/pair.h @@ -37,9 +37,9 @@ struct Pair { S second; Pair() {} - Pair(F p_first, const S &p_second) - : first(p_first), - second(p_second) { + Pair(F p_first, const S &p_second) : + first(p_first), + second(p_second) { } }; diff --git a/core/project_settings.h b/core/project_settings.h index 1c4078cebb..d8a1ea1f7a 100644 --- a/core/project_settings.h +++ b/core/project_settings.h @@ -58,18 +58,18 @@ protected: Variant initial; bool hide_from_editor; bool overrided; - VariantContainer() - : order(0), - persist(false), - hide_from_editor(false), - overrided(false) { + VariantContainer() : + order(0), + persist(false), + hide_from_editor(false), + overrided(false) { } - VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false) - : order(p_order), - persist(p_persist), - variant(p_variant), - hide_from_editor(false), - overrided(false) { + VariantContainer(const Variant &p_variant, int p_order, bool p_persist = false) : + order(p_order), + persist(p_persist), + variant(p_variant), + hide_from_editor(false), + overrided(false) { } }; diff --git a/core/resource.cpp b/core/resource.cpp index d339eb78ad..be6da792ad 100644 --- a/core/resource.cpp +++ b/core/resource.cpp @@ -378,8 +378,8 @@ void Resource::_bind_methods() { BIND_VMETHOD(MethodInfo("_setup_local_to_scene")); } -Resource::Resource() - : remapped_list(this) { +Resource::Resource() : + remapped_list(this) { #ifdef TOOLS_ENABLED last_modified_time = 0; diff --git a/core/safe_refcount.cpp b/core/safe_refcount.cpp index c9acdb7970..908c8a34b5 100644 --- a/core/safe_refcount.cpp +++ b/core/safe_refcount.cpp @@ -57,7 +57,7 @@ return m_val; \ } -_ALWAYS_INLINE_ uint32_t _atomic_conditional_increment_impl(register uint32_t *pw) { +_ALWAYS_INLINE_ uint32_t _atomic_conditional_increment_impl(register uint32_t *pw){ ATOMIC_CONDITIONAL_INCREMENT_BODY(pw, LONG, InterlockedCompareExchange, uint32_t) } @@ -82,12 +82,12 @@ _ALWAYS_INLINE_ uint32_t _atomic_add_impl(register uint32_t *pw, register uint32 return InterlockedAdd((LONG volatile *)pw, val); } -_ALWAYS_INLINE_ uint32_t _atomic_exchange_if_greater_impl(register uint32_t *pw, register uint32_t val) { +_ALWAYS_INLINE_ uint32_t _atomic_exchange_if_greater_impl(register uint32_t *pw, register uint32_t val){ ATOMIC_EXCHANGE_IF_GREATER_BODY(pw, val, LONG, InterlockedCompareExchange, uint32_t) } -_ALWAYS_INLINE_ uint64_t _atomic_conditional_increment_impl(register uint64_t *pw) { +_ALWAYS_INLINE_ uint64_t _atomic_conditional_increment_impl(register uint64_t *pw){ ATOMIC_CONDITIONAL_INCREMENT_BODY(pw, LONGLONG, InterlockedCompareExchange64, uint64_t) } @@ -112,7 +112,7 @@ _ALWAYS_INLINE_ uint64_t _atomic_add_impl(register uint64_t *pw, register uint64 return InterlockedAdd64((LONGLONG volatile *)pw, val); } -_ALWAYS_INLINE_ uint64_t _atomic_exchange_if_greater_impl(register uint64_t *pw, register uint64_t val) { +_ALWAYS_INLINE_ uint64_t _atomic_exchange_if_greater_impl(register uint64_t *pw, register uint64_t val){ ATOMIC_EXCHANGE_IF_GREATER_BODY(pw, val, LONGLONG, InterlockedCompareExchange64, uint64_t) } diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index 495c99c122..658b72b47a 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -989,25 +989,25 @@ void ScriptDebuggerRemote::profiling_set_frame_times(float p_frame_time, float p ScriptDebuggerRemote::ResourceUsageFunc ScriptDebuggerRemote::resource_usage_func = NULL; -ScriptDebuggerRemote::ScriptDebuggerRemote() - : profiling(false), - max_frame_functions(16), - skip_profile_frame(false), - reload_all_scripts(false), - tcp_client(StreamPeerTCP::create_ref()), - packet_peer_stream(Ref<PacketPeerStream>(memnew(PacketPeerStream))), - last_perf_time(0), - performance(Engine::get_singleton()->get_singleton_object("Performance")), - requested_quit(false), - mutex(Mutex::create()), - max_cps(GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second")), - char_count(0), - last_msec(0), - msec_count(0), - locking(false), - poll_every(0), - request_scene_tree(NULL), - live_edit_funcs(NULL) { +ScriptDebuggerRemote::ScriptDebuggerRemote() : + profiling(false), + max_frame_functions(16), + skip_profile_frame(false), + reload_all_scripts(false), + tcp_client(StreamPeerTCP::create_ref()), + packet_peer_stream(Ref<PacketPeerStream>(memnew(PacketPeerStream))), + last_perf_time(0), + performance(Engine::get_singleton()->get_singleton_object("Performance")), + requested_quit(false), + mutex(Mutex::create()), + max_cps(GLOBAL_GET("network/limits/debugger_stdout/max_chars_per_second")), + char_count(0), + last_msec(0), + msec_count(0), + locking(false), + poll_every(0), + request_scene_tree(NULL), + live_edit_funcs(NULL) { packet_peer_stream->set_stream_peer(tcp_client); packet_peer_stream->set_output_buffer_max_size(1024 * 1024 * 8); //8mb should be way more than enough diff --git a/core/script_language.cpp b/core/script_language.cpp index 384e41e4bd..c1e9d55872 100644 --- a/core/script_language.cpp +++ b/core/script_language.cpp @@ -387,10 +387,10 @@ void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, c //change notify } -PlaceHolderScriptInstance::PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner) - : owner(p_owner), - language(p_language), - script(p_script) { +PlaceHolderScriptInstance::PlaceHolderScriptInstance(ScriptLanguage *p_language, Ref<Script> p_script, Object *p_owner) : + owner(p_owner), + language(p_language), + script(p_script) { } PlaceHolderScriptInstance::~PlaceHolderScriptInstance() { diff --git a/core/translation.cpp b/core/translation.cpp index dcca58692a..515b5f1134 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -876,8 +876,8 @@ void Translation::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::STRING, "locale"), "set_locale", "get_locale"); } -Translation::Translation() - : locale("en") { +Translation::Translation() : + locale("en") { } /////////////////////////////////////////////// @@ -1163,9 +1163,9 @@ void TranslationServer::load_translations() { } } -TranslationServer::TranslationServer() - : locale("en"), - enabled(true) { +TranslationServer::TranslationServer() : + locale("en"), + enabled(true) { singleton = this; for (int i = 0; locale_list[i]; ++i) { diff --git a/core/typedefs.h b/core/typedefs.h index c509edf9fe..889513ddc9 100644 --- a/core/typedefs.h +++ b/core/typedefs.h @@ -73,7 +73,7 @@ T *_nullptr() { #define OFFSET_OF(st, m) \ ((size_t)((char *)&(_nullptr<st>()->m) - (char *)0)) -/** + /** * Some platforms (devices) not define NULL */ @@ -81,7 +81,7 @@ T *_nullptr() { #define NULL 0 #endif -/** + /** * Windows defines a lot of badly stuff we'll never ever use. undefine it. */ @@ -103,7 +103,7 @@ T *_nullptr() { #include "error_list.h" #include "error_macros.h" -/** Generic ABS function, for math uses please use Math::abs */ + /** Generic ABS function, for math uses please use Math::abs */ #ifndef ABS #define ABS(m_v) ((m_v < 0) ? (-(m_v)) : (m_v)) diff --git a/core/variant.cpp b/core/variant.cpp index 0f97b98a6f..7f0cabbce4 100644 --- a/core/variant.cpp +++ b/core/variant.cpp @@ -67,7 +67,6 @@ String Variant::get_type_name(Variant::Type p_type) { } break; // math types - case VECTOR2: { return "Vector2"; @@ -725,7 +724,6 @@ bool Variant::is_zero() const { } break; // math types - case VECTOR2: { return *reinterpret_cast<const Vector2 *>(_data._mem) == Vector2(); @@ -934,7 +932,6 @@ void Variant::reference(const Variant &p_variant) { } break; // math types - case VECTOR2: { memnew_placement(_data._mem, Vector2(*reinterpret_cast<const Vector2 *>(p_variant._data._mem))); @@ -2506,7 +2503,6 @@ void Variant::operator=(const Variant &p_variant) { } break; // math types - case VECTOR2: { *reinterpret_cast<Vector2 *>(_data._mem) = *reinterpret_cast<const Vector2 *>(p_variant._data._mem); @@ -2645,8 +2641,8 @@ uint32_t Variant::hash() const { return reinterpret_cast<const String *>(_data._mem)->hash(); } break; - // math types + // math types case VECTOR2: { uint32_t hash = hash_djb2_one_float(reinterpret_cast<const Vector2 *>(_data._mem)->x); diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 10f5ca0ce1..991573e8d7 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -130,9 +130,9 @@ struct _VariantCall { StringName name; Variant::Type type; Arg() { type = Variant::NIL; } - Arg(Variant::Type p_type, const StringName &p_name) - : name(p_name), - type(p_type) { + Arg(Variant::Type p_type, const StringName &p_name) : + name(p_name), + type(p_type) { } }; diff --git a/doc/classes/@GlobalScope.xml b/doc/classes/@GlobalScope.xml index deddaffdc6..de5dc18702 100644 --- a/doc/classes/@GlobalScope.xml +++ b/doc/classes/@GlobalScope.xml @@ -1277,7 +1277,7 @@ </constant> <constant name="PROPERTY_USAGE_DEFAULT_INTL" value="71" enum="PropertyUsageFlags"> </constant> - <constant name="PROPERTY_USAGE_NOEDITOR" value="5" enum="PropertyUsageFlags"> + <constant name="PROPERTY_USAGE_NOEDITOR" value="1048581" enum="PropertyUsageFlags"> </constant> <constant name="METHOD_FLAG_NORMAL" value="1" enum="MethodFlags"> Flag for normal method diff --git a/doc/classes/ARVRController.xml b/doc/classes/ARVRController.xml index d813479cf1..47a9341643 100644 --- a/doc/classes/ARVRController.xml +++ b/doc/classes/ARVRController.xml @@ -31,7 +31,7 @@ <return type="bool"> </return> <description> - Returns true if the controller bound to this node is currently active and being tracked. + Returns [code]true[/code] if the bound controller is active. ARVR systems attempt to track active controllers. </description> </method> <method name="get_joystick_axis" qualifiers="const"> @@ -56,7 +56,7 @@ <argument index="0" name="button" type="int"> </argument> <description> - Is the given button currently pressed? + Returns [code]true[/code] if the button at index [code]button[/code] is pressed. </description> </method> </methods> @@ -65,6 +65,7 @@ The controller's id. The first controller that the [ARVRServer] detects will have id 1, the second id 2, the third id 3, etc. When a controller is turned off, it's slot is freed. This ensures controllers will keep the same id even when controllers with lower ids are turned off. </member> <member name="rumble" type="float" setter="set_rumble" getter="get_rumble"> + The degree to which the tracker rumbles. Ranges from [code]0.0[/code] to [code]1.0[/code] with precision [code].01[/code]. If changed, updates [member ARVRPositionalTracker.rumble] accordingly. </member> </members> <signals> @@ -72,14 +73,14 @@ <argument index="0" name="button" type="int"> </argument> <description> - When a button on this controller is pressed, this signal is given. + Emitted when a button on this controller is pressed. </description> </signal> <signal name="button_release"> <argument index="0" name="button" type="int"> </argument> <description> - When a button on this controller is released, this signal is given. + Emitted when a button on this controller is released. </description> </signal> </signals> diff --git a/doc/classes/ARVRPositionalTracker.xml b/doc/classes/ARVRPositionalTracker.xml index f171e4fc5a..88740f5dc1 100644 --- a/doc/classes/ARVRPositionalTracker.xml +++ b/doc/classes/ARVRPositionalTracker.xml @@ -31,35 +31,35 @@ <return type="String"> </return> <description> - If available this returns the name of the controller or anchor point. + Returns the controller or anchor point's name if available. </description> </method> <method name="get_orientation" qualifiers="const"> <return type="Basis"> </return> <description> - Returns the orientation matrix of the controller. + Returns the controller's orientation matrix. </description> </method> <method name="get_position" qualifiers="const"> <return type="Vector3"> </return> <description> - Returns the position of the controller adjusted by world scale. + Returns the world-space controller position. </description> </method> <method name="get_tracks_orientation" qualifiers="const"> <return type="bool"> </return> <description> - Returns true if the orientation of this device is being tracked. + Returns [code]true[/code] if this device tracks orientation. </description> </method> <method name="get_tracks_position" qualifiers="const"> <return type="bool"> </return> <description> - Returns true if the position of this device is being tracked. + Returns [code]true[/code] if this device tracks position. </description> </method> <method name="get_transform" qualifiers="const"> @@ -68,19 +68,20 @@ <argument index="0" name="adjust_by_reference_frame" type="bool"> </argument> <description> - Returns the transform combining the orientation and position of this device. + Returns the transform combining this device's orientation and position. </description> </method> <method name="get_type" qualifiers="const"> <return type="int" enum="ARVRServer.TrackerType"> </return> <description> - Type of tracker. + Returns the tracker's type. </description> </method> </methods> <members> <member name="rumble" type="float" setter="set_rumble" getter="get_rumble"> + The degree to which the tracker rumbles. Ranges from [code]0.0[/code] to [code]1.0[/code] with precision [code].01[/code]. </member> </members> <constants> diff --git a/doc/classes/AStar.xml b/doc/classes/AStar.xml index acbd49afb9..eefdf4d7a7 100644 --- a/doc/classes/AStar.xml +++ b/doc/classes/AStar.xml @@ -47,7 +47,7 @@ Adds a new point at the given position with the given identifier. The algorithm prefers points with lower [code]weight_scale[/code] to form a path. The [code]id[/code] must be 0 or larger, and the [code]weight_scale[/code] must be 1 or larger. [codeblock] var as = AStar.new() - + as.add_point(1, Vector3(1,0,0), 4) # Adds the point (1,0,0) with weight_scale=4 and id=1 [/codeblock] If there already exists a point for the given id, its position and weight scale are updated to the given values. @@ -84,10 +84,10 @@ Creates a segment between the given points. [codeblock] var as = AStar.new() - + as.add_point(1, Vector3(1,1,0)) as.add_point(2, Vector3(0,5,0)) - + as.connect_points(1, 2, false) # If bidirectional=false it's only possible to go from point 1 to point 2 # and not from point 2 to point 1. [/codeblock] @@ -129,12 +129,12 @@ Returns the closest position to [code]to_position[/code] that resides inside a segment between two connected points. [codeblock] var as = AStar.new() - + as.add_point(1, Vector3(0,0,0)) as.add_point(2, Vector3(0,5,0)) - + as.connect_points(1, 2) - + var res = as.get_closest_position_in_segment(Vector3(3,3,0)) # returns (0, 3, 0) [/codeblock] The result is in the segment that goes from [code]y=0[/code] to [code]y=5[/code]. It's the closest position in the segment to the given point. @@ -151,18 +151,18 @@ Returns an array with the ids of the points that form the path found by AStar between the given points. The array is ordered from the starting point to the ending point of the path. [codeblock] var as = AStar.new() - + as.add_point(1, Vector3(0,0,0)) as.add_point(2, Vector3(0,1,0), 1) # default weight is 1 as.add_point(3, Vector3(1,1,0)) as.add_point(4, Vector3(2,0,0)) - + as.connect_points(1, 2, false) as.connect_points(2, 3, false) as.connect_points(4, 3, false) as.connect_points(1, 4, false) as.connect_points(5, 4, false) - + var res = as.get_id_path(1, 3) # returns [1, 2, 3] [/codeblock] If you change the 2nd point's weight to 3, then the result will be [code][1, 4, 3][/code] instead, because now even though the distance is longer, it's "easier" to get through point 4 than through point 2. @@ -223,6 +223,7 @@ <return type="Array"> </return> <description> + Returns an array of all points. </description> </method> <method name="has_point" qualifiers="const"> diff --git a/doc/classes/Animation.xml b/doc/classes/Animation.xml index ac547d20b7..c3933443a0 100644 --- a/doc/classes/Animation.xml +++ b/doc/classes/Animation.xml @@ -157,6 +157,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns [code]true[/code] if the track at [code]idx[/code] wraps the interpolation loop. Default value: [code]true[/code]. </description> </method> <method name="track_get_interpolation_type" qualifiers="const"> @@ -311,6 +312,7 @@ <argument index="1" name="interpolation" type="bool"> </argument> <description> + If [code]true[/code] the track at [code]idx[/code] wraps the interpolation loop. </description> </method> <method name="track_set_interpolation_type"> diff --git a/doc/classes/AnimationPlayer.xml b/doc/classes/AnimationPlayer.xml index e724f24498..3b1ce37619 100644 --- a/doc/classes/AnimationPlayer.xml +++ b/doc/classes/AnimationPlayer.xml @@ -19,7 +19,7 @@ <argument index="1" name="animation" type="Animation"> </argument> <description> - Add an animation resource to the player, which will be later referenced by the "name" argument. + Adds [code]animation[/code] to the player accessible with the key [code]name[/code]. </description> </method> <method name="advance"> @@ -28,7 +28,7 @@ <argument index="0" name="delta" type="float"> </argument> <description> - Used to skip ahead or skip back in an animation. Delta is the time in seconds to skip. + Shifts position in the animation timeline. Delta is the time in seconds to shift. </description> </method> <method name="animation_get_next" qualifiers="const"> @@ -37,7 +37,7 @@ <argument index="0" name="anim_from" type="String"> </argument> <description> - Return the name of the next animation in the queue. + Returns the name of the next animation in the queue. </description> </method> <method name="animation_set_next"> @@ -48,21 +48,21 @@ <argument index="1" name="anim_to" type="String"> </argument> <description> - Set the name of an animation that will be played after. + Triggers the [code]anim_to[/code] animation when the [code]anim_from[/code] animation completes. </description> </method> <method name="clear_caches"> <return type="void"> </return> <description> - The animation player creates caches for faster access to the nodes it will animate. However, if a specific node is removed, it may not notice it, so clear_caches will force the player to search for the nodes again. + [code]AnimationPlayer[/code] caches animated nodes. It may not notice if a node disappears, so clear_caches forces it to update the cache again. </description> </method> <method name="clear_queue"> <return type="void"> </return> <description> - If animations are queued to play, clear them. + Clears all queued, unplayed animations. </description> </method> <method name="find_animation" qualifiers="const"> @@ -71,7 +71,21 @@ <argument index="0" name="animation" type="Animation"> </argument> <description> - Find an animation name by resource. + Returns the name of [code]animation[/code] or empty string if not found. + </description> + </method> + <method name="get_anim_length" qualifiers="const"> + <return type="float"> + </return> + <description> + Get the length (in seconds) of the currently playing animation. + </description> + </method> + <method name="get_anim_position" qualifiers="const"> + <return type="float"> + </return> + <description> + Get the position (in seconds) of the currently playing animation. </description> </method> <method name="get_animation" qualifiers="const"> @@ -80,21 +94,14 @@ <argument index="0" name="name" type="String"> </argument> <description> - Get an [Animation] resource by requesting a name. + Returns the [Animation] with key [code]name[/code] or [code]null[/code] if not found. </description> </method> <method name="get_animation_list" qualifiers="const"> <return type="PoolStringArray"> </return> <description> - Get the list of names of the animations stored in the player. - </description> - </method> - <method name="get_autoplay" qualifiers="const"> - <return type="String"> - </return> - <description> - Return the name of the animation that will be automatically played when the scene is loaded. + Returns the list of stored animation names. </description> </method> <method name="get_blend_time" qualifiers="const"> @@ -105,42 +112,14 @@ <argument index="1" name="anim_to" type="String"> </argument> <description> - Get the blend time between two animations, referenced by their names. + Get the blend time (in seconds) between two animations, referenced by their names. </description> </method> <method name="get_current_animation" qualifiers="const"> <return type="String"> </return> <description> - Return the name of the animation being played. - </description> - </method> - <method name="get_current_animation_length" qualifiers="const"> - <return type="float"> - </return> - <description> - Get the length (in seconds) of the currently being played animation. - </description> - </method> - <method name="get_current_animation_position" qualifiers="const"> - <return type="float"> - </return> - <description> - Get the position (in seconds) of the currently being played animation. - </description> - </method> - <method name="get_position" qualifiers="const"> - <return type="float"> - </return> - <description> - Return the playback position (in seconds) in an animation channel (or channel 0 if none is provided). - </description> - </method> - <method name="get_speed_scale" qualifiers="const"> - <return type="float"> - </return> - <description> - Get the speed scaling ratio in a given animation channel (or channel 0 if none is provided). Default ratio is [i]1[/i] (no scaling). + Returns the name of the currently playing animation. </description> </method> <method name="has_animation" qualifiers="const"> @@ -149,21 +128,14 @@ <argument index="0" name="name" type="String"> </argument> <description> - Request whether an [Animation] name exist within the player. - </description> - </method> - <method name="is_active" qualifiers="const"> - <return type="bool"> - </return> - <description> - Return true if the player is active. + Returns [code]true[/code] if the [code]AnimationPlayer[/code] stores an [Animation] with key [code]name[/code]. </description> </method> <method name="is_playing" qualifiers="const"> <return type="bool"> </return> <description> - Return whether an animation is playing. + Returns [code]true[/code] if playing an animation. </description> </method> <method name="play"> @@ -178,7 +150,7 @@ <argument index="3" name="from_end" type="bool" default="false"> </argument> <description> - Play a given animation by the animation name. Custom speed and blend times can be set. If custom speed is negative (-1), 'from_end' being true can play the animation backwards. + Play the animation with key [code]name[/code]. Custom speed and blend times can be set. If custom speed is negative (-1), 'from_end' being true can play the animation backwards. </description> </method> <method name="play_backwards"> @@ -189,7 +161,7 @@ <argument index="1" name="custom_blend" type="float" default="-1"> </argument> <description> - Play a given animation by the animation name in reverse. + Play the animation with key [code]name[/code] in reverse. </description> </method> <method name="queue"> @@ -207,7 +179,7 @@ <argument index="0" name="name" type="String"> </argument> <description> - Remove an animation from the player (by supplying the same name used to add it). + Remove the animation with key [code]name[/code]. </description> </method> <method name="rename_animation"> @@ -218,7 +190,7 @@ <argument index="1" name="newname" type="String"> </argument> <description> - Rename an existing animation. + Rename an existing animation with key [code]name[/code] to [code]newname[/code]. </description> </method> <method name="seek"> @@ -229,25 +201,7 @@ <argument index="1" name="update" type="bool" default="false"> </argument> <description> - Seek the animation to a given position in time (in seconds). If 'update' is true, the animation will be updated too, otherwise it will be updated at process time. - </description> - </method> - <method name="set_active"> - <return type="void"> - </return> - <argument index="0" name="active" type="bool"> - </argument> - <description> - Set the player as active (playing). If false, it will do nothing. - </description> - </method> - <method name="set_autoplay"> - <return type="void"> - </return> - <argument index="0" name="name" type="String"> - </argument> - <description> - Set the name of the animation that will be automatically played when the scene is loaded. + Seek the animation to the [code]seconds[/code] point in time (in seconds). If 'update' is true, the animation updates too, otherwise it updates at process time. </description> </method> <method name="set_blend_time"> @@ -272,22 +226,13 @@ Set the current animation (even if no playback occurs). Using set_current_animation() and set_active() are similar to calling play(). </description> </method> - <method name="set_speed_scale"> - <return type="void"> - </return> - <argument index="0" name="speed" type="float"> - </argument> - <description> - Set a speed scaling ratio in a given animation channel (or channel 0 if none is provided). Default ratio is [i]1[/i] (no scaling). - </description> - </method> <method name="stop"> <return type="void"> </return> <argument index="0" name="reset" type="bool" default="true"> </argument> <description> - Stop the currently playing animation. + Stop the currently playing animation. If [code]reset[/code] is [code]true[/code], the anim position is reset to [code]0[/code]. </description> </method> <method name="stop_all"> @@ -299,11 +244,23 @@ </method> </methods> <members> + <member name="active" type="bool" setter="set_active" getter="is_active"> + If [code]true[/code] updates animations in response to process-related notifications. Default value: [code]true[/code]. + </member> + <member name="autoplay" type="String" setter="set_autoplay" getter="get_autoplay"> + The name of the animation to play when the scene loads. Default value: [code]""[/code]. + </member> <member name="playback_default_blend_time" type="float" setter="set_default_blend_time" getter="get_default_blend_time"> + The default time in which to blend animations. Ranges from 0 to 4096 with 0.01 precision. Default value: [code]0[/code]. </member> <member name="playback_process_mode" type="int" setter="set_animation_process_mode" getter="get_animation_process_mode" enum="AnimationPlayer.AnimationProcessMode"> + The process notification in which to update animations. Default value: [enum ANIMATION_PROCESS_IDLE]. </member> <member name="root_node" type="NodePath" setter="set_root" getter="get_root"> + The node from which node path references will travel. Default value: [code]".."[/code]. + </member> + <member name="speed_scale" type="float" setter="set_speed_scale" getter="get_speed_scale"> + The speed scaling ratio in a given animation channel (or channel 0 if none is provided). Default value: [code]1[/code]. </member> </members> <signals> @@ -313,21 +270,21 @@ <argument index="1" name="new_name" type="String"> </argument> <description> - If the currently being played animation changes, this signal will notify of such change. + Emitted when the [Animation] with key [member current_anim] is modified. </description> </signal> <signal name="animation_finished"> <argument index="0" name="name" type="String"> </argument> <description> - Notifies when an animation finished playing. + Emitted when an animation finishes. </description> </signal> <signal name="animation_started"> <argument index="0" name="name" type="String"> </argument> <description> - Notifies when an animation starts playing. + Emitted when an animation starts. </description> </signal> </signals> diff --git a/doc/classes/Area.xml b/doc/classes/Area.xml index f58aa3cc0a..b74e767fd2 100644 --- a/doc/classes/Area.xml +++ b/doc/classes/Area.xml @@ -17,7 +17,7 @@ <argument index="0" name="bit" type="int"> </argument> <description> - Return an individual bit on the layer mask. + Returns an individual bit on the layer mask. </description> </method> <method name="get_collision_mask_bit" qualifiers="const"> @@ -26,7 +26,7 @@ <argument index="0" name="bit" type="int"> </argument> <description> - Return an individual bit on the collision mask. + Returns an individual bit on the collision mask. </description> </method> <method name="get_overlapping_areas" qualifiers="const"> @@ -69,7 +69,7 @@ <argument index="1" name="value" type="bool"> </argument> <description> - Set/clear individual bits on the layer mask. This makes getting an area in/out of only one layer easier. + Set/clear individual bits on the layer mask. This simplifies editing this [code]Area[code]'s layers. </description> </method> <method name="set_collision_mask_bit"> @@ -80,7 +80,7 @@ <argument index="1" name="value" type="bool"> </argument> <description> - Set/clear individual bits on the collision mask. This makes selecting the areas scanned easier. + Set/clear individual bits on the collision mask. This simplifies editing which [code]Area[/code] layers this [code]Area[/code] scans. </description> </method> </methods> @@ -125,12 +125,16 @@ The area's priority. Higher priority areas are processed first. Default value: 0. </member> <member name="reverb_bus_amount" type="float" setter="set_reverb_amount" getter="get_reverb_amount"> + The degree to which this area applies reverb to its associated audio. Ranges from [code]0[/code] to [code]1[/code] with [code]0.1[/code] precision. </member> <member name="reverb_bus_enable" type="bool" setter="set_use_reverb_bus" getter="is_using_reverb_bus"> + If [code]true[/code] the area applies reverb to its associated audio. </member> <member name="reverb_bus_name" type="String" setter="set_reverb_bus" getter="get_reverb_bus"> + The reverb bus name to use for this area's associated audio. </member> <member name="reverb_bus_uniformity" type="float" setter="set_reverb_uniformity" getter="get_reverb_uniformity"> + The degree to which this area's reverb is a uniform effect. Ranges from [code]0[/code] to [code]1[/code] with [code]0.1[/code] precision. </member> <member name="space_override" type="int" setter="set_space_override_mode" getter="get_space_override_mode" enum="Area.SpaceOverride"> Override mode for gravity and damping calculations within this area. See the SPACE_OVERRIDE_* constants for values. diff --git a/doc/classes/AtlasTexture.xml b/doc/classes/AtlasTexture.xml index 33566d9ec1..f1a79bc312 100644 --- a/doc/classes/AtlasTexture.xml +++ b/doc/classes/AtlasTexture.xml @@ -18,6 +18,7 @@ The texture that contains the atlas. Can be any [Texture] subtype. </member> <member name="filter_clip" type="bool" setter="set_filter_clip" getter="has_filter_clip"> + If [code]true[/code] clips the area outside of the region to avoid bleeding of the surrounding texture pixels. </member> <member name="margin" type="Rect2" setter="set_margin" getter="get_margin"> The margin around the region. The [Rect2]'s 'size' parameter ('w' and 'h' in the editor) resizes the texture so it fits within the margin. diff --git a/doc/classes/AudioStreamSample.xml b/doc/classes/AudioStreamSample.xml index ac8cc7a445..83e9729bc1 100644 --- a/doc/classes/AudioStreamSample.xml +++ b/doc/classes/AudioStreamSample.xml @@ -11,11 +11,22 @@ <demos> </demos> <methods> + <method name="get_data" qualifiers="const"> + <return type="PoolByteArray"> + </return> + <description> + </description> + </method> + <method name="set_data"> + <return type="void"> + </return> + <argument index="0" name="data" type="PoolByteArray"> + </argument> + <description> + </description> + </method> </methods> <members> - <member name="data" type="PoolByteArray" setter="set_data" getter="get_data"> - Raw audio data. - </member> <member name="format" type="int" setter="set_format" getter="get_format" enum="AudioStreamSample.Format"> Audio format. See FORMAT_* constants for values. </member> diff --git a/doc/classes/Basis.xml b/doc/classes/Basis.xml index 5b3b27ec60..a873bd9a27 100644 --- a/doc/classes/Basis.xml +++ b/doc/classes/Basis.xml @@ -171,10 +171,13 @@ </methods> <members> <member name="x" type="Vector3" setter="" getter=""> + The basis matrix's x vector. </member> <member name="y" type="Vector3" setter="" getter=""> + The basis matrix's y vector. </member> <member name="z" type="Vector3" setter="" getter=""> + The basis matrix's z vector. </member> </members> <constants> diff --git a/doc/classes/BitMap.xml b/doc/classes/BitMap.xml index 9e2cd616f2..39bf46ac3d 100644 --- a/doc/classes/BitMap.xml +++ b/doc/classes/BitMap.xml @@ -75,13 +75,6 @@ </description> </method> </methods> - <members> - <member name="data" type="Dictionary" setter="_set_data" getter="_get_data"> - Returns a [Dictionary] with two keys : - [code]data[/code] : [PoolByteArray] with [code]true[/code]/[code]false[/code] [code]BitMap[/code] data. - [code]size[/code] : The [code]Bitmap[/code]'s size. - </member> - </members> <constants> </constants> </class> diff --git a/doc/classes/BitmapFont.xml b/doc/classes/BitmapFont.xml index 6d98c5e629..2fb7d7d87a 100644 --- a/doc/classes/BitmapFont.xml +++ b/doc/classes/BitmapFont.xml @@ -109,9 +109,6 @@ <member name="ascent" type="float" setter="set_ascent" getter="get_ascent"> Ascent (number of pixels above the baseline). </member> - <member name="chars" type="PoolIntArray" setter="_set_chars" getter="_get_chars"> - The characters in the BitmapFont. - </member> <member name="distance_field" type="bool" setter="set_distance_field_hint" getter="is_distance_field_hint"> If [code]true[/code] distance field hint is enabled. </member> @@ -121,12 +118,6 @@ <member name="height" type="float" setter="set_height" getter="get_height"> Total font height (ascent plus descent) in pixels. </member> - <member name="kernings" type="PoolIntArray" setter="_set_kernings" getter="_get_kernings"> - The font's kernings as [PoolIntArray]. - </member> - <member name="textures" type="Array" setter="_set_textures" getter="_get_textures"> - The font's [Texture]s. - </member> </members> <constants> </constants> diff --git a/doc/classes/Camera2D.xml b/doc/classes/Camera2D.xml index 86c89bf4ca..c95691d07f 100644 --- a/doc/classes/Camera2D.xml +++ b/doc/classes/Camera2D.xml @@ -23,6 +23,7 @@ <return type="void"> </return> <description> + Removes any [code]Camera2D[/code] from the ancestor [Viewport]'s internal currently-assigned camera. </description> </method> <method name="force_update_scroll"> @@ -43,24 +44,28 @@ <return type="Vector2"> </return> <description> + Returns the location of the [code]Camera2D[/code]'s screen-center, relative to the origin. </description> </method> <method name="get_custom_viewport" qualifiers="const"> <return type="Node"> </return> <description> + Returns the [Viewport] used by the camera if it is not using the default viewport. </description> </method> <method name="get_h_offset" qualifiers="const"> <return type="float"> </return> <description> + Returns the horizontal offset of the camera. </description> </method> <method name="get_v_offset" qualifiers="const"> <return type="float"> </return> <description> + Returns the vertical offset of the camera. </description> </method> <method name="make_current"> @@ -84,6 +89,7 @@ <argument index="0" name="viewport" type="Node"> </argument> <description> + Assigns a custom [Viewport] node to the [code]Camera2D[/code]. If [code]viewport[/code] is not a [Viewport], it re-assigns the default viewport instead. </description> </method> <method name="set_h_offset"> @@ -92,6 +98,7 @@ <argument index="0" name="ofs" type="float"> </argument> <description> + The camera's horizontal offset is set to [code]ofs[/code]. </description> </method> <method name="set_v_offset"> @@ -100,6 +107,7 @@ <argument index="0" name="ofs" type="float"> </argument> <description> + The camera's vertical offset is set to [code]ofs[/code]. </description> </method> </methods> @@ -170,8 +178,10 @@ </members> <constants> <constant name="ANCHOR_MODE_FIXED_TOP_LEFT" value="0" enum="AnchorMode"> + The camera's position is fixed so that the top-left corner is always at the origin. </constant> <constant name="ANCHOR_MODE_DRAG_CENTER" value="1" enum="AnchorMode"> + The camera's position takes into account vertical/horizontal offsets and the screen size. </constant> </constants> </class> diff --git a/doc/classes/CanvasItem.xml b/doc/classes/CanvasItem.xml index d1524074fd..4a567981e6 100644 --- a/doc/classes/CanvasItem.xml +++ b/doc/classes/CanvasItem.xml @@ -119,6 +119,7 @@ <argument index="3" name="antialiased" type="bool" default="false"> </argument> <description> + Draw a polyline with a uniform [code]color[/code] and [code]width[/code] and optional antialiasing. </description> </method> <method name="draw_polyline_colors"> @@ -133,6 +134,7 @@ <argument index="3" name="antialiased" type="bool" default="false"> </argument> <description> + Draw a polyline with a uniform [code]width[/code], segment-by-segment coloring, and optional antialiasing. Colors assigned to line segments match by index between [code]points[/code] and [code]colors[/code]. </description> </method> <method name="draw_primitive"> @@ -177,7 +179,7 @@ <argument index="2" name="scale" type="Vector2"> </argument> <description> - Set a custom transform for drawing. Anything drawn afterwards will be transformed by this. + Sets a custom transform for drawing via components. Anything drawn afterwards will be transformed by this. </description> </method> <method name="draw_set_transform_matrix"> @@ -186,6 +188,7 @@ <argument index="0" name="xform" type="Transform2D"> </argument> <description> + Sets a custom transform for drawing via matrix. Anything drawn afterwards will be transformed by this. </description> </method> <method name="draw_string"> @@ -359,6 +362,7 @@ <return type="bool"> </return> <description> + Returns [code]true[/code] if local transform notifications are communicated to children. </description> </method> <method name="is_set_as_toplevel" qualifiers="const"> @@ -372,12 +376,14 @@ <return type="bool"> </return> <description> + Returns [code]true[/code] if global transform notifications are communicated to children. </description> </method> <method name="is_visible_in_tree" qualifiers="const"> <return type="bool"> </return> <description> + Returns [code]true[/code] if the node is in the [SceneTree] and is visible on-screen. </description> </method> <method name="make_canvas_position_local" qualifiers="const"> @@ -386,6 +392,7 @@ <argument index="0" name="screen_point" type="Vector2"> </argument> <description> + Assigns [code]screen_point[/code] as this node's new local transform. </description> </method> <method name="make_input_local" qualifiers="const"> @@ -394,6 +401,7 @@ <argument index="0" name="event" type="InputEvent"> </argument> <description> + Transformations issued by [code]event[/code]'s inputs are applied in local space instead of global space. </description> </method> <method name="set_as_toplevel"> @@ -402,7 +410,7 @@ <argument index="0" name="enable" type="bool"> </argument> <description> - Set as top level. This means that it will not inherit transform from parent canvas items. + Sets as top level. This means that it will not inherit transform from parent canvas items. </description> </method> <method name="set_notify_local_transform"> @@ -411,6 +419,7 @@ <argument index="0" name="enable" type="bool"> </argument> <description> + If [code]enable[/code] is [code]true[/code], children will be updated with local transform data. </description> </method> <method name="set_notify_transform"> @@ -419,6 +428,7 @@ <argument index="0" name="enable" type="bool"> </argument> <description> + If [code]enable[/code] is [code]true[/code], children will be updated with global transform data. </description> </method> <method name="show"> @@ -438,20 +448,28 @@ </methods> <members> <member name="light_mask" type="int" setter="set_light_mask" getter="get_light_mask"> + The rendering layers in which this [code]CanvasItem[/code] responds to [Light2D] nodes. Default value: [code]1[/code]. </member> <member name="material" type="Material" setter="set_material" getter="get_material"> + The material applied to textures on this [code]CanvasItem[/code]. Default value: [code]null[/code]. </member> <member name="modulate" type="Color" setter="set_modulate" getter="get_modulate"> + The color applied to textures on this [code]CanvasItem[/code]. Default value: [code]Color(1, 1, 1, 1)[/code] (opaque "white"). </member> <member name="self_modulate" type="Color" setter="set_self_modulate" getter="get_self_modulate"> + The color applied to textures on this [code]CanvasItem[/code]. This is not inherited by children [code]CanvasItem[/code]s. Default value: [code]Color(1, 1, 1, 1)[/code] (opaque "white").. </member> <member name="show_behind_parent" type="bool" setter="set_draw_behind_parent" getter="is_draw_behind_parent_enabled"> + If [code]true[/code] the object draws behind its parent. Default value: [code]false[/code]. </member> <member name="show_on_top" type="bool" setter="_set_on_top" getter="_is_on_top"> + If [code]true[/code] the object draws on top of its parent. Default value: [code]true[/code]. </member> <member name="use_parent_material" type="bool" setter="set_use_parent_material" getter="get_use_parent_material"> + If [code]true[/code] the parent [code]CanvasItem[/code]'s [member material] property is used as this one's material. Default value: [code]false[/code]. </member> <member name="visible" type="bool" setter="set_visible" getter="is_visible"> + If [code]true[/code] this [code]CanvasItem[/code] is drawn. Default value: [code]true[/code]. </member> </members> <signals> diff --git a/doc/classes/CanvasItemMaterial.xml b/doc/classes/CanvasItemMaterial.xml index b30261d5bf..81709227ad 100644 --- a/doc/classes/CanvasItemMaterial.xml +++ b/doc/classes/CanvasItemMaterial.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="CanvasItemMaterial" inherits="Material" category="Core" version="3.0-beta"> <brief_description> + A material for [CanvasItem]s. </brief_description> <description> + [code]CanvasItemMaterial[/code]s provide a means of modifying the textures associated with a CanvasItem. They specialize in describing blend and lighting behaviors for textures. Use a [ShaderMaterial] to more fully customize a material's interactions with a [CanvasItem]. </description> <tutorials> </tutorials> @@ -12,26 +14,36 @@ </methods> <members> <member name="blend_mode" type="int" setter="set_blend_mode" getter="get_blend_mode" enum="CanvasItemMaterial.BlendMode"> + The manner in which a material's rendering is applied to underlying textures. </member> <member name="light_mode" type="int" setter="set_light_mode" getter="get_light_mode" enum="CanvasItemMaterial.LightMode"> + The manner in which material reacts to lighting. </member> </members> <constants> <constant name="BLEND_MODE_MIX" value="0" enum="BlendMode"> + Mix blending mode. Colors are assumed to be independent of the alpha (opacity) value. </constant> <constant name="BLEND_MODE_ADD" value="1" enum="BlendMode"> + Additive blending mode. </constant> <constant name="BLEND_MODE_SUB" value="2" enum="BlendMode"> + Subtractive blending mode. </constant> <constant name="BLEND_MODE_MUL" value="3" enum="BlendMode"> + Multiplicative blending mode. </constant> <constant name="BLEND_MODE_PREMULT_ALPHA" value="4" enum="BlendMode"> + Mix blending mode. Colors are assumed to be premultiplied by the alpha (opacity) value. </constant> <constant name="LIGHT_MODE_NORMAL" value="0" enum="LightMode"> + Render the material using both light and non-light sensitive material properties. </constant> <constant name="LIGHT_MODE_UNSHADED" value="1" enum="LightMode"> + Render the material as if there were no light. </constant> <constant name="LIGHT_MODE_LIGHT_ONLY" value="2" enum="LightMode"> + Render the material as if there were only light. </constant> </constants> </class> diff --git a/doc/classes/CanvasLayer.xml b/doc/classes/CanvasLayer.xml index 86b788bb44..01c2dd6ba9 100644 --- a/doc/classes/CanvasLayer.xml +++ b/doc/classes/CanvasLayer.xml @@ -15,6 +15,7 @@ <return type="Node"> </return> <description> + Returns the [Viewport] used by the camera if it is not using the default viewport. </description> </method> <method name="get_rotation" qualifiers="const"> @@ -44,6 +45,7 @@ <argument index="0" name="viewport" type="Node"> </argument> <description> + Assigns a custom [Viewport] node to the [code]CanvasLayer[/code]. If [code]viewport[/code] is not a [Viewport], it re-assigns the default viewport instead. </description> </method> <method name="set_rotation"> diff --git a/doc/classes/ClassDB.xml b/doc/classes/ClassDB.xml index 37e85d033b..b4d4d0b448 100644 --- a/doc/classes/ClassDB.xml +++ b/doc/classes/ClassDB.xml @@ -35,6 +35,7 @@ <argument index="0" name="class" type="String"> </argument> <description> + Returns a category associated with the class for use in documentation and the Asset Library. Debug mode required. </description> </method> <method name="class_get_integer_constant" qualifiers="const"> diff --git a/doc/classes/CollisionObject.xml b/doc/classes/CollisionObject.xml index 82f65b6d11..5d0984bcdf 100644 --- a/doc/classes/CollisionObject.xml +++ b/doc/classes/CollisionObject.xml @@ -25,6 +25,7 @@ <argument index="4" name="shape_idx" type="int"> </argument> <description> + Accepts unhandled [InputEvent]s. [code]click_position[/code] is the clicked location in world space and [code]click_normal[/code] is the normal vector extending from the clicked surface of the [Shape] at [code]shape_idx[/code]. Connect to the [code]input_event[/code] signal to easily pick up these events. </description> </method> <method name="create_shape_owner"> @@ -134,6 +135,7 @@ <argument index="1" name="shape_id" type="int"> </argument> <description> + Returns the child index of the [Shape] with the given id from the given shape owner. </description> </method> <method name="shape_owner_get_transform" qualifiers="const"> @@ -181,8 +183,10 @@ </methods> <members> <member name="input_capture_on_drag" type="bool" setter="set_capture_input_on_drag" getter="get_capture_input_on_drag"> + If [code]true[/code] the [code]CollisionObject[/code] will continue to receive input events as the mouse is dragged across its shapes. Default value: [code]false[/code]. </member> <member name="input_ray_pickable" type="bool" setter="set_ray_pickable" getter="is_ray_pickable"> + If [code]true[/code] the [CollisionObject]'s shapes will respond to [RayCast]s. Default value: [code]true[/code]. </member> </members> <signals> @@ -198,6 +202,7 @@ <argument index="4" name="shape_idx" type="int"> </argument> <description> + Emitted when [method _input_event] receives an event. See its description for details. </description> </signal> <signal name="mouse_entered"> diff --git a/doc/classes/CollisionObject2D.xml b/doc/classes/CollisionObject2D.xml index ffc79d359d..086513cad5 100644 --- a/doc/classes/CollisionObject2D.xml +++ b/doc/classes/CollisionObject2D.xml @@ -21,6 +21,7 @@ <argument index="2" name="shape_idx" type="int"> </argument> <description> + Accepts unhandled [InputEvent]s. [code]shape_idx[/code] is the child index of the clicked [Shape2D]. Connect to the [code]input_event[/code] signal to easily pick up these events. </description> </method> <method name="create_shape_owner"> @@ -61,6 +62,7 @@ <argument index="0" name="owner_id" type="int"> </argument> <description> + Returns [code]true[/code] if collisions for the shape owner originating from this [code]CollisionObject2D[/code] will not be reported to collided with [code]CollisionObject2D[/code]s. </description> </method> <method name="remove_shape_owner"> @@ -138,6 +140,7 @@ <argument index="1" name="shape_id" type="int"> </argument> <description> + Returns the child index of the [Shape2D] with the given id from the given shape owner. </description> </method> <method name="shape_owner_get_transform" qualifiers="const"> @@ -179,6 +182,7 @@ <argument index="1" name="enable" type="bool"> </argument> <description> + If [code]enable[/code] is [code]true[/code], collisions for the shape owner originating from this [code]CollisionObject2D[/code] will not be reported to collided with [code]CollisionObject2D[/code]s. </description> </method> <method name="shape_owner_set_transform"> @@ -207,7 +211,7 @@ <argument index="2" name="shape_idx" type="int"> </argument> <description> - Emitted when an input event occurs and [code]input_pickable[/code] is [code]true[/code]. + Emitted when an input event occurs and [code]input_pickable[/code] is [code]true[/code]. See [method _input_event] for details. </description> </signal> <signal name="mouse_entered"> diff --git a/doc/classes/ColorPickerButton.xml b/doc/classes/ColorPickerButton.xml index c8a4b850d0..185460eef2 100644 --- a/doc/classes/ColorPickerButton.xml +++ b/doc/classes/ColorPickerButton.xml @@ -18,6 +18,13 @@ Returns the [code]ColorPicker[/code] that this [code]ColorPickerButton[/code] toggles. </description> </method> + <method name="get_popup"> + <return type="PopupPanel"> + </return> + <description> + Returns the control's [PopupPanel] which allows you to connect to Popup Signals. This allows you to handle events when the ColorPicker is shown or hidden. + </description> + </method> </methods> <members> <member name="color" type="Color" setter="set_pick_color" getter="get_pick_color"> diff --git a/doc/classes/Curve.xml b/doc/classes/Curve.xml index 4c9ced63c8..3e1158ca3b 100644 --- a/doc/classes/Curve.xml +++ b/doc/classes/Curve.xml @@ -169,8 +169,6 @@ </method> </methods> <members> - <member name="_data" type="Array" setter="_set_data" getter="_get_data"> - </member> <member name="bake_resolution" type="int" setter="set_bake_resolution" getter="get_bake_resolution"> </member> <member name="max_value" type="float" setter="set_max_value" getter="get_max_value"> diff --git a/doc/classes/Curve2D.xml b/doc/classes/Curve2D.xml index 8b86359cc5..8a857799e6 100644 --- a/doc/classes/Curve2D.xml +++ b/doc/classes/Curve2D.xml @@ -175,9 +175,6 @@ </method> </methods> <members> - <member name="_data" type="Dictionary" setter="_set_data" getter="_get_data"> - The points describing the curve. Value is a [Dictionary] with the keys [code]in[/code], [code]out[/code], and [code]pos[/code]. The key pos is the position of a vertex of the curve, the key in is the vector from that position to the control point before this vertex, the key out is the vector from that position to the controlpoint after this vertex. - </member> <member name="bake_interval" type="float" setter="set_bake_interval" getter="get_bake_interval"> The distance in pixels between two adjacent cached points. Changing it forces the cache to be recomputed the next time the [method get_baked_points] or [method get_baked_length] function is called. The smaller the distance, the more points in the cache and the more memory it will consume, so use with care. </member> diff --git a/doc/classes/Curve3D.xml b/doc/classes/Curve3D.xml index c758e1d9da..e30ae85617 100644 --- a/doc/classes/Curve3D.xml +++ b/doc/classes/Curve3D.xml @@ -202,8 +202,6 @@ </method> </methods> <members> - <member name="_data" type="Dictionary" setter="_set_data" getter="_get_data"> - </member> <member name="bake_interval" type="float" setter="set_bake_interval" getter="get_bake_interval"> </member> </members> diff --git a/doc/classes/CurveTexture.xml b/doc/classes/CurveTexture.xml index 73126de4aa..f62da8a135 100644 --- a/doc/classes/CurveTexture.xml +++ b/doc/classes/CurveTexture.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="CurveTexture" inherits="Texture" category="Core" version="3.0-beta"> <brief_description> + A texture that shows a curve. </brief_description> <description> + Renders a given [Curve] provided to it. Simplifies the task of drawing curves and/or saving them as image files. </description> <tutorials> </tutorials> @@ -12,8 +14,10 @@ </methods> <members> <member name="curve" type="Curve" setter="set_curve" getter="get_curve"> + The [code]curve[/code] rendered onto the texture. </member> <member name="width" type="int" setter="set_width" getter="get_width"> + The width of the texture. </member> </members> <constants> diff --git a/doc/classes/EditorFileDialog.xml b/doc/classes/EditorFileDialog.xml index e893d92840..1a1c382e59 100644 --- a/doc/classes/EditorFileDialog.xml +++ b/doc/classes/EditorFileDialog.xml @@ -15,179 +15,111 @@ <argument index="0" name="filter" type="String"> </argument> <description> + Adds a comma-delimited file extension filter option to the [code]EditorFileDialog[/code] with an optional semi-colon-delimited label. + Example: "*.tscn, *.scn; Scenes", results in filter text "Scenes (*.tscn, *.scn)". </description> </method> <method name="clear_filters"> <return type="void"> </return> <description> - </description> - </method> - <method name="get_access" qualifiers="const"> - <return type="int" enum="EditorFileDialog.Access"> - </return> - <description> - </description> - </method> - <method name="get_current_dir" qualifiers="const"> - <return type="String"> - </return> - <description> - </description> - </method> - <method name="get_current_file" qualifiers="const"> - <return type="String"> - </return> - <description> - </description> - </method> - <method name="get_current_path" qualifiers="const"> - <return type="String"> - </return> - <description> - </description> - </method> - <method name="get_display_mode" qualifiers="const"> - <return type="int" enum="EditorFileDialog.DisplayMode"> - </return> - <description> - </description> - </method> - <method name="get_mode" qualifiers="const"> - <return type="int" enum="EditorFileDialog.Mode"> - </return> - <description> + Removes all filters except for "All Files (*)". </description> </method> <method name="get_vbox"> <return type="VBoxContainer"> </return> <description> + Returns the [code]VBoxContainer[/code] used to display the file system. </description> </method> <method name="invalidate"> <return type="void"> </return> <description> - </description> - </method> - <method name="is_overwrite_warning_disabled" qualifiers="const"> - <return type="bool"> - </return> - <description> - </description> - </method> - <method name="is_showing_hidden_files" qualifiers="const"> - <return type="bool"> - </return> - <description> - </description> - </method> - <method name="set_access"> - <return type="void"> - </return> - <argument index="0" name="access" type="int" enum="EditorFileDialog.Access"> - </argument> - <description> - </description> - </method> - <method name="set_current_dir"> - <return type="void"> - </return> - <argument index="0" name="dir" type="String"> - </argument> - <description> - </description> - </method> - <method name="set_current_file"> - <return type="void"> - </return> - <argument index="0" name="file" type="String"> - </argument> - <description> - </description> - </method> - <method name="set_current_path"> - <return type="void"> - </return> - <argument index="0" name="path" type="String"> - </argument> - <description> - </description> - </method> - <method name="set_disable_overwrite_warning"> - <return type="void"> - </return> - <argument index="0" name="disable" type="bool"> - </argument> - <description> - </description> - </method> - <method name="set_display_mode"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="EditorFileDialog.DisplayMode"> - </argument> - <description> - </description> - </method> - <method name="set_mode"> - <return type="void"> - </return> - <argument index="0" name="mode" type="int" enum="EditorFileDialog.Mode"> - </argument> - <description> - </description> - </method> - <method name="set_show_hidden_files"> - <return type="void"> - </return> - <argument index="0" name="show" type="bool"> - </argument> - <description> + Notify the [code]EditorFileDialog[/code] that its view of the data is no longer accurate. Updates the view contents on next view update. </description> </method> </methods> + <members> + <member name="access" type="int" setter="set_access" getter="get_access" enum="EditorFileDialog.Access"> + The location from which the user may select a file, including [code]res://[/code], [code]user://[/code], and the local file system. + </member> + <member name="current_dir" type="String" setter="set_current_dir" getter="get_current_dir"> + The currently occupied directory. + </member> + <member name="current_file" type="String" setter="set_current_file" getter="get_current_file"> + The currently selected file. + </member> + <member name="current_path" type="String" setter="set_current_path" getter="get_current_path"> + The file system path in the address bar. + </member> + <member name="disable_overwrite_warning" type="bool" setter="set_disable_overwrite_warning" getter="is_overwrite_warning_disabled"> + If [code]true[/code] the [code]EditorFileDialog[/code] will not warn the user before overwriting files. + </member> + <member name="display_mode" type="int" setter="set_display_mode" getter="get_display_mode" enum="EditorFileDialog.DisplayMode"> + The view format in which the [code]EditorFileDialog[/code] displays resources to the user. + </member> + <member name="mode" type="int" setter="set_mode" getter="get_mode" enum="EditorFileDialog.Mode"> + The purpose of the [code]EditorFileDialog[/code]. Changes allowed behaviors. + </member> + <member name="show_hidden_files" type="bool" setter="set_show_hidden_files" getter="is_showing_hidden_files"> + If [code]true[/code] hidden files and directories will be visible in the [code]EditorFileDialog[/code]. + </member> + </members> <signals> <signal name="dir_selected"> <argument index="0" name="dir" type="String"> </argument> <description> + Emitted when a directory is selected. </description> </signal> <signal name="file_selected"> <argument index="0" name="path" type="String"> </argument> <description> + Emitted when a file is selected. </description> </signal> <signal name="files_selected"> <argument index="0" name="paths" type="PoolStringArray"> </argument> <description> + Emitted when multiple files are selected. </description> </signal> </signals> <constants> <constant name="MODE_OPEN_FILE" value="0" enum="Mode"> + The [code]EditorFileDialog[/code] can select only one file. Accepting the window will open the file. </constant> <constant name="MODE_OPEN_FILES" value="1" enum="Mode"> + The [code]EditorFileDialog[/code] can select multiple files. Accepting the window will open all files. </constant> <constant name="MODE_OPEN_DIR" value="2" enum="Mode"> + The [code]EditorFileDialog[/code] can select only one directory. Accepting the window will open the directory. </constant> <constant name="MODE_OPEN_ANY" value="3" enum="Mode"> + The [code]EditorFileDialog[/code] can select a file or directory. Accepting the window will open it. </constant> <constant name="MODE_SAVE_FILE" value="4" enum="Mode"> + The [code]EditorFileDialog[/code] can select only one file. Accepting the window will save the file. </constant> <constant name="ACCESS_RESOURCES" value="0" enum="Access"> + The [code]EditorFileDialog[/code] can only view [code]res://[/code] directory contents. </constant> <constant name="ACCESS_USERDATA" value="1" enum="Access"> + The [code]EditorFileDialog[/code] can only view [code]user://[/code] directory contents. </constant> <constant name="ACCESS_FILESYSTEM" value="2" enum="Access"> + The [code]EditorFileDialog[/code] can view the entire local file system. </constant> <constant name="DISPLAY_THUMBNAILS" value="0" enum="DisplayMode"> + The [code]EditorFileDialog[/code] displays resources as thumbnails. </constant> <constant name="DISPLAY_LIST" value="1" enum="DisplayMode"> + The [code]EditorFileDialog[/code] displays resources as a list of filenames. </constant> </constants> </class> diff --git a/doc/classes/EditorFileSystemDirectory.xml b/doc/classes/EditorFileSystemDirectory.xml index 50b6f3680c..1a2f73a683 100644 --- a/doc/classes/EditorFileSystemDirectory.xml +++ b/doc/classes/EditorFileSystemDirectory.xml @@ -4,6 +4,7 @@ A diretory for the resource filesystem. </brief_description> <description> + A more generalized, low-level variation of the directory concept. </description> <tutorials> </tutorials> @@ -16,6 +17,7 @@ <argument index="0" name="name" type="String"> </argument> <description> + Returns the index of the directory with name [code]name[/code] or [code]-1[/code] if not found. </description> </method> <method name="find_file_index" qualifiers="const"> @@ -24,6 +26,7 @@ <argument index="0" name="name" type="String"> </argument> <description> + Returns the index of the file with name [code]name[/code] or [code]-1[/code] if not found. </description> </method> <method name="get_file" qualifiers="const"> @@ -32,12 +35,14 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the name of the file at index [code]idx[/code]. </description> </method> <method name="get_file_count" qualifiers="const"> <return type="int"> </return> <description> + Returns the number of files in this directory. </description> </method> <method name="get_file_import_is_valid" qualifiers="const"> @@ -46,6 +51,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns [code]true[/code] if the file at index [code]idx[/code] imported properly. </description> </method> <method name="get_file_path" qualifiers="const"> @@ -54,6 +60,7 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the path to the file at index [code]idx[/code]. </description> </method> <method name="get_file_type" qualifiers="const"> @@ -62,24 +69,28 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the file extension of the file at index [code]idx[/code]. </description> </method> <method name="get_name"> <return type="String"> </return> <description> + Returns the name of this directory. </description> </method> <method name="get_parent"> <return type="EditorFileSystemDirectory"> </return> <description> + Returns the parent directory for this directory or null if called on a directory at [code]res://[/code] or [code]user://[/code]. </description> </method> <method name="get_path" qualifiers="const"> <return type="String"> </return> <description> + Returns the path to this directory. </description> </method> <method name="get_subdir"> @@ -88,12 +99,14 @@ <argument index="0" name="idx" type="int"> </argument> <description> + Returns the subdirectory at index [code]idx[/code]. </description> </method> <method name="get_subdir_count" qualifiers="const"> <return type="int"> </return> <description> + Returns the number of subdirectories in this directory. </description> </method> </methods> diff --git a/doc/classes/EditorScript.xml b/doc/classes/EditorScript.xml index fcc297a1e8..97f126e7f7 100644 --- a/doc/classes/EditorScript.xml +++ b/doc/classes/EditorScript.xml @@ -9,7 +9,7 @@ [codeblock] tool extends EditorScript - + func _run(): print("Hello from the Godot Editor!") [/codeblock] @@ -33,6 +33,8 @@ <argument index="0" name="node" type="Node"> </argument> <description> + Adds [code]node[/code] as a child of the root node in the editor context. + WARNING: The implementation of this method is currently disabled. </description> </method> <method name="get_editor_interface"> diff --git a/doc/classes/FileDialog.xml b/doc/classes/FileDialog.xml index 0f7038238e..8057e95d44 100644 --- a/doc/classes/FileDialog.xml +++ b/doc/classes/FileDialog.xml @@ -160,6 +160,8 @@ </theme_item> <theme_item name="folder" type="Texture"> </theme_item> + <theme_item name="parent_folder" type="Texture"> + </theme_item> <theme_item name="reload" type="Texture"> </theme_item> </theme_items> diff --git a/doc/classes/GIProbeData.xml b/doc/classes/GIProbeData.xml index 2ac591889c..aba59f57ea 100644 --- a/doc/classes/GIProbeData.xml +++ b/doc/classes/GIProbeData.xml @@ -9,31 +9,161 @@ <demos> </demos> <methods> + <method name="get_bias" qualifiers="const"> + <return type="float"> + </return> + <description> + </description> + </method> + <method name="get_bounds" qualifiers="const"> + <return type="AABB"> + </return> + <description> + </description> + </method> + <method name="get_cell_size" qualifiers="const"> + <return type="float"> + </return> + <description> + </description> + </method> + <method name="get_dynamic_data" qualifiers="const"> + <return type="PoolIntArray"> + </return> + <description> + </description> + </method> + <method name="get_dynamic_range" qualifiers="const"> + <return type="int"> + </return> + <description> + </description> + </method> + <method name="get_energy" qualifiers="const"> + <return type="float"> + </return> + <description> + </description> + </method> + <method name="get_normal_bias" qualifiers="const"> + <return type="float"> + </return> + <description> + </description> + </method> + <method name="get_propagation" qualifiers="const"> + <return type="float"> + </return> + <description> + </description> + </method> + <method name="get_to_cell_xform" qualifiers="const"> + <return type="Transform"> + </return> + <description> + </description> + </method> + <method name="is_compressed" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="is_interior" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="set_bias"> + <return type="void"> + </return> + <argument index="0" name="bias" type="float"> + </argument> + <description> + </description> + </method> + <method name="set_bounds"> + <return type="void"> + </return> + <argument index="0" name="bounds" type="AABB"> + </argument> + <description> + </description> + </method> + <method name="set_cell_size"> + <return type="void"> + </return> + <argument index="0" name="cell_size" type="float"> + </argument> + <description> + </description> + </method> + <method name="set_compress"> + <return type="void"> + </return> + <argument index="0" name="compress" type="bool"> + </argument> + <description> + </description> + </method> + <method name="set_dynamic_data"> + <return type="void"> + </return> + <argument index="0" name="dynamic_data" type="PoolIntArray"> + </argument> + <description> + </description> + </method> + <method name="set_dynamic_range"> + <return type="void"> + </return> + <argument index="0" name="dynamic_range" type="int"> + </argument> + <description> + </description> + </method> + <method name="set_energy"> + <return type="void"> + </return> + <argument index="0" name="energy" type="float"> + </argument> + <description> + </description> + </method> + <method name="set_interior"> + <return type="void"> + </return> + <argument index="0" name="interior" type="bool"> + </argument> + <description> + </description> + </method> + <method name="set_normal_bias"> + <return type="void"> + </return> + <argument index="0" name="bias" type="float"> + </argument> + <description> + </description> + </method> + <method name="set_propagation"> + <return type="void"> + </return> + <argument index="0" name="propagation" type="float"> + </argument> + <description> + </description> + </method> + <method name="set_to_cell_xform"> + <return type="void"> + </return> + <argument index="0" name="to_cell_xform" type="Transform"> + </argument> + <description> + </description> + </method> </methods> - <members> - <member name="bias" type="float" setter="set_bias" getter="get_bias"> - </member> - <member name="bounds" type="AABB" setter="set_bounds" getter="get_bounds"> - </member> - <member name="cell_size" type="float" setter="set_cell_size" getter="get_cell_size"> - </member> - <member name="compress" type="bool" setter="set_compress" getter="is_compressed"> - </member> - <member name="dynamic_data" type="PoolIntArray" setter="set_dynamic_data" getter="get_dynamic_data"> - </member> - <member name="dynamic_range" type="int" setter="set_dynamic_range" getter="get_dynamic_range"> - </member> - <member name="energy" type="float" setter="set_energy" getter="get_energy"> - </member> - <member name="interior" type="bool" setter="set_interior" getter="is_interior"> - </member> - <member name="normal_bias" type="float" setter="set_normal_bias" getter="get_normal_bias"> - </member> - <member name="propagation" type="float" setter="set_propagation" getter="get_propagation"> - </member> - <member name="to_cell_xform" type="Transform" setter="set_to_cell_xform" getter="get_to_cell_xform"> - </member> - </members> <constants> </constants> </class> diff --git a/doc/classes/ItemList.xml b/doc/classes/ItemList.xml index d10722d411..f3d0c271ac 100644 --- a/doc/classes/ItemList.xml +++ b/doc/classes/ItemList.xml @@ -332,8 +332,6 @@ </member> <member name="icon_scale" type="float" setter="set_icon_scale" getter="get_icon_scale"> </member> - <member name="items" type="Array" setter="_set_items" getter="_get_items"> - </member> <member name="max_columns" type="int" setter="set_max_columns" getter="get_max_columns"> </member> <member name="max_text_lines" type="int" setter="set_max_text_lines" getter="get_max_text_lines"> diff --git a/doc/classes/JSON.xml b/doc/classes/JSON.xml index bda205d294..bb48833878 100644 --- a/doc/classes/JSON.xml +++ b/doc/classes/JSON.xml @@ -25,6 +25,10 @@ </return> <argument index="0" name="value" type="Variant"> </argument> + <argument index="1" name="indent" type="String" default=""""> + </argument> + <argument index="2" name="sort_keys" type="bool" default="false"> + </argument> <description> Converts a Variant var to JSON text and returns the result. Useful for serializing data to store or send over the network. </description> diff --git a/doc/classes/LargeTexture.xml b/doc/classes/LargeTexture.xml index 3899254e9d..9d79034dea 100644 --- a/doc/classes/LargeTexture.xml +++ b/doc/classes/LargeTexture.xml @@ -87,14 +87,6 @@ </description> </method> </methods> - <members> - <member name="_data" type="Array" setter="_set_data" getter="_get_data"> - Returns an [Array] with offsets and textures data of each added piece. Schema is [offsets1, texture1, offsets2, texture2, large_texture_size]. - [code]offsets[/code] : [Vector2] offsets of the texture piece. - [code]second[/code] : [StreamTexture] data of the texture piece. - [code]last entry[/code] : [Vector2] size of the entire large texture. - </member> - </members> <constants> </constants> </class> diff --git a/doc/classes/LinkButton.xml b/doc/classes/LinkButton.xml index a6194d129a..82b3a90180 100644 --- a/doc/classes/LinkButton.xml +++ b/doc/classes/LinkButton.xml @@ -30,6 +30,8 @@ </constant> </constants> <theme_items> + <theme_item name="focus" type="StyleBox"> + </theme_item> <theme_item name="font" type="Font"> </theme_item> <theme_item name="font_color" type="Color"> diff --git a/doc/classes/MenuButton.xml b/doc/classes/MenuButton.xml index 6f41f84485..c41c86d693 100644 --- a/doc/classes/MenuButton.xml +++ b/doc/classes/MenuButton.xml @@ -19,10 +19,6 @@ </description> </method> </methods> - <members> - <member name="items" type="Array" setter="_set_items" getter="_get_items"> - </member> - </members> <signals> <signal name="about_to_show"> <description> diff --git a/doc/classes/MultiMesh.xml b/doc/classes/MultiMesh.xml index ae26641596..ff2d89b2ca 100644 --- a/doc/classes/MultiMesh.xml +++ b/doc/classes/MultiMesh.xml @@ -63,16 +63,12 @@ </method> </methods> <members> - <member name="color_array" type="PoolColorArray" setter="_set_color_array" getter="_get_color_array"> - </member> <member name="color_format" type="int" setter="set_color_format" getter="get_color_format" enum="MultiMesh.ColorFormat"> </member> <member name="instance_count" type="int" setter="set_instance_count" getter="get_instance_count"> </member> <member name="mesh" type="Mesh" setter="set_mesh" getter="get_mesh"> </member> - <member name="transform_array" type="PoolVector3Array" setter="_set_transform_array" getter="_get_transform_array"> - </member> <member name="transform_format" type="int" setter="set_transform_format" getter="get_transform_format" enum="MultiMesh.TransformFormat"> </member> </members> diff --git a/doc/classes/NavigationMesh.xml b/doc/classes/NavigationMesh.xml index 5563c94b35..55a3771d79 100644 --- a/doc/classes/NavigationMesh.xml +++ b/doc/classes/NavigationMesh.xml @@ -45,6 +45,20 @@ <description> </description> </method> + <method name="get_vertices" qualifiers="const"> + <return type="PoolVector3Array"> + </return> + <description> + </description> + </method> + <method name="set_vertices"> + <return type="void"> + </return> + <argument index="0" name="vertices" type="PoolVector3Array"> + </argument> + <description> + </description> + </method> </methods> <members> <member name="agent/height" type="float" setter="set_agent_height" getter="get_agent_height"> @@ -75,16 +89,12 @@ </member> <member name="polygon/verts_per_poly" type="float" setter="set_verts_per_poly" getter="get_verts_per_poly"> </member> - <member name="polygons" type="Array" setter="_set_polygons" getter="_get_polygons"> - </member> <member name="region/merge_size" type="float" setter="set_region_merge_size" getter="get_region_merge_size"> </member> <member name="region/min_size" type="float" setter="set_region_min_size" getter="get_region_min_size"> </member> <member name="sample_partition_type/sample_partition_type" type="int" setter="set_sample_partition_type" getter="get_sample_partition_type"> </member> - <member name="vertices" type="PoolVector3Array" setter="set_vertices" getter="get_vertices"> - </member> </members> <constants> <constant name="SAMPLE_PARTITION_WATERSHED" value="0"> diff --git a/doc/classes/NavigationPolygon.xml b/doc/classes/NavigationPolygon.xml index 585566dbf9..663ac4cd67 100644 --- a/doc/classes/NavigationPolygon.xml +++ b/doc/classes/NavigationPolygon.xml @@ -75,6 +75,12 @@ <description> </description> </method> + <method name="get_vertices" qualifiers="const"> + <return type="PoolVector2Array"> + </return> + <description> + </description> + </method> <method name="make_polygons_from_outlines"> <return type="void"> </return> @@ -99,15 +105,15 @@ <description> </description> </method> + <method name="set_vertices"> + <return type="void"> + </return> + <argument index="0" name="vertices" type="PoolVector2Array"> + </argument> + <description> + </description> + </method> </methods> - <members> - <member name="outlines" type="Array" setter="_set_outlines" getter="_get_outlines"> - </member> - <member name="polygons" type="Array" setter="_set_polygons" getter="_get_polygons"> - </member> - <member name="vertices" type="PoolVector2Array" setter="set_vertices" getter="get_vertices"> - </member> - </members> <constants> </constants> </class> diff --git a/doc/classes/NetworkedMultiplayerPeer.xml b/doc/classes/NetworkedMultiplayerPeer.xml index 33ffce9cf9..a7350b3863 100644 --- a/doc/classes/NetworkedMultiplayerPeer.xml +++ b/doc/classes/NetworkedMultiplayerPeer.xml @@ -1,8 +1,10 @@ <?xml version="1.0" encoding="UTF-8" ?> <class name="NetworkedMultiplayerPeer" inherits="PacketPeer" category="Core" version="3.0-beta"> <brief_description> + A high-level network interface to simplify multiplayer interactions. </brief_description> <description> + Manages the connection to network peers. Assigns unique IDs to each client connected to the server. </description> <tutorials> </tutorials> @@ -13,31 +15,35 @@ <return type="int" enum="NetworkedMultiplayerPeer.ConnectionStatus"> </return> <description> + Returns the current state of the connection. See [enum ConnectionStatus]. </description> </method> <method name="get_packet_peer" qualifiers="const"> <return type="int"> </return> <description> + Returns the ID of the [code]NetworkedMultiplayerPeer[/code] who sent the most recent packet. </description> </method> <method name="get_unique_id" qualifiers="const"> <return type="int"> </return> <description> + Returns the ID of this [code]NetworkedMultiplayerPeer[/code]. </description> </method> <method name="is_refusing_new_connections" qualifiers="const"> <return type="bool"> </return> <description> - Return whether this [code]NetworkedMultiplayerPeer[/code] is refusing new connections. + Returns [code]true[/code] if this [code]NetworkedMultiplayerPeer[/code] refuses new connections. Default value: [code]false[/code]. </description> </method> <method name="poll"> <return type="void"> </return> <description> + Waits up to 1 second to receive a new network event. </description> </method> <method name="set_refuse_new_connections"> @@ -46,7 +52,7 @@ <argument index="0" name="enable" type="bool"> </argument> <description> - If [code]endable[/code] is true, this [code]NetworkedMultiplayerPeer[/code] will refuse new connections. + If [code]true[/code] this [code]NetworkedMultiplayerPeer[/code] refuses new connections. Default value: [code]false[/code]. </description> </method> <method name="set_target_peer"> @@ -55,6 +61,7 @@ <argument index="0" name="id" type="int"> </argument> <description> + The peer to which packets will be sent. Default value: [code]0[/code]. </description> </method> <method name="set_transfer_mode"> @@ -63,56 +70,65 @@ <argument index="0" name="mode" type="int" enum="NetworkedMultiplayerPeer.TransferMode"> </argument> <description> + The manner in which to send packets to the [code]target_peer[/code]. See [enum TransferMode]. </description> </method> </methods> <signals> <signal name="connection_failed"> <description> - Emitted when failed to connect to server. + Emitted when a connection attempt fails. </description> </signal> <signal name="connection_succeeded"> <description> - Emitted when successfully connected to server. + Emitted when a connection attempt succeeds. </description> </signal> <signal name="peer_connected"> <argument index="0" name="id" type="int"> </argument> <description> - Emitted by the server when a client is connected. + Emitted by the server when a client connects. </description> </signal> <signal name="peer_disconnected"> <argument index="0" name="id" type="int"> </argument> <description> - Emitted by the server when a client is disconnected. + Emitted by the server when a client disconnects. </description> </signal> <signal name="server_disconnected"> <description> - Emitted by clients when server is disconnected. + Emitted by clients when the server disconnects. </description> </signal> </signals> <constants> <constant name="TRANSFER_MODE_UNRELIABLE" value="0" enum="TransferMode"> + Packets are sent via unordered UDP packets. </constant> <constant name="TRANSFER_MODE_UNRELIABLE_ORDERED" value="1" enum="TransferMode"> + Packets are sent via ordered UDP packets. </constant> <constant name="TRANSFER_MODE_RELIABLE" value="2" enum="TransferMode"> + Packets are sent via TCP packets. </constant> <constant name="CONNECTION_DISCONNECTED" value="0" enum="ConnectionStatus"> + The ongoing connection disconnected. </constant> <constant name="CONNECTION_CONNECTING" value="1" enum="ConnectionStatus"> + A connection attempt is ongoing. </constant> <constant name="CONNECTION_CONNECTED" value="2" enum="ConnectionStatus"> + The connection attempt succeeded. </constant> <constant name="TARGET_PEER_BROADCAST" value="0"> + Packets are sent to the server and then redistributed to other peers. </constant> <constant name="TARGET_PEER_SERVER" value="1"> + Packets are sent to the server alone. </constant> </constants> </class> diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index 13a25fa48f..e2198c3e15 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -350,6 +350,12 @@ Returns [code]true[/code] if the "node" argument is a direct or indirect child of the current node, otherwise return [code]false[code]. </description> </method> + <method name="is_displayed_folded" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> <method name="is_greater_than" qualifiers="const"> <return type="bool"> </return> @@ -641,6 +647,14 @@ Remotely changes property's value on a specific peer identified by [i]peer_id[/i] using an unreliable protocol. </description> </method> + <method name="set_display_folded"> + <return type="void"> + </return> + <argument index="0" name="fold" type="bool"> + </argument> + <description> + </description> + </method> <method name="set_filename"> <return type="void"> </return> @@ -750,10 +764,6 @@ </method> </methods> <members> - <member name="_import_path" type="NodePath" setter="_set_import_path" getter="_get_import_path"> - </member> - <member name="editor/display_folded" type="bool" setter="set_display_folded" getter="is_displayed_folded"> - </member> <member name="pause_mode" type="int" setter="set_pause_mode" getter="get_pause_mode" enum="Node.PauseMode"> </member> </members> diff --git a/doc/classes/Node2D.xml b/doc/classes/Node2D.xml index 112960d9f8..81978809d7 100644 --- a/doc/classes/Node2D.xml +++ b/doc/classes/Node2D.xml @@ -38,6 +38,12 @@ Returns the [Transform2D] relative to this node's parent. </description> </method> + <method name="get_rotation" qualifiers="const"> + <return type="float"> + </return> + <description> + </description> + </method> <method name="global_translate"> <return type="void"> </return> @@ -87,6 +93,14 @@ Applies a rotation to the node, in radians, starting from its current rotation. </description> </method> + <method name="set_rotation"> + <return type="void"> + </return> + <argument index="0" name="radians" type="float"> + </argument> + <description> + </description> + </method> <method name="to_global" qualifiers="const"> <return type="Vector2"> </return> @@ -134,9 +148,6 @@ <member name="position" type="Vector2" setter="set_position" getter="get_position"> Position, relative to the node's parent. </member> - <member name="rotation" type="float" setter="set_rotation" getter="get_rotation"> - Rotation in radians, relative to the node's parent. - </member> <member name="rotation_degrees" type="float" setter="set_rotation_degrees" getter="get_rotation_degrees"> Rotation in degrees, relative to the node's parent. </member> diff --git a/doc/classes/OptionButton.xml b/doc/classes/OptionButton.xml index 5f1b6f328c..76265e700a 100644 --- a/doc/classes/OptionButton.xml +++ b/doc/classes/OptionButton.xml @@ -183,8 +183,6 @@ </method> </methods> <members> - <member name="items" type="Array" setter="_set_items" getter="_get_items"> - </member> <member name="selected" type="int" setter="_select_int" getter="get_selected"> </member> </members> diff --git a/doc/classes/PolygonPathFinder.xml b/doc/classes/PolygonPathFinder.xml index 58c14cc920..48c5625e6b 100644 --- a/doc/classes/PolygonPathFinder.xml +++ b/doc/classes/PolygonPathFinder.xml @@ -80,10 +80,6 @@ </description> </method> </methods> - <members> - <member name="data" type="Dictionary" setter="_set_data" getter="_get_data"> - </member> - </members> <constants> </constants> </class> diff --git a/doc/classes/PopupMenu.xml b/doc/classes/PopupMenu.xml index 6b36ff9eee..7071d64f2e 100644 --- a/doc/classes/PopupMenu.xml +++ b/doc/classes/PopupMenu.xml @@ -423,8 +423,6 @@ </member> <member name="hide_on_item_selection" type="bool" setter="set_hide_on_item_selection" getter="is_hide_on_item_selection"> </member> - <member name="items" type="Array" setter="_set_items" getter="_get_items"> - </member> </members> <signals> <signal name="id_pressed"> diff --git a/doc/classes/ProxyTexture.xml b/doc/classes/ProxyTexture.xml new file mode 100644 index 0000000000..2cdcac8775 --- /dev/null +++ b/doc/classes/ProxyTexture.xml @@ -0,0 +1,19 @@ +<?xml version="1.0" encoding="UTF-8" ?> +<class name="ProxyTexture" inherits="Texture" category="Core" version="3.0-beta"> + <brief_description> + </brief_description> + <description> + </description> + <tutorials> + </tutorials> + <demos> + </demos> + <methods> + </methods> + <members> + <member name="base" type="Texture" setter="set_base" getter="get_base"> + </member> + </members> + <constants> + </constants> +</class> diff --git a/doc/classes/RayCast.xml b/doc/classes/RayCast.xml index 1ec16753c2..20e262b664 100644 --- a/doc/classes/RayCast.xml +++ b/doc/classes/RayCast.xml @@ -77,6 +77,7 @@ <argument index="0" name="bit" type="int"> </argument> <description> + Returns [code]true[/code] if the bit index passed is turned on. Note that bit indexes range from 0-19. </description> </method> <method name="get_collision_normal" qualifiers="const"> @@ -126,6 +127,7 @@ <argument index="1" name="value" type="bool"> </argument> <description> + Sets the bit index passed to the [code]value[/code] passed. Note that bit indexes range from 0-19. </description> </method> </methods> @@ -137,7 +139,10 @@ The ray's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. </member> <member name="enabled" type="bool" setter="set_enabled" getter="is_enabled"> - If [code]true[/code], collisions will be reported. Default value: [code]false[/code]. + If [code]true[/code] collisions will be reported. Default value: [code]false[/code]. + </member> + <member name="exclude_parent" type="bool" setter="set_exclude_parent_body" getter="get_exclude_parent_body"> + If [code]true[/code] collisions will be ignored for this RayCast's immediate parent. Default value: [code]true[/code]. </member> </members> <constants> diff --git a/doc/classes/ResourcePreloader.xml b/doc/classes/ResourcePreloader.xml index 1766845bf2..c749529a19 100644 --- a/doc/classes/ResourcePreloader.xml +++ b/doc/classes/ResourcePreloader.xml @@ -67,10 +67,6 @@ </description> </method> </methods> - <members> - <member name="resources" type="Array" setter="_set_resources" getter="_get_resources"> - </member> - </members> <constants> </constants> </class> diff --git a/doc/classes/Shader.xml b/doc/classes/Shader.xml index 543164d92e..082c48dfce 100644 --- a/doc/classes/Shader.xml +++ b/doc/classes/Shader.xml @@ -11,6 +11,12 @@ <demos> </demos> <methods> + <method name="get_code" qualifiers="const"> + <return type="String"> + </return> + <description> + </description> + </method> <method name="get_default_texture_param" qualifiers="const"> <return type="Texture"> </return> @@ -33,6 +39,14 @@ <description> </description> </method> + <method name="set_code"> + <return type="void"> + </return> + <argument index="0" name="code" type="String"> + </argument> + <description> + </description> + </method> <method name="set_default_texture_param"> <return type="void"> </return> @@ -44,10 +58,6 @@ </description> </method> </methods> - <members> - <member name="code" type="String" setter="set_code" getter="get_code"> - </member> - </members> <constants> <constant name="MODE_SPATIAL" value="0" enum="Mode"> </constant> diff --git a/doc/classes/SpatialMaterial.xml b/doc/classes/SpatialMaterial.xml index 4e63e6dd11..cf08b0daae 100644 --- a/doc/classes/SpatialMaterial.xml +++ b/doc/classes/SpatialMaterial.xml @@ -79,6 +79,8 @@ </member> <member name="emission_texture" type="Texture" setter="set_texture" getter="get_texture"> </member> + <member name="flags_albedo_tex_force_srgb" type="bool" setter="set_flag" getter="get_flag"> + </member> <member name="flags_fixed_size" type="bool" setter="set_flag" getter="get_flag"> </member> <member name="flags_no_depth_test" type="bool" setter="set_flag" getter="get_flag"> @@ -307,7 +309,9 @@ </constant> <constant name="FLAG_TRIPLANAR_USE_WORLD" value="9" enum="Flags"> </constant> - <constant name="FLAG_MAX" value="12" enum="Flags"> + <constant name="FLAG_ALBEDO_TEXTURE_FORCE_SRGB" value="12" enum="Flags"> + </constant> + <constant name="FLAG_MAX" value="13" enum="Flags"> </constant> <constant name="DIFFUSE_BURLEY" value="0" enum="DiffuseMode"> </constant> diff --git a/doc/classes/SpriteFrames.xml b/doc/classes/SpriteFrames.xml index 0157386573..883a6d4fa8 100644 --- a/doc/classes/SpriteFrames.xml +++ b/doc/classes/SpriteFrames.xml @@ -164,9 +164,6 @@ </method> </methods> <members> - <member name="animations" type="Array" setter="_set_animations" getter="_get_animations"> - An [Array] containing the [code]name[/code], [code]speed[/code], [code]loop[/code], and [code]frames[/code] of each animation. - </member> <member name="frames" type="Array" setter="_set_frames" getter="_get_frames"> </member> </members> diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml index d5afe28eb8..df48ba3e23 100644 --- a/doc/classes/TextEdit.xml +++ b/doc/classes/TextEdit.xml @@ -470,6 +470,8 @@ </theme_item> <theme_item name="number_color" type="Color"> </theme_item> + <theme_item name="read_only" type="StyleBox"> + </theme_item> <theme_item name="selection_color" type="Color"> </theme_item> <theme_item name="symbol_color" type="Color"> diff --git a/doc/classes/Translation.xml b/doc/classes/Translation.xml index a684e63e22..cb49c66383 100644 --- a/doc/classes/Translation.xml +++ b/doc/classes/Translation.xml @@ -57,8 +57,6 @@ <members> <member name="locale" type="String" setter="set_locale" getter="get_locale"> </member> - <member name="messages" type="PoolStringArray" setter="_set_messages" getter="_get_messages"> - </member> </members> <constants> </constants> diff --git a/drivers/convex_decomp/b2d_decompose.cpp b/drivers/convex_decomp/b2d_decompose.cpp index 97d312983f..c7681ed2ad 100644 --- a/drivers/convex_decomp/b2d_decompose.cpp +++ b/drivers/convex_decomp/b2d_decompose.cpp @@ -153,7 +153,7 @@ static Vector<Vector<Vector2> > _b2d_decompose(const Vector<Vector2> &p_polygon) delete p; return res; // pdarray; //needs to be deleted after body is created } -} +} // namespace b2ConvexDecomp Vector<Vector<Vector2> > b2d_decompose(const Vector<Vector2> &p_polygon) { diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 3031b70f70..d38ec2a1f9 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1134,18 +1134,6 @@ bool RasterizerSceneGLES3::_setup_material(RasterizerStorageGLES3::Material *p_m state.current_depth_draw = p_material->shader->spatial.depth_draw_mode; } -//glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - -/* - if (p_material->flags[VS::MATERIAL_FLAG_WIREFRAME]) - glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); - else - glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); - - if (p_material->line_width) - glLineWidth(p_material->line_width); - */ - #if 0 //blend mode if (state.current_blend_mode!=p_material->shader->spatial.blend_mode) { diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index 99c8044e2f..ffbe10fb60 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -817,7 +817,7 @@ public: void _render_list(RenderList::Element **p_elements, int p_element_count, const Transform &p_view_transform, const CameraMatrix &p_projection, GLuint p_base_env, bool p_reverse_cull, bool p_alpha_pass, bool p_shadow, bool p_directional_add, bool p_directional_shadows); - _FORCE_INLINE_ void _add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_depth_pass,bool p_shadow_pass); + _FORCE_INLINE_ void _add_geometry(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, int p_material, bool p_depth_pass, bool p_shadow_pass); _FORCE_INLINE_ void _add_geometry_with_material(RasterizerStorageGLES3::Geometry *p_geometry, InstanceBase *p_instance, RasterizerStorageGLES3::GeometryOwner *p_owner, RasterizerStorageGLES3::Material *p_material, bool p_depth_pass, bool p_shadow_pass); diff --git a/drivers/gles3/rasterizer_storage_gles3.h b/drivers/gles3/rasterizer_storage_gles3.h index d5efd5307c..25327af0a5 100644 --- a/drivers/gles3/rasterizer_storage_gles3.h +++ b/drivers/gles3/rasterizer_storage_gles3.h @@ -486,8 +486,8 @@ public: bool uses_vertex_time; bool uses_fragment_time; - Shader() - : dirty_list(this) { + Shader() : + dirty_list(this) { shader = NULL; ubo_size = 0; @@ -540,8 +540,9 @@ public: bool can_cast_shadow_cache; bool is_animated_cache; - Material() - : list(this), dirty_list(this) { + Material() : + list(this), + dirty_list(this) { can_cast_shadow_cache = false; is_animated_cache = false; shader = NULL; @@ -764,8 +765,9 @@ public: bool dirty_aabb; bool dirty_data; - MultiMesh() - : update_list(this), mesh_list(this) { + MultiMesh() : + update_list(this), + mesh_list(this) { dirty_aabb = true; dirty_data = true; xform_floats = 0; @@ -865,8 +867,8 @@ public: SelfList<Skeleton> update_list; Set<RasterizerScene::InstanceBase *> instances; //instances using skeleton - Skeleton() - : update_list(this) { + Skeleton() : + update_list(this) { size = 0; use_2d = false; @@ -1116,8 +1118,8 @@ public: Transform emission_transform; - Particles() - : particle_element(this) { + Particles() : + particle_element(this) { cycle_number = 0; emitting = false; one_shot = false; diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index 79b989be4a..b70d59652d 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -827,7 +827,7 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) { pixel_size = abs((pos.y-endpoint.y)/(screen_rel.y/screen_pixel_size.y)); }*/ - vec4 bias = projection_matrix * vec4(pos+vec3(0.0,0.0,0.04), 1.0); //todo un-harcode the 0.04 + vec4 bias = projection_matrix * vec4(pos+vec3(0.0,0.0,max_distance*0.5), 1.0); //todo un-harcode the 0.04 @@ -1030,7 +1030,7 @@ LIGHT_SHADER_CODE #if defined(LIGHT_USE_RIM) - float rim_light = pow(1.0-cNdotV, (1.0-roughness)*16.0); + float rim_light = pow(max(0.0,1.0-cNdotV), max(0.0,(1.0-roughness)*16.0)); diffuse_light += rim_light * rim * mix(vec3(1.0),diffuse_color,rim_tint) * light_color; #endif } diff --git a/drivers/unix/ip_unix.cpp b/drivers/unix/ip_unix.cpp index 77c942c673..6254466efc 100644 --- a/drivers/unix/ip_unix.cpp +++ b/drivers/unix/ip_unix.cpp @@ -149,10 +149,7 @@ void IP_Unix::get_local_addresses(List<IP_Address> *r_addresses) const { while (true) { addrs = (IP_ADAPTER_ADDRESSES *)memalloc(buf_size); - int err = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | - GAA_FLAG_SKIP_MULTICAST | - GAA_FLAG_SKIP_DNS_SERVER | - GAA_FLAG_SKIP_FRIENDLY_NAME, + int err = GetAdaptersAddresses(AF_UNSPEC, GAA_FLAG_SKIP_ANYCAST | GAA_FLAG_SKIP_MULTICAST | GAA_FLAG_SKIP_DNS_SERVER | GAA_FLAG_SKIP_FRIENDLY_NAME, NULL, addrs, &buf_size); if (err == NO_ERROR) { break; diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp index fa208f40ec..5a06a58b80 100644 --- a/drivers/unix/os_unix.cpp +++ b/drivers/unix/os_unix.cpp @@ -391,7 +391,7 @@ String OS_Unix::get_locale() const { return locale; } -Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle,bool p_also_set_library_path) { +Error OS_Unix::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) { p_library_handle = dlopen(p_path.utf8().get_data(), RTLD_NOW); if (!p_library_handle) { ERR_EXPLAIN("Can't open dynamic library: " + p_path + ". Error: " + dlerror()); diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h index 325aaf7550..1a4c73ce4c 100644 --- a/drivers/unix/os_unix.h +++ b/drivers/unix/os_unix.h @@ -77,7 +77,7 @@ public: //virtual VideoMode get_video_mode() const; //virtual void get_fullscreen_mode_list(List<VideoMode> *p_list) const; - virtual Error open_dynamic_library(const String p_path, void *&p_library_handle,bool p_also_set_library_path=false); + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false); virtual Error close_dynamic_library(void *p_library_handle); virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false); diff --git a/drivers/xaudio2/audio_driver_xaudio2.h b/drivers/xaudio2/audio_driver_xaudio2.h index 27ef2ebcb8..dd4fc76047 100644 --- a/drivers/xaudio2/audio_driver_xaudio2.h +++ b/drivers/xaudio2/audio_driver_xaudio2.h @@ -48,8 +48,8 @@ class AudioDriverXAudio2 : public AudioDriver { struct XAudio2DriverVoiceCallback : public IXAudio2VoiceCallback { HANDLE buffer_end_event; - XAudio2DriverVoiceCallback() - : buffer_end_event(CreateEvent(NULL, FALSE, FALSE, NULL)) {} + XAudio2DriverVoiceCallback() : + buffer_end_event(CreateEvent(NULL, FALSE, FALSE, NULL)) {} void STDMETHODCALLTYPE OnBufferEnd(void *pBufferContext) { /*print_line("buffer ended");*/ SetEvent(buffer_end_event); } diff --git a/editor/dependency_editor.h b/editor/dependency_editor.h index 9b0aca67d5..0cc153945d 100644 --- a/editor/dependency_editor.h +++ b/editor/dependency_editor.h @@ -35,6 +35,7 @@ #include "scene/gui/tab_container.h" #include "scene/gui/tree.h" +class EditorFileDialog; class EditorFileSystemDirectory; class EditorNode; diff --git a/editor/doc/doc_data.cpp b/editor/doc/doc_data.cpp index 3a72f8e569..0bb059f425 100644 --- a/editor/doc/doc_data.cpp +++ b/editor/doc/doc_data.cpp @@ -235,7 +235,7 @@ void DocData::generate(bool p_basic_types) { ClassDB::get_property_list(name, &properties, true); for (List<PropertyInfo>::Element *E = properties.front(); E; E = E->next()) { - if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_CATEGORY) + if (E->get().usage & PROPERTY_USAGE_GROUP || E->get().usage & PROPERTY_USAGE_CATEGORY || E->get().usage & PROPERTY_USAGE_INTERNAL) continue; PropertyDoc prop; diff --git a/editor/editor_export.cpp b/editor/editor_export.cpp index 8c8d9c4c79..3f618c3199 100644 --- a/editor/editor_export.cpp +++ b/editor/editor_export.cpp @@ -743,6 +743,18 @@ Error EditorExportPlatform::export_project_files(const Ref<EditorExportPreset> & custom_map["path_remap/remapped_paths"] = path_remaps; } + // Store icon and splash images directly, they need to bypass the import system and be loaded as images + String icon = ProjectSettings::get_singleton()->get("application/config/icon"); + String splash = ProjectSettings::get_singleton()->get("application/boot_splash/image"); + if (icon != String() && FileAccess::exists(icon)) { + Vector<uint8_t> array = FileAccess::get_file_as_array(icon); + p_func(p_udata, icon, array, idx, total); + } + if (splash != String() && FileAccess::exists(splash)) { + Vector<uint8_t> array = FileAccess::get_file_as_array(splash); + p_func(p_udata, splash, array, idx, total); + } + String config_file = "project.binary"; String engine_cfb = EditorSettings::get_singleton()->get_cache_dir().plus_file("tmp" + config_file); ProjectSettings::get_singleton()->save_custom(engine_cfb, custom_map, custom_list); @@ -1249,6 +1261,7 @@ bool EditorExportPlatformPC::can_export(const Ref<EditorExportPreset> &p_preset, if (custom_debug_binary == "" && custom_release_binary == "") { if (!err.empty()) r_error = err; + r_missing_templates = !valid; return valid; } diff --git a/editor/editor_export.h b/editor/editor_export.h index 346c3b58e1..215a770a12 100644 --- a/editor/editor_export.h +++ b/editor/editor_export.h @@ -122,8 +122,9 @@ struct SharedObject { String path; Vector<String> tags; - SharedObject(const String &p_path, const Vector<String> &p_tags) - : path(p_path), tags(p_tags) { + SharedObject(const String &p_path, const Vector<String> &p_tags) : + path(p_path), + tags(p_tags) { } SharedObject() {} diff --git a/editor/editor_file_dialog.cpp b/editor/editor_file_dialog.cpp index eb5af2eaeb..eaa57fa46b 100644 --- a/editor/editor_file_dialog.cpp +++ b/editor/editor_file_dialog.cpp @@ -28,12 +28,13 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ #include "editor_file_dialog.h" - +#include "dependency_editor.h" #include "editor_resource_preview.h" #include "editor_scale.h" #include "editor_settings.h" #include "os/file_access.h" #include "os/keyboard.h" +#include "os/os.h" #include "print_string.h" #include "scene/gui/center_container.h" #include "scene/gui/label.h" @@ -159,6 +160,10 @@ void EditorFileDialog::_unhandled_input(const Ref<InputEvent> &p_event) { _make_dir(); handled = true; } + if (ED_IS_SHORTCUT("file_dialog/delete", p_event)) { + _delete_items(); + handled = true; + } if (ED_IS_SHORTCUT("file_dialog/focus_path", p_event)) { dir->grab_focus(); handled = true; @@ -512,6 +517,106 @@ void EditorFileDialog::_item_dc_selected(int p_item) { } } +void EditorFileDialog::_item_list_item_rmb_selected(int p_item, const Vector2 &p_pos) { + + // Right click on specific file(s) or folder(s). + item_menu->clear(); + item_menu->set_size(Size2(1, 1)); + + // Allow specific actions only on one item. + bool single_item_selected = item_list->get_selected_items().size() == 1; + + // Disallow deleting the .import folder, Godot kills a cat if you do and it is possibly a senseless novice action. + bool allow_delete = true; + for (int i = 0; i < item_list->get_item_count(); i++) { + if (!item_list->is_selected(i)) { + continue; + } + Dictionary item_meta = item_list->get_item_metadata(i); + if (item_meta["path"] == "res://.import") { + allow_delete = false; + break; + } + } + + if (single_item_selected) { + item_menu->add_icon_item(get_icon("CopyNodePath", "EditorIcons"), TTR("Copy Path"), ITEM_MENU_COPY_PATH); + } + if (allow_delete) { + item_menu->add_icon_item(get_icon("Remove", "EditorIcons"), TTR("Delete"), ITEM_MENU_DELETE, KEY_DELETE); + } + if (single_item_selected) { + item_menu->add_separator(); + item_menu->add_icon_item(get_icon("Filesystem", "EditorIcons"), TTR("Show In File Manager"), ITEM_MENU_SHOW_IN_EXPLORER); + } + + if (item_menu->get_item_count() > 0) { + item_menu->set_position(item_list->get_global_position() + p_pos); + item_menu->popup(); + } +} + +void EditorFileDialog::_item_list_rmb_clicked(const Vector2 &p_pos) { + + // Right click on folder background. Deselect all files so that actions are applied on the current folder. + for (int i = 0; i < item_list->get_item_count(); i++) { + item_list->unselect(i); + } + + item_menu->clear(); + item_menu->set_size(Size2(1, 1)); + + if (can_create_dir) { + item_menu->add_icon_item(get_icon("folder", "FileDialog"), TTR("New Folder.."), ITEM_MENU_NEW_FOLDER, KEY_MASK_CMD | KEY_N); + } + item_menu->add_icon_item(get_icon("Reload", "EditorIcons"), TTR("Refresh"), ITEM_MENU_REFRESH, KEY_F5); + item_menu->add_separator(); + item_menu->add_icon_item(get_icon("Filesystem", "EditorIcons"), TTR("Show In File Manager"), ITEM_MENU_SHOW_IN_EXPLORER); + + item_menu->set_position(item_list->get_global_position() + p_pos); + item_menu->popup(); +} + +void EditorFileDialog::_item_menu_id_pressed(int p_option) { + + switch (p_option) { + + case ITEM_MENU_COPY_PATH: { + Dictionary item_meta = item_list->get_item_metadata(item_list->get_current()); + OS::get_singleton()->set_clipboard(item_meta["path"]); + } break; + + case ITEM_MENU_DELETE: { + _delete_items(); + } break; + + case ITEM_MENU_REFRESH: { + invalidate(); + } break; + + case ITEM_MENU_NEW_FOLDER: { + _make_dir(); + } break; + + case ITEM_MENU_SHOW_IN_EXPLORER: { + String path; + int idx = item_list->get_current(); + if (idx == -1 || item_list->get_selected_items().size() == 0) { + // Folder background was clicked. Open this folder. + path = ProjectSettings::get_singleton()->globalize_path(dir_access->get_current_dir()); + } else { + // Specific item was clicked. Open folders directly, or the folder containing a selected file. + Dictionary item_meta = item_list->get_item_metadata(idx); + path = ProjectSettings::get_singleton()->globalize_path(item_meta["path"]); + if (!item_meta["dir"]) { + path = path.get_base_dir(); + } + } + OS::get_singleton()->shell_open(String("file://") + path); + } break; + } +} + bool EditorFileDialog::_is_open_should_be_disabled() { if (mode == MODE_OPEN_ANY || mode == MODE_SAVE_FILE) @@ -617,7 +722,7 @@ void EditorFileDialog::update_file_list() { Dictionary d; d["name"] = dir_name; - d["path"] = String(); + d["path"] = cdir.plus_file(dir_name); d["dir"] = true; item_list->set_item_metadata(item_list->get_item_count() - 1, d); @@ -657,8 +762,6 @@ void EditorFileDialog::update_file_list() { } } - String base_dir = dir_access->get_current_dir(); - while (!files.empty()) { bool match = patterns.empty(); @@ -679,7 +782,7 @@ void EditorFileDialog::update_file_list() { if (get_icon_func) { - Ref<Texture> icon = get_icon_func(base_dir.plus_file(files.front()->get())); + Ref<Texture> icon = get_icon_func(cdir.plus_file(files.front()->get())); //ti->set_icon(0,icon); if (display_mode == DISPLAY_THUMBNAILS) { @@ -698,12 +801,11 @@ void EditorFileDialog::update_file_list() { Dictionary d; d["name"] = files.front()->get(); d["dir"] = false; - String fullpath = base_dir.plus_file(files.front()->get()); - + String fullpath = cdir.plus_file(files.front()->get()); if (display_mode == DISPLAY_THUMBNAILS) { EditorResourcePreview::get_singleton()->queue_resource_preview(fullpath, this, "_thumbnail_result", fullpath); } - d["path"] = base_dir.plus_file(files.front()->get()); + d["path"] = fullpath; //ti->set_metadata(0,d); item_list->set_item_metadata(item_list->get_item_count() - 1, d); @@ -723,7 +825,7 @@ void EditorFileDialog::update_file_list() { fav_down->set_disabled(true); get_ok()->set_disabled(_is_open_should_be_disabled()); for (int i = 0; i < favorites->get_item_count(); i++) { - if (favorites->get_item_metadata(i) == base_dir) { + if (favorites->get_item_metadata(i) == cdir) { favorites->select(i); favorite->set_pressed(true); if (i > 0) { @@ -854,27 +956,27 @@ void EditorFileDialog::set_mode(Mode p_mode) { case MODE_OPEN_FILE: get_ok()->set_text(TTR("Open")); set_title(TTR("Open a File")); - makedir->hide(); + can_create_dir = false; break; case MODE_OPEN_FILES: get_ok()->set_text(TTR("Open")); set_title(TTR("Open File(s)")); - makedir->hide(); + can_create_dir = false; break; case MODE_OPEN_DIR: get_ok()->set_text(TTR("Open")); set_title(TTR("Open a Directory")); - makedir->show(); + can_create_dir = true; break; case MODE_OPEN_ANY: get_ok()->set_text(TTR("Open")); set_title(TTR("Open a File or Directory")); - makedir->show(); + can_create_dir = true; break; case MODE_SAVE_FILE: get_ok()->set_text(TTR("Save")); set_title(TTR("Save a File")); - makedir->show(); + can_create_dir = true; break; } @@ -883,6 +985,12 @@ void EditorFileDialog::set_mode(Mode p_mode) { } else { item_list->set_select_mode(ItemList::SELECT_SINGLE); } + + if (can_create_dir) { + makedir->show(); + } else { + makedir->hide(); + } } EditorFileDialog::Mode EditorFileDialog::get_mode() const { @@ -954,6 +1062,28 @@ void EditorFileDialog::_make_dir() { makedirname->grab_focus(); } +void EditorFileDialog::_delete_items() { + + // Collect the selected folders and files to delete and check them in the deletion dependency dialog. + Vector<String> folders; + Vector<String> files; + for (int i = 0; i < item_list->get_item_count(); i++) { + if (!item_list->is_selected(i)) { + continue; + } + Dictionary item_meta = item_list->get_item_metadata(i); + if (item_meta["dir"]) { + folders.push_back(item_meta["path"]); + } else { + files.push_back(item_meta["path"]); + } + } + if (folders.size() + files.size() > 0) { + remove_dialog->set_size(Size2(1, 1)); + remove_dialog->show(folders, files); + } +} + void EditorFileDialog::_select_drive(int p_idx) { String d = drives->get_item_text(p_idx); @@ -1181,6 +1311,9 @@ void EditorFileDialog::_bind_methods() { ClassDB::bind_method(D_METHOD("_item_selected"), &EditorFileDialog::_item_selected); ClassDB::bind_method(D_METHOD("_items_clear_selection"), &EditorFileDialog::_items_clear_selection); + ClassDB::bind_method(D_METHOD("_item_list_item_rmb_selected"), &EditorFileDialog::_item_list_item_rmb_selected); + ClassDB::bind_method(D_METHOD("_item_list_rmb_clicked"), &EditorFileDialog::_item_list_rmb_clicked); + ClassDB::bind_method(D_METHOD("_item_menu_id_pressed"), &EditorFileDialog::_item_menu_id_pressed); ClassDB::bind_method(D_METHOD("_item_db_selected"), &EditorFileDialog::_item_dc_selected); ClassDB::bind_method(D_METHOD("_dir_entered"), &EditorFileDialog::_dir_entered); ClassDB::bind_method(D_METHOD("_file_entered"), &EditorFileDialog::_file_entered); @@ -1232,6 +1365,15 @@ void EditorFileDialog::_bind_methods() { ADD_SIGNAL(MethodInfo("files_selected", PropertyInfo(Variant::POOL_STRING_ARRAY, "paths"))); ADD_SIGNAL(MethodInfo("dir_selected", PropertyInfo(Variant::STRING, "dir"))); + ADD_PROPERTY(PropertyInfo(Variant::INT, "access", PROPERTY_HINT_ENUM, "Resources,User data,File system"), "set_access", "get_access"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "display_mode", PROPERTY_HINT_ENUM, "Thumbnails,List"), "set_display_mode", "get_display_mode"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "mode", PROPERTY_HINT_ENUM, "Open one,Open many,Open folder,Open any,Save"), "set_mode", "get_mode"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_dir", PROPERTY_HINT_DIR), "set_current_dir", "get_current_dir"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_file", PROPERTY_HINT_FILE, "*"), "set_current_file", "get_current_file"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_path"), "set_current_path", "get_current_path"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "show_hidden_files"), "set_show_hidden_files", "is_showing_hidden_files"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "disable_overwrite_warning"), "set_disable_overwrite_warning", "is_overwrite_warning_disabled"); + BIND_ENUM_CONSTANT(MODE_OPEN_FILE); BIND_ENUM_CONSTANT(MODE_OPEN_FILES); BIND_ENUM_CONSTANT(MODE_OPEN_DIR); @@ -1317,6 +1459,7 @@ EditorFileDialog::EditorFileDialog() { ED_SHORTCUT("file_dialog/toggle_favorite", TTR("Toggle Favorite"), KEY_MASK_ALT | KEY_F); ED_SHORTCUT("file_dialog/toggle_mode", TTR("Toggle Mode"), KEY_MASK_ALT | KEY_V); ED_SHORTCUT("file_dialog/create_folder", TTR("Create Folder"), KEY_MASK_CMD | KEY_N); + ED_SHORTCUT("file_dialog/delete", TTR("Delete"), KEY_DELETE); ED_SHORTCUT("file_dialog/focus_path", TTR("Focus Path"), KEY_MASK_CMD | KEY_D); ED_SHORTCUT("file_dialog/move_favorite_up", TTR("Move Favorite Up"), KEY_MASK_CMD | KEY_UP); ED_SHORTCUT("file_dialog/move_favorite_down", TTR("Move Favorite Down"), KEY_MASK_CMD | KEY_DOWN); @@ -1423,10 +1566,21 @@ EditorFileDialog::EditorFileDialog() { list_vb->add_child(memnew(Label(TTR("Directories & Files:")))); preview_hb->add_child(list_vb); + // Item (files and folders) list with context menu + item_list = memnew(ItemList); item_list->set_v_size_flags(SIZE_EXPAND_FILL); + item_list->connect("item_rmb_selected", this, "_item_list_item_rmb_selected"); + item_list->connect("rmb_clicked", this, "_item_list_rmb_clicked"); + item_list->set_allow_rmb_select(true); list_vb->add_child(item_list); + item_menu = memnew(PopupMenu); + item_menu->connect("id_pressed", this, "_item_menu_id_pressed"); + add_child(item_menu); + + // Other stuff + preview_vb = memnew(VBoxContainer); preview_hb->add_child(preview_vb); CenterContainer *prev_cc = memnew(CenterContainer); @@ -1465,9 +1619,11 @@ EditorFileDialog::EditorFileDialog() { confirm_save = memnew(ConfirmationDialog); confirm_save->set_as_toplevel(true); add_child(confirm_save); - confirm_save->connect("confirmed", this, "_save_confirm_pressed"); + remove_dialog = memnew(DependencyRemoveDialog); + add_child(remove_dialog); + makedialog = memnew(ConfirmationDialog); makedialog->set_title(TTR("Create Folder")); VBoxContainer *makevb = memnew(VBoxContainer); diff --git a/editor/editor_file_dialog.h b/editor/editor_file_dialog.h index 0599d222f3..f4a9a174e7 100644 --- a/editor/editor_file_dialog.h +++ b/editor/editor_file_dialog.h @@ -39,6 +39,9 @@ #include "scene/gui/split_container.h" #include "scene/gui/texture_rect.h" #include "scene/gui/tool_button.h" + +class DependencyRemoveDialog; + /** @author Juan Linietsky <reduzio@gmail.com> */ @@ -75,6 +78,14 @@ public: static RegisterFunc unregister_func; private: + enum ItemMenu { + ITEM_MENU_COPY_PATH, + ITEM_MENU_DELETE, + ITEM_MENU_REFRESH, + ITEM_MENU_NEW_FOLDER, + ITEM_MENU_SHOW_IN_EXPLORER + }; + ConfirmationDialog *makedialog; LineEdit *makedirname; @@ -83,6 +94,7 @@ private: //Button *action; VBoxContainer *vbox; Mode mode; + bool can_create_dir; LineEdit *dir; ToolButton *dir_prev; @@ -91,6 +103,7 @@ private: OptionButton *drives; ItemList *item_list; + PopupMenu *item_menu; TextureRect *preview; VBoxContainer *preview_vb; HSplitContainer *list_hb; @@ -100,6 +113,7 @@ private: OptionButton *filter; DirAccess *dir_access; ConfirmationDialog *confirm_save; + DependencyRemoveDialog *remove_dialog; ToolButton *mode_thumbnails; ToolButton *mode_list; @@ -146,6 +160,10 @@ private: void _items_clear_selection(); void _item_dc_selected(int p_item); + void _item_list_item_rmb_selected(int p_item, const Vector2 &p_pos); + void _item_list_rmb_clicked(const Vector2 &p_pos); + void _item_menu_id_pressed(int p_option); + void _select_drive(int p_idx); void _dir_entered(String p_dir); void _file_entered(const String &p_file); @@ -156,6 +174,8 @@ private: void _make_dir(); void _make_dir_confirm(); + void _delete_items(); + void _update_drives(); void _go_up(); diff --git a/editor/editor_file_system.cpp b/editor/editor_file_system.cpp index 1cc518ff31..d462cce908 100644 --- a/editor/editor_file_system.cpp +++ b/editor/editor_file_system.cpp @@ -1244,8 +1244,10 @@ void EditorFileSystem::update_file(const String &p_file) { if (!FileAccess::exists(p_file)) { //was removed _delete_internal_files(p_file); - memdelete(fs->files[cpos]); - fs->files.remove(cpos); + if (cpos != -1) { // Might've never been part of the editor file system (*.* files deleted in Open dialog). + memdelete(fs->files[cpos]); + fs->files.remove(cpos); + } call_deferred("emit_signal", "filesystem_changed"); //update later return; } diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp index 5fc27c2e3c..8f427582ae 100644 --- a/editor/editor_help.cpp +++ b/editor/editor_help.cpp @@ -78,50 +78,40 @@ void EditorHelpSearch::_sbox_input(const Ref<InputEvent> &p_ie) { } } -void EditorHelpSearch::_update_search() { +class EditorHelpSearch::IncrementalSearch : public Reference { + String term; + TreeItem *root; - search_options->clear(); - search_options->set_hide_root(true); + EditorHelpSearch *search; + Tree *search_options; - /* - TreeItem *root = search_options->create_item(); - _parse_fs(EditorFileSystem::get_singleton()->get_filesystem()); -*/ + DocData *doc; + Ref<Texture> def_icon; - List<StringName> type_list; - ClassDB::get_class_list(&type_list); + int phase; + Map<String, DocData::ClassDoc>::Element *iterator; - DocData *doc = EditorHelp::get_doc_data(); - String term = search_box->get_text(); - if (term.length() < 2) - return; - - TreeItem *root = search_options->create_item(); - - Ref<Texture> def_icon = get_icon("Node", "EditorIcons"); - //classes first - for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) { + void phase1(Map<String, DocData::ClassDoc>::Element *E) { if (E->key().findn(term) != -1) { TreeItem *item = search_options->create_item(root); item->set_metadata(0, "class_name:" + E->key()); item->set_text(0, E->key() + " (Class)"); - if (has_icon(E->key(), "EditorIcons")) - item->set_icon(0, get_icon(E->key(), "EditorIcons")); + if (search->has_icon(E->key(), "EditorIcons")) + item->set_icon(0, search->get_icon(E->key(), "EditorIcons")); else item->set_icon(0, def_icon); } } - //class methods, etc second - for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) { + void phase2(Map<String, DocData::ClassDoc>::Element *E) { DocData::ClassDoc &c = E->get(); Ref<Texture> cicon; - if (has_icon(E->key(), "EditorIcons")) - cicon = get_icon(E->key(), "EditorIcons"); + if (search->has_icon(E->key(), "EditorIcons")) + cicon = search->get_icon(E->key(), "EditorIcons"); else cicon = def_icon; @@ -180,72 +170,80 @@ void EditorHelpSearch::_update_search() { } } - //same but descriptions + bool slice() { - for (Map<String, DocData::ClassDoc>::Element *E = doc->class_list.front(); E; E = E->next()) { + if (phase > 2) + return true; - DocData::ClassDoc &c = E->get(); + if (iterator) { - Ref<Texture> cicon; - if (has_icon(E->key(), "EditorIcons")) - cicon = get_icon(E->key(), "EditorIcons"); - else - cicon = def_icon; + switch (phase) { + + case 1: { + phase1(iterator); + } break; + case 2: { + phase2(iterator); + } break; + default: { + WARN_PRINT("illegal phase in IncrementalSearch"); + return true; + } + } - if (c.description.findn(term) != -1) { + iterator = iterator->next(); + } else { - TreeItem *item = search_options->create_item(root); - item->set_metadata(0, "class_desc:" + E->key()); - item->set_text(0, E->key() + " (Class Description)"); - item->set_icon(0, cicon); + phase += 1; + iterator = doc->class_list.front(); } - for (int i = 0; i < c.methods.size(); i++) { + return false; + } - if (c.methods[i].description.findn(term) != -1) { +public: + IncrementalSearch(EditorHelpSearch *p_search, Tree *p_search_options, const String &p_term) + : search(p_search), search_options(p_search_options) { - TreeItem *item = search_options->create_item(root); - item->set_metadata(0, "class_method_desc:" + E->key() + ":" + c.methods[i].name); - item->set_text(0, E->key() + "." + c.methods[i].name + " (Method Description)"); - item->set_icon(0, cicon); - } - } - - for (int i = 0; i < c.signals.size(); i++) { + def_icon = search->get_icon("Node", "EditorIcons"); + doc = EditorHelp::get_doc_data(); - if (c.signals[i].description.findn(term) != -1) { + term = p_term; - TreeItem *item = search_options->create_item(root); - item->set_metadata(0, "class_signal:" + E->key() + ":" + c.signals[i].name); - item->set_text(0, E->key() + "." + c.signals[i].name + " (Signal Description)"); - item->set_icon(0, cicon); - } - } + root = search_options->create_item(); + phase = 0; + iterator = 0; + } - for (int i = 0; i < c.constants.size(); i++) { + bool empty() const { - if (c.constants[i].description.findn(term) != -1) { + return root->get_children() == NULL; + } - TreeItem *item = search_options->create_item(root); - item->set_metadata(0, "class_constant:" + E->key() + ":" + c.constants[i].name); - item->set_text(0, E->key() + "." + c.constants[i].name + " (Constant Description)"); - item->set_icon(0, cicon); - } - } + bool work(uint64_t slot = 1000000 / 10) { - for (int i = 0; i < c.properties.size(); i++) { + const uint64_t until = OS::get_singleton()->get_ticks_usec() + slot; - if (c.properties[i].description.findn(term) != -1) { + while (!slice()) { - TreeItem *item = search_options->create_item(root); - item->set_metadata(0, "class_property_desc:" + E->key() + ":" + c.properties[i].name); - item->set_text(0, E->key() + "." + c.properties[i].name + " (Property Description)"); - item->set_icon(0, cicon); - } + if (OS::get_singleton()->get_ticks_usec() > until) + return false; } + + return true; } +}; - get_ok()->set_disabled(root->get_children() == NULL); +void EditorHelpSearch::_update_search() { + search_options->clear(); + search_options->set_hide_root(true); + + String term = search_box->get_text(); + if (term.length() < 2) + return; + + search = Ref<IncrementalSearch>(memnew(IncrementalSearch(this, search_options, term))); + set_process(true); } void EditorHelpSearch::_confirmed() { @@ -281,6 +279,20 @@ void EditorHelpSearch::_notification(int p_what) { //_update_icons search_box->add_icon_override("right_icon", get_icon("Search", "EditorIcons")); + } else if (p_what == NOTIFICATION_PROCESS) { + + if (search.is_valid()) { + + if (search->work()) { + + get_ok()->set_disabled(search->empty()); + search = Ref<IncrementalSearch>(); + set_process(false); + } + } else { + + set_process(false); + } } } diff --git a/editor/editor_help.h b/editor/editor_help.h index 92c0e2f4d1..a224c7f8ee 100644 --- a/editor/editor_help.h +++ b/editor/editor_help.h @@ -53,6 +53,9 @@ class EditorHelpSearch : public ConfirmationDialog { Tree *search_options; String base_type; + class IncrementalSearch; + Ref<IncrementalSearch> search; + void _update_search(); void _sbox_input(const Ref<InputEvent> &p_ie); diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index d6c8d65193..0252358a27 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -269,6 +269,7 @@ void EditorNode::_notification(int p_what) { Engine::get_singleton()->set_editor_hint(true); + get_tree()->get_root()->set_usage(Viewport::USAGE_2D_NO_SAMPLING); //reduce memory usage get_tree()->get_root()->set_disable_3d(true); get_tree()->get_root()->set_as_audio_listener(false); get_tree()->get_root()->set_as_audio_listener_2d(false); @@ -337,7 +338,13 @@ void EditorNode::_notification(int p_what) { //_update_icons for (int i = 0; i < singleton->main_editor_buttons.size(); i++) { - main_editor_buttons[i]->set_icon(gui_base->get_icon(singleton->main_editor_buttons[i]->get_name(), "EditorIcons")); + Ref<Texture> icon = singleton->main_editor_buttons[i]->get_icon(); + + if (icon.is_valid()) { + main_editor_buttons[i]->set_icon(icon); + } else if (singleton->gui_base->has_icon(singleton->main_editor_buttons[i]->get_name(), "EditorIcons")) { + main_editor_buttons[i]->set_icon(gui_base->get_icon(singleton->main_editor_buttons[i]->get_name(), "EditorIcons")); + } } play_button->set_icon(gui_base->get_icon("MainPlay", "EditorIcons")); play_scene_button->set_icon(gui_base->get_icon("PlayScene", "EditorIcons")); @@ -1394,11 +1401,13 @@ void EditorNode::_property_editor_back() { } void EditorNode::_menu_collapseall() { - property_editor->collapse_all_parent_nodes(); + + property_editor->collapse_all_folding(); } void EditorNode::_menu_expandall() { - property_editor->expand_all_parent_nodes(); + + property_editor->expand_all_folding(); } void EditorNode::_save_default_environment() { @@ -2670,7 +2679,14 @@ void EditorNode::add_editor_plugin(EditorPlugin *p_editor) { tb->set_toggle_mode(true); tb->connect("pressed", singleton, "_editor_select", varray(singleton->main_editor_buttons.size())); tb->set_text(p_editor->get_name()); - tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons")); + Ref<Texture> icon = p_editor->get_icon(); + + if (icon.is_valid()) { + tb->set_icon(icon); + } else if (singleton->gui_base->has_icon(p_editor->get_name(), "EditorIcons")) { + tb->set_icon(singleton->gui_base->get_icon(p_editor->get_name(), "EditorIcons")); + } + tb->set_name(p_editor->get_name()); singleton->main_editor_buttons.push_back(tb); singleton->main_editor_button_vb->add_child(tb); @@ -3348,6 +3364,8 @@ void EditorNode::register_editor_types() { ClassDB::register_virtual_class<EditorInterface>(); ClassDB::register_class<EditorExportPlugin>(); ClassDB::register_class<EditorResourceConversionPlugin>(); + ClassDB::register_class<EditorSceneImporter>(); + // FIXME: Is this stuff obsolete, or should it be ported to new APIs? ClassDB::register_class<EditorScenePostImport>(); @@ -5019,6 +5037,7 @@ EditorNode::EditorNode() { scene_root_parent->set_v_size_flags(Control::SIZE_EXPAND_FILL); scene_root = memnew(Viewport); + scene_root->set_usage(Viewport::USAGE_2D); scene_root->set_disable_3d(true); VisualServer::get_singleton()->viewport_set_hide_scenario(scene_root->get_viewport_rid(), true); @@ -5444,7 +5463,7 @@ EditorNode::EditorNode() { property_editor->set_use_doc_hints(true); property_editor->set_hide_script(false); property_editor->set_enable_capitalize_paths(bool(EDITOR_DEF("interface/editor/capitalize_properties", true))); - property_editor->set_use_folding(bool(EDITOR_DEF("interface/editor/expand_all_properties", false)) == false); + property_editor->set_use_folding(!bool(EDITOR_DEF("interface/editor/disable_inspector_folding", false))); property_editor->hide_top_label(); property_editor->register_text_enter(search_box); diff --git a/editor/editor_plugin.cpp b/editor/editor_plugin.cpp index c1fbcde6ac..a39e4d6efb 100644 --- a/editor/editor_plugin.cpp +++ b/editor/editor_plugin.cpp @@ -466,6 +466,14 @@ String EditorPlugin::get_name() const { return String(); } +const Ref<Texture> EditorPlugin::get_icon() const { + + if (get_script_instance() && get_script_instance()->has_method("get_plugin_icon")) { + return get_script_instance()->call("get_plugin_icon"); + } + + return Ref<Texture>(); +} bool EditorPlugin::has_main_screen() const { if (get_script_instance() && get_script_instance()->has_method("has_main_screen")) { @@ -573,6 +581,15 @@ void EditorPlugin::remove_export_plugin(const Ref<EditorExportPlugin> &p_exporte EditorExport::get_singleton()->remove_export_plugin(p_exporter); } +void EditorPlugin::add_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer) { + ResourceImporterScene::get_singleton()->add_importer(p_importer); +} + +void EditorPlugin::remove_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer) { + ResourceImporterScene::get_singleton()->remove_importer(p_importer); + +} + void EditorPlugin::set_window_layout(Ref<ConfigFile> p_layout) { if (get_script_instance() && get_script_instance()->has_method("set_window_layout")) { @@ -628,6 +645,8 @@ void EditorPlugin::_bind_methods() { ClassDB::bind_method(D_METHOD("queue_save_layout"), &EditorPlugin::queue_save_layout); ClassDB::bind_method(D_METHOD("add_import_plugin", "importer"), &EditorPlugin::add_import_plugin); ClassDB::bind_method(D_METHOD("remove_import_plugin", "importer"), &EditorPlugin::remove_import_plugin); + ClassDB::bind_method(D_METHOD("add_scene_import_plugin", "scene_importer"), &EditorPlugin::add_scene_import_plugin); + ClassDB::bind_method(D_METHOD("remove_scene_import_plugin", "scene_importer"), &EditorPlugin::remove_scene_import_plugin); ClassDB::bind_method(D_METHOD("add_export_plugin", "exporter"), &EditorPlugin::add_export_plugin); ClassDB::bind_method(D_METHOD("remove_export_plugin", "exporter"), &EditorPlugin::remove_export_plugin); ClassDB::bind_method(D_METHOD("set_input_event_forwarding_always_enabled"), &EditorPlugin::set_input_event_forwarding_always_enabled); @@ -644,6 +663,7 @@ void EditorPlugin::_bind_methods() { gizmo.return_val.hint_string = "EditorSpatialGizmo"; ClassDB::add_virtual_method(get_class_static(), gizmo); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::STRING, "get_plugin_name")); + ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::OBJECT, "get_plugin_icon")); ClassDB::add_virtual_method(get_class_static(), MethodInfo(Variant::BOOL, "has_main_screen")); ClassDB::add_virtual_method(get_class_static(), MethodInfo("make_visible", PropertyInfo(Variant::BOOL, "visible"))); ClassDB::add_virtual_method(get_class_static(), MethodInfo("edit", PropertyInfo(Variant::OBJECT, "object"))); diff --git a/editor/editor_plugin.h b/editor/editor_plugin.h index 11f4378667..89a6d3d250 100644 --- a/editor/editor_plugin.h +++ b/editor/editor_plugin.h @@ -35,6 +35,7 @@ #include "scene/gui/tool_button.h" #include "scene/main/node.h" #include "scene/resources/texture.h" +#include "editor/import/resource_importer_scene.h" #include "undo_redo.h" /** @@ -165,6 +166,7 @@ public: virtual void forward_force_draw_over_viewport(Control *p_overlay); virtual bool forward_spatial_gui_input(Camera *p_camera, const Ref<InputEvent> &p_event); virtual String get_name() const; + virtual const Ref<Texture> get_icon() const; virtual bool has_main_screen() const; virtual void make_visible(bool p_visible); virtual void selected_notify() {} //notify that it was raised by the user, not the editor @@ -199,6 +201,9 @@ public: void add_export_plugin(const Ref<EditorExportPlugin> &p_exporter); void remove_export_plugin(const Ref<EditorExportPlugin> &p_exporter); + void add_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer); + void remove_scene_import_plugin(const Ref<EditorSceneImporter> &p_importer); + EditorPlugin(); virtual ~EditorPlugin(); }; diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp index 2f73e459ed..04e09abcea 100644 --- a/editor/editor_settings.cpp +++ b/editor/editor_settings.cpp @@ -543,6 +543,7 @@ void EditorSettings::_load_default_text_editor_theme() { _initial_set("text_editor/highlighting/line_length_guideline_color", Color(0.3, 0.5, 0.8, 0.1)); _initial_set("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4)); _initial_set("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2)); + _initial_set("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8)); _initial_set("text_editor/highlighting/word_highlighted_color", Color(0.8, 0.9, 0.9, 0.15)); _initial_set("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1)); _initial_set("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1)); @@ -577,6 +578,7 @@ bool EditorSettings::_save_text_editor_theme(String p_file) { cf->set_value(theme_section, "line_length_guideline_color", ((Color)get("text_editor/highlighting/line_length_guideline_color")).to_html()); cf->set_value(theme_section, "mark_color", ((Color)get("text_editor/highlighting/mark_color")).to_html()); cf->set_value(theme_section, "breakpoint_color", ((Color)get("text_editor/highlighting/breakpoint_color")).to_html()); + cf->set_value(theme_section, "code_folding_color", ((Color)get("text_editor/highlighting/code_folding_color")).to_html()); cf->set_value(theme_section, "word_highlighted_color", ((Color)get("text_editor/highlighting/word_highlighted_color")).to_html()); cf->set_value(theme_section, "search_result_color", ((Color)get("text_editor/highlighting/search_result_color")).to_html()); cf->set_value(theme_section, "search_result_border_color", ((Color)get("text_editor/highlighting/search_result_border_color")).to_html()); diff --git a/editor/editor_themes.cpp b/editor/editor_themes.cpp index ae29b7420e..4661fcf668 100644 --- a/editor/editor_themes.cpp +++ b/editor/editor_themes.cpp @@ -793,6 +793,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { // TextEdit theme->set_stylebox("normal", "TextEdit", style_widget); theme->set_stylebox("focus", "TextEdit", style_widget_hover); + theme->set_stylebox("read_only", "TextEdit", style_widget_disabled); theme->set_constant("side_margin", "TabContainer", 0); theme->set_icon("tab", "TextEdit", theme->get_icon("GuiTab", "EditorIcons")); theme->set_color("font_color", "TextEdit", font_color); @@ -1038,6 +1039,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { const Color member_variable_color = mono_color; const Color mark_color = Color(error_color.r, error_color.g, error_color.b, 0.3); const Color breakpoint_color = error_color; + const Color code_folding_color = alpha4; const Color search_result_color = alpha1; const Color search_result_border_color = alpha4; @@ -1068,6 +1070,7 @@ Ref<Theme> create_editor_theme(const Ref<Theme> p_theme) { theme->set_color("text_editor/theme/member_variable_color", "Editor", member_variable_color); theme->set_color("text_editor/theme/mark_color", "Editor", mark_color); theme->set_color("text_editor/theme/breakpoint_color", "Editor", breakpoint_color); + theme->set_color("text_editor/theme/code_folding_color", "Editor", code_folding_color); theme->set_color("text_editor/theme/search_result_color", "Editor", search_result_color); theme->set_color("text_editor/theme/search_result_border_color", "Editor", search_result_border_color); diff --git a/editor/filesystem_dock.cpp b/editor/filesystem_dock.cpp index 9fe3e2ad25..ca6571fdda 100644 --- a/editor/filesystem_dock.cpp +++ b/editor/filesystem_dock.cpp @@ -909,10 +909,11 @@ void FileSystemDock::_file_option(int p_option) { OS::get_singleton()->shell_open(String("file://") + dir); } break; case FILE_OPEN: { - int idx = files->get_current(); - if (idx < 0 || idx >= files->get_item_count()) - break; - _select_file(idx); + for (int i = 0; i < files->get_item_count(); i++) { + if (files->is_selected(i)) { + _select_file(i); + } + } } break; case FILE_INSTANCE: { @@ -1429,14 +1430,17 @@ void FileSystemDock::_files_list_rmb_select(int p_item, const Vector2 &p_pos) { file_options->clear(); file_options->set_size(Size2(1, 1)); - if (all_files && filenames.size() > 0) { - file_options->add_item(TTR("Open"), FILE_OPEN); - if (all_files_scenes) { + if (all_files) { + + if (all_files_scenes && filenames.size() >= 1) { + file_options->add_item(TTR("Open Scene(s)"), FILE_OPEN); file_options->add_item(TTR("Instance"), FILE_INSTANCE); + file_options->add_separator(); } - file_options->add_separator(); - if (filenames.size() == 1) { + if (!all_files_scenes && filenames.size() == 1) { + file_options->add_item(TTR("Open"), FILE_OPEN); + file_options->add_separator(); file_options->add_item(TTR("Edit Dependencies.."), FILE_DEPENDENCIES); file_options->add_item(TTR("View Owners.."), FILE_OWNERS); file_options->add_separator(); diff --git a/editor/filesystem_dock.h b/editor/filesystem_dock.h index f1fd342052..b004b1974d 100644 --- a/editor/filesystem_dock.h +++ b/editor/filesystem_dock.h @@ -128,10 +128,12 @@ private: String path; bool is_file; - FileOrFolder() - : path(""), is_file(false) {} - FileOrFolder(const String &p_path, bool p_is_file) - : path(p_path), is_file(p_is_file) {} + FileOrFolder() : + path(""), + is_file(false) {} + FileOrFolder(const String &p_path, bool p_is_file) : + path(p_path), + is_file(p_is_file) {} }; FileOrFolder to_rename; Vector<FileOrFolder> to_move; diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp index 3c73411dee..c38391c71b 100644 --- a/editor/import/editor_import_collada.cpp +++ b/editor/import/editor_import_collada.cpp @@ -1913,8 +1913,6 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones /*************************************** SCENE ***********************************/ /*********************************************************************************/ -#define DEBUG_ANIMATION - uint32_t EditorSceneImporterCollada::get_import_flags() const { return IMPORT_SCENE | IMPORT_ANIMATION; @@ -1981,7 +1979,7 @@ Node *EditorSceneImporterCollada::import_scene(const String &p_path, uint32_t p_ return state.scene; } -Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path, uint32_t p_flags) { +Ref<Animation> EditorSceneImporterCollada::import_animation(const String &p_path, uint32_t p_flags,int p_bake_fps) { ColladaImport state; diff --git a/editor/import/editor_import_collada.h b/editor/import/editor_import_collada.h index 865a72739f..986b5b766f 100644 --- a/editor/import/editor_import_collada.h +++ b/editor/import/editor_import_collada.h @@ -40,7 +40,7 @@ public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = NULL, Error *r_err = NULL); - virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags); + virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags,int p_bake_fps); EditorSceneImporterCollada(); }; diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp index f704d97373..e801f3e7c3 100644 --- a/editor/import/editor_scene_importer_gltf.cpp +++ b/editor/import/editor_scene_importer_gltf.cpp @@ -2106,7 +2106,7 @@ Node *EditorSceneImporterGLTF::import_scene(const String &p_path, uint32_t p_fla return scene; } -Ref<Animation> EditorSceneImporterGLTF::import_animation(const String &p_path, uint32_t p_flags) { +Ref<Animation> EditorSceneImporterGLTF::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { return Ref<Animation>(); } diff --git a/editor/import/editor_scene_importer_gltf.h b/editor/import/editor_scene_importer_gltf.h index d9479fae6f..0c8000427e 100644 --- a/editor/import/editor_scene_importer_gltf.h +++ b/editor/import/editor_scene_importer_gltf.h @@ -296,7 +296,7 @@ public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps = NULL, Error *r_err = NULL); - virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags); + virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags,int p_bake_fps); EditorSceneImporterGLTF(); }; diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 14bda9bb4e..0297a6c24e 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -426,7 +426,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in return scene; } -Ref<Animation> EditorOBJImporter::import_animation(const String &p_path, uint32_t p_flags) { +Ref<Animation> EditorOBJImporter::import_animation(const String &p_path, uint32_t p_flags, int p_bake_fps) { return Ref<Animation>(); } diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h index 7eeceeabbe..09dc8ac8a1 100644 --- a/editor/import/resource_importer_obj.h +++ b/editor/import/resource_importer_obj.h @@ -40,7 +40,7 @@ public: virtual uint32_t get_import_flags() const; virtual void get_extensions(List<String> *r_extensions) const; virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); - virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags); + virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags,int p_bake_fps); EditorOBJImporter(); }; diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp index 95445693b4..4ef8ec48a0 100644 --- a/editor/import/resource_importer_scene.cpp +++ b/editor/import/resource_importer_scene.cpp @@ -47,6 +47,94 @@ #include "scene/resources/ray_shape.h" #include "scene/resources/sphere_shape.h" + + +uint32_t EditorSceneImporter::get_import_flags() const { + + if (get_script_instance()) { + return get_script_instance()->call("_get_import_flags"); + } + + ERR_FAIL_V(0); +} +void EditorSceneImporter::get_extensions(List<String> *r_extensions) const { + + if (get_script_instance()) { + Array arr= get_script_instance()->call("_get_extensions"); + for(int i=0;i<arr.size();i++) { + r_extensions->push_back(arr[i]); + } + return; + } + + ERR_FAIL(); + +} +Node *EditorSceneImporter::import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err) { + + if (get_script_instance()) { + return get_script_instance()->call("_import_scene",p_path,p_flags,p_bake_fps); + } + + ERR_FAIL_V(NULL); + +} + +Ref<Animation> EditorSceneImporter::import_animation(const String &p_path, uint32_t p_flags,int p_bake_fps) { + + if (get_script_instance()) { + return get_script_instance()->call("_import_animation",p_path,p_flags); + } + + ERR_FAIL_V(NULL); + +} + +//for documenters, these functions are useful when an importer calls an external conversion helper (like, fbx2gltf), +//and you want to load the resulting file + +Node* EditorSceneImporter::import_scene_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) { + + return ResourceImporterScene::get_singleton()->import_scene_from_other_importer(this,p_path,p_flags,p_bake_fps); + +} + +Ref<Animation> EditorSceneImporter::import_animation_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps) { + + return ResourceImporterScene::get_singleton()->import_animation_from_other_importer(this,p_path,p_flags,p_bake_fps); + +} + +void EditorSceneImporter::_bind_methods() { + + ClassDB::bind_method(D_METHOD("import_scene_from_other_importer","path","flags","bake_fps"),&EditorSceneImporter::import_scene_from_other_importer); + ClassDB::bind_method(D_METHOD("import_animation_from_other_importer","path","flags","bake_fps"),&EditorSceneImporter::import_animation_from_other_importer); + + BIND_VMETHOD(MethodInfo(Variant::INT, "_get_import_flags")); + BIND_VMETHOD(MethodInfo(Variant::ARRAY, "_get_extensions")); + + MethodInfo mi = MethodInfo(Variant::OBJECT, "_import_scene",PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "flags"), PropertyInfo(Variant::INT, "bake_fps")); + mi.return_val.class_name="Node"; + BIND_VMETHOD(mi); + mi = MethodInfo(Variant::OBJECT, "_import_animation",PropertyInfo(Variant::STRING, "path"), PropertyInfo(Variant::INT, "flags"), PropertyInfo(Variant::INT, "bake_fps")); + mi.return_val.class_name="Animation"; + BIND_VMETHOD(mi); + + BIND_CONSTANT( IMPORT_SCENE ); + BIND_CONSTANT( IMPORT_ANIMATION ); + BIND_CONSTANT( IMPORT_ANIMATION_DETECT_LOOP ); + BIND_CONSTANT( IMPORT_ANIMATION_OPTIMIZE ); + BIND_CONSTANT( IMPORT_ANIMATION_FORCE_ALL_TRACKS_IN_ALL_CLIPS ); + BIND_CONSTANT( IMPORT_ANIMATION_KEEP_VALUE_TRACKS ); + BIND_CONSTANT( IMPORT_GENERATE_TANGENT_ARRAYS ); + BIND_CONSTANT( IMPORT_FAIL_ON_MISSING_DEPENDENCIES ); + BIND_CONSTANT( IMPORT_MATERIALS_IN_INSTANCES ); + BIND_CONSTANT( IMPORT_USE_COMPRESSION ); + +} + + +///////////////////////////////// void EditorScenePostImport::_bind_methods() { BIND_VMETHOD(MethodInfo("post_import", PropertyInfo(Variant::OBJECT, "scene"))); @@ -95,6 +183,9 @@ bool ResourceImporterScene::get_option_visibility(const String &p_option, const if (p_option != "animation/import" && !bool(p_options["animation/import"])) return false; + if (p_option == "animation/keep_custom_tracks" && int(p_options["animation/storage"]) == 0) + return false; + if (p_option.begins_with("animation/optimizer/") && p_option != "animation/optimizer/enabled" && !bool(p_options["animation/optimizer/enabled"])) return false; @@ -870,7 +961,7 @@ static String _make_extname(const String &p_str) { return ext_name; } -void ResourceImporterScene::_make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes) { +void ResourceImporterScene::_make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_keep_animations, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes) { List<PropertyInfo> pi; @@ -889,7 +980,26 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String if (!p_animations.has(anim)) { + //mark what comes from the file first, this helps eventually keep user data + for (int i = 0; i < anim->get_track_count(); i++) { + anim->track_set_imported(i, true); + } + String ext_name = p_base_path.plus_file(_make_extname(E->get()) + ".anim"); + + if (FileAccess::exists(ext_name) && p_keep_animations) { + //try to keep custom animation tracks + Ref<Animation> old_anim = ResourceLoader::load(ext_name, "Animation", true); + if (old_anim.is_valid()) { + //meergeee + for (int i = 0; i < old_anim->get_track_count(); i++) { + if (!old_anim->track_is_imported(i)) { + old_anim->copy_track(i, anim); + } + } + } + } + ResourceSaver::save(ext_name, anim, ResourceSaver::FLAG_CHANGE_PATH); p_animations[anim] = anim; } @@ -997,7 +1107,7 @@ void ResourceImporterScene::_make_external_resources(Node *p_node, const String for (int i = 0; i < p_node->get_child_count(); i++) { - _make_external_resources(p_node->get_child(i), p_base_path, p_make_animations, p_make_materials, p_keep_materials, p_make_meshes, p_animations, p_materials, p_meshes); + _make_external_resources(p_node->get_child(i), p_base_path, p_make_animations, p_keep_animations, p_make_materials, p_keep_materials, p_make_meshes, p_animations, p_materials, p_meshes); } } @@ -1036,6 +1146,7 @@ void ResourceImporterScene::get_import_options(List<ImportOption> *r_options, in 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"), animations_out ? true : false)); + r_options->push_back(ImportOption(PropertyInfo(Variant::BOOL, "animation/keep_custom_tracks"), animations_out ? true : false)); 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)); r_options->push_back(ImportOption(PropertyInfo(Variant::REAL, "animation/optimizer/max_angular_error"), 0.01)); @@ -1060,6 +1171,70 @@ void ResourceImporterScene::_replace_owner(Node *p_node, Node *p_scene, Node *p_ Node *n = p_node->get_child(i); _replace_owner(n, p_scene, p_new_owner); } + +} + +Node* ResourceImporterScene::import_scene_from_other_importer(EditorSceneImporter *p_exception,const String &p_path, uint32_t p_flags, int p_bake_fps) { + + Ref<EditorSceneImporter> importer; + String ext = p_path.get_extension().to_lower(); + + for (Set<Ref<EditorSceneImporter> >::Element *E = importers.front(); E; E = E->next()) { + + if (E->get().ptr()==p_exception) + continue; + List<String> extensions; + E->get()->get_extensions(&extensions); + + for (List<String>::Element *F = extensions.front(); F; F = F->next()) { + + if (F->get().to_lower() == ext) { + + importer = E->get(); + break; + } + } + + if (importer.is_valid()) + break; + } + + ERR_FAIL_COND_V(!importer.is_valid(),NULL); + + List<String> missing; + Error err; + return importer->import_scene(p_path,p_flags,p_bake_fps,&missing,&err); +} + +Ref<Animation> ResourceImporterScene::import_animation_from_other_importer(EditorSceneImporter *p_exception,const String &p_path, uint32_t p_flags, int p_bake_fps) { + + + Ref<EditorSceneImporter> importer; + String ext = p_path.get_extension().to_lower(); + + for (Set<Ref<EditorSceneImporter> >::Element *E = importers.front(); E; E = E->next()) { + + if (E->get().ptr()==p_exception) + continue; + List<String> extensions; + E->get()->get_extensions(&extensions); + + for (List<String>::Element *F = extensions.front(); F; F = F->next()) { + + if (F->get().to_lower() == ext) { + + importer = E->get(); + break; + } + } + + if (importer.is_valid()) + break; + } + + ERR_FAIL_COND_V(!importer.is_valid(),NULL); + + return importer->import_animation(p_path,p_flags,p_bake_fps); } Error ResourceImporterScene::import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files) { @@ -1176,6 +1351,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p } bool external_animations = int(p_options["animation/storage"]) == 1; + bool keep_custom_tracks = p_options["animation/keep_custom_tracks"]; bool external_materials = p_options["materials/storage"]; bool external_meshes = p_options["meshes/storage"]; bool external_scenes = int(p_options["nodes/storage"]) == 1; @@ -1202,7 +1378,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p bool keep_materials = bool(p_options["materials/keep_on_reimport"]); - _make_external_resources(scene, base_path, external_animations, external_materials, keep_materials, external_meshes, anim_map, mat_map, mesh_map); + _make_external_resources(scene, base_path, external_animations, keep_custom_tracks, external_materials, keep_materials, external_meshes, anim_map, mat_map, mesh_map); } progress.step(TTR("Running Custom Script.."), 2); diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h index 92777fafb6..fc6ce05fa4 100644 --- a/editor/import/resource_importer_scene.h +++ b/editor/import/resource_importer_scene.h @@ -40,7 +40,13 @@ class Material; class EditorSceneImporter : public Reference { GDCLASS(EditorSceneImporter, Reference); +protected: + + static void _bind_methods(); + + Node* import_scene_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps); + Ref<Animation> import_animation_from_other_importer(const String &p_path, uint32_t p_flags, int p_bake_fps); public: enum ImportFlags { IMPORT_SCENE = 1, @@ -56,10 +62,11 @@ public: }; - virtual uint32_t get_import_flags() const = 0; - virtual void get_extensions(List<String> *r_extensions) const = 0; - virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL) = 0; - virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags) = 0; + + virtual uint32_t get_import_flags() const; + virtual void get_extensions(List<String> *r_extensions) const; + virtual Node *import_scene(const String &p_path, uint32_t p_flags, int p_bake_fps, List<String> *r_missing_deps, Error *r_err = NULL); + virtual Ref<Animation> import_animation(const String &p_path, uint32_t p_flags,int p_bake_fps); EditorSceneImporter() {} }; @@ -114,6 +121,7 @@ public: const Set<Ref<EditorSceneImporter> > &get_importers() const { return importers; } void add_importer(Ref<EditorSceneImporter> p_importer) { importers.insert(p_importer); } + void remove_importer(Ref<EditorSceneImporter> p_importer) { importers.erase(p_importer); } virtual String get_importer_name() const; virtual String get_visible_name() const; @@ -128,7 +136,7 @@ public: virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const; virtual int get_import_order() const { return 100; } //after everything - void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes); + void _make_external_resources(Node *p_node, const String &p_base_path, bool p_make_animations, bool p_keep_animations, bool p_make_materials, bool p_keep_materials, bool p_make_meshes, Map<Ref<Animation>, Ref<Animation> > &p_animations, Map<Ref<Material>, Ref<Material> > &p_materials, Map<Ref<ArrayMesh>, Ref<ArrayMesh> > &p_meshes); Node *_fix_node(Node *p_node, Node *p_root, Map<Ref<ArrayMesh>, Ref<Shape> > &collision_map, LightBakeMode p_light_bake_mode); @@ -139,6 +147,9 @@ public: virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL); + Node* import_scene_from_other_importer(EditorSceneImporter *p_exception,const String &p_path, uint32_t p_flags, int p_bake_fps); + Ref<Animation> import_animation_from_other_importer(EditorSceneImporter *p_exception,const String &p_path, uint32_t p_flags, int p_bake_fps); + ResourceImporterScene(); }; diff --git a/editor/plugins/abstract_polygon_2d_editor.cpp b/editor/plugins/abstract_polygon_2d_editor.cpp index cabdfa761d..ff72a5a25e 100644 --- a/editor/plugins/abstract_polygon_2d_editor.cpp +++ b/editor/plugins/abstract_polygon_2d_editor.cpp @@ -32,18 +32,21 @@ #include "canvas_item_editor_plugin.h" #include "core/os/keyboard.h" -AbstractPolygon2DEditor::Vertex::Vertex() - : polygon(-1), vertex(-1) { +AbstractPolygon2DEditor::Vertex::Vertex() : + polygon(-1), + vertex(-1) { // invalid vertex } -AbstractPolygon2DEditor::Vertex::Vertex(int p_vertex) - : polygon(-1), vertex(p_vertex) { +AbstractPolygon2DEditor::Vertex::Vertex(int p_vertex) : + polygon(-1), + vertex(p_vertex) { // vertex p_vertex of current wip polygon } -AbstractPolygon2DEditor::Vertex::Vertex(int p_polygon, int p_vertex) - : polygon(p_polygon), vertex(p_vertex) { +AbstractPolygon2DEditor::Vertex::Vertex(int p_polygon, int p_vertex) : + polygon(p_polygon), + vertex(p_vertex) { // vertex p_vertex of polygon p_polygon } @@ -66,12 +69,14 @@ AbstractPolygon2DEditor::PosVertex::PosVertex() { // invalid vertex } -AbstractPolygon2DEditor::PosVertex::PosVertex(const Vertex &p_vertex, const Vector2 &p_pos) - : Vertex(p_vertex.polygon, p_vertex.vertex), pos(p_pos) { +AbstractPolygon2DEditor::PosVertex::PosVertex(const Vertex &p_vertex, const Vector2 &p_pos) : + Vertex(p_vertex.polygon, p_vertex.vertex), + pos(p_pos) { } -AbstractPolygon2DEditor::PosVertex::PosVertex(int p_polygon, int p_vertex, const Vector2 &p_pos) - : Vertex(p_polygon, p_vertex), pos(p_pos) { +AbstractPolygon2DEditor::PosVertex::PosVertex(int p_polygon, int p_vertex, const Vector2 &p_pos) : + Vertex(p_polygon, p_vertex), + pos(p_pos) { } bool AbstractPolygon2DEditor::_is_empty() const { @@ -167,7 +172,7 @@ void AbstractPolygon2DEditor::_menu_option(int p_option) { } break; case MODE_EDIT: { - wip_active = false; + _wip_close(); mode = MODE_EDIT; button_create->set_pressed(false); button_edit->set_pressed(true); @@ -175,7 +180,7 @@ void AbstractPolygon2DEditor::_menu_option(int p_option) { } break; case MODE_DELETE: { - wip_active = false; + _wip_close(); mode = MODE_DELETE; button_create->set_pressed(false); button_edit->set_pressed(false); @@ -224,6 +229,9 @@ void AbstractPolygon2DEditor::_wip_changed() { } void AbstractPolygon2DEditor::_wip_close() { + if (!wip_active) + return; + if (_is_line()) { _set_polygon(0, wip); diff --git a/editor/plugins/canvas_item_editor_plugin.cpp b/editor/plugins/canvas_item_editor_plugin.cpp index ddcdb5a321..8eee9c7e7c 100644 --- a/editor/plugins/canvas_item_editor_plugin.cpp +++ b/editor/plugins/canvas_item_editor_plugin.cpp @@ -69,8 +69,8 @@ class SnapDialog : public ConfirmationDialog { SpinBox *rotation_step; public: - SnapDialog() - : ConfirmationDialog() { + SnapDialog() : + ConfirmationDialog() { const int SPIN_BOX_GRID_RANGE = 256; const int SPIN_BOX_ROTATION_RANGE = 360; Label *label; diff --git a/editor/plugins/collision_polygon_2d_editor_plugin.cpp b/editor/plugins/collision_polygon_2d_editor_plugin.cpp index 00e6d617a1..6ac80caf94 100644 --- a/editor/plugins/collision_polygon_2d_editor_plugin.cpp +++ b/editor/plugins/collision_polygon_2d_editor_plugin.cpp @@ -39,10 +39,10 @@ void CollisionPolygon2DEditor::_set_node(Node *p_polygon) { node = Object::cast_to<CollisionPolygon2D>(p_polygon); } -CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) - : AbstractPolygon2DEditor(p_editor) { +CollisionPolygon2DEditor::CollisionPolygon2DEditor(EditorNode *p_editor) : + AbstractPolygon2DEditor(p_editor) { } -CollisionPolygon2DEditorPlugin::CollisionPolygon2DEditorPlugin(EditorNode *p_node) - : AbstractPolygon2DEditorPlugin(p_node, memnew(CollisionPolygon2DEditor(p_node)), "CollisionPolygon2D") { +CollisionPolygon2DEditorPlugin::CollisionPolygon2DEditorPlugin(EditorNode *p_node) : + AbstractPolygon2DEditorPlugin(p_node, memnew(CollisionPolygon2DEditor(p_node)), "CollisionPolygon2D") { } diff --git a/editor/plugins/curve_editor_plugin.cpp b/editor/plugins/curve_editor_plugin.cpp index 2754aeed06..f77016c1d6 100644 --- a/editor/plugins/curve_editor_plugin.cpp +++ b/editor/plugins/curve_editor_plugin.cpp @@ -586,8 +586,10 @@ struct CanvasItemPlotCurve { Color color1; Color color2; - CanvasItemPlotCurve(CanvasItem &p_ci, Color p_color1, Color p_color2) - : ci(p_ci), color1(p_color1), color2(p_color2) {} + CanvasItemPlotCurve(CanvasItem &p_ci, Color p_color1, Color p_color2) : + ci(p_ci), + color1(p_color1), + color2(p_color2) {} void operator()(Vector2 pos0, Vector2 pos1, bool in_definition) { ci.draw_line(pos0, pos1, in_definition ? color1 : color2); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index ed04c90cc5..558f44769d 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -235,29 +235,34 @@ Ref<Texture> EditorMaterialPreviewPlugin::generate(const RES &p_from) { Ref<Material> material = p_from; ERR_FAIL_COND_V(material.is_null(), Ref<Texture>()); - VS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid()); + if (material->get_shader_mode() == Shader::MODE_SPATIAL) { - VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture + VS::get_singleton()->mesh_surface_set_material(sphere, 0, material->get_rid()); - preview_done = false; - VS::get_singleton()->request_frame_drawn_callback(this, "_preview_done", Variant()); + VS::get_singleton()->viewport_set_update_mode(viewport, VS::VIEWPORT_UPDATE_ONCE); //once used for capture - while (!preview_done) { - OS::get_singleton()->delay_usec(10); - } + preview_done = false; + VS::get_singleton()->request_frame_drawn_callback(this, "_preview_done", Variant()); - Ref<Image> img = VS::get_singleton()->VS::get_singleton()->texture_get_data(viewport_texture); - VS::get_singleton()->mesh_surface_set_material(sphere, 0, RID()); + while (!preview_done) { + OS::get_singleton()->delay_usec(10); + } - ERR_FAIL_COND_V(!img.is_valid(), Ref<ImageTexture>()); + Ref<Image> img = VS::get_singleton()->VS::get_singleton()->texture_get_data(viewport_texture); + VS::get_singleton()->mesh_surface_set_material(sphere, 0, RID()); - int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); - thumbnail_size *= EDSCALE; - img->convert(Image::FORMAT_RGBA8); - img->resize(thumbnail_size, thumbnail_size); - Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); - ptex->create_from_image(img, 0); - return ptex; + ERR_FAIL_COND_V(!img.is_valid(), Ref<ImageTexture>()); + + int thumbnail_size = EditorSettings::get_singleton()->get("filesystem/file_dialog/thumbnail_size"); + thumbnail_size *= EDSCALE; + img->convert(Image::FORMAT_RGBA8); + img->resize(thumbnail_size, thumbnail_size); + Ref<ImageTexture> ptex = Ref<ImageTexture>(memnew(ImageTexture)); + ptex->create_from_image(img, 0); + return ptex; + } + + return Ref<Texture>(); } EditorMaterialPreviewPlugin::EditorMaterialPreviewPlugin() { diff --git a/editor/plugins/line_2d_editor_plugin.cpp b/editor/plugins/line_2d_editor_plugin.cpp index 51fa488b43..04d8519b2f 100644 --- a/editor/plugins/line_2d_editor_plugin.cpp +++ b/editor/plugins/line_2d_editor_plugin.cpp @@ -61,10 +61,10 @@ void Line2DEditor::_action_set_polygon(int p_idx, const Variant &p_previous, con undo_redo->add_undo_method(node, "set_points", p_previous); } -Line2DEditor::Line2DEditor(EditorNode *p_editor) - : AbstractPolygon2DEditor(p_editor) { +Line2DEditor::Line2DEditor(EditorNode *p_editor) : + AbstractPolygon2DEditor(p_editor) { } -Line2DEditorPlugin::Line2DEditorPlugin(EditorNode *p_node) - : AbstractPolygon2DEditorPlugin(p_node, memnew(Line2DEditor(p_node)), "Line2D") { +Line2DEditorPlugin::Line2DEditorPlugin(EditorNode *p_node) : + AbstractPolygon2DEditorPlugin(p_node, memnew(Line2DEditor(p_node)), "Line2D") { } diff --git a/editor/plugins/navigation_polygon_editor_plugin.cpp b/editor/plugins/navigation_polygon_editor_plugin.cpp index 6560a8dac7..36c608310b 100644 --- a/editor/plugins/navigation_polygon_editor_plugin.cpp +++ b/editor/plugins/navigation_polygon_editor_plugin.cpp @@ -120,10 +120,10 @@ void NavigationPolygonEditor::_create_resource() { _menu_option(MODE_CREATE); } -NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) - : AbstractPolygon2DEditor(p_editor) { +NavigationPolygonEditor::NavigationPolygonEditor(EditorNode *p_editor) : + AbstractPolygon2DEditor(p_editor) { } -NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin(EditorNode *p_node) - : AbstractPolygon2DEditorPlugin(p_node, memnew(NavigationPolygonEditor(p_node)), "NavigationPolygonInstance") { +NavigationPolygonEditorPlugin::NavigationPolygonEditorPlugin(EditorNode *p_node) : + AbstractPolygon2DEditorPlugin(p_node, memnew(NavigationPolygonEditor(p_node)), "NavigationPolygonInstance") { } diff --git a/editor/plugins/polygon_2d_editor_plugin.cpp b/editor/plugins/polygon_2d_editor_plugin.cpp index ebb5f57e99..25e734187d 100644 --- a/editor/plugins/polygon_2d_editor_plugin.cpp +++ b/editor/plugins/polygon_2d_editor_plugin.cpp @@ -459,8 +459,8 @@ Vector2 Polygon2DEditor::snap_point(Vector2 p_target) const { return p_target; } -Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) - : AbstractPolygon2DEditor(p_editor) { +Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) : + AbstractPolygon2DEditor(p_editor) { snap_step = Vector2(10, 10); use_snap = false; @@ -609,6 +609,6 @@ Polygon2DEditor::Polygon2DEditor(EditorNode *p_editor) uv_edit_draw->set_clip_contents(true); } -Polygon2DEditorPlugin::Polygon2DEditorPlugin(EditorNode *p_node) - : AbstractPolygon2DEditorPlugin(p_node, memnew(Polygon2DEditor(p_node)), "Polygon2D") { +Polygon2DEditorPlugin::Polygon2DEditorPlugin(EditorNode *p_node) : + AbstractPolygon2DEditorPlugin(p_node, memnew(Polygon2DEditor(p_node)), "Polygon2D") { } diff --git a/editor/plugins/script_editor_plugin.cpp b/editor/plugins/script_editor_plugin.cpp index 3c2d52c128..c02b3458e5 100644 --- a/editor/plugins/script_editor_plugin.cpp +++ b/editor/plugins/script_editor_plugin.cpp @@ -586,6 +586,12 @@ void ScriptEditor::_close_docs_tab() { } } +void ScriptEditor::_copy_script_path() { + ScriptEditorBase *se = Object::cast_to<ScriptEditorBase>(tab_container->get_child(tab_container->get_current_tab())); + Ref<Script> script = se->get_edited_script(); + OS::get_singleton()->set_clipboard(script->get_path()); +} + void ScriptEditor::_close_other_tabs() { int child_count = tab_container->get_child_count(); @@ -1026,6 +1032,9 @@ void ScriptEditor::_menu_option(int p_option) { _close_current_tab(); } } break; + case FILE_COPY_PATH: { + _copy_script_path(); + } break; case CLOSE_DOCS: { _close_docs_tab(); } break; @@ -2175,6 +2184,7 @@ void ScriptEditor::_make_script_list_context_menu() { context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_all"), CLOSE_ALL); context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/close_other_tabs"), CLOSE_OTHER_TABS); context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/copy_path"), FILE_COPY_PATH); context_menu->add_shortcut(ED_GET_SHORTCUT("script_editor/reload_script_soft"), FILE_TOOL_RELOAD_SOFT); Ref<Script> scr = se->get_edited_script(); @@ -2507,6 +2517,7 @@ void ScriptEditor::_bind_methods() { ClassDB::bind_method("_help_search", &ScriptEditor::_help_search); ClassDB::bind_method("_help_index", &ScriptEditor::_help_index); ClassDB::bind_method("_save_history", &ScriptEditor::_save_history); + ClassDB::bind_method("_copy_script_path", &ScriptEditor::_copy_script_path); ClassDB::bind_method("_breaked", &ScriptEditor::_breaked); ClassDB::bind_method("_show_debugger", &ScriptEditor::_show_debugger); @@ -2626,6 +2637,7 @@ ScriptEditor::ScriptEditor(EditorNode *p_editor) { file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/save_all", TTR("Save All"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_MASK_ALT | KEY_S), FILE_SAVE_ALL); file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/reload_script_soft", TTR("Soft Reload Script"), KEY_MASK_CMD | KEY_MASK_SHIFT | KEY_R), FILE_TOOL_RELOAD_SOFT); + file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/copy_path", TTR("Copy Script Path")), FILE_COPY_PATH); file_menu->get_popup()->add_separator(); file_menu->get_popup()->add_shortcut(ED_SHORTCUT("script_editor/history_previous", TTR("History Prev"), KEY_MASK_ALT | KEY_LEFT), WINDOW_PREV); diff --git a/editor/plugins/script_editor_plugin.h b/editor/plugins/script_editor_plugin.h index 77ca4bc9d9..ffd42d18ca 100644 --- a/editor/plugins/script_editor_plugin.h +++ b/editor/plugins/script_editor_plugin.h @@ -137,6 +137,7 @@ class ScriptEditor : public PanelContainer { CLOSE_ALL, CLOSE_OTHER_TABS, TOGGLE_SCRIPTS_PANEL, + FILE_COPY_PATH, FILE_TOOL_RELOAD, FILE_TOOL_RELOAD_SOFT, DEBUG_NEXT, @@ -255,6 +256,8 @@ class ScriptEditor : public PanelContainer { void _close_other_tabs(); void _close_all_tabs(); + void _copy_script_path(); + void _ask_close_current_unsaved_tab(ScriptEditorBase *current); bool grab_focus_block; diff --git a/editor/plugins/script_text_editor.cpp b/editor/plugins/script_text_editor.cpp index 3a443e1bf7..6a869aaadb 100644 --- a/editor/plugins/script_text_editor.cpp +++ b/editor/plugins/script_text_editor.cpp @@ -96,10 +96,10 @@ void ScriptTextEditor::_load_theme_settings() { Color member_variable_color = EDITOR_DEF("text_editor/highlighting/member_variable_color", Color(0.9, 0.3, 0.3)); Color mark_color = EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4)); Color breakpoint_color = EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2)); + Color code_folding_color = EDITOR_DEF("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8)); Color search_result_color = EDITOR_DEF("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1)); Color search_result_border_color = EDITOR_DEF("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1)); Color symbol_color = EDITOR_DEF("text_editor/highlighting/symbol_color", Color::hex(0x005291ff)); - Color keyword_color = EDITOR_DEF("text_editor/highlighting/keyword_color", Color(0.5, 0.0, 0.2)); Color basetype_color = EDITOR_DEF("text_editor/highlighting/base_type_color", Color(0.3, 0.3, 0.0)); Color type_color = EDITOR_DEF("text_editor/highlighting/engine_type_color", Color(0.0, 0.2, 0.4)); @@ -137,6 +137,7 @@ void ScriptTextEditor::_load_theme_settings() { member_variable_color = tm->get_color("text_editor/theme/member_variable_color", "Editor"); mark_color = tm->get_color("text_editor/theme/mark_color", "Editor"); breakpoint_color = tm->get_color("text_editor/theme/breakpoint_color", "Editor"); + code_folding_color = tm->get_color("text_editor/theme/code_folding_color", "Editor"); search_result_color = tm->get_color("text_editor/theme/search_result_color", "Editor"); search_result_border_color = tm->get_color("text_editor/theme/search_result_border_color", "Editor"); } @@ -160,8 +161,9 @@ void ScriptTextEditor::_load_theme_settings() { text_edit->add_color_override("number_color", number_color); text_edit->add_color_override("function_color", function_color); text_edit->add_color_override("member_variable_color", member_variable_color); - text_edit->add_color_override("mark_color", mark_color); text_edit->add_color_override("breakpoint_color", breakpoint_color); + text_edit->add_color_override("mark_color", mark_color); + text_edit->add_color_override("code_folding_color", code_folding_color); text_edit->add_color_override("search_result_color", search_result_color); text_edit->add_color_override("search_result_border_color", search_result_border_color); text_edit->add_color_override("symbol_color", symbol_color); @@ -1509,6 +1511,8 @@ void ScriptTextEditor::_make_context_menu(bool p_selection, bool p_color, bool p if (p_selection) { context_menu->add_separator(); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_to_uppercase"), EDIT_TO_UPPERCASE); + context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/convert_to_lowercase"), EDIT_TO_LOWERCASE); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_left"), EDIT_INDENT_LEFT); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/indent_right"), EDIT_INDENT_RIGHT); context_menu->add_shortcut(ED_GET_SHORTCUT("script_text_editor/toggle_comment"), EDIT_TOGGLE_COMMENT); diff --git a/editor/plugins/shader_editor_plugin.cpp b/editor/plugins/shader_editor_plugin.cpp index 49e4642049..b390070b4a 100644 --- a/editor/plugins/shader_editor_plugin.cpp +++ b/editor/plugins/shader_editor_plugin.cpp @@ -81,6 +81,7 @@ void ShaderTextEditor::_load_theme_settings() { Color member_variable_color = EDITOR_DEF("text_editor/highlighting/member_variable_color", Color(0.9, 0.3, 0.3)); Color mark_color = EDITOR_DEF("text_editor/highlighting/mark_color", Color(1.0, 0.4, 0.4, 0.4)); Color breakpoint_color = EDITOR_DEF("text_editor/highlighting/breakpoint_color", Color(0.8, 0.8, 0.4, 0.2)); + Color code_folding_color = EDITOR_DEF("text_editor/highlighting/code_folding_color", Color(0.8, 0.8, 0.8, 0.8)); Color search_result_color = EDITOR_DEF("text_editor/highlighting/search_result_color", Color(0.05, 0.25, 0.05, 1)); Color search_result_border_color = EDITOR_DEF("text_editor/highlighting/search_result_border_color", Color(0.1, 0.45, 0.1, 1)); Color symbol_color = EDITOR_DEF("text_editor/highlighting/symbol_color", Color::hex(0x005291ff)); @@ -122,6 +123,7 @@ void ShaderTextEditor::_load_theme_settings() { member_variable_color = tm->get_color("text_editor/theme/member_variable_color", "Editor"); mark_color = tm->get_color("text_editor/theme/mark_color", "Editor"); breakpoint_color = tm->get_color("text_editor/theme/breakpoint_color", "Editor"); + code_folding_color = tm->get_color("text_editor/theme/code_folding_color", "Editor"); search_result_color = tm->get_color("text_editor/theme/search_result_color", "Editor"); search_result_border_color = tm->get_color("text_editor/theme/search_result_border_color", "Editor"); } @@ -147,6 +149,7 @@ void ShaderTextEditor::_load_theme_settings() { get_text_edit()->add_color_override("member_variable_color", member_variable_color); get_text_edit()->add_color_override("mark_color", mark_color); get_text_edit()->add_color_override("breakpoint_color", breakpoint_color); + get_text_edit()->add_color_override("code_folding_color", code_folding_color); get_text_edit()->add_color_override("search_result_color", search_result_color); get_text_edit()->add_color_override("search_result_border_color", search_result_border_color); get_text_edit()->add_color_override("symbol_color", symbol_color); diff --git a/editor/project_manager.cpp b/editor/project_manager.cpp index 60d7e59991..00488a2a88 100644 --- a/editor/project_manager.cpp +++ b/editor/project_manager.cpp @@ -508,7 +508,8 @@ public: } else if (current->has_setting("application/config/name")) { project_name->set_text(current->get("application/config/name")); } - project_name->grab_focus(); + + project_name->call_deferred("grab_focus"); create_dir->hide(); status_btn->hide(); diff --git a/editor/project_settings_editor.cpp b/editor/project_settings_editor.cpp index 900f7625bc..76fd20ca12 100644 --- a/editor/project_settings_editor.cpp +++ b/editor/project_settings_editor.cpp @@ -1776,7 +1776,6 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { //translations TabContainer *translations = memnew(TabContainer); - translations->add_style_override("panel", memnew(StyleBoxEmpty)); translations->set_tab_align(TabContainer::ALIGN_LEFT); translations->set_name(TTR("Localization")); tab_container->add_child(translations); @@ -1888,19 +1887,14 @@ ProjectSettingsEditor::ProjectSettingsEditor(EditorData *p_data) { translation_filter->connect("item_edited", this, "_translation_filter_option_changed"); } - { - autoload_settings = memnew(EditorAutoloadSettings); - autoload_settings->set_name(TTR("AutoLoad")); - tab_container->add_child(autoload_settings); - autoload_settings->connect("autoload_changed", this, "_settings_changed"); - } + autoload_settings = memnew(EditorAutoloadSettings); + autoload_settings->set_name(TTR("AutoLoad")); + tab_container->add_child(autoload_settings); + autoload_settings->connect("autoload_changed", this, "_settings_changed"); - { - - plugin_settings = memnew(EditorPluginSettings); - plugin_settings->set_name(TTR("Plugins")); - tab_container->add_child(plugin_settings); - } + plugin_settings = memnew(EditorPluginSettings); + plugin_settings->set_name(TTR("Plugins")); + tab_container->add_child(plugin_settings); timer = memnew(Timer); timer->set_wait_time(1.5); diff --git a/editor/property_editor.cpp b/editor/property_editor.cpp index 6f9454be2c..eed1efaf9c 100644 --- a/editor/property_editor.cpp +++ b/editor/property_editor.cpp @@ -2101,6 +2101,23 @@ bool PropertyEditor::_is_property_different(const Variant &p_current, const Vari return bool(Variant::evaluate(Variant::OP_NOT_EQUAL, p_current, p_orig)); } +bool PropertyEditor::_is_instanced_node_with_original_property_different(const String &p_name, TreeItem *item) { + bool mbi = _might_be_in_instance(); + if (mbi) { + Variant vorig; + Dictionary d = item->get_metadata(0); + int usage = d.has("usage") ? int(int(d["usage"]) & (PROPERTY_USAGE_STORE_IF_NONONE | PROPERTY_USAGE_STORE_IF_NONZERO)) : 0; + if (_get_instanced_node_original_property(p_name, vorig) || usage) { + Variant v = obj->get(p_name); + + if (_is_property_different(v, vorig, usage)) { + return true; + } + } + } + return false; +} + TreeItem *PropertyEditor::find_item(TreeItem *p_item, const String &p_name) { if (!p_item) @@ -2360,6 +2377,10 @@ void PropertyEditor::_check_reload_status(const String &p_name, TreeItem *item) } } + if (_is_instanced_node_with_original_property_different(p_name, item)) { + has_reload = true; + } + if (obj->call("property_can_revert", p_name).operator bool()) { has_reload = true; @@ -2665,18 +2686,14 @@ TreeItem *PropertyEditor::get_parent_node(String p_path, HashMap<String, TreeIte item->set_editable(1, false); item->set_selectable(1, subsection_selectable); - if (use_folding || folding_behaviour != FB_UNDEFINED) { // Even if you disabled folding (expand all by default), you still can collapse all manually. + if (use_folding) { // if (!obj->editor_is_section_unfolded(p_path)) { updating_folding = true; - if (folding_behaviour == FB_COLLAPSEALL) - item->set_collapsed(true); - else if (folding_behaviour == FB_EXPANDALL || is_expandall_enabled) - item->set_collapsed(false); - else - item->set_collapsed(true); + item->set_collapsed(true); updating_folding = false; } item->set_metadata(0, p_path); + foldable_property_cache.push_back(p_path); } if (item->get_parent() == root) { @@ -2725,6 +2742,7 @@ void PropertyEditor::refresh() { void PropertyEditor::update_tree() { tree->clear(); + foldable_property_cache.clear(); if (!obj) return; @@ -3512,20 +3530,9 @@ void PropertyEditor::update_tree() { bool has_reload = false; - bool mbi = _might_be_in_instance(); - if (mbi) { - - Variant vorig; - Dictionary d = item->get_metadata(0); - int usage = d.has("usage") ? int(int(d["usage"]) & (PROPERTY_USAGE_STORE_IF_NONONE | PROPERTY_USAGE_STORE_IF_NONZERO)) : 0; - if (_get_instanced_node_original_property(p.name, vorig) || usage) { - Variant v = obj->get(p.name); - - if (_is_property_different(v, vorig, usage)) { - item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3); - has_reload = true; - } - } + if (_is_instanced_node_with_original_property_different(p.name, item)) { + item->add_button(1, get_icon("ReloadSmall", "EditorIcons"), 3); + has_reload = true; } if (obj->call("property_can_revert", p.name).operator bool()) { @@ -3545,7 +3552,7 @@ void PropertyEditor::update_tree() { } } - if (mbi && !has_reload && item->get_cell_mode(1) == TreeItem::CELL_MODE_RANGE && item->get_text(1) == String()) { + if (_might_be_in_instance() && !has_reload && item->get_cell_mode(1) == TreeItem::CELL_MODE_RANGE && item->get_text(1) == String()) { item->add_button(1, get_icon("ReloadEmpty", "EditorIcons"), 3, true); } } @@ -3733,8 +3740,8 @@ void PropertyEditor::_item_edited() { _edit_set(name, item->get_text(1), refresh_all); } } break; - // math types + // math types case Variant::VECTOR3: { } break; @@ -4212,29 +4219,29 @@ void PropertyEditor::set_subsection_selectable(bool p_selectable) { update_tree(); } -bool PropertyEditor::is_expand_all_properties_enabled() const { - - return (use_folding == false); -} - void PropertyEditor::set_use_folding(bool p_enable) { use_folding = p_enable; tree->set_hide_folding(false); } -void PropertyEditor::collapse_all_parent_nodes() { - - folding_behaviour = FB_COLLAPSEALL; +void PropertyEditor::collapse_all_folding() { + if (!obj) + return; + for (List<String>::Element *E = foldable_property_cache.front(); E; E = E->next()) { + obj->editor_set_section_unfold(E->get(), false); + } update_tree(); - folding_behaviour = FB_UNDEFINED; } -void PropertyEditor::expand_all_parent_nodes() { +void PropertyEditor::expand_all_folding() { - folding_behaviour = FB_EXPANDALL; + if (!obj) + return; + for (List<String>::Element *E = foldable_property_cache.front(); E; E = E->next()) { + obj->editor_set_section_unfold(E->get(), true); + } update_tree(); - folding_behaviour = FB_UNDEFINED; } PropertyEditor::PropertyEditor() { @@ -4309,8 +4316,6 @@ PropertyEditor::PropertyEditor() { subsection_selectable = false; property_selectable = false; show_type_icons = false; // maybe one day will return. - folding_behaviour = FB_UNDEFINED; - is_expandall_enabled = bool(EDITOR_DEF("interface/editor/expand_all_properties", true)); } PropertyEditor::~PropertyEditor() { diff --git a/editor/property_editor.h b/editor/property_editor.h index a337a05e46..f684f5768d 100644 --- a/editor/property_editor.h +++ b/editor/property_editor.h @@ -203,18 +203,9 @@ class PropertyEditor : public Control { bool hide_script; bool use_folding; bool property_selectable; - bool is_expandall_enabled; - bool updating_folding; - enum FOLDING_BEHAVIOUR { - FB_UNDEFINED, - FB_COLLAPSEALL, - FB_EXPANDALL, - FB_EXPANDALL_FORCE - }; - FOLDING_BEHAVIOUR folding_behaviour; - + List<String> foldable_property_cache; HashMap<String, String> pending; String selected_property; @@ -253,6 +244,7 @@ class PropertyEditor : public Control { bool _might_be_in_instance(); bool _get_instanced_node_original_property(const StringName &p_prop, Variant &value); bool _is_property_different(const Variant &p_current, const Variant &p_orig, int p_usage = 0); + bool _is_instanced_node_with_original_property_different(const String &p_name, TreeItem *item); void _refresh_item(TreeItem *p_item); void _set_range_def(Object *p_item, String prop, float p_frame); @@ -314,10 +306,8 @@ public: void set_use_folding(bool p_enable); - bool is_expand_all_properties_enabled() const; - - void collapse_all_parent_nodes(); - void expand_all_parent_nodes(); + void collapse_all_folding(); + void expand_all_folding(); PropertyEditor(); ~PropertyEditor(); }; diff --git a/main/main.cpp b/main/main.cpp index c9b84d2cd1..b2f091e76a 100755..100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -168,7 +168,6 @@ static String get_full_version_string() { } //#define DEBUG_INIT - #ifdef DEBUG_INIT #define MAIN_PRINT(m_txt) print_line(m_txt) #else diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index b41b5f6452..f99fd5fd88 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -1057,7 +1057,7 @@ MainLoop *test(TestType p_type) { return NULL; } -} +} // namespace TestGDScript #else @@ -1067,6 +1067,6 @@ MainLoop *test(TestType p_type) { return NULL; } -} +} // namespace TestGDScript #endif diff --git a/main/tests/test_gdscript.h b/main/tests/test_gdscript.h index f37b175913..cbbf7f3ef4 100644 --- a/main/tests/test_gdscript.h +++ b/main/tests/test_gdscript.h @@ -42,6 +42,6 @@ enum TestType { }; MainLoop *test(TestType p_type); -} +} // namespace TestGDScript #endif // TEST_GDSCRIPT_H diff --git a/main/tests/test_image.cpp b/main/tests/test_image.cpp index b94d93b2b1..0b7ba0edcc 100644 --- a/main/tests/test_image.cpp +++ b/main/tests/test_image.cpp @@ -65,4 +65,4 @@ MainLoop *test() { return memnew(TestMainLoop); } -} +} // namespace TestImage diff --git a/main/tests/test_io.cpp b/main/tests/test_io.cpp index f96c5cfe3c..1477df4415 100644 --- a/main/tests/test_io.cpp +++ b/main/tests/test_io.cpp @@ -118,7 +118,7 @@ MainLoop *test() { return memnew(TestMainLoop); } -} +} // namespace TestIO #else @@ -128,5 +128,5 @@ MainLoop *test() { return NULL; } -} +} // namespace TestIO #endif diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp index 3ba8ef51b4..7d88372ee6 100644 --- a/main/tests/test_math.cpp +++ b/main/tests/test_math.cpp @@ -684,4 +684,4 @@ MainLoop *test() { return NULL; } -} +} // namespace TestMath diff --git a/main/tests/test_physics.cpp b/main/tests/test_physics.cpp index 1c50470544..e374113b67 100644 --- a/main/tests/test_physics.cpp +++ b/main/tests/test_physics.cpp @@ -435,4 +435,4 @@ MainLoop *test() { return memnew(TestPhysicsMainLoop); } -} +} // namespace TestPhysics diff --git a/main/tests/test_physics_2d.cpp b/main/tests/test_physics_2d.cpp index 7d596fbda3..41b7893032 100644 --- a/main/tests/test_physics_2d.cpp +++ b/main/tests/test_physics_2d.cpp @@ -431,4 +431,4 @@ MainLoop *test() { return memnew(TestPhysics2DMainLoop); } -} +} // namespace TestPhysics2D diff --git a/main/tests/test_render.cpp b/main/tests/test_render.cpp index cbf1a57855..9860a4a447 100644 --- a/main/tests/test_render.cpp +++ b/main/tests/test_render.cpp @@ -241,4 +241,4 @@ MainLoop *test() { return memnew(TestMainLoop); } -} +} // namespace TestRender diff --git a/main/tests/test_shader_lang.cpp b/main/tests/test_shader_lang.cpp index ddb2ed5e75..679e54451e 100644 --- a/main/tests/test_shader_lang.cpp +++ b/main/tests/test_shader_lang.cpp @@ -339,4 +339,4 @@ MainLoop *test() { return NULL; } -} +} // namespace TestShaderLang diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp index 88d7702acc..db57788ade 100644 --- a/main/tests/test_string.cpp +++ b/main/tests/test_string.cpp @@ -919,4 +919,4 @@ MainLoop *test() { return NULL; } -} +} // namespace TestString diff --git a/misc/travis/clang-format.sh b/misc/travis/clang-format.sh index 741d3bff1b..2b30cf5ada 100755 --- a/misc/travis/clang-format.sh +++ b/misc/travis/clang-format.sh @@ -1,6 +1,6 @@ #!/bin/sh -CLANG_FORMAT=clang-format-3.9 +CLANG_FORMAT=clang-format-5.0 if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then # Check the whole commit range against $TRAVIS_BRANCH, the base merge branch diff --git a/modules/bullet/area_bullet.cpp b/modules/bullet/area_bullet.cpp index 54024b4f90..fad6f52cea 100644 --- a/modules/bullet/area_bullet.cpp +++ b/modules/bullet/area_bullet.cpp @@ -37,19 +37,19 @@ #include "collision_object_bullet.h" #include "space_bullet.h" -AreaBullet::AreaBullet() - : RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_AREA), - monitorable(true), - isScratched(false), - spOv_mode(PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED), - spOv_gravityPoint(false), - spOv_gravityPointDistanceScale(0), - spOv_gravityPointAttenuation(1), - spOv_gravityVec(0, -1, 0), - spOv_gravityMag(10), - spOv_linearDump(0.1), - spOv_angularDump(1), - spOv_priority(0) { +AreaBullet::AreaBullet() : + RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_AREA), + monitorable(true), + isScratched(false), + spOv_mode(PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED), + spOv_gravityPoint(false), + spOv_gravityPointDistanceScale(0), + spOv_gravityPointAttenuation(1), + spOv_gravityVec(0, -1, 0), + spOv_gravityMag(10), + spOv_linearDump(0.1), + spOv_angularDump(1), + spOv_priority(0) { btGhost = bulletnew(btGhostObject); btGhost->setCollisionShape(compoundShape); diff --git a/modules/bullet/area_bullet.h b/modules/bullet/area_bullet.h index f6e3b7e902..95ce62bfed 100644 --- a/modules/bullet/area_bullet.h +++ b/modules/bullet/area_bullet.h @@ -47,8 +47,8 @@ public: ObjectID event_callback_id; StringName event_callback_method; - InOutEventCallback() - : event_callback_id(0) {} + InOutEventCallback() : + event_callback_id(0) {} }; enum OverlapState { @@ -62,10 +62,12 @@ public: CollisionObjectBullet *object; OverlapState state; - OverlappingObjectData() - : object(NULL), state(OVERLAP_STATE_ENTER) {} - OverlappingObjectData(CollisionObjectBullet *p_object, OverlapState p_state) - : object(p_object), state(p_state) {} + OverlappingObjectData() : + object(NULL), + state(OVERLAP_STATE_ENTER) {} + OverlappingObjectData(CollisionObjectBullet *p_object, OverlapState p_state) : + object(p_object), + state(p_state) {} OverlappingObjectData(const OverlappingObjectData &other) { operator=(other); } diff --git a/modules/bullet/btRayShape.cpp b/modules/bullet/btRayShape.cpp index ac95faaac6..bbd2b19677 100644 --- a/modules/bullet/btRayShape.cpp +++ b/modules/bullet/btRayShape.cpp @@ -33,9 +33,9 @@ #include "LinearMath/btAabbUtil2.h" #include "math/math_funcs.h" -btRayShape::btRayShape(btScalar length) - : btConvexInternalShape(), - m_shapeAxis(0, 0, 1) { +btRayShape::btRayShape(btScalar length) : + btConvexInternalShape(), + m_shapeAxis(0, 0, 1) { m_shapeType = CUSTOM_CONVEX_SHAPE_TYPE; setLength(length); } diff --git a/modules/bullet/bullet_physics_server.cpp b/modules/bullet/bullet_physics_server.cpp index 6e9ed0e318..26c879fddb 100644 --- a/modules/bullet/bullet_physics_server.cpp +++ b/modules/bullet/bullet_physics_server.cpp @@ -78,10 +78,10 @@ void BulletPhysicsServer::_bind_methods() { //ClassDB::bind_method(D_METHOD("DoTest"), &BulletPhysicsServer::DoTest); } -BulletPhysicsServer::BulletPhysicsServer() - : PhysicsServer(), - active(true), - active_spaces_count(0) {} +BulletPhysicsServer::BulletPhysicsServer() : + PhysicsServer(), + active(true), + active_spaces_count(0) {} BulletPhysicsServer::~BulletPhysicsServer() {} diff --git a/modules/bullet/collision_object_bullet.cpp b/modules/bullet/collision_object_bullet.cpp index 5e878b0ee4..da3a4b73cf 100644 --- a/modules/bullet/collision_object_bullet.cpp +++ b/modules/bullet/collision_object_bullet.cpp @@ -50,8 +50,14 @@ void CollisionObjectBullet::ShapeWrapper::set_transform(const btTransform &p_tra transform = p_transform; } -CollisionObjectBullet::CollisionObjectBullet(Type p_type) - : RIDBullet(), space(NULL), type(p_type), collisionsEnabled(true), m_isStatic(false), bt_collision_object(NULL), body_scale(1., 1., 1.) {} +CollisionObjectBullet::CollisionObjectBullet(Type p_type) : + RIDBullet(), + space(NULL), + type(p_type), + collisionsEnabled(true), + m_isStatic(false), + bt_collision_object(NULL), + body_scale(1., 1., 1.) {} CollisionObjectBullet::~CollisionObjectBullet() { // Remove all overlapping @@ -165,8 +171,9 @@ const btTransform &CollisionObjectBullet::get_transform__bullet() const { return bt_collision_object->getWorldTransform(); } -RigidCollisionObjectBullet::RigidCollisionObjectBullet(Type p_type) - : CollisionObjectBullet(p_type), compoundShape(bulletnew(btCompoundShape(enableDynamicAabbTree, initialChildCapacity))) { +RigidCollisionObjectBullet::RigidCollisionObjectBullet(Type p_type) : + CollisionObjectBullet(p_type), + compoundShape(bulletnew(btCompoundShape(enableDynamicAabbTree, initialChildCapacity))) { } RigidCollisionObjectBullet::~RigidCollisionObjectBullet() { diff --git a/modules/bullet/collision_object_bullet.h b/modules/bullet/collision_object_bullet.h index 153b8ea5bc..51e48909e4 100644 --- a/modules/bullet/collision_object_bullet.h +++ b/modules/bullet/collision_object_bullet.h @@ -70,16 +70,22 @@ public: btTransform transform; bool active; - ShapeWrapper() - : shape(NULL), bt_shape(NULL), active(true) {} - - ShapeWrapper(ShapeBullet *p_shape, const btTransform &p_transform, bool p_active) - : shape(p_shape), bt_shape(NULL), active(p_active) { + ShapeWrapper() : + shape(NULL), + bt_shape(NULL), + active(true) {} + + ShapeWrapper(ShapeBullet *p_shape, const btTransform &p_transform, bool p_active) : + shape(p_shape), + bt_shape(NULL), + active(p_active) { set_transform(p_transform); } - ShapeWrapper(ShapeBullet *p_shape, const Transform &p_transform, bool p_active) - : shape(p_shape), bt_shape(NULL), active(p_active) { + ShapeWrapper(ShapeBullet *p_shape, const Transform &p_transform, bool p_active) : + shape(p_shape), + bt_shape(NULL), + active(p_active) { set_transform(p_transform); } ~ShapeWrapper(); diff --git a/modules/bullet/cone_twist_joint_bullet.cpp b/modules/bullet/cone_twist_joint_bullet.cpp index f6ac40e001..7ae5e79645 100644 --- a/modules/bullet/cone_twist_joint_bullet.cpp +++ b/modules/bullet/cone_twist_joint_bullet.cpp @@ -35,8 +35,8 @@ #include "bullet_utilities.h" #include "rigid_body_bullet.h" -ConeTwistJointBullet::ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &rbAFrame, const Transform &rbBFrame) - : JointBullet() { +ConeTwistJointBullet::ConeTwistJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &rbAFrame, const Transform &rbBFrame) : + JointBullet() { btTransform btFrameA; G_TO_B(rbAFrame, btFrameA); if (rbB) { diff --git a/modules/bullet/constraint_bullet.cpp b/modules/bullet/constraint_bullet.cpp index 08fc36f274..505579ce9b 100644 --- a/modules/bullet/constraint_bullet.cpp +++ b/modules/bullet/constraint_bullet.cpp @@ -33,8 +33,9 @@ #include "collision_object_bullet.h" #include "space_bullet.h" -ConstraintBullet::ConstraintBullet() - : space(NULL), constraint(NULL) {} +ConstraintBullet::ConstraintBullet() : + space(NULL), + constraint(NULL) {} void ConstraintBullet::setup(btTypedConstraint *p_constraint) { constraint = p_constraint; diff --git a/modules/bullet/generic_6dof_joint_bullet.cpp b/modules/bullet/generic_6dof_joint_bullet.cpp index 647396c24c..28928bd861 100644 --- a/modules/bullet/generic_6dof_joint_bullet.cpp +++ b/modules/bullet/generic_6dof_joint_bullet.cpp @@ -35,8 +35,8 @@ #include "bullet_utilities.h" #include "rigid_body_bullet.h" -Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA) - : JointBullet() { +Generic6DOFJointBullet::Generic6DOFJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA) : + JointBullet() { btTransform btFrameA; G_TO_B(frameInA, btFrameA); diff --git a/modules/bullet/godot_collision_configuration.cpp b/modules/bullet/godot_collision_configuration.cpp index 4e4228cc48..136fb2ee74 100644 --- a/modules/bullet/godot_collision_configuration.cpp +++ b/modules/bullet/godot_collision_configuration.cpp @@ -34,8 +34,8 @@ #include "BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h" #include "godot_ray_world_algorithm.h" -GodotCollisionConfiguration::GodotCollisionConfiguration(const btDiscreteDynamicsWorld *world, const btDefaultCollisionConstructionInfo &constructionInfo) - : btDefaultCollisionConfiguration(constructionInfo) { +GodotCollisionConfiguration::GodotCollisionConfiguration(const btDiscreteDynamicsWorld *world, const btDefaultCollisionConstructionInfo &constructionInfo) : + btDefaultCollisionConfiguration(constructionInfo) { void *mem = NULL; diff --git a/modules/bullet/godot_collision_dispatcher.cpp b/modules/bullet/godot_collision_dispatcher.cpp index ea75e4eef4..e0ca29a8f3 100644 --- a/modules/bullet/godot_collision_dispatcher.cpp +++ b/modules/bullet/godot_collision_dispatcher.cpp @@ -34,8 +34,8 @@ const int GodotCollisionDispatcher::CASTED_TYPE_AREA = static_cast<int>(CollisionObjectBullet::TYPE_AREA); -GodotCollisionDispatcher::GodotCollisionDispatcher(btCollisionConfiguration *collisionConfiguration) - : btCollisionDispatcher(collisionConfiguration) {} +GodotCollisionDispatcher::GodotCollisionDispatcher(btCollisionConfiguration *collisionConfiguration) : + btCollisionDispatcher(collisionConfiguration) {} bool GodotCollisionDispatcher::needsCollision(const btCollisionObject *body0, const btCollisionObject *body1) { if (body0->getUserIndex() == CASTED_TYPE_AREA || body1->getUserIndex() == CASTED_TYPE_AREA) { diff --git a/modules/bullet/godot_motion_state.h b/modules/bullet/godot_motion_state.h index 5111807394..62ea472446 100644 --- a/modules/bullet/godot_motion_state.h +++ b/modules/bullet/godot_motion_state.h @@ -51,10 +51,10 @@ class GodotMotionState : public btMotionState { RigidBodyBullet *owner; public: - GodotMotionState(RigidBodyBullet *p_owner) - : bodyKinematicWorldTransf(btMatrix3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.), btVector3(0., 0., 0.)), - bodyCurrentWorldTransform(btMatrix3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.), btVector3(0., 0., 0.)), - owner(p_owner) {} + GodotMotionState(RigidBodyBullet *p_owner) : + bodyKinematicWorldTransf(btMatrix3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.), btVector3(0., 0., 0.)), + bodyCurrentWorldTransform(btMatrix3x3(1., 0., 0., 0., 1., 0., 0., 0., 1.), btVector3(0., 0., 0.)), + owner(p_owner) {} /// IMPORTANT DON'T USE THIS FUNCTION TO KNOW THE CURRENT BODY TRANSFORM /// This class is used internally by Bullet diff --git a/modules/bullet/godot_ray_world_algorithm.cpp b/modules/bullet/godot_ray_world_algorithm.cpp index 98daf8398e..ba13903548 100644 --- a/modules/bullet/godot_ray_world_algorithm.cpp +++ b/modules/bullet/godot_ray_world_algorithm.cpp @@ -34,18 +34,18 @@ #include "btRayShape.h" #include "collision_object_bullet.h" -GodotRayWorldAlgorithm::CreateFunc::CreateFunc(const btDiscreteDynamicsWorld *world) - : m_world(world) {} - -GodotRayWorldAlgorithm::SwappedCreateFunc::SwappedCreateFunc(const btDiscreteDynamicsWorld *world) - : m_world(world) {} - -GodotRayWorldAlgorithm::GodotRayWorldAlgorithm(const btDiscreteDynamicsWorld *world, btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped) - : btActivatingCollisionAlgorithm(ci, body0Wrap, body1Wrap), - m_manifoldPtr(mf), - m_ownManifold(false), - m_world(world), - m_isSwapped(isSwapped) {} +GodotRayWorldAlgorithm::CreateFunc::CreateFunc(const btDiscreteDynamicsWorld *world) : + m_world(world) {} + +GodotRayWorldAlgorithm::SwappedCreateFunc::SwappedCreateFunc(const btDiscreteDynamicsWorld *world) : + m_world(world) {} + +GodotRayWorldAlgorithm::GodotRayWorldAlgorithm(const btDiscreteDynamicsWorld *world, btPersistentManifold *mf, const btCollisionAlgorithmConstructionInfo &ci, const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap, bool isSwapped) : + btActivatingCollisionAlgorithm(ci, body0Wrap, body1Wrap), + m_manifoldPtr(mf), + m_ownManifold(false), + m_world(world), + m_isSwapped(isSwapped) {} GodotRayWorldAlgorithm::~GodotRayWorldAlgorithm() { if (m_ownManifold && m_manifoldPtr) { diff --git a/modules/bullet/godot_result_callbacks.h b/modules/bullet/godot_result_callbacks.h index ba5142676b..5750dc2acd 100644 --- a/modules/bullet/godot_result_callbacks.h +++ b/modules/bullet/godot_result_callbacks.h @@ -52,8 +52,10 @@ struct GodotClosestRayResultCallback : public btCollisionWorld::ClosestRayResult bool m_pickRay; public: - GodotClosestRayResultCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, const Set<RID> *p_exclude) - : btCollisionWorld::ClosestRayResultCallback(rayFromWorld, rayToWorld), m_exclude(p_exclude), m_pickRay(false) {} + GodotClosestRayResultCallback(const btVector3 &rayFromWorld, const btVector3 &rayToWorld, const Set<RID> *p_exclude) : + btCollisionWorld::ClosestRayResultCallback(rayFromWorld, rayToWorld), + m_exclude(p_exclude), + m_pickRay(false) {} virtual bool needsCollision(btBroadphaseProxy *proxy0) const; }; @@ -66,8 +68,11 @@ public: int count; const Set<RID> *m_exclude; - GodotAllConvexResultCallback(PhysicsDirectSpaceState::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude) - : m_results(p_results), m_exclude(p_exclude), m_resultMax(p_resultMax), count(0) {} + GodotAllConvexResultCallback(PhysicsDirectSpaceState::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude) : + m_results(p_results), + m_exclude(p_exclude), + m_resultMax(p_resultMax), + count(0) {} virtual bool needsCollision(btBroadphaseProxy *proxy0) const; @@ -79,8 +84,10 @@ public: const RigidBodyBullet *m_self_object; const bool m_ignore_areas; - GodotKinClosestConvexResultCallback(const btVector3 &convexFromWorld, const btVector3 &convexToWorld, const RigidBodyBullet *p_self_object, bool p_ignore_areas) - : btCollisionWorld::ClosestConvexResultCallback(convexFromWorld, convexToWorld), m_self_object(p_self_object), m_ignore_areas(p_ignore_areas) {} + GodotKinClosestConvexResultCallback(const btVector3 &convexFromWorld, const btVector3 &convexToWorld, const RigidBodyBullet *p_self_object, bool p_ignore_areas) : + btCollisionWorld::ClosestConvexResultCallback(convexFromWorld, convexToWorld), + m_self_object(p_self_object), + m_ignore_areas(p_ignore_areas) {} virtual bool needsCollision(btBroadphaseProxy *proxy0) const; }; @@ -90,8 +97,9 @@ public: const Set<RID> *m_exclude; int m_shapeId; - GodotClosestConvexResultCallback(const btVector3 &convexFromWorld, const btVector3 &convexToWorld, const Set<RID> *p_exclude) - : btCollisionWorld::ClosestConvexResultCallback(convexFromWorld, convexToWorld), m_exclude(p_exclude) {} + GodotClosestConvexResultCallback(const btVector3 &convexFromWorld, const btVector3 &convexToWorld, const Set<RID> *p_exclude) : + btCollisionWorld::ClosestConvexResultCallback(convexFromWorld, convexToWorld), + m_exclude(p_exclude) {} virtual bool needsCollision(btBroadphaseProxy *proxy0) const; @@ -106,8 +114,12 @@ public: int m_count; const Set<RID> *m_exclude; - GodotAllContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude) - : m_self_object(p_self_object), m_results(p_results), m_exclude(p_exclude), m_resultMax(p_resultMax), m_count(0) {} + GodotAllContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState::ShapeResult *p_results, int p_resultMax, const Set<RID> *p_exclude) : + m_self_object(p_self_object), + m_results(p_results), + m_exclude(p_exclude), + m_resultMax(p_resultMax), + m_count(0) {} virtual bool needsCollision(btBroadphaseProxy *proxy0) const; @@ -123,8 +135,12 @@ public: int m_count; const Set<RID> *m_exclude; - GodotContactPairContactResultCallback(btCollisionObject *p_self_object, Vector3 *p_results, int p_resultMax, const Set<RID> *p_exclude) - : m_self_object(p_self_object), m_results(p_results), m_exclude(p_exclude), m_resultMax(p_resultMax), m_count(0) {} + GodotContactPairContactResultCallback(btCollisionObject *p_self_object, Vector3 *p_results, int p_resultMax, const Set<RID> *p_exclude) : + m_self_object(p_self_object), + m_results(p_results), + m_exclude(p_exclude), + m_resultMax(p_resultMax), + m_count(0) {} virtual bool needsCollision(btBroadphaseProxy *proxy0) const; @@ -141,8 +157,12 @@ public: btVector3 m_rest_info_bt_point; const Set<RID> *m_exclude; - GodotRestInfoContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState::ShapeRestInfo *p_result, const Set<RID> *p_exclude) - : m_self_object(p_self_object), m_result(p_result), m_exclude(p_exclude), m_collided(false), m_min_distance(0) {} + GodotRestInfoContactResultCallback(btCollisionObject *p_self_object, PhysicsDirectSpaceState::ShapeRestInfo *p_result, const Set<RID> *p_exclude) : + m_self_object(p_self_object), + m_result(p_result), + m_exclude(p_exclude), + m_collided(false), + m_min_distance(0) {} virtual bool needsCollision(btBroadphaseProxy *proxy0) const; @@ -158,12 +178,12 @@ struct GodotDeepPenetrationContactResultCallback : public btManifoldResult { btScalar m_most_penetrated_distance; - GodotDeepPenetrationContactResultCallback(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap) - : btManifoldResult(body0Wrap, body1Wrap), - m_pointCollisionObject(NULL), - m_penetration_distance(0), - m_other_compound_shape_index(0), - m_most_penetrated_distance(1e20) {} + GodotDeepPenetrationContactResultCallback(const btCollisionObjectWrapper *body0Wrap, const btCollisionObjectWrapper *body1Wrap) : + btManifoldResult(body0Wrap, body1Wrap), + m_pointCollisionObject(NULL), + m_penetration_distance(0), + m_other_compound_shape_index(0), + m_most_penetrated_distance(1e20) {} void reset() { m_pointCollisionObject = NULL; diff --git a/modules/bullet/hinge_joint_bullet.cpp b/modules/bullet/hinge_joint_bullet.cpp index bb70babd99..d3288807b3 100644 --- a/modules/bullet/hinge_joint_bullet.cpp +++ b/modules/bullet/hinge_joint_bullet.cpp @@ -35,8 +35,8 @@ #include "bullet_utilities.h" #include "rigid_body_bullet.h" -HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameA, const Transform &frameB) - : JointBullet() { +HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameA, const Transform &frameB) : + JointBullet() { btTransform btFrameA; G_TO_B(frameA, btFrameA); @@ -53,8 +53,8 @@ HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, c setup(hingeConstraint); } -HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB) - : JointBullet() { +HingeJointBullet::HingeJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, const Vector3 &axisInA, const Vector3 &axisInB) : + JointBullet() { btVector3 btPivotA; btVector3 btAxisA; diff --git a/modules/bullet/joint_bullet.cpp b/modules/bullet/joint_bullet.cpp index be544f89bf..c8d91aa257 100644 --- a/modules/bullet/joint_bullet.cpp +++ b/modules/bullet/joint_bullet.cpp @@ -32,7 +32,7 @@ #include "joint_bullet.h" #include "space_bullet.h" -JointBullet::JointBullet() - : ConstraintBullet() {} +JointBullet::JointBullet() : + ConstraintBullet() {} JointBullet::~JointBullet() {} diff --git a/modules/bullet/pin_joint_bullet.cpp b/modules/bullet/pin_joint_bullet.cpp index cd9e9a4557..8c74fcbc94 100644 --- a/modules/bullet/pin_joint_bullet.cpp +++ b/modules/bullet/pin_joint_bullet.cpp @@ -34,8 +34,8 @@ #include "bullet_types_converter.h" #include "rigid_body_bullet.h" -PinJointBullet::PinJointBullet(RigidBodyBullet *p_body_a, const Vector3 &p_pos_a, RigidBodyBullet *p_body_b, const Vector3 &p_pos_b) - : JointBullet() { +PinJointBullet::PinJointBullet(RigidBodyBullet *p_body_a, const Vector3 &p_pos_a, RigidBodyBullet *p_body_b, const Vector3 &p_pos_b) : + JointBullet() { if (p_body_b) { btVector3 btPivotA; diff --git a/modules/bullet/rigid_body_bullet.cpp b/modules/bullet/rigid_body_bullet.cpp index f5ab8221e3..b134bd3a36 100644 --- a/modules/bullet/rigid_body_bullet.cpp +++ b/modules/bullet/rigid_body_bullet.cpp @@ -176,9 +176,9 @@ PhysicsDirectSpaceState *BulletPhysicsDirectBodyState::get_space_state() { return body->get_space()->get_direct_state(); } -RigidBodyBullet::KinematicUtilities::KinematicUtilities(RigidBodyBullet *p_owner) - : owner(p_owner), - safe_margin(0.001) { +RigidBodyBullet::KinematicUtilities::KinematicUtilities(RigidBodyBullet *p_owner) : + owner(p_owner), + safe_margin(0.001) { } RigidBodyBullet::KinematicUtilities::~KinematicUtilities() { @@ -250,22 +250,22 @@ void RigidBodyBullet::KinematicUtilities::just_delete_shapes(int new_size) { shapes.resize(new_size); } -RigidBodyBullet::RigidBodyBullet() - : RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_RIGID_BODY), - kinematic_utilities(NULL), - gravity_scale(1), - mass(1), - linearDamp(0), - angularDamp(0), - can_sleep(true), - force_integration_callback(NULL), - isTransformChanged(false), - maxCollisionsDetection(0), - collisionsCount(0), - maxAreasWhereIam(10), - areaWhereIamCount(0), - countGravityPointSpaces(0), - isScratchedSpaceOverrideModificator(false) { +RigidBodyBullet::RigidBodyBullet() : + RigidCollisionObjectBullet(CollisionObjectBullet::TYPE_RIGID_BODY), + kinematic_utilities(NULL), + gravity_scale(1), + mass(1), + linearDamp(0), + angularDamp(0), + can_sleep(true), + force_integration_callback(NULL), + isTransformChanged(false), + maxCollisionsDetection(0), + collisionsCount(0), + maxAreasWhereIam(10), + areaWhereIamCount(0), + countGravityPointSpaces(0), + isScratchedSpaceOverrideModificator(false) { godotMotionState = bulletnew(GodotMotionState(this)); diff --git a/modules/bullet/rigid_body_bullet.h b/modules/bullet/rigid_body_bullet.h index ab3c3e58b2..c54b5784b5 100644 --- a/modules/bullet/rigid_body_bullet.h +++ b/modules/bullet/rigid_body_bullet.h @@ -156,8 +156,8 @@ public: class btConvexShape *shape; btTransform transform; - KinematicShape() - : shape(NULL) {} + KinematicShape() : + shape(NULL) {} const bool is_active() const { return shape; } }; diff --git a/modules/bullet/shape_bullet.cpp b/modules/bullet/shape_bullet.cpp index f51af93a31..572a3b4476 100644 --- a/modules/bullet/shape_bullet.cpp +++ b/modules/bullet/shape_bullet.cpp @@ -130,8 +130,8 @@ btRayShape *ShapeBullet::create_shape_ray(real_t p_length) { /* PLANE */ -PlaneShapeBullet::PlaneShapeBullet() - : ShapeBullet() {} +PlaneShapeBullet::PlaneShapeBullet() : + ShapeBullet() {} void PlaneShapeBullet::set_data(const Variant &p_data) { setup(p_data); @@ -158,8 +158,8 @@ btCollisionShape *PlaneShapeBullet::create_bt_shape() { /* Sphere */ -SphereShapeBullet::SphereShapeBullet() - : ShapeBullet() {} +SphereShapeBullet::SphereShapeBullet() : + ShapeBullet() {} void SphereShapeBullet::set_data(const Variant &p_data) { setup(p_data); @@ -183,8 +183,8 @@ btCollisionShape *SphereShapeBullet::create_bt_shape() { } /* Box */ -BoxShapeBullet::BoxShapeBullet() - : ShapeBullet() {} +BoxShapeBullet::BoxShapeBullet() : + ShapeBullet() {} void BoxShapeBullet::set_data(const Variant &p_data) { setup(p_data); @@ -211,8 +211,8 @@ btCollisionShape *BoxShapeBullet::create_bt_shape() { /* Capsule */ -CapsuleShapeBullet::CapsuleShapeBullet() - : ShapeBullet() {} +CapsuleShapeBullet::CapsuleShapeBullet() : + ShapeBullet() {} void CapsuleShapeBullet::set_data(const Variant &p_data) { Dictionary d = p_data; @@ -244,8 +244,8 @@ btCollisionShape *CapsuleShapeBullet::create_bt_shape() { /* Convex polygon */ -ConvexPolygonShapeBullet::ConvexPolygonShapeBullet() - : ShapeBullet() {} +ConvexPolygonShapeBullet::ConvexPolygonShapeBullet() : + ShapeBullet() {} void ConvexPolygonShapeBullet::set_data(const Variant &p_data) { setup(p_data); @@ -286,8 +286,9 @@ btCollisionShape *ConvexPolygonShapeBullet::create_bt_shape() { /* Concave polygon */ -ConcavePolygonShapeBullet::ConcavePolygonShapeBullet() - : ShapeBullet(), meshShape(NULL) {} +ConcavePolygonShapeBullet::ConcavePolygonShapeBullet() : + ShapeBullet(), + meshShape(NULL) {} ConcavePolygonShapeBullet::~ConcavePolygonShapeBullet() { if (meshShape) { @@ -359,8 +360,8 @@ btCollisionShape *ConcavePolygonShapeBullet::create_bt_shape() { /* Height map shape */ -HeightMapShapeBullet::HeightMapShapeBullet() - : ShapeBullet() {} +HeightMapShapeBullet::HeightMapShapeBullet() : + ShapeBullet() {} void HeightMapShapeBullet::set_data(const Variant &p_data) { ERR_FAIL_COND(p_data.get_type() != Variant::DICTIONARY); @@ -411,8 +412,9 @@ btCollisionShape *HeightMapShapeBullet::create_bt_shape() { } /* Ray shape */ -RayShapeBullet::RayShapeBullet() - : ShapeBullet(), length(1) {} +RayShapeBullet::RayShapeBullet() : + ShapeBullet(), + length(1) {} void RayShapeBullet::set_data(const Variant &p_data) { setup(p_data); diff --git a/modules/bullet/slider_joint_bullet.cpp b/modules/bullet/slider_joint_bullet.cpp index 2da65677f5..f1d60679ec 100644 --- a/modules/bullet/slider_joint_bullet.cpp +++ b/modules/bullet/slider_joint_bullet.cpp @@ -35,8 +35,8 @@ #include "bullet_utilities.h" #include "rigid_body_bullet.h" -SliderJointBullet::SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB) - : JointBullet() { +SliderJointBullet::SliderJointBullet(RigidBodyBullet *rbA, RigidBodyBullet *rbB, const Transform &frameInA, const Transform &frameInB) : + JointBullet() { btTransform btFrameA; G_TO_B(frameInA, btFrameA); if (rbB) { diff --git a/modules/bullet/soft_body_bullet.cpp b/modules/bullet/soft_body_bullet.cpp index 64ef7bfad2..ef5c8cac6f 100644 --- a/modules/bullet/soft_body_bullet.cpp +++ b/modules/bullet/soft_body_bullet.cpp @@ -36,8 +36,18 @@ #include "scene/3d/immediate_geometry.h" -SoftBodyBullet::SoftBodyBullet() - : CollisionObjectBullet(CollisionObjectBullet::TYPE_SOFT_BODY), mass(1), simulation_precision(5), stiffness(0.5f), pressure_coefficient(50), damping_coefficient(0.005), drag_coefficient(0.005), bt_soft_body(NULL), soft_shape_type(SOFT_SHAPETYPE_NONE), isScratched(false), soft_body_shape_data(NULL) { +SoftBodyBullet::SoftBodyBullet() : + CollisionObjectBullet(CollisionObjectBullet::TYPE_SOFT_BODY), + mass(1), + simulation_precision(5), + stiffness(0.5f), + pressure_coefficient(50), + damping_coefficient(0.005), + drag_coefficient(0.005), + bt_soft_body(NULL), + soft_shape_type(SOFT_SHAPETYPE_NONE), + isScratched(false), + soft_body_shape_data(NULL) { test_geometry = memnew(ImmediateGeometry); diff --git a/modules/bullet/space_bullet.cpp b/modules/bullet/space_bullet.cpp index d8c8cab17a..c1f6e81734 100644 --- a/modules/bullet/space_bullet.cpp +++ b/modules/bullet/space_bullet.cpp @@ -50,8 +50,9 @@ #include "ustring.h" #include <assert.h> -BulletPhysicsDirectSpaceState::BulletPhysicsDirectSpaceState(SpaceBullet *p_space) - : PhysicsDirectSpaceState(), space(p_space) {} +BulletPhysicsDirectSpaceState::BulletPhysicsDirectSpaceState(SpaceBullet *p_space) : + PhysicsDirectSpaceState(), + space(p_space) {} int BulletPhysicsDirectSpaceState::intersect_point(const Vector3 &p_point, ShapeResult *r_results, int p_result_max, const Set<RID> &p_exclude, uint32_t p_collision_mask) { @@ -330,18 +331,18 @@ Vector3 BulletPhysicsDirectSpaceState::get_closest_point_to_object_volume(RID p_ } } -SpaceBullet::SpaceBullet(bool p_create_soft_world) - : broadphase(NULL), - dispatcher(NULL), - solver(NULL), - collisionConfiguration(NULL), - dynamicsWorld(NULL), - soft_body_world_info(NULL), - ghostPairCallback(NULL), - godotFilterCallback(NULL), - gravityDirection(0, -1, 0), - gravityMagnitude(10), - contactDebugCount(0) { +SpaceBullet::SpaceBullet(bool p_create_soft_world) : + broadphase(NULL), + dispatcher(NULL), + solver(NULL), + collisionConfiguration(NULL), + dynamicsWorld(NULL), + soft_body_world_info(NULL), + ghostPairCallback(NULL), + godotFilterCallback(NULL), + gravityDirection(0, -1, 0), + gravityMagnitude(10), + contactDebugCount(0) { create_empty_world(p_create_soft_world); direct_access = memnew(BulletPhysicsDirectSpaceState(this)); @@ -939,14 +940,14 @@ bool SpaceBullet::test_body_motion(RigidBodyBullet *p_body, const Transform &p_f r_result->collider_shape = r_recover_result.other_compound_shape_index; r_result->collision_local_shape = r_recover_result.local_shape_most_recovered; -//{ /// Add manifold point to manage collisions -// btPersistentManifold* manifold = dynamicsWorld->getDispatcher()->getNewManifold(p_body->getBtBody(), btRigid); -// btManifoldPoint manifoldPoint(result_callabck.m_pointWorld, result_callabck.m_pointWorld, result_callabck.m_pointNormalWorld, result_callabck.m_penetration_distance); -// manifoldPoint.m_index0 = r_result->collision_local_shape; -// manifoldPoint.m_index1 = r_result->collider_shape; -// manifold->addManifoldPoint(manifoldPoint); -// p_body->get_kinematic_utilities()->m_generatedManifold.push_back(manifold); -//} + //{ /// Add manifold point to manage collisions + // btPersistentManifold* manifold = dynamicsWorld->getDispatcher()->getNewManifold(p_body->getBtBody(), btRigid); + // btManifoldPoint manifoldPoint(result_callabck.m_pointWorld, result_callabck.m_pointWorld, result_callabck.m_pointNormalWorld, result_callabck.m_penetration_distance); + // manifoldPoint.m_index0 = r_result->collision_local_shape; + // manifoldPoint.m_index1 = r_result->collider_shape; + // manifold->addManifoldPoint(manifoldPoint); + // p_body->get_kinematic_utilities()->m_generatedManifold.push_back(manifold); + //} #if debug_test_motion Vector3 sup_line2; @@ -979,10 +980,10 @@ public: Vector<btCollisionObject *> result_collision_objects; public: - RecoverPenetrationBroadPhaseCallback(const btCollisionObject *p_self_collision_object, uint32_t p_collision_layer, uint32_t p_collision_mask) - : self_collision_object(p_self_collision_object), - collision_layer(p_collision_layer), - collision_mask(p_collision_mask) {} + RecoverPenetrationBroadPhaseCallback(const btCollisionObject *p_self_collision_object, uint32_t p_collision_layer, uint32_t p_collision_mask) : + self_collision_object(p_self_collision_object), + collision_layer(p_collision_layer), + collision_mask(p_collision_mask) {} virtual ~RecoverPenetrationBroadPhaseCallback() {} diff --git a/modules/bullet/space_bullet.h b/modules/bullet/space_bullet.h index 99bcfb8563..e5267c01a9 100644 --- a/modules/bullet/space_bullet.h +++ b/modules/bullet/space_bullet.h @@ -185,8 +185,8 @@ private: const btCollisionObject *other_collision_object; int local_shape_most_recovered; - RecoverResult() - : hasPenetration(false) {} + RecoverResult() : + hasPenetration(false) {} }; bool recover_from_penetration(RigidBodyBullet *p_body, const btTransform &p_from, btVector3 &r_recover_position, RecoverResult *r_recover_result = NULL); diff --git a/modules/gdnative/arvr/arvr_interface_gdnative.cpp b/modules/gdnative/arvr/arvr_interface_gdnative.cpp index 9b0d1ebb31..29e4775e62 100644 --- a/modules/gdnative/arvr/arvr_interface_gdnative.cpp +++ b/modules/gdnative/arvr/arvr_interface_gdnative.cpp @@ -219,7 +219,7 @@ extern "C" { void GDAPI godot_arvr_register_interface(const godot_arvr_interface_gdnative *p_interface) { Ref<ARVRInterfaceGDNative> new_interface; new_interface.instance(); - new_interface->set_interface((godot_arvr_interface_gdnative * const)p_interface); + new_interface->set_interface((godot_arvr_interface_gdnative *const)p_interface); ARVRServer::get_singleton()->add_interface(new_interface); } diff --git a/modules/gdnative/gdnative.cpp b/modules/gdnative/gdnative.cpp index 21c24fabd8..9c0041cbe0 100644 --- a/modules/gdnative/gdnative.cpp +++ b/modules/gdnative/gdnative.cpp @@ -144,7 +144,7 @@ bool GDNative::initialize() { } } - Error err = OS::get_singleton()->open_dynamic_library(path, native_handle,true); + Error err = OS::get_singleton()->open_dynamic_library(path, native_handle, true); if (err != OK) { return false; } diff --git a/modules/gdnative/gdnative.h b/modules/gdnative/gdnative.h index bb260bdd1b..993cd0ece7 100644 --- a/modules/gdnative/gdnative.h +++ b/modules/gdnative/gdnative.h @@ -106,8 +106,8 @@ struct GDNativeCallRegistry { return singleton; } - inline GDNativeCallRegistry() - : native_calls() {} + inline GDNativeCallRegistry() : + native_calls() {} Map<StringName, native_call_cb> native_calls; diff --git a/modules/gdnative/nativescript/api_generator.cpp b/modules/gdnative/nativescript/api_generator.cpp index f9d699fb59..653445c2db 100644 --- a/modules/gdnative/nativescript/api_generator.cpp +++ b/modules/gdnative/nativescript/api_generator.cpp @@ -468,8 +468,6 @@ static List<String> generate_c_api_json(const List<ClassAPI> &p_api) { return source; } -// - #endif /* diff --git a/modules/gdnative/nativescript/nativescript.cpp b/modules/gdnative/nativescript/nativescript.cpp index c2c7c27f25..965de062e3 100644 --- a/modules/gdnative/nativescript/nativescript.cpp +++ b/modules/gdnative/nativescript/nativescript.cpp @@ -437,11 +437,11 @@ NativeScript::~NativeScript() { #endif } -// -// -// ScriptInstance stuff -// -// + // + // + // ScriptInstance stuff + // + // #define GET_SCRIPT_DESC() script->get_script_desc() diff --git a/modules/gdnative/nativescript/nativescript.h b/modules/gdnative/nativescript/nativescript.h index f0f14e2f30..30fa400cb0 100644 --- a/modules/gdnative/nativescript/nativescript.h +++ b/modules/gdnative/nativescript/nativescript.h @@ -76,12 +76,12 @@ struct NativeScriptDesc { bool is_tool; - inline NativeScriptDesc() - : methods(), - properties(), - signals_(), - base(), - base_native_type() { + inline NativeScriptDesc() : + methods(), + properties(), + signals_(), + base(), + base_native_type() { zeromem(&create_func, sizeof(godot_instance_create_func)); zeromem(&destroy_func, sizeof(godot_instance_destroy_func)); } diff --git a/modules/gdnative/pluginscript/pluginscript_language.cpp b/modules/gdnative/pluginscript/pluginscript_language.cpp index 40feb5ae43..e358c2fb69 100644 --- a/modules/gdnative/pluginscript/pluginscript_language.cpp +++ b/modules/gdnative/pluginscript/pluginscript_language.cpp @@ -410,8 +410,8 @@ void PluginScriptLanguage::unlock() { #endif } -PluginScriptLanguage::PluginScriptLanguage(const godot_pluginscript_language_desc *desc) - : _desc(*desc) { +PluginScriptLanguage::PluginScriptLanguage(const godot_pluginscript_language_desc *desc) : + _desc(*desc) { _resource_loader = memnew(ResourceFormatLoaderPluginScript(this)); _resource_saver = memnew(ResourceFormatSaverPluginScript(this)); diff --git a/modules/gdnative/pluginscript/pluginscript_script.cpp b/modules/gdnative/pluginscript/pluginscript_script.cpp index 4169b07f63..0b71b3b10d 100644 --- a/modules/gdnative/pluginscript/pluginscript_script.cpp +++ b/modules/gdnative/pluginscript/pluginscript_script.cpp @@ -423,8 +423,11 @@ ScriptInstance::RPCMode PluginScript::get_rset_mode(const StringName &p_variable } } -PluginScript::PluginScript() - : _data(NULL), _tool(false), _valid(false), _script_list(this) { +PluginScript::PluginScript() : + _data(NULL), + _tool(false), + _valid(false), + _script_list(this) { } void PluginScript::init(PluginScriptLanguage *language) { diff --git a/modules/gdscript/gdscript.cpp b/modules/gdscript/gdscript.cpp index 9496d0b310..b75f670906 100644 --- a/modules/gdscript/gdscript.cpp +++ b/modules/gdscript/gdscript.cpp @@ -100,7 +100,7 @@ GDScriptInstance *GDScript::_create_instance(const Variant **p_args, int p_argco #endif instance->owner->set_script_instance(instance); -/* STEP 2, INITIALIZE AND CONSRTUCT */ + /* STEP 2, INITIALIZE AND CONSRTUCT */ #ifndef NO_THREADS GDScriptLanguage::singleton->lock->lock(); @@ -876,8 +876,8 @@ void GDScript::get_script_signal_list(List<MethodInfo> *r_signals) const { #endif } -GDScript::GDScript() - : script_list(this) { +GDScript::GDScript() : + script_list(this) { _static_ref = this; valid = false; diff --git a/modules/gdscript/gdscript_compiler.cpp b/modules/gdscript/gdscript_compiler.cpp index 4cd6472b7f..f9385d7a11 100644 --- a/modules/gdscript/gdscript_compiler.cpp +++ b/modules/gdscript/gdscript_compiler.cpp @@ -806,8 +806,8 @@ int GDScriptCompiler::_parse_expression(CodeGen &codegen, const GDScriptParser:: ERR_FAIL_COND_V(on->arguments.size() != 2, -1); if (on->arguments[0]->type == GDScriptParser::Node::TYPE_OPERATOR && (static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX || static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED)) { -//SET (chained) MODE!! + // SET (chained) MODE! #ifdef DEBUG_ENABLED if (static_cast<GDScriptParser::OperatorNode *>(on->arguments[0])->op == GDScriptParser::OperatorNode::OP_INDEX_NAMED) { const GDScriptParser::OperatorNode *inon = static_cast<GDScriptParser::OperatorNode *>(on->arguments[0]); diff --git a/modules/gdscript/gdscript_editor.cpp b/modules/gdscript/gdscript_editor.cpp index e7100d835c..adf6780278 100644 --- a/modules/gdscript/gdscript_editor.cpp +++ b/modules/gdscript/gdscript_editor.cpp @@ -1795,8 +1795,8 @@ static void _find_type_arguments(GDScriptCompletionContext &context, const GDScr } } else { -//regular method + //regular method #if defined(DEBUG_METHODS_ENABLED) && defined(TOOLS_ENABLED) if (p_argidx < m->get_argument_count()) { PropertyInfo pi = m->get_argument_info(p_argidx); diff --git a/modules/gdscript/gdscript_function.cpp b/modules/gdscript/gdscript_function.cpp index 765a76fec4..d2ce318f82 100644 --- a/modules/gdscript/gdscript_function.cpp +++ b/modules/gdscript/gdscript_function.cpp @@ -250,7 +250,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a #ifdef DEBUG_ENABLED -//GDScriptLanguage::get_singleton()->calls++; + //GDScriptLanguage::get_singleton()->calls++; #endif @@ -515,7 +515,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a } else { v = "of type '" + _get_var_type(index) + "'"; } - err_text = "Invalid set index " + v + " (on base: '" + _get_var_type(dst) + "')."; + err_text = "Invalid set index " + v + " (on base: '" + _get_var_type(dst) + "') with value of type '"+_get_var_type(value)+"'"; OPCODE_BREAK; } #endif @@ -574,7 +574,7 @@ Variant GDScriptFunction::call(GDScriptInstance *p_instance, const Variant **p_a #ifdef DEBUG_ENABLED if (!valid) { String err_type; - err_text = "Invalid set index '" + String(*index) + "' (on base: '" + _get_var_type(dst) + "')."; + err_text = "Invalid set index '" + String(*index) + "' (on base: '" + _get_var_type(dst) + "') with value of type '"+_get_var_type(value)+"'."; OPCODE_BREAK; } #endif @@ -1432,8 +1432,8 @@ void GDScriptFunction::debug_get_stack_member_state(int p_line, List<Pair<String } } -GDScriptFunction::GDScriptFunction() - : function_list(this) { +GDScriptFunction::GDScriptFunction() : + function_list(this) { _stack_size = 0; _call_size = 0; diff --git a/modules/gdscript/gdscript_parser.cpp b/modules/gdscript/gdscript_parser.cpp index bee9ef1998..e48b03968b 100644 --- a/modules/gdscript/gdscript_parser.cpp +++ b/modules/gdscript/gdscript_parser.cpp @@ -2976,10 +2976,9 @@ void GDScriptParser::_parse_extends(ClassNode *p_class) { case GDScriptTokenizer::TK_IDENTIFIER: { - StringName identifier = tokenizer->get_token_identifier(); - p_class->extends_class.push_back(identifier); - } - break; + StringName identifier = tokenizer->get_token_identifier(); + p_class->extends_class.push_back(identifier); + } break; case GDScriptTokenizer::TK_PERIOD: break; diff --git a/modules/mobile_vr/mobile_interface.cpp b/modules/mobile_vr/mobile_interface.cpp index 3a0b83d534..35253d5a77 100644 --- a/modules/mobile_vr/mobile_interface.cpp +++ b/modules/mobile_vr/mobile_interface.cpp @@ -461,6 +461,7 @@ MobileVRInterface::MobileVRInterface() { glGenBuffers(1, &half_screen_quad); glBindBuffer(GL_ARRAY_BUFFER, half_screen_quad); { + /* clang-format off */ const float qv[16] = { 0, -1, -1, -1, @@ -471,6 +472,7 @@ MobileVRInterface::MobileVRInterface() { 1, -1, 1, -1, }; + /* clang-format on */ glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 16, qv, GL_STATIC_DRAW); } diff --git a/modules/mono/csharp_script.cpp b/modules/mono/csharp_script.cpp index 6fbc309fa3..af5a0334c3 100644 --- a/modules/mono/csharp_script.cpp +++ b/modules/mono/csharp_script.cpp @@ -1885,8 +1885,8 @@ StringName CSharpScript::get_script_name() const { return name; } -CSharpScript::CSharpScript() - : script_list(this) { +CSharpScript::CSharpScript() : + script_list(this) { _clear(); diff --git a/modules/mono/editor/csharp_project.cpp b/modules/mono/editor/csharp_project.cpp index bde5f0fd0b..9a1efb4423 100644 --- a/modules/mono/editor/csharp_project.cpp +++ b/modules/mono/editor/csharp_project.cpp @@ -117,4 +117,4 @@ void add_item(const String &p_project_path, const String &p_item_type, const Str ERR_FAIL(); } } -} // CSharpProject +} // namespace CSharpProject diff --git a/modules/mono/editor/csharp_project.h b/modules/mono/editor/csharp_project.h index 4832d2251e..44e8325a59 100644 --- a/modules/mono/editor/csharp_project.h +++ b/modules/mono/editor/csharp_project.h @@ -39,6 +39,6 @@ String generate_editor_api_project(const String &p_dir, const String &p_core_dll String generate_game_project(const String &p_dir, const String &p_name, const Vector<String> &p_files = Vector<String>()); void add_item(const String &p_project_path, const String &p_item_type, const String &p_include); -} +} // namespace CSharpProject #endif // CSHARP_PROJECT_H diff --git a/modules/mono/godotsharp_dirs.cpp b/modules/mono/godotsharp_dirs.cpp index a0c2508b0d..0f6245a37c 100644 --- a/modules/mono/godotsharp_dirs.cpp +++ b/modules/mono/godotsharp_dirs.cpp @@ -192,4 +192,4 @@ String get_project_csproj_path() { return _GodotSharpDirs::get_singleton().csproj_filepath; } #endif -} +} // namespace GodotSharpDirs diff --git a/modules/mono/godotsharp_dirs.h b/modules/mono/godotsharp_dirs.h index ba2c065210..914df40629 100644 --- a/modules/mono/godotsharp_dirs.h +++ b/modules/mono/godotsharp_dirs.h @@ -53,6 +53,6 @@ String get_custom_project_settings_dir(); String get_project_sln_path(); String get_project_csproj_path(); -} +} // namespace GodotSharpDirs #endif // GODOTSHARP_DIRS_H diff --git a/modules/mono/mono_gc_handle.cpp b/modules/mono/mono_gc_handle.cpp index e10e06df0e..121392b3f8 100644 --- a/modules/mono/mono_gc_handle.cpp +++ b/modules/mono/mono_gc_handle.cpp @@ -36,7 +36,7 @@ uint32_t MonoGCHandle::make_strong_handle(MonoObject *p_object) { return mono_gchandle_new( p_object, false /* do not pin the object */ - ); + ); } uint32_t MonoGCHandle::make_weak_handle(MonoObject *p_object) { @@ -44,7 +44,7 @@ uint32_t MonoGCHandle::make_weak_handle(MonoObject *p_object) { return mono_gchandle_new_weakref( p_object, true /* track_resurrection: allows us to invoke _notification(NOTIFICATION_PREDELETE) while disposing */ - ); + ); } Ref<MonoGCHandle> MonoGCHandle::create_strong(MonoObject *p_object) { diff --git a/modules/mono/mono_gd/gd_mono_internals.cpp b/modules/mono/mono_gd/gd_mono_internals.cpp index cfe2148b80..56e8a01567 100644 --- a/modules/mono/mono_gd/gd_mono_internals.cpp +++ b/modules/mono/mono_gd/gd_mono_internals.cpp @@ -63,4 +63,4 @@ void tie_managed_to_unmanaged(MonoObject *managed, Object *unmanaged) { return; } -} +} // namespace GDMonoInternals diff --git a/modules/mono/signal_awaiter_utils.cpp b/modules/mono/signal_awaiter_utils.cpp index 7e99df29a1..47cc11cc0a 100644 --- a/modules/mono/signal_awaiter_utils.cpp +++ b/modules/mono/signal_awaiter_utils.cpp @@ -62,7 +62,7 @@ Error connect_signal_awaiter(Object *p_source, const String &p_signal, Object *p return err; } -} +} // namespace SignalAwaiterUtils Variant SignalAwaiterHandle::_signal_callback(const Variant **p_args, int p_argcount, Variant::CallError &r_error) { @@ -116,8 +116,8 @@ void SignalAwaiterHandle::_bind_methods() { ClassDB::bind_vararg_method(METHOD_FLAGS_DEFAULT, "_signal_callback", &SignalAwaiterHandle::_signal_callback, MethodInfo("_signal_callback")); } -SignalAwaiterHandle::SignalAwaiterHandle(uint32_t p_managed_handle) - : MonoGCHandle(p_managed_handle) { +SignalAwaiterHandle::SignalAwaiterHandle(uint32_t p_managed_handle) : + MonoGCHandle(p_managed_handle) { #ifdef DEBUG_ENABLED conn_target_id = 0; diff --git a/modules/mono/utils/mono_reg_utils.h b/modules/mono/utils/mono_reg_utils.h index 4cc4965acb..599828aa80 100644 --- a/modules/mono/utils/mono_reg_utils.h +++ b/modules/mono/utils/mono_reg_utils.h @@ -47,7 +47,7 @@ namespace MonoRegUtils { MonoRegInfo find_mono(); String find_msbuild_tools_path(); -} // MonoRegUtils +} // namespace MonoRegUtils #endif // WINDOWS_ENABLED diff --git a/modules/mono/utils/string_utils.cpp b/modules/mono/utils/string_utils.cpp index f26663ea11..8f817771ac 100644 --- a/modules/mono/utils/string_utils.cpp +++ b/modules/mono/utils/string_utils.cpp @@ -78,7 +78,7 @@ int sfind(const String &p_text, int p_from) { return -1; } -} +} // namespace String sformat(const String &p_text, const Variant &p1, const Variant &p2, const Variant &p3, const Variant &p4, const Variant &p5) { if (p_text.length() < 2) diff --git a/modules/pvr/texture_loader_pvr.cpp b/modules/pvr/texture_loader_pvr.cpp index 03592047ad..4415c888a4 100644 --- a/modules/pvr/texture_loader_pvr.cpp +++ b/modules/pvr/texture_loader_pvr.cpp @@ -239,11 +239,11 @@ ResourceFormatPVR::ResourceFormatPVR() { Image::_image_compress_pvrtc2_func = _compress_pvrtc4; } -///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// -//PVRTC decompressor, Based on PVRTC decompressor by IMGTEC. + //PVRTC decompressor, Based on PVRTC decompressor by IMGTEC. -///////////////////////////////////////////////////////// + ///////////////////////////////////////////////////////// #define PT_INDEX 2 #define BLK_Y_SIZE 4 diff --git a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml index c0f8c6b9c7..4533d59cae 100644 --- a/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml +++ b/modules/stb_vorbis/doc_classes/AudioStreamOGGVorbis.xml @@ -11,18 +11,49 @@ <demos> </demos> <methods> + <method name="get_data" qualifiers="const"> + <return type="PoolByteArray"> + </return> + <description> + </description> + </method> + <method name="get_loop_offset" qualifiers="const"> + <return type="float"> + </return> + <description> + </description> + </method> + <method name="has_loop" qualifiers="const"> + <return type="bool"> + </return> + <description> + </description> + </method> + <method name="set_data"> + <return type="void"> + </return> + <argument index="0" name="data" type="PoolByteArray"> + </argument> + <description> + </description> + </method> + <method name="set_loop"> + <return type="void"> + </return> + <argument index="0" name="enable" type="bool"> + </argument> + <description> + </description> + </method> + <method name="set_loop_offset"> + <return type="void"> + </return> + <argument index="0" name="seconds" type="float"> + </argument> + <description> + </description> + </method> </methods> - <members> - <member name="data" type="PoolByteArray" setter="set_data" getter="get_data"> - Raw audio data. - </member> - <member name="loop" type="bool" setter="set_loop" getter="has_loop"> - If [code]true[/code], audio will loop continuously. Default value: [code]false[/code]. - </member> - <member name="loop_offset" type="float" setter="set_loop_offset" getter="get_loop_offset"> - If loop is [code]true[/code], loop starts from this position, in seconds. - </member> - </members> <constants> </constants> </class> diff --git a/modules/theora/doc_classes/VideoStreamTheora.xml b/modules/theora/doc_classes/VideoStreamTheora.xml index 61884f47fa..6c8806ed72 100644 --- a/modules/theora/doc_classes/VideoStreamTheora.xml +++ b/modules/theora/doc_classes/VideoStreamTheora.xml @@ -9,11 +9,21 @@ <demos> </demos> <methods> + <method name="get_file"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="set_file"> + <return type="void"> + </return> + <argument index="0" name="file" type="String"> + </argument> + <description> + </description> + </method> </methods> - <members> - <member name="file" type="String" setter="set_file" getter="get_file"> - </member> - </members> <constants> </constants> </class> diff --git a/modules/tinyexr/image_loader_tinyexr.cpp b/modules/tinyexr/image_loader_tinyexr.cpp index 49a4db237a..c88662454c 100644 --- a/modules/tinyexr/image_loader_tinyexr.cpp +++ b/modules/tinyexr/image_loader_tinyexr.cpp @@ -47,6 +47,11 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f f->close(); + // Re-implementation of tinyexr's LoadEXRFromMemory using Godot types to store the Image data + // and Godot's error codes. + // When debugging after updating the thirdparty library, check that we're still in sync with + // their API usage in LoadEXRFromMemory. + EXRVersion exr_version; EXRImage exr_image; EXRHeader exr_header; @@ -68,6 +73,13 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f return ERR_FILE_CORRUPT; } + // Read HALF channel as FLOAT. (GH-13490) + for (int i = 0; i < exr_header.num_channels; i++) { + if (exr_header.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) { + exr_header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; + } + } + InitEXRImage(&exr_image); ret = LoadEXRImageFromMemory(&exr_image, &exr_header, w.ptr(), src_image_len, &err); if (ret != TINYEXR_SUCCESS) { @@ -95,23 +107,25 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f } if (idxR == -1) { - ERR_PRINT("R channel not found"); + ERR_PRINT("TinyEXR: R channel not found."); // @todo { free exr_image } return ERR_FILE_CORRUPT; } if (idxG == -1) { - ERR_PRINT("G channel not found\n") + ERR_PRINT("TinyEXR: G channel not found.") // @todo { free exr_image } return ERR_FILE_CORRUPT; } if (idxB == -1) { - ERR_PRINT("B channel not found\n") + ERR_PRINT("TinyEXR: B channel not found.") // @todo { free exr_image } return ERR_FILE_CORRUPT; } + // EXR image data loaded, now parse it into Godot-friendly image data + PoolVector<uint8_t> imgdata; Image::Format format; @@ -126,7 +140,6 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f } { - PoolVector<uint8_t>::Write wd = imgdata.write(); uint16_t *iw = (uint16_t *)wd.ptr(); @@ -151,11 +164,13 @@ Error ImageLoaderTinyEXR::load_image(Ref<Image> p_image, FileAccess *f, bool p_f } } - print_line("EXR w: " + itos(exr_image.width) + " h:" + itos(exr_image.height) + " format " + Image::get_format_name(format)); p_image->create(exr_image.width, exr_image.height, false, format, imgdata); w = PoolVector<uint8_t>::Write(); + FreeEXRHeader(&exr_header); + FreeEXRImage(&exr_image); + return OK; } diff --git a/modules/visual_script/doc_classes/VisualScript.xml b/modules/visual_script/doc_classes/VisualScript.xml index cc55b72ec7..46bd35dd73 100644 --- a/modules/visual_script/doc_classes/VisualScript.xml +++ b/modules/visual_script/doc_classes/VisualScript.xml @@ -495,10 +495,6 @@ </description> </method> </methods> - <members> - <member name="data" type="Dictionary" setter="_set_data" getter="_get_data"> - </member> - </members> <signals> <signal name="node_ports_changed"> <argument index="0" name="function" type="String"> diff --git a/modules/visual_script/doc_classes/VisualScriptConstructor.xml b/modules/visual_script/doc_classes/VisualScriptConstructor.xml index f3c6b6a304..cbe8c6c096 100644 --- a/modules/visual_script/doc_classes/VisualScriptConstructor.xml +++ b/modules/visual_script/doc_classes/VisualScriptConstructor.xml @@ -11,31 +11,35 @@ <demos> </demos> <methods> + <method name="get_constructor" qualifiers="const"> + <return type="Dictionary"> + </return> + <description> + </description> + </method> + <method name="get_constructor_type" qualifiers="const"> + <return type="int" enum="Variant.Type"> + </return> + <description> + </description> + </method> + <method name="set_constructor"> + <return type="void"> + </return> + <argument index="0" name="constructor" type="Dictionary"> + </argument> + <description> + </description> + </method> + <method name="set_constructor_type"> + <return type="void"> + </return> + <argument index="0" name="type" type="int" enum="Variant.Type"> + </argument> + <description> + </description> + </method> </methods> - <members> - <member name="constructor" type="Dictionary" setter="set_constructor" getter="get_constructor"> - The constructor function's method info. Has roughly the following structure: - [codeblock] - { - name = "string", - args = [{ - name = "string" - class_name = "string" - type = TYPE_* - hint = PROPERTY_HINT_* - hint_string = "string" - }] - default_args = [] # Array of variants - flags = METHOD_FLAG_* - id = 0 - return = {type = TYPE_*} - } - [/codeblock] - </member> - <member name="type" type="int" setter="set_constructor_type" getter="get_constructor_type" enum="Variant.Type"> - The type to be constructed. - </member> - </members> <constants> </constants> </class> diff --git a/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml b/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml index 86cf4410ac..0f396564e2 100644 --- a/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml +++ b/modules/visual_script/doc_classes/VisualScriptDeconstruct.xml @@ -13,8 +13,6 @@ <methods> </methods> <members> - <member name="elem_cache" type="Array" setter="_set_elem_cache" getter="_get_elem_cache"> - </member> <member name="type" type="int" setter="set_deconstruct_type" getter="get_deconstruct_type" enum="Variant.Type"> The type to deconstruct. </member> diff --git a/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml index cc2360fc2e..03c47dca7c 100644 --- a/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml +++ b/modules/visual_script/doc_classes/VisualScriptFunctionCall.xml @@ -11,8 +11,6 @@ <methods> </methods> <members> - <member name="argument_cache" type="Dictionary" setter="_set_argument_cache" getter="_get_argument_cache"> - </member> <member name="base_script" type="String" setter="set_base_script" getter="get_base_script"> </member> <member name="base_type" type="String" setter="set_base_type" getter="get_base_type"> diff --git a/modules/visual_script/doc_classes/VisualScriptNode.xml b/modules/visual_script/doc_classes/VisualScriptNode.xml index 94fed44950..ef7cf7c3b8 100644 --- a/modules/visual_script/doc_classes/VisualScriptNode.xml +++ b/modules/visual_script/doc_classes/VisualScriptNode.xml @@ -46,10 +46,6 @@ </description> </method> </methods> - <members> - <member name="_default_input_values" type="Array" setter="_set_default_input_values" getter="_get_default_input_values"> - </member> - </members> <signals> <signal name="ports_changed"> <description> diff --git a/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml index f68f0edeea..11c50f2b97 100644 --- a/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml +++ b/modules/visual_script/doc_classes/VisualScriptPropertyGet.xml @@ -25,8 +25,6 @@ </member> <member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertyGet.CallMode"> </member> - <member name="type_cache" type="int" setter="_set_type_cache" getter="_get_type_cache" enum="Variant.Type"> - </member> </members> <constants> <constant name="CALL_MODE_SELF" value="0" enum="CallMode"> diff --git a/modules/visual_script/doc_classes/VisualScriptPropertySet.xml b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml index d4305af57f..2e96ccc1f6 100644 --- a/modules/visual_script/doc_classes/VisualScriptPropertySet.xml +++ b/modules/visual_script/doc_classes/VisualScriptPropertySet.xml @@ -27,8 +27,6 @@ </member> <member name="set_mode" type="int" setter="set_call_mode" getter="get_call_mode" enum="VisualScriptPropertySet.CallMode"> </member> - <member name="type_cache" type="Dictionary" setter="_set_type_cache" getter="_get_type_cache"> - </member> </members> <constants> <constant name="CALL_MODE_SELF" value="0" enum="CallMode"> diff --git a/modules/visual_script/doc_classes/VisualScriptYield.xml b/modules/visual_script/doc_classes/VisualScriptYield.xml index b42fc027cf..72ef586c1f 100644 --- a/modules/visual_script/doc_classes/VisualScriptYield.xml +++ b/modules/visual_script/doc_classes/VisualScriptYield.xml @@ -9,10 +9,22 @@ <demos> </demos> <methods> + <method name="get_yield_mode"> + <return type="int" enum="VisualScriptYield.YieldMode"> + </return> + <description> + </description> + </method> + <method name="set_yield_mode"> + <return type="void"> + </return> + <argument index="0" name="mode" type="int" enum="VisualScriptYield.YieldMode"> + </argument> + <description> + </description> + </method> </methods> <members> - <member name="mode" type="int" setter="set_yield_mode" getter="get_yield_mode" enum="VisualScriptYield.YieldMode"> - </member> <member name="wait_time" type="float" setter="set_wait_time" getter="get_wait_time"> </member> </members> diff --git a/modules/visual_script/register_types.cpp b/modules/visual_script/register_types.cpp index b6ce10381d..ecdca7eb42 100644 --- a/modules/visual_script/register_types.cpp +++ b/modules/visual_script/register_types.cpp @@ -53,7 +53,7 @@ void register_visual_script_types() { ClassDB::register_class<VisualScript>(); ClassDB::register_virtual_class<VisualScriptNode>(); - ClassDB::register_virtual_class<VisualScriptFunctionState>(); + ClassDB::register_class<VisualScriptFunctionState>(); ClassDB::register_class<VisualScriptFunction>(); ClassDB::register_class<VisualScriptOperator>(); ClassDB::register_class<VisualScriptVariableSet>(); diff --git a/modules/visual_script/visual_script.cpp b/modules/visual_script/visual_script.cpp index 26f2d687d8..bb6c32e9e0 100644 --- a/modules/visual_script/visual_script.cpp +++ b/modules/visual_script/visual_script.cpp @@ -2289,7 +2289,7 @@ void VisualScriptFunctionState::connect_to_signal(Object *p_obj, const String &p binds.push_back(p_binds[i]); } binds.push_back(Ref<VisualScriptFunctionState>(this)); //add myself on the back to avoid dying from unreferencing - p_obj->connect(p_signal, this, "_signal_callback", binds); + p_obj->connect(p_signal, this, "_signal_callback", binds, CONNECT_ONESHOT); } bool VisualScriptFunctionState::is_valid() const { diff --git a/modules/visual_script/visual_script_flow_control.cpp b/modules/visual_script/visual_script_flow_control.cpp index 59d9540239..a38266acc0 100644 --- a/modules/visual_script/visual_script_flow_control.cpp +++ b/modules/visual_script/visual_script_flow_control.cpp @@ -731,9 +731,9 @@ void VisualScriptSwitch::_bind_methods() { VisualScriptSwitch::VisualScriptSwitch() { } -////////////////////////////////////////// -////////////////EVENT ACTION FILTER/////////// -////////////////////////////////////////// + ////////////////////////////////////////// + ////////////////EVENT ACTION FILTER/////////// + ////////////////////////////////////////// #if 0 int VisualScriptInputFilter::get_output_sequence_port_count() const { diff --git a/modules/webm/doc_classes/VideoStreamWebm.xml b/modules/webm/doc_classes/VideoStreamWebm.xml index 8b6696cfe9..6e8120b1de 100644 --- a/modules/webm/doc_classes/VideoStreamWebm.xml +++ b/modules/webm/doc_classes/VideoStreamWebm.xml @@ -9,11 +9,21 @@ <demos> </demos> <methods> + <method name="get_file"> + <return type="String"> + </return> + <description> + </description> + </method> + <method name="set_file"> + <return type="void"> + </return> + <argument index="0" name="file" type="String"> + </argument> + <description> + </description> + </method> </methods> - <members> - <member name="file" type="String" setter="set_file" getter="get_file"> - </member> - </members> <constants> </constants> </class> diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp index 0fc9df5b58..b055ccf5aa 100644 --- a/modules/webm/video_stream_webm.cpp +++ b/modules/webm/video_stream_webm.cpp @@ -92,21 +92,27 @@ private: /**/ -VideoStreamPlaybackWebm::VideoStreamPlaybackWebm() - : audio_track(0), - webm(NULL), - video(NULL), - audio(NULL), - video_frames(NULL), audio_frame(NULL), - video_frames_pos(0), video_frames_capacity(0), - num_decoded_samples(0), samples_offset(-1), - mix_callback(NULL), - mix_udata(NULL), - playing(false), paused(false), - delay_compensation(0.0), - time(0.0), video_frame_delay(0.0), video_pos(0.0), - texture(memnew(ImageTexture)), - pcm(NULL) {} +VideoStreamPlaybackWebm::VideoStreamPlaybackWebm() : + audio_track(0), + webm(NULL), + video(NULL), + audio(NULL), + video_frames(NULL), + audio_frame(NULL), + video_frames_pos(0), + video_frames_capacity(0), + num_decoded_samples(0), + samples_offset(-1), + mix_callback(NULL), + mix_udata(NULL), + playing(false), + paused(false), + delay_compensation(0.0), + time(0.0), + video_frame_delay(0.0), + video_pos(0.0), + texture(memnew(ImageTexture)), + pcm(NULL) {} VideoStreamPlaybackWebm::~VideoStreamPlaybackWebm() { delete_pointers(); @@ -403,8 +409,8 @@ void VideoStreamPlaybackWebm::delete_pointers() { /**/ -VideoStreamWebm::VideoStreamWebm() - : audio_track(0) {} +VideoStreamWebm::VideoStreamWebm() : + audio_track(0) {} Ref<VideoStreamPlayback> VideoStreamWebm::instance_playback() { diff --git a/platform/android/build.gradle.template b/platform/android/build.gradle.template index 11c49fbb50..4a44d1c5f9 100644 --- a/platform/android/build.gradle.template +++ b/platform/android/build.gradle.template @@ -31,7 +31,7 @@ android { disable 'MissingTranslation' } - compileSdkVersion 24 + compileSdkVersion 26 buildToolsVersion "26.0.1" useLibrary 'org.apache.http.legacy' diff --git a/platform/android/power_android.cpp b/platform/android/power_android.cpp index 48c9377a5a..54fb435b62 100644 --- a/platform/android/power_android.cpp +++ b/platform/android/power_android.cpp @@ -245,8 +245,10 @@ int power_android::get_power_percent_left() { } } -power_android::power_android() - : nsecs_left(-1), percent_left(-1), power_state(OS::POWERSTATE_UNKNOWN) { +power_android::power_android() : + nsecs_left(-1), + percent_left(-1), + power_state(OS::POWERSTATE_UNKNOWN) { } power_android::~power_android() { diff --git a/platform/haiku/haiku_application.cpp b/platform/haiku/haiku_application.cpp index d23b9e27d8..e2649b15a4 100644 --- a/platform/haiku/haiku_application.cpp +++ b/platform/haiku/haiku_application.cpp @@ -29,6 +29,6 @@ /*************************************************************************/ #include "haiku_application.h" -HaikuApplication::HaikuApplication() - : BApplication("application/x-vnd.godot") { +HaikuApplication::HaikuApplication() : + BApplication("application/x-vnd.godot") { } diff --git a/platform/haiku/haiku_direct_window.cpp b/platform/haiku/haiku_direct_window.cpp index 24a8a4b17b..aa25064ccb 100644 --- a/platform/haiku/haiku_direct_window.cpp +++ b/platform/haiku/haiku_direct_window.cpp @@ -34,8 +34,8 @@ #include "main/main.h" #include "os/keyboard.h" -HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) - : BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) { +HaikuDirectWindow::HaikuDirectWindow(BRect p_frame) : + BDirectWindow(p_frame, "Godot", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE) { last_mouse_pos_valid = false; last_buttons_state = 0; last_button_mask = 0; diff --git a/platform/haiku/haiku_gl_view.cpp b/platform/haiku/haiku_gl_view.cpp index d898bd1a5d..bb9c439e94 100644 --- a/platform/haiku/haiku_gl_view.cpp +++ b/platform/haiku/haiku_gl_view.cpp @@ -30,8 +30,8 @@ #include "haiku_gl_view.h" #include "main/main.h" -HaikuGLView::HaikuGLView(BRect frame, uint32 type) - : BGLView(frame, "GodotGLView", B_FOLLOW_ALL_SIDES, 0, type) { +HaikuGLView::HaikuGLView(BRect frame, uint32 type) : + BGLView(frame, "GodotGLView", B_FOLLOW_ALL_SIDES, 0, type) { } void HaikuGLView::AttachedToWindow(void) { diff --git a/platform/haiku/power_haiku.cpp b/platform/haiku/power_haiku.cpp index 8718b317a3..73d60e9fec 100644 --- a/platform/haiku/power_haiku.cpp +++ b/platform/haiku/power_haiku.cpp @@ -64,8 +64,10 @@ int PowerX11::get_power_percent_left() { } } -PowerHaiku::PowerHaiku() - : nsecs_left(-1), percent_left(-1), power_state(OS::POWERSTATE_UNKNOWN) { +PowerHaiku::PowerHaiku() : + nsecs_left(-1), + percent_left(-1), + power_state(OS::POWERSTATE_UNKNOWN) { } PowerHaiku::~PowerHaiku() { diff --git a/platform/iphone/app_delegate.mm b/platform/iphone/app_delegate.mm index 8f2893e69e..b591f80aa7 100644 --- a/platform/iphone/app_delegate.mm +++ b/platform/iphone/app_delegate.mm @@ -564,7 +564,7 @@ static int frame_count = 0; MainLoop::NOTIFICATION_OS_MEMORY_WARNING); }; -- (void)applicationDidFinishLaunching:(UIApplication *)application { +- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { printf("**************** app delegate init\n"); CGRect rect = [[UIScreen mainScreen] bounds]; @@ -671,6 +671,7 @@ static int frame_count = 0; isAdvertisingTrackingEnabled]]; #endif + return TRUE; }; - (void)applicationWillTerminate:(UIApplication *)application { diff --git a/platform/iphone/export/export.cpp b/platform/iphone/export/export.cpp index b05bb9ab09..1833bdf2b3 100644 --- a/platform/iphone/export/export.cpp +++ b/platform/iphone/export/export.cpp @@ -69,8 +69,9 @@ class EditorExportPlatformIOS : public EditorExportPlatform { String name; bool is_default; - ExportArchitecture() - : name(""), is_default(false) { + ExportArchitecture() : + name(""), + is_default(false) { } ExportArchitecture(String p_name, bool p_is_default) { @@ -453,8 +454,9 @@ struct CodesignData { const Ref<EditorExportPreset> &preset; bool debug; - CodesignData(const Ref<EditorExportPreset> &p_preset, bool p_debug) - : preset(p_preset), debug(p_debug) { + CodesignData(const Ref<EditorExportPreset> &p_preset, bool p_debug) : + preset(p_preset), + debug(p_debug) { } }; @@ -972,6 +974,7 @@ bool EditorExportPlatformIOS::can_export(const Ref<EditorExportPreset> &p_preset if (!err.empty()) r_error = err; + r_missing_templates = !valid; return valid; } diff --git a/platform/iphone/os_iphone.cpp b/platform/iphone/os_iphone.cpp index f06657cd7b..1c7f41b464 100644 --- a/platform/iphone/os_iphone.cpp +++ b/platform/iphone/os_iphone.cpp @@ -117,7 +117,7 @@ void OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_ */ visual_server->init(); - // visual_server->cursor_set_visible(false, 0); + //visual_server->cursor_set_visible(false, 0); // reset this to what it should be, it will have been set to 0 after visual_server->init() is called RasterizerStorageGLES3::system_fbo = gl_view_base_fb; @@ -127,14 +127,6 @@ void OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_ input = memnew(InputDefault); -/* -#ifdef IOS_SCORELOOP_ENABLED - scoreloop = memnew(ScoreloopIOS); - Engine::get_singleton()->add_singleton(Engine::Singleton("Scoreloop", scoreloop)); - scoreloop->connect(); -#endif - */ - #ifdef GAME_CENTER_ENABLED game_center = memnew(GameCenter); Engine::get_singleton()->add_singleton(Engine::Singleton("GameCenter", game_center)); @@ -149,7 +141,7 @@ void OSIPhone::initialize(const VideoMode &p_desired, int p_video_driver, int p_ #ifdef ICLOUD_ENABLED icloud = memnew(ICloud); Engine::get_singleton()->add_singleton(Engine::Singleton("ICloud", icloud)); -//icloud->connect(); + //icloud->connect(); #endif Engine::get_singleton()->add_singleton(Engine::Singleton("iOS", memnew(iOS))); }; diff --git a/platform/iphone/power_iphone.cpp b/platform/iphone/power_iphone.cpp index 055d31ef0a..03afdb15f9 100644 --- a/platform/iphone/power_iphone.cpp +++ b/platform/iphone/power_iphone.cpp @@ -58,8 +58,10 @@ int PowerIphone::get_power_percent_left() { } } -PowerIphone::PowerIphone() - : nsecs_left(-1), percent_left(-1), power_state(OS::POWERSTATE_UNKNOWN) { +PowerIphone::PowerIphone() : + nsecs_left(-1), + percent_left(-1), + power_state(OS::POWERSTATE_UNKNOWN) { // TODO Auto-generated constructor stub } diff --git a/platform/javascript/dom_keys.h b/platform/javascript/dom_keys.h index d63f165382..bd15cec603 100644 --- a/platform/javascript/dom_keys.h +++ b/platform/javascript/dom_keys.h @@ -262,7 +262,7 @@ int dom2godot_scancode(int dom_keycode) { case DOM_VK_CAPS_LOCK: return KEY_CAPSLOCK; - /* + /* case DOM_VK_KANA: return KEY_UNKNOWN; case DOM_VK_HANGUL: return KEY_UNKNOWN; case DOM_VK_EISU: return KEY_UNKNOWN; @@ -274,7 +274,7 @@ int dom2godot_scancode(int dom_keycode) { case DOM_VK_ESCAPE: return KEY_ESCAPE; - /* + /* case DOM_VK_CONVERT: return KEY_UNKNOWN; case DOM_VK_NONCONVERT: return KEY_UNKNOWN; case DOM_VK_ACCEPT: return KEY_UNKNOWN; @@ -292,7 +292,7 @@ int dom2godot_scancode(int dom_keycode) { case DOM_VK_DOWN: return KEY_DOWN; - //case DOM_VK_SELECT: return KEY_UNKNOWN; + //case DOM_VK_SELECT: return KEY_UNKNOWN; case DOM_VK_PRINTSCREEN: // this is the usual printScreen key case DOM_VK_PRINT: // maybe for alt+printScreen or physical printers? @@ -320,7 +320,7 @@ int dom2godot_scancode(int dom_keycode) { case DOM_VK_DIVIDE: return KEY_KP_DIVIDE; - /* + /* case DOM_VK_F17: return KEY_UNKNOWN; case DOM_VK_F18: return KEY_UNKNOWN; case DOM_VK_F19: return KEY_UNKNOWN; @@ -335,7 +335,7 @@ int dom2godot_scancode(int dom_keycode) { case DOM_VK_SCROLL_LOCK: return KEY_SCROLLLOCK; - /* + /* case DOM_VK_WIN_OEM_FJ_JISHO: return KEY_UNKNOWN; case DOM_VK_WIN_OEM_FJ_MASSHOU: return KEY_UNKNOWN; case DOM_VK_WIN_OEM_FJ_TOUROKU: return KEY_UNKNOWN; @@ -375,7 +375,7 @@ int dom2godot_scancode(int dom_keycode) { case DOM_VK_QUOTE: return KEY_APOSTROPHE; - // rest is OEM/unusual + // rest is OEM/unusual default: return KEY_UNKNOWN; }; diff --git a/platform/javascript/power_javascript.cpp b/platform/javascript/power_javascript.cpp index 10964502d4..54fceb75f4 100644 --- a/platform/javascript/power_javascript.cpp +++ b/platform/javascript/power_javascript.cpp @@ -63,8 +63,10 @@ int PowerJavascript::get_power_percent_left() { } } -PowerJavascript::PowerJavascript() - : nsecs_left(-1), percent_left(-1), power_state(OS::POWERSTATE_UNKNOWN) { +PowerJavascript::PowerJavascript() : + nsecs_left(-1), + percent_left(-1), + power_state(OS::POWERSTATE_UNKNOWN) { } PowerJavascript::~PowerJavascript() { diff --git a/platform/osx/export/export.cpp b/platform/osx/export/export.cpp index 8091a38adb..d3b763b42e 100644 --- a/platform/osx/export/export.cpp +++ b/platform/osx/export/export.cpp @@ -605,6 +605,7 @@ bool EditorExportPlatformOSX::can_export(const Ref<EditorExportPreset> &p_preset if (!err.empty()) r_error = err; + r_missing_templates = !valid; return valid; } diff --git a/platform/osx/os_osx.mm b/platform/osx/os_osx.mm index 732ec910c0..6cc8be250d 100644 --- a/platform/osx/os_osx.mm +++ b/platform/osx/os_osx.mm @@ -1028,7 +1028,7 @@ void OS_OSX::initialize(const VideoMode &p_desired, int p_video_driver, int p_au // OS X needs non-zero color size, so set resonable values int colorBits = 32; -// Fail if a robustness strategy was requested + // Fail if a robustness strategy was requested #define ADD_ATTR(x) \ { attributes[attributeCount++] = x; } diff --git a/platform/osx/power_osx.cpp b/platform/osx/power_osx.cpp index eed03e63c1..bd5f9fe65f 100644 --- a/platform/osx/power_osx.cpp +++ b/platform/osx/power_osx.cpp @@ -242,8 +242,10 @@ int power_osx::get_power_percent_left() { } } -power_osx::power_osx() - : nsecs_left(-1), percent_left(-1), power_state(OS::POWERSTATE_UNKNOWN) { +power_osx::power_osx() : + nsecs_left(-1), + percent_left(-1), + power_state(OS::POWERSTATE_UNKNOWN) { } power_osx::~power_osx() { diff --git a/platform/uwp/app.cpp b/platform/uwp/app.cpp index c565999d82..b47b99744e 100644 --- a/platform/uwp/app.cpp +++ b/platform/uwp/app.cpp @@ -77,15 +77,15 @@ public: return 0; } -App::App() - : mWindowClosed(false), - mWindowVisible(true), - mWindowWidth(0), - mWindowHeight(0), - mEglDisplay(EGL_NO_DISPLAY), - mEglContext(EGL_NO_CONTEXT), - mEglSurface(EGL_NO_SURFACE), - number_of_contacts(0) { +App::App() : + mWindowClosed(false), + mWindowVisible(true), + mWindowWidth(0), + mWindowHeight(0), + mEglDisplay(EGL_NO_DISPLAY), + mEglContext(EGL_NO_CONTEXT), + mEglSurface(EGL_NO_SURFACE), + number_of_contacts(0) { } // The first method called when the IFrameworkView is being created. diff --git a/platform/uwp/gl_context_egl.cpp b/platform/uwp/gl_context_egl.cpp index dafe5d5e25..2130af6d60 100644 --- a/platform/uwp/gl_context_egl.cpp +++ b/platform/uwp/gl_context_egl.cpp @@ -108,7 +108,8 @@ Error ContextEGL::initialize() { EGL_NONE,*/ // These are the default display attributes, used to request ANGLE's D3D11 renderer. // eglInitialize will only succeed with these attributes if the hardware supports D3D11 Feature Level 10_0+. - EGL_PLATFORM_ANGLE_TYPE_ANGLE, EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, + EGL_PLATFORM_ANGLE_TYPE_ANGLE, + EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE, // EGL_ANGLE_DISPLAY_ALLOW_RENDER_TO_BACK_BUFFER is an optimization that can have large performance benefits on mobile devices. // Its syntax is subject to change, though. Please update your Visual Studio templates if you experience compilation issues with it. @@ -117,7 +118,8 @@ Error ContextEGL::initialize() { // EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE is an option that enables ANGLE to automatically call // the IDXGIDevice3::Trim method on behalf of the application when it gets suspended. // Calling IDXGIDevice3::Trim when an application is suspended is a Windows Store application certification requirement. - EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, EGL_TRUE, + EGL_PLATFORM_ANGLE_ENABLE_AUTOMATIC_TRIM_ANGLE, + EGL_TRUE, EGL_NONE, }; @@ -190,10 +192,10 @@ void ContextEGL::cleanup() { } }; -ContextEGL::ContextEGL(CoreWindow ^ p_window) - : mEglDisplay(EGL_NO_DISPLAY), - mEglContext(EGL_NO_CONTEXT), - mEglSurface(EGL_NO_SURFACE) { +ContextEGL::ContextEGL(CoreWindow ^ p_window) : + mEglDisplay(EGL_NO_DISPLAY), + mEglContext(EGL_NO_CONTEXT), + mEglSurface(EGL_NO_SURFACE) { window = p_window; }; diff --git a/platform/uwp/joypad_uwp.cpp b/platform/uwp/joypad_uwp.cpp index 0f84bd55a3..088d232e04 100644 --- a/platform/uwp/joypad_uwp.cpp +++ b/platform/uwp/joypad_uwp.cpp @@ -54,7 +54,7 @@ void JoypadUWP::process_controllers() { case ControllerType::GAMEPAD_CONTROLLER: { - GamepadReading reading = ((Gamepad ^)joy.controller_reference)->GetCurrentReading(); + GamepadReading reading = ((Gamepad ^) joy.controller_reference)->GetCurrentReading(); int button_mask = (int)GamepadButtons::Menu; for (int j = 0; j < 14; j++) { @@ -161,7 +161,7 @@ void JoypadUWP::joypad_vibration_start(int p_device, float p_weak_magnitude, flo GamepadVibration vibration; vibration.LeftMotor = p_strong_magnitude; vibration.RightMotor = p_weak_magnitude; - ((Gamepad ^)joy.controller_reference)->Vibration = vibration; + ((Gamepad ^) joy.controller_reference)->Vibration = vibration; joy.ff_timestamp = p_timestamp; joy.ff_end_timestamp = p_duration == 0 ? 0 : p_timestamp + (uint64_t)(p_duration * 1000000.0); @@ -175,7 +175,7 @@ void JoypadUWP::joypad_vibration_stop(int p_device, uint64_t p_timestamp) { GamepadVibration vibration; vibration.LeftMotor = 0.0; vibration.RightMotor = 0.0; - ((Gamepad ^)joy.controller_reference)->Vibration = vibration; + ((Gamepad ^) joy.controller_reference)->Vibration = vibration; joy.ff_timestamp = p_timestamp; joy.vibrating = false; diff --git a/platform/uwp/power_uwp.cpp b/platform/uwp/power_uwp.cpp index 81e97b1391..14fce8b133 100644 --- a/platform/uwp/power_uwp.cpp +++ b/platform/uwp/power_uwp.cpp @@ -30,8 +30,10 @@ #include "power_uwp.h" -PowerUWP::PowerUWP() - : nsecs_left(-1), percent_left(-1), power_state(OS::POWERSTATE_UNKNOWN) { +PowerUWP::PowerUWP() : + nsecs_left(-1), + percent_left(-1), + power_state(OS::POWERSTATE_UNKNOWN) { } PowerUWP::~PowerUWP() { diff --git a/platform/windows/crash_handler_win.cpp b/platform/windows/crash_handler_win.cpp index feea3911b2..5657036693 100644 --- a/platform/windows/crash_handler_win.cpp +++ b/platform/windows/crash_handler_win.cpp @@ -61,8 +61,8 @@ class symbol { static const int max_name_len = 1024; public: - symbol(HANDLE process, DWORD64 address) - : sym((sym_type *)::operator new(sizeof(*sym) + max_name_len)) { + symbol(HANDLE process, DWORD64 address) : + sym((sym_type *)::operator new(sizeof(*sym) + max_name_len)) { memset(sym, '\0', sizeof(*sym) + max_name_len); sym->SizeOfStruct = sizeof(*sym); sym->MaxNameLength = max_name_len; @@ -85,8 +85,8 @@ class get_mod_info { HANDLE process; public: - get_mod_info(HANDLE h) - : process(h) {} + get_mod_info(HANDLE h) : + process(h) {} module_data operator()(HMODULE module) { module_data ret; diff --git a/platform/windows/detect.py b/platform/windows/detect.py index fbb02c9d1b..d85e1b061c 100644 --- a/platform/windows/detect.py +++ b/platform/windows/detect.py @@ -64,6 +64,10 @@ def get_opts(): return [ ('mingw_prefix_32', 'MinGW prefix (Win32)', mingw32), ('mingw_prefix_64', 'MinGW prefix (Win64)', mingw64), + # Targeted Windows version: 7 (and later), minimum supported version + # XP support dropped after EOL due to missing API for IPv6 and other issues + # Vista support dropped after EOL due to GH-10243 + ('target_win_version', 'Targeted Windows version, >= 0x0601 (Windows 7)', '0x0601'), EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')), ] @@ -97,11 +101,6 @@ def configure(env): env.Append(CPPPATH=['#platform/windows']) - # Targeted Windows version: 7 (and later), minimum supported version - # XP support dropped after EOL due to missing API for IPv6 and other issues - # Vista support dropped after EOL due to GH-10243 - winver = "0x0601" - if (os.name == "nt" and os.getenv("VCINSTALLDIR")): # MSVC env['ENV']['TMP'] = os.environ['TMP'] @@ -175,7 +174,7 @@ def configure(env): env.Append(CCFLAGS=['/DWASAPI_ENABLED']) env.Append(CCFLAGS=['/DTYPED_METHOD_BIND']) env.Append(CCFLAGS=['/DWIN32']) - env.Append(CCFLAGS=['/DWINVER=%s' % winver, '/D_WIN32_WINNT=%s' % winver]) + env.Append(CCFLAGS=['/DWINVER=%s' % env['target_win_version'], '/D_WIN32_WINNT=%s' % env['target_win_version']]) if env["bits"] == "64": env.Append(CCFLAGS=['/D_WIN64']) @@ -271,7 +270,7 @@ def configure(env): env.Append(CCFLAGS=['-DOPENGL_ENABLED']) env.Append(CCFLAGS=['-DRTAUDIO_ENABLED']) env.Append(CCFLAGS=['-DWASAPI_ENABLED']) - env.Append(CCFLAGS=['-DWINVER=%s' % winver, '-D_WIN32_WINNT=%s' % winver]) + env.Append(CCFLAGS=['-DWINVER=%s' % env['target_win_version'], '-D_WIN32_WINNT=%s' % env['target_win_version']]) env.Append(LIBS=['mingw32', 'opengl32', 'dsound', 'ole32', 'd3d9', 'winmm', 'gdi32', 'iphlpapi', 'shlwapi', 'wsock32', 'ws2_32', 'kernel32', 'oleaut32', 'dinput8', 'dxguid', 'ksuser']) env.Append(CPPFLAGS=['-DMINGW_ENABLED']) diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp index 9bcbb6ddb6..79a760f055 100644 --- a/platform/windows/os_windows.cpp +++ b/platform/windows/os_windows.cpp @@ -73,22 +73,17 @@ static String format_error_message(DWORD id) { LPWSTR messageBuffer = NULL; size_t size = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, - NULL, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, NULL); + NULL, id, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&messageBuffer, 0, NULL); - String msg = "Error "+itos(id)+": "+String(messageBuffer,size); + String msg = "Error " + itos(id) + ": " + String(messageBuffer, size); LocalFree(messageBuffer); return msg; - } - - extern HINSTANCE godot_hinstance; - - void RedirectIOToConsole() { int hConHandle; @@ -228,7 +223,17 @@ bool OS_Windows::can_draw() const { #define SIGNATURE_MASK 0xFFFFFF00 #define IsPenEvent(dw) (((dw)&SIGNATURE_MASK) == MI_WP_SIGNATURE) -void OS_Windows::_touch_event(bool p_pressed, int p_x, int p_y, int idx) { +void OS_Windows::_touch_event(bool p_pressed, float p_x, float p_y, int idx) { + + // Defensive + if (touch_state.has(idx) == p_pressed) + return; + + if (p_pressed) { + touch_state.insert(idx, Vector2(p_x, p_y)); + } else { + touch_state.erase(idx); + } Ref<InputEventScreenTouch> event; event.instance(); @@ -241,7 +246,17 @@ void OS_Windows::_touch_event(bool p_pressed, int p_x, int p_y, int idx) { } }; -void OS_Windows::_drag_event(int p_x, int p_y, int idx) { +void OS_Windows::_drag_event(float p_x, float p_y, int idx) { + + Map<int, Vector2>::Element *curr = touch_state.find(idx); + // Defensive + if (!curr) + return; + + if (curr->get() == Vector2(p_x, p_y)) + return; + + curr->get() = Vector2(p_x, p_y); Ref<InputEventScreenDrag> event; event.instance(); @@ -271,6 +286,13 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if (mouse_mode == MOUSE_MODE_CAPTURED || mouse_mode == MOUSE_MODE_CONFINED) { ReleaseCapture(); } + + // Release every touch to avoid sticky points + for (Map<int, Vector2>::Element *E = touch_state.front(); E; E = E->next()) { + _touch_event(false, E->get().x, E->get().y, E->key()); + } + touch_state.clear(); + break; } case WM_ACTIVATE: // Watch For Window Activate Message @@ -674,7 +696,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) print_line("input lang change"); } break; -#if WINVER >= 0x0601 // for windows 7 case WM_TOUCH: { BOOL bHandled = FALSE; @@ -687,10 +708,10 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) //do something with each touch input entry if (ti.dwFlags & TOUCHEVENTF_MOVE) { - _drag_event(ti.x / 100, ti.y / 100, ti.dwID); + _drag_event(ti.x / 100.0f, ti.y / 100.0f, ti.dwID); } else if (ti.dwFlags & (TOUCHEVENTF_UP | TOUCHEVENTF_DOWN)) { - _touch_event(ti.dwFlags & TOUCHEVENTF_DOWN != 0, ti.x / 100, ti.y / 100, ti.dwID); + _touch_event(ti.dwFlags & TOUCHEVENTF_DOWN, ti.x / 100.0f, ti.y / 100.0f, ti.dwID); }; } bHandled = TRUE; @@ -708,7 +729,6 @@ LRESULT OS_Windows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } break; -#endif case WM_DEVICECHANGE: { joypad->probe_joypads(); @@ -1092,7 +1112,7 @@ void OS_Windows::initialize(const VideoMode &p_desired, int p_video_driver, int tme.dwHoverTime = HOVER_DEFAULT; TrackMouseEvent(&tme); - //RegisterTouchWindow(hWnd, 0); // Windows 7 + RegisterTouchWindow(hWnd, 0); _ensure_user_data_dir(); @@ -1206,6 +1226,7 @@ void OS_Windows::finalize() { memdelete(joypad); memdelete(input); + touch_state.clear(); visual_server->finish(); memdelete(visual_server); @@ -1608,17 +1629,23 @@ void OS_Windows::_update_window_style(bool repaint) { Error OS_Windows::open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path) { + typedef DLL_DIRECTORY_COOKIE(WINAPI * PAddDllDirectory)(PCWSTR); + typedef BOOL(WINAPI * PRemoveDllDirectory)(DLL_DIRECTORY_COOKIE); + + PAddDllDirectory add_dll_directory = (PAddDllDirectory)GetProcAddress(GetModuleHandle("kernel32.dll"), "AddDllDirectory"); + PRemoveDllDirectory remove_dll_directory = (PRemoveDllDirectory)GetProcAddress(GetModuleHandle("kernel32.dll"), "RemoveDllDirectory"); + bool has_dll_directory_api = ((add_dll_directory != NULL) && (remove_dll_directory != NULL)); DLL_DIRECTORY_COOKIE cookie; - if (p_also_set_library_path) { - cookie = AddDllDirectory(p_path.get_base_dir().c_str()); + if (p_also_set_library_path && has_dll_directory_api) { + cookie = add_dll_directory(p_path.get_base_dir().c_str()); } - p_library_handle = (void *)LoadLibraryExW(p_path.c_str(), NULL, p_also_set_library_path ? LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : 0); + p_library_handle = (void *)LoadLibraryExW(p_path.c_str(), NULL, (p_also_set_library_path && has_dll_directory_api) ? LOAD_LIBRARY_SEARCH_DEFAULT_DIRS : 0); - if (p_also_set_library_path) { - RemoveDllDirectory(cookie); + if (p_also_set_library_path && has_dll_directory_api) { + remove_dll_directory(cookie); } if (!p_library_handle) { diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h index e98f8277df..af1ccd4446 100644 --- a/platform/windows/os_windows.h +++ b/platform/windows/os_windows.h @@ -117,6 +117,7 @@ class OS_Windows : public OS { InputDefault *input; JoypadWindows *joypad; + Map<int, Vector2> touch_state; PowerWindows *power_manager; @@ -132,8 +133,8 @@ class OS_Windows : public OS { CrashHandler crash_handler; - void _drag_event(int p_x, int p_y, int idx); - void _touch_event(bool p_pressed, int p_x, int p_y, int idx); + void _drag_event(float p_x, float p_y, int idx); + void _touch_event(bool p_pressed, float p_x, float p_y, int idx); void _update_window_style(bool repaint = true); @@ -212,7 +213,7 @@ public: virtual void set_borderless_window(int p_borderless); virtual bool get_borderless_window(); - virtual Error open_dynamic_library(const String p_path, void *&p_library_handle,bool p_also_set_library_path=false); + virtual Error open_dynamic_library(const String p_path, void *&p_library_handle, bool p_also_set_library_path = false); virtual Error close_dynamic_library(void *p_library_handle); virtual Error get_dynamic_library_symbol_handle(void *p_library_handle, const String p_name, void *&p_symbol_handle, bool p_optional = false); diff --git a/platform/windows/power_windows.cpp b/platform/windows/power_windows.cpp index 8d86f160f1..cc452d774d 100644 --- a/platform/windows/power_windows.cpp +++ b/platform/windows/power_windows.cpp @@ -121,8 +121,10 @@ int PowerWindows::get_power_percent_left() { } } -PowerWindows::PowerWindows() - : nsecs_left(-1), percent_left(-1), power_state(OS::POWERSTATE_UNKNOWN) { +PowerWindows::PowerWindows() : + nsecs_left(-1), + percent_left(-1), + power_state(OS::POWERSTATE_UNKNOWN) { } PowerWindows::~PowerWindows() { diff --git a/platform/x11/context_gl_x11.cpp b/platform/x11/context_gl_x11.cpp index 4f9d4a84b9..61c6b3c9dd 100644 --- a/platform/x11/context_gl_x11.cpp +++ b/platform/x11/context_gl_x11.cpp @@ -228,8 +228,8 @@ bool ContextGL_X11::is_using_vsync() const { return use_vsync; } -ContextGL_X11::ContextGL_X11(::Display *p_x11_display, ::Window &p_x11_window, const OS::VideoMode &p_default_video_mode, bool p_opengl_3_context) - : x11_window(p_x11_window) { +ContextGL_X11::ContextGL_X11(::Display *p_x11_display, ::Window &p_x11_window, const OS::VideoMode &p_default_video_mode, bool p_opengl_3_context) : + x11_window(p_x11_window) { default_video_mode = p_default_video_mode; x11_display = p_x11_display; diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 3d07851c4f..d7dbe71da4 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -55,6 +55,7 @@ def get_opts(): BoolVariable('pulseaudio', 'Detect & use pulseaudio', True), BoolVariable('udev', 'Use udev for gamepad connection callbacks', False), EnumVariable('debug_symbols', 'Add debug symbols to release version', 'yes', ('yes', 'no', 'full')), + BoolVariable('touch', 'Enable touch events', True), ] @@ -141,6 +142,14 @@ def configure(env): env.ParseConfig('pkg-config xinerama --cflags --libs') env.ParseConfig('pkg-config xrandr --cflags --libs') + if (env['touch']): + x11_error = os.system("pkg-config xi --modversion > /dev/null ") + if (x11_error): + print("xi not found.. cannot build with touch. Aborting.") + sys.exit(255) + env.ParseConfig('pkg-config xi --cflags --libs') + env.Append(CPPFLAGS=['-DTOUCH_ENABLED']) + # FIXME: Check for existence of the libs before parsing their flags with pkg-config if not env['builtin_openssl']: diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index d1aa129e77..c210a03688 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -132,10 +132,9 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au // Try to support IME if detectable auto-repeat is supported if (xkb_dar == True) { -// Xutf8LookupString will be used later instead of XmbLookupString before -// the multibyte sequences can be converted to unicode string. - #ifdef X_HAVE_UTF8_STRING + // Xutf8LookupString will be used later instead of XmbLookupString before + // the multibyte sequences can be converted to unicode string. modifiers = XSetLocaleModifiers(""); #endif } @@ -178,6 +177,50 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au } } +#ifdef TOUCH_ENABLED + if (!XQueryExtension(x11_display, "XInputExtension", &touch.opcode, &event_base, &error_base)) { + fprintf(stderr, "XInput extension not available"); + } else { + // 2.2 is the first release with multitouch + int xi_major = 2; + int xi_minor = 2; + if (XIQueryVersion(x11_display, &xi_major, &xi_minor) != Success) { + fprintf(stderr, "XInput 2.2 not available (server supports %d.%d)\n", xi_major, xi_minor); + touch.opcode = 0; + } else { + int dev_count; + XIDeviceInfo *info = XIQueryDevice(x11_display, XIAllDevices, &dev_count); + + for (int i = 0; i < dev_count; i++) { + XIDeviceInfo *dev = &info[i]; + if (!dev->enabled) + continue; + /*if (dev->use != XIMasterPointer) + continue;*/ + + bool direct_touch = false; + for (int j = 0; j < dev->num_classes; j++) { + if (dev->classes[j]->type == XITouchClass && ((XITouchClassInfo *)dev->classes[j])->mode == XIDirectTouch) { + direct_touch = true; + printf("%d) %d %s\n", i, dev->attachment, dev->name); + break; + } + } + if (direct_touch) { + touch.devices.push_back(dev->deviceid); + fprintf(stderr, "Using touch device: %s\n", dev->name); + } + } + + XIFreeDeviceInfo(info); + + if (!touch.devices.size()) { + fprintf(stderr, "No suitable touch device found\n"); + } + } + } +#endif + xim = XOpenIM(x11_display, NULL, NULL, NULL); if (xim == NULL) { @@ -308,6 +351,32 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au XChangeWindowAttributes(x11_display, x11_window, CWEventMask, &new_attr); +#ifdef TOUCH_ENABLED + if (touch.devices.size()) { + + // Must be alive after this block + static unsigned char mask_data[XIMaskLen(XI_LASTEVENT)] = {}; + + touch.event_mask.deviceid = XIAllMasterDevices; + touch.event_mask.mask_len = sizeof(mask_data); + touch.event_mask.mask = mask_data; + + XISetMask(touch.event_mask.mask, XI_TouchBegin); + XISetMask(touch.event_mask.mask, XI_TouchUpdate); + XISetMask(touch.event_mask.mask, XI_TouchEnd); + XISetMask(touch.event_mask.mask, XI_TouchOwnership); + + XISelectEvents(x11_display, x11_window, &touch.event_mask, 1); + + XIClearMask(touch.event_mask.mask, XI_TouchOwnership); + + // Grab touch devices to avoid OS gesture interference + for (int i = 0; i < touch.devices.size(); ++i) { + XIGrabDevice(x11_display, touch.devices[i], x11_window, CurrentTime, None, XIGrabModeAsync, XIGrabModeAsync, False, &touch.event_mask); + } + } +#endif + /* set the titlebar name */ XStoreName(x11_display, x11_window, "Godot"); @@ -478,7 +547,7 @@ void OS_X11::finalize() { memdelete(main_loop); main_loop = NULL; -/* + /* if (debugger_connection_console) { memdelete(debugger_connection_console); } @@ -487,6 +556,10 @@ void OS_X11::finalize() { #ifdef JOYDEV_ENABLED memdelete(joypad); #endif +#ifdef TOUCH_ENABLED + touch.devices.clear(); + touch.state.clear(); +#endif memdelete(input); visual_server->finish(); @@ -1435,6 +1508,69 @@ void OS_X11::process_xevents() { continue; } +#ifdef TOUCH_ENABLED + if (XGetEventData(x11_display, &event.xcookie)) { + + if (event.xcookie.extension == touch.opcode) { + + XIDeviceEvent *event_data = (XIDeviceEvent *)event.xcookie.data; + int index = event_data->detail; + Vector2 pos = Vector2(event_data->event_x, event_data->event_y); + + switch (event_data->evtype) { + + case XI_TouchBegin: // Fall-through + XIAllowTouchEvents(x11_display, event_data->deviceid, event_data->detail, x11_window, XIAcceptTouch); + + case XI_TouchEnd: { + + bool is_begin = event_data->evtype == XI_TouchBegin; + + Ref<InputEventScreenTouch> st; + st.instance(); + st->set_index(index); + st->set_position(pos); + st->set_pressed(is_begin); + + if (is_begin) { + if (touch.state.has(index)) // Defensive + break; + touch.state[index] = pos; + input->parse_input_event(st); + } else { + if (!touch.state.has(index)) // Defensive + break; + touch.state.erase(index); + input->parse_input_event(st); + } + } break; + + case XI_TouchUpdate: { + + Map<int, Vector2>::Element *curr_pos_elem = touch.state.find(index); + if (!curr_pos_elem) { // Defensive + break; + } + + if (curr_pos_elem->value() != pos) { + + Ref<InputEventScreenDrag> sd; + sd.instance(); + sd->set_index(index); + sd->set_position(pos); + sd->set_relative(pos - curr_pos_elem->value()); + input->parse_input_event(sd); + + curr_pos_elem->value() = pos; + } + } break; + } + } + + XFreeEventData(x11_display, &event.xcookie); + } +#endif + switch (event.type) { case Expose: Main::force_redraw(); @@ -1477,6 +1613,12 @@ void OS_X11::process_xevents() { ButtonPressMask | ButtonReleaseMask | PointerMotionMask, GrabModeAsync, GrabModeAsync, x11_window, None, CurrentTime); } +#ifdef TOUCH_ENABLED + // Grab touch devices to avoid OS gesture interference + for (int i = 0; i < touch.devices.size(); ++i) { + XIGrabDevice(x11_display, touch.devices[i], x11_window, CurrentTime, None, XIGrabModeAsync, XIGrabModeAsync, False, &touch.event_mask); + } +#endif if (xic) { XSetICFocus(xic); } @@ -1493,6 +1635,23 @@ void OS_X11::process_xevents() { } XUngrabPointer(x11_display, CurrentTime); } +#ifdef TOUCH_ENABLED + // Ungrab touch devices so input works as usual while we are unfocused + for (int i = 0; i < touch.devices.size(); ++i) { + XIUngrabDevice(x11_display, touch.devices[i], CurrentTime); + } + + // Release every pointer to avoid sticky points + for (Map<int, Vector2>::Element *E = touch.state.front(); E; E = E->next()) { + + Ref<InputEventScreenTouch> st; + st.instance(); + st->set_index(E->key()); + st->set_position(E->get()); + input->parse_input_event(st); + } + touch.state.clear(); +#endif if (xic) { XUnsetICFocus(xic); } diff --git a/platform/x11/os_x11.h b/platform/x11/os_x11.h index a74e6ee5f3..84dff2e089 100644 --- a/platform/x11/os_x11.h +++ b/platform/x11/os_x11.h @@ -48,6 +48,9 @@ #include <X11/Xlib.h> #include <X11/extensions/Xrandr.h> #include <X11/keysym.h> +#ifdef TOUCH_ENABLED +#include <X11/extensions/XInput2.h> +#endif // Hints for X11 fullscreen typedef struct { @@ -117,6 +120,14 @@ class OS_X11 : public OS_Unix { Point2i last_click_pos; uint64_t last_click_ms; uint32_t last_button_state; +#ifdef TOUCH_ENABLED + struct { + int opcode; + Vector<int> devices; + XIEventMask event_mask; + Map<int, Vector2> state; + } touch; +#endif unsigned int get_mouse_button_state(unsigned int p_x11_state); void get_key_modifier_state(unsigned int p_x11_state, Ref<InputEventWithModifiers> state); diff --git a/platform/x11/power_x11.cpp b/platform/x11/power_x11.cpp index 76ff7f91fb..0ef2629cb0 100644 --- a/platform/x11/power_x11.cpp +++ b/platform/x11/power_x11.cpp @@ -542,8 +542,10 @@ bool PowerX11::UpdatePowerInfo() { return false; } -PowerX11::PowerX11() - : nsecs_left(-1), percent_left(-1), power_state(OS::POWERSTATE_UNKNOWN) { +PowerX11::PowerX11() : + nsecs_left(-1), + percent_left(-1), + power_state(OS::POWERSTATE_UNKNOWN) { } PowerX11::~PowerX11() { diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 4865858b7d..f8f94926b7 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -568,7 +568,7 @@ void AnimatedSprite::stop() { bool AnimatedSprite::is_playing() const { - return is_processing(); + return playing; } void AnimatedSprite::_reset_timeout() { diff --git a/scene/2d/area_2d.cpp b/scene/2d/area_2d.cpp index 9ee77a710c..80f9bf0f9f 100644 --- a/scene/2d/area_2d.cpp +++ b/scene/2d/area_2d.cpp @@ -688,8 +688,8 @@ void Area2D::_bind_methods() { BIND_ENUM_CONSTANT(SPACE_OVERRIDE_REPLACE_COMBINE); } -Area2D::Area2D() - : CollisionObject2D(Physics2DServer::get_singleton()->area_create(), true) { +Area2D::Area2D() : + CollisionObject2D(Physics2DServer::get_singleton()->area_create(), true) { space_override = SPACE_OVERRIDE_DISABLED; set_gravity(98); diff --git a/scene/2d/canvas_item.cpp b/scene/2d/canvas_item.cpp index 66abe1baa8..768d5185d7 100644 --- a/scene/2d/canvas_item.cpp +++ b/scene/2d/canvas_item.cpp @@ -184,6 +184,11 @@ RID CanvasItemMaterial::get_shader_rid() const { return shader_map[current_key].shader; } +Shader::Mode CanvasItemMaterial::get_shader_mode() const { + + return Shader::MODE_CANVAS_ITEM; +} + void CanvasItemMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_blend_mode", "blend_mode"), &CanvasItemMaterial::set_blend_mode); @@ -206,8 +211,8 @@ void CanvasItemMaterial::_bind_methods() { BIND_ENUM_CONSTANT(LIGHT_MODE_LIGHT_ONLY); } -CanvasItemMaterial::CanvasItemMaterial() - : element(this) { +CanvasItemMaterial::CanvasItemMaterial() : + element(this) { blend_mode = BLEND_MODE_MIX; light_mode = LIGHT_MODE_NORMAL; @@ -1126,8 +1131,8 @@ Rect2 CanvasItem::_edit_get_item_and_children_rect() const { return rect; } -CanvasItem::CanvasItem() - : xform_change(this) { +CanvasItem::CanvasItem() : + xform_change(this) { canvas_item = VisualServer::get_singleton()->canvas_item_create(); visible = true; diff --git a/scene/2d/canvas_item.h b/scene/2d/canvas_item.h index c877a94755..ccbb528d6f 100644 --- a/scene/2d/canvas_item.h +++ b/scene/2d/canvas_item.h @@ -123,6 +123,8 @@ public: RID get_shader_rid() const; + virtual Shader::Mode get_shader_mode() const; + CanvasItemMaterial(); virtual ~CanvasItemMaterial(); }; diff --git a/scene/2d/line_2d.cpp b/scene/2d/line_2d.cpp index 9131223ff3..57a0e15447 100644 --- a/scene/2d/line_2d.cpp +++ b/scene/2d/line_2d.cpp @@ -37,8 +37,8 @@ VARIANT_ENUM_CAST(Line2D::LineJointMode) VARIANT_ENUM_CAST(Line2D::LineCapMode) VARIANT_ENUM_CAST(Line2D::LineTextureMode) -Line2D::Line2D() - : Node2D() { +Line2D::Line2D() : + Node2D() { _joint_mode = LINE_JOINT_SHARP; _begin_cap_mode = LINE_CAP_NONE; _end_cap_mode = LINE_CAP_NONE; diff --git a/scene/2d/navigation2d.h b/scene/2d/navigation2d.h index e87b01f7c5..bb97e1a9a9 100644 --- a/scene/2d/navigation2d.h +++ b/scene/2d/navigation2d.h @@ -57,9 +57,9 @@ class Navigation2D : public Node2D { return (a.key == p_key.a.key) ? (b.key < p_key.b.key) : (a.key < p_key.a.key); }; - EdgeKey(const Point &p_a = Point(), const Point &p_b = Point()) - : a(p_a), - b(p_b) { + EdgeKey(const Point &p_a = Point(), const Point &p_b = Point()) : + a(p_a), + b(p_b) { if (a.key > b.key) { SWAP(a, b); } diff --git a/scene/2d/particles_2d.cpp b/scene/2d/particles_2d.cpp index aee5d89150..7d53557216 100644 --- a/scene/2d/particles_2d.cpp +++ b/scene/2d/particles_2d.cpp @@ -291,7 +291,7 @@ void Particles2D::_notification(int p_what) { texture_rid = texture->get_rid(); RID normal_rid; if (normal_map.is_valid()) - normal_rid = texture->get_rid(); + normal_rid = normal_map->get_rid(); VS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid, h_frames, v_frames); diff --git a/scene/2d/physics_body_2d.cpp b/scene/2d/physics_body_2d.cpp index 1f6127e6eb..a1a1101b11 100644 --- a/scene/2d/physics_body_2d.cpp +++ b/scene/2d/physics_body_2d.cpp @@ -132,8 +132,8 @@ bool PhysicsBody2D::get_collision_layer_bit(int p_bit) const { return get_collision_layer() & (1 << p_bit); } -PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) - : CollisionObject2D(Physics2DServer::get_singleton()->body_create(), false) { +PhysicsBody2D::PhysicsBody2D(Physics2DServer::BodyMode p_mode) : + CollisionObject2D(Physics2DServer::get_singleton()->body_create(), false) { Physics2DServer::get_singleton()->body_set_mode(get_rid(), p_mode); collision_layer = 1; @@ -226,8 +226,8 @@ void StaticBody2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "bounce", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_bounce", "get_bounce"); } -StaticBody2D::StaticBody2D() - : PhysicsBody2D(Physics2DServer::BODY_MODE_STATIC) { +StaticBody2D::StaticBody2D() : + PhysicsBody2D(Physics2DServer::BODY_MODE_STATIC) { constant_angular_velocity = 0; bounce = 0; @@ -921,8 +921,8 @@ void RigidBody2D::_bind_methods() { BIND_ENUM_CONSTANT(CCD_MODE_CAST_SHAPE); } -RigidBody2D::RigidBody2D() - : PhysicsBody2D(Physics2DServer::BODY_MODE_RIGID) { +RigidBody2D::RigidBody2D() : + PhysicsBody2D(Physics2DServer::BODY_MODE_RIGID) { mode = MODE_RIGID; @@ -1144,8 +1144,8 @@ void KinematicBody2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision/safe_margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_safe_margin", "get_safe_margin"); } -KinematicBody2D::KinematicBody2D() - : PhysicsBody2D(Physics2DServer::BODY_MODE_KINEMATIC) { +KinematicBody2D::KinematicBody2D() : + PhysicsBody2D(Physics2DServer::BODY_MODE_KINEMATIC) { margin = 0.08; diff --git a/scene/2d/tile_map.h b/scene/2d/tile_map.h index 8eecf48df2..edc9de0543 100644 --- a/scene/2d/tile_map.h +++ b/scene/2d/tile_map.h @@ -147,8 +147,8 @@ private: navpoly_ids = q.navpoly_ids; occluder_instances = q.occluder_instances; } - Quadrant(const Quadrant &q) - : dirty_list(this) { + Quadrant(const Quadrant &q) : + dirty_list(this) { pos = q.pos; canvas_items = q.canvas_items; body = q.body; @@ -156,8 +156,8 @@ private: occluder_instances = q.occluder_instances; navpoly_ids = q.navpoly_ids; } - Quadrant() - : dirty_list(this) {} + Quadrant() : + dirty_list(this) {} }; Map<PosKey, Quadrant> quadrant_map; diff --git a/scene/3d/area.cpp b/scene/3d/area.cpp index 266bc5e381..422aa556f9 100644 --- a/scene/3d/area.cpp +++ b/scene/3d/area.cpp @@ -737,8 +737,8 @@ void Area::_bind_methods() { BIND_ENUM_CONSTANT(SPACE_OVERRIDE_REPLACE_COMBINE); } -Area::Area() - : CollisionObject(PhysicsServer::get_singleton()->area_create(), true) { +Area::Area() : + CollisionObject(PhysicsServer::get_singleton()->area_create(), true) { space_override = SPACE_OVERRIDE_DISABLED; set_gravity(9.8); diff --git a/scene/3d/camera.cpp b/scene/3d/camera.cpp index abc4a03498..af210fff1c 100644 --- a/scene/3d/camera.cpp +++ b/scene/3d/camera.cpp @@ -191,11 +191,12 @@ void Camera::_update_camera() { get_viewport()->_camera_transform_changed_notify(); */ - if (is_inside_tree() && is_current()) { - get_viewport()->_camera_transform_changed_notify(); - } + if (!is_inside_tree() || get_tree()->is_node_being_edited(this) || !is_current()) + return; + + get_viewport()->_camera_transform_changed_notify(); - if (is_current() && get_world().is_valid()) { + if (get_world().is_valid()) { get_world()->_update_camera(this); } } diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 2754d56a05..8e2f87738a 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -410,7 +410,7 @@ static bool planeBoxOverlap(Vector3 normal, float d, Vector3 maxbox) { rad = fa * boxhalfsize.x + fb * boxhalfsize.z; \ if (min > rad || max < -rad) return false; -/*======================== Z-tests ========================*/ + /*======================== Z-tests ========================*/ #define AXISTEST_Z12(a, b, fa, fb) \ p1 = a * v1.x - b * v1.y; \ diff --git a/scene/3d/light.cpp b/scene/3d/light.cpp index 126c07f0be..1fc4e932e8 100644 --- a/scene/3d/light.cpp +++ b/scene/3d/light.cpp @@ -367,8 +367,8 @@ void DirectionalLight::_bind_methods() { BIND_ENUM_CONSTANT(SHADOW_DEPTH_RANGE_OPTIMIZED); } -DirectionalLight::DirectionalLight() - : Light(VisualServer::LIGHT_DIRECTIONAL) { +DirectionalLight::DirectionalLight() : + Light(VisualServer::LIGHT_DIRECTIONAL) { set_param(PARAM_SHADOW_NORMAL_BIAS, 0.8); set_param(PARAM_SHADOW_BIAS, 0.1); @@ -422,8 +422,8 @@ void OmniLight::_bind_methods() { BIND_ENUM_CONSTANT(SHADOW_DETAIL_HORIZONTAL); } -OmniLight::OmniLight() - : Light(VisualServer::LIGHT_OMNI) { +OmniLight::OmniLight() : + Light(VisualServer::LIGHT_OMNI) { set_shadow_mode(SHADOW_CUBE); set_shadow_detail(SHADOW_DETAIL_HORIZONTAL); diff --git a/scene/3d/light.h b/scene/3d/light.h index 8514b429ec..33e62214b1 100644 --- a/scene/3d/light.h +++ b/scene/3d/light.h @@ -208,8 +208,8 @@ protected: static void _bind_methods(); public: - SpotLight() - : Light(VisualServer::LIGHT_SPOT) {} + SpotLight() : + Light(VisualServer::LIGHT_SPOT) {} }; #endif diff --git a/scene/3d/navigation.h b/scene/3d/navigation.h index 010d16dedd..d9a38f7b00 100644 --- a/scene/3d/navigation.h +++ b/scene/3d/navigation.h @@ -58,9 +58,9 @@ class Navigation : public Spatial { return (a.key == p_key.a.key) ? (b.key < p_key.b.key) : (a.key < p_key.a.key); }; - EdgeKey(const Point &p_a = Point(), const Point &p_b = Point()) - : a(p_a), - b(p_b) { + EdgeKey(const Point &p_a = Point(), const Point &p_b = Point()) : + a(p_a), + b(p_b) { if (a.key > b.key) { SWAP(a, b); } diff --git a/scene/3d/particles.cpp b/scene/3d/particles.cpp index 2a032f5d96..c137b7e8ff 100644 --- a/scene/3d/particles.cpp +++ b/scene/3d/particles.cpp @@ -703,10 +703,13 @@ void ParticlesMaterial::_update_shader() { else code += " float tex_linear_velocity = 0.0;\n"; - if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid()) - code += " float tex_orbit_velocity = textureLod(orbit_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; - else - code += " float tex_orbit_velocity = 0.0;\n"; + if (flags[FLAG_DISABLE_Z]) { + + if (tex_parameters[PARAM_ORBIT_VELOCITY].is_valid()) + code += " float tex_orbit_velocity = textureLod(orbit_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; + else + code += " float tex_orbit_velocity = 0.0;\n"; + } if (tex_parameters[PARAM_ANGULAR_VELOCITY].is_valid()) code += " float tex_angular_velocity = textureLod(angular_velocity_texture,vec2(CUSTOM.y,0.0),0.0).r;\n"; @@ -756,7 +759,7 @@ void ParticlesMaterial::_update_shader() { code += " //apply linear acceleration\n"; code += " force += length(VELOCITY) > 0.0 ? normalize(VELOCITY) * (linear_accel+tex_linear_accel)*mix(1.0,rand_from_seed(alt_seed),linear_accel_random) : vec3(0.0);\n"; code += " //apply radial acceleration\n"; - code += " vec3 org = vec3(0.0);\n"; + code += " vec3 org = EMISSION_TRANSFORM[3].xyz;\n"; code += " vec3 diff = pos-org;\n"; code += " force += length(diff) > 0.0 ? normalize(diff) * (radial_accel+tex_radial_accel)*mix(1.0,rand_from_seed(alt_seed),radial_accel_random) : vec3(0.0);\n"; code += " //apply tangential acceleration;\n"; @@ -769,6 +772,18 @@ void ParticlesMaterial::_update_shader() { } code += " //apply attractor forces\n"; code += " VELOCITY += force * DELTA;\n"; + code += " //orbit velocity\n"; + if (flags[FLAG_DISABLE_Z]) { + + code += " float orbit_amount = (orbit_velocity+tex_orbit_velocity)*mix(1.0,rand_from_seed(alt_seed),orbit_velocity_random);\n"; + code += " if (orbit_amount!=0.0) {\n"; + code += " float ang = orbit_amount * DELTA * 3.1416 * 2.0;\n"; + code += " mat2 rot = mat2(vec2(cos(ang),-sin(ang)),vec2(sin(ang),cos(ang)));\n"; + code += " TRANSFORM[3].xy-=diff.xy;\n"; + code += " TRANSFORM[3].xy+=rot * diff.xy;\n"; + code += " }\n"; + } + if (tex_parameters[PARAM_INITIAL_LINEAR_VELOCITY].is_valid()) { code += " VELOCITY = normalize(VELOCITY)*tex_linear_velocity;\n"; } @@ -869,6 +884,7 @@ void ParticlesMaterial::_update_shader() { } //scale by scale code += " float base_scale = mix(scale*tex_scale,1.0,scale_random*scale_rand);\n"; + code += " if (base_scale==0.0) base_scale=0.000001;\n"; if (trail_size_modifier.is_valid()) { code += " if (trail_divisor > 1) { base_scale *= textureLod(trail_size_modifier,vec2(float(int(NUMBER)%trail_divisor)/float(trail_divisor-1),0.0),0.0).r; } \n"; } @@ -1173,6 +1189,9 @@ void ParticlesMaterial::set_flag(Flags p_flag, bool p_enable) { ERR_FAIL_INDEX(p_flag, FLAG_MAX); flags[p_flag] = p_enable; _queue_shader_change(); + if (p_flag==FLAG_DISABLE_Z) { + _change_notify(); + } } bool ParticlesMaterial::get_flag(Flags p_flag) const { @@ -1358,6 +1377,15 @@ void ParticlesMaterial::_validate_property(PropertyInfo &property) const { if (property.name == "emission_point_count" && (emission_shape != EMISSION_SHAPE_POINTS && emission_shape != EMISSION_SHAPE_DIRECTED_POINTS)) { property.usage = 0; } + + if (property.name.begins_with("orbit_") && !flags[FLAG_DISABLE_Z]) { + property.usage=0; + } +} + +Shader::Mode ParticlesMaterial::get_shader_mode() const { + + return Shader::MODE_PARTICLES; } void ParticlesMaterial::_bind_methods() { @@ -1517,8 +1545,8 @@ void ParticlesMaterial::_bind_methods() { BIND_ENUM_CONSTANT(EMISSION_SHAPE_DIRECTED_POINTS); } -ParticlesMaterial::ParticlesMaterial() - : element(this) { +ParticlesMaterial::ParticlesMaterial() : + element(this) { set_spread(45); set_flatness(0); diff --git a/scene/3d/particles.h b/scene/3d/particles.h index 30080360bb..5b8121e937 100644 --- a/scene/3d/particles.h +++ b/scene/3d/particles.h @@ -390,6 +390,8 @@ public: RID get_shader_rid() const; + virtual Shader::Mode get_shader_mode() const; + ParticlesMaterial(); ~ParticlesMaterial(); }; diff --git a/scene/3d/physics_body.cpp b/scene/3d/physics_body.cpp index 4e06b272e2..f2f00bb617 100644 --- a/scene/3d/physics_body.cpp +++ b/scene/3d/physics_body.cpp @@ -166,8 +166,8 @@ void PhysicsBody::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "collision_mask", PROPERTY_HINT_LAYERS_3D_PHYSICS), "set_collision_mask", "get_collision_mask"); } -PhysicsBody::PhysicsBody(PhysicsServer::BodyMode p_mode) - : CollisionObject(PhysicsServer::get_singleton()->body_create(p_mode), false) { +PhysicsBody::PhysicsBody(PhysicsServer::BodyMode p_mode) : + CollisionObject(PhysicsServer::get_singleton()->body_create(p_mode), false) { collision_layer = 1; collision_mask = 1; @@ -241,8 +241,8 @@ void StaticBody::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "constant_angular_velocity"), "set_constant_angular_velocity", "get_constant_angular_velocity"); } -StaticBody::StaticBody() - : PhysicsBody(PhysicsServer::BODY_MODE_STATIC) { +StaticBody::StaticBody() : + PhysicsBody(PhysicsServer::BODY_MODE_STATIC) { bounce = 0; friction = 1; @@ -881,8 +881,8 @@ void RigidBody::_bind_methods() { BIND_ENUM_CONSTANT(AXIS_LOCK_Z); } -RigidBody::RigidBody() - : PhysicsBody(PhysicsServer::BODY_MODE_RIGID) { +RigidBody::RigidBody() : + PhysicsBody(PhysicsServer::BODY_MODE_RIGID) { mode = MODE_RIGID; @@ -1104,8 +1104,8 @@ void KinematicBody::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "collision/safe_margin", PROPERTY_HINT_RANGE, "0.001,256,0.001"), "set_safe_margin", "get_safe_margin"); } -KinematicBody::KinematicBody() - : PhysicsBody(PhysicsServer::BODY_MODE_KINEMATIC) { +KinematicBody::KinematicBody() : + PhysicsBody(PhysicsServer::BODY_MODE_KINEMATIC) { margin = 0.001; diff --git a/scene/3d/spatial.cpp b/scene/3d/spatial.cpp index 588aa2881a..d9f88ac693 100644 --- a/scene/3d/spatial.cpp +++ b/scene/3d/spatial.cpp @@ -756,8 +756,8 @@ void Spatial::_bind_methods() { ADD_SIGNAL(MethodInfo("visibility_changed")); } -Spatial::Spatial() - : xform_change(this) { +Spatial::Spatial() : + xform_change(this) { data.dirty = DIRTY_NONE; data.children_lock = 0; diff --git a/scene/3d/vehicle_body.cpp b/scene/3d/vehicle_body.cpp index a072572142..2e3e179a7b 100644 --- a/scene/3d/vehicle_body.cpp +++ b/scene/3d/vehicle_body.cpp @@ -54,8 +54,8 @@ public: const Vector3 &inertiaInvA, const real_t massInvA, const Vector3 &inertiaInvB, - const real_t massInvB) - : m_linearJointAxis(jointAxis) { + const real_t massInvB) : + m_linearJointAxis(jointAxis) { m_aJ = world2A.xform(rel_pos1.cross(m_linearJointAxis)); m_bJ = world2B.xform(rel_pos2.cross(-m_linearJointAxis)); m_0MinvJt = inertiaInvA * m_aJ; @@ -593,12 +593,12 @@ void VehicleBody::_resolve_single_bilateral(PhysicsDirectBodyState *s, const Vec #endif } -VehicleBody::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirectBodyState *s, PhysicsBody *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse) - : m_s(s), - m_body1(body1), - m_frictionPositionWorld(frictionPosWorld), - m_frictionDirectionWorld(frictionDirectionWorld), - m_maxImpulse(maxImpulse) { +VehicleBody::btVehicleWheelContactPoint::btVehicleWheelContactPoint(PhysicsDirectBodyState *s, PhysicsBody *body1, const Vector3 &frictionPosWorld, const Vector3 &frictionDirectionWorld, real_t maxImpulse) : + m_s(s), + m_body1(body1), + m_frictionPositionWorld(frictionPosWorld), + m_frictionDirectionWorld(frictionDirectionWorld), + m_maxImpulse(maxImpulse) { float denom0 = 0; float denom1 = 0; @@ -969,8 +969,8 @@ void VehicleBody::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "friction", PROPERTY_HINT_RANGE, "0.01,1,0.01"), "set_friction", "get_friction"); } -VehicleBody::VehicleBody() - : PhysicsBody(PhysicsServer::BODY_MODE_RIGID) { +VehicleBody::VehicleBody() : + PhysicsBody(PhysicsServer::BODY_MODE_RIGID) { m_pitchControl = 0; m_currentVehicleSpeedKmHour = real_t(0.); diff --git a/scene/animation/animation_player.cpp b/scene/animation/animation_player.cpp index 206f3ccca2..f3e750d0da 100644 --- a/scene/animation/animation_player.cpp +++ b/scene/animation/animation_player.cpp @@ -1324,7 +1324,9 @@ void AnimationPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("get_root"), &AnimationPlayer::get_root); ClassDB::bind_method(D_METHOD("seek", "seconds", "update"), &AnimationPlayer::seek, DEFVAL(false)); - ClassDB::bind_method(D_METHOD("get_position"), &AnimationPlayer::get_current_animation_position); + ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationPlayer::advance); + ClassDB::bind_method(D_METHOD("get_anim_position"), &AnimationPlayer::get_current_animation_position); + ClassDB::bind_method(D_METHOD("get_anim_length"), &AnimationPlayer::get_current_animation_length); ClassDB::bind_method(D_METHOD("find_animation", "animation"), &AnimationPlayer::find_animation); @@ -1333,15 +1335,15 @@ void AnimationPlayer::_bind_methods() { ClassDB::bind_method(D_METHOD("set_animation_process_mode", "mode"), &AnimationPlayer::set_animation_process_mode); ClassDB::bind_method(D_METHOD("get_animation_process_mode"), &AnimationPlayer::get_animation_process_mode); - ClassDB::bind_method(D_METHOD("get_current_animation_position"), &AnimationPlayer::get_current_animation_position); - ClassDB::bind_method(D_METHOD("get_current_animation_length"), &AnimationPlayer::get_current_animation_length); - - ClassDB::bind_method(D_METHOD("advance", "delta"), &AnimationPlayer::advance); - ADD_GROUP("Playback Options", "playback_"); ADD_PROPERTY(PropertyInfo(Variant::INT, "playback_process_mode", PROPERTY_HINT_ENUM, "Physics,Idle"), "set_animation_process_mode", "get_animation_process_mode"); ADD_PROPERTY(PropertyInfo(Variant::REAL, "playback_default_blend_time", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_default_blend_time", "get_default_blend_time"); + ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "root_node"), "set_root", "get_root"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "autoplay"), "set_autoplay", "get_autoplay"); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "speed_scale"), "set_speed_scale", "get_speed_scale"); + ADD_PROPERTY(PropertyInfo(Variant::BOOL, "active"), "set_active", "is_active"); + ADD_PROPERTY(PropertyInfo(Variant::STRING, "current_anim"), "set_current_anim", "get_current_anim"); ADD_SIGNAL(MethodInfo("animation_finished", PropertyInfo(Variant::STRING, "name"))); ADD_SIGNAL(MethodInfo("animation_changed", PropertyInfo(Variant::STRING, "old_name"), PropertyInfo(Variant::STRING, "new_name"))); diff --git a/scene/animation/tween_interpolaters.cpp b/scene/animation/tween_interpolaters.cpp index 8f543a575a..cbf941f3ed 100644 --- a/scene/animation/tween_interpolaters.cpp +++ b/scene/animation/tween_interpolaters.cpp @@ -50,7 +50,7 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { static real_t out_in(real_t t, real_t b, real_t c, real_t d) { return c * t / d + b; } -}; +}; // namespace linear /////////////////////////////////////////////////////////////////////////// // sine /////////////////////////////////////////////////////////////////////////// @@ -70,7 +70,7 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { static real_t out_in(real_t t, real_t b, real_t c, real_t d) { return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); } -}; +}; // namespace sine /////////////////////////////////////////////////////////////////////////// // quint /////////////////////////////////////////////////////////////////////////// @@ -92,7 +92,7 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { static real_t out_in(real_t t, real_t b, real_t c, real_t d) { return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); } -}; +}; // namespace quint /////////////////////////////////////////////////////////////////////////// // quart /////////////////////////////////////////////////////////////////////////// @@ -114,7 +114,7 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { static real_t out_in(real_t t, real_t b, real_t c, real_t d) { return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); } -}; +}; // namespace quart /////////////////////////////////////////////////////////////////////////// // quad /////////////////////////////////////////////////////////////////////////// @@ -137,7 +137,7 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { static real_t out_in(real_t t, real_t b, real_t c, real_t d) { return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); } -}; +}; // namespace quad /////////////////////////////////////////////////////////////////////////// // expo /////////////////////////////////////////////////////////////////////////// @@ -163,7 +163,7 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { static real_t out_in(real_t t, real_t b, real_t c, real_t d) { return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); } -}; +}; // namespace expo /////////////////////////////////////////////////////////////////////////// // elastic /////////////////////////////////////////////////////////////////////////// @@ -205,7 +205,7 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { static real_t out_in(real_t t, real_t b, real_t c, real_t d) { return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); } -}; +}; // namespace elastic /////////////////////////////////////////////////////////////////////////// // cubic /////////////////////////////////////////////////////////////////////////// @@ -227,7 +227,7 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { static real_t out_in(real_t t, real_t b, real_t c, real_t d) { return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); } -}; +}; // namespace cubic /////////////////////////////////////////////////////////////////////////// // circ /////////////////////////////////////////////////////////////////////////// @@ -248,7 +248,7 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { static real_t out_in(real_t t, real_t b, real_t c, real_t d) { return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); } -}; +}; // namespace circ /////////////////////////////////////////////////////////////////////////// // bounce /////////////////////////////////////////////////////////////////////////// @@ -281,7 +281,7 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { static real_t out_in(real_t t, real_t b, real_t c, real_t d) { return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); } -}; +}; // namespace bounce /////////////////////////////////////////////////////////////////////////// // back /////////////////////////////////////////////////////////////////////////// @@ -307,7 +307,7 @@ static real_t in_out(real_t t, real_t b, real_t c, real_t d) { static real_t out_in(real_t t, real_t b, real_t c, real_t d) { return (t < d / 2) ? out(t * 2, b, c / 2, d) : in((t * 2) - d, b + c / 2, c / 2, d); } -}; +}; // namespace back Tween::interpolater Tween::interpolaters[Tween::TRANS_COUNT][Tween::EASE_COUNT] = { { &linear::in, &linear::out, &linear::in_out, &linear::out_in }, diff --git a/scene/gui/box_container.h b/scene/gui/box_container.h index 4d00a2011f..ebbbbed1f9 100644 --- a/scene/gui/box_container.h +++ b/scene/gui/box_container.h @@ -70,8 +70,8 @@ class HBoxContainer : public BoxContainer { GDCLASS(HBoxContainer, BoxContainer); public: - HBoxContainer() - : BoxContainer(false) {} + HBoxContainer() : + BoxContainer(false) {} }; class MarginContainer; @@ -82,8 +82,8 @@ class VBoxContainer : public BoxContainer { public: MarginContainer *add_margin_child(const String &p_label, Control *p_control, bool p_expand = false); - VBoxContainer() - : BoxContainer(true) {} + VBoxContainer() : + BoxContainer(true) {} }; VARIANT_ENUM_CAST(BoxContainer::AlignMode); diff --git a/scene/gui/check_box.cpp b/scene/gui/check_box.cpp index e2b10a948f..00f6153062 100644 --- a/scene/gui/check_box.cpp +++ b/scene/gui/check_box.cpp @@ -56,8 +56,8 @@ bool CheckBox::is_radio() { return get_button_group().is_valid(); } -CheckBox::CheckBox(const String &p_text) - : Button(p_text) { +CheckBox::CheckBox(const String &p_text) : + Button(p_text) { set_toggle_mode(true); set_text_align(ALIGN_LEFT); } diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index dbd7c1bbc0..cb6283507e 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -486,8 +486,8 @@ void ColorPicker::_bind_methods() { ADD_SIGNAL(MethodInfo("color_changed", PropertyInfo(Variant::COLOR, "color"))); } -ColorPicker::ColorPicker() - : BoxContainer(true) { +ColorPicker::ColorPicker() : + BoxContainer(true) { updating = true; edit_alpha = true; @@ -664,11 +664,16 @@ ColorPicker *ColorPickerButton::get_picker() { return picker; } +PopupPanel *ColorPickerButton::get_popup() { + return popup; +} + void ColorPickerButton::_bind_methods() { ClassDB::bind_method(D_METHOD("set_pick_color", "color"), &ColorPickerButton::set_pick_color); ClassDB::bind_method(D_METHOD("get_pick_color"), &ColorPickerButton::get_pick_color); ClassDB::bind_method(D_METHOD("get_picker"), &ColorPickerButton::get_picker); + ClassDB::bind_method(D_METHOD("get_popup"), &ColorPickerButton::get_popup); ClassDB::bind_method(D_METHOD("set_edit_alpha", "show"), &ColorPickerButton::set_edit_alpha); ClassDB::bind_method(D_METHOD("is_editing_alpha"), &ColorPickerButton::is_editing_alpha); ClassDB::bind_method(D_METHOD("_color_changed"), &ColorPickerButton::_color_changed); diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index 7de67a707c..c02cdc8608 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -130,6 +130,7 @@ public: bool is_editing_alpha() const; ColorPicker *get_picker(); + PopupPanel *get_popup(); ColorPickerButton(); }; diff --git a/scene/gui/line_edit.cpp b/scene/gui/line_edit.cpp index f7bf1cd9ea..85ae6d6241 100644 --- a/scene/gui/line_edit.cpp +++ b/scene/gui/line_edit.cpp @@ -1046,6 +1046,10 @@ void LineEdit::set_cursor_position(int p_pos) { } else if (cursor_pos > window_pos) { /* Adjust window if cursor goes too much to the right */ int window_width = get_size().width - style->get_minimum_size().width; + if (has_icon("right_icon")) { + Ref<Texture> r_icon = Control::get_icon("right_icon"); + window_width -= r_icon->get_width(); + } if (window_width < 0) return; diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp index f3711b86b6..4ee6f93c9a 100644 --- a/scene/gui/popup_menu.cpp +++ b/scene/gui/popup_menu.cpp @@ -202,10 +202,10 @@ void PopupMenu::_activate_submenu(int over) { void PopupMenu::_submenu_timeout() { - if (mouse_over == submenu_over) { + if (mouse_over == submenu_over) _activate_submenu(mouse_over); - submenu_over = -1; - } + + submenu_over = -1; } void PopupMenu::_gui_input(const Ref<InputEvent> &p_event) { diff --git a/scene/gui/scroll_bar.h b/scene/gui/scroll_bar.h index 373483a8a0..753bd35de7 100644 --- a/scene/gui/scroll_bar.h +++ b/scene/gui/scroll_bar.h @@ -117,8 +117,8 @@ class HScrollBar : public ScrollBar { GDCLASS(HScrollBar, ScrollBar); public: - HScrollBar() - : ScrollBar(HORIZONTAL) { set_v_size_flags(0); } + HScrollBar() : + ScrollBar(HORIZONTAL) { set_v_size_flags(0); } }; class VScrollBar : public ScrollBar { @@ -126,8 +126,8 @@ class VScrollBar : public ScrollBar { GDCLASS(VScrollBar, ScrollBar); public: - VScrollBar() - : ScrollBar(VERTICAL) { set_h_size_flags(0); } + VScrollBar() : + ScrollBar(VERTICAL) { set_h_size_flags(0); } }; #endif diff --git a/scene/gui/slider.h b/scene/gui/slider.h index a2334a69fc..95ae429d63 100644 --- a/scene/gui/slider.h +++ b/scene/gui/slider.h @@ -77,8 +77,8 @@ class HSlider : public Slider { GDCLASS(HSlider, Slider); public: - HSlider() - : Slider(HORIZONTAL) { set_v_size_flags(0); } + HSlider() : + Slider(HORIZONTAL) { set_v_size_flags(0); } }; class VSlider : public Slider { @@ -86,8 +86,8 @@ class VSlider : public Slider { GDCLASS(VSlider, Slider); public: - VSlider() - : Slider(VERTICAL) { set_h_size_flags(0); } + VSlider() : + Slider(VERTICAL) { set_h_size_flags(0); } }; #endif // SLIDER_H diff --git a/scene/gui/split_container.h b/scene/gui/split_container.h index 8ec21b5eaa..c7a484c4c5 100644 --- a/scene/gui/split_container.h +++ b/scene/gui/split_container.h @@ -87,8 +87,8 @@ class HSplitContainer : public SplitContainer { GDCLASS(HSplitContainer, SplitContainer); public: - HSplitContainer() - : SplitContainer(false) { set_default_cursor_shape(CURSOR_HSPLIT); } + HSplitContainer() : + SplitContainer(false) { set_default_cursor_shape(CURSOR_HSPLIT); } }; class VSplitContainer : public SplitContainer { @@ -96,8 +96,8 @@ class VSplitContainer : public SplitContainer { GDCLASS(VSplitContainer, SplitContainer); public: - VSplitContainer() - : SplitContainer(true) { set_default_cursor_shape(CURSOR_VSPLIT); } + VSplitContainer() : + SplitContainer(true) { set_default_cursor_shape(CURSOR_VSPLIT); } }; #endif // SPLIT_CONTAINER_H diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 6fa73e4b58..7ff85716a5 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -251,13 +251,14 @@ void TextEdit::Text::clear() { insert(0, ""); } -int TextEdit::Text::get_max_width() const { +int TextEdit::Text::get_max_width(bool p_exclude_hidden) const { //quite some work.. but should be fast enough. int max = 0; - - for (int i = 0; i < text.size(); i++) - max = MAX(max, get_line_width(i)); + for (int i = 0; i < text.size(); i++) { + if (!p_exclude_hidden || !is_hidden(i)) + max = MAX(max, get_line_width(i)); + } return max; } @@ -307,7 +308,7 @@ void TextEdit::_update_scrollbars() { int vscroll_pixels = v_scroll->get_combined_minimum_size().width; int visible_width = size.width - cache.style_normal->get_minimum_size().width; - int total_width = text.get_max_width() + vmin.x; + int total_width = text.get_max_width(true) + vmin.x; if (line_numbers) total_width += cache.line_number_w; @@ -360,6 +361,7 @@ void TextEdit::_update_scrollbars() { } } else { + cursor.line_ofs = 0; line_scroll_pos = 0; v_scroll->set_value(0); @@ -371,12 +373,16 @@ void TextEdit::_update_scrollbars() { h_scroll->show(); h_scroll->set_max(total_width); h_scroll->set_page(visible_width); + if (cursor.x_ofs > (total_width - visible_width)) + cursor.x_ofs = (total_width - visible_width); if (fabs(h_scroll->get_value() - (double)cursor.x_ofs) >= 1) { h_scroll->set_value(cursor.x_ofs); } } else { + cursor.x_ofs = 0; + h_scroll->set_value(0); h_scroll->hide(); } @@ -594,6 +600,12 @@ void TextEdit::_notification(int p_what) { int xmargin_end = cache.size.width - cache.style_normal->get_margin(MARGIN_RIGHT); //let's do it easy for now: cache.style_normal->draw(ci, Rect2(Point2(), cache.size)); + float readonly_alpha = 1.0; // used to set the input text color when in read-only mode + if (readonly) { + cache.style_readonly->draw(ci, Rect2(Point2(), cache.size)); + readonly_alpha = .5; + draw_caret = false; + } if (has_focus()) cache.style_focus->draw(ci, Rect2(Point2(), cache.size)); @@ -604,6 +616,8 @@ void TextEdit::_notification(int p_what) { int tab_w = cache.font->get_char_size(' ').width * indent_size; Color color = cache.font_color; + color.a *= readonly_alpha; + int in_region = -1; if (syntax_coloring) { @@ -823,10 +837,16 @@ void TextEdit::_notification(int p_what) { int char_margin = xmargin_beg - cursor.x_ofs; int char_ofs = 0; - int ofs_y = (i * get_row_height() + cache.line_spacing / 2); - if (smooth_scroll_enabled) { - ofs_y -= (v_scroll->get_value() - get_line_scroll_pos()) * get_row_height(); + + int ofs_readonly = 0; + int ofs_x = 0; + if (readonly) { + ofs_readonly = cache.style_readonly->get_offset().y / 2; + ofs_x = cache.style_readonly->get_offset().x / 2; } + int ofs_y = (i * get_row_height() + cache.line_spacing / 2) + ofs_readonly; + if (smooth_scroll_enabled) + ofs_y -= ((v_scroll->get_value() - get_line_scroll_pos()) * get_row_height()); bool prev_is_char = false; bool prev_is_number = false; @@ -852,27 +872,32 @@ void TextEdit::_notification(int p_what) { if (text.is_marked(line)) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.mark_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.mark_color); } if (str.length() == 0) { // draw line background if empty as we won't loop at at all if (line == cursor.line && highlight_current_line) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, xmargin_end, get_row_height()), cache.current_line_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, get_row_height()), cache.current_line_color); } // give visual indication of empty selected line if (selection.active && line >= selection.from_line && line <= selection.to_line) { int char_w = cache.font->get_char_size(' ').width; - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y, char_w, get_row_height()), cache.selection_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, char_w, get_row_height()), cache.selection_color); + } + } else { + // if it has text, then draw current line marker in the margin, as line number ect will draw over it, draw the rest of line marker later. + if (line == cursor.line && highlight_current_line) { + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, xmargin_beg, get_row_height()), cache.current_line_color); } } if (text.is_breakpoint(line) && !draw_breakpoint_gutter) { #ifdef TOOLS_ENABLED - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.breakpoint_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y + get_row_height() - EDSCALE, xmargin_end - xmargin_beg, EDSCALE), cache.breakpoint_color); #else - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.breakpoint_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(xmargin_beg + ofs_x, ofs_y, xmargin_end - xmargin_beg, get_row_height()), cache.breakpoint_color); #endif } @@ -895,11 +920,11 @@ void TextEdit::_notification(int p_what) { if (is_folded(line)) { int xofs = horizontal_gap - (cache.can_fold_icon->get_width()) / 2; int yofs = (get_row_height() - cache.folded_icon->get_height()) / 2; - cache.folded_icon->draw(ci, Point2(gutter_left + xofs, ofs_y + yofs), Color(0.8f, 0.8f, 0.8f, 0.8f)); + cache.folded_icon->draw(ci, Point2(gutter_left + xofs + ofs_x, ofs_y + yofs), cache.code_folding_color); } else if (can_fold(line)) { int xofs = -cache.can_fold_icon->get_width() / 2 - horizontal_gap + 3; int yofs = (get_row_height() - cache.can_fold_icon->get_height()) / 2; - cache.can_fold_icon->draw(ci, Point2(gutter_left + xofs, ofs_y + yofs), Color(0.8f, 0.8f, 0.8f, 0.8f)); + cache.can_fold_icon->draw(ci, Point2(gutter_left + xofs + ofs_x, ofs_y + yofs), cache.code_folding_color); } } @@ -909,7 +934,7 @@ void TextEdit::_notification(int p_what) { fc = line_num_padding + fc; } - cache.font->draw(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + cache.breakpoint_gutter_width, ofs_y + cache.font->get_ascent()), fc, cache.line_number_color); + cache.font->draw(ci, Point2(cache.style_normal->get_margin(MARGIN_LEFT) + cache.breakpoint_gutter_width + ofs_x, ofs_y + cache.font->get_ascent()), fc, cache.line_number_color); } //loop through charcters in one line for (int j = 0; j < str.length(); j++) { @@ -924,6 +949,7 @@ void TextEdit::_notification(int p_what) { if (syntax_coloring && deregion == 0) { color = cache.font_color; //reset + color.a *= readonly_alpha; //find keyword bool is_char = _is_text_char(str[j]); bool is_symbol = _is_symbol(str[j]); @@ -1105,34 +1131,30 @@ void TextEdit::_notification(int p_what) { bool in_selection = (selection.active && line >= selection.from_line && line <= selection.to_line && (line > selection.from_line || j >= selection.from_column) && (line < selection.to_line || j < selection.to_column)); if (line == cursor.line && highlight_current_line) { - // if its the first char draw behind line numbers - if (j == 0) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(0, ofs_y, (char_ofs + char_margin), get_row_height()), cache.current_line_color); - } // if its the last char draw to end of the line if (j == str.length() - 1) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(char_ofs + char_margin + char_w, ofs_y, xmargin_end - (char_ofs + char_margin + char_w), get_row_height()), cache.current_line_color); } // actual text if (!in_selection) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.current_line_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.current_line_color); } } if (in_selection) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.selection_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.selection_color); } if (in_search_result) { Color border_color = (line == search_result_line && j >= search_result_col && j < search_result_col + search_text.length()) ? cache.font_color : cache.search_result_border_color; - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, 1)), border_color); - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y + get_row_height() - 1), Size2i(char_w, 1)), border_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, 1)), border_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y + get_row_height() - 1), Size2i(char_w, 1)), border_color); if (j == search_text_col) - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(1, get_row_height())), border_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(1, get_row_height())), border_color); if (j == search_text_col + search_text.length() - 1) - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + char_w - 1, ofs_y), Size2i(1, get_row_height())), border_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + char_w + ofs_x - 1, ofs_y), Size2i(1, get_row_height())), border_color); } if (highlight_all_occurrences) { @@ -1151,7 +1173,7 @@ void TextEdit::_notification(int p_what) { } if (in_highlighted_word) { - VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin, ofs_y), Size2i(char_w, get_row_height())), cache.word_highlighted_color); + VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2i(char_ofs + char_margin + ofs_x, ofs_y), Size2i(char_w, get_row_height())), cache.word_highlighted_color); } } } @@ -1162,7 +1184,7 @@ void TextEdit::_notification(int p_what) { if (brace_open_mismatch) color = cache.brace_mismatch_color; - cache.font->draw_char(ci, Point2i(char_ofs + char_margin, ofs_y + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + cache.font->draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, ofs_y + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); } if ( @@ -1171,13 +1193,13 @@ void TextEdit::_notification(int p_what) { if (brace_close_mismatch) color = cache.brace_mismatch_color; - cache.font->draw_char(ci, Point2i(char_ofs + char_margin, ofs_y + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + cache.font->draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, ofs_y + ascent), '_', str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); } } if (cursor.column == j && cursor.line == line) { - cursor_pos = Point2i(char_ofs + char_margin, ofs_y); + cursor_pos = Point2i(char_ofs + char_margin + ofs_x, ofs_y); if (insert_mode) { cursor_pos.y += (get_row_height() - 3); @@ -1204,7 +1226,7 @@ void TextEdit::_notification(int p_what) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 1)), color); } - cache.font->draw_char(ci, Point2(char_ofs + char_margin, ofs_y + ascent), cchar, next, color); + cache.font->draw_char(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + ascent), cchar, next, color); char_ofs += im_char_width; ofs++; @@ -1227,18 +1249,19 @@ void TextEdit::_notification(int p_what) { color = cache.caret_background_color; } else if (!syntax_coloring && block_caret) { color = cache.font_color; + color.a *= readonly_alpha; } if (str[j] >= 32) { - int w = cache.font->draw_char(ci, Point2i(char_ofs + char_margin, ofs_y + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); + int w = cache.font->draw_char(ci, Point2i(char_ofs + char_margin + ofs_x, ofs_y + ascent), str[j], str[j + 1], in_selection && override_selected_font_color ? cache.font_selected_color : color); if (underlined) { - draw_rect(Rect2(char_ofs + char_margin, ofs_y + ascent + 2, w, 1), in_selection && override_selected_font_color ? cache.font_selected_color : color); + draw_rect(Rect2(char_ofs + char_margin + ofs_x, ofs_y + ascent + 2, w, 1), in_selection && override_selected_font_color ? cache.font_selected_color : color); } } else if (draw_tabs && str[j] == '\t') { int yofs = (get_row_height() - cache.tab_icon->get_height()) / 2; - cache.tab_icon->draw(ci, Point2(char_ofs + char_margin, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_selected_color : color); + cache.tab_icon->draw(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + yofs), in_selection && override_selected_font_color ? cache.font_selected_color : color); } char_ofs += char_w; @@ -1246,13 +1269,15 @@ void TextEdit::_notification(int p_what) { if (j == str.length() - 1 && is_folded(line)) { int yofs = (get_row_height() - cache.folded_eol_icon->get_height()) / 2; int xofs = cache.folded_eol_icon->get_width() / 2; - cache.folded_eol_icon->draw(ci, Point2(char_ofs + char_margin + xofs, ofs_y + yofs), Color(1, 1, 1, 1)); + Color eol_color = cache.code_folding_color; + eol_color.a = 1; + cache.folded_eol_icon->draw(ci, Point2(char_ofs + char_margin + xofs + ofs_x, ofs_y + yofs), eol_color); } } if (cursor.column == str.length() && cursor.line == line && (char_ofs + char_margin) >= xmargin_beg) { - cursor_pos = Point2i(char_ofs + char_margin, ofs_y); + cursor_pos = Point2i(char_ofs + char_margin + ofs_x, ofs_y); if (insert_mode) { cursor_pos.y += (get_row_height() - 3); @@ -1277,7 +1302,7 @@ void TextEdit::_notification(int p_what) { VisualServer::get_singleton()->canvas_item_add_rect(ci, Rect2(Point2(char_ofs + char_margin, ofs_y + get_row_height()), Size2(im_char_width, 1)), color); } - cache.font->draw_char(ci, Point2(char_ofs + char_margin, ofs_y + ascent), cchar, next, color); + cache.font->draw_char(ci, Point2(char_ofs + char_margin + ofs_x, ofs_y + ascent), cchar, next, color); char_ofs += im_char_width; ofs++; @@ -3913,6 +3938,7 @@ void TextEdit::clear() { void TextEdit::set_readonly(bool p_readonly) { readonly = p_readonly; + update(); } bool TextEdit::is_readonly() const { @@ -3950,6 +3976,7 @@ void TextEdit::_update_caches() { cache.style_normal = get_stylebox("normal"); cache.style_focus = get_stylebox("focus"); + cache.style_readonly = get_stylebox("read_only"); cache.completion_background_color = get_color("completion_background_color"); cache.completion_selected_color = get_color("completion_selected_color"); cache.completion_existing_color = get_color("completion_existing_color"); @@ -3969,6 +3996,7 @@ void TextEdit::_update_caches() { cache.current_line_color = get_color("current_line_color"); cache.line_length_guideline_color = get_color("line_length_guideline_color"); cache.breakpoint_color = get_color("breakpoint_color"); + cache.code_folding_color = get_color("code_folding_color"); cache.brace_mismatch_color = get_color("brace_mismatch_color"); cache.word_highlighted_color = get_color("word_highlighted_color"); cache.search_result_color = get_color("search_result_color"); @@ -4489,16 +4517,17 @@ int TextEdit::num_lines_from(int p_line_from, int unhidden_amount) const { return num_total; } -int TextEdit::get_whitespace_level(int p_line) const { +int TextEdit::get_indent_level(int p_line) const { ERR_FAIL_INDEX_V(p_line, text.size(), 0); // counts number of tabs and spaces before line starts + int tab_count = 0; int whitespace_count = 0; int line_length = text[p_line].size(); for (int i = 0; i < line_length - 1; i++) { if (text[p_line][i] == '\t') { - whitespace_count++; + tab_count++; } else if (text[p_line][i] == ' ') { whitespace_count++; } else if (text[p_line][i] == '#') { @@ -4507,7 +4536,7 @@ int TextEdit::get_whitespace_level(int p_line) const { break; } } - return whitespace_count; + return tab_count + whitespace_count / indent_size; } bool TextEdit::can_fold(int p_line) const { @@ -4524,12 +4553,12 @@ bool TextEdit::can_fold(int p_line) const { if (is_line_hidden(p_line)) return false; - int start_indent = get_whitespace_level(p_line); + int start_indent = get_indent_level(p_line); for (int i = p_line + 1; i < text.size(); i++) { if (text[i].size() == 0) continue; - int next_indent = get_whitespace_level(i); + int next_indent = get_indent_level(i); if (next_indent > start_indent) return true; else @@ -4558,22 +4587,20 @@ void TextEdit::fold_line(int p_line) { return; // hide lines below this one - int start_indent = get_whitespace_level(p_line); + int start_indent = get_indent_level(p_line); + int last_line = start_indent; for (int i = p_line + 1; i < text.size(); i++) { - int cur_indent = get_whitespace_level(i); - if (text[i].size() == 0 || cur_indent > start_indent) { - set_line_as_hidden(i, true); - } else { - // exclude trailing empty lines - for (int trail_i = i - 1; trail_i > p_line; trail_i--) { - if (text[trail_i].size() == 0) - set_line_as_hidden(trail_i, false); - else - break; + if (text[i].strip_edges().size() != 0) { + if (get_indent_level(i) > start_indent) { + last_line = i; + } else { + break; } - break; } } + for (int i = p_line + 1; i <= last_line; i++) { + set_line_as_hidden(i, true); + } // fix selection if (is_selection_active()) { diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h index bb9ca87d06..e5dc2da7c7 100644 --- a/scene/gui/text_edit.h +++ b/scene/gui/text_edit.h @@ -78,6 +78,7 @@ class TextEdit : public Control { Ref<Texture> folded_eol_icon; Ref<StyleBox> style_normal; Ref<StyleBox> style_focus; + Ref<StyleBox> style_readonly; Ref<Font> font; Color completion_background_color; Color completion_selected_color; @@ -95,6 +96,7 @@ class TextEdit : public Control { Color selection_color; Color mark_color; Color breakpoint_color; + Color code_folding_color; Color current_line_color; Color line_length_guideline_color; Color brace_mismatch_color; @@ -158,7 +160,7 @@ class TextEdit : public Control { void set_font(const Ref<Font> &p_font); void set_color_regions(const Vector<ColorRegion> *p_regions) { color_regions = p_regions; } int get_line_width(int p_line) const; - int get_max_width() const; + int get_max_width(bool p_exclude_hidden = false) const; const Map<int, ColorRegionInfo> &get_color_region_info(int p_line); void set(int p_line, const String &p_text); void set_marked(int p_line, bool p_marked) { text[p_line].marked = p_marked; } @@ -430,7 +432,6 @@ public: void fold_all_lines(); void unhide_all_lines(); int num_lines_from(int p_line_from, int unhidden_amount) const; - int get_whitespace_level(int p_line) const; bool can_fold(int p_line) const; bool is_folded(int p_line) const; void fold_line(int p_line); @@ -443,6 +444,7 @@ public: void indent_selection_left(); void indent_selection_right(); + int get_indent_level(int p_line) const; inline void set_scroll_pass_end_of_file(bool p_enabled) { scroll_past_end_of_file_enabled = p_enabled; diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 5ee286c2d5..deb40800bc 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -794,6 +794,7 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() { Vector3(0, 0, 1) }; + /* clang-format off */ int diamond_faces[8 * 3] = { 0, 2, 4, 0, 3, 4, @@ -804,6 +805,7 @@ Ref<ArrayMesh> SceneTree::get_debug_contact_mesh() { 1, 2, 5, 1, 3, 5, }; + /* clang-format on */ PoolVector<int> indices; for (int i = 0; i < 8 * 3; i++) diff --git a/scene/main/scene_tree.h b/scene/main/scene_tree.h index 7898dc065a..244fc8da62 100644 --- a/scene/main/scene_tree.h +++ b/scene/main/scene_tree.h @@ -420,8 +420,8 @@ public: void set_screen_stretch(StretchMode p_mode, StretchAspect p_aspect, const Size2 p_minsize, real_t p_shrink = 1); -//void change_scene(const String& p_path); -//Node *get_loaded_scene(); + //void change_scene(const String& p_path); + //Node *get_loaded_scene(); #ifdef TOOLS_ENABLED void set_edited_scene_root(Node *p_node); diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index d864b0f763..a785abbc65 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -936,6 +936,9 @@ void Viewport::_camera_remove(Camera *p_camera) { cameras.erase(p_camera); if (camera == p_camera) { + if (camera && find_world().is_valid()) { + camera->notification(Camera::NOTIFICATION_LOST_CURRENT); + } camera = NULL; } } diff --git a/scene/resources/animation.cpp b/scene/resources/animation.cpp index 8192074c17..ebbd2d35c3 100644 --- a/scene/resources/animation.cpp +++ b/scene/resources/animation.cpp @@ -1595,6 +1595,21 @@ float Animation::get_step() const { return step; } +void Animation::copy_track(int src_track, Ref<Animation> p_to_animation) { + ERR_FAIL_COND(p_to_animation.is_null()); + ERR_FAIL_INDEX(src_track, get_track_count()); + int dst_track = p_to_animation->get_track_count(); + p_to_animation->add_track(track_get_type(src_track)); + + p_to_animation->track_set_path(dst_track, track_get_path(src_track)); + p_to_animation->track_set_imported(dst_track, track_is_imported(src_track)); + p_to_animation->track_set_interpolation_type(dst_track, track_get_interpolation_type(src_track)); + p_to_animation->track_set_interpolation_loop_wrap(dst_track, track_get_interpolation_loop_wrap(src_track)); + for (int i = 0; i < track_get_key_count(src_track); i++) { + p_to_animation->track_insert_key(dst_track, track_get_key_time(src_track, i), track_get_key_value(src_track, i), track_get_key_transition(src_track, i)); + } +} + void Animation::_bind_methods() { ClassDB::bind_method(D_METHOD("add_track", "type", "at_position"), &Animation::add_track, DEFVAL(-1)); @@ -1650,6 +1665,7 @@ void Animation::_bind_methods() { ClassDB::bind_method(D_METHOD("get_step"), &Animation::get_step); ClassDB::bind_method(D_METHOD("clear"), &Animation::clear); + ClassDB::bind_method(D_METHOD("copy_track", "track", "to_animation"), &Animation::copy_track); BIND_ENUM_CONSTANT(TYPE_VALUE); BIND_ENUM_CONSTANT(TYPE_TRANSFORM); diff --git a/scene/resources/animation.h b/scene/resources/animation.h index 6235e161a3..c96beeb01f 100644 --- a/scene/resources/animation.h +++ b/scene/resources/animation.h @@ -269,6 +269,8 @@ public: Vector<Variant> method_track_get_params(int p_track, int p_key_idx) const; StringName method_track_get_name(int p_track, int p_key_idx) const; + void copy_track(int p_track, Ref<Animation> p_to_animation); + void set_length(float p_length); float get_length() const; diff --git a/scene/resources/box_shape.cpp b/scene/resources/box_shape.cpp index 4b9843f3f5..858e19c9a6 100644 --- a/scene/resources/box_shape.cpp +++ b/scene/resources/box_shape.cpp @@ -73,8 +73,8 @@ void BoxShape::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "extents"), "set_extents", "get_extents"); } -BoxShape::BoxShape() - : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_BOX)) { +BoxShape::BoxShape() : + Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_BOX)) { set_extents(Vector3(1, 1, 1)); } diff --git a/scene/resources/capsule_shape.cpp b/scene/resources/capsule_shape.cpp index e11b98f82e..f0eb8232e5 100644 --- a/scene/resources/capsule_shape.cpp +++ b/scene/resources/capsule_shape.cpp @@ -113,8 +113,8 @@ void CapsuleShape::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "height", PROPERTY_HINT_RANGE, "0.01,4096,0.01"), "set_height", "get_height"); } -CapsuleShape::CapsuleShape() - : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CAPSULE)) { +CapsuleShape::CapsuleShape() : + Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CAPSULE)) { radius = 1.0; height = 1.0; diff --git a/scene/resources/capsule_shape_2d.cpp b/scene/resources/capsule_shape_2d.cpp index 912150b939..3caf12feb8 100644 --- a/scene/resources/capsule_shape_2d.cpp +++ b/scene/resources/capsule_shape_2d.cpp @@ -97,8 +97,8 @@ void CapsuleShape2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "height"), "set_height", "get_height"); } -CapsuleShape2D::CapsuleShape2D() - : Shape2D(Physics2DServer::get_singleton()->capsule_shape_create()) { +CapsuleShape2D::CapsuleShape2D() : + Shape2D(Physics2DServer::get_singleton()->capsule_shape_create()) { radius = 10; height = 20; diff --git a/scene/resources/circle_shape_2d.cpp b/scene/resources/circle_shape_2d.cpp index 287bde4bfb..bff3ed4d67 100644 --- a/scene/resources/circle_shape_2d.cpp +++ b/scene/resources/circle_shape_2d.cpp @@ -76,8 +76,8 @@ void CircleShape2D::draw(const RID &p_to_rid, const Color &p_color) { VisualServer::get_singleton()->canvas_item_add_polygon(p_to_rid, points, col); } -CircleShape2D::CircleShape2D() - : Shape2D(Physics2DServer::get_singleton()->circle_shape_create()) { +CircleShape2D::CircleShape2D() : + Shape2D(Physics2DServer::get_singleton()->circle_shape_create()) { radius = 10; _update_shape(); diff --git a/scene/resources/concave_polygon_shape.cpp b/scene/resources/concave_polygon_shape.cpp index 6ae4fde85e..1c48f0c30b 100644 --- a/scene/resources/concave_polygon_shape.cpp +++ b/scene/resources/concave_polygon_shape.cpp @@ -106,8 +106,8 @@ void ConcavePolygonShape::_bind_methods() { ClassDB::bind_method(D_METHOD("get_faces"), &ConcavePolygonShape::get_faces); } -ConcavePolygonShape::ConcavePolygonShape() - : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON)) { +ConcavePolygonShape::ConcavePolygonShape() : + Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONCAVE_POLYGON)) { //set_planes(Vector3(1,1,1)); } diff --git a/scene/resources/concave_polygon_shape_2d.cpp b/scene/resources/concave_polygon_shape_2d.cpp index bb91e33ec2..e90046fd28 100644 --- a/scene/resources/concave_polygon_shape_2d.cpp +++ b/scene/resources/concave_polygon_shape_2d.cpp @@ -84,6 +84,6 @@ void ConcavePolygonShape2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::POOL_VECTOR2_ARRAY, "segments"), "set_segments", "get_segments"); } -ConcavePolygonShape2D::ConcavePolygonShape2D() - : Shape2D(Physics2DServer::get_singleton()->concave_polygon_shape_create()) { +ConcavePolygonShape2D::ConcavePolygonShape2D() : + Shape2D(Physics2DServer::get_singleton()->concave_polygon_shape_create()) { } diff --git a/scene/resources/convex_polygon_shape.cpp b/scene/resources/convex_polygon_shape.cpp index bba52bd5ff..31c4ea55e9 100644 --- a/scene/resources/convex_polygon_shape.cpp +++ b/scene/resources/convex_polygon_shape.cpp @@ -81,8 +81,8 @@ void ConvexPolygonShape::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "points"), "set_points", "get_points"); } -ConvexPolygonShape::ConvexPolygonShape() - : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON)) { +ConvexPolygonShape::ConvexPolygonShape() : + Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON)) { //set_points(Vector3(1,1,1)); } diff --git a/scene/resources/convex_polygon_shape_2d.cpp b/scene/resources/convex_polygon_shape_2d.cpp index a76b6a7cf4..9c25b6b467 100644 --- a/scene/resources/convex_polygon_shape_2d.cpp +++ b/scene/resources/convex_polygon_shape_2d.cpp @@ -86,8 +86,8 @@ Rect2 ConvexPolygonShape2D::get_rect() const { return rect; } -ConvexPolygonShape2D::ConvexPolygonShape2D() - : Shape2D(Physics2DServer::get_singleton()->convex_polygon_shape_create()) { +ConvexPolygonShape2D::ConvexPolygonShape2D() : + Shape2D(Physics2DServer::get_singleton()->convex_polygon_shape_create()) { int pcount = 3; for (int i = 0; i < pcount; i++) diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index c5feecd7c4..bb2c8750e3 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -257,6 +257,8 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const // LinkButton + theme->set_stylebox("focus", "LinkButton", focus); + theme->set_font("font", "LinkButton", default_font); theme->set_color("font_color", "LinkButton", control_font_color); @@ -448,6 +450,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_stylebox("normal", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3)); theme->set_stylebox("focus", "TextEdit", focus); + theme->set_stylebox("read_only", "TextEdit", make_stylebox(tree_bg_disabled_png, 4, 4, 4, 4)); theme->set_stylebox("completion", "TextEdit", make_stylebox(tree_bg_png, 3, 3, 3, 3)); theme->set_icon("tab", "TextEdit", make_icon(tab_png)); @@ -465,6 +468,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const theme->set_color("selection_color", "TextEdit", font_color_selection); theme->set_color("mark_color", "TextEdit", Color(1.0, 0.4, 0.4, 0.4)); theme->set_color("breakpoint_color", "TextEdit", Color(0.8, 0.8, 0.4, 0.2)); + theme->set_color("code_folding_color", "TextEdit", Color(0.8, 0.8, 0.8, 0.8)); theme->set_color("current_line_color", "TextEdit", Color(0.25, 0.25, 0.26, 0.8)); theme->set_color("caret_color", "TextEdit", control_font_color); theme->set_color("caret_background_color", "TextEdit", Color::html("000000")); diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h index 255bb4c6dd..c6b37cad5a 100644 --- a/scene/resources/default_theme/theme_data.h +++ b/scene/resources/default_theme/theme_data.h @@ -410,6 +410,10 @@ static const unsigned char tree_bg_png[] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0xa, 0x4, 0x3, 0x0, 0x0, 0x0, 0x7f, 0x1c, 0xd2, 0x8e, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2a, 0x50, 0x4c, 0x54, 0x45, 0x17, 0x16, 0x1a, 0x1d, 0x1c, 0x21, 0x20, 0x1e, 0x24, 0x21, 0x1f, 0x25, 0x1d, 0x1c, 0x21, 0x20, 0x1e, 0x24, 0x1d, 0x1c, 0x21, 0x1d, 0x1c, 0x21, 0x24, 0x22, 0x29, 0x28, 0x26, 0x2d, 0x28, 0x26, 0x2e, 0x2b, 0x2a, 0x31, 0x2c, 0x2a, 0x32, 0xff, 0xff, 0xff, 0xb9, 0x11, 0x56, 0x3e, 0x0, 0x0, 0x0, 0x8, 0x74, 0x52, 0x4e, 0x53, 0x6f, 0xef, 0xf7, 0xf7, 0xf0, 0xf9, 0xf1, 0xee, 0xcf, 0x21, 0xd2, 0xdf, 0x0, 0x0, 0x0, 0x1, 0x62, 0x4b, 0x47, 0x44, 0xd, 0xf6, 0xb4, 0x61, 0xf5, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x2d, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x63, 0x60, 0x54, 0x36, 0x36, 0x12, 0x60, 0xf0, 0x98, 0xb5, 0x6a, 0x65, 0xb, 0x43, 0xe4, 0x9e, 0x33, 0xa7, 0xa7, 0x32, 0x58, 0x9d, 0x39, 0x73, 0x66, 0x31, 0x16, 0x12, 0x22, 0xb, 0x52, 0xd9, 0xc6, 0xc0, 0x2, 0xd4, 0x55, 0x0, 0x0, 0xc, 0x14, 0x1a, 0x90, 0x55, 0x1a, 0xec, 0xdb, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; +static const unsigned char tree_bg_disabled_png[] = { + 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0xa, 0x0, 0x0, 0x0, 0xa, 0x8, 0x4, 0x0, 0x0, 0x0, 0x27, 0x3b, 0x7, 0x36, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x2, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x87, 0x8f, 0xcc, 0xbf, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xe0, 0x6, 0x16, 0x12, 0x2b, 0x5, 0x39, 0x1a, 0x32, 0x39, 0x0, 0x0, 0x0, 0x64, 0x49, 0x44, 0x41, 0x54, 0x8, 0xd7, 0x95, 0xce, 0x31, 0x12, 0x2, 0x21, 0x10, 0x44, 0xd1, 0x3f, 0x40, 0xa1, 0x44, 0xa6, 0x46, 0xde, 0x63, 0x4f, 0xe5, 0x15, 0x38, 0xb2, 0xd6, 0x6, 0xb0, 0xc8, 0x30, 0x6, 0x96, 0xac, 0x56, 0x99, 0xf8, 0xb3, 0x7e, 0x51, 0xcb, 0xf9, 0x1a, 0xb3, 0x3f, 0xa, 0xaf, 0xc, 0xad, 0x2d, 0xcb, 0xe5, 0x76, 0x38, 0x5, 0x76, 0xec, 0x6c, 0xf7, 0xe0, 0x53, 0xe0, 0x13, 0xa1, 0x27, 0x27, 0x43, 0x26, 0x81, 0x20, 0xc8, 0x70, 0xfc, 0xe8, 0xf, 0x34, 0x67, 0xd8, 0x9c, 0x86, 0x61, 0x2e, 0x68, 0xe9, 0x91, 0xaf, 0x4b, 0x5a, 0x7d, 0x2a, 0x2c, 0x3, 0xed, 0xef, 0x1e, 0x6b, 0xcb, 0x4f, 0xa6, 0x66, 0x2b, 0x25, 0x6, 0x1, 0x37, 0x40, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 +}; + static const unsigned char tree_bg_focus_png[] = { 0x89, 0x50, 0x4e, 0x47, 0xd, 0xa, 0x1a, 0xa, 0x0, 0x0, 0x0, 0xd, 0x49, 0x48, 0x44, 0x52, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x20, 0x8, 0x6, 0x0, 0x0, 0x0, 0x73, 0x7a, 0x7a, 0xf4, 0x0, 0x0, 0x0, 0x4, 0x67, 0x41, 0x4d, 0x41, 0x0, 0x0, 0xb1, 0x8f, 0xb, 0xfc, 0x61, 0x5, 0x0, 0x0, 0x0, 0x20, 0x63, 0x48, 0x52, 0x4d, 0x0, 0x0, 0x7a, 0x26, 0x0, 0x0, 0x80, 0x84, 0x0, 0x0, 0xfa, 0x0, 0x0, 0x0, 0x80, 0xe8, 0x0, 0x0, 0x75, 0x30, 0x0, 0x0, 0xea, 0x60, 0x0, 0x0, 0x3a, 0x98, 0x0, 0x0, 0x17, 0x70, 0x9c, 0xba, 0x51, 0x3c, 0x0, 0x0, 0x0, 0x6, 0x62, 0x4b, 0x47, 0x44, 0x0, 0xff, 0x0, 0xff, 0x0, 0xff, 0xa0, 0xbd, 0xa7, 0x93, 0x0, 0x0, 0x0, 0x9, 0x70, 0x48, 0x59, 0x73, 0x0, 0x0, 0xb, 0x13, 0x0, 0x0, 0xb, 0x13, 0x1, 0x0, 0x9a, 0x9c, 0x18, 0x0, 0x0, 0x0, 0x7, 0x74, 0x49, 0x4d, 0x45, 0x7, 0xdb, 0xb, 0x4, 0x12, 0x2d, 0x3a, 0xb5, 0x1b, 0x14, 0x49, 0x0, 0x0, 0x2, 0xd9, 0x49, 0x44, 0x41, 0x54, 0x58, 0xc3, 0xc5, 0x57, 0x31, 0x8e, 0x14, 0x31, 0x10, 0xac, 0xea, 0x3d, 0x11, 0x91, 0xdf, 0x49, 0xf7, 0xf, 0x78, 0x1, 0xf, 0x40, 0x84, 0x44, 0x10, 0xf2, 0x20, 0x42, 0x62, 0x12, 0xc4, 0x3, 0x78, 0x1, 0xff, 0x21, 0x42, 0xb8, 0x8a, 0xc0, 0x1e, 0x4f, 0xdb, 0xe3, 0xb9, 0xbb, 0x45, 0x20, 0x7c, 0x1a, 0xdd, 0x8c, 0xec, 0xed, 0xae, 0xae, 0xea, 0xee, 0xe9, 0xe1, 0xfd, 0xed, 0xdd, 0xb, 0x0, 0xdf, 0xf1, 0x7f, 0xd6, 0x4b, 0xde, 0xdf, 0xde, 0xf9, 0xcb, 0xeb, 0x9f, 0xff, 0xc5, 0xfb, 0x9b, 0xaf, 0xcf, 0x70, 0xb3, 0x3d, 0x3c, 0xff, 0xf0, 0xd, 0x24, 0x11, 0x71, 0x1, 0x49, 0x90, 0x4, 0x0, 0x4, 0xd3, 0x2f, 0xb6, 0x7b, 0xf, 0xff, 0x86, 0x2d, 0x8c, 0x47, 0x60, 0x1b, 0x0, 0x61, 0x1b, 0xb6, 0x21, 0x15, 0xd8, 0xc6, 0x8f, 0x8f, 0xaf, 0x0, 0x60, 0x7, 0x0, 0xa2, 0x2, 0x20, 0x11, 0x41, 0x30, 0xa2, 0x2, 0xc1, 0xb5, 0x0, 0x8c, 0x79, 0xd9, 0x80, 0x24, 0x48, 0x0, 0x48, 0x28, 0x9d, 0xb9, 0xd9, 0xd, 0xb0, 0x31, 0x40, 0x5c, 0x2e, 0x1, 0x46, 0x0, 0xd, 0xd0, 0xb6, 0xef, 0x35, 0x8e, 0x13, 0x6, 0xbc, 0x33, 0x60, 0xa3, 0x9a, 0x11, 0x6c, 0x82, 0xe6, 0xa, 0x0, 0x86, 0xe8, 0x2f, 0x71, 0xa9, 0xf7, 0x9c, 0x4d, 0x1f, 0x69, 0x5e, 0x1, 0xd8, 0xa3, 0x37, 0xa4, 0xa, 0x27, 0x1a, 0x13, 0x79, 0x25, 0x9, 0xaa, 0xe3, 0xd8, 0x9c, 0x5f, 0xea, 0x7d, 0x67, 0x80, 0xd7, 0x31, 0x20, 0xab, 0x3, 0x20, 0x5, 0x20, 0x2a, 0x13, 0x41, 0x40, 0x2b, 0x0, 0x76, 0x22, 0xb9, 0xb1, 0xd1, 0x92, 0x91, 0x5d, 0x86, 0xf3, 0x35, 0xef, 0x5, 0xa3, 0x25, 0x60, 0xd, 0x6e, 0x66, 0xe5, 0x0, 0xc0, 0xa8, 0x54, 0x1, 0x6, 0xe9, 0x16, 0x9f, 0x4f, 0xdc, 0x1c, 0x13, 0xed, 0xb1, 0x55, 0x31, 0x78, 0x70, 0x8e, 0xca, 0xcb, 0x8e, 0x6a, 0xbe, 0x56, 0x88, 0x67, 0x38, 0xdb, 0x75, 0x58, 0x76, 0xdf, 0x1b, 0x6c, 0x7a, 0xc, 0x6c, 0x90, 0x0, 0xfd, 0xe0, 0xe8, 0x98, 0xe4, 0x4, 0xe2, 0x69, 0xc, 0xe4, 0x40, 0xaa, 0xf9, 0x63, 0x70, 0xbb, 0x4, 0x16, 0x9c, 0x12, 0xa7, 0x3e, 0xe7, 0x38, 0xb3, 0x4, 0x2b, 0x6f, 0xc7, 0x23, 0xbb, 0xc3, 0x66, 0xdb, 0x38, 0x7, 0x0, 0xcf, 0x32, 0x34, 0xb6, 0x52, 0xb4, 0x3c, 0xf7, 0x35, 0x10, 0xd9, 0xf7, 0x6, 0x56, 0x93, 0x4, 0x4b, 0x0, 0x43, 0x28, 0xf9, 0x4a, 0x3d, 0x6e, 0xb0, 0x3e, 0x9, 0x31, 0xa9, 0x62, 0xd6, 0xc4, 0x36, 0x9c, 0xf2, 0xd9, 0xbd, 0x41, 0x2d, 0x24, 0x68, 0xc7, 0x1f, 0x62, 0x60, 0x6a, 0xc1, 0x7f, 0x95, 0x81, 0xaa, 0x13, 0x61, 0x9, 0xa6, 0xf6, 0x1c, 0x30, 0x17, 0x11, 0x6f, 0x48, 0x12, 0x3b, 0xf3, 0x7b, 0xc2, 0xeb, 0xca, 0x92, 0xb7, 0x72, 0x5f, 0x31, 0x90, 0x11, 0x4e, 0x48, 0xb3, 0x13, 0xa6, 0xcc, 0x3e, 0x51, 0x60, 0x91, 0x53, 0x55, 0x87, 0xf3, 0x2a, 0x98, 0xff, 0x7c, 0x6c, 0x1a, 0xf9, 0xec, 0xda, 0xeb, 0x94, 0x13, 0x43, 0xdd, 0x3f, 0x2a, 0x41, 0xd2, 0xb, 0x27, 0x65, 0xe8, 0x13, 0x20, 0x29, 0x3f, 0xc6, 0x7c, 0x48, 0x65, 0x8, 0x41, 0xda, 0xa4, 0xd5, 0x11, 0xc0, 0x2a, 0x61, 0xce, 0x18, 0x58, 0xd2, 0xbe, 0x98, 0x48, 0x96, 0xdd, 0xf5, 0xbc, 0x11, 0x65, 0xb6, 0x12, 0x55, 0xcb, 0xde, 0xb3, 0x78, 0x27, 0x78, 0xdc, 0xcb, 0x72, 0xe6, 0xd7, 0x8a, 0x27, 0xe6, 0x52, 0x1f, 0x10, 0xe0, 0xb8, 0x92, 0x81, 0xb4, 0x3f, 0x1, 0x1d, 0xed, 0x6c, 0xd4, 0xef, 0x12, 0x2f, 0x73, 0xa0, 0xe, 0xf, 0x42, 0x24, 0x20, 0xf, 0x91, 0xbf, 0x6e, 0x44, 0xfb, 0xde, 0xa1, 0x4, 0xa5, 0x7, 0xaa, 0xa0, 0x23, 0xad, 0xd4, 0x4b, 0xaa, 0x73, 0x0, 0xb7, 0xa1, 0x82, 0x87, 0x46, 0x74, 0x9a, 0xf, 0x48, 0x5d, 0xb3, 0xd, 0xa2, 0xb0, 0x96, 0xe5, 0x7d, 0xc8, 0x81, 0x19, 0xf1, 0x36, 0x2b, 0xba, 0xbd, 0x5e, 0xb3, 0xb7, 0x55, 0x12, 0x76, 0x90, 0xc4, 0x3a, 0x1, 0xa7, 0x66, 0xbc, 0x3, 0x90, 0xe0, 0x8, 0xc8, 0x42, 0x29, 0xa5, 0x7b, 0xa2, 0x63, 0x9f, 0x88, 0x26, 0xa, 0x9c, 0x85, 0x6f, 0x7b, 0x2b, 0x0, 0x92, 0x51, 0x4a, 0x81, 0x5c, 0x2a, 0xcb, 0x2a, 0x47, 0x0, 0xb0, 0x2b, 0x8, 0x11, 0x62, 0x20, 0x58, 0x20, 0x47, 0x77, 0x5a, 0xe5, 0x98, 0x43, 0x3f, 0x2, 0xd8, 0xc1, 0xa5, 0x39, 0x40, 0x82, 0xb5, 0xd9, 0xd7, 0x5a, 0x2, 0x59, 0x80, 0x9, 0x8a, 0x0, 0x7f, 0x1, 0x8, 0x44, 0x8, 0x64, 0xe0, 0xe8, 0x6e, 0x4b, 0xb4, 0x87, 0xa6, 0xc4, 0x3d, 0x17, 0x24, 0xa3, 0xa8, 0xc0, 0x32, 0x8a, 0xea, 0x33, 0x67, 0x0, 0x6e, 0xc, 0x94, 0x5e, 0xe2, 0x46, 0x11, 0x3a, 0x0, 0x82, 0x57, 0x1, 0x98, 0xbf, 0xb, 0xa4, 0xf6, 0x55, 0xd4, 0x2a, 0xe1, 0x0, 0x40, 0xf5, 0xf3, 0xa5, 0xd3, 0x16, 0x6a, 0xb4, 0xa7, 0x19, 0xfa, 0x4f, 0x18, 0xe8, 0x2c, 0x34, 0xfb, 0x92, 0x20, 0xbb, 0xf, 0xa3, 0x1d, 0xc0, 0xcd, 0xe7, 0xb7, 0x83, 0xf9, 0xf2, 0x24, 0xd3, 0xd7, 0xaf, 0x40, 0x9a, 0x84, 0x1, 0xf0, 0xfe, 0xf6, 0xee, 0x1d, 0x80, 0x4f, 0xff, 0xc8, 0xdf, 0x63, 0xeb, 0xfd, 0x6f, 0x3, 0x74, 0x35, 0xa7, 0x2a, 0xf0, 0x17, 0xed, 0x0, 0x0, 0x0, 0x19, 0x74, 0x45, 0x58, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x65, 0x6e, 0x74, 0x0, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x64, 0x20, 0x77, 0x69, 0x74, 0x68, 0x20, 0x47, 0x49, 0x4d, 0x50, 0x57, 0x81, 0xe, 0x17, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xc9, 0xad, 0xc8, 0x52, 0x0, 0x0, 0x0, 0x25, 0x74, 0x45, 0x58, 0x74, 0x64, 0x61, 0x74, 0x65, 0x3a, 0x6d, 0x6f, 0x64, 0x69, 0x66, 0x79, 0x0, 0x32, 0x30, 0x31, 0x36, 0x2d, 0x30, 0x36, 0x2d, 0x32, 0x32, 0x54, 0x32, 0x30, 0x3a, 0x33, 0x39, 0x3a, 0x32, 0x36, 0x2b, 0x30, 0x32, 0x3a, 0x30, 0x30, 0xb8, 0xf0, 0x70, 0xee, 0x0, 0x0, 0x0, 0x0, 0x49, 0x45, 0x4e, 0x44, 0xae, 0x42, 0x60, 0x82 }; diff --git a/scene/resources/default_theme/tree_bg_disabled.png b/scene/resources/default_theme/tree_bg_disabled.png Binary files differnew file mode 100644 index 0000000000..a0fa505e4c --- /dev/null +++ b/scene/resources/default_theme/tree_bg_disabled.png diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 15710f4c14..c8ab7c2a04 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -215,6 +215,13 @@ bool ShaderMaterial::_can_do_next_pass() const { return shader.is_valid() && shader->get_mode() == Shader::MODE_SPATIAL; } +Shader::Mode ShaderMaterial::get_shader_mode() const { + if (shader.is_valid()) + return shader->get_mode(); + else + return Shader::MODE_SPATIAL; +} + ShaderMaterial::ShaderMaterial() { } @@ -1662,6 +1669,11 @@ RID SpatialMaterial::get_shader_rid() const { return shader_map[current_key].shader; } +Shader::Mode SpatialMaterial::get_shader_mode() const { + + return Shader::MODE_SPATIAL; +} + void SpatialMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_albedo", "albedo"), &SpatialMaterial::set_albedo); @@ -2054,8 +2066,8 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(EMISSION_OP_MULTIPLY); } -SpatialMaterial::SpatialMaterial() - : element(this) { +SpatialMaterial::SpatialMaterial() : + element(this) { //initialize to right values set_albedo(Color(1.0, 1.0, 1.0, 1.0)); diff --git a/scene/resources/material.h b/scene/resources/material.h index 374ec853dc..7cfa38fce4 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -69,6 +69,8 @@ public: int get_render_priority() const; virtual RID get_rid() const; + + virtual Shader::Mode get_shader_mode() const = 0; Material(); virtual ~Material(); }; @@ -96,6 +98,8 @@ public: void set_shader_param(const StringName &p_param, const Variant &p_value); Variant get_shader_param(const StringName &p_param) const; + virtual Shader::Mode get_shader_mode() const; + ShaderMaterial(); ~ShaderMaterial(); }; @@ -600,6 +604,8 @@ public: RID get_shader_rid() const; + virtual Shader::Mode get_shader_mode() const; + SpatialMaterial(); virtual ~SpatialMaterial(); }; diff --git a/scene/resources/plane_shape.cpp b/scene/resources/plane_shape.cpp index 2b1e890a5d..2eb2ceff24 100644 --- a/scene/resources/plane_shape.cpp +++ b/scene/resources/plane_shape.cpp @@ -86,8 +86,8 @@ void PlaneShape::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::PLANE, "plane"), "set_plane", "get_plane"); } -PlaneShape::PlaneShape() - : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_PLANE)) { +PlaneShape::PlaneShape() : + Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_PLANE)) { set_plane(Plane(0, 1, 0, 0)); } diff --git a/scene/resources/primitive_meshes.cpp b/scene/resources/primitive_meshes.cpp index 3b80db291c..2e8f9cbb33 100644 --- a/scene/resources/primitive_meshes.cpp +++ b/scene/resources/primitive_meshes.cpp @@ -164,7 +164,7 @@ void PrimitiveMesh::_bind_methods() { ClassDB::bind_method(D_METHOD("get_mesh_arrays"), &PrimitiveMesh::get_mesh_arrays); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "Material"), "set_material", "get_material"); + ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "material", PROPERTY_HINT_RESOURCE_TYPE, "SpatialMaterial,ShaderMaterial"), "set_material", "get_material"); } void PrimitiveMesh::set_material(const Ref<Material> &p_material) { diff --git a/scene/resources/ray_shape.cpp b/scene/resources/ray_shape.cpp index ccce7660c6..b03a81b6bd 100644 --- a/scene/resources/ray_shape.cpp +++ b/scene/resources/ray_shape.cpp @@ -66,8 +66,8 @@ void RayShape::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "length", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_length", "get_length"); } -RayShape::RayShape() - : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_RAY)) { +RayShape::RayShape() : + Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_RAY)) { set_length(1.0); } diff --git a/scene/resources/rectangle_shape_2d.cpp b/scene/resources/rectangle_shape_2d.cpp index 69dbb76744..202024aa96 100644 --- a/scene/resources/rectangle_shape_2d.cpp +++ b/scene/resources/rectangle_shape_2d.cpp @@ -66,8 +66,8 @@ void RectangleShape2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "extents"), "set_extents", "get_extents"); } -RectangleShape2D::RectangleShape2D() - : Shape2D(Physics2DServer::get_singleton()->rectangle_shape_create()) { +RectangleShape2D::RectangleShape2D() : + Shape2D(Physics2DServer::get_singleton()->rectangle_shape_create()) { extents = Vector2(10, 10); _update_shape(); diff --git a/scene/resources/segment_shape_2d.cpp b/scene/resources/segment_shape_2d.cpp index 7c7ec0d112..e8ef448e23 100644 --- a/scene/resources/segment_shape_2d.cpp +++ b/scene/resources/segment_shape_2d.cpp @@ -86,8 +86,8 @@ void SegmentShape2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "b"), "set_b", "get_b"); } -SegmentShape2D::SegmentShape2D() - : Shape2D(Physics2DServer::get_singleton()->segment_shape_create()) { +SegmentShape2D::SegmentShape2D() : + Shape2D(Physics2DServer::get_singleton()->segment_shape_create()) { a = Vector2(); b = Vector2(0, 10); @@ -145,8 +145,8 @@ real_t RayShape2D::get_length() const { return length; } -RayShape2D::RayShape2D() - : Shape2D(Physics2DServer::get_singleton()->ray_shape_create()) { +RayShape2D::RayShape2D() : + Shape2D(Physics2DServer::get_singleton()->ray_shape_create()) { length = 20; _update_shape(); diff --git a/scene/resources/shape_line_2d.cpp b/scene/resources/shape_line_2d.cpp index d046ce876c..512ff3bc56 100644 --- a/scene/resources/shape_line_2d.cpp +++ b/scene/resources/shape_line_2d.cpp @@ -95,8 +95,8 @@ void LineShape2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "d"), "set_d", "get_d"); } -LineShape2D::LineShape2D() - : Shape2D(Physics2DServer::get_singleton()->line_shape_create()) { +LineShape2D::LineShape2D() : + Shape2D(Physics2DServer::get_singleton()->line_shape_create()) { normal = Vector2(0, -1); d = 0; diff --git a/scene/resources/sphere_shape.cpp b/scene/resources/sphere_shape.cpp index 00203c2b4b..042988dcd3 100644 --- a/scene/resources/sphere_shape.cpp +++ b/scene/resources/sphere_shape.cpp @@ -80,8 +80,8 @@ void SphereShape::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "radius", PROPERTY_HINT_RANGE, "0,4096,0.01"), "set_radius", "get_radius"); } -SphereShape::SphereShape() - : Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_SPHERE)) { +SphereShape::SphereShape() : + Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_SPHERE)) { set_radius(1.0); } diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h index 18b62c778d..4d2b02f54b 100644 --- a/scene/resources/tile_set.h +++ b/scene/resources/tile_set.h @@ -81,8 +81,9 @@ public: Map<Vector2, int> priority_map; // Default size to prevent invalid value - explicit AutotileData() - : size(64, 64), icon_coord(0, 0) { + explicit AutotileData() : + size(64, 64), + icon_coord(0, 0) { bitmask_mode = BITMASK_2X2; } }; @@ -106,8 +107,9 @@ private: AutotileData autotile_data; // Default modulate for back-compat - explicit TileData() - : modulate(1, 1, 1), is_autotile(false) {} + explicit TileData() : + modulate(1, 1, 1), + is_autotile(false) {} }; Map<int, TileData> tile_map; diff --git a/servers/audio/effects/audio_effect_eq.h b/servers/audio/effects/audio_effect_eq.h index 440f46c0c2..5d0c3d9729 100644 --- a/servers/audio/effects/audio_effect_eq.h +++ b/servers/audio/effects/audio_effect_eq.h @@ -76,22 +76,22 @@ public: class AudioEffectEQ6 : public AudioEffectEQ { GDCLASS(AudioEffectEQ6, AudioEffectEQ) public: - AudioEffectEQ6() - : AudioEffectEQ(EQ::PRESET_6_BANDS) {} + AudioEffectEQ6() : + AudioEffectEQ(EQ::PRESET_6_BANDS) {} }; class AudioEffectEQ10 : public AudioEffectEQ { GDCLASS(AudioEffectEQ10, AudioEffectEQ) public: - AudioEffectEQ10() - : AudioEffectEQ(EQ::PRESET_10_BANDS) {} + AudioEffectEQ10() : + AudioEffectEQ(EQ::PRESET_10_BANDS) {} }; class AudioEffectEQ21 : public AudioEffectEQ { GDCLASS(AudioEffectEQ21, AudioEffectEQ) public: - AudioEffectEQ21() - : AudioEffectEQ(EQ::PRESET_21_BANDS) {} + AudioEffectEQ21() : + AudioEffectEQ(EQ::PRESET_21_BANDS) {} }; #endif // AUDIOEFFECTEQ_H diff --git a/servers/audio/effects/audio_effect_filter.h b/servers/audio/effects/audio_effect_filter.h index 903977cb97..7fb5ba4c83 100644 --- a/servers/audio/effects/audio_effect_filter.h +++ b/servers/audio/effects/audio_effect_filter.h @@ -96,50 +96,50 @@ VARIANT_ENUM_CAST(AudioEffectFilter::FilterDB) class AudioEffectLowPassFilter : public AudioEffectFilter { GDCLASS(AudioEffectLowPassFilter, AudioEffectFilter) public: - AudioEffectLowPassFilter() - : AudioEffectFilter(AudioFilterSW::LOWPASS) {} + AudioEffectLowPassFilter() : + AudioEffectFilter(AudioFilterSW::LOWPASS) {} }; class AudioEffectHighPassFilter : public AudioEffectFilter { GDCLASS(AudioEffectHighPassFilter, AudioEffectFilter) public: - AudioEffectHighPassFilter() - : AudioEffectFilter(AudioFilterSW::HIGHPASS) {} + AudioEffectHighPassFilter() : + AudioEffectFilter(AudioFilterSW::HIGHPASS) {} }; class AudioEffectBandPassFilter : public AudioEffectFilter { GDCLASS(AudioEffectBandPassFilter, AudioEffectFilter) public: - AudioEffectBandPassFilter() - : AudioEffectFilter(AudioFilterSW::BANDPASS) {} + AudioEffectBandPassFilter() : + AudioEffectFilter(AudioFilterSW::BANDPASS) {} }; class AudioEffectNotchFilter : public AudioEffectFilter { GDCLASS(AudioEffectNotchFilter, AudioEffectFilter) public: - AudioEffectNotchFilter() - : AudioEffectFilter(AudioFilterSW::NOTCH) {} + AudioEffectNotchFilter() : + AudioEffectFilter(AudioFilterSW::NOTCH) {} }; class AudioEffectBandLimitFilter : public AudioEffectFilter { GDCLASS(AudioEffectBandLimitFilter, AudioEffectFilter) public: - AudioEffectBandLimitFilter() - : AudioEffectFilter(AudioFilterSW::BANDLIMIT) {} + AudioEffectBandLimitFilter() : + AudioEffectFilter(AudioFilterSW::BANDLIMIT) {} }; class AudioEffectLowShelfFilter : public AudioEffectFilter { GDCLASS(AudioEffectLowShelfFilter, AudioEffectFilter) public: - AudioEffectLowShelfFilter() - : AudioEffectFilter(AudioFilterSW::LOWSHELF) {} + AudioEffectLowShelfFilter() : + AudioEffectFilter(AudioFilterSW::LOWSHELF) {} }; class AudioEffectHighShelfFilter : public AudioEffectFilter { GDCLASS(AudioEffectHighShelfFilter, AudioEffectFilter) public: - AudioEffectHighShelfFilter() - : AudioEffectFilter(AudioFilterSW::HIGHSHELF) {} + AudioEffectHighShelfFilter() : + AudioEffectFilter(AudioFilterSW::HIGHSHELF) {} }; #endif // AUDIOEFFECTFILTER_H diff --git a/servers/audio/reverb_sw.cpp b/servers/audio/reverb_sw.cpp index 96d2ad848b..e2bb04c213 100644 --- a/servers/audio/reverb_sw.cpp +++ b/servers/audio/reverb_sw.cpp @@ -252,15 +252,13 @@ static ReverbParamsSW *reverb_param_modes[] = { bool ReverbSW::process(int *p_input, int *p_output, int p_frames, int p_stereo_stride) { + // p_input must point to a non-looping buffer. + // BOTH p_input and p_output must be touched (use ClearModuleBuffer). + if (!reverb_buffer) return false; -// -// p_input must point to a non-looping buffer. -// BOTH p_input and p_output must be touched (use ClearModuleBuffer). - // LOCAL MACROS - #undef LM_SETSRCOFFSET #define LM_SETSRCOFFSET(x) \ (x) = current_params->x + Offset; \ diff --git a/servers/physics/area_sw.cpp b/servers/physics/area_sw.cpp index 387230a478..9615708f1d 100644 --- a/servers/physics/area_sw.cpp +++ b/servers/physics/area_sw.cpp @@ -237,8 +237,10 @@ void AreaSW::call_queries() { //get_space()->area_remove_from_monitor_query_list(&monitor_query_list); } -AreaSW::AreaSW() - : CollisionObjectSW(TYPE_AREA), monitor_query_list(this), moved_list(this) { +AreaSW::AreaSW() : + CollisionObjectSW(TYPE_AREA), + monitor_query_list(this), + moved_list(this) { _set_static(true); //areas are never active space_override_mode = PhysicsServer::AREA_SPACE_OVERRIDE_DISABLED; diff --git a/servers/physics/body_pair_sw.cpp b/servers/physics/body_pair_sw.cpp index ef54eb58cf..80e0ad1b07 100644 --- a/servers/physics/body_pair_sw.cpp +++ b/servers/physics/body_pair_sw.cpp @@ -464,8 +464,8 @@ void BodyPairSW::solve(real_t p_step) { } } -BodyPairSW::BodyPairSW(BodySW *p_A, int p_shape_A, BodySW *p_B, int p_shape_B) - : ConstraintSW(_arr, 2) { +BodyPairSW::BodyPairSW(BodySW *p_A, int p_shape_A, BodySW *p_B, int p_shape_B) : + ConstraintSW(_arr, 2) { A = p_A; B = p_B; diff --git a/servers/physics/body_sw.cpp b/servers/physics/body_sw.cpp index f8cd6ca858..5057c6ab9d 100644 --- a/servers/physics/body_sw.cpp +++ b/servers/physics/body_sw.cpp @@ -740,8 +740,11 @@ void BodySW::set_kinematic_margin(real_t p_margin) { kinematic_safe_margin = p_margin; } -BodySW::BodySW() - : CollisionObjectSW(TYPE_BODY), active_list(this), inertia_update_list(this), direct_state_query_list(this) { +BodySW::BodySW() : + CollisionObjectSW(TYPE_BODY), + active_list(this), + inertia_update_list(this), + direct_state_query_list(this) { mode = PhysicsServer::BODY_MODE_RIGID; active = true; diff --git a/servers/physics/collision_object_sw.cpp b/servers/physics/collision_object_sw.cpp index 126f8141ff..ef7cd0780f 100644 --- a/servers/physics/collision_object_sw.cpp +++ b/servers/physics/collision_object_sw.cpp @@ -217,8 +217,8 @@ void CollisionObjectSW::_shape_changed() { _shapes_changed(); } -CollisionObjectSW::CollisionObjectSW(Type p_type) - : pending_shape_update_list(this) { +CollisionObjectSW::CollisionObjectSW(Type p_type) : + pending_shape_update_list(this) { _static = true; type = p_type; diff --git a/servers/physics/collision_solver_sat.cpp b/servers/physics/collision_solver_sat.cpp index a044df7f31..f56d311a59 100644 --- a/servers/physics/collision_solver_sat.cpp +++ b/servers/physics/collision_solver_sat.cpp @@ -255,7 +255,8 @@ static void _generate_contacts_from_supports(const Vector3 *p_points_A, int p_po _generate_contacts_face_face, }, { - 0, 0, + 0, + 0, _generate_contacts_face_face, } }; diff --git a/servers/physics/joints/cone_twist_joint_sw.cpp b/servers/physics/joints/cone_twist_joint_sw.cpp index 3c900d4fbe..617ce125b3 100644 --- a/servers/physics/joints/cone_twist_joint_sw.cpp +++ b/servers/physics/joints/cone_twist_joint_sw.cpp @@ -85,8 +85,8 @@ static _FORCE_INLINE_ real_t atan2fast(real_t y, real_t x) { return (y < 0.0f) ? -angle : angle; } -ConeTwistJointSW::ConeTwistJointSW(BodySW *rbA, BodySW *rbB, const Transform &rbAFrame, const Transform &rbBFrame) - : JointSW(_arr, 2) { +ConeTwistJointSW::ConeTwistJointSW(BodySW *rbA, BodySW *rbB, const Transform &rbAFrame, const Transform &rbBFrame) : + JointSW(_arr, 2) { A = rbA; B = rbB; diff --git a/servers/physics/joints/generic_6dof_joint_sw.cpp b/servers/physics/joints/generic_6dof_joint_sw.cpp index 1e323be36c..b8234be4d9 100644 --- a/servers/physics/joints/generic_6dof_joint_sw.cpp +++ b/servers/physics/joints/generic_6dof_joint_sw.cpp @@ -209,9 +209,11 @@ real_t G6DOFTranslationalLimitMotorSW::solveLinearAxis( //////////////////////////// G6DOFTranslationalLimitMotorSW //////////////////////////////////// -Generic6DOFJointSW::Generic6DOFJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA) - : JointSW(_arr, 2), m_frameInA(frameInA), m_frameInB(frameInB), - m_useLinearReferenceFrameA(useLinearReferenceFrameA) { +Generic6DOFJointSW::Generic6DOFJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB, bool useLinearReferenceFrameA) : + JointSW(_arr, 2), + m_frameInA(frameInA), + m_frameInB(frameInB), + m_useLinearReferenceFrameA(useLinearReferenceFrameA) { A = rbA; B = rbB; A->add_constraint(this, 0); diff --git a/servers/physics/joints/hinge_joint_sw.cpp b/servers/physics/joints/hinge_joint_sw.cpp index fe20a55b60..2edccc26c2 100644 --- a/servers/physics/joints/hinge_joint_sw.cpp +++ b/servers/physics/joints/hinge_joint_sw.cpp @@ -68,8 +68,8 @@ static void plane_space(const Vector3 &n, Vector3 &p, Vector3 &q) { } } -HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameA, const Transform &frameB) - : JointSW(_arr, 2) { +HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameA, const Transform &frameB) : + JointSW(_arr, 2) { A = rbA; B = rbB; @@ -101,8 +101,8 @@ HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameA, co } HingeJointSW::HingeJointSW(BodySW *rbA, BodySW *rbB, const Vector3 &pivotInA, const Vector3 &pivotInB, - const Vector3 &axisInA, const Vector3 &axisInB) - : JointSW(_arr, 2) { + const Vector3 &axisInA, const Vector3 &axisInB) : + JointSW(_arr, 2) { A = rbA; B = rbB; diff --git a/servers/physics/joints/jacobian_entry_sw.h b/servers/physics/joints/jacobian_entry_sw.h index 79ce0e6157..7aeb06ddd8 100644 --- a/servers/physics/joints/jacobian_entry_sw.h +++ b/servers/physics/joints/jacobian_entry_sw.h @@ -64,8 +64,8 @@ public: const Vector3 &inertiaInvA, const real_t massInvA, const Vector3 &inertiaInvB, - const real_t massInvB) - : m_linearJointAxis(jointAxis) { + const real_t massInvB) : + m_linearJointAxis(jointAxis) { m_aJ = world2A.xform(rel_pos1.cross(m_linearJointAxis)); m_bJ = world2B.xform(rel_pos2.cross(-m_linearJointAxis)); m_0MinvJt = inertiaInvA * m_aJ; @@ -80,8 +80,8 @@ public: const Basis &world2A, const Basis &world2B, const Vector3 &inertiaInvA, - const Vector3 &inertiaInvB) - : m_linearJointAxis(Vector3(real_t(0.), real_t(0.), real_t(0.))) { + const Vector3 &inertiaInvB) : + m_linearJointAxis(Vector3(real_t(0.), real_t(0.), real_t(0.))) { m_aJ = world2A.xform(jointAxis); m_bJ = world2B.xform(-jointAxis); m_0MinvJt = inertiaInvA * m_aJ; @@ -95,8 +95,10 @@ public: JacobianEntrySW(const Vector3 &axisInA, const Vector3 &axisInB, const Vector3 &inertiaInvA, - const Vector3 &inertiaInvB) - : m_linearJointAxis(Vector3(real_t(0.), real_t(0.), real_t(0.))), m_aJ(axisInA), m_bJ(-axisInB) { + const Vector3 &inertiaInvB) : + m_linearJointAxis(Vector3(real_t(0.), real_t(0.), real_t(0.))), + m_aJ(axisInA), + m_bJ(-axisInB) { m_0MinvJt = inertiaInvA * m_aJ; m_1MinvJt = inertiaInvB * m_bJ; m_Adiag = m_0MinvJt.dot(m_aJ) + m_1MinvJt.dot(m_bJ); @@ -110,8 +112,8 @@ public: const Vector3 &rel_pos1, const Vector3 &rel_pos2, const Vector3 &jointAxis, const Vector3 &inertiaInvA, - const real_t massInvA) - : m_linearJointAxis(jointAxis) { + const real_t massInvA) : + m_linearJointAxis(jointAxis) { m_aJ = world2A.xform(rel_pos1.cross(jointAxis)); m_bJ = world2A.xform(rel_pos2.cross(-jointAxis)); m_0MinvJt = inertiaInvA * m_aJ; diff --git a/servers/physics/joints/pin_joint_sw.cpp b/servers/physics/joints/pin_joint_sw.cpp index 779e086858..ab2ab2299a 100644 --- a/servers/physics/joints/pin_joint_sw.cpp +++ b/servers/physics/joints/pin_joint_sw.cpp @@ -146,8 +146,8 @@ real_t PinJointSW::get_param(PhysicsServer::PinJointParam p_param) const { return 0; } -PinJointSW::PinJointSW(BodySW *p_body_a, const Vector3 &p_pos_a, BodySW *p_body_b, const Vector3 &p_pos_b) - : JointSW(_arr, 2) { +PinJointSW::PinJointSW(BodySW *p_body_a, const Vector3 &p_pos_a, BodySW *p_body_b, const Vector3 &p_pos_b) : + JointSW(_arr, 2) { A = p_body_a; B = p_body_b; diff --git a/servers/physics/joints/slider_joint_sw.cpp b/servers/physics/joints/slider_joint_sw.cpp index 66585f2605..7777de0324 100644 --- a/servers/physics/joints/slider_joint_sw.cpp +++ b/servers/physics/joints/slider_joint_sw.cpp @@ -112,8 +112,10 @@ void SliderJointSW::initParams() { //----------------------------------------------------------------------------- -SliderJointSW::SliderJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB) - : JointSW(_arr, 2), m_frameInA(frameInA), m_frameInB(frameInB) { +SliderJointSW::SliderJointSW(BodySW *rbA, BodySW *rbB, const Transform &frameInA, const Transform &frameInB) : + JointSW(_arr, 2), + m_frameInA(frameInA), + m_frameInB(frameInB) { A = rbA; B = rbB; diff --git a/servers/physics/joints_sw.h b/servers/physics/joints_sw.h index b15ae08049..29581c7337 100644 --- a/servers/physics/joints_sw.h +++ b/servers/physics/joints_sw.h @@ -37,8 +37,8 @@ class JointSW : public ConstraintSW { public: virtual PhysicsServer::JointType get_type() const = 0; - _FORCE_INLINE_ JointSW(BodySW **p_body_ptr = NULL, int p_body_count = 0) - : ConstraintSW(p_body_ptr, p_body_count) { + _FORCE_INLINE_ JointSW(BodySW **p_body_ptr = NULL, int p_body_count = 0) : + ConstraintSW(p_body_ptr, p_body_count) { } }; diff --git a/servers/physics_2d/area_2d_sw.cpp b/servers/physics_2d/area_2d_sw.cpp index 6c0bc2c186..d73619ba13 100644 --- a/servers/physics_2d/area_2d_sw.cpp +++ b/servers/physics_2d/area_2d_sw.cpp @@ -238,8 +238,10 @@ void Area2DSW::call_queries() { //get_space()->area_remove_from_monitor_query_list(&monitor_query_list); } -Area2DSW::Area2DSW() - : CollisionObject2DSW(TYPE_AREA), monitor_query_list(this), moved_list(this) { +Area2DSW::Area2DSW() : + CollisionObject2DSW(TYPE_AREA), + monitor_query_list(this), + moved_list(this) { _set_static(true); //areas are not active by default space_override_mode = Physics2DServer::AREA_SPACE_OVERRIDE_DISABLED; diff --git a/servers/physics_2d/body_2d_sw.cpp b/servers/physics_2d/body_2d_sw.cpp index eb5fb5a729..2bdde244df 100644 --- a/servers/physics_2d/body_2d_sw.cpp +++ b/servers/physics_2d/body_2d_sw.cpp @@ -650,8 +650,11 @@ void Body2DSW::set_force_integration_callback(ObjectID p_id, const StringName &p } } -Body2DSW::Body2DSW() - : CollisionObject2DSW(TYPE_BODY), active_list(this), inertia_update_list(this), direct_state_query_list(this) { +Body2DSW::Body2DSW() : + CollisionObject2DSW(TYPE_BODY), + active_list(this), + inertia_update_list(this), + direct_state_query_list(this) { mode = Physics2DServer::BODY_MODE_RIGID; active = true; diff --git a/servers/physics_2d/body_pair_2d_sw.cpp b/servers/physics_2d/body_pair_2d_sw.cpp index 828b90e5d0..b106b37db0 100644 --- a/servers/physics_2d/body_pair_2d_sw.cpp +++ b/servers/physics_2d/body_pair_2d_sw.cpp @@ -417,7 +417,7 @@ bool BodyPair2DSW::setup(real_t p_step) { c.bias = -bias * inv_dt * MIN(0.0f, -depth + max_penetration); c.depth = depth; -//c.acc_bias_impulse=0; + //c.acc_bias_impulse=0; #ifdef ACCUMULATE_IMPULSES { @@ -500,8 +500,8 @@ void BodyPair2DSW::solve(real_t p_step) { } } -BodyPair2DSW::BodyPair2DSW(Body2DSW *p_A, int p_shape_A, Body2DSW *p_B, int p_shape_B) - : Constraint2DSW(_arr, 2) { +BodyPair2DSW::BodyPair2DSW(Body2DSW *p_A, int p_shape_A, Body2DSW *p_B, int p_shape_B) : + Constraint2DSW(_arr, 2) { A = p_A; B = p_B; diff --git a/servers/physics_2d/joints_2d_sw.cpp b/servers/physics_2d/joints_2d_sw.cpp index 897e145a3e..caeb62d74f 100644 --- a/servers/physics_2d/joints_2d_sw.cpp +++ b/servers/physics_2d/joints_2d_sw.cpp @@ -178,8 +178,8 @@ real_t PinJoint2DSW::get_param(Physics2DServer::PinJointParam p_param) const { ERR_FAIL_V(0); } -PinJoint2DSW::PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p_body_b) - : Joint2DSW(_arr, p_body_b ? 2 : 1) { +PinJoint2DSW::PinJoint2DSW(const Vector2 &p_pos, Body2DSW *p_body_a, Body2DSW *p_body_b) : + Joint2DSW(_arr, p_body_b ? 2 : 1) { A = p_body_a; B = p_body_b; @@ -323,8 +323,8 @@ void GrooveJoint2DSW::solve(real_t p_step) { B->apply_impulse(rB, j); } -GrooveJoint2DSW::GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, Body2DSW *p_body_a, Body2DSW *p_body_b) - : Joint2DSW(_arr, 2) { +GrooveJoint2DSW::GrooveJoint2DSW(const Vector2 &p_a_groove1, const Vector2 &p_a_groove2, const Vector2 &p_b_anchor, Body2DSW *p_body_a, Body2DSW *p_body_b) : + Joint2DSW(_arr, 2) { A = p_body_a; B = p_body_b; @@ -432,8 +432,8 @@ real_t DampedSpringJoint2DSW::get_param(Physics2DServer::DampedStringParam p_par ERR_FAIL_V(0); } -DampedSpringJoint2DSW::DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, Body2DSW *p_body_a, Body2DSW *p_body_b) - : Joint2DSW(_arr, 2) { +DampedSpringJoint2DSW::DampedSpringJoint2DSW(const Vector2 &p_anchor_a, const Vector2 &p_anchor_b, Body2DSW *p_body_a, Body2DSW *p_body_b) : + Joint2DSW(_arr, 2) { A = p_body_a; B = p_body_b; diff --git a/servers/physics_2d/joints_2d_sw.h b/servers/physics_2d/joints_2d_sw.h index 11cb41d9d1..0e5e8012b6 100644 --- a/servers/physics_2d/joints_2d_sw.h +++ b/servers/physics_2d/joints_2d_sw.h @@ -50,8 +50,8 @@ public: _FORCE_INLINE_ real_t get_max_bias() const { return max_bias; } virtual Physics2DServer::JointType get_type() const = 0; - Joint2DSW(Body2DSW **p_body_ptr = NULL, int p_body_count = 0) - : Constraint2DSW(p_body_ptr, p_body_count) { + Joint2DSW(Body2DSW **p_body_ptr = NULL, int p_body_count = 0) : + Constraint2DSW(p_body_ptr, p_body_count) { bias = 0; max_force = max_bias = 3.40282e+38; }; diff --git a/servers/physics_2d/physics_2d_server_wrap_mt.cpp b/servers/physics_2d/physics_2d_server_wrap_mt.cpp index f92ed18de2..0e5bd82599 100644 --- a/servers/physics_2d/physics_2d_server_wrap_mt.cpp +++ b/servers/physics_2d/physics_2d_server_wrap_mt.cpp @@ -151,8 +151,8 @@ void Physics2DServerWrapMT::finish() { memdelete(step_sem); } -Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool p_create_thread) - : command_queue(p_create_thread) { +Physics2DServerWrapMT::Physics2DServerWrapMT(Physics2DServer *p_contained, bool p_create_thread) : + command_queue(p_create_thread) { physics_2d_server = p_contained; create_thread = p_create_thread; diff --git a/servers/physics_2d_server.h b/servers/physics_2d_server.h index d6a988f512..c57503f06e 100644 --- a/servers/physics_2d_server.h +++ b/servers/physics_2d_server.h @@ -589,14 +589,17 @@ class Physics2DServerManager { String name; CreatePhysics2DServerCallback create_callback; - ClassInfo() - : name(""), create_callback(NULL) {} + ClassInfo() : + name(""), + create_callback(NULL) {} - ClassInfo(String p_name, CreatePhysics2DServerCallback p_create_callback) - : name(p_name), create_callback(p_create_callback) {} + ClassInfo(String p_name, CreatePhysics2DServerCallback p_create_callback) : + name(p_name), + create_callback(p_create_callback) {} - ClassInfo(const ClassInfo &p_ci) - : name(p_ci.name), create_callback(p_ci.create_callback) {} + ClassInfo(const ClassInfo &p_ci) : + name(p_ci.name), + create_callback(p_ci.create_callback) {} }; static Vector<ClassInfo> physics_2d_servers; diff --git a/servers/physics_server.h b/servers/physics_server.h index 9a4155dd8b..4886317224 100644 --- a/servers/physics_server.h +++ b/servers/physics_server.h @@ -652,14 +652,17 @@ class PhysicsServerManager { String name; CreatePhysicsServerCallback create_callback; - ClassInfo() - : name(""), create_callback(NULL) {} + ClassInfo() : + name(""), + create_callback(NULL) {} - ClassInfo(String p_name, CreatePhysicsServerCallback p_create_callback) - : name(p_name), create_callback(p_create_callback) {} + ClassInfo(String p_name, CreatePhysicsServerCallback p_create_callback) : + name(p_name), + create_callback(p_create_callback) {} - ClassInfo(const ClassInfo &p_ci) - : name(p_ci.name), create_callback(p_ci.create_callback) {} + ClassInfo(const ClassInfo &p_ci) : + name(p_ci.name), + create_callback(p_ci.create_callback) {} }; static Vector<ClassInfo> physics_servers; diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index 4bb34af241..0ee70878dc 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -116,8 +116,8 @@ public: virtual void base_changed() = 0; virtual void base_material_changed() = 0; - InstanceBase() - : dependency_item(this) { + InstanceBase() : + dependency_item(this) { base_type = VS::INSTANCE_NONE; cast_shadows = VS::SHADOW_CASTING_SETTING_ON; diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 91542625e0..9223d81e32 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -77,8 +77,8 @@ class VisualServerRaster : public VisualServer { static void _changes_changed() {} public: -//if editor is redrawing when it shouldn't, enable this and put a breakpoint in _changes_changed() -//#define DEBUG_CHANGES + //if editor is redrawing when it shouldn't, enable this and put a breakpoint in _changes_changed() + //#define DEBUG_CHANGES #ifdef DEBUG_CHANGES _FORCE_INLINE_ static void redraw_request() { @@ -96,7 +96,6 @@ public: #define DISPLAY_CHANGED \ changes++; #endif -// print_line(String("CHANGED: ") + __FUNCTION__); #define BIND0R(m_r, m_name) \ m_r m_name() { return BINDBASE->m_name(); } @@ -451,7 +450,7 @@ public: BIND2R(int, viewport_get_render_info, RID, ViewportRenderInfo) BIND2(viewport_set_debug_draw, RID, ViewportDebugDraw) -/* ENVIRONMENT API */ + /* ENVIRONMENT API */ #undef BINDBASE //from now on, calls forwarded to this singleton @@ -481,7 +480,7 @@ public: BIND6(environment_set_fog_depth, RID, bool, float, float, bool, float) BIND5(environment_set_fog_height, RID, bool, float, float, float) -/* SCENARIO API */ + /* SCENARIO API */ #undef BINDBASE #define BINDBASE VSG::scene diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 69827b330d..eef4720d22 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -303,6 +303,23 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { VSG::storage->instance_remove_dependency(instance->base, instance); + if (instance->base_type == VS::INSTANCE_GI_PROBE) { + //if gi probe is baking, wait until done baking, else race condition may happen when removing it + //from octree + InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data); + + //make sure probes are done baking + while (!probe_bake_list.empty()) { + OS::get_singleton()->delay_usec(1); + } + //make sure this one is done baking + + while (gi_probe->dynamic.updating_stage == GI_UPDATE_STAGE_LIGHTING) { + //wait until bake is done if it's baking + OS::get_singleton()->delay_usec(1); + } + } + if (scenario && instance->octree_id) { scenario->octree.erase(instance->octree_id); //make dependencies generated by the octree go away instance->octree_id = 0; @@ -331,10 +348,6 @@ void VisualServerScene::instance_set_base(RID p_instance, RID p_base) { InstanceGIProbeData *gi_probe = static_cast<InstanceGIProbeData *>(instance->base_data); - while (gi_probe->dynamic.updating_stage == GI_UPDATE_STAGE_LIGHTING) { - //wait until bake is done if it's baking - OS::get_singleton()->delay_usec(1); - } if (gi_probe->update_element.in_list()) { gi_probe_update_list.remove(&gi_probe->update_element); } @@ -1320,9 +1333,7 @@ void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_view p_viewport_size.width / (float)p_viewport_size.height, camera->znear, camera->zfar, - camera->vaspect - - ); + camera->vaspect); ortho = true; } break; case Camera::PERSPECTIVE: { @@ -1332,9 +1343,7 @@ void VisualServerScene::render_camera(RID p_camera, RID p_scenario, Size2 p_view p_viewport_size.width / (float)p_viewport_size.height, camera->znear, camera->zfar, - camera->vaspect - - ); + camera->vaspect); ortho = false; } break; @@ -2589,7 +2598,15 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) { } //send back to main thread to update un little chunks + if (probe_bake_mutex) { + probe_bake_mutex->lock(); + } + probe_data->dynamic.updating_stage = GI_UPDATE_STAGE_UPLOADING; + + if (probe_bake_mutex) { + probe_bake_mutex->unlock(); + } } bool VisualServerScene::_check_gi_probe(Instance *p_gi_probe) { @@ -2721,12 +2738,11 @@ void VisualServerScene::render_probes() { switch (probe->dynamic.updating_stage) { case GI_UPDATE_STAGE_CHECK: { - if (_check_gi_probe(instance_probe) || force_lighting) { - //send to lighting thread - probe->dynamic.updating_stage = GI_UPDATE_STAGE_LIGHTING; + if (_check_gi_probe(instance_probe) || force_lighting) { //send to lighting thread #ifndef NO_THREADS probe_bake_mutex->lock(); + probe->dynamic.updating_stage = GI_UPDATE_STAGE_LIGHTING; probe_bake_list.push_back(instance_probe); probe_bake_mutex->unlock(); probe_bake_sem->post(); diff --git a/servers/visual/visual_server_scene.h b/servers/visual/visual_server_scene.h index 9af5ffb74d..9e4701de65 100644 --- a/servers/visual/visual_server_scene.h +++ b/servers/visual/visual_server_scene.h @@ -229,8 +229,9 @@ public: singleton->_instance_queue_update(this, false, true); } - Instance() - : scenario_item(this), update_item(this) { + Instance() : + scenario_item(this), + update_item(this) { octree_id = 0; scenario = NULL; @@ -305,8 +306,8 @@ public: int render_step; - InstanceReflectionProbeData() - : update_list(this) { + InstanceReflectionProbeData() : + update_list(this) { reflection_dirty = true; render_step = -1; @@ -434,10 +435,11 @@ public: SelfList<InstanceGIProbeData> update_element; - InstanceGIProbeData() - : update_element(this) { + InstanceGIProbeData() : + update_element(this) { invalid = true; base_version = 0; + dynamic.updating_stage = GI_UPDATE_STAGE_CHECK; } }; diff --git a/servers/visual/visual_server_wrap_mt.cpp b/servers/visual/visual_server_wrap_mt.cpp index 03c68ab454..b86a0ae3f6 100644 --- a/servers/visual/visual_server_wrap_mt.cpp +++ b/servers/visual/visual_server_wrap_mt.cpp @@ -158,8 +158,8 @@ void VisualServerWrapMT::finish() { canvas_occluder_polygon_free_cached_ids(); } -VisualServerWrapMT::VisualServerWrapMT(VisualServer *p_contained, bool p_create_thread) - : command_queue(p_create_thread) { +VisualServerWrapMT::VisualServerWrapMT(VisualServer *p_contained, bool p_create_thread) : + command_queue(p_create_thread) { visual_server = p_contained; create_thread = p_create_thread; diff --git a/servers/visual/visual_server_wrap_mt.h b/servers/visual/visual_server_wrap_mt.h index 1c3b34d16f..b58b1d917e 100644 --- a/servers/visual/visual_server_wrap_mt.h +++ b/servers/visual/visual_server_wrap_mt.h @@ -62,7 +62,7 @@ class VisualServerWrapMT : public VisualServer { int pool_max_size; -//#define DEBUG_SYNC + //#define DEBUG_SYNC #ifdef DEBUG_SYNC #define SYNC_DEBUG print_line("sync on: " + String(__FUNCTION__)); diff --git a/thirdparty/README.md b/thirdparty/README.md index 1573fab7b6..8ff64c4636 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -390,17 +390,13 @@ Files extracted from upstream source: ## tinyexr - Upstream: https://github.com/syoyo/tinyexr -- Version: 0.9.5+ (git a145d69) +- Version: 0.9.5+ (git 9f784ca - 24 October 2017) - License: BSD-3-Clause Files extracted from upstream source: - `tinyexr.{cc,h}` -Important: Some changes were made to get TinyEXR to build on the ancient -MinGW-w64 toolchain of Travis CI. -https://github.com/godotengine/godot/commit/37f5e1dcd94611dd5b670f013abf0323e8b47def - ## zlib diff --git a/thirdparty/tinyexr/tinyexr.h b/thirdparty/tinyexr/tinyexr.h index c82768be9a..606c19756a 100644 --- a/thirdparty/tinyexr/tinyexr.h +++ b/thirdparty/tinyexr/tinyexr.h @@ -85,11 +85,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include <stddef.h> // for size_t #include <stdint.h> // guess stdint.h is available(C99) -// -- GODOT change for old MinGW on Travis CI -- -#if defined(__MINGW32__) -#include <_mingw.h> // for __MINGW64_VERSION_MAJOR -#endif - #ifdef __cplusplus extern "C" { #endif @@ -264,7 +259,8 @@ typedef struct _DeepImage { } DeepImage; // @deprecated { to be removed. } -// Loads single-frame OpenEXR image. Assume EXR image contains RGB(A) channels. +// Loads single-frame OpenEXR image. Assume EXR image contains A(single channel +// alpha) or RGB(A) channels. // Application must free image data as returned by `out_rgba` // Result image format is: float x RGBA x width x hight // Returns negative value and may set error string in `err` when there's an @@ -274,9 +270,14 @@ extern int LoadEXR(float **out_rgba, int *width, int *height, // @deprecated { to be removed. } // Saves single-frame OpenEXR image. Assume EXR image contains RGB(A) channels. -// components must be 3(RGB) or 4(RGBA). -// Result image format is: float x RGB(A) x width x hight -extern int SaveEXR(const float *data, int width, int height, int components, +// components must be 1(Grayscale), 3(RGB) or 4(RGBA). +// Input image format is: `float x width x height`, or `float x RGB(A) x width x +// hight` +// Save image as fp16(HALF) format when `save_as_fp16` is positive non-zero +// value. +// Save image as fp32(FLOAT) format when `save_as_fp16` is 0. +extern int SaveEXR(const float *data, const int width, const int height, + const int components, const int save_as_fp16, const char *filename); // Initialize EXRHeader struct @@ -406,12 +407,11 @@ extern int LoadDeepEXR(DeepImage *out_image, const char *filename, // For emscripten. // Loads single-frame OpenEXR image from memory. Assume EXR image contains // RGB(A) channels. -// `out_rgba` must have enough memory(at least sizeof(float) x 4(RGBA) x width x -// hight) // Returns negative value and may set error string in `err` when there's an // error -extern int LoadEXRFromMemory(float *out_rgba, const unsigned char *memory, - size_t size, const char **err); +extern int LoadEXRFromMemory(float **out_rgba, int *width, int *height, + const unsigned char *memory, size_t size, + const char **err); #ifdef __cplusplus } @@ -444,7 +444,8 @@ extern int LoadEXRFromMemory(float *out_rgba, const unsigned char *memory, #if TINYEXR_USE_MINIZ #else -#include "zlib.h" +// Issue #46. Please include your own zlib-compatible API header before including `tinyexr.h` +//#include "zlib.h" #endif #if TINYEXR_USE_ZFP @@ -483,13 +484,11 @@ namespace miniz { #pragma clang diagnostic ignored "-Wsign-conversion" #pragma clang diagnostic ignored "-Wc++11-extensions" #pragma clang diagnostic ignored "-Wconversion" -#ifdef __APPLE__ -#if __clang_major__ >= 8 && __clang__minor__ > 1 +#pragma clang diagnostic ignored "-Wunused-function" +#if __has_warning("-Wcomma") #pragma clang diagnostic ignored "-Wcomma" #endif #endif -#pragma clang diagnostic ignored "-Wunused-function" -#endif /* miniz.c v1.15 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing @@ -1918,11 +1917,11 @@ static void def_free_func(void *opaque, void *address) { (void)opaque, (void)address; MZ_FREE(address); } -static void *def_realloc_func(void *opaque, void *address, size_t items, - size_t size) { - (void)opaque, (void)address, (void)items, (void)size; - return MZ_REALLOC(address, items * size); -} +// static void *def_realloc_func(void *opaque, void *address, size_t items, +// size_t size) { +// (void)opaque, (void)address, (void)items, (void)size; +// return MZ_REALLOC(address, items * size); +//} const char *mz_version(void) { return MZ_VERSION; } @@ -2894,8 +2893,9 @@ void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, tinfl_status status = tinfl_decompress( &decomp, (const mz_uint8 *)pSrc_buf + src_buf_ofs, &src_buf_size, (mz_uint8 *)pBuf, pBuf ? (mz_uint8 *)pBuf + *pOut_len : NULL, - &dst_buf_size, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | - TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); + &dst_buf_size, + (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | + TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF); if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT)) { MZ_FREE(pBuf); *pOut_len = 0; @@ -3542,9 +3542,10 @@ static int tdefl_flush_block(tdefl_compressor *d, int flush) { mz_uint saved_bit_buf, saved_bits_in; mz_uint8 *pSaved_output_buf; mz_bool comp_block_succeeded = MZ_FALSE; - int n, use_raw_block = - ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && - (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size; + int n, + use_raw_block = + ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && + (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size; mz_uint8 *pOutput_buf_start = ((d->m_pPut_buf_func == NULL) && ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE)) @@ -3574,8 +3575,9 @@ static int tdefl_flush_block(tdefl_compressor *d, int flush) { if (!use_raw_block) comp_block_succeeded = - tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || - (d->m_total_lz_bytes < 48)); + tdefl_compress_block(d, + (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || + (d->m_total_lz_bytes < 48)); // If the block gets expanded, forget the current contents of the output // buffer and send a raw block instead. @@ -4519,10 +4521,7 @@ void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, #include <stdio.h> #include <sys/stat.h> -// -- GODOT change for old MinGW on Travis CI -- -//#if defined(_MSC_VER) || defined(__MINGW64__) -#if defined(_MSC_VER) || (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 3) -// -- GODOT end -- +#if defined(_MSC_VER) || defined(__MINGW64__) static FILE *mz_fopen(const char *pFilename, const char *pMode) { FILE *pFile = NULL; fopen_s(&pFile, pFilename, pMode); @@ -5223,9 +5222,10 @@ mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1); pStat->m_comment_size = n; - memcpy(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + - MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + - MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), + memcpy(pStat->m_comment, + p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), n); pStat->m_comment[n] = '\0'; @@ -6883,6 +6883,12 @@ void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, #ifdef __clang__ #pragma clang diagnostic pop #endif + +#ifdef _MSC_VER +#pragma warning(pop) +#endif + + } #else @@ -7346,11 +7352,23 @@ static void CompressZip(unsigned char *dst, compressedSize = outSize; #endif + + // Use uncompressed data when compressed data is larger than uncompressed. + // (Issue 40) + if (compressedSize >= src_size) { + compressedSize = src_size; + memcpy(dst, src, src_size); + } } static void DecompressZip(unsigned char *dst, unsigned long *uncompressed_size /* inout */, const unsigned char *src, unsigned long src_size) { + if ((*uncompressed_size) == src_size) { + // Data is not compressed(Issue 40). + memcpy(dst, src, src_size); + return; + } std::vector<unsigned char> tmpBuf(*uncompressed_size); #if TINYEXR_USE_MINIZ @@ -7410,6 +7428,22 @@ static void DecompressZip(unsigned char *dst, #pragma clang diagnostic ignored "-Wsign-conversion" #endif +#ifdef _MSC_VER +#pragma warning(push) +#pragma warning(disable : 4204) // nonstandard extension used : non-constant + // aggregate initializer (also supported by GNU + // C and C99, so no big deal) +#pragma warning(disable : 4244) // 'initializing': conversion from '__int64' to + // 'int', possible loss of data +#pragma warning( \ + disable : 4267) // 'argument': conversion from '__int64' to 'int', + // possible loss of data +#pragma warning(disable : 4996) // 'strdup': The POSIX name for this item is + // deprecated. Instead, use the ISO C and C++ + // conformant name: _strdup. +#endif + + const int MIN_RUN_LENGTH = 3; const int MAX_RUN_LENGTH = 127; @@ -7502,6 +7536,7 @@ static int rleUncompress(int inLength, int maxLength, const signed char in[], #ifdef __clang__ #pragma clang diagnostic pop #endif + // End of RLE code from OpenEXR ----------------------------------- static void CompressRle(unsigned char *dst, @@ -7562,11 +7597,24 @@ static void CompressRle(unsigned char *dst, assert(outSize > 0); compressedSize = static_cast<tinyexr::tinyexr_uint64>(outSize); + + // Use uncompressed data when compressed data is larger than uncompressed. + // (Issue 40) + if (compressedSize >= src_size) { + compressedSize = src_size; + memcpy(dst, src, src_size); + } } static void DecompressRle(unsigned char *dst, const unsigned long uncompressed_size, const unsigned char *src, unsigned long src_size) { + if (uncompressed_size == src_size) { + // Data is not compressed(Issue 40). + memcpy(dst, src, src_size); + return; + } + std::vector<unsigned char> tmpBuf(uncompressed_size); int ret = rleUncompress(static_cast<int>(src_size), @@ -8882,7 +8930,12 @@ static void applyLut(const unsigned short lut[USHORT_RANGE], #pragma clang diagnostic pop #endif // __clang__ -static bool CompressPiz(unsigned char *outPtr, unsigned int &outSize, +#ifdef _MSC_VER +#pragma warning(pop) +#endif + + +static bool CompressPiz(unsigned char *outPtr, unsigned int *outSize, const unsigned char *inPtr, size_t inSize, const std::vector<ChannelInfo> &channelInfo, int data_width, int num_lines) { @@ -8989,16 +9042,29 @@ static bool CompressPiz(unsigned char *outPtr, unsigned int &outSize, hufCompress(&tmpBuffer.at(0), static_cast<int>(tmpBuffer.size()), buf); memcpy(lengthPtr, &length, sizeof(int)); - outSize = static_cast<unsigned int>( + (*outSize) = static_cast<unsigned int>( (reinterpret_cast<unsigned char *>(buf) - outPtr) + static_cast<unsigned int>(length)); + + // Use uncompressed data when compressed data is larger than uncompressed. + // (Issue 40) + if ((*outSize) >= inSize) { + (*outSize) = static_cast<unsigned int>(inSize); + memcpy(outPtr, inPtr, inSize); + } return true; } static bool DecompressPiz(unsigned char *outPtr, const unsigned char *inPtr, - size_t tmpBufSize, int num_channels, + size_t tmpBufSize, size_t inLen, int num_channels, const EXRChannelInfo *channels, int data_width, int num_lines) { + if (inLen == tmpBufSize) { + // Data is not compressed(Issue 40). + memcpy(outPtr, inPtr, inLen); + return true; + } + unsigned char bitmap[BITMAP_SIZE]; unsigned short minNonZero; unsigned short maxNonZero; @@ -9173,6 +9239,11 @@ static bool DecompressZfp(float *dst, int dst_width, int dst_num_lines, const ZFPCompressionParam ¶m) { size_t uncompressed_size = dst_width * dst_num_lines * num_channels; + if (uncompressed_size == src_size) { + // Data is not compressed(Issue 40). + memcpy(dst, src, src_size); + } + zfp_stream *zfp = NULL; zfp_field *field = NULL; @@ -9317,12 +9388,11 @@ static void DecodePixelData(/* out */ unsigned char **out_images, // Allocate original data size. std::vector<unsigned char> outBuf(static_cast<size_t>( static_cast<size_t>(width * num_lines) * pixel_data_size)); - size_t tmpBufLen = static_cast<size_t>( - static_cast<size_t>(width * num_lines) * pixel_data_size); + size_t tmpBufLen = outBuf.size(); bool ret = tinyexr::DecompressPiz( reinterpret_cast<unsigned char *>(&outBuf.at(0)), data_ptr, tmpBufLen, - static_cast<int>(num_channels), channels, width, num_lines); + data_len, static_cast<int>(num_channels), channels, width, num_lines); assert(ret); (void)ret; @@ -10047,8 +10117,7 @@ static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, } else if (attr_name.compare("compression") == 0) { bool ok = false; - if ((data[0] >= TINYEXR_COMPRESSIONTYPE_NONE) && - (data[0] < TINYEXR_COMPRESSIONTYPE_PIZ)) { + if (data[0] < TINYEXR_COMPRESSIONTYPE_PIZ) { ok = true; } @@ -10158,9 +10227,14 @@ static int ParseEXRHeader(HeaderInfo *info, bool *empty_header, // Custom attribute(up to TINYEXR_MAX_ATTRIBUTES) if (info->attributes.size() < TINYEXR_MAX_ATTRIBUTES) { EXRAttribute attrib; +#ifdef _MSC_VER + strncpy_s(attrib.name, attr_name.c_str(), 255); + strncpy_s(attrib.type, attr_type.c_str(), 255); +#else strncpy(attrib.name, attr_name.c_str(), 255); - attrib.name[255] = '\0'; strncpy(attrib.type, attr_type.c_str(), 255); +#endif + attrib.name[255] = '\0'; attrib.type[255] = '\0'; attrib.size = static_cast<int>(data.size()); attrib.value = static_cast<unsigned char *>(malloc(data.size())); @@ -10254,8 +10328,12 @@ static void ConvertHeader(EXRHeader *exr_header, const HeaderInfo &info) { exr_header->channels = static_cast<EXRChannelInfo *>(malloc( sizeof(EXRChannelInfo) * static_cast<size_t>(exr_header->num_channels))); for (size_t c = 0; c < static_cast<size_t>(exr_header->num_channels); c++) { +#ifdef _MSC_VER + strncpy_s(exr_header->channels[c].name, info.channels[c].name.c_str(), 255); +#else strncpy(exr_header->channels[c].name, info.channels[c].name.c_str(), 255); - // manually add '\0' for safety. +#endif + // manually add '\0' for safety. exr_header->channels[c].name[255] = '\0'; exr_header->channels[c].pixel_type = info.channels[c].pixel_type; @@ -10317,6 +10395,8 @@ static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, &channel_offset, num_channels, exr_header->channels); + bool invalid_data = false; + if (exr_header->tiled) { size_t num_tiles = offsets.size(); // = # of blocks @@ -10411,18 +10491,26 @@ static int DecodeChunk(EXRImage *exr_image, const EXRHeader *exr_header, // Adjust line_no with data_window.bmin.y line_no -= exr_header->data_window[1]; - tinyexr::DecodePixelData( - exr_image->images, exr_header->requested_pixel_types, data_ptr, - static_cast<size_t>(data_len), exr_header->compression_type, - exr_header->line_order, data_width, data_height, data_width, y, - line_no, num_lines, static_cast<size_t>(pixel_data_size), - static_cast<size_t>(exr_header->num_custom_attributes), - exr_header->custom_attributes, - static_cast<size_t>(exr_header->num_channels), exr_header->channels, - channel_offset_list); + if (line_no < 0) { + invalid_data = true; + } else { + tinyexr::DecodePixelData( + exr_image->images, exr_header->requested_pixel_types, data_ptr, + static_cast<size_t>(data_len), exr_header->compression_type, + exr_header->line_order, data_width, data_height, data_width, y, + line_no, num_lines, static_cast<size_t>(pixel_data_size), + static_cast<size_t>(exr_header->num_custom_attributes), + exr_header->custom_attributes, + static_cast<size_t>(exr_header->num_channels), exr_header->channels, + channel_offset_list); + } } // omp parallel } + if (invalid_data) { + return TINYEXR_ERROR_INVALID_DATA; + } + // Overwrite `pixel_type` with `requested_pixel_type`. { for (int c = 0; c < exr_header->num_channels; c++) { @@ -10641,46 +10729,63 @@ int LoadEXR(float **out_rgba, int *width, int *height, const char *filename, } } - if (idxR == -1) { - if (err) { - (*err) = "R channel not found\n"; + if ((idxA == 0) && (idxR == -1) && (idxG == -1) && (idxB == -1)) { + // Alpha channel only. + + (*out_rgba) = reinterpret_cast<float *>( + malloc(4 * sizeof(float) * static_cast<size_t>(exr_image.width) * + static_cast<size_t>(exr_image.height))); + for (int i = 0; i < exr_image.width * exr_image.height; i++) { + const float val = reinterpret_cast<float **>(exr_image.images)[0][i]; + (*out_rgba)[4 * i + 0] = val; + (*out_rgba)[4 * i + 1] = val; + (*out_rgba)[4 * i + 2] = val; + (*out_rgba)[4 * i + 3] = val; } + } else { + // Assume RGB(A) - // @todo { free exr_image } - return TINYEXR_ERROR_INVALID_DATA; - } + if (idxR == -1) { + if (err) { + (*err) = "R channel not found\n"; + } - if (idxG == -1) { - if (err) { - (*err) = "G channel not found\n"; + // @todo { free exr_image } + return TINYEXR_ERROR_INVALID_DATA; } - // @todo { free exr_image } - return TINYEXR_ERROR_INVALID_DATA; - } - if (idxB == -1) { - if (err) { - (*err) = "B channel not found\n"; + if (idxG == -1) { + if (err) { + (*err) = "G channel not found\n"; + } + // @todo { free exr_image } + return TINYEXR_ERROR_INVALID_DATA; } - // @todo { free exr_image } - return TINYEXR_ERROR_INVALID_DATA; - } - (*out_rgba) = reinterpret_cast<float *>( - malloc(4 * sizeof(float) * static_cast<size_t>(exr_image.width) * - static_cast<size_t>(exr_image.height))); - for (int i = 0; i < exr_image.width * exr_image.height; i++) { - (*out_rgba)[4 * i + 0] = - reinterpret_cast<float **>(exr_image.images)[idxR][i]; - (*out_rgba)[4 * i + 1] = - reinterpret_cast<float **>(exr_image.images)[idxG][i]; - (*out_rgba)[4 * i + 2] = - reinterpret_cast<float **>(exr_image.images)[idxB][i]; - if (idxA != -1) { - (*out_rgba)[4 * i + 3] = - reinterpret_cast<float **>(exr_image.images)[idxA][i]; - } else { - (*out_rgba)[4 * i + 3] = 1.0; + if (idxB == -1) { + if (err) { + (*err) = "B channel not found\n"; + } + // @todo { free exr_image } + return TINYEXR_ERROR_INVALID_DATA; + } + + (*out_rgba) = reinterpret_cast<float *>( + malloc(4 * sizeof(float) * static_cast<size_t>(exr_image.width) * + static_cast<size_t>(exr_image.height))); + for (int i = 0; i < exr_image.width * exr_image.height; i++) { + (*out_rgba)[4 * i + 0] = + reinterpret_cast<float **>(exr_image.images)[idxR][i]; + (*out_rgba)[4 * i + 1] = + reinterpret_cast<float **>(exr_image.images)[idxG][i]; + (*out_rgba)[4 * i + 2] = + reinterpret_cast<float **>(exr_image.images)[idxB][i]; + if (idxA != -1) { + (*out_rgba)[4 * i + 3] = + reinterpret_cast<float **>(exr_image.images)[idxA][i]; + } else { + (*out_rgba)[4 * i + 3] = 1.0; + } } } @@ -10720,7 +10825,11 @@ int ParseEXRHeaderFromMemory(EXRHeader *exr_header, const EXRVersion *version, if (ret != TINYEXR_SUCCESS) { if (err && !err_str.empty()) { +#ifdef _WIN32 + (*err) = _strdup(err_str.c_str()); // May leak +#else (*err) = strdup(err_str.c_str()); // May leak +#endif } } @@ -10732,8 +10841,9 @@ int ParseEXRHeaderFromMemory(EXRHeader *exr_header, const EXRVersion *version, return ret; } -int LoadEXRFromMemory(float *out_rgba, const unsigned char *memory, size_t size, - const char **err) { +int LoadEXRFromMemory(float **out_rgba, int *width, int *height, + const unsigned char *memory, size_t size, + const char **err) { if (out_rgba == NULL || memory == NULL) { if (err) { (*err) = "Invalid argument.\n"; @@ -10756,6 +10866,13 @@ int LoadEXRFromMemory(float *out_rgba, const unsigned char *memory, size_t size, if (ret != TINYEXR_SUCCESS) { return ret; } + + // Read HALF channel as FLOAT. + for (int i = 0; i < exr_header.num_channels; i++) { + if (exr_header.pixel_types[i] == TINYEXR_PIXELTYPE_HALF) { + exr_header.requested_pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; + } + } InitEXRImage(&exr_image); ret = LoadEXRImageFromMemory(&exr_image, &exr_header, memory, size, err); @@ -10805,19 +10922,32 @@ int LoadEXRFromMemory(float *out_rgba, const unsigned char *memory, size_t size, return TINYEXR_ERROR_INVALID_DATA; } - // Assume `out_rgba` have enough memory allocated. + (*out_rgba) = reinterpret_cast<float *>( + malloc(4 * sizeof(float) * static_cast<size_t>(exr_image.width) * + static_cast<size_t>(exr_image.height))); + for (int i = 0; i < exr_image.width * exr_image.height; i++) { - out_rgba[4 * i + 0] = reinterpret_cast<float **>(exr_image.images)[idxR][i]; - out_rgba[4 * i + 1] = reinterpret_cast<float **>(exr_image.images)[idxG][i]; - out_rgba[4 * i + 2] = reinterpret_cast<float **>(exr_image.images)[idxB][i]; - if (idxA > 0) { - out_rgba[4 * i + 3] = - reinterpret_cast<float **>(exr_image.images)[idxA][i]; - } else { - out_rgba[4 * i + 3] = 1.0; - } + (*out_rgba)[4 * i + 0] = + reinterpret_cast<float **>(exr_image.images)[idxR][i]; + (*out_rgba)[4 * i + 1] = + reinterpret_cast<float **>(exr_image.images)[idxG][i]; + (*out_rgba)[4 * i + 2] = + reinterpret_cast<float **>(exr_image.images)[idxB][i]; + if (idxA != -1) { + (*out_rgba)[4 * i + 3] = + reinterpret_cast<float **>(exr_image.images)[idxA][i]; + } + else { + (*out_rgba)[4 * i + 3] = 1.0; + } } + (*width) = exr_image.width; + (*height) = exr_image.height; + + FreeEXRHeader(&exr_header); + FreeEXRImage(&exr_image); + return TINYEXR_SUCCESS; } @@ -10830,10 +10960,7 @@ int LoadEXRImageFromFile(EXRImage *exr_image, const EXRHeader *exr_header, return TINYEXR_ERROR_INVALID_ARGUMENT; } -// -- GODOT change for old MinGW on Travis CI -- -//#ifdef _WIN32 -#if defined(_MSC_VER) || (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 3) -// -- GODOT end -- +#ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else @@ -11315,7 +11442,7 @@ size_t SaveEXRImageToMemory(const EXRImage *exr_image, std::vector<unsigned char> block(bufLen); unsigned int outSize = static_cast<unsigned int>(block.size()); - CompressPiz(&block.at(0), outSize, + CompressPiz(&block.at(0), &outSize, reinterpret_cast<const unsigned char *>(&buf.at(0)), buf.size(), channels, exr_image->width, h); @@ -11422,10 +11549,7 @@ int SaveEXRImageToFile(const EXRImage *exr_image, const EXRHeader *exr_header, } #endif -// -- GODOT change for old MinGW on Travis CI -- -//#ifdef _WIN32 -#if defined(_MSC_VER) || (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 3) -// -- GODOT end -- +#ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "wb"); #else @@ -11459,6 +11583,16 @@ int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { return TINYEXR_ERROR_INVALID_ARGUMENT; } +#ifdef _MSC_VER + FILE *fp = NULL; + errno_t errcode = fopen_s(&fp, filename, "rb"); + if ((!errcode) || (!fp)) { + if (err) { + (*err) = "Cannot read file."; + } + return TINYEXR_ERROR_CANT_OPEN_FILE; + } +#else FILE *fp = fopen(filename, "rb"); if (!fp) { if (err) { @@ -11466,6 +11600,7 @@ int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { } return TINYEXR_ERROR_CANT_OPEN_FILE; } +#endif size_t filesize; // Compute size @@ -11535,6 +11670,7 @@ int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { if (0 == size) { return TINYEXR_ERROR_INVALID_DATA; } else if (marker[0] == '\0') { + marker++; size--; break; } @@ -11724,11 +11860,13 @@ int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { // decode sample data. { unsigned long dstLen = static_cast<unsigned long>(unpackedSampleDataSize); - tinyexr::DecompressZip( - reinterpret_cast<unsigned char *>(&sample_data.at(0)), &dstLen, - data_ptr + 28 + packedOffsetTableSize, - static_cast<unsigned long>(packedSampleDataSize)); - assert(dstLen == static_cast<unsigned long>(unpackedSampleDataSize)); + if (dstLen) { + tinyexr::DecompressZip( + reinterpret_cast<unsigned char *>(&sample_data.at(0)), &dstLen, + data_ptr + 28 + packedOffsetTableSize, + static_cast<unsigned long>(packedSampleDataSize)); + assert(dstLen == static_cast<unsigned long>(unpackedSampleDataSize)); + } } // decode sample @@ -11774,7 +11912,7 @@ int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { if (channels[c].pixel_type == 0) { // UINT for (size_t x = 0; x < static_cast<size_t>(samples_per_line); x++) { unsigned int ui = *reinterpret_cast<unsigned int *>( - &sample_data.at(data_offset + x * sizeof(int))); + &sample_data.at(size_t(data_offset) + x * sizeof(int))); deep_image->image[c][y][x] = static_cast<float>(ui); // @fixme } data_offset += @@ -11783,7 +11921,7 @@ int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { for (size_t x = 0; x < static_cast<size_t>(samples_per_line); x++) { tinyexr::FP16 f16; f16.u = *reinterpret_cast<unsigned short *>( - &sample_data.at(data_offset + x * sizeof(short))); + &sample_data.at(size_t(data_offset) + x * sizeof(short))); tinyexr::FP32 f32 = half_to_float(f16); deep_image->image[c][y][x] = f32.f; } @@ -11791,7 +11929,7 @@ int LoadDeepEXR(DeepImage *deep_image, const char *filename, const char **err) { } else { // float for (size_t x = 0; x < static_cast<size_t>(samples_per_line); x++) { float f = *reinterpret_cast<float *>( - &sample_data.at(data_offset + x * sizeof(float))); + &sample_data.at(size_t(data_offset) + x * sizeof(float))); deep_image->image[c][y][x] = f; } data_offset += sizeof(float) * static_cast<size_t>(samples_per_line); @@ -11906,10 +12044,7 @@ int ParseEXRHeaderFromFile(EXRHeader *exr_header, const EXRVersion *exr_version, return TINYEXR_ERROR_INVALID_ARGUMENT; } -// -- GODOT change for old MinGW on Travis CI -- -//#ifdef _WIN32 -#if defined(_MSC_VER) || (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 3) -// -- GODOT end -- +#ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else @@ -11978,7 +12113,11 @@ int ParseEXRMultipartHeaderFromMemory(EXRHeader ***exr_headers, if (ret != TINYEXR_SUCCESS) { if (err) { +#ifdef _WIN32 + (*err) = _strdup(err_str.c_str()); // may leak +#else (*err) = strdup(err_str.c_str()); // may leak +#endif } return ret; } @@ -12033,10 +12172,7 @@ int ParseEXRMultipartHeaderFromFile(EXRHeader ***exr_headers, int *num_headers, return TINYEXR_ERROR_INVALID_ARGUMENT; } -// -- GODOT change for old MinGW on Travis CI -- -//#ifdef _WIN32 -#if defined(_MSC_VER) || (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 3) -// -- GODOT end -- +#ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else @@ -12136,10 +12272,7 @@ int ParseEXRVersionFromFile(EXRVersion *version, const char *filename) { return TINYEXR_ERROR_INVALID_ARGUMENT; } -// -- GODOT change for old MinGW on Travis CI -- -//#ifdef _WIN32 -#if defined(_MSC_VER) || (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 3) -// -- GODOT end -- +#ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else @@ -12277,10 +12410,7 @@ int LoadEXRMultipartImageFromFile(EXRImage *exr_images, return TINYEXR_ERROR_INVALID_ARGUMENT; } -// -- GODOT change for old MinGW on Travis CI -- -//#ifdef _WIN32 -#if defined(_MSC_VER) || (defined(__MINGW32__) && __MINGW64_VERSION_MAJOR >= 3) -// -- GODOT end -- +#ifdef _WIN32 FILE *fp = NULL; fopen_s(&fp, filename, "rb"); #else @@ -12313,8 +12443,8 @@ int LoadEXRMultipartImageFromFile(EXRImage *exr_images, } int SaveEXR(const float *data, int width, int height, int components, - const char *outfilename) { - if (components == 3 || components == 4) { + const int save_as_fp16, const char *outfilename) { + if ((components == 1) || components == 3 || components == 4) { // OK } else { return TINYEXR_ERROR_INVALID_ARGUMENT; @@ -12333,18 +12463,24 @@ int SaveEXR(const float *data, int width, int height, int components, image.num_channels = components; std::vector<float> images[4]; - images[0].resize(static_cast<size_t>(width * height)); - images[1].resize(static_cast<size_t>(width * height)); - images[2].resize(static_cast<size_t>(width * height)); - images[3].resize(static_cast<size_t>(width * height)); - // Split RGB(A)RGB(A)RGB(A)... into R, G and B(and A) layers - for (size_t i = 0; i < static_cast<size_t>(width * height); i++) { - images[0][i] = data[static_cast<size_t>(components) * i + 0]; - images[1][i] = data[static_cast<size_t>(components) * i + 1]; - images[2][i] = data[static_cast<size_t>(components) * i + 2]; - if (components == 4) { - images[3][i] = data[static_cast<size_t>(components) * i + 3]; + if (components == 1) { + images[0].resize(static_cast<size_t>(width * height)); + memcpy(images[0].data(), data, sizeof(float) * size_t(width * height)); + } else { + images[0].resize(static_cast<size_t>(width * height)); + images[1].resize(static_cast<size_t>(width * height)); + images[2].resize(static_cast<size_t>(width * height)); + images[3].resize(static_cast<size_t>(width * height)); + + // Split RGB(A)RGB(A)RGB(A)... into R, G and B(and A) layers + for (size_t i = 0; i < static_cast<size_t>(width * height); i++) { + images[0][i] = data[static_cast<size_t>(components) * i + 0]; + images[1][i] = data[static_cast<size_t>(components) * i + 1]; + images[2][i] = data[static_cast<size_t>(components) * i + 2]; + if (components == 4) { + images[3][i] = data[static_cast<size_t>(components) * i + 3]; + } } } @@ -12354,10 +12490,12 @@ int SaveEXR(const float *data, int width, int height, int components, image_ptr[1] = &(images[2].at(0)); // B image_ptr[2] = &(images[1].at(0)); // G image_ptr[3] = &(images[0].at(0)); // R - } else { + } else if (components == 3) { image_ptr[0] = &(images[2].at(0)); // B image_ptr[1] = &(images[1].at(0)); // G image_ptr[2] = &(images[0].at(0)); // R + } else if (components == 1) { + image_ptr[0] = &(images[0].at(0)); // A } image.images = reinterpret_cast<unsigned char **>(image_ptr); @@ -12369,21 +12507,41 @@ int SaveEXR(const float *data, int width, int height, int components, sizeof(EXRChannelInfo) * static_cast<size_t>(header.num_channels))); // Must be (A)BGR order, since most of EXR viewers expect this channel order. if (components == 4) { +#ifdef _MSC_VER + strncpy_s(header.channels[0].name, "A", 255); + strncpy_s(header.channels[1].name, "B", 255); + strncpy_s(header.channels[2].name, "G", 255); + strncpy_s(header.channels[3].name, "R", 255); +#else strncpy(header.channels[0].name, "A", 255); - header.channels[0].name[strlen("A")] = '\0'; strncpy(header.channels[1].name, "B", 255); - header.channels[1].name[strlen("B")] = '\0'; strncpy(header.channels[2].name, "G", 255); - header.channels[2].name[strlen("G")] = '\0'; strncpy(header.channels[3].name, "R", 255); +#endif + header.channels[0].name[strlen("A")] = '\0'; + header.channels[1].name[strlen("B")] = '\0'; + header.channels[2].name[strlen("G")] = '\0'; header.channels[3].name[strlen("R")] = '\0'; - } else { + } else if (components == 3) { +#ifdef _MSC_VER + strncpy_s(header.channels[0].name, "B", 255); + strncpy_s(header.channels[1].name, "G", 255); + strncpy_s(header.channels[2].name, "R", 255); +#else strncpy(header.channels[0].name, "B", 255); - header.channels[0].name[strlen("B")] = '\0'; strncpy(header.channels[1].name, "G", 255); - header.channels[1].name[strlen("G")] = '\0'; strncpy(header.channels[2].name, "R", 255); +#endif + header.channels[0].name[strlen("B")] = '\0'; + header.channels[1].name[strlen("G")] = '\0'; header.channels[2].name[strlen("R")] = '\0'; + } else { +#ifdef _MSC_VER + strncpy_s(header.channels[0].name, "A", 255); +#else + strncpy(header.channels[0].name, "A", 255); +#endif + header.channels[0].name[strlen("A")] = '\0'; } header.pixel_types = static_cast<int *>( @@ -12393,9 +12551,15 @@ int SaveEXR(const float *data, int width, int height, int components, for (int i = 0; i < header.num_channels; i++) { header.pixel_types[i] = TINYEXR_PIXELTYPE_FLOAT; // pixel type of input image - header.requested_pixel_types[i] = - TINYEXR_PIXELTYPE_HALF; // pixel type of output image to be stored in - // .EXR + + if (save_as_fp16 > 0) { + header.requested_pixel_types[i] = + TINYEXR_PIXELTYPE_HALF; // save with half(fp16) pixel format + } else { + header.requested_pixel_types[i] = + TINYEXR_PIXELTYPE_FLOAT; // save with float(fp32) pixel format(i.e. + // no precision reduction) + } } const char *err; @@ -12411,9 +12575,5 @@ int SaveEXR(const float *data, int width, int height, int components, return ret; } -#ifdef _MSC_VER -#pragma warning(pop) -#endif - #endif // TINYEXR_IMPLEMENTATION_DEIFNED #endif // TINYEXR_IMPLEMENTATION |