Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHoward Trickey <howard.trickey@gmail.com>2022-01-18 07:22:40 +0300
committerHoward Trickey <howard.trickey@gmail.com>2022-01-18 07:22:40 +0300
commit6dd89afa966042f8ae402c848655ac0dc0d795fe (patch)
tree9c46d63d75f17bfa40a1622d6be2480a413eea22 /source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh
parentdb496a0b7dcf1ab024aece9858257c40529138e4 (diff)
Fix obj exporter tests by deduping normals and printing with less precision.
Some new obj exporter tests were disabled because the normals were different in the last decimal place on different platforms. The old python exporter deduped normals with their coordinates rounded to four decimal places. This change does the same in the new exporter. On one test, this produced a file 25% smaller and even ran 10% faster.
Diffstat (limited to 'source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh')
-rw-r--r--source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh26
1 files changed, 17 insertions, 9 deletions
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh
index e6d2853d040..3113a82b4d1 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.hh
@@ -78,6 +78,15 @@ class OBJMesh : NonCopyable {
*/
Vector<Vector<int>> uv_indices_;
/**
+ * Per-loop normal index.
+ */
+ Vector<int> loop_to_normal_index_;
+ /*
+ * Total number of normal indices (maximum entry, plus 1, in
+ * the loop_to_norm_index_ vector).
+ */
+ int tot_normal_indices_ = NEGATIVE_INIT;
+ /**
* Total smooth groups in an object.
*/
int tot_smooth_groups_ = NEGATIVE_INIT;
@@ -97,6 +106,7 @@ class OBJMesh : NonCopyable {
int tot_vertices() const;
int tot_polygons() const;
int tot_uv_vertices() const;
+ int tot_normal_indices() const;
int tot_edges() const;
/**
@@ -162,18 +172,16 @@ class OBJMesh : NonCopyable {
*/
float3 calc_poly_normal(int poly_index) const;
/**
- * Calculate a polygon's polygon/loop normal indices.
- * \param object_tot_prev_normals Number of normals of this Object written so far.
- * \return Number of distinct normal indices.
+ * Find the unqique normals of the mesh and return them in \a r_normal_coords.
+ * Store the indices into that vector with for each loop in this OBJMesh.
*/
- std::pair<int, Vector<int>> calc_poly_normal_indices(int poly_index,
- int object_tot_prev_normals) const;
+ void store_normal_coords_and_indices(Vector<float3> &r_normal_coords);
/**
- * Calculate loop normals of a polygon at the given index.
- *
- * Should be used for smooth-shaded polygons.
+ * Calculate a polygon's polygon/loop normal indices.
+ * \param poly_index Index of the polygon to calculate indices for.
+ * \return Vector of normal indices, aligned with vertices of polygon.
*/
- void calc_loop_normals(int poly_index, Vector<float3> &r_loop_normals) const;
+ Vector<int> calc_poly_normal_indices(int poly_index) const;
/**
* Find the index of the vertex group with the maximum number of vertices in a polygon.
* The index indices into the #Object.defbase.