summaryrefslogtreecommitdiff
path: root/editor/import
diff options
context:
space:
mode:
authorreduz <reduzio@gmail.com>2020-12-01 22:40:47 -0300
committerreduz <reduzio@gmail.com>2020-12-02 13:07:59 -0300
commit70f5972905a5ea6916e9aab909f9a34b963f67b1 (patch)
treef9bca7f6950e8a69fd61c0ea8b341a4976accb80 /editor/import
parent3beab2646fa8744a84382d9fcfb73848404fe5b5 (diff)
Refactored Mesh internals and formats.
-Changed how mesh data is organized, hoping to make it more efficient on Vulkan and GLES. -Removed compression, it now always uses the most efficient format. -Added support for custom arrays (up to 8 custom formats) -Added support for 8 weights in skeleton data. -Added a simple optional versioning system for imported assets, to reimport if binary is newer -Fixes #43979 (I needed to test) WARNING: -NOT backwards compatible with previous 4.x-devel, will most likely never be, but it will force reimport scenes due to version change. -NOT backwards compatible with 3.x scenes, this will be eventually re-added. -Skeletons not working any longer, will fix in next PR.
Diffstat (limited to 'editor/import')
-rw-r--r--editor/import/editor_import_collada.cpp16
-rw-r--r--editor/import/editor_scene_importer_gltf.cpp3
-rw-r--r--editor/import/resource_importer_obj.cpp10
-rw-r--r--editor/import/resource_importer_obj.h1
-rw-r--r--editor/import/resource_importer_scene.cpp4
-rw-r--r--editor/import/resource_importer_scene.h1
6 files changed, 22 insertions, 13 deletions
diff --git a/editor/import/editor_import_collada.cpp b/editor/import/editor_import_collada.cpp
index 12cbaaa885..41099dc8ea 100644
--- a/editor/import/editor_import_collada.cpp
+++ b/editor/import/editor_import_collada.cpp
@@ -844,19 +844,19 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
for (int k = 0; k < vertex_array.size(); k++) {
if (normal_src) {
- surftool->add_normal(vertex_array[k].normal);
+ surftool->set_normal(vertex_array[k].normal);
if (binormal_src && tangent_src) {
- surftool->add_tangent(vertex_array[k].tangent);
+ surftool->set_tangent(vertex_array[k].tangent);
}
}
if (uv_src) {
- surftool->add_uv(Vector2(vertex_array[k].uv.x, vertex_array[k].uv.y));
+ surftool->set_uv(Vector2(vertex_array[k].uv.x, vertex_array[k].uv.y));
}
if (uv2_src) {
- surftool->add_uv2(Vector2(vertex_array[k].uv2.x, vertex_array[k].uv2.y));
+ surftool->set_uv2(Vector2(vertex_array[k].uv2.x, vertex_array[k].uv2.y));
}
if (color_src) {
- surftool->add_color(vertex_array[k].color);
+ surftool->set_color(vertex_array[k].color);
}
if (has_weights) {
@@ -876,8 +876,8 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
}
}
- surftool->add_bones(bones);
- surftool->add_weights(weights);
+ surftool->set_bones(bones);
+ surftool->set_weights(weights);
}
surftool->add_vertex(vertex_array[k].vertex);
@@ -923,7 +923,7 @@ Error ColladaImport::_create_mesh_surfaces(bool p_optimize, Ref<ArrayMesh> &p_me
mr.push_back(a);
}
- p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, d, mr, Dictionary(), p_use_compression ? Mesh::ARRAY_COMPRESS_DEFAULT : 0);
+ p_mesh->add_surface_from_arrays(Mesh::PRIMITIVE_TRIANGLES, d, mr, Dictionary(), 0);
if (material.is_valid()) {
if (p_use_mesh_material) {
diff --git a/editor/import/editor_scene_importer_gltf.cpp b/editor/import/editor_scene_importer_gltf.cpp
index 0c860a8965..c1877895ce 100644
--- a/editor/import/editor_scene_importer_gltf.cpp
+++ b/editor/import/editor_scene_importer_gltf.cpp
@@ -970,8 +970,7 @@ Error EditorSceneImporterGLTF::_parse_meshes(GLTFState &state) {
return OK;
}
- bool compress_vert_data = state.import_flags & IMPORT_USE_COMPRESSION;
- uint32_t mesh_flags = compress_vert_data ? Mesh::ARRAY_COMPRESS_DEFAULT : 0;
+ uint32_t mesh_flags = 0;
Array meshes = state.json["meshes"];
for (GLTFMeshIndex i = 0; i < meshes.size(); i++) {
diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp
index 49b47bf4be..d4560a2984 100644
--- a/editor/import/resource_importer_obj.cpp
+++ b/editor/import/resource_importer_obj.cpp
@@ -210,7 +210,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
bool generate_tangents = p_generate_tangents;
Vector3 scale_mesh = p_scale_mesh;
Vector3 offset_mesh = p_offset_mesh;
- int mesh_flags = p_optimize ? Mesh::ARRAY_COMPRESS_DEFAULT : 0;
+ int mesh_flags = 0;
Vector<Vector3> vertices;
Vector<Vector3> normals;
@@ -294,7 +294,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
norm += normals.size() + 1;
}
ERR_FAIL_INDEX_V(norm, normals.size(), ERR_FILE_CORRUPT);
- surf_tool->add_normal(normals[norm]);
+ surf_tool->set_normal(normals[norm]);
}
if (face[idx].size() >= 2 && face[idx][1] != String()) {
@@ -303,7 +303,7 @@ static Error _parse_obj(const String &p_path, List<Ref<Mesh>> &r_meshes, bool p_
uv += uvs.size() + 1;
}
ERR_FAIL_INDEX_V(uv, uvs.size(), ERR_FILE_CORRUPT);
- surf_tool->add_uv(uvs[uv]);
+ surf_tool->set_uv(uvs[uv]);
}
int vtx = face[idx][0].to_int() - 1;
@@ -473,6 +473,10 @@ String ResourceImporterOBJ::get_resource_type() const {
return "Mesh";
}
+int ResourceImporterOBJ::get_format_version() const {
+ return 1;
+}
+
int ResourceImporterOBJ::get_preset_count() const {
return 0;
}
diff --git a/editor/import/resource_importer_obj.h b/editor/import/resource_importer_obj.h
index 4083bc7403..97f747b33c 100644
--- a/editor/import/resource_importer_obj.h
+++ b/editor/import/resource_importer_obj.h
@@ -54,6 +54,7 @@ public:
virtual void get_recognized_extensions(List<String> *p_extensions) const override;
virtual String get_save_extension() const override;
virtual String get_resource_type() const override;
+ virtual int get_format_version() const override;
virtual int get_preset_count() const override;
virtual String get_preset_name(int p_idx) const override;
diff --git a/editor/import/resource_importer_scene.cpp b/editor/import/resource_importer_scene.cpp
index 5dcdf6bec4..fc4f673ec4 100644
--- a/editor/import/resource_importer_scene.cpp
+++ b/editor/import/resource_importer_scene.cpp
@@ -172,6 +172,10 @@ String ResourceImporterScene::get_resource_type() const {
return "PackedScene";
}
+int ResourceImporterScene::get_format_version() const {
+ return 1;
+}
+
bool ResourceImporterScene::get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const {
if (p_option.begins_with("animation/")) {
if (p_option != "animation/import" && !bool(p_options["animation/import"])) {
diff --git a/editor/import/resource_importer_scene.h b/editor/import/resource_importer_scene.h
index 465d11116b..cd61ec01f2 100644
--- a/editor/import/resource_importer_scene.h
+++ b/editor/import/resource_importer_scene.h
@@ -133,6 +133,7 @@ public:
virtual void get_recognized_extensions(List<String> *p_extensions) const override;
virtual String get_save_extension() const override;
virtual String get_resource_type() const override;
+ virtual int get_format_version() const override;
virtual int get_preset_count() const override;
virtual String get_preset_name(int p_idx) const override;