[Bf-blender-cvs] [c4c1d7b0b95] soc-2020-io-performance: Renaming: Specify mesh objects instead of object

Ankit Meel noreply at git.blender.org
Mon Jun 22 21:03:36 CEST 2020


Commit: c4c1d7b0b95304875f5c583189e828b0269a1147
Author: Ankit Meel
Date:   Thu Jun 18 20:16:13 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rBc4c1d7b0b95304875f5c583189e828b0269a1147

Renaming: Specify mesh objects instead of object

No functional change is there.

This change is required to distinguish mesh objects from curve objects.
Both of them have different requirements for the structs they'd use to
store their processed data.
So instead of adding if-else everywhere, curves and meshes can be
separated into different files.

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

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

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

diff --git a/source/blender/io/wavefront_obj/intern/wavefront_obj.hh b/source/blender/io/wavefront_obj/intern/wavefront_obj.hh
index 62d7af22932..a1d7993809e 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj.hh
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj.hh
@@ -60,9 +60,9 @@ struct Polygon {
 };
 
 /**
- * Stores geometry of one object to be exported.
+ * Stores geometry of one mesh object to be exported.
  */
-typedef struct OBJ_object_to_export {
+typedef struct OBJ_obmesh_to_export {
   bContext *C;
   Depsgraph *depsgraph;
   Object *object;
@@ -86,7 +86,7 @@ typedef struct OBJ_object_to_export {
   int forward_axis;
   int up_axis;
   float scaling_factor;
-} OBJ_object_to_export;
+} OBJ_obmesh_to_export;
 }  // namespace obj
 }  // namespace io
 
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 6f095a782ec..5d66fb19b57 100644
--- a/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
+++ b/source/blender/io/wavefront_obj/intern/wavefront_obj_exporter.cc
@@ -58,47 +58,47 @@ namespace io {
 namespace obj {
 
 /**
- * Store the mesh vertex coordinates in object_to_export, in world coordinates.
+ * Store the mesh vertex coordinates in obmesh_to_export, in world coordinates.
  */
 static void get_transformed_mesh_vertices(Mesh *me_eval,
                                           Object *ob_eval,
-                                          OBJ_object_to_export &object_to_export)
+                                          OBJ_obmesh_to_export &obmesh_to_export)
 {
-  uint num_verts = object_to_export.tot_vertices = me_eval->totvert;
-  object_to_export.mvert = (MVert *)MEM_callocN(num_verts * sizeof(MVert),
-                                                "OBJ object vertex coordinates & normals");
+  uint num_verts = obmesh_to_export.tot_vertices = me_eval->totvert;
+  obmesh_to_export.mvert = (MVert *)MEM_callocN(num_verts * sizeof(MVert),
+                                                "OBJ mesh object vertex coordinates & normals");
   float axes_transform[3][3];
   unit_m3(axes_transform);
   mat3_from_axis_conversion(DEFAULT_AXIS_FORWARD,
                             DEFAULT_AXIS_UP,
-                            object_to_export.forward_axis,
-                            object_to_export.up_axis,
+                            obmesh_to_export.forward_axis,
+                            obmesh_to_export.up_axis,
                             axes_transform);
 
   float world_transform[4][4];
   copy_m4_m4(world_transform, ob_eval->obmat);
   mul_m4_m3m4(world_transform, axes_transform, world_transform);
   for (uint i = 0; i < num_verts; i++) {
-    copy_v3_v3(object_to_export.mvert[i].co, me_eval->mvert[i].co);
-    mul_m4_v3(world_transform, object_to_export.mvert[i].co);
-    mul_v3_fl(object_to_export.mvert[i].co, object_to_export.scaling_factor);
+    copy_v3_v3(obmesh_to_export.mvert[i].co, me_eval->mvert[i].co);
+    mul_m4_v3(world_transform, obmesh_to_export.mvert[i].co);
+    mul_v3_fl(obmesh_to_export.mvert[i].co, obmesh_to_export.scaling_factor);
   }
 }
 
 /**
- * Store the mesh vertex normals in object_to_export, in world coordinates.
- * Memory for object_to_export.mvert pre-allocated in get_transformed_mesh_vertices.
+ * Store the mesh vertex normals in obmesh_to_export, in world coordinates.
+ * Memory for obmesh_to_export.mvert pre-allocated in get_transformed_mesh_vertices.
  */
 static void get_transformed_vertex_normals(Mesh *me_eval,
                                            Object *ob_eval,
-                                           OBJ_object_to_export &object_to_export)
+                                           OBJ_obmesh_to_export &obmesh_to_export)
 {
   BKE_mesh_ensure_normals(me_eval);
   float transformed_normal[3];
   for (uint i = 0; i < me_eval->totvert; i++) {
     normal_short_to_float_v3(transformed_normal, me_eval->mvert[i].no);
     mul_mat3_m4_v3(ob_eval->obmat, transformed_normal);
-    normal_float_to_short_v3(object_to_export.mvert[i].no, transformed_normal);
+    normal_float_to_short_v3(obmesh_to_export.mvert[i].no, transformed_normal);
   }
 }
 
@@ -106,32 +106,32 @@ static void get_transformed_vertex_normals(Mesh *me_eval,
  * Store a polygon's vertex indices, indexing into the pre-defined
  * vertex coordinates list.
  */
-static void get_polygon_vert_indices(Mesh *me_eval, OBJ_object_to_export &object_to_export)
+static void get_polygon_vert_indices(Mesh *me_eval, OBJ_obmesh_to_export &obmesh_to_export)
 {
   const MLoop *mloop;
   const MPoly *mpoly = me_eval->mpoly;
 
-  object_to_export.tot_poly = me_eval->totpoly;
-  object_to_export.polygon_list.resize(me_eval->totpoly);
+  obmesh_to_export.tot_poly = me_eval->totpoly;
+  obmesh_to_export.polygon_list.resize(me_eval->totpoly);
 
   for (uint i = 0; i < me_eval->totpoly; i++, mpoly++) {
     mloop = &me_eval->mloop[mpoly->loopstart];
-    object_to_export.polygon_list[i].total_vertices_per_poly = mpoly->totloop;
+    obmesh_to_export.polygon_list[i].total_vertices_per_poly = mpoly->totloop;
 
-    object_to_export.polygon_list[i].vertex_index.resize(mpoly->totloop);
+    obmesh_to_export.polygon_list[i].vertex_index.resize(mpoly->totloop);
 
     for (int j = 0; j < mpoly->totloop; j++) {
       /* mloop->v is 0-based index. Indices in OBJ start from 1. */
-      object_to_export.polygon_list[i].vertex_index[j] = (mloop + j)->v + 1;
+      obmesh_to_export.polygon_list[i].vertex_index[j] = (mloop + j)->v + 1;
     }
   }
 }
 
 /**
- * Store UV vertex coordinates in object_to_export.uv_coords as well as their indices, in
+ * Store UV vertex coordinates in obmesh_to_export.uv_coords as well as their indices, in
  * a polygon[i].uv_vertex_index.
  */
-static void get_uv_coordinates(Mesh *me_eval, OBJ_object_to_export &object_to_export)
+static void get_uv_coordinates(Mesh *me_eval, OBJ_obmesh_to_export &obmesh_to_export)
 {
   const CustomData *ldata = &me_eval->ldata;
 
@@ -149,46 +149,46 @@ static void get_uv_coordinates(Mesh *me_eval, OBJ_object_to_export &object_to_ex
     UvVertMap *uv_vert_map = BKE_mesh_uv_vert_map_create(
         mpoly, mloop, mloopuv, me_eval->totpoly, me_eval->totvert, limit, false, false);
 
-    object_to_export.tot_uv_vertices = -1;
+    obmesh_to_export.tot_uv_vertices = -1;
     for (int vertex_index = 0; vertex_index < me_eval->totvert; vertex_index++) {
       const UvMapVert *uv_vert = BKE_mesh_uv_vert_map_get_vert(uv_vert_map, vertex_index);
       while (uv_vert != NULL) {
         if (uv_vert->separate) {
-          object_to_export.tot_uv_vertices++;
+          obmesh_to_export.tot_uv_vertices++;
         }
-        Polygon &polygon_of_uv_vert = object_to_export.polygon_list[uv_vert->poly_index];
+        Polygon &polygon_of_uv_vert = obmesh_to_export.polygon_list[uv_vert->poly_index];
         const uint vertices_in_poly = polygon_of_uv_vert.total_vertices_per_poly;
         /* Resize UV vertices index list. */
         polygon_of_uv_vert.uv_vertex_index.resize(vertices_in_poly);
 
         /* Fill up UV vertex index for current polygon's one vertex. */
         polygon_of_uv_vert.uv_vertex_index[uv_vert->loop_of_poly_index] =
-            object_to_export.tot_uv_vertices;
+            obmesh_to_export.tot_uv_vertices;
 
         /* Fill up UV vertices' coordinates. We don't know how many unique vertices are there, so
          * need to push back everytime. */
-        object_to_export.uv_coords.push_back(std::array<float, 2>());
-        object_to_export.uv_coords[object_to_export.tot_uv_vertices][0] =
+        obmesh_to_export.uv_coords.push_back(std::array<float, 2>());
+        obmesh_to_export.uv_coords[obmesh_to_export.tot_uv_vertices][0] =
             mloopuv[mpoly[uv_vert->poly_index].loopstart + uv_vert->loop_of_poly_index].uv[0];
-        object_to_export.uv_coords[object_to_export.tot_uv_vertices][1] =
+        obmesh_to_export.uv_coords[obmesh_to_export.tot_uv_vertices][1] =
             mloopuv[mpoly[uv_vert->poly_index].loopstart + uv_vert->loop_of_poly_index].uv[1];
 
         uv_vert = uv_vert->next;
       }
     }
     /* Actual number of total UV vertices is 1-based, as opposed to the index: 0-based. */
-    object_to_export.tot_uv_vertices += 1;
+    obmesh_to_export.tot_uv_vertices += 1;
     BKE_mesh_uv_vert_map_free(uv_vert_map);
     /* No need to go over other layers. */
     break;
   }
 }
 
-static void get_geometry_per_object(const OBJExportParams *export_params,
-                                    OBJ_object_to_export &object_to_export)
+static void get_geometry_per_obmesh(const OBJExportParams *export_params,
+                                    OBJ_obmesh_to_export &obmesh_to_export)
 {
-  Depsgraph *depsgraph = object_to_export.depsgraph;
-  Object *ob = object_to_export.object;
+  Depsgraph *depsgraph = obmesh_to_export.depsgraph;
+  Object *ob = obmesh_to_export.object;
   Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
   Mesh *me_eval = BKE_object_get_evaluated_mesh(ob_eval);
 
@@ -221,13 +221,13 @@ static void get_geometry_per_object(const OBJExportParams *export_params,
     BM_mesh_free(bmesh);
   }
 
-  get_transformed_mesh_vertices(me_eval, ob_eval, object_to_export);
-  get_polygon_vert_indices(me_eval, object_to_export);
+  get_transformed_mesh_vertices(me_eval, ob_eval, obmesh_to_export);
+  get_polygon_vert_indices(me_eval, obmesh_to_export);
   if (export_params->export_normals) {
-    get_transformed_vertex_normals(me_eval, ob_eval, object_to_export);
+    get_transformed_vertex_normals(me_eval, ob_eval, obmesh_to_export);
   }
   if (export_params->export_uv) {
-    get_uv_coordinates(me_eval, object_to_export);
+    get_uv_coordinates(me_eval, obmesh_to_export);
   }
   if (export_params->export_triangulated) {
     BKE_id_free(NULL, triangulated);
@@ -237,12 +237,12 @@ static void get_geometry_per_object(const OBJExportParams *export_params,
 /**
  * Check object type to filter only exportable objects.
  */
-static void check_object_type(Object *object, std::vector<OBJ_object_to_export> &objects_to_export)
+static void check_object_type(Object *object, std::vector<OBJ_obmesh_to_export> &meshes_t

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list