summaryrefslogtreecommitdiff
path: root/editor/import
diff options
context:
space:
mode:
Diffstat (limited to 'editor/import')
-rw-r--r--editor/import/editor_import_collada.cpp6
-rw-r--r--editor/import/resource_importer_bitmask.cpp4
-rw-r--r--editor/import/resource_importer_csv_translation.cpp2
-rw-r--r--editor/import/resource_importer_layered_texture.cpp4
-rw-r--r--editor/import/resource_importer_obj.cpp8
-rw-r--r--editor/import/resource_importer_scene.cpp4
-rw-r--r--editor/import/resource_importer_shader_file.cpp2
-rw-r--r--editor/import/resource_importer_texture.cpp6
-rw-r--r--editor/import/resource_importer_texture_atlas.cpp16
-rw-r--r--editor/import/resource_importer_wav.cpp2
-rw-r--r--editor/import/scene_import_settings.cpp16
-rw-r--r--editor/import/scene_importer_mesh.cpp15
12 files changed, 43 insertions, 42 deletions
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index dc1bd38a99..ddf89f077b 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -850,7 +850,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<EditorSceneImpor
}
Ref<SurfaceTool> surftool;
- surftool.instance();
+ surftool.instantiate();
surftool->begin(Mesh::PRIMITIVE_TRIANGLES);
for (int k = 0; k < vertex_array.size(); k++) {
@@ -1544,7 +1544,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
}
Vector3 s = xform.basis.get_scale();
- bool singular_matrix = Math::is_equal_approx(s.x, 0.0f) || Math::is_equal_approx(s.y, 0.0f) || Math::is_equal_approx(s.z, 0.0f);
+ bool singular_matrix = Math::is_zero_approx(s.x) || Math::is_zero_approx(s.y) || Math::is_zero_approx(s.z);
Quaternion q = singular_matrix ? Quaternion() : xform.basis.get_rotation_quaternion();
Vector3 l = xform.origin;
@@ -1595,7 +1595,7 @@ void ColladaImport::create_animation(int p_clip, bool p_make_tracks_in_all_bones
xform = sk->get_bone_rest(nm.bone).affine_inverse() * xform;
Vector3 s = xform.basis.get_scale();
- bool singular_matrix = Math::is_equal_approx(s.x, 0.0f) || Math::is_equal_approx(s.y, 0.0f) || Math::is_equal_approx(s.z, 0.0f);
+ bool singular_matrix = Math::is_zero_approx(s.x) || Math::is_zero_approx(s.y) || Math::is_zero_approx(s.z);
Quaternion q = singular_matrix ? Quaternion() : xform.basis.get_rotation_quaternion();
Vector3 l = xform.origin;
diff --git a/editor/import/resource_importer_bitmask.cpp b/editor/import/resource_importer_bitmask.cpp
index ffef759c07..7fd9230284 100644
--- a/editor/import/resource_importer_bitmask.cpp
+++ b/editor/import/resource_importer_bitmask.cpp
@@ -78,7 +78,7 @@ Error ResourceImporterBitMap::import(const String &p_source_file, const String &
int create_from = p_options["create_from"];
float threshold = p_options["threshold"];
Ref<Image> image;
- image.instance();
+ image.instantiate();
Error err = ImageLoader::load_image(p_source_file, image);
if (err != OK) {
return err;
@@ -88,7 +88,7 @@ Error ResourceImporterBitMap::import(const String &p_source_file, const String &
int h = image->get_height();
Ref<BitMap> bitmap;
- bitmap.instance();
+ bitmap.instantiate();
bitmap->create(Size2(w, h));
for (int i = 0; i < h; i++) {
diff --git a/editor/import/resource_importer_csv_translation.cpp b/editor/import/resource_importer_csv_translation.cpp
index c9e446a1a2..07647d8b6a 100644
--- a/editor/import/resource_importer_csv_translation.cpp
+++ b/editor/import/resource_importer_csv_translation.cpp
@@ -104,7 +104,7 @@ Error ResourceImporterCSVTranslation::import(const String &p_source_file, const
locales.push_back(locale);
Ref<Translation> translation;
- translation.instance();
+ translation.instantiate();
translation->set_locale(locale);
translations.push_back(translation);
}
diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp
index 6d2215c379..2ac8b8bd7d 100644
--- a/editor/import/resource_importer_layered_texture.cpp
+++ b/editor/import/resource_importer_layered_texture.cpp
@@ -186,7 +186,7 @@ void ResourceImporterLayeredTexture::_save_tex(Vector<Ref<Image>> p_images, cons
for (int i = 0; i < mm_d; i++) {
Ref<Image> mm;
- mm.instance();
+ mm.instantiate();
mm->create(mm_w, mm_h, false, p_images[0]->get_format());
Vector3 pos;
pos.z = float(i) * float(d) / float(mm_d) + 0.5;
@@ -328,7 +328,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const
}
Ref<Image> image;
- image.instance();
+ image.instantiate();
Error err = ImageLoader::load_image(p_source_file, image, nullptr, false, 1.0);
if (err != OK) {
return err;
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 3aa17ee581..01603c0a6a 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -57,7 +57,7 @@ static Error _parse_material_library(const String &p_path, Map<String, Ref<Stand
//vertex
current_name = l.replace("newmtl", "").strip_edges();
- current.instance();
+ current.instantiate();
current->set_name(current_name);
material_map[current_name] = current;
} else if (l.begins_with("Ka ")) {
@@ -207,7 +207,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, vformat("Couldn't open OBJ file '%s', it may not exist or not be readable.", p_path));
Ref<ArrayMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
bool generate_tangents = p_generate_tangents;
Vector3 scale_mesh = p_scale_mesh;
@@ -378,7 +378,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
if (!p_single_mesh) {
mesh->set_name(name);
r_meshes.push_back(mesh);
- mesh.instance();
+ mesh.instantiate();
current_group = "";
current_material = "";
}
@@ -440,7 +440,7 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in
for (List<Ref<Mesh>>::Element *E = meshes.front(); E; E = E->next()) {
Ref<EditorSceneImporterMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
Ref<Mesh> m = E->get();
for (int i = 0; i < m->get_surface_count(); i++) {
mesh->add_surface(m->surface_get_primitive_type(i), m->surface_get_arrays(i), Array(), Dictionary(), m->surface_get_material(i));
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 08aa2fecbb..c14b948dae 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -1422,7 +1422,7 @@ Error ResourceImporterScene::import(const String &p_source_file, const String &p
}
if (root_type != "Node3D") {
- Node *base_node = Object::cast_to<Node>(ClassDB::instance(root_type));
+ Node *base_node = Object::cast_to<Node>(ClassDB::instantiate(root_type));
if (base_node) {
scene->replace_by(base_node);
@@ -1557,7 +1557,7 @@ Node *EditorSceneImporterESCN::import_scene(const String &p_path, uint32_t p_fla
Ref<PackedScene> ps = ResourceFormatLoaderText::singleton->load(p_path, p_path, &error);
ERR_FAIL_COND_V_MSG(!ps.is_valid(), nullptr, "Cannot load scene as text resource from path '" + p_path + "'.");
- Node *scene = ps->instance();
+ Node *scene = ps->instantiate();
ERR_FAIL_COND_V(!scene, nullptr);
return scene;
diff --git a/editor/import/resource_importer_shader_file.cpp b/editor/import/resource_importer_shader_file.cpp
index 70119bfd1c..4d92490675 100644
--- a/editor/import/resource_importer_shader_file.cpp
+++ b/editor/import/resource_importer_shader_file.cpp
@@ -99,7 +99,7 @@ Error ResourceImporterShaderFile::import(const String &p_source_file, const Stri
String file_txt = file->get_as_utf8_string();
Ref<RDShaderFile> shader_file;
- shader_file.instance();
+ shader_file.instantiate();
String base_path = p_source_file.get_base_dir();
err = shader_file->parse_versions_from_text(file_txt, "", _include_function, &base_path);
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp
index 72df65a787..daf7b15794 100644
--- a/editor/import/resource_importer_texture.cpp
+++ b/editor/import/resource_importer_texture.cpp
@@ -88,7 +88,7 @@ void ResourceImporterTexture::update_imports() {
for (Map<StringName, MakeInfo>::Element *E = make_flags.front(); E; E = E->next()) {
Ref<ConfigFile> cf;
- cf.instance();
+ cf.instantiate();
String src_path = String(E->key()) + ".import";
Error err = cf->load(src_path);
@@ -411,13 +411,13 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String
Image::RoughnessChannel roughness_channel = Image::ROUGHNESS_CHANNEL_R;
if (mipmaps && roughness > 1 && FileAccess::exists(normal_map)) {
- normal_image.instance();
+ normal_image.instantiate();
if (ImageLoader::load_image(normal_map, normal_image) == OK) {
roughness_channel = Image::RoughnessChannel(roughness - 2);
}
}
Ref<Image> image;
- image.instance();
+ image.instantiate();
Error err = ImageLoader::load_image(p_source_file, image, nullptr, hdr_as_srgb, scale);
if (err != OK) {
return err;
diff --git a/editor/import/resource_importer_texture_atlas.cpp b/editor/import/resource_importer_texture_atlas.cpp
index d5d1a14be3..dec1466da1 100644
--- a/editor/import/resource_importer_texture_atlas.cpp
+++ b/editor/import/resource_importer_texture_atlas.cpp
@@ -87,7 +87,7 @@ Error ResourceImporterTextureAtlas::import(const String &p_source_file, const St
//it's a simple hack
Ref<Image> broken = memnew(Image((const char **)atlas_import_failed_xpm));
Ref<ImageTexture> broken_texture;
- broken_texture.instance();
+ broken_texture.instantiate();
broken_texture->create_from_image(broken);
String target_file = p_save_path + ".tex";
@@ -201,7 +201,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
const Map<StringName, Variant> &options = E->get();
Ref<Image> image;
- image.instance();
+ image.instantiate();
Error err = ImageLoader::load_image(source, image);
ERR_CONTINUE(err != OK);
@@ -240,7 +240,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
pack_data.is_mesh = true;
Ref<BitMap> bit_map;
- bit_map.instance();
+ bit_map.instantiate();
bit_map->create_from_image_alpha(image);
Vector<Vector<Vector2>> polygons = bit_map->clip_opaque_to_polygons(Rect2(0, 0, image->get_width(), image->get_height()));
@@ -272,7 +272,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
//blit the atlas
Ref<Image> new_atlas;
- new_atlas.instance();
+ new_atlas.instantiate();
new_atlas->create(atlas_width, atlas_height, false, Image::FORMAT_RGBA8);
for (int i = 0; i < pack_data_files.size(); i++) {
@@ -303,7 +303,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
cache.reference_ptr(resptr);
} else {
Ref<ImageTexture> res_cache;
- res_cache.instance();
+ res_cache.instantiate();
res_cache->create_from_image(new_atlas);
res_cache->set_path(p_group_file);
cache = res_cache;
@@ -321,7 +321,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
//region
Ref<AtlasTexture> atlas_texture;
- atlas_texture.instance();
+ atlas_texture.instantiate();
atlas_texture->set_atlas(cache);
atlas_texture->set_region(Rect2(offset, pack_data.region.size));
atlas_texture->set_margin(Rect2(pack_data.region.position, Size2(pack_data.image->get_width(), pack_data.image->get_height()) - pack_data.region.size));
@@ -329,7 +329,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
texture = atlas_texture;
} else {
Ref<ArrayMesh> mesh;
- mesh.instance();
+ mesh.instantiate();
for (int i = 0; i < pack_data.chart_pieces.size(); i++) {
const EditorAtlasPacker::Chart &chart = charts[pack_data.chart_pieces[i]];
@@ -375,7 +375,7 @@ Error ResourceImporterTextureAtlas::import_group_file(const String &p_group_file
}
Ref<MeshTexture> mesh_texture;
- mesh_texture.instance();
+ mesh_texture.instantiate();
mesh_texture->set_base_texture(cache);
mesh_texture->set_image_size(pack_data.image->get_size());
mesh_texture->set_mesh(mesh);
diff --git a/editor/import/resource_importer_wav.cpp b/editor/import/resource_importer_wav.cpp
index e615212569..e845a90259 100644
--- a/editor/import/resource_importer_wav.cpp
+++ b/editor/import/resource_importer_wav.cpp
@@ -508,7 +508,7 @@ Error ResourceImporterWAV::import(const String &p_source_file, const String &p_s
}
Ref<AudioStreamSample> sample;
- sample.instance();
+ sample.instantiate();
sample->set_data(dst_data);
sample->set_format(dst_format);
sample->set_mix_rate(rate);
diff --git a/editor/import/scene_import_settings.cpp b/editor/import/scene_import_settings.cpp
index 600f3fe2f0..f9f47ec4f4 100644
--- a/editor/import/scene_import_settings.cpp
+++ b/editor/import/scene_import_settings.cpp
@@ -435,7 +435,7 @@ void SceneImportSettings::open_settings(const String &p_path) {
base_subresource_settings.clear();
Ref<ConfigFile> config;
- config.instance();
+ config.instantiate();
Error err = config->load(p_path + ".import");
if (err == OK) {
List<String> keys;
@@ -1105,12 +1105,12 @@ SceneImportSettings::SceneImportSettings() {
{
Ref<StandardMaterial3D> selection_mat;
- selection_mat.instance();
+ selection_mat.instantiate();
selection_mat->set_shading_mode(StandardMaterial3D::SHADING_MODE_UNSHADED);
selection_mat->set_albedo(Color(1, 0.8, 1.0));
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
st->begin(Mesh::PRIMITIVE_LINES);
AABB base_aabb;
@@ -1126,7 +1126,7 @@ SceneImportSettings::SceneImportSettings() {
st->add_vertex(b.lerp(a, 0.2));
}
- selection_mesh.instance();
+ selection_mesh.instantiate();
st->commit(selection_mesh);
selection_mesh->surface_set_material(0, selection_mat);
@@ -1141,7 +1141,7 @@ SceneImportSettings::SceneImportSettings() {
base_viewport->add_child(mesh_preview);
mesh_preview->hide();
- material_preview.instance();
+ material_preview.instantiate();
}
inspector = memnew(EditorInspector);
@@ -1163,13 +1163,13 @@ SceneImportSettings::SceneImportSettings() {
external_path_tree->set_columns(3);
external_path_tree->set_column_titles_visible(true);
external_path_tree->set_column_expand(0, true);
- external_path_tree->set_column_min_width(0, 100 * EDSCALE);
+ external_path_tree->set_column_custom_minimum_width(0, 100 * EDSCALE);
external_path_tree->set_column_title(0, TTR("Resource"));
external_path_tree->set_column_expand(1, true);
- external_path_tree->set_column_min_width(1, 100 * EDSCALE);
+ external_path_tree->set_column_custom_minimum_width(1, 100 * EDSCALE);
external_path_tree->set_column_title(1, TTR("Path"));
external_path_tree->set_column_expand(2, false);
- external_path_tree->set_column_min_width(2, 200 * EDSCALE);
+ external_path_tree->set_column_custom_minimum_width(2, 200 * EDSCALE);
external_path_tree->set_column_title(2, TTR("Status"));
save_path = memnew(EditorFileDialog);
save_path->set_file_mode(EditorFileDialog::FILE_MODE_OPEN_DIR);
diff --git a/editor/import/scene_importer_mesh.cpp b/editor/import/scene_importer_mesh.cpp
index bf17ea7bca..ce78166d1e 100644
--- a/editor/import/scene_importer_mesh.cpp
+++ b/editor/import/scene_importer_mesh.cpp
@@ -215,6 +215,7 @@ void EditorSceneImporterMesh::generate_lods() {
int index_target = indices.size() * threshold;
float max_mesh_error_percentage = 1e0f;
float mesh_error = 0.0f;
+ float scale = SurfaceTool::simplify_scale_func((const float *)vertices_ptr, vertex_count, sizeof(Vector3));
while (index_target > min_indices) {
Vector<int> new_indices;
new_indices.resize(indices.size());
@@ -223,8 +224,8 @@ void EditorSceneImporterMesh::generate_lods() {
break;
}
Surface::LOD lod;
- lod.distance = mesh_error;
- if (Math::is_equal_approx(mesh_error, 0.0f)) {
+ lod.distance = mesh_error * scale;
+ if (Math::is_zero_approx(mesh_error)) {
break;
}
if (new_len <= 0) {
@@ -251,7 +252,7 @@ Ref<ArrayMesh> EditorSceneImporterMesh::get_mesh(const Ref<Mesh> &p_base) {
mesh = p_base;
}
if (mesh.is_null()) {
- mesh.instance();
+ mesh.instantiate();
}
mesh->set_name(get_name());
if (has_meta("import_id")) {
@@ -320,7 +321,7 @@ void EditorSceneImporterMesh::create_shadow_mesh() {
}
}
- shadow_mesh.instance();
+ shadow_mesh.instantiate();
for (int i = 0; i < surfaces.size(); i++) {
LocalVector<int> vertex_remap;
@@ -528,7 +529,7 @@ Vector<Ref<Shape3D>> EditorSceneImporterMesh::convex_decompose() const {
}
Ref<ConvexPolygonShape3D> shape;
- shape.instance();
+ shape.instantiate();
shape->set_points(convex_points);
ret.push_back(shape);
}
@@ -587,7 +588,7 @@ Ref<NavigationMesh> EditorSceneImporterMesh::create_navigation_mesh() {
}
Ref<NavigationMesh> nm;
- nm.instance();
+ nm.instantiate();
nm->set_vertices(vertices);
Vector<int> v3;
@@ -733,7 +734,7 @@ Error EditorSceneImporterMesh::lightmap_unwrap_cached(const Transform3D &p_base_
for (int i = 0; i < lightmap_surfaces.size(); i++) {
Ref<SurfaceTool> st;
- st.instance();
+ st.instantiate();
st->begin(Mesh::PRIMITIVE_TRIANGLES);
st->set_material(lightmap_surfaces[i].material);
st->set_meta("name", lightmap_surfaces[i].name);