[Bf-blender-cvs] [5bfdaaa8008] master: Fix T96415: new OBJ exporter was applying scaling factor incorrectly

Aras Pranckevicius noreply at git.blender.org
Sat Mar 19 22:17:01 CET 2022


Commit: 5bfdaaa80082be12af9850a2af294823005abb72
Author: Aras Pranckevicius
Date:   Sat Mar 19 17:13:21 2022 -0400
Branches: master
https://developer.blender.org/rB5bfdaaa80082be12af9850a2af294823005abb72

Fix T96415: new OBJ exporter was applying scaling factor incorrectly

This is patch D14347 from Aras Pranckevicius.

Instead of scaling "the scene" (i.e. transform vertices by object matrix,
then multiply by scale factor), it was instead first applying the scale
factor in local space, and then transforming by the object matrix.

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

M	source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
M	source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc

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

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 bd235ae07ae..5be68565054 100644
--- a/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
+++ b/source/blender/io/wavefront_obj/exporter/obj_export_mesh.cc
@@ -246,8 +246,8 @@ float3 OBJMesh::calc_vertex_coords(const int vert_index, const float scaling_fac
 {
   float3 r_coords;
   copy_v3_v3(r_coords, export_mesh_eval_->mvert[vert_index].co);
-  mul_v3_fl(r_coords, scaling_factor);
   mul_m4_v3(world_and_axes_transform_, r_coords);
+  mul_v3_fl(r_coords, scaling_factor);
   return r_coords;
 }
 
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 27f34ca6be9..e96a7d28561 100644
--- a/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
+++ b/source/blender/io/wavefront_obj/tests/obj_exporter_tests.cc
@@ -475,6 +475,17 @@ TEST_F(obj_exporter_regression_test, cube_normal_edit)
                                _export.params);
 }
 
+TEST_F(obj_exporter_regression_test, cubes_positioned)
+{
+  OBJExportParamsDefault _export;
+  _export.params.export_materials = false;
+  _export.params.scaling_factor = 2.0f;
+  compare_obj_export_to_golden("io_tests/blend_geometry/cubes_positioned.blend",
+                               "io_tests/obj/cubes_positioned.obj",
+                               "",
+                               _export.params);
+}
+
 TEST_F(obj_exporter_regression_test, suzanne_all_data)
 {
   OBJExportParamsDefault _export;



More information about the Bf-blender-cvs mailing list