[Bf-blender-cvs] [2585882973d] soc-2020-io-performance: Cleanup: simplified conditionals, remove warnings on linux

Ankit Meel noreply at git.blender.org
Tue Jun 30 13:20:12 CEST 2020


Commit: 2585882973df70fabefb596a9d40f96441573c62
Author: Ankit Meel
Date:   Tue Jun 30 16:47:05 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rB2585882973df70fabefb596a9d40f96441573c62

Cleanup: simplified conditionals, remove warnings on linux

Use unsigned int to avoid any range issues.
Remove trailing whitespaces in face elements.
Remove `== false` from conditionals.

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

M	source/blender/io/wavefront_obj/CMakeLists.txt
M	source/blender/io/wavefront_obj/intern/wavefront_obj.cc
M	source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
M	source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mtl.cc
M	source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mtl.hh
M	source/blender/io/wavefront_obj/intern/wavefront_obj_file_handler.cc

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

diff --git a/source/blender/io/wavefront_obj/CMakeLists.txt b/source/blender/io/wavefront_obj/CMakeLists.txt
index 70f7a552000..bcc298ddde3 100644
--- a/source/blender/io/wavefront_obj/CMakeLists.txt
+++ b/source/blender/io/wavefront_obj/CMakeLists.txt
@@ -59,7 +59,7 @@ set(SRC
 )
 
 set(LIB
-
+  bf_blenkernel
 )
 
 blender_add_lib(bf_wavefront_obj "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj.cc b/source/blender/io/wavefront_obj/intern/wavefront_obj.cc
index 3c7c9d067a7..e23ee016a4d 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj.cc
@@ -44,6 +44,6 @@ void OBJ_export(bContext *C, const OBJExportParams *export_params)
 /**
  * Called from io_obj.c. Currently not implemented.
  */
-void OBJ_import(bContext *C, const OBJImportParams *import_params)
+void OBJ_import(bContext *UNUSED(C), const OBJImportParams *UNUSED(import_params))
 {
 }
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 bedcdf61bd1..97af6859c17 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
@@ -162,7 +162,7 @@ void exporter_main(bContext *C, const OBJExportParams *export_params)
     char frame_ext[17];
     BLI_snprintf(frame_ext, 17, "_%d.obj", frame);
     bool filepath_ok = BLI_path_extension_replace(filepath_with_frames, FILE_MAX, frame_ext);
-    if (filepath_ok == false) {
+    if (!filepath_ok) {
       fprintf(stderr, "Error: File Path too long.\n%s\n", filepath_with_frames);
       return;
     }
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mtl.cc b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mtl.cc
index 7aec770b2c3..3bd5c3ee95b 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mtl.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mtl.cc
@@ -43,7 +43,7 @@ namespace obj {
  */
 void MTLWriter::init_bsdf_node(const char *object_name)
 {
-  if (_export_mtl->use_nodes == false) {
+  if (!_export_mtl->use_nodes) {
     fprintf(
         stderr, "No Principled-BSDF node found in the material node tree of: %s.\n", object_name);
     _bsdf_node = nullptr;
diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mtl.hh b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mtl.hh
index 4aad44fdd49..b2a50c5f37b 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mtl.hh
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter_mtl.hh
@@ -43,7 +43,8 @@ class MTLWriter {
     BLI_path_extension_replace(_mtl_filepath, PATH_MAX, ".mtl");
   }
 
-  ~MTLWriter(){
+  ~MTLWriter()
+  {
     fclose(_mtl_outfile);
   }
 
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 723dc1dec13..250ac8904a6 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
@@ -38,10 +38,10 @@ void OBJWriter::write_vert_uv_normal_indices(Span<uint> vert_indices,
                                              Span<uint> normal_indices,
                                              const MPoly &poly_to_write)
 {
-  fprintf(_outfile, "f ");
-  for (int j = 0; j < poly_to_write.totloop; j++) {
+  fprintf(_outfile, "f");
+  for (uint j = 0; j < poly_to_write.totloop; j++) {
     fprintf(_outfile,
-            "%d/%d/%d ",
+            " %u/%u/%u",
             vert_indices[j] + _index_offset[VERTEX_OFF],
             uv_indices[j] + _index_offset[UV_VERTEX_OFF],
             normal_indices[j] + _index_offset[NORMAL_OFF]);
@@ -54,10 +54,10 @@ void OBJWriter::write_vert_normal_indices(Span<uint> vert_indices,
                                           Span<uint> normal_indices,
                                           const MPoly &poly_to_write)
 {
-  fprintf(_outfile, "f ");
-  for (int j = 0; j < poly_to_write.totloop; j++) {
+  fprintf(_outfile, "f");
+  for (uint j = 0; j < poly_to_write.totloop; j++) {
     fprintf(_outfile,
-            "%d//%d ",
+            " %u//%u ",
             vert_indices[j] + _index_offset[VERTEX_OFF],
             normal_indices[j] + _index_offset[NORMAL_OFF]);
   }
@@ -69,10 +69,10 @@ void OBJWriter::write_vert_uv_indices(Span<uint> vert_indices,
                                       Span<uint> uv_indices,
                                       const MPoly &poly_to_write)
 {
-  fprintf(_outfile, "f ");
-  for (int j = 0; j < poly_to_write.totloop; j++) {
+  fprintf(_outfile, "f");
+  for (uint j = 0; j < poly_to_write.totloop; j++) {
     fprintf(_outfile,
-            "%d/%d ",
+            " %u/%u",
             vert_indices[j] + _index_offset[VERTEX_OFF],
             uv_indices[j] + 1 + _index_offset[UV_VERTEX_OFF]);
   }
@@ -82,9 +82,9 @@ void OBJWriter::write_vert_uv_indices(Span<uint> vert_indices,
 /** Write one line of polygon indices as f v1 v2 ... . */
 void OBJWriter::write_vert_indices(Span<uint> vert_indices, const MPoly &poly_to_write)
 {
-  fprintf(_outfile, "f ");
-  for (int j = 0; j < poly_to_write.totloop; j++) {
-    fprintf(_outfile, "%d ", vert_indices[j] + _index_offset[VERTEX_OFF]);
+  fprintf(_outfile, "f");
+  for (uint j = 0; j < poly_to_write.totloop; j++) {
+    fprintf(_outfile, " %u", vert_indices[j] + _index_offset[VERTEX_OFF]);
   }
   fprintf(_outfile, "\n");
 }
@@ -184,7 +184,7 @@ void OBJWriter::write_poly_normals(OBJMesh &obj_mesh_data)
  */
 void OBJWriter::write_poly_material(short &last_face_mat_nr, OBJMesh &obj_mesh_data, short mat_nr)
 {
-  if (_export_params->export_materials == false || !(obj_mesh_data.tot_col() > 0)) {
+  if (!_export_params->export_materials || obj_mesh_data.tot_col() <= 0) {
     return;
   }
   /* Whenever a face with a new material is encountered, write its material and group, otherwise
@@ -271,7 +271,7 @@ void OBJWriter::write_curve_edges(OBJMesh &obj_mesh_data)
   for (uint edge_index = 0; edge_index < obj_mesh_data.tot_edges(); edge_index++) {
     obj_mesh_data.calc_edge_vert_indices(vertex_indices, edge_index);
     fprintf(_outfile,
-            "l %d %d\n",
+            "l %u %u\n",
             vertex_indices[0] + _index_offset[VERTEX_OFF],
             vertex_indices[1] + _index_offset[VERTEX_OFF]);
   }
@@ -298,13 +298,13 @@ void OBJWriter::write_nurbs_curve(OBJNurbs &obj_nurbs_data)
 
     fprintf(_outfile, "g %s\ncstype bspline\ndeg %d\n", nurbs_name, nurbs_degree);
     /**
-     * curv_num refers to the vertices above written in relative indices.
+     * curv_num indices into the point vertices above, in relative indices.
      * 0.0 1.0 -1 -2 -3 -4 for a non-cyclic curve with 4 points.
      * 0.0 1.0 -1 -2 -3 -4 -1 -2 -3 for a cyclic curve with 4 points.
      */
-    fprintf(_outfile, "curv 0.0 1.0 ");
+    fprintf(_outfile, "curv 0.0 1.0");
     for (int i = 0; i < curv_num; i++) {
-      fprintf(_outfile, "%d ", -1 * ((i % tot_points) + 1));
+      fprintf(_outfile, " -%u", (i % tot_points) + 1);
     }
     fprintf(_outfile, "\n");



More information about the Bf-blender-cvs mailing list