Commit: d514de67e6b1bd3418b6828886d7c189b1297e41
Author: Ankit Meel
Date:   Fri Aug 21 22:15:33 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rBd514de67e6b1bd3418b6828886d7c189b1297e41

Cleanup: Comments, clang-format.

===================================================================

M       source/blender/io/wavefront_obj/intern/mesh_utils.cc
M       source/blender/io/wavefront_obj/intern/mesh_utils.hh
M       source/blender/io/wavefront_obj/intern/wavefront_obj_ex_mtl.cc
M       source/blender/io/wavefront_obj/intern/wavefront_obj_im_file_reader.cc
M       source/blender/io/wavefront_obj/intern/wavefront_obj_im_mesh.cc
M       source/blender/io/wavefront_obj/intern/wavefront_obj_im_mtl.hh

===================================================================

diff --git a/source/blender/io/wavefront_obj/intern/mesh_utils.cc 
b/source/blender/io/wavefront_obj/intern/mesh_utils.cc
index 52bbd56927a..21c65583344 100644
--- a/source/blender/io/wavefront_obj/intern/mesh_utils.cc
+++ b/source/blender/io/wavefront_obj/intern/mesh_utils.cc
@@ -125,6 +125,12 @@ static void tessellate_polygon(Vector<Vector<const float3 
*>> &polyLineSeq,
   }
 }
 
+/**
+ * Tessellate an ngon with holes to triangles.
+ *
+ * \param face_vertex_indices A polygon's indices that index into the given 
vertex coordinate list.
+ * \return List of polygons with each element containing indices of one 
polygon.
+ */
 Vector<Vector<int>> ngon_tessellate(Span<float3> vertex_coords, Span<int> 
face_vertex_indices)
 {
   if (face_vertex_indices.is_empty()) {
diff --git a/source/blender/io/wavefront_obj/intern/mesh_utils.hh 
b/source/blender/io/wavefront_obj/intern/mesh_utils.hh
index ca5f30541ec..6a7098f86e0 100644
--- a/source/blender/io/wavefront_obj/intern/mesh_utils.hh
+++ b/source/blender/io/wavefront_obj/intern/mesh_utils.hh
@@ -23,9 +23,9 @@
 
 #pragma once
 
-#include "BLI_vector.hh"
-#include "BLI_span.hh"
 #include "BLI_float3.hh"
+#include "BLI_span.hh"
+#include "BLI_vector.hh"
 
 namespace blender::io::obj {
 
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_ex_mtl.cc 
b/source/blender/io/wavefront_obj/intern/wavefront_obj_ex_mtl.cc
index f8f8c4577da..54711da8867 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_ex_mtl.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_ex_mtl.cc
@@ -184,7 +184,7 @@ void MaterialWrap::init_bsdf_node(StringRefNull object_name)
 }
 
 /**
- * Store properties found either in p-BSDF node or `Material` of the object. 
+ * Store properties found either in p-BSDF node or `Material` of the object.
  */
 void MaterialWrap::store_bsdf_properties(MTLMaterial &r_mtl_mat) const
 {
diff --git 
a/source/blender/io/wavefront_obj/intern/wavefront_obj_im_file_reader.cc 
b/source/blender/io/wavefront_obj/intern/wavefront_obj_im_file_reader.cc
index dc584189f94..4a6e9fab072 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_im_file_reader.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_im_file_reader.cc
@@ -38,7 +38,7 @@ using std::string_view;
 
 /**
  * Split a line string into the first word (key) and the rest of the line.
- * Also remove leading & trailing space as well as `\r` carriage return
+ * Also remove leading & trailing spaces as well as `\r` carriage return
  * character if present.
  */
 static void split_line_key_rest(string_view line,
@@ -68,6 +68,8 @@ static void split_line_key_rest(string_view line,
     r_rest_line = r_rest_line.substr(leading_space, string_view::npos);
   }
 
+  /* Another way is to do a test run before the actual parsing to find the 
new-line
+   * character and use it in the main getline. */
   const string_view::size_type 
carriage_return{r_rest_line.find_first_of('\r')};
   if (carriage_return != string_view::npos) {
     r_rest_line = r_rest_line.substr(0, carriage_return);
@@ -84,7 +86,7 @@ static void split_line_key_rest(string_view line,
  * Split the given string by the delimiter and fill the given vector.
  * If an intermediate string is empty, or space or null character, it is not 
appended to the
  * vector.
- * Ensure that the given string has no leading spaces.
+ * Caller should ensure that the given string has no leading spaces.
  */
 static void split_by_char(string_view in_string, char delimiter, 
Vector<string_view> &r_out_list)
 {
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mesh.cc 
b/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mesh.cc
index 3ce965ac493..b5a08241a79 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mesh.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mesh.cc
@@ -34,8 +34,8 @@
 #include "BLI_vector_set.hh"
 
 #include "bmesh.h"
-#include "bmesh_tools.h"
 #include "bmesh_operator_api.h"
+#include "bmesh_tools.h"
 
 #include "DNA_customdata_types.h"
 #include "DNA_mesh_types.h"
@@ -65,6 +65,7 @@ MeshFromGeometry::MeshFromGeometry(Main *bmain,
   const auto [removed_faces, removed_loops]{tessellate_polygons(new_faces, 
fgon_edges)};
 
   const int64_t tot_verts_object{mesh_geometry_.tot_verts()};
+  /* Total explicitly imported edges, not the ones belonging the polygons to 
be created. */
   const int64_t tot_edges{mesh_geometry_.tot_edges()};
   const int64_t tot_face_elems{mesh_geometry_.tot_face_elems() - removed_faces 
+ new_faces.size()};
   const int64_t tot_loops{mesh_geometry_.tot_loops() - removed_loops + 3 * 
new_faces.size()};
@@ -87,9 +88,12 @@ MeshFromGeometry::MeshFromGeometry(Main *bmain,
 #endif
   BKE_mesh_validate(blender_mesh_.get(), verbose_validate, false);
 #if 0
+  /* TODO ankitm Check if it should be executed or not. */
   add_custom_normals();
 #endif
+  /* Un-tessellate unnecesarily triangulated n-gons. */
   dissolve_edges(fgon_edges);
+
   BKE_mesh_nomain_to_mesh(blender_mesh_.release(),
                           static_cast<Mesh *>(blender_object_->data),
                           blender_object_.get(),
@@ -97,6 +101,9 @@ MeshFromGeometry::MeshFromGeometry(Main *bmain,
                           true);
 }
 
+/**
+ * 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)
 {
@@ -205,9 +212,16 @@ void MeshFromGeometry::create_vertices()
   }
 }
 
+/**
+ * Create polygons for the Mesh, set smooth shading flag, deform group name, 
assigned material
+ * also.
+ *
+ * It must recieve all polygons to be added to the mesh. Remove holes from 
polygons before
+ * calling this.
+ */
 void MeshFromGeometry::create_polys_loops(Span<FaceElement> all_faces)
 {
-  /* May not be used conditionally. */
+  /* Will not be used if vertex groups are not imported. */
   blender_mesh_->dvert = nullptr;
   float weight = 0.0f;
   if (mesh_geometry_.tot_verts() && mesh_geometry_.use_vertex_groups()) {
@@ -283,6 +297,9 @@ void MeshFromGeometry::create_polys_loops(Span<FaceElement> 
all_faces)
   }
 }
 
+/**
+ * Add explicitly imported OBJ edges to the mesh.
+ */
 void MeshFromGeometry::create_edges()
 {
   const int64_t tot_edges{mesh_geometry_.tot_edges()};
@@ -302,9 +319,12 @@ void MeshFromGeometry::create_edges()
   BKE_mesh_calc_edges_loose(blender_mesh_.get());
 }
 
+/**
+ * Add UV layer and vertices to the Mesh.
+ */
 void MeshFromGeometry::create_uv_verts()
 {
-  if (global_vertices_.uv_vertices.size() <= 0 ) {
+  if (global_vertices_.uv_vertices.size() <= 0) {
     return;
   }
   MLoopUV *mluv_dst = static_cast<MLoopUV *>(CustomData_add_layer(
@@ -323,6 +343,9 @@ void MeshFromGeometry::create_uv_verts()
   }
 }
 
+/**
+ * Add materials and the nodetree to the Mesh Object.
+ */
 void MeshFromGeometry::create_materials(Main *bmain,
                                         const Map<std::string, MTLMaterial> 
&materials)
 {
@@ -345,7 +368,7 @@ void MeshFromGeometry::create_materials(Main *bmain,
 }
 
 /**
- * Needs more clarity upon what is expected here?
+ * Needs more clarity about what is expected in the viewport if the function 
works.
  */
 void MeshFromGeometry::add_custom_normals()
 {
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mtl.hh 
b/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mtl.hh
index 8473a46ad59..b47bfb8e469 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mtl.hh
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_im_mtl.hh
@@ -30,8 +30,8 @@
 #include "BLI_array.hh"
 #include "BLI_float3.hh"
 #include "BLI_map.hh"
-#include "BLI_vector.hh"
 #include "BLI_string_ref.hh"
+#include "BLI_vector.hh"
 
 namespace blender::io::obj {
 /**

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to