diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/config/project_settings.cpp | 19 | ||||
-rw-r--r-- | core/config/project_settings.h | 8 | ||||
-rw-r--r-- | core/math/basis.cpp | 7 | ||||
-rw-r--r-- | core/object/script_language.cpp | 4 | ||||
-rw-r--r-- | core/object/script_language.h | 1 | ||||
-rw-r--r-- | core/string/node_path.cpp | 5 | ||||
-rw-r--r-- | core/string/node_path.h | 1 | ||||
-rw-r--r-- | core/variant/array.cpp | 4 | ||||
-rw-r--r-- | core/variant/array.h | 4 | ||||
-rw-r--r-- | core/variant/variant.cpp | 9 |
10 files changed, 32 insertions, 30 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 39f8ad68e4..f0de22f2ef 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -40,6 +40,7 @@ #include "core/io/file_access_pack.h" #include "core/io/marshalls.h" #include "core/os/keyboard.h" +#include "core/variant/typed_array.h" #include "core/variant/variant_parser.h" #include "core/version.h" @@ -1136,20 +1137,27 @@ Variant ProjectSettings::get_setting(const String &p_setting, const Variant &p_d } } -Array ProjectSettings::get_global_class_list() { - Array script_classes; +TypedArray<Dictionary> ProjectSettings::get_global_class_list() { + if (is_global_class_list_loaded) { + return global_class_list; + } Ref<ConfigFile> cf; cf.instantiate(); if (cf->load(get_global_class_list_path()) == OK) { - script_classes = cf->get_value("", "list", Array()); + global_class_list = cf->get_value("", "list", Array()); } else { #ifndef TOOLS_ENABLED // Script classes can't be recreated in exported project, so print an error. ERR_PRINT("Could not load global script cache."); #endif } - return script_classes; + + // File read succeeded or failed. If it failed, assume everything is still okay. + // We will later receive updated class data in store_global_class_list(). + is_global_class_list_loaded = true; + + return global_class_list; } String ProjectSettings::get_global_class_list_path() const { @@ -1161,6 +1169,8 @@ void ProjectSettings::store_global_class_list(const Array &p_classes) { cf.instantiate(); cf->set_value("", "list", p_classes); cf->save(get_global_class_list_path()); + + global_class_list = p_classes; } bool ProjectSettings::has_custom_feature(const String &p_feature) const { @@ -1195,6 +1205,7 @@ void ProjectSettings::_bind_methods() { ClassDB::bind_method(D_METHOD("set_setting", "name", "value"), &ProjectSettings::set_setting); ClassDB::bind_method(D_METHOD("get_setting", "name", "default_value"), &ProjectSettings::get_setting, DEFVAL(Variant())); ClassDB::bind_method(D_METHOD("get_setting_with_override", "name"), &ProjectSettings::get_setting_with_override); + ClassDB::bind_method(D_METHOD("get_global_class_list"), &ProjectSettings::get_global_class_list); ClassDB::bind_method(D_METHOD("set_order", "name", "position"), &ProjectSettings::set_order); ClassDB::bind_method(D_METHOD("get_order", "name"), &ProjectSettings::get_order); ClassDB::bind_method(D_METHOD("set_initial_value", "name", "value"), &ProjectSettings::set_initial_value); diff --git a/core/config/project_settings.h b/core/config/project_settings.h index 70f697741f..50cb274831 100644 --- a/core/config/project_settings.h +++ b/core/config/project_settings.h @@ -37,6 +37,9 @@ #include "core/templates/local_vector.h" #include "core/templates/rb_set.h" +template <typename T> +class TypedArray; + class ProjectSettings : public Object { GDCLASS(ProjectSettings, Object); _THREAD_SAFE_CLASS_ @@ -99,6 +102,9 @@ protected: HashMap<StringName, AutoloadInfo> autoloads; + Array global_class_list; + bool is_global_class_list_loaded = false; + String project_data_dir_name; bool _set(const StringName &p_name, const Variant &p_value); @@ -141,7 +147,7 @@ public: void set_setting(const String &p_setting, const Variant &p_value); Variant get_setting(const String &p_setting, const Variant &p_default_value = Variant()) const; - Array get_global_class_list(); + TypedArray<Dictionary> get_global_class_list(); void store_global_class_list(const Array &p_classes); String get_global_class_list_path() const; diff --git a/core/math/basis.cpp b/core/math/basis.cpp index 234a4ddb79..95a4187062 100644 --- a/core/math/basis.cpp +++ b/core/math/basis.cpp @@ -239,13 +239,18 @@ void Basis::scale_orthogonal(const Vector3 &p_scale) { Basis Basis::scaled_orthogonal(const Vector3 &p_scale) const { Basis m = *this; Vector3 s = Vector3(-1, -1, -1) + p_scale; + bool sign = signbit(s.x + s.y + s.z); + Basis b = m.orthonormalized(); + s = b.xform_inv(s); Vector3 dots; - Basis b; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { dots[j] += s[i] * abs(m.get_column(i).normalized().dot(b.get_column(j))); } } + if (sign != signbit(dots.x + dots.y + dots.z)) { + dots = -dots; + } m.scale_local(Vector3(1, 1, 1) + dots); return m; } diff --git a/core/object/script_language.cpp b/core/object/script_language.cpp index 61f5cfc22a..1d53cf66d4 100644 --- a/core/object/script_language.cpp +++ b/core/object/script_language.cpp @@ -369,10 +369,6 @@ void ScriptServer::save_global_classes() { ProjectSettings::get_singleton()->store_global_class_list(gcarr); } -bool ScriptServer::has_global_classes() { - return !global_classes.is_empty(); -} - String ScriptServer::get_global_class_cache_file_path() { return ProjectSettings::get_singleton()->get_global_class_list_path(); } diff --git a/core/object/script_language.h b/core/object/script_language.h index b1393c7196..14cc30e029 100644 --- a/core/object/script_language.h +++ b/core/object/script_language.h @@ -91,7 +91,6 @@ public: static void get_global_class_list(List<StringName> *r_global_classes); static void get_inheriters_list(const StringName &p_base_type, List<StringName> *r_classes); static void save_global_classes(); - static bool has_global_classes(); static String get_global_class_cache_file_path(); static void init_languages(); diff --git a/core/string/node_path.cpp b/core/string/node_path.cpp index 9ce1c2d4bb..af7c18741d 100644 --- a/core/string/node_path.cpp +++ b/core/string/node_path.cpp @@ -339,7 +339,6 @@ NodePath::NodePath(const Vector<StringName> &p_path, bool p_absolute) { data->refcount.init(); data->absolute = p_absolute; data->path = p_path; - data->has_slashes = true; data->hash_cache_valid = false; } @@ -353,7 +352,6 @@ NodePath::NodePath(const Vector<StringName> &p_path, const Vector<StringName> &p data->absolute = p_absolute; data->path = p_path; data->subpath = p_subpath; - data->has_slashes = true; data->hash_cache_valid = false; } @@ -373,7 +371,6 @@ NodePath::NodePath(const String &p_path) { bool absolute = (path[0] == '/'); bool last_is_slash = true; - bool has_slashes = false; int slices = 0; int subpath_pos = path.find(":"); @@ -402,7 +399,6 @@ NodePath::NodePath(const String &p_path) { for (int i = (int)absolute; i < path.length(); i++) { if (path[i] == '/') { last_is_slash = true; - has_slashes = true; } else { if (last_is_slash) { slices++; @@ -419,7 +415,6 @@ NodePath::NodePath(const String &p_path) { data = memnew(Data); data->refcount.init(); data->absolute = absolute; - data->has_slashes = has_slashes; data->subpath = subpath; data->hash_cache_valid = false; diff --git a/core/string/node_path.h b/core/string/node_path.h index 7053798cb2..876d69924e 100644 --- a/core/string/node_path.h +++ b/core/string/node_path.h @@ -42,7 +42,6 @@ class NodePath { StringName concatenated_path; StringName concatenated_subpath; bool absolute; - bool has_slashes; mutable bool hash_cache_valid; mutable uint32_t hash_cache; }; diff --git a/core/variant/array.cpp b/core/variant/array.cpp index 2d7dff0b27..2e1adb9167 100644 --- a/core/variant/array.cpp +++ b/core/variant/array.cpp @@ -629,14 +629,14 @@ void Array::shuffle() { } } -int Array::bsearch(const Variant &p_value, bool p_before) { +int Array::bsearch(const Variant &p_value, bool p_before) const { Variant value = p_value; ERR_FAIL_COND_V(!_p->typed.validate(value, "binary search"), -1); SearchArray<Variant, _ArrayVariantSort> avs; return avs.bisect(_p->array.ptrw(), _p->array.size(), value, p_before); } -int Array::bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before) { +int Array::bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before) const { Variant value = p_value; ERR_FAIL_COND_V(!_p->typed.validate(value, "custom binary search"), -1); diff --git a/core/variant/array.h b/core/variant/array.h index 4ef8ba8ce7..8b1f8c0678 100644 --- a/core/variant/array.h +++ b/core/variant/array.h @@ -83,8 +83,8 @@ public: void sort(); void sort_custom(const Callable &p_callable); void shuffle(); - int bsearch(const Variant &p_value, bool p_before = true); - int bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before = true); + int bsearch(const Variant &p_value, bool p_before = true) const; + int bsearch_custom(const Variant &p_value, const Callable &p_callable, bool p_before = true) const; void reverse(); int find(const Variant &p_value, int p_from = 0) const; diff --git a/core/variant/variant.cpp b/core/variant/variant.cpp index 672b030806..04e1561a0c 100644 --- a/core/variant/variant.cpp +++ b/core/variant/variant.cpp @@ -3601,15 +3601,6 @@ bool Variant::is_type_shared(Variant::Type p_type) { case OBJECT: case ARRAY: case DICTIONARY: - case PACKED_BYTE_ARRAY: - case PACKED_INT32_ARRAY: - case PACKED_INT64_ARRAY: - case PACKED_FLOAT32_ARRAY: - case PACKED_FLOAT64_ARRAY: - case PACKED_STRING_ARRAY: - case PACKED_VECTOR2_ARRAY: - case PACKED_VECTOR3_ARRAY: - case PACKED_COLOR_ARRAY: return true; default: { } |