[Bf-blender-cvs] [f0de7b58bf0] soc-2020-io-performance: Rename curv_num to control_points

Ankit Meel noreply at git.blender.org
Tue Sep 29 19:20:18 CEST 2020


Commit: f0de7b58bf01b0a2a276e0b77d3a4c6a893820d5
Author: Ankit Meel
Date:   Tue Sep 29 21:39:25 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rBf0de7b58bf01b0a2a276e0b77d3a4c6a893820d5

Rename curv_num to control_points

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

M	source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
M	source/blender/io/wavefront_obj/intern/obj_export_nurbs.cc

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

diff --git a/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc b/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
index dd4c766afbe..f6c8eb89d16 100644
--- a/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
+++ b/source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
@@ -404,7 +404,6 @@ void OBJWriter::write_nurbs_curve(const OBJCurve &obj_nurbs_data) const
 
     const char *nurbs_name = obj_nurbs_data.get_curve_name();
     const int nurbs_degree = obj_nurbs_data.get_nurbs_degree(i);
-
     fprintf(outfile_,
             "g %s\n"
             "cstype bspline\n"
@@ -412,25 +411,26 @@ void OBJWriter::write_nurbs_curve(const OBJCurve &obj_nurbs_data) const
             nurbs_name,
             nurbs_degree);
     /**
-     * curv_num indices into the point vertices above, in relative indices.
+     * The numbers here are indices into the point vertex coordinates written above.
      * 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.
      */
-    /* Number of vertices in the curve + degree of the curve if it is cyclic. */
-    const int curv_num = obj_nurbs_data.get_nurbs_num(i);
+    const int total_control_points = obj_nurbs_data.get_nurbs_num(i);
+    /* [0.0 - 1.0] is the curve parameter range. */
     fputs("curv 0.0 1.0", outfile_);
-    for (int i = 0; i < curv_num; i++) {
+    for (int i = 0; i < total_control_points; i++) {
       /* + 1 to keep indices one-based, even if they're negative. */
-      fprintf(outfile_, " %d", -1 * ((i % tot_points) + 1));
+      fprintf(outfile_, " %d", -((i % tot_points) + 1));
     }
     fputs("\n", outfile_);
 
     /**
-     * In parm u line: between 0 and 1, curv_num + 2 equidistant numbers are inserted.
+     * In "parm u 0 0.1 .." line:, total control points + 2 equidistant numbers in the paramter
+     * range are inserted.
      */
     fputs("parm u 0.000000 ", outfile_);
-    for (int i = 1; i <= curv_num + 2; i++) {
-      fprintf(outfile_, "%f ", 1.0f * i / (curv_num + 2 + 1));
+    for (int i = 1; i <= total_control_points + 2; i++) {
+      fprintf(outfile_, "%f ", 1.0f * i / (total_control_points + 2 + 1));
     }
     fputs("1.000000\n", outfile_);
 
diff --git a/source/blender/io/wavefront_obj/intern/obj_export_nurbs.cc b/source/blender/io/wavefront_obj/intern/obj_export_nurbs.cc
index 0faf9c017b1..51d5a9a1cbb 100644
--- a/source/blender/io/wavefront_obj/intern/obj_export_nurbs.cc
+++ b/source/blender/io/wavefront_obj/intern/obj_export_nurbs.cc
@@ -92,19 +92,18 @@ float3 OBJCurve::calc_nurbs_point_coords(const int index,
 }
 
 /**
- * Get number of "curv" points of the Nurb at the given index.
+ * Get number of control points of the Nurb at the given index.
  */
 int OBJCurve::get_nurbs_num(const int index) const
 {
   const Nurb *nurb = static_cast<Nurb *>(BLI_findlink(&export_curve_->nurb, index));
   const int r_nurbs_degree = nurb->orderu - 1;
-  /* "curv_num" is the number of control points in a nurbs.
-   * If it is cyclic, degree also adds up. */
-  int r_curv_num = nurb->pntsv * nurb->pntsu;
+  /* Number of points in the curve + (degree of the curve if it is cyclic). */
+  int r_control_points = nurb->pntsv * nurb->pntsu;
   if (nurb->flagu & CU_NURB_CYCLIC) {
-    r_curv_num += r_nurbs_degree;
+    r_control_points += r_nurbs_degree;
   }
-  return r_curv_num;
+  return r_control_points;
 }
 
 /**



More information about the Bf-blender-cvs mailing list