[Bf-blender-cvs] [7faaaf7fd76] soc-2020-io-performance: Importer Cleanup: renames, const.
Ankit Meel
noreply at git.blender.org
Fri Dec 4 19:57:27 CET 2020
Commit: 7faaaf7fd766db868a498be3f6a2464ca6e7196e
Author: Ankit Meel
Date: Tue Dec 1 00:58:44 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rB7faaaf7fd766db868a498be3f6a2464ca6e7196e
Importer Cleanup: renames, const.
===================================================================
M source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
M source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
M source/blender/io/wavefront_obj/importer/obj_import_mesh.hh
M source/blender/io/wavefront_obj/importer/obj_import_objects.cc
M source/blender/io/wavefront_obj/importer/obj_import_objects.hh
===================================================================
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
index 57f6a07e858..5cbd06bad67 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc
@@ -113,10 +113,10 @@ void OBJParser::parse_and_store(Vector<std::unique_ptr<Geometry>> &r_all_geometr
string line;
/* Store vertex coordinates that belong to other Geometry instances. */
- VertexIndexOffset offset;
+ VertexIndexOffset offsets;
/* Non owning raw pointer to a Geometry. To be updated while creating a new Geometry. */
Geometry *current_geometry = create_geometry(
- nullptr, GEOM_MESH, "", r_global_vertices, r_all_geometries, offset);
+ nullptr, GEOM_MESH, "", r_global_vertices, r_all_geometries, offsets);
/* State-setting variables: if set, they remain the same for the remaining
* elements in the object. */
@@ -143,7 +143,7 @@ void OBJParser::parse_and_store(Vector<std::unique_ptr<Geometry>> &r_all_geometr
state_object_group = "";
state_material_name = "";
current_geometry = create_geometry(
- current_geometry, GEOM_MESH, rest_line, r_global_vertices, r_all_geometries, offset);
+ current_geometry, GEOM_MESH, rest_line, r_global_vertices, r_all_geometries, offsets);
}
else if (line_key == "v") {
BLI_assert(current_geometry);
@@ -177,14 +177,15 @@ void OBJParser::parse_and_store(Vector<std::unique_ptr<Geometry>> &r_all_geometr
copy_string_to_int(str_edge_split[0], -1, edge_v1);
copy_string_to_int(str_edge_split[1], -1, edge_v2);
/* Always keep stored indices non-negative and zero-based. */
- edge_v1 += edge_v1 < 0 ? r_global_vertices.vertices.size() : -offset.get_index_offset() - 1;
- edge_v2 += edge_v2 < 0 ? r_global_vertices.vertices.size() : -offset.get_index_offset() - 1;
+ edge_v1 += edge_v1 < 0 ? r_global_vertices.vertices.size() : -offsets.get_index_offset() - 1;
+ edge_v2 += edge_v2 < 0 ? r_global_vertices.vertices.size() : -offsets.get_index_offset() - 1;
BLI_assert(edge_v1 >= 0 && edge_v2 >= 0);
current_geometry->edges_.append({static_cast<uint>(edge_v1), static_cast<uint>(edge_v2)});
}
else if (line_key == "g") {
state_object_group = rest_line;
- if (state_object_group.find("off") != string::npos || state_object_group.find("null") != string::npos ||
+ if (state_object_group.find("off") != string::npos ||
+ state_object_group.find("null") != string::npos ||
state_object_group.find("default") != string::npos) {
/* Set group for future elements like faces or curves to empty. */
state_object_group = "";
@@ -205,7 +206,7 @@ void OBJParser::parse_and_store(Vector<std::unique_ptr<Geometry>> &r_all_geometr
}
else if (line_key == "f") {
BLI_assert(current_geometry);
- FaceElement curr_face;
+ PolyElem curr_face;
curr_face.shaded_smooth = state_shaded_smooth;
if (!state_material_name.empty()) {
curr_face.material_name = state_material_name;
@@ -219,14 +220,14 @@ void OBJParser::parse_and_store(Vector<std::unique_ptr<Geometry>> &r_all_geometr
Vector<StringRef> str_corners_split;
split_by_char(rest_line, ' ', str_corners_split);
for (StringRef str_corner : str_corners_split) {
- FaceCorner corner;
- size_t n_slash = std::count(str_corner.begin(), str_corner.end(), '/');
+ PolyCorner corner;
+ const size_t n_slash = std::count(str_corner.begin(), str_corner.end(), '/');
if (n_slash == 0) {
- /* Case: f v1 v2 v3 . */
+ /* Case: "f v1 v2 v3". */
copy_string_to_int(str_corner, INT32_MAX, corner.vert_index);
}
else if (n_slash == 1) {
- /* Case: f v1/vt1 v2/vt2 v3/vt3 . */
+ /* Case: "f v1/vt1 v2/vt2 v3/vt3". */
Vector<StringRef> vert_uv_split;
split_by_char(str_corner, '/', vert_uv_split);
copy_string_to_int(vert_uv_split[0], INT32_MAX, corner.vert_index);
@@ -235,8 +236,8 @@ void OBJParser::parse_and_store(Vector<std::unique_ptr<Geometry>> &r_all_geometr
}
}
else if (n_slash == 2) {
- /* Case: f v1//vn1 v2//vn2 v3//vn3 . */
- /* Case: f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 . */
+ /* Case: "f v1//vn1 v2//vn2 v3//vn3". */
+ /* Case: "f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3". */
Vector<StringRef> vert_uv_normal_split;
split_by_char(str_corner, '/', vert_uv_normal_split);
copy_string_to_int(vert_uv_normal_split[0], INT32_MAX, corner.vert_index);
@@ -247,7 +248,7 @@ void OBJParser::parse_and_store(Vector<std::unique_ptr<Geometry>> &r_all_geometr
}
/* Always keep stored indices non-negative and zero-based. */
corner.vert_index += corner.vert_index < 0 ? r_global_vertices.vertices.size() :
- -offset.get_index_offset() - 1;
+ -offsets.get_index_offset() - 1;
corner.uv_vert_index += corner.uv_vert_index < 0 ? r_global_vertices.uv_vertices.size() :
-1;
corner.vertex_normal_index += corner.vertex_normal_index < 0 ?
@@ -266,7 +267,7 @@ void OBJParser::parse_and_store(Vector<std::unique_ptr<Geometry>> &r_all_geometr
state_object_group,
r_global_vertices,
r_all_geometries,
- offset);
+ offsets);
current_geometry->nurbs_element_.group_ = state_object_group;
}
else {
diff --git a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
index cb0d54b6217..9b564d977e9 100644
--- a/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
+++ b/source/blender/io/wavefront_obj/importer/obj_import_mesh.cc
@@ -68,7 +68,7 @@ void MeshFromGeometry::create_mesh(Main *bmain,
if (ob_name.empty()) {
ob_name = "Untitled";
}
- Vector<FaceElement> new_faces;
+ Vector<PolyElem> new_faces;
Set<std::pair<int, int>> fgon_edges;
const auto [removed_faces, removed_loops]{tessellate_polygons(new_faces, fgon_edges)};
@@ -115,11 +115,11 @@ void MeshFromGeometry::create_mesh(Main *bmain,
* Tessellate potentially invalid polygons and fill the
*/
std::pair<int64_t, int64_t> MeshFromGeometry::tessellate_polygons(
- Vector<FaceElement> &r_new_faces, Set<std::pair<int, int>> &fgon_edges)
+ Vector<PolyElem> &r_new_faces, Set<std::pair<int, int>> &fgon_edges)
{
int64_t removed_faces = 0;
int64_t removed_loops = 0;
- for (const FaceElement &curr_face : mesh_geometry_.face_elements()) {
+ for (const PolyElem &curr_face : mesh_geometry_.face_elements()) {
if (curr_face.shaded_smooth || true) { // should be valid/invalid
return {removed_faces, removed_loops};
}
@@ -129,7 +129,7 @@ std::pair<int64_t, int64_t> MeshFromGeometry::tessellate_polygons(
face_vert_indices.reserve(curr_face.face_corners.size());
face_uv_indices.reserve(curr_face.face_corners.size());
face_normal_indices.reserve(curr_face.face_corners.size());
- for (const FaceCorner &corner : curr_face.face_corners) {
+ for (const PolyCorner &corner : curr_face.face_corners) {
face_vert_indices.append(corner.vert_index);
face_normal_indices.append(corner.vertex_normal_index);
face_uv_indices.append(corner.uv_vert_index);
@@ -238,7 +238,7 @@ void MeshFromGeometry::create_vertices()
* It must receive all polygons to be added to the mesh. Remove holes from polygons before
* calling this.
*/
-void MeshFromGeometry::create_polys_loops(Span<FaceElement> all_faces)
+void MeshFromGeometry::create_polys_loops(Span<PolyElem> all_faces)
{
/* Will not be used if vertex groups are not imported. */
blender_mesh_->dvert = nullptr;
@@ -259,7 +259,7 @@ void MeshFromGeometry::create_polys_loops(Span<FaceElement> all_faces)
int tot_loop_idx = 0;
for (int poly_idx = 0; poly_idx < tot_face_elems; ++poly_idx) {
- const FaceElement &curr_face = all_faces[poly_idx];
+ const PolyElem &curr_face = all_faces[poly_idx];
if (curr_face.face_corners.size() < 3) {
/* Don't add single vertex face, or edges. */
std::cerr << "Face with less than 3 vertices found, skipping." << std::endl;
@@ -274,7 +274,7 @@ void MeshFromGeometry::create_polys_loops(Span<FaceElement> all_faces)
}
mpoly.mat_nr = mesh_geometry_.material_names().index_of_try(curr_face.material_name);
- for (const FaceCorner &curr_corner : curr_face.face_corners) {
+ for (const PolyCorner &curr_corner : curr_face.face_corners) {
MLoop &mloop = blender_mesh_->mloop[tot_loop_idx];
tot_loop_idx++;
mloop.v = curr_corner.vert_index;
@@ -351,8 +351,8 @@ void MeshFromGeometry::create_uv_verts()
&blender_mesh_->ldata, CD_MLOOPUV, CD_DEFAULT, nullptr, mesh_geometry_.total_loops()));
int tot_loop_idx = 0;
- for (const FaceElement &curr_face : mesh_geometry_.face_elements()) {
- for (const FaceCorner &curr_corner : curr_face.face_corners) {
+ for (const PolyElem &curr_face : mesh_geometry_.face_elements()) {
+ for (const PolyCorner &curr_corner : curr_face.face_corners) {
if (curr_corner.uv_vert_index >= 0 &&
curr_corner.uv_vert_index < global_vertices_.uv_vertices.size()) {
const float2 &mluv_src = global_vertices_.uv_vertices[curr_corner.uv_vert_index];
@@ -393,7 +393,7 @@ void MeshFromGeometry::create_materials(
*/
void MeshFromGeometry::add_custom_normals()
{
- const int64_t tot_loop_normals{mesh_geometry_.tot_normals()};
+ const int64_t tot_loop_normals{mesh_geometry_.total_normals()};
float(*loop_normals)[3] = static_cast<float(*)[3]>(
MEM_malloc_arrayN(tot_loop_normals, sizeof(float[3]), __func__));
diff --git a/source/blender/io/w
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list