From 07514def194a78fbb70931d5fbd002248e8f3c34 Mon Sep 17 00:00:00 2001 From: Aras Pranckevicius Date: Sun, 30 Jan 2022 13:48:03 -0500 Subject: 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.) --- source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc | 2 +- source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) (limited to 'source/blender') 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 &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; -- cgit v1.2.3