summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/config/project_settings.cpp5
-rw-r--r--core/config/project_settings.h2
-rw-r--r--core/core_constants.cpp237
-rw-r--r--core/core_constants.h5
-rw-r--r--core/input/input.cpp4
-rw-r--r--core/input/input_map.cpp4
-rw-r--r--core/io/file_access.cpp7
-rw-r--r--core/io/resource.cpp19
-rw-r--r--core/math/bvh.h8
9 files changed, 222 insertions, 69 deletions
diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp
index f0de22f2ef..56e9057a2a 100644
--- a/core/config/project_settings.cpp
+++ b/core/config/project_settings.cpp
@@ -656,6 +656,7 @@ Error ProjectSettings::setup(const String &p_path, const String &p_main_pack, bo
Compression::gzip_level = GLOBAL_GET("compression/formats/gzip/compression_level");
+ project_loaded = err == OK;
return err;
}
@@ -1106,6 +1107,10 @@ bool ProjectSettings::is_using_datapack() const {
return using_datapack;
}
+bool ProjectSettings::is_project_loaded() const {
+ return project_loaded;
+}
+
bool ProjectSettings::_property_can_revert(const StringName &p_name) const {
if (!props.has(p_name)) {
return false;
diff --git a/core/config/project_settings.h b/core/config/project_settings.h
index 50cb274831..a0249ef267 100644
--- a/core/config/project_settings.h
+++ b/core/config/project_settings.h
@@ -95,6 +95,7 @@ protected:
String resource_path;
HashMap<StringName, PropertyInfo> custom_prop_info;
bool using_datapack = false;
+ bool project_loaded = false;
List<String> input_presets;
HashSet<String> custom_features;
@@ -190,6 +191,7 @@ public:
Variant get_setting_with_override(const StringName &p_name) const;
bool is_using_datapack() const;
+ bool is_project_loaded() const;
bool has_custom_feature(const String &p_feature) const;
diff --git a/core/core_constants.cpp b/core/core_constants.cpp
index b1f56539e5..d88dda6609 100644
--- a/core/core_constants.cpp
+++ b/core/core_constants.cpp
@@ -33,14 +33,15 @@
#include "core/input/input_event.h"
#include "core/object/class_db.h"
#include "core/os/keyboard.h"
+#include "core/templates/hash_set.h"
#include "core/variant/variant.h"
struct _CoreConstant {
#ifdef DEBUG_METHODS_ENABLED
- StringName enum_name;
bool ignore_value_in_docs = false;
bool is_bitfield = false;
#endif
+ StringName enum_name;
const char *name = nullptr;
int64_t value = 0;
@@ -48,14 +49,15 @@ struct _CoreConstant {
#ifdef DEBUG_METHODS_ENABLED
_CoreConstant(const StringName &p_enum_name, const char *p_name, int64_t p_value, bool p_ignore_value_in_docs = false, bool p_is_bitfield = false) :
- enum_name(p_enum_name),
ignore_value_in_docs(p_ignore_value_in_docs),
is_bitfield(p_is_bitfield),
+ enum_name(p_enum_name),
name(p_name),
value(p_value) {
}
#else
- _CoreConstant(const char *p_name, int64_t p_value) :
+ _CoreConstant(const StringName &p_enum_name, const char *p_name, int64_t p_value) :
+ enum_name(p_enum_name),
name(p_name),
value(p_value) {
}
@@ -63,84 +65,190 @@ struct _CoreConstant {
};
static Vector<_CoreConstant> _global_constants;
+static HashMap<StringName, int> _global_constants_map;
+static HashMap<StringName, Vector<_CoreConstant>> _global_enums;
#ifdef DEBUG_METHODS_ENABLED
-#define BIND_CORE_CONSTANT(m_constant) \
- _global_constants.push_back(_CoreConstant(StringName(), #m_constant, m_constant));
+#define BIND_CORE_CONSTANT(m_constant) \
+ _global_constants.push_back(_CoreConstant(StringName(), #m_constant, m_constant)); \
+ _global_constants_map[#m_constant] = _global_constants.size() - 1;
-#define BIND_CORE_ENUM_CONSTANT(m_constant) \
- _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_constant, #m_constant), #m_constant, m_constant));
+#define BIND_CORE_ENUM_CONSTANT(m_constant) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_constant, #m_constant); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \
+ _global_constants_map[#m_constant] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_BITFIELD_FLAG(m_constant) \
- _global_constants.push_back(_CoreConstant(__constant_get_bitfield_name(m_constant, #m_constant), #m_constant, m_constant, false, true));
+#define BIND_CORE_BITFIELD_FLAG(m_constant) \
+ { \
+ StringName enum_name = __constant_get_bitfield_name(m_constant, #m_constant); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant, false, true)); \
+ _global_constants_map[#m_constant] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
// This just binds enum classes as if they were regular enum constants.
-#define BIND_CORE_ENUM_CLASS_CONSTANT(m_enum, m_prefix, m_member) \
- _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_enum::m_member, #m_prefix "_" #m_member), #m_prefix "_" #m_member, (int64_t)m_enum::m_member));
+#define BIND_CORE_ENUM_CLASS_CONSTANT(m_enum, m_prefix, m_member) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_enum::m_member, #m_prefix "_" #m_member); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member)); \
+ _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_BITFIELD_CLASS_FLAG(m_enum, m_prefix, m_member) \
- _global_constants.push_back(_CoreConstant(__constant_get_bitfield_name(m_enum::m_member, #m_prefix "_" #m_member), #m_prefix "_" #m_member, (int64_t)m_enum::m_member, false, true));
+#define BIND_CORE_BITFIELD_CLASS_FLAG(m_enum, m_prefix, m_member) \
+ { \
+ StringName enum_name = __constant_get_bitfield_name(m_enum::m_member, #m_prefix "_" #m_member); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member, false, true)); \
+ _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(m_enum, m_name, m_member) \
- _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_enum::m_member, #m_name), #m_name, (int64_t)m_enum::m_member));
+#define BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(m_enum, m_name, m_member) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_enum::m_member, #m_name); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_name, (int64_t)m_enum::m_member)); \
+ _global_constants_map[#m_name] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(m_enum, m_name, m_member) \
- _global_constants.push_back(_CoreConstant(__constant_get_bitfield_name(m_enum::m_member, #m_name), #m_name, (int64_t)m_enum::m_member, false, true));
+#define BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(m_enum, m_name, m_member) \
+ { \
+ StringName enum_name = __constant_get_bitfield_name(m_enum::m_member, #m_name); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_name, (int64_t)m_enum::m_member, false, true)); \
+ _global_constants_map[#m_name] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_ENUM_CLASS_CONSTANT_NO_VAL(m_enum, m_prefix, m_member) \
- _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_enum::m_member, #m_prefix "_" #m_member), #m_prefix "_" #m_member, (int64_t)m_enum::m_member, true));
+#define BIND_CORE_ENUM_CLASS_CONSTANT_NO_VAL(m_enum, m_prefix, m_member) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_enum::m_member, #m_prefix "_" #m_member); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member, true)); \
+ _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \
- _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_constant, #m_constant), m_custom_name, m_constant));
+#define BIND_CORE_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_constant, #m_constant); \
+ _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant)); \
+ _global_constants_map[m_custom_name] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_CONSTANT_NO_VAL(m_constant) \
- _global_constants.push_back(_CoreConstant(StringName(), #m_constant, m_constant, true));
+#define BIND_CORE_CONSTANT_NO_VAL(m_constant) \
+ _global_constants.push_back(_CoreConstant(StringName(), #m_constant, m_constant, true)); \
+ _global_constants_map[#m_constant] = _global_constants.size() - 1;
-#define BIND_CORE_ENUM_CONSTANT_NO_VAL(m_constant) \
- _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_constant, #m_constant), #m_constant, m_constant, true));
+#define BIND_CORE_ENUM_CONSTANT_NO_VAL(m_constant) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_constant, #m_constant); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant, true)); \
+ _global_constants_map[#m_constant] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_ENUM_CONSTANT_CUSTOM_NO_VAL(m_custom_name, m_constant) \
- _global_constants.push_back(_CoreConstant(__constant_get_enum_name(m_constant, #m_constant), m_custom_name, m_constant, true));
+#define BIND_CORE_ENUM_CONSTANT_CUSTOM_NO_VAL(m_custom_name, m_constant) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_constant, #m_constant); \
+ _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant, true)); \
+ _global_constants_map[m_custom_name] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
#else
-#define BIND_CORE_CONSTANT(m_constant) \
- _global_constants.push_back(_CoreConstant(#m_constant, m_constant));
+#define BIND_CORE_CONSTANT(m_constant) \
+ _global_constants.push_back(_CoreConstant(StringName(), #m_constant, m_constant)); \
+ _global_constants_map[#m_constant] = _global_constants.size() - 1;
-#define BIND_CORE_ENUM_CONSTANT(m_constant) \
- _global_constants.push_back(_CoreConstant(#m_constant, m_constant));
+#define BIND_CORE_ENUM_CONSTANT(m_constant) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_constant, #m_constant); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \
+ _global_constants_map[#m_constant] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_BITFIELD_FLAG(m_constant) \
- _global_constants.push_back(_CoreConstant(#m_constant, m_constant));
+#define BIND_CORE_BITFIELD_FLAG(m_constant) \
+ { \
+ StringName enum_name = __constant_get_bitfield_name(m_constant, #m_constant); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \
+ _global_constants_map[#m_constant] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
// This just binds enum classes as if they were regular enum constants.
-#define BIND_CORE_ENUM_CLASS_CONSTANT(m_enum, m_prefix, m_member) \
- _global_constants.push_back(_CoreConstant(#m_prefix "_" #m_member, (int64_t)m_enum::m_member));
+#define BIND_CORE_ENUM_CLASS_CONSTANT(m_enum, m_prefix, m_member) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_enum::m_member, #m_prefix "_" #m_member); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member)); \
+ _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_BITFIELD_CLASS_FLAG(m_enum, m_prefix, m_member) \
- _global_constants.push_back(_CoreConstant(#m_prefix "_" #m_member, (int64_t)m_enum::m_member));
+#define BIND_CORE_BITFIELD_CLASS_FLAG(m_enum, m_prefix, m_member) \
+ { \
+ StringName enum_name = __constant_get_bitfield_name(m_enum::m_member, #m_prefix "_" #m_member); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member)); \
+ _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(m_enum, m_name, m_member) \
- _global_constants.push_back(_CoreConstant(#m_name, (int64_t)m_enum::m_member));
+#define BIND_CORE_ENUM_CLASS_CONSTANT_CUSTOM(m_enum, m_name, m_member) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_enum::m_member, #m_name); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_name, (int64_t)m_enum::m_member)); \
+ _global_constants_map[#m_name] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(m_enum, m_name, m_member) \
- _global_constants.push_back(_CoreConstant(#m_name, (int64_t)m_enum::m_member));
+#define BIND_CORE_BITFIELD_CLASS_FLAG_CUSTOM(m_enum, m_name, m_member) \
+ { \
+ StringName enum_name = __constant_get_bitfield_name(m_enum::m_member, #m_name); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_name, (int64_t)m_enum::m_member)); \
+ _global_constants_map[#m_name] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_ENUM_CLASS_CONSTANT_NO_VAL(m_enum, m_prefix, m_member) \
- _global_constants.push_back(_CoreConstant(#m_prefix "_" #m_member, (int64_t)m_enum::m_member));
+#define BIND_CORE_ENUM_CLASS_CONSTANT_NO_VAL(m_enum, m_prefix, m_member) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_enum::m_member, #m_prefix "_" #m_member); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_prefix "_" #m_member, (int64_t)m_enum::m_member)); \
+ _global_constants_map[#m_prefix "_" #m_member] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \
- _global_constants.push_back(_CoreConstant(m_custom_name, m_constant));
+#define BIND_CORE_ENUM_CONSTANT_CUSTOM(m_custom_name, m_constant) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_constant, #m_constant); \
+ _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant)); \
+ _global_constants_map[m_custom_name] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_CONSTANT_NO_VAL(m_constant) \
- _global_constants.push_back(_CoreConstant(#m_constant, m_constant));
+#define BIND_CORE_CONSTANT_NO_VAL(m_constant) \
+ _global_constants.push_back(_CoreConstant(StringName(), #m_constant, m_constant)); \
+ _global_constants_map[#m_constant] = _global_constants.size() - 1;
-#define BIND_CORE_ENUM_CONSTANT_NO_VAL(m_constant) \
- _global_constants.push_back(_CoreConstant(#m_constant, m_constant));
+#define BIND_CORE_ENUM_CONSTANT_NO_VAL(m_constant) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_constant, #m_constant); \
+ _global_constants.push_back(_CoreConstant(enum_name, #m_constant, m_constant)); \
+ _global_constants_map[#m_constant] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
-#define BIND_CORE_ENUM_CONSTANT_CUSTOM_NO_VAL(m_custom_name, m_constant) \
- _global_constants.push_back(_CoreConstant(m_custom_name, m_constant));
+#define BIND_CORE_ENUM_CONSTANT_CUSTOM_NO_VAL(m_custom_name, m_constant) \
+ { \
+ StringName enum_name = __constant_get_enum_name(m_constant, #m_constant); \
+ _global_constants.push_back(_CoreConstant(enum_name, m_custom_name, m_constant)); \
+ _global_constants_map[m_custom_name] = _global_constants.size() - 1; \
+ _global_enums[enum_name].push_back((_global_constants.ptr())[_global_constants.size() - 1]); \
+ }
#endif
@@ -690,11 +798,11 @@ int CoreConstants::get_global_constant_count() {
return _global_constants.size();
}
-#ifdef DEBUG_METHODS_ENABLED
StringName CoreConstants::get_global_constant_enum(int p_idx) {
return _global_constants[p_idx].enum_name;
}
+#ifdef DEBUG_METHODS_ENABLED
bool CoreConstants::is_global_constant_bitfield(int p_idx) {
return _global_constants[p_idx].is_bitfield;
}
@@ -703,10 +811,6 @@ bool CoreConstants::get_ignore_value_in_docs(int p_idx) {
return _global_constants[p_idx].ignore_value_in_docs;
}
#else
-StringName CoreConstants::get_global_constant_enum(int p_idx) {
- return StringName();
-}
-
bool CoreConstants::is_global_constant_bitfield(int p_idx) {
return false;
}
@@ -723,3 +827,24 @@ const char *CoreConstants::get_global_constant_name(int p_idx) {
int64_t CoreConstants::get_global_constant_value(int p_idx) {
return _global_constants[p_idx].value;
}
+
+bool CoreConstants::is_global_constant(const StringName &p_name) {
+ return _global_constants_map.has(p_name);
+}
+
+int CoreConstants::get_global_constant_index(const StringName &p_name) {
+ ERR_FAIL_COND_V_MSG(!_global_constants_map.has(p_name), -1, "Trying to get index of non-existing constant.");
+ return _global_constants_map[p_name];
+}
+
+bool CoreConstants::is_global_enum(const StringName &p_enum) {
+ return _global_enums.has(p_enum);
+}
+
+void CoreConstants::get_enum_values(StringName p_enum, HashMap<StringName, int64_t> *p_values) {
+ ERR_FAIL_NULL_MSG(p_values, "Trying to get enum values with null map.");
+ ERR_FAIL_COND_MSG(!_global_enums.has(p_enum), "Trying to get values of non-existing enum.");
+ for (const _CoreConstant &constant : _global_enums[p_enum]) {
+ (*p_values)[constant.name] = constant.value;
+ }
+}
diff --git a/core/core_constants.h b/core/core_constants.h
index 5a5cd4394c..51842490c8 100644
--- a/core/core_constants.h
+++ b/core/core_constants.h
@@ -32,6 +32,7 @@
#define CORE_CONSTANTS_H
#include "core/string/string_name.h"
+#include "core/templates/hash_set.h"
class CoreConstants {
public:
@@ -41,6 +42,10 @@ public:
static bool get_ignore_value_in_docs(int p_idx);
static const char *get_global_constant_name(int p_idx);
static int64_t get_global_constant_value(int p_idx);
+ static bool is_global_constant(const StringName &p_name);
+ static int get_global_constant_index(const StringName &p_name);
+ static bool is_global_enum(const StringName &p_enum);
+ static void get_enum_values(StringName p_enum, HashMap<StringName, int64_t> *p_values);
};
#endif // CORE_CONSTANTS_H
diff --git a/core/input/input.cpp b/core/input/input.cpp
index b2164b8e76..e74523e059 100644
--- a/core/input/input.cpp
+++ b/core/input/input.cpp
@@ -352,8 +352,8 @@ float Input::get_axis(const StringName &p_negative_action, const StringName &p_p
Vector2 Input::get_vector(const StringName &p_negative_x, const StringName &p_positive_x, const StringName &p_negative_y, const StringName &p_positive_y, float p_deadzone) const {
Vector2 vector = Vector2(
- get_action_strength(p_positive_x) - get_action_strength(p_negative_x),
- get_action_strength(p_positive_y) - get_action_strength(p_negative_y));
+ get_action_raw_strength(p_positive_x) - get_action_raw_strength(p_negative_x),
+ get_action_raw_strength(p_positive_y) - get_action_raw_strength(p_negative_y));
if (p_deadzone < 0.0f) {
// If the deadzone isn't specified, get it from the average of the actions.
diff --git a/core/input/input_map.cpp b/core/input/input_map.cpp
index b2e6b57eb6..910778324c 100644
--- a/core/input/input_map.cpp
+++ b/core/input/input_map.cpp
@@ -669,6 +669,10 @@ const HashMap<String, List<Ref<InputEvent>>> &InputMap::get_builtins() {
default_builtin_cache.insert("ui_text_select_word_under_caret", inputs);
inputs = List<Ref<InputEvent>>();
+ inputs.push_back(InputEventKey::create_reference(Key::G | KeyModifierMask::CTRL | KeyModifierMask::META));
+ default_builtin_cache.insert("ui_text_select_word_under_caret.macos", inputs);
+
+ inputs = List<Ref<InputEvent>>();
inputs.push_back(InputEventKey::create_reference(Key::D | KeyModifierMask::CMD_OR_CTRL));
default_builtin_cache.insert("ui_text_add_selection_for_next_occurrence", inputs);
diff --git a/core/io/file_access.cpp b/core/io/file_access.cpp
index 0e9084de84..3d10151327 100644
--- a/core/io/file_access.cpp
+++ b/core/io/file_access.cpp
@@ -133,8 +133,8 @@ Ref<FileAccess> FileAccess::open_encrypted(const String &p_path, ModeFlags p_mod
Ref<FileAccessEncrypted> fae;
fae.instantiate();
Error err = fae->open_and_parse(fa, p_key, (p_mode_flags == WRITE) ? FileAccessEncrypted::MODE_WRITE_AES256 : FileAccessEncrypted::MODE_READ);
+ last_file_open_error = err;
if (err) {
- last_file_open_error = err;
return Ref<FileAccess>();
}
return fae;
@@ -149,8 +149,8 @@ Ref<FileAccess> FileAccess::open_encrypted_pass(const String &p_path, ModeFlags
Ref<FileAccessEncrypted> fae;
fae.instantiate();
Error err = fae->open_and_parse_password(fa, p_pass, (p_mode_flags == WRITE) ? FileAccessEncrypted::MODE_WRITE_AES256 : FileAccessEncrypted::MODE_READ);
+ last_file_open_error = err;
if (err) {
- last_file_open_error = err;
return Ref<FileAccess>();
}
return fae;
@@ -161,9 +161,8 @@ Ref<FileAccess> FileAccess::open_compressed(const String &p_path, ModeFlags p_mo
fac.instantiate();
fac->configure("GCPF", (Compression::Mode)p_compress_mode);
Error err = fac->open_internal(p_path, p_mode_flags);
-
+ last_file_open_error = err;
if (err) {
- last_file_open_error = err;
return Ref<FileAccess>();
}
diff --git a/core/io/resource.cpp b/core/io/resource.cpp
index 4abcbffb61..6b8ec8d5f6 100644
--- a/core/io/resource.cpp
+++ b/core/io/resource.cpp
@@ -542,9 +542,26 @@ Ref<Resource> ResourceCache::get_ref(const String &p_path) {
void ResourceCache::get_cached_resources(List<Ref<Resource>> *p_resources) {
lock.lock();
+
+ LocalVector<String> to_remove;
+
for (KeyValue<String, Resource *> &E : resources) {
- p_resources->push_back(Ref<Resource>(E.value));
+ Ref<Resource> ref = Ref<Resource>(E.value);
+
+ if (!ref.is_valid()) {
+ // This resource is in the process of being deleted, ignore its existence
+ E.value->path_cache = String();
+ to_remove.push_back(E.key);
+ continue;
+ }
+
+ p_resources->push_back(ref);
+ }
+
+ for (const String &E : to_remove) {
+ resources.erase(E);
}
+
lock.unlock();
}
diff --git a/core/math/bvh.h b/core/math/bvh.h
index ea8289607e..8fbbd8e7fd 100644
--- a/core/math/bvh.h
+++ b/core/math/bvh.h
@@ -55,7 +55,7 @@
#include "core/os/mutex.h"
#define BVHTREE_CLASS BVH_Tree<T, NUM_TREES, 2, MAX_ITEMS, USER_PAIR_TEST_FUNCTION, USER_CULL_TEST_FUNCTION, USE_PAIRS, BOUNDS, POINT>
-#define BVH_LOCKED_FUNCTION BVHLockedFunction(&_mutex, BVH_THREAD_SAFE &&_thread_safe);
+#define BVH_LOCKED_FUNCTION BVHLockedFunction _lock_guard(&_mutex, BVH_THREAD_SAFE &&_thread_safe);
template <class T, int NUM_TREES = 1, bool USE_PAIRS = false, int MAX_ITEMS = 32, class USER_PAIR_TEST_FUNCTION = BVH_DummyPairTestFunction<T>, class USER_CULL_TEST_FUNCTION = BVH_DummyCullTestFunction<T>, class BOUNDS = AABB, class POINT = Vector3, bool BVH_THREAD_SAFE = true>
class BVH_Manager {
@@ -779,11 +779,7 @@ private:
// will be compiled out if not set in template
if (p_thread_safe) {
_mutex = p_mutex;
-
- if (!_mutex->try_lock()) {
- WARN_PRINT("Info : multithread BVH access detected (benign)");
- _mutex->lock();
- }
+ _mutex->lock();
} else {
_mutex = nullptr;