summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/dynamic_font.cpp61
-rw-r--r--scene/resources/dynamic_font.h4
-rw-r--r--scene/resources/font.cpp2
-rw-r--r--scene/resources/font.h2
-rw-r--r--scene/resources/material.cpp45
-rw-r--r--scene/resources/material.h2
-rw-r--r--scene/resources/mesh.cpp1
-rw-r--r--scene/resources/mesh_library.h2
-rw-r--r--scene/resources/packed_scene.cpp2
-rw-r--r--scene/resources/particles_material.cpp40
-rw-r--r--scene/resources/particles_material.h2
-rw-r--r--scene/resources/resource_format_text.cpp244
-rw-r--r--scene/resources/resource_format_text.h28
-rw-r--r--scene/resources/shader.cpp2
-rw-r--r--scene/resources/shader.h2
-rw-r--r--scene/resources/texture.cpp17
-rw-r--r--scene/resources/texture.h4
-rw-r--r--scene/resources/theme.cpp30
-rw-r--r--scene/resources/visual_shader.cpp11
-rw-r--r--scene/resources/world_margin_shape.cpp (renamed from scene/resources/plane_shape.cpp)20
-rw-r--r--scene/resources/world_margin_shape.h (renamed from scene/resources/plane_shape.h)14
21 files changed, 270 insertions, 265 deletions
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 79a1500129..ebd5b02dbc 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -990,7 +990,7 @@ void DynamicFont::_bind_methods() {
BIND_ENUM_CONSTANT(SPACING_SPACE);
}
-Mutex *DynamicFont::dynamic_font_mutex = NULL;
+Mutex DynamicFont::dynamic_font_mutex;
SelfList<DynamicFont>::List *DynamicFont::dynamic_fonts = NULL;
@@ -1004,29 +1004,21 @@ DynamicFont::DynamicFont() :
spacing_char = 0;
spacing_space = 0;
outline_color = Color(1, 1, 1);
- if (dynamic_font_mutex) {
- dynamic_font_mutex->lock();
- dynamic_fonts->add(&font_list);
- dynamic_font_mutex->unlock();
- }
+
+ MutexLock lock(dynamic_font_mutex);
+ dynamic_fonts->add(&font_list);
}
DynamicFont::~DynamicFont() {
- if (dynamic_font_mutex) {
- dynamic_font_mutex->lock();
- dynamic_fonts->remove(&font_list);
- dynamic_font_mutex->unlock();
- }
+ MutexLock lock(dynamic_font_mutex);
+ dynamic_fonts->remove(&font_list);
}
void DynamicFont::initialize_dynamic_fonts() {
dynamic_fonts = memnew(SelfList<DynamicFont>::List());
- dynamic_font_mutex = Mutex::create();
}
void DynamicFont::finish_dynamic_fonts() {
- memdelete(dynamic_font_mutex);
- dynamic_font_mutex = NULL;
memdelete(dynamic_fonts);
dynamic_fonts = NULL;
}
@@ -1034,39 +1026,36 @@ void DynamicFont::finish_dynamic_fonts() {
void DynamicFont::update_oversampling() {
Vector<Ref<DynamicFont> > changed;
+ {
+ MutexLock lock(dynamic_font_mutex);
- if (dynamic_font_mutex)
- dynamic_font_mutex->lock();
-
- SelfList<DynamicFont> *E = dynamic_fonts->first();
- while (E) {
+ SelfList<DynamicFont> *E = dynamic_fonts->first();
+ while (E) {
- if (E->self()->data_at_size.is_valid()) {
- E->self()->data_at_size->update_oversampling();
+ if (E->self()->data_at_size.is_valid()) {
+ E->self()->data_at_size->update_oversampling();
- if (E->self()->outline_data_at_size.is_valid()) {
- E->self()->outline_data_at_size->update_oversampling();
- }
+ if (E->self()->outline_data_at_size.is_valid()) {
+ E->self()->outline_data_at_size->update_oversampling();
+ }
- for (int i = 0; i < E->self()->fallback_data_at_size.size(); i++) {
- if (E->self()->fallback_data_at_size[i].is_valid()) {
- E->self()->fallback_data_at_size.write[i]->update_oversampling();
+ for (int i = 0; i < E->self()->fallback_data_at_size.size(); i++) {
+ if (E->self()->fallback_data_at_size[i].is_valid()) {
+ E->self()->fallback_data_at_size.write[i]->update_oversampling();
- if (E->self()->has_outline() && E->self()->fallback_outline_data_at_size[i].is_valid()) {
- E->self()->fallback_outline_data_at_size.write[i]->update_oversampling();
+ if (E->self()->has_outline() && E->self()->fallback_outline_data_at_size[i].is_valid()) {
+ E->self()->fallback_outline_data_at_size.write[i]->update_oversampling();
+ }
}
}
+
+ changed.push_back(Ref<DynamicFont>(E->self()));
}
- changed.push_back(Ref<DynamicFont>(E->self()));
+ E = E->next();
}
-
- E = E->next();
}
- if (dynamic_font_mutex)
- dynamic_font_mutex->unlock();
-
for (int i = 0; i < changed.size(); i++) {
changed.write[i]->emit_changed();
}
@@ -1074,7 +1063,7 @@ void DynamicFont::update_oversampling() {
/////////////////////////
-RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String &p_original_path, Error *r_error) {
+RES ResourceFormatLoaderDynamicFont::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
if (r_error)
*r_error = ERR_FILE_CANT_OPEN;
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index fa6db370f8..c10f1e6681 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -285,7 +285,7 @@ public:
SelfList<DynamicFont> font_list;
- static Mutex *dynamic_font_mutex;
+ static Mutex dynamic_font_mutex;
static SelfList<DynamicFont>::List *dynamic_fonts;
static void initialize_dynamic_fonts();
@@ -302,7 +302,7 @@ VARIANT_ENUM_CAST(DynamicFont::SpacingType);
class ResourceFormatLoaderDynamicFont : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 316d6f04d7..1f5e4b647a 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -646,7 +646,7 @@ BitmapFont::~BitmapFont() {
////////////
-RES ResourceFormatLoaderBMFont::load(const String &p_path, const String &p_original_path, Error *r_error) {
+RES ResourceFormatLoaderBMFont::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
if (r_error)
*r_error = ERR_FILE_CANT_OPEN;
diff --git a/scene/resources/font.h b/scene/resources/font.h
index 1ce8e79f09..85b295b5f8 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -200,7 +200,7 @@ public:
class ResourceFormatLoaderBMFont : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index ff51cab0a4..d387a39dbe 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -197,7 +197,7 @@ void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
// This can be a slow operation, and `_change_notify()` (which is called by `_shader_changed()`)
// does nothing in non-editor builds anyway. See GH-34741 for details.
if (shader.is_valid() && Engine::get_singleton()->is_editor_hint()) {
- shader->disconnect_compat("changed", this, "_shader_changed");
+ shader->disconnect("changed", callable_mp(this, &ShaderMaterial::_shader_changed));
}
shader = p_shader;
@@ -207,7 +207,7 @@ void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) {
rid = shader->get_rid();
if (Engine::get_singleton()->is_editor_hint()) {
- shader->connect_compat("changed", this, "_shader_changed");
+ shader->connect("changed", callable_mp(this, &ShaderMaterial::_shader_changed));
}
}
@@ -241,7 +241,6 @@ void ShaderMaterial::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_shader"), &ShaderMaterial::get_shader);
ClassDB::bind_method(D_METHOD("set_shader_param", "param", "value"), &ShaderMaterial::set_shader_param);
ClassDB::bind_method(D_METHOD("get_shader_param", "param"), &ShaderMaterial::get_shader_param);
- ClassDB::bind_method(D_METHOD("_shader_changed"), &ShaderMaterial::_shader_changed);
ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ShaderMaterial::property_can_revert);
ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &ShaderMaterial::property_get_revert);
@@ -290,17 +289,13 @@ ShaderMaterial::~ShaderMaterial() {
/////////////////////////////////
-Mutex *BaseMaterial3D::material_mutex = NULL;
+Mutex BaseMaterial3D::material_mutex;
SelfList<BaseMaterial3D>::List *BaseMaterial3D::dirty_materials = NULL;
Map<BaseMaterial3D::MaterialKey, BaseMaterial3D::ShaderData> BaseMaterial3D::shader_map;
BaseMaterial3D::ShaderNames *BaseMaterial3D::shader_names = NULL;
void BaseMaterial3D::init_shaders() {
-#ifndef NO_THREADS
- material_mutex = Mutex::create();
-#endif
-
dirty_materials = memnew(SelfList<BaseMaterial3D>::List);
shader_names = memnew(ShaderNames);
@@ -379,10 +374,6 @@ void BaseMaterial3D::finish_shaders() {
materials_for_2d[i].unref();
}
-#ifndef NO_THREADS
- memdelete(material_mutex);
-#endif
-
memdelete(dirty_materials);
dirty_materials = NULL;
@@ -1133,44 +1124,28 @@ void BaseMaterial3D::_update_shader() {
void BaseMaterial3D::flush_changes() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
while (dirty_materials->first()) {
dirty_materials->first()->self()->_update_shader();
}
-
- if (material_mutex)
- material_mutex->unlock();
}
void BaseMaterial3D::_queue_shader_change() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
if (!element.in_list()) {
dirty_materials->add(&element);
}
-
- if (material_mutex)
- material_mutex->unlock();
}
bool BaseMaterial3D::_is_shader_dirty() const {
- bool dirty = false;
-
- if (material_mutex)
- material_mutex->lock();
-
- dirty = element.in_list();
+ MutexLock lock(material_mutex);
- if (material_mutex)
- material_mutex->unlock();
-
- return dirty;
+ return element.in_list();
}
void BaseMaterial3D::set_albedo(const Color &p_albedo) {
@@ -2580,8 +2555,7 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) :
BaseMaterial3D::~BaseMaterial3D() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
if (shader_map.has(current_key)) {
shader_map[current_key].users--;
@@ -2593,9 +2567,6 @@ BaseMaterial3D::~BaseMaterial3D() {
VS::get_singleton()->material_set_shader(_get_material(), RID());
}
-
- if (material_mutex)
- material_mutex->unlock();
}
//////////////////////
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 927334c74d..fc77226fb9 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -388,7 +388,7 @@ private:
StringName texture_names[TEXTURE_MAX];
};
- static Mutex *material_mutex;
+ static Mutex material_mutex;
static SelfList<BaseMaterial3D>::List *dirty_materials;
static ShaderNames *shader_names;
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index 08c4169167..a063b7f74f 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -1004,7 +1004,6 @@ void ArrayMesh::_set_surfaces(const Array &p_surfaces) {
} else {
// if mesh does not exist (first time this is loaded, most likely),
// we can create it with a single call, which is a lot more efficient and thread friendly
- print_line("create mesh from surfaces: " + itos(surface_data.size()));
mesh = VS::get_singleton()->mesh_create_from_surfaces(surface_data);
VS::get_singleton()->mesh_set_blend_shape_mode(mesh, (VS::BlendShapeMode)blend_shape_mode);
}
diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h
index 9155975f47..b256e86b96 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -34,7 +34,7 @@
#include "core/map.h"
#include "core/resource.h"
#include "mesh.h"
-#include "scene/3d/navigation_mesh_instance.h"
+#include "scene/3d/navigation_region.h"
#include "shape.h"
class MeshLibrary : public Resource {
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 00910095c7..0538f679cc 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -331,7 +331,7 @@ Node *SceneState::instance(GenEditState p_edit_state) const {
binds.write[j] = props[c.binds[j]];
}
- cfrom->connect_compat(snames[c.signal], cto, snames[c.method], binds, CONNECT_PERSIST | c.flags);
+ cfrom->connect(snames[c.signal], Callable(cto, snames[c.method]), binds, CONNECT_PERSIST | c.flags);
}
//Node *s = ret_nodes[0];
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index e820aec2ed..f18e8956f1 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -30,17 +30,13 @@
#include "particles_material.h"
-Mutex *ParticlesMaterial::material_mutex = NULL;
+Mutex ParticlesMaterial::material_mutex;
SelfList<ParticlesMaterial>::List *ParticlesMaterial::dirty_materials = NULL;
Map<ParticlesMaterial::MaterialKey, ParticlesMaterial::ShaderData> ParticlesMaterial::shader_map;
ParticlesMaterial::ShaderNames *ParticlesMaterial::shader_names = NULL;
void ParticlesMaterial::init_shaders() {
-#ifndef NO_THREADS
- material_mutex = Mutex::create();
-#endif
-
dirty_materials = memnew(SelfList<ParticlesMaterial>::List);
shader_names = memnew(ShaderNames);
@@ -107,10 +103,6 @@ void ParticlesMaterial::init_shaders() {
void ParticlesMaterial::finish_shaders() {
-#ifndef NO_THREADS
- memdelete(material_mutex);
-#endif
-
memdelete(dirty_materials);
dirty_materials = NULL;
@@ -612,44 +604,28 @@ void ParticlesMaterial::_update_shader() {
void ParticlesMaterial::flush_changes() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
while (dirty_materials->first()) {
dirty_materials->first()->self()->_update_shader();
}
-
- if (material_mutex)
- material_mutex->unlock();
}
void ParticlesMaterial::_queue_shader_change() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
if (!element.in_list()) {
dirty_materials->add(&element);
}
-
- if (material_mutex)
- material_mutex->unlock();
}
bool ParticlesMaterial::_is_shader_dirty() const {
- bool dirty = false;
+ MutexLock lock(material_mutex);
- if (material_mutex)
- material_mutex->lock();
-
- dirty = element.in_list();
-
- if (material_mutex)
- material_mutex->unlock();
-
- return dirty;
+ return element.in_list();
}
void ParticlesMaterial::set_direction(Vector3 p_direction) {
@@ -1298,8 +1274,7 @@ ParticlesMaterial::ParticlesMaterial() :
ParticlesMaterial::~ParticlesMaterial() {
- if (material_mutex)
- material_mutex->lock();
+ MutexLock lock(material_mutex);
if (shader_map.has(current_key)) {
shader_map[current_key].users--;
@@ -1311,7 +1286,4 @@ ParticlesMaterial::~ParticlesMaterial() {
VS::get_singleton()->material_set_shader(_get_material(), RID());
}
-
- if (material_mutex)
- material_mutex->unlock();
}
diff --git a/scene/resources/particles_material.h b/scene/resources/particles_material.h
index 246ce58a21..c6c8316995 100644
--- a/scene/resources/particles_material.h
+++ b/scene/resources/particles_material.h
@@ -126,7 +126,7 @@ private:
return mk;
}
- static Mutex *material_mutex;
+ static Mutex material_mutex;
static SelfList<ParticlesMaterial>::List *dirty_materials;
struct ShaderNames {
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index 956cc0bc4a..97bd12c119 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -45,17 +45,17 @@
///
-void ResourceInteractiveLoaderText::set_local_path(const String &p_local_path) {
+void ResourceLoaderText::set_local_path(const String &p_local_path) {
res_path = p_local_path;
}
-Ref<Resource> ResourceInteractiveLoaderText::get_resource() {
+Ref<Resource> ResourceLoaderText::get_resource() {
return resource;
}
-Error ResourceInteractiveLoaderText::_parse_sub_resource_dummy(DummyReadData *p_data, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
+Error ResourceLoaderText::_parse_sub_resource_dummy(DummyReadData *p_data, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
VariantParser::Token token;
VariantParser::get_token(p_stream, token, line, r_err_str);
@@ -85,7 +85,7 @@ Error ResourceInteractiveLoaderText::_parse_sub_resource_dummy(DummyReadData *p_
return OK;
}
-Error ResourceInteractiveLoaderText::_parse_ext_resource_dummy(DummyReadData *p_data, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
+Error ResourceLoaderText::_parse_ext_resource_dummy(DummyReadData *p_data, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
VariantParser::Token token;
VariantParser::get_token(p_stream, token, line, r_err_str);
@@ -109,7 +109,7 @@ Error ResourceInteractiveLoaderText::_parse_ext_resource_dummy(DummyReadData *p_
return OK;
}
-Error ResourceInteractiveLoaderText::_parse_sub_resource(VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
+Error ResourceLoaderText::_parse_sub_resource(VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
VariantParser::Token token;
VariantParser::get_token(p_stream, token, line, r_err_str);
@@ -143,7 +143,7 @@ Error ResourceInteractiveLoaderText::_parse_sub_resource(VariantParser::Stream *
return OK;
}
-Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
+Error ResourceLoaderText::_parse_ext_resource(VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) {
VariantParser::Token token;
VariantParser::get_token(p_stream, token, line, r_err_str);
@@ -164,15 +164,30 @@ Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream *
String path = ext_resources[id].path;
String type = ext_resources[id].type;
- if (path.find("://") == -1 && path.is_rel_path()) {
- // path is relative to file being loaded, so convert to a resource path
- path = ProjectSettings::get_singleton()->localize_path(res_path.get_base_dir().plus_file(path));
- }
+ if (ext_resources[id].cache.is_valid()) {
+ r_res = ext_resources[id].cache;
+ } else if (use_sub_threads) {
- r_res = ResourceLoader::load(path, type);
+ RES res = ResourceLoader::load_threaded_get(path);
+ if (res.is_null()) {
- if (r_res.is_null()) {
- WARN_PRINT(String("Couldn't load external resource: " + path).utf8().get_data());
+ if (ResourceLoader::get_abort_on_missing_resources()) {
+ error = ERR_FILE_CORRUPT;
+ error_text = "[ext_resource] referenced nonexistent resource at: " + path;
+ _printerr();
+ return error;
+ } else {
+ ResourceLoader::notify_dependency_error(local_path, path, type);
+ }
+ } else {
+ ext_resources[id].cache = res;
+ r_res = res;
+ }
+ } else {
+ error = ERR_FILE_CORRUPT;
+ error_text = "[ext_resource] referenced non-loaded resource at: " + path;
+ _printerr();
+ return error;
}
} else {
r_res = RES();
@@ -187,7 +202,7 @@ Error ResourceInteractiveLoaderText::_parse_ext_resource(VariantParser::Stream *
return OK;
}
-Ref<PackedScene> ResourceInteractiveLoaderText::_parse_node_tag(VariantParser::ResourceParser &parser) {
+Ref<PackedScene> ResourceLoaderText::_parse_node_tag(VariantParser::ResourceParser &parser) {
Ref<PackedScene> packed_scene;
packed_scene.instance();
@@ -278,6 +293,7 @@ Ref<PackedScene> ResourceInteractiveLoaderText::_parse_node_tag(VariantParser::R
_printerr();
return Ref<PackedScene>();
} else {
+ error = OK;
return packed_scene;
}
}
@@ -321,7 +337,7 @@ Ref<PackedScene> ResourceInteractiveLoaderText::_parse_node_tag(VariantParser::R
NodePath to = next_tag.fields["to"];
StringName method = next_tag.fields["method"];
StringName signal = next_tag.fields["signal"];
- int flags = CONNECT_PERSIST;
+ int flags = Object::CONNECT_PERSIST;
Array binds;
if (next_tag.fields.has("flags")) {
@@ -352,6 +368,7 @@ Ref<PackedScene> ResourceInteractiveLoaderText::_parse_node_tag(VariantParser::R
_printerr();
return Ref<PackedScene>();
} else {
+ error = OK;
return packed_scene;
}
}
@@ -375,6 +392,7 @@ Ref<PackedScene> ResourceInteractiveLoaderText::_parse_node_tag(VariantParser::R
_printerr();
return Ref<PackedScene>();
} else {
+ error = OK;
return packed_scene;
}
}
@@ -389,12 +407,15 @@ Ref<PackedScene> ResourceInteractiveLoaderText::_parse_node_tag(VariantParser::R
return packed_scene;
}
-Error ResourceInteractiveLoaderText::poll() {
+Error ResourceLoaderText::load() {
if (error != OK)
return error;
- if (next_tag.name == "ext_resource") {
+ while (true) {
+ if (next_tag.name != "ext_resource") {
+ break;
+ }
if (!next_tag.fields.has("path")) {
error = ERR_FILE_CORRUPT;
@@ -430,30 +451,49 @@ Error ResourceInteractiveLoaderText::poll() {
path = remaps[path];
}
- RES res = ResourceLoader::load(path, type);
+ ExtResource er;
+ er.path = path;
+ er.type = type;
+
+ if (use_sub_threads) {
- if (res.is_null()) {
+ Error err = ResourceLoader::load_threaded_request(path, type, use_sub_threads, local_path);
- if (ResourceLoader::get_abort_on_missing_resources()) {
- error = ERR_FILE_CORRUPT;
- error_text = "[ext_resource] referenced nonexistent resource at: " + path;
- _printerr();
- return error;
- } else {
- ResourceLoader::notify_dependency_error(local_path, path, type);
+ if (err != OK) {
+ if (ResourceLoader::get_abort_on_missing_resources()) {
+ error = ERR_FILE_CORRUPT;
+ error_text = "[ext_resource] referenced broken resource at: " + path;
+ _printerr();
+ return error;
+ } else {
+ ResourceLoader::notify_dependency_error(local_path, path, type);
+ }
}
+
} else {
+ RES res = ResourceLoader::load(path, type);
+
+ if (res.is_null()) {
+
+ if (ResourceLoader::get_abort_on_missing_resources()) {
+ error = ERR_FILE_CORRUPT;
+ error_text = "[ext_resource] referenced nonexistent resource at: " + path;
+ _printerr();
+ return error;
+ } else {
+ ResourceLoader::notify_dependency_error(local_path, path, type);
+ }
+ } else {
- resource_cache.push_back(res);
#ifdef TOOLS_ENABLED
- //remember ID for saving
- res->set_id_for_path(local_path, index);
+ //remember ID for saving
+ res->set_id_for_path(local_path, index);
#endif
+ }
+
+ er.cache = res;
}
- ExtResource er;
- er.path = path;
- er.type = type;
ext_resources[index] = er;
error = VariantParser::parse_tag(&stream, lines, error_text, next_tag, &rp);
@@ -463,9 +503,16 @@ Error ResourceInteractiveLoaderText::poll() {
}
resource_current++;
- return error;
+ }
- } else if (next_tag.name == "sub_resource") {
+ //these are the ones that count
+ resources_total -= resource_current;
+ resource_current = 0;
+
+ while (true) {
+ if (next_tag.name != "sub_resource") {
+ break;
+ }
if (!next_tag.fields.has("type")) {
error = ERR_FILE_CORRUPT;
@@ -546,9 +593,15 @@ Error ResourceInteractiveLoaderText::poll() {
}
}
- return OK;
+ if (progress) {
+ *progress = resource_current / float(resources_total);
+ }
+ }
- } else if (next_tag.name == "resource") {
+ while (true) {
+ if (next_tag.name != "resource") {
+ break;
+ }
if (is_scene) {
@@ -591,6 +644,7 @@ Error ResourceInteractiveLoaderText::poll() {
if (error != ERR_FILE_EOF) {
_printerr();
} else {
+ error = OK;
if (!ResourceCache::has(res_path)) {
resource->set_path(res_path);
}
@@ -609,14 +663,23 @@ Error ResourceInteractiveLoaderText::poll() {
_printerr();
return error;
} else {
- error = ERR_FILE_EOF;
+ error = OK;
+ if (progress) {
+ *progress = resource_current / float(resources_total);
+ }
+
return error;
}
}
- return OK;
+ if (progress) {
+ *progress = resource_current / float(resources_total);
+ }
+ }
- } else if (next_tag.name == "node") {
+ //for scene files
+
+ if (next_tag.name == "node") {
if (!is_scene) {
@@ -631,49 +694,54 @@ Error ResourceInteractiveLoaderText::poll() {
if (!packed_scene.is_valid())
return error;
- error = ERR_FILE_EOF;
+ error = OK;
//get it here
resource = packed_scene;
if (!ResourceCache::has(res_path)) {
packed_scene->set_path(res_path);
}
- return error;
+ resource_current++;
+
+ if (progress) {
+ *progress = resource_current / float(resources_total);
+ }
+ return error;
} else {
error_text += "Unknown tag in file: " + next_tag.name;
_printerr();
error = ERR_FILE_CORRUPT;
return error;
}
-
- return OK;
}
-int ResourceInteractiveLoaderText::get_stage() const {
+int ResourceLoaderText::get_stage() const {
return resource_current;
}
-int ResourceInteractiveLoaderText::get_stage_count() const {
+int ResourceLoaderText::get_stage_count() const {
return resources_total; //+ext_resources;
}
-void ResourceInteractiveLoaderText::set_translation_remapped(bool p_remapped) {
+void ResourceLoaderText::set_translation_remapped(bool p_remapped) {
translation_remapped = p_remapped;
}
-ResourceInteractiveLoaderText::ResourceInteractiveLoaderText() {
+ResourceLoaderText::ResourceLoaderText() {
+ progress = nullptr;
translation_remapped = false;
+ use_sub_threads = false;
}
-ResourceInteractiveLoaderText::~ResourceInteractiveLoaderText() {
+ResourceLoaderText::~ResourceLoaderText() {
memdelete(f);
}
-void ResourceInteractiveLoaderText::get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types) {
+void ResourceLoaderText::get_dependencies(FileAccess *p_f, List<String> *p_dependencies, bool p_add_types) {
open(p_f);
ignore_resource_parsing = true;
@@ -720,7 +788,7 @@ void ResourceInteractiveLoaderText::get_dependencies(FileAccess *p_f, List<Strin
}
}
-Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const String &p_path, const Map<String, String> &p_map) {
+Error ResourceLoaderText::rename_dependencies(FileAccess *p_f, const String &p_path, const Map<String, String> &p_map) {
open(p_f, true);
ERR_FAIL_COND_V(error != OK, error);
@@ -822,7 +890,7 @@ Error ResourceInteractiveLoaderText::rename_dependencies(FileAccess *p_f, const
return OK;
}
-void ResourceInteractiveLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) {
+void ResourceLoaderText::open(FileAccess *p_f, bool p_skip_first_tag) {
error = OK;
@@ -908,7 +976,7 @@ static void bs_save_unicode_string(FileAccess *f, const String &p_string, bool p
f->store_buffer((const uint8_t *)utf8.get_data(), utf8.length() + 1);
}
-Error ResourceInteractiveLoaderText::save_as_binary(FileAccess *p_f, const String &p_path) {
+Error ResourceLoaderText::save_as_binary(FileAccess *p_f, const String &p_path) {
if (error)
return error;
@@ -1172,7 +1240,7 @@ Error ResourceInteractiveLoaderText::save_as_binary(FileAccess *p_f, const Strin
return OK;
}
-String ResourceInteractiveLoaderText::recognize(FileAccess *p_f) {
+String ResourceLoaderText::recognize(FileAccess *p_f) {
error = OK;
@@ -1217,24 +1285,34 @@ String ResourceInteractiveLoaderText::recognize(FileAccess *p_f) {
/////////////////////
-Ref<ResourceInteractiveLoader> ResourceFormatLoaderText::load_interactive(const String &p_path, const String &p_original_path, Error *r_error) {
+RES ResourceFormatLoaderText::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
if (r_error)
*r_error = ERR_CANT_OPEN;
Error err;
+
FileAccess *f = FileAccess::open(p_path, FileAccess::READ, &err);
- ERR_FAIL_COND_V_MSG(err != OK, Ref<ResourceInteractiveLoader>(), "Cannot open file '" + p_path + "'.");
+ ERR_FAIL_COND_V_MSG(err != OK, RES(), "Cannot open file '" + p_path + "'.");
- Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
+ ResourceLoaderText loader;
String path = p_original_path != "" ? p_original_path : p_path;
- ria->local_path = ProjectSettings::get_singleton()->localize_path(path);
- ria->res_path = ria->local_path;
- //ria->set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
- ria->open(f);
-
- return ria;
+ loader.use_sub_threads = p_use_sub_threads;
+ loader.local_path = ProjectSettings::get_singleton()->localize_path(path);
+ loader.progress = r_progress;
+ loader.res_path = loader.local_path;
+ //loader.set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
+ loader.open(f);
+ err = loader.load();
+ if (r_error) {
+ *r_error = err;
+ }
+ if (err == OK) {
+ return loader.get_resource();
+ } else {
+ return RES();
+ }
}
void ResourceFormatLoaderText::get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const {
@@ -1276,11 +1354,11 @@ String ResourceFormatLoaderText::get_resource_type(const String &p_path) const {
return ""; //could not rwead
}
- Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
- ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
- ria->res_path = ria->local_path;
- //ria->set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
- String r = ria->recognize(f);
+ ResourceLoaderText loader;
+ loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
+ loader.res_path = loader.local_path;
+ //loader.set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
+ String r = loader.recognize(f);
return ClassDB::get_compatibility_remapped_class(r);
}
@@ -1292,11 +1370,11 @@ void ResourceFormatLoaderText::get_dependencies(const String &p_path, List<Strin
ERR_FAIL();
}
- Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
- ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
- ria->res_path = ria->local_path;
- //ria->set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
- ria->get_dependencies(f, p_dependencies, p_add_types);
+ ResourceLoaderText loader;
+ loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
+ loader.res_path = loader.local_path;
+ //loader.set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
+ loader.get_dependencies(f, p_dependencies, p_add_types);
}
Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const Map<String, String> &p_map) {
@@ -1307,11 +1385,11 @@ Error ResourceFormatLoaderText::rename_dependencies(const String &p_path, const
ERR_FAIL_V(ERR_CANT_OPEN);
}
- Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
- ria->local_path = ProjectSettings::get_singleton()->localize_path(p_path);
- ria->res_path = ria->local_path;
- //ria->set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
- return ria->rename_dependencies(f, p_path, p_map);
+ ResourceLoaderText loader;
+ loader.local_path = ProjectSettings::get_singleton()->localize_path(p_path);
+ loader.res_path = loader.local_path;
+ //loader.set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
+ return loader.rename_dependencies(f, p_path, p_map);
}
ResourceFormatLoaderText *ResourceFormatLoaderText::singleton = NULL;
@@ -1323,13 +1401,13 @@ Error ResourceFormatLoaderText::convert_file_to_binary(const String &p_src_path,
ERR_FAIL_COND_V_MSG(err != OK, ERR_CANT_OPEN, "Cannot open file '" + p_src_path + "'.");
- Ref<ResourceInteractiveLoaderText> ria = memnew(ResourceInteractiveLoaderText);
+ ResourceLoaderText loader;
const String &path = p_src_path;
- ria->local_path = ProjectSettings::get_singleton()->localize_path(path);
- ria->res_path = ria->local_path;
- //ria->set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
- ria->open(f);
- return ria->save_as_binary(f, p_dst_path);
+ loader.local_path = ProjectSettings::get_singleton()->localize_path(path);
+ loader.res_path = loader.local_path;
+ //loader.set_local_path( ProjectSettings::get_singleton()->localize_path(p_path) );
+ loader.open(f);
+ return loader.save_as_binary(f, p_dst_path);
}
/*****************************************************************************************************/
diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h
index 66c69725e8..2425ac7f6c 100644
--- a/scene/resources/resource_format_text.h
+++ b/scene/resources/resource_format_text.h
@@ -37,7 +37,7 @@
#include "core/variant_parser.h"
#include "scene/resources/packed_scene.h"
-class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
+class ResourceLoaderText {
bool translation_remapped;
String local_path;
@@ -49,6 +49,7 @@ class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
VariantParser::StreamFile stream;
struct ExtResource {
+ RES cache;
String path;
String type;
};
@@ -68,13 +69,16 @@ class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
VariantParser::Tag next_tag;
+ bool use_sub_threads;
+ float *progress;
+
mutable int lines;
Map<String, String> remaps;
//void _printerr();
- static Error _parse_sub_resources(void *p_self, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText *>(p_self)->_parse_sub_resource(p_stream, r_res, line, r_err_str); }
- static Error _parse_ext_resources(void *p_self, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) { return reinterpret_cast<ResourceInteractiveLoaderText *>(p_self)->_parse_ext_resource(p_stream, r_res, line, r_err_str); }
+ static Error _parse_sub_resources(void *p_self, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) { return reinterpret_cast<ResourceLoaderText *>(p_self)->_parse_sub_resource(p_stream, r_res, line, r_err_str); }
+ static Error _parse_ext_resources(void *p_self, VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str) { return reinterpret_cast<ResourceLoaderText *>(p_self)->_parse_ext_resource(p_stream, r_res, line, r_err_str); }
Error _parse_sub_resource(VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str);
Error _parse_ext_resource(VariantParser::Stream *p_stream, Ref<Resource> &r_res, int &line, String &r_err_str);
@@ -110,12 +114,12 @@ class ResourceInteractiveLoaderText : public ResourceInteractiveLoader {
Ref<PackedScene> _parse_node_tag(VariantParser::ResourceParser &parser);
public:
- virtual void set_local_path(const String &p_local_path);
- virtual Ref<Resource> get_resource();
- virtual Error poll();
- virtual int get_stage() const;
- virtual int get_stage_count() const;
- virtual void set_translation_remapped(bool p_remapped);
+ void set_local_path(const String &p_local_path);
+ Ref<Resource> get_resource();
+ Error load();
+ int get_stage() const;
+ int get_stage_count() const;
+ void set_translation_remapped(bool p_remapped);
void open(FileAccess *p_f, bool p_skip_first_tag = false);
String recognize(FileAccess *p_f);
@@ -123,14 +127,14 @@ public:
Error rename_dependencies(FileAccess *p_f, const String &p_path, const Map<String, String> &p_map);
Error save_as_binary(FileAccess *p_f, const String &p_path);
- ResourceInteractiveLoaderText();
- ~ResourceInteractiveLoaderText();
+ ResourceLoaderText();
+ ~ResourceLoaderText();
};
class ResourceFormatLoaderText : public ResourceFormatLoader {
public:
static ResourceFormatLoaderText *singleton;
- virtual Ref<ResourceInteractiveLoader> load_interactive(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const;
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 79cb9754df..8f76c0165f 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -173,7 +173,7 @@ Shader::~Shader() {
}
////////////
-RES ResourceFormatLoaderShader::load(const String &p_path, const String &p_original_path, Error *r_error) {
+RES ResourceFormatLoaderShader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
if (r_error)
*r_error = ERR_FILE_CANT_OPEN;
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 702e58aedc..5050632dd5 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -101,7 +101,7 @@ VARIANT_ENUM_CAST(Shader::Mode);
class ResourceFormatLoaderShader : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 64de19c197..cb827c4b0b 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -363,7 +363,6 @@ Ref<Image> StreamTexture::load_image_from_file(FileAccess *f, int p_size_limit)
uint32_t mipmaps = f->get_32();
Image::Format format = Image::Format(f->get_32());
- print_line("format: " + itos(data_format) + " size " + Size2i(w, h) + " mipmaps: " + itos(mipmaps));
if (data_format == DATA_FORMAT_LOSSLESS || data_format == DATA_FORMAT_LOSSY || data_format == DATA_FORMAT_BASIS_UNIVERSAL) {
//look for a PNG or WEBP file inside
@@ -797,7 +796,7 @@ StreamTexture::~StreamTexture() {
}
}
-RES ResourceFormatLoaderStreamTexture::load(const String &p_path, const String &p_original_path, Error *r_error) {
+RES ResourceFormatLoaderStreamTexture::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
Ref<StreamTexture> st;
st.instance();
@@ -1409,11 +1408,11 @@ void CurveTexture::ensure_default_setup(float p_min, float p_max) {
void CurveTexture::set_curve(Ref<Curve> p_curve) {
if (_curve != p_curve) {
if (_curve.is_valid()) {
- _curve->disconnect_compat(CoreStringNames::get_singleton()->changed, this, "_update");
+ _curve->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CurveTexture::_update));
}
_curve = p_curve;
if (_curve.is_valid()) {
- _curve->connect_compat(CoreStringNames::get_singleton()->changed, this, "_update");
+ _curve->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &CurveTexture::_update));
}
_update();
}
@@ -1514,11 +1513,11 @@ void GradientTexture::set_gradient(Ref<Gradient> p_gradient) {
if (p_gradient == gradient)
return;
if (gradient.is_valid()) {
- gradient->disconnect_compat(CoreStringNames::get_singleton()->changed, this, "_update");
+ gradient->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &GradientTexture::_update));
}
gradient = p_gradient;
if (gradient.is_valid()) {
- gradient->connect_compat(CoreStringNames::get_singleton()->changed, this, "_update");
+ gradient->connect(CoreStringNames::get_singleton()->changed, callable_mp(this, &GradientTexture::_update));
}
_update();
emit_changed();
@@ -1843,8 +1842,6 @@ void AnimatedTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_frame_delay", "frame", "delay"), &AnimatedTexture::set_frame_delay);
ClassDB::bind_method(D_METHOD("get_frame_delay", "frame"), &AnimatedTexture::get_frame_delay);
- ClassDB::bind_method(D_METHOD("_update_proxy"), &AnimatedTexture::_update_proxy);
-
ADD_PROPERTY(PropertyInfo(Variant::INT, "frames", PROPERTY_HINT_RANGE, "1," + itos(MAX_FRAMES), PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_UPDATE_ALL_IF_MODIFIED), "set_frames", "get_frames");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fps", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_fps", "get_fps");
@@ -1867,7 +1864,7 @@ AnimatedTexture::AnimatedTexture() {
fps = 4;
prev_ticks = 0;
current_frame = 0;
- VisualServer::get_singleton()->connect_compat("frame_pre_draw", this, "_update_proxy");
+ VisualServer::get_singleton()->connect("frame_pre_draw", callable_mp(this, &AnimatedTexture::_update_proxy));
#ifndef NO_THREADS
rw_lock = RWLock::create();
@@ -2027,7 +2024,7 @@ TextureLayered::~TextureLayered() {
}
}
-RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String &p_original_path, Error *r_error) {
+RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) {
if (r_error) {
*r_error = ERR_CANT_OPEN;
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index cd8576539b..237c02a8cd 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -213,7 +213,7 @@ public:
class ResourceFormatLoaderStreamTexture : public ResourceFormatLoader {
public:
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
@@ -421,7 +421,7 @@ public:
COMPRESSION_UNCOMPRESSED
};
- virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
+ virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
virtual bool handles_type(const String &p_type) const;
virtual String get_resource_type(const String &p_path) const;
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 5db521bc20..d67f5f9ff2 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -302,13 +302,13 @@ void Theme::set_default_theme_font(const Ref<Font> &p_default_font) {
return;
if (default_theme_font.is_valid()) {
- default_theme_font->disconnect_compat("changed", this, "_emit_theme_changed");
+ default_theme_font->disconnect("changed", callable_mp(this, &Theme::_emit_theme_changed));
}
default_theme_font = p_default_font;
if (default_theme_font.is_valid()) {
- default_theme_font->connect_compat("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
+ default_theme_font->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(), CONNECT_REFERENCE_COUNTED);
}
_change_notify();
@@ -366,13 +366,13 @@ void Theme::set_icon(const StringName &p_name, const StringName &p_type, const R
bool new_value = !icon_map.has(p_type) || !icon_map[p_type].has(p_name);
if (icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid()) {
- icon_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
+ icon_map[p_type][p_name]->disconnect("changed", callable_mp(this, &Theme::_emit_theme_changed));
}
icon_map[p_type][p_name] = p_icon;
if (p_icon.is_valid()) {
- icon_map[p_type][p_name]->connect_compat("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
+ icon_map[p_type][p_name]->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(), CONNECT_REFERENCE_COUNTED);
}
if (new_value) {
@@ -401,7 +401,7 @@ void Theme::clear_icon(const StringName &p_name, const StringName &p_type) {
ERR_FAIL_COND(!icon_map[p_type].has(p_name));
if (icon_map[p_type][p_name].is_valid()) {
- icon_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
+ icon_map[p_type][p_name]->disconnect("changed", callable_mp(this, &Theme::_emit_theme_changed));
}
icon_map[p_type].erase(p_name);
@@ -479,13 +479,13 @@ void Theme::set_stylebox(const StringName &p_name, const StringName &p_type, con
bool new_value = !style_map.has(p_type) || !style_map[p_type].has(p_name);
if (style_map[p_type].has(p_name) && style_map[p_type][p_name].is_valid()) {
- style_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
+ style_map[p_type][p_name]->disconnect("changed", callable_mp(this, &Theme::_emit_theme_changed));
}
style_map[p_type][p_name] = p_style;
if (p_style.is_valid()) {
- style_map[p_type][p_name]->connect_compat("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
+ style_map[p_type][p_name]->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(), CONNECT_REFERENCE_COUNTED);
}
if (new_value)
@@ -514,7 +514,7 @@ void Theme::clear_stylebox(const StringName &p_name, const StringName &p_type) {
ERR_FAIL_COND(!style_map[p_type].has(p_name));
if (style_map[p_type][p_name].is_valid()) {
- style_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
+ style_map[p_type][p_name]->disconnect("changed", callable_mp(this, &Theme::_emit_theme_changed));
}
style_map[p_type].erase(p_name);
@@ -554,13 +554,13 @@ void Theme::set_font(const StringName &p_name, const StringName &p_type, const R
bool new_value = !font_map.has(p_type) || !font_map[p_type].has(p_name);
if (font_map[p_type][p_name].is_valid()) {
- font_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
+ font_map[p_type][p_name]->disconnect("changed", callable_mp(this, &Theme::_emit_theme_changed));
}
font_map[p_type][p_name] = p_font;
if (p_font.is_valid()) {
- font_map[p_type][p_name]->connect_compat("changed", this, "_emit_theme_changed", varray(), CONNECT_REFERENCE_COUNTED);
+ font_map[p_type][p_name]->connect("changed", callable_mp(this, &Theme::_emit_theme_changed), varray(), CONNECT_REFERENCE_COUNTED);
}
if (new_value) {
@@ -589,7 +589,7 @@ void Theme::clear_font(const StringName &p_name, const StringName &p_type) {
ERR_FAIL_COND(!font_map[p_type].has(p_name));
if (font_map[p_type][p_name].is_valid()) {
- font_map[p_type][p_name]->disconnect_compat("changed", this, "_emit_theme_changed");
+ font_map[p_type][p_name]->disconnect("changed", callable_mp(this, &Theme::_emit_theme_changed));
}
font_map[p_type].erase(p_name);
@@ -722,7 +722,7 @@ void Theme::clear() {
while ((L = icon_map[*K].next(L))) {
Ref<Texture2D> icon = icon_map[*K][*L];
if (icon.is_valid()) {
- icon->disconnect_compat("changed", this, "_emit_theme_changed");
+ icon->disconnect("changed", callable_mp(this, &Theme::_emit_theme_changed));
}
}
}
@@ -735,7 +735,7 @@ void Theme::clear() {
while ((L = style_map[*K].next(L))) {
Ref<StyleBox> style = style_map[*K][*L];
if (style.is_valid()) {
- style->disconnect_compat("changed", this, "_emit_theme_changed");
+ style->disconnect("changed", callable_mp(this, &Theme::_emit_theme_changed));
}
}
}
@@ -748,7 +748,7 @@ void Theme::clear() {
while ((L = font_map[*K].next(L))) {
Ref<Font> font = font_map[*K][*L];
if (font.is_valid()) {
- font->disconnect_compat("changed", this, "_emit_theme_changed");
+ font->disconnect("changed", callable_mp(this, &Theme::_emit_theme_changed));
}
}
}
@@ -906,8 +906,6 @@ void Theme::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_type_list", "type"), &Theme::_get_type_list);
- ClassDB::bind_method(D_METHOD("_emit_theme_changed"), &Theme::_emit_theme_changed);
-
ClassDB::bind_method("copy_default_theme", &Theme::copy_default_theme);
ClassDB::bind_method(D_METHOD("copy_theme", "other"), &Theme::copy_theme);
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 556d299198..407325c199 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -349,10 +349,10 @@ void VisualShader::add_node(Type p_type, const Ref<VisualShaderNode> &p_node, co
if (input.is_valid()) {
input->shader_mode = shader_mode;
input->shader_type = p_type;
- input->connect_compat("input_type_changed", this, "_input_type_changed", varray(p_type, p_id));
+ input->connect("input_type_changed", callable_mp(this, &VisualShader::_input_type_changed), varray(p_type, p_id));
}
- n.node->connect_compat("changed", this, "_queue_update");
+ n.node->connect("changed", callable_mp(this, &VisualShader::_queue_update));
Ref<VisualShaderNodeCustom> custom = n.node;
if (custom.is_valid()) {
@@ -419,10 +419,10 @@ void VisualShader::remove_node(Type p_type, int p_id) {
Ref<VisualShaderNodeInput> input = g->nodes[p_id].node;
if (input.is_valid()) {
- input->disconnect_compat("input_type_changed", this, "_input_type_changed");
+ input->disconnect("input_type_changed", callable_mp(this, &VisualShader::_input_type_changed));
}
- g->nodes[p_id].node->disconnect_compat("changed", this, "_queue_update");
+ g->nodes[p_id].node->disconnect("changed", callable_mp(this, &VisualShader::_queue_update));
g->nodes.erase(p_id);
@@ -1480,11 +1480,8 @@ void VisualShader::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_graph_offset", "offset"), &VisualShader::set_graph_offset);
ClassDB::bind_method(D_METHOD("get_graph_offset"), &VisualShader::get_graph_offset);
- ClassDB::bind_method(D_METHOD("_queue_update"), &VisualShader::_queue_update);
ClassDB::bind_method(D_METHOD("_update_shader"), &VisualShader::_update_shader);
- ClassDB::bind_method(D_METHOD("_input_type_changed"), &VisualShader::_input_type_changed);
-
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "graph_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_graph_offset", "get_graph_offset");
ADD_PROPERTY(PropertyInfo(Variant::STRING, "version", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "set_version", "get_version");
diff --git a/scene/resources/plane_shape.cpp b/scene/resources/world_margin_shape.cpp
index ddc820233e..b5b701327c 100644
--- a/scene/resources/plane_shape.cpp
+++ b/scene/resources/world_margin_shape.cpp
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* plane_shape.cpp */
+/* world_margin_shape.cpp */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,11 +28,11 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "plane_shape.h"
+#include "world_margin_shape.h"
#include "servers/physics_server.h"
-Vector<Vector3> PlaneShape::get_debug_mesh_lines() {
+Vector<Vector3> WorldMarginShape::get_debug_mesh_lines() {
Plane p = get_plane();
Vector<Vector3> points;
@@ -61,13 +61,13 @@ Vector<Vector3> PlaneShape::get_debug_mesh_lines() {
return points;
}
-void PlaneShape::_update_shape() {
+void WorldMarginShape::_update_shape() {
PhysicsServer::get_singleton()->shape_set_data(get_shape(), plane);
Shape::_update_shape();
}
-void PlaneShape::set_plane(Plane p_plane) {
+void WorldMarginShape::set_plane(Plane p_plane) {
plane = p_plane;
_update_shape();
@@ -75,20 +75,20 @@ void PlaneShape::set_plane(Plane p_plane) {
_change_notify("plane");
}
-Plane PlaneShape::get_plane() const {
+Plane WorldMarginShape::get_plane() const {
return plane;
}
-void PlaneShape::_bind_methods() {
+void WorldMarginShape::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_plane", "plane"), &PlaneShape::set_plane);
- ClassDB::bind_method(D_METHOD("get_plane"), &PlaneShape::get_plane);
+ ClassDB::bind_method(D_METHOD("set_plane", "plane"), &WorldMarginShape::set_plane);
+ ClassDB::bind_method(D_METHOD("get_plane"), &WorldMarginShape::get_plane);
ADD_PROPERTY(PropertyInfo(Variant::PLANE, "plane"), "set_plane", "get_plane");
}
-PlaneShape::PlaneShape() :
+WorldMarginShape::WorldMarginShape() :
Shape(PhysicsServer::get_singleton()->shape_create(PhysicsServer::SHAPE_PLANE)) {
set_plane(Plane(0, 1, 0, 0));
diff --git a/scene/resources/plane_shape.h b/scene/resources/world_margin_shape.h
index 360f9dbbe9..78ea570212 100644
--- a/scene/resources/plane_shape.h
+++ b/scene/resources/world_margin_shape.h
@@ -1,5 +1,5 @@
/*************************************************************************/
-/* plane_shape.h */
+/* world_margin_shape.h */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
@@ -28,14 +28,14 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#ifndef PLANE_SHAPE_H
-#define PLANE_SHAPE_H
+#ifndef WORLD_MARGIN_SHAPE_H
+#define WORLD_MARGIN_SHAPE_H
#include "scene/resources/shape.h"
-class PlaneShape : public Shape {
+class WorldMarginShape : public Shape {
- GDCLASS(PlaneShape, Shape);
+ GDCLASS(WorldMarginShape, Shape);
Plane plane;
protected:
@@ -52,6 +52,6 @@ public:
return 0;
}
- PlaneShape();
+ WorldMarginShape();
};
-#endif // PLANE_SHAPE_H
+#endif // WORLD_MARGIN_SHAPE_H