[Bf-blender-cvs] [d13a05a6cff] soc-2020-io-performance: Use blender::Vector and Array instead of std
Ankit Meel
noreply at git.blender.org
Mon Jun 22 21:03:37 CEST 2020
Commit: d13a05a6cff45d63a8209be551907c395ab96750
Author: Ankit Meel
Date: Tue Jun 23 00:18:50 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rBd13a05a6cff45d63a8209be551907c395ab96750
Use blender::Vector and Array instead of std
The equivalent functions have also been replaced:
`back()` -> `last()`
`push_back()` -> `append()`
===================================================================
M source/blender/io/wavefront_obj/intern/wavefront_obj.hh
M source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
M source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc
M source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.hh
===================================================================
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj.hh b/source/blender/io/wavefront_obj/intern/wavefront_obj.hh
index eb1aa6d58dd..d494ffb7108 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj.hh
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj.hh
@@ -82,12 +82,12 @@ class OBJMesh {
/**
* Calculate vertex indices of all vertices of a polygon.
*/
- void calc_poly_vertex_indices(std::vector<uint> &poly_vertex_indices, uint poly_index);
+ void calc_poly_vertex_indices(blender::Vector<uint> &poly_vertex_indices, uint poly_index);
/**
* Store UV vertex coordinates as well as their indices.
*/
- void store_uv_coords_and_indices(std::vector<std::array<float, 2>> &uv_coords,
- std::vector<std::vector<uint>> &uv_indices);
+ void store_uv_coords_and_indices(blender::Vector<std::array<float, 2>> &uv_coords,
+ blender::Vector<blender::Vector<uint>> &uv_indices);
/**
* Calculate face normal of the polygon at given index.
*/
@@ -95,11 +95,11 @@ class OBJMesh {
/**
* Calculate face normal indices of all polygons.
*/
- void calc_poly_normal_indices(std::vector<uint> &normal_indices, uint poly_indices);
+ void calc_poly_normal_indices(blender::Vector<uint> &normal_indices, uint poly_indices);
/**
* Only for curve-like meshes: calculate vertex indices of one edge.
*/
- void calc_edge_vert_indices(std::array<uint, 2> &vert_indices, uint edge_index);
+ void calc_edge_vert_indices(blender::Array<uint, 2> &vert_indices, uint edge_index);
};
class OBJNurbs {
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
index bbb8e8273b6..d96e1098393 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
@@ -24,7 +24,6 @@
#include "MEM_guardedalloc.h"
#include <stdio.h>
-#include <vector>
#include "BKE_curve.h"
#include "BKE_lib_id.h"
@@ -90,7 +89,7 @@ void OBJMesh::calc_vertex_coords(float coords[3], uint vert_index)
/**
* Calculate vertex indices of all vertices of a polygon.
*/
-void OBJMesh::calc_poly_vertex_indices(std::vector<uint> &poly_vertex_indices, uint poly_index)
+void OBJMesh::calc_poly_vertex_indices(blender::Vector<uint> &poly_vertex_indices, uint poly_index)
{
const MPoly &mpoly = me_eval->mpoly[poly_index];
const MLoop *mloop = &me_eval->mloop[mpoly.loopstart];
@@ -103,8 +102,8 @@ void OBJMesh::calc_poly_vertex_indices(std::vector<uint> &poly_vertex_indices, u
/**
* Store UV vertex coordinates as well as their indices.
*/
-void OBJMesh::store_uv_coords_and_indices(std::vector<std::array<float, 2>> &uv_coords,
- std::vector<std::vector<uint>> &uv_indices)
+void OBJMesh::store_uv_coords_and_indices(blender::Vector<std::array<float, 2>> &uv_coords,
+ blender::Vector<blender::Vector<uint>> &uv_indices)
{
Mesh *me_eval = this->me_eval;
OBJMesh *ob_mesh = this;
@@ -133,15 +132,13 @@ void OBJMesh::store_uv_coords_and_indices(std::vector<std::array<float, 2>> &uv_
ob_mesh->tot_uv_vertices++;
}
const uint vertices_in_poly = me_eval->mpoly[uv_vert->poly_index].totloop;
- /* Resize UV vertices index list. */
uv_indices[uv_vert->poly_index].resize(vertices_in_poly);
- /* Fill up UV vertex index for the polygon's one vertex. */
+ /* Fill up UV vertex index. The indices in OBJ are 1-based, so added 1. */
uv_indices[uv_vert->poly_index][uv_vert->loop_of_poly_index] = ob_mesh->tot_uv_vertices +
1;
- /* Fill up UV vertices' coordinates. We don't know how many unique vertices are there, so
- * need to push back everytime. */
- uv_coords.push_back(std::array<float, 2>());
+ /* Fill up UV vertices' coordinates. */
+ uv_coords.append(std::array<float, 2>());
uv_coords[ob_mesh->tot_uv_vertices][0] =
mloopuv[mpoly[uv_vert->poly_index].loopstart + uv_vert->loop_of_poly_index].uv[0];
uv_coords[ob_mesh->tot_uv_vertices][1] =
@@ -183,7 +180,7 @@ void OBJMesh::calc_poly_normal(float poly_normal[3], uint poly_index)
/**
* Calculate face normal indices of all polygons.
*/
-void OBJMesh::calc_poly_normal_indices(std::vector<uint> &normal_indices, uint poly_index)
+void OBJMesh::calc_poly_normal_indices(blender::Vector<uint> &normal_indices, uint poly_index)
{
normal_indices.resize(me_eval->mpoly[poly_index].totloop);
for (uint i = 0; i < normal_indices.size(); i++) {
@@ -194,7 +191,7 @@ void OBJMesh::calc_poly_normal_indices(std::vector<uint> &normal_indices, uint p
/**
* Only for curve-like meshes: calculate vertex indices of one edge.
*/
-void OBJMesh::calc_edge_vert_indices(std::array<uint, 2> &vert_indices, uint edge_index)
+void OBJMesh::calc_edge_vert_indices(blender::Array<uint, 2> &vert_indices, uint edge_index)
{
vert_indices[0] = edge_index + 1;
vert_indices[1] = edge_index + 2;
@@ -270,9 +267,9 @@ void OBJMesh::get_mesh_eval()
*/
static void export_frame(bContext *C, const OBJExportParams *export_params, const char *filepath)
{
- std::vector<OBJMesh> export_mesh;
+ blender::Vector<OBJMesh> export_mesh;
/** TODO ankitm Unused now; to be done. */
- std::vector<OBJNurbs> export_nurbs;
+ blender::Vector<OBJNurbs> export_nurbs;
ViewLayer *view_layer = CTX_data_view_layer(C);
Base *base = static_cast<Base *>(view_layer->object_bases.first);
@@ -280,17 +277,17 @@ static void export_frame(bContext *C, const OBJExportParams *export_params, cons
Object *object_in_layer = base->object;
switch (object_in_layer->type) {
case OB_MESH:
- export_mesh.push_back(OBJMesh());
- export_mesh.back().object = object_in_layer;
- export_mesh.back().export_params = export_params;
- export_mesh.back().C = C;
+ export_mesh.append(OBJMesh());
+ export_mesh.last().object = object_in_layer;
+ export_mesh.last().export_params = export_params;
+ export_mesh.last().C = C;
break;
case OB_CURVE:
/* TODO (ankitm) Conditionally push to export_nurbs too. */
- export_mesh.push_back(OBJMesh());
- export_mesh.back().object = object_in_layer;
- export_mesh.back().export_params = export_params;
- export_mesh.back().C = C;
+ export_mesh.append(OBJMesh());
+ export_mesh.last().object = object_in_layer;
+ export_mesh.last().export_params = export_params;
+ export_mesh.last().C = C;
default:
break;
}
@@ -318,7 +315,7 @@ static void export_frame(bContext *C, const OBJExportParams *export_params, cons
frame_writer.write_curve_edges(mesh_to_export);
}
else {
- std::vector<std::vector<uint>> uv_indices;
+ blender::Vector<blender::Vector<uint>> uv_indices;
if (mesh_to_export.export_params->export_uv) {
frame_writer.write_uv_coords(mesh_to_export, uv_indices);
}
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc b/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc
index 57295d7c63f..a1dbc89a718 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc
@@ -34,9 +34,9 @@ namespace io {
namespace obj {
/** Write one line of polygon indices as f v1/vt1/vn1 v2/vt2/vn2 .... */
-void OBJWriter::write_vert_uv_normal_indices(std::vector<uint> &vert_indices,
- std::vector<uint> &uv_indices,
- std::vector<uint> &normal_indices,
+void OBJWriter::write_vert_uv_normal_indices(blender::Vector<uint> &vert_indices,
+ blender::Vector<uint> &uv_indices,
+ blender::Vector<uint> &normal_indices,
const MPoly &poly_to_write)
{
fprintf(outfile, "f ");
@@ -51,8 +51,8 @@ void OBJWriter::write_vert_uv_normal_indices(std::vector<uint> &vert_indices,
}
/** Write one line of polygon indices as f v1//vn1 v2//vn2 .... */
-void OBJWriter::write_vert_normal_indices(std::vector<uint> &vert_indices,
- std::vector<uint> &normal_indices,
+void OBJWriter::write_vert_normal_indices(blender::Vector<uint> &vert_indices,
+ blender::Vector<uint> &normal_indices,
const MPoly &poly_to_write)
{
fprintf(outfile, "f ");
@@ -66,8 +66,8 @@ void OBJWriter::write_vert_normal_indices(std::vector<uint> &vert_indices,
}
/** Write one line of polygon indices as f v1/vt1 v2/vt2 .... */
-void OBJWriter::write_vert_uv_indices(std::vector<uint> &vert_indices,
- std::vector<uint> &uv_indices,
+void OBJWriter::write_vert_uv_indices(blender::Vector<uint> &vert_indices,
+ blender::Vector<uint> &uv_indices,
const MPoly &poly_to_write)
{
fprintf(outfile, "f ");
@@ -81,7 +81,7 @@ void OBJWriter::write_vert_uv_indices(std::vector<uint> &vert_indices,
}
/** Write one line of polygon indices as f v1 v2 .... */
-void OBJWriter::write_vert_indices(std::vector<uint> &vert_indices, const MPoly &poly_to_write)
+void OBJWriter::write_vert_indices(blender::Vector<uint> &vert_indices, const MPoly &poly_to_write)
{
fprintf(outfile, "f ");
for (int j = 0; j < poly_to_write.totloop; j++) {
@@ -132,9 +132,9 @@ void OBJWriter::write_vertex_coords(OBJMesh &ob_mesh)
/** Write UV vertex coordinates for all vertices as vt u v
* \note UV indices are stored here, but written later.
*/
-void OBJWriter::write_uv_coords(OBJMesh &ob_mesh, std::vector<std::vector<uint>> &uv_indices)
+void OBJWriter::write_uv_coords(OBJMesh &ob_mesh, blender::Vector<blender
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list