[Bf-blender-cvs] [f1a60130bd9] soc-2020-io-performance: Move normal indices update near normal writer code.
Ankit Meel
noreply at git.blender.org
Tue Oct 6 20:45:23 CEST 2020
Commit: f1a60130bd94a4756a43c8cf74c5ba46d473e36c
Author: Ankit Meel
Date: Tue Oct 6 22:32:13 2020 +0530
Branches: soc-2020-io-performance
https://developer.blender.org/rBf1a60130bd94a4756a43c8cf74c5ba46d473e36c
Move normal indices update near normal writer code.
Remove `per_object_tot_normals_` from member variable.
===================================================================
M source/blender/io/wavefront_obj/intern/obj_export_file_writer.cc
M source/blender/io/wavefront_obj/intern/obj_export_file_writer.hh
===================================================================
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 ce302f13014..3d7c9301a5f 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
@@ -348,16 +348,16 @@ void OBJWriter::write_poly_elements(const OBJMesh &obj_mesh_data)
Vector<int> face_vertex_indices;
Vector<int> face_normal_indices;
- /* Reset for every Object. */
- per_object_tot_normals_ = 0;
+ /** Number of normals may not be equal to number of polygons due to smooth shading. */
+ int per_object_tot_normals = 0;
const int tot_polygons = obj_mesh_data.tot_polygons();
for (int i = 0; i < tot_polygons; i++) {
obj_mesh_data.calc_poly_vertex_indices(i, face_vertex_indices);
/* For an Object, a normal index depends on how many have been written before it.
* This is unknown because of smooth shading. So pass "per object total normals"
* and update it after each call. */
- per_object_tot_normals_ += obj_mesh_data.calc_poly_normal_indices(
- i, per_object_tot_normals_, face_normal_indices);
+ per_object_tot_normals += obj_mesh_data.calc_poly_normal_indices(
+ i, per_object_tot_normals, face_normal_indices);
write_smooth_group(obj_mesh_data, i, last_face_smooth_group);
write_vertex_group(obj_mesh_data, i, last_face_vertex_group);
@@ -365,6 +365,7 @@ void OBJWriter::write_poly_elements(const OBJMesh &obj_mesh_data)
(this->*poly_element_writer)(
face_vertex_indices, obj_mesh_data.uv_indices(i), face_normal_indices);
}
+ index_offsets_.normal_offset += per_object_tot_normals;
}
/**
@@ -447,8 +448,7 @@ void OBJWriter::update_index_offsets(const OBJMesh &obj_mesh_data)
{
index_offsets_.vertex_offset += obj_mesh_data.tot_vertices();
index_offsets_.uv_vertex_offset += obj_mesh_data.tot_uv_vertices();
- index_offsets_.normal_offset += per_object_tot_normals_;
- per_object_tot_normals_ = 0;
+ /* Normal index is updated right after writing the normals. */
}
/* -------------------------------------------------------------------- */
diff --git a/source/blender/io/wavefront_obj/intern/obj_export_file_writer.hh b/source/blender/io/wavefront_obj/intern/obj_export_file_writer.hh
index dfb42f53b04..fd8801bbcce 100644
--- a/source/blender/io/wavefront_obj/intern/obj_export_file_writer.hh
+++ b/source/blender/io/wavefront_obj/intern/obj_export_file_writer.hh
@@ -55,13 +55,6 @@ class OBJWriter {
const OBJExportParams &export_params_;
IndexOffsets index_offsets_{0, 0, 0};
- /**
- * Total normals of an Object. It is not that same as `Mesh.tot_poly` due
- * to unknown smooth groups which add loop normals for smooth faces.
- *
- * Used for updating normal offset.
- */
- int per_object_tot_normals_ = 0;
public:
OBJWriter(const OBJExportParams &export_params) : export_params_(export_params)
More information about the Bf-blender-cvs
mailing list