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:
authorAras Pranckevicius <aras_p>2022-01-30 21:48:03 +0300
committerHoward Trickey <howard.trickey@gmail.com>2022-01-30 21:48:03 +0300
commit07514def194a78fbb70931d5fbd002248e8f3c34 (patch)
tree2f705e3fc423177c9c7bd57052d608e192e718c9 /source/blender/io/wavefront_obj
parent2cf3ed13da1b76dec6e9a2cbe9ba0c4f7daf2cee (diff)
Fix T95328, new obj exporter not exporting custom normals.
Previously, the new obj exporter was only exporting per-vertex normals for faces marked as "smooth". But a face can have custom normals, as soon as the normals data layer exists. This change makes it follow the behavior of USD & Collada exporters and the old Python one, which also export per-vertex normals as soon as the layer is there. (From Patch D13957.)
Diffstat (limited to 'source/blender/io/wavefront_obj')
-rw-r--r--source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc2
-rw-r--r--source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc12
2 files changed, 13 insertions, 1 deletions
diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
index c1b12ddd217..14e50d726c0 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
@@ -358,7 +358,7 @@ void OBJMesh::store_normal_coords_and_indices(Vector<float3> &r_normal_coords)
*lnors)[3] = (const float(*)[3])(CustomData_get_layer(&export_mesh_eval_->ldata, CD_NORMAL));
for (int poly_index = 0; poly_index < export_mesh_eval_->totpoly; ++poly_index) {
const MPoly &mpoly = export_mesh_eval_->mpoly[poly_index];
- bool need_per_loop_normals = is_ith_poly_smooth(poly_index);
+ bool need_per_loop_normals = lnors != nullptr || (mpoly.flag & ME_SMOOTH);
if (need_per_loop_normals) {
for (int loop_of_poly = 0; loop_of_poly < mpoly.totloop; ++loop_of_poly) {
float3 loop_normal;
diff --git a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
index 89e1de49511..1e2d509ef29 100644
--- a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
+++ b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
@@ -402,6 +402,18 @@ TEST_F(obj_exporter_regression_test, cube_all_data_triangulated)
_export.params);
}
+TEST_F(obj_exporter_regression_test, cube_normal_edit)
+{
+ OBJExportParamsDefault _export;
+ _export.params.forward_axis = OBJ_AXIS_Y_FORWARD;
+ _export.params.up_axis = OBJ_AXIS_Z_UP;
+ _export.params.export_materials = false;
+ compare_obj_export_to_golden("io_tests/blend_geometry/cube_normal_edit.blend",
+ "io_tests/obj/cube_normal_edit.obj",
+ "",
+ _export.params);
+}
+
TEST_F(obj_exporter_regression_test, suzanne_all_data)
{
OBJExportParamsDefault _export;