[Bf-blender-cvs] [69270c7800c] soc-2020-io-performance: Cleanup: use const, remove single use variables.

Ankit Meel noreply at git.blender.org
Tue Aug 18 12:32:22 CEST 2020


Commit: 69270c7800c4859d1cb82285f3f8f250b59522dc
Author: Ankit Meel
Date:   Tue Aug 18 16:02:02 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rB69270c7800c4859d1cb82285f3f8f250b59522dc

Cleanup: use const, remove single use variables.

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

M	source/blender/io/wavefront_obj/intern/wavefront_obj_ex_file_writer.cc
M	source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
M	source/blender/io/wavefront_obj/intern/wavefront_obj_im_file_reader.cc

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

diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj_ex_file_writer.cc b/source/blender/io/wavefront_obj/intern/wavefront_obj_ex_file_writer.cc
index 840408bcc36..e19dc5284a9 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_ex_file_writer.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_ex_file_writer.cc
@@ -457,12 +457,12 @@ void MTLWriter::append_materials(const OBJMesh &mesh_to_export)
     fprintf(mtl_outfile_, "\nnewmtl %s\n", mtl_material.name.c_str());
     fprintf(mtl_outfile_, "Ns %.6f\n", mtl_material.Ns);
     fprintf(mtl_outfile_,
-            "Ka %.6f %.6f %.6f\n",
+            "Ka %0.6f %0.6f %0.6f\n",
             mtl_material.Ka[0],
             mtl_material.Ka[1],
             mtl_material.Ka[2]);
     fprintf(mtl_outfile_,
-            "Kd %.6f %.6f %.6f\n",
+            "Kd %0.6f %0.6f %0.6f\n",
             mtl_material.Kd[0],
             mtl_material.Kd[1],
             mtl_material.Kd[2]);
@@ -490,7 +490,8 @@ void MTLWriter::append_materials(const OBJMesh &mesh_to_export)
       if (texture_map.key == "map_Bump" && mtl_material.map_Bump_strength > -0.9f) {
         map_bump_strength = " -bm " + std::to_string(mtl_material.map_Bump_strength);
       }
-      /* Always keep only one space between options. map_Bump string has its leading space. */
+      /* Always keep only one space between options since filepaths may have leading spaces too.
+       * map_Bump string has its leading space. */
       fprintf(mtl_outfile_,
               "%s -o %.6f %.6f %.6f -s %.6f %.6f %.6f%s %s\n",
               texture_map.key.c_str(),
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 b60060dfad6..a720d68f437 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
@@ -191,13 +191,11 @@ void exporter_main(bContext *C, const OBJExportParams &export_params)
     return;
   }
 
-  int start_frame = export_params.start_frame;
-  int end_frame = export_params.end_frame;
   char filepath_with_frames[FILE_MAX];
   /* To reset the Scene to its original state. */
-  int original_frame = CFRA;
+  const int original_frame = CFRA;
 
-  for (int frame = start_frame; frame <= end_frame; frame++) {
+  for (int frame = export_params.start_frame; frame <= export_params.end_frame; frame++) {
     bool filepath_ok = insert_frame_in_path(filepath, filepath_with_frames, frame);
     if (!filepath_ok) {
       fprintf(stderr, "Error: File Path too long.\n%s\n", filepath_with_frames);
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 c2f05b8f371..6d542cd00b4 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
@@ -584,8 +584,8 @@ void MTLParser::parse_and_store(Map<string, MTLMaterial> &mtl_materials)
       Vector<string_view> str_map_xx_split{};
       split_by_char(rest_line, ' ', str_map_xx_split);
 
-      /* TODO ankitm: use `skip_unsupported_options` for parsing this options too. */
-      int64_t pos_o{str_map_xx_split.first_index_of_try("-o")};
+      /* TODO ankitm: use `skip_unsupported_options` for parsing these options too? */
+      const int64_t pos_o{str_map_xx_split.first_index_of_try("-o")};
       if (pos_o != string::npos && pos_o + 3 < str_map_xx_split.size()) {
         copy_string_to_float({str_map_xx_split[pos_o + 1],
                               str_map_xx_split[pos_o + 2],
@@ -593,7 +593,7 @@ void MTLParser::parse_and_store(Map<string, MTLMaterial> &mtl_materials)
                              0.0f,
                              {tex_map.translation, 3});
       }
-      int64_t pos_s{str_map_xx_split.first_index_of_try("-s")};
+      const int64_t pos_s{str_map_xx_split.first_index_of_try("-s")};
       if (pos_s != string::npos && pos_s + 3 < str_map_xx_split.size()) {
         copy_string_to_float({str_map_xx_split[pos_s + 1],
                               str_map_xx_split[pos_s + 2],
@@ -602,7 +602,7 @@ void MTLParser::parse_and_store(Map<string, MTLMaterial> &mtl_materials)
                              {tex_map.scale, 3});
       }
       /* Only specific to Normal Map node. */
-      int64_t pos_bm{str_map_xx_split.first_index_of_try("-bm")};
+      const int64_t pos_bm{str_map_xx_split.first_index_of_try("-bm")};
       if (pos_bm != string::npos && pos_bm + 1 < str_map_xx_split.size()) {
         copy_string_to_float(
             str_map_xx_split[pos_bm + 1], 0.0f, current_mtlmaterial->map_Bump_strength);



More information about the Bf-blender-cvs mailing list