diff options
author | Ankit Meel <ankitjmeel@gmail.com> | 2022-04-04 13:36:10 +0300 |
---|---|---|
committer | Aras Pranckevicius <aras@nesnausk.org> | 2022-04-04 13:36:10 +0300 |
commit | e6a9b223844346a34ce195652449fec3229a2ec1 (patch) | |
tree | 38b9621299a83515670af0189b8cddc51813f838 /source/blender/io/wavefront_obj/importer/obj_import_mesh.hh | |
parent | ee3f71d747e3ffd5091335437d52b3ec518d7b67 (diff) |
OBJ: New C++ based wavefront OBJ importer
This takes state of soc-2020-io-performance branch as it was at
e9bbfd0c8c7 (2021 Oct 31), merges latest master (2022 Apr 4),
adds a bunch of tests, and fixes a bunch of stuff found by said
tests. The fixes are detailed in the differential.
Timings on my machine (Windows, VS2022 release build, AMD Ryzen
5950X 32 threads):
- Rungholt minecraft level (269MB file, 1 mesh): 54.2s -> 14.2s
(memory usage: 7.0GB -> 1.9GB).
- Blender 3.0 splash scene: "I waited for 90 minutes and gave up"
-> 109s. Now, this time is not great, but at least 20% of the
time is spent assigning unique names for the imported objects
(the scene has 24 thousand objects). This is not specific to obj
importer, but rather a general issue across blender overall.
Test suite file updates done in Subversion tests repository.
Reviewed By: @howardt, @sybren
Differential Revision: https://developer.blender.org/D13958
Diffstat (limited to 'source/blender/io/wavefront_obj/importer/obj_import_mesh.hh')
-rw-r--r-- | source/blender/io/wavefront_obj/importer/obj_import_mesh.hh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.hh b/source/blender/io/wavefront_obj/importer/obj_import_mesh.hh new file mode 100644 index 00000000000..86132b94a31 --- /dev/null +++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.hh @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +/** \file + * \ingroup obj + */ + +#pragma once + +#include "BKE_lib_id.h" + +#include "BLI_utility_mixins.hh" + +#include "obj_import_mtl.hh" +#include "obj_import_objects.hh" + +struct Material; + +namespace blender::io::obj { + +/** + * Make a Blender Mesh Object from a Geometry of GEOM_MESH type. + */ +class MeshFromGeometry : NonMovable, NonCopyable { + private: + Geometry &mesh_geometry_; + const GlobalVertices &global_vertices_; + + public: + MeshFromGeometry(Geometry &mesh_geometry, const GlobalVertices &global_vertices) + : mesh_geometry_(mesh_geometry), global_vertices_(global_vertices) + { + } + + Object *create_mesh(Main *bmain, + const Map<std::string, std::unique_ptr<MTLMaterial>> &materials, + Map<std::string, Material *> &created_materials, + const OBJImportParams &import_params); + + private: + void fixup_invalid_faces(); + void create_vertices(Mesh *mesh); + void create_polys_loops(Object *obj, Mesh *mesh); + void create_edges(Mesh *mesh); + void create_uv_verts(Mesh *mesh); + void create_materials(Main *bmain, + const Map<std::string, std::unique_ptr<MTLMaterial>> &materials, + Map<std::string, Material *> &created_materials, + Object *obj); + void create_normals(Mesh *mesh); +}; + +} // namespace blender::io::obj |