Commit: 40027f31b3508848d9c9c9a1d048344901d95906 Author: Ankit Meel Date: Sat Jul 10 19:08:45 2021 +0530 Branches: soc-2020-io-performance https://developer.blender.org/rB40027f31b3508848d9c9c9a1d048344901d95906
Consistent var naming, function usage. =================================================================== M source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc M source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc M source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh =================================================================== diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc index 2895c3fb647..b1cacfb2026 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc @@ -356,11 +356,9 @@ void OBJWriter::write_poly_elements(const OBJMesh &obj_mesh_data, /* Number of normals may not be equal to number of polygons due to smooth shading. */ int per_object_tot_normals = 0; const int tot_polygons = obj_mesh_data.tot_polygons(); - /* If we aren't exporting UVs, need an array for the ignored argument to poly_element_writer. */ - Array<int> dummy_uvs(0); - Span<int> uvs = dummy_uvs.as_span(); for (int i = 0; i < tot_polygons; i++) { Vector<int> poly_vertex_indices = obj_mesh_data.calc_poly_vertex_indices(i); + Span<int> poly_uv_indices = obj_mesh_data.calc_poly_uv_indices(i); /* For an Object, a normal index depends on how many of its normals have been written before * it. This is unknown because of smooth shading. So pass "per object total normals" * and update it after each call. */ @@ -373,10 +371,7 @@ void OBJWriter::write_poly_elements(const OBJMesh &obj_mesh_data, last_poly_smooth_group = write_smooth_group(obj_mesh_data, i, last_poly_smooth_group); last_poly_vertex_group = write_vertex_group(obj_mesh_data, i, last_poly_vertex_group); last_poly_mat_nr = write_poly_material(obj_mesh_data, i, last_poly_mat_nr, matname_fn); - if (export_params_.export_uv) { - uvs = obj_mesh_data.uv_indices(i); - } - (this->*poly_element_writer)(poly_vertex_indices, uvs, poly_normal_indices); + (this->*poly_element_writer)(poly_vertex_indices, poly_uv_indices, poly_normal_indices); } /* Unusual: Other indices are updated in #OBJWriter::update_index_offsets. */ index_offsets_.normal_offset += per_object_tot_normals; diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc index d4b017bcece..7b7c5a7c4f1 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc @@ -154,16 +154,6 @@ int OBJMesh::tot_uv_vertices() const return tot_uv_vertices_; } -/** - * \return UV vertex indices of one polygon. - */ -Span<int> OBJMesh::uv_indices(const int poly_index) const -{ - BLI_assert(poly_index < export_mesh_eval_->totpoly); - BLI_assert(poly_index < uv_indices_.size()); - return uv_indices_[poly_index]; -} - int OBJMesh::tot_edges() const { return export_mesh_eval_->totedge; @@ -354,6 +344,15 @@ void OBJMesh::store_uv_coords_and_indices(Vector<std::array<float, 2>> &r_uv_coo BKE_mesh_uv_vert_map_free(uv_vert_map); } +Span<int> OBJMesh::calc_poly_uv_indices(const int poly_index) const +{ + if (uv_indices_.size() <= 0) { + return {}; + } + BLI_assert(poly_index < export_mesh_eval_->totpoly); + BLI_assert(poly_index < uv_indices_.size()); + return uv_indices_[poly_index]; +} /** * Calculate polygon normal of a polygon at given index. * diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh index f73a114659d..6e6cf6383a9 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh @@ -96,7 +96,6 @@ class OBJMesh : NonCopyable { int tot_vertices() const; int tot_polygons() const; int tot_uv_vertices() const; - Span<int> uv_indices(const int poly_index) const; int tot_edges() const; int16_t tot_materials() const; @@ -117,6 +116,7 @@ class OBJMesh : NonCopyable { float3 calc_vertex_coords(const int vert_index, const float scaling_factor) const; Vector<int> calc_poly_vertex_indices(const int poly_index) const; void store_uv_coords_and_indices(Vector<std::array<float, 2>> &r_uv_coords); + Span<int> calc_poly_uv_indices(const int poly_index) const; float3 calc_poly_normal(const int poly_index) const; std::pair<int, Vector<int>> calc_poly_normal_indices(const int poly_index, const int object_tot_prev_normals) const; _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org List details, subscription details or unsubscribe: https://lists.blender.org/mailman/listinfo/bf-blender-cvs