diff options
Diffstat (limited to 'core')
37 files changed, 271 insertions, 318 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp index 57e88044b5..edd49fe95f 100644 --- a/core/class_db.cpp +++ b/core/class_db.cpp @@ -1036,7 +1036,6 @@ bool ClassDB::get_property(Object *p_object, const StringName &p_property, Varia r_value = *c; return true; } - //if (check->constant_map.fin) check = check->inherits_ptr; } @@ -1163,24 +1162,6 @@ bool ClassDB::has_method(StringName p_class, StringName p_method, bool p_no_inhe return false; } -bool ClassDB::get_setter_and_type_for_property(const StringName &p_class, const StringName &p_prop, StringName &r_class, StringName &r_setter) { - - ClassInfo *type = classes.getptr(p_class); - ClassInfo *check = type; - while (check) { - - if (check->property_setget.has(p_prop)) { - r_class = check->name; - r_setter = check->property_setget[p_prop].setter; - return true; - } - - check = check->inherits_ptr; - } - - return false; -} - #ifdef DEBUG_METHODS_ENABLED MethodBind *ClassDB::bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const MethodDefinition &method_name, const Variant **p_defs, int p_defcount) { StringName mdname = method_name.name; diff --git a/core/class_db.h b/core/class_db.h index 24db4c61bb..55fe01ec6d 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); @@ -349,8 +349,6 @@ public: static StringName get_category(const StringName &p_node); - static bool get_setter_and_type_for_property(const StringName &p_class, const StringName &p_prop, StringName &r_class, StringName &r_setter); - static void set_class_enabled(StringName p_class, bool p_enable); static bool is_class_enabled(StringName p_class); 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/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 ddfc792cc7..82e938d2db 100644 --- a/core/io/json.cpp +++ b/core/io/json.cpp @@ -43,7 +43,7 @@ const char *JSON::tk_name[TK_MAX] = { "EOF", }; -static String _make_indent(const String& p_indent, int p_size) { +static String _make_indent(const String &p_indent, int p_size) { String indent_text = ""; if (!p_indent.empty()) { @@ -53,7 +53,7 @@ static String _make_indent(const String& p_indent, int p_size) { return indent_text; } -String JSON::_print_var(const Variant &p_var, const String& p_indent, int p_cur_indent, bool p_sort_keys) { +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 = ""; @@ -116,7 +116,7 @@ String JSON::_print_var(const Variant &p_var, const String& p_indent, int p_cur_ } } -String JSON::print(const Variant &p_var, const String& p_indent, bool p_sort_keys) { +String JSON::print(const Variant &p_var, const String &p_indent, bool p_sort_keys) { return _print_var(p_var, p_indent, 0, p_sort_keys); } diff --git a/core/io/json.h b/core/io/json.h index 5e1a89f069..fbb7875c7c 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, const String& p_indent, int p_cur_indent, bool p_sort_keys); + 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, const String& p_indent = "", bool p_sort_keys = true); + 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.cpp b/core/math/math_2d.cpp index c77fe96ff2..11003c1cd5 100644 --- a/core/math/math_2d.cpp +++ b/core/math/math_2d.cpp @@ -222,35 +222,6 @@ Vector2 Vector2::cubic_interpolate(const Vector2 &p_b, const Vector2 &p_pre_a, c (2.0 * p0 - 5.0 * p1 + 4 * p2 - p3) * t2 + (-p0 + 3.0 * p1 - 3.0 * p2 + p3) * t3); return out; - - /* - real_t mu = p_t; - real_t mu2 = mu*mu; - - Vector2 a0 = p_post_b - p_b - p_pre_a + *this; - Vector2 a1 = p_pre_a - *this - a0; - Vector2 a2 = p_b - p_pre_a; - Vector2 a3 = *this; - - return ( a0*mu*mu2 + a1*mu2 + a2*mu + a3 ); -*/ - /* - real_t t = p_t; - real_t t2 = t*t; - real_t t3 = t2*t; - - real_t a = 2.0*t3- 3.0*t2 + 1; - real_t b = -2.0*t3+ 3.0*t2; - real_t c = t3- 2.0*t2 + t; - real_t d = t3- t2; - - Vector2 p_a=*this; - - return Vector2( - (a * p_a.x) + (b *p_b.x) + (c * p_pre_a.x) + (d * p_post_b.x), - (a * p_a.y) + (b *p_b.y) + (c * p_pre_a.y) + (d * p_post_b.y) - ); -*/ } // slide returns the component of the vector along the given plane, specified by its normal vector. diff --git a/core/math/math_2d.h b/core/math/math_2d.h index d215df8a43..60351445c0 100644 --- a/core/math/math_2d.h +++ b/core/math/math_2d.h @@ -382,16 +382,21 @@ struct Rect2 { size = end - begin; } + inline Rect2 abs() const { + + return Rect2(Point2(position.x + MIN(size.x, 0), position.y + MIN(size.y, 0)), size.abs()); + } + 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 +583,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 0a0c781649..3d93953227 100644 --- a/core/object.h +++ b/core/object.h @@ -1,4 +1,4 @@ -/*************************************************************************/ +/*************************************************************************/ /* object.h */ /*************************************************************************/ /* This file is part of: */ @@ -144,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; @@ -164,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 { @@ -428,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/os.h b/core/os/os.h index 91fbf082bf..979ad7e92a 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -92,14 +92,16 @@ public: bool resizable; bool borderless_window; bool maximized; + bool use_vsync; float get_aspect() const { return (float)width / (float)height; } - VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false, bool p_maximized = false) { + VideoMode(int p_width = 1024, int p_height = 600, bool p_fullscreen = false, bool p_resizable = true, bool p_borderless_window = false, bool p_maximized = false, bool p_use_vsync = false) { width = p_width; height = p_height; fullscreen = p_fullscreen; resizable = p_resizable; borderless_window = p_borderless_window; maximized = p_maximized; + use_vsync = p_use_vsync; } }; @@ -195,7 +197,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..f66cce85c9 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) { } }; @@ -360,6 +360,7 @@ struct _VariantCall { VCALL_LOCALMEM2R(Rect2, grow_margin); VCALL_LOCALMEM4R(Rect2, grow_individual); VCALL_LOCALMEM1R(Rect2, expand); + VCALL_LOCALMEM0R(Rect2, abs); VCALL_LOCALMEM0R(Vector3, min_axis); VCALL_LOCALMEM0R(Vector3, max_axis); @@ -1526,6 +1527,7 @@ void register_variant_methods() { ADDFUNC2R(RECT2, RECT2, Rect2, grow_margin, INT, "margin", REAL, "by", varray()); ADDFUNC4R(RECT2, RECT2, Rect2, grow_individual, REAL, "left", REAL, "top", REAL, "right", REAL, " bottom", varray()); ADDFUNC1R(RECT2, RECT2, Rect2, expand, VECTOR2, "to", varray()); + ADDFUNC0R(RECT2, RECT2, Rect2, abs, varray()); ADDFUNC0R(VECTOR3, INT, Vector3, min_axis, varray()); ADDFUNC0R(VECTOR3, INT, Vector3, max_axis, varray()); |