Page MenuHome

Fix T96399: New 3.1 OBJ exporter is missing Path Mode setting
ClosedPublic

Authored by Aras Pranckevicius (aras_p) on May 10 2022, 10:41 AM.

Details

Summary

New OBJ exporter is missing "Path Mode" setting for exporting .mtl files. The options that used to be available were: Auto, Absolute, Relative, Match, Strip Path, Copy. All of them are important. The new behavior (without any UI option to control it) curiously does not match any of the previous setting. New behavior is like "Relative, but to the source blender file, and not the destination export file".

Most of the previous logic was only present in Python based code (bpy_extras.io_utils.path_reference and friends). I searched whether something similar exists in the C++ codebase, but did not find anything -- none of the other C++ I/O modules have a need for something like that. So this meant that the python enum & path adjustment function & the texture copying had to be ported over to C++. That's the bulk of this commit.

For the obj test coverage, this changes the golden output of cubes_with_textures.mtl (which was previously "wrong"), and adds a new test to cover "relative" path mode setting:

Various other modes are hard to test using "golden" templates due to presence of absolute filesystem paths in the output. I tested all of them manually, and compared to previous python based exporter.

Diff Detail

Repository
rB Blender

Event Timeline

I made a couple of comments which you can answer/address, but then you can commit this.

source/blender/io/common/IO_path_util.hh
13

Rather than just referencing the python equivalent, it would be nicer if this comment more explicitly described what this function does. In particular, the purpose of the copy_set argument is not obvious to a casual reader.

source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
557

Has this code been tested on Windows?

This revision is now accepted and ready to land.May 10 2022, 1:19 PM
source/blender/io/common/IO_path_util.hh
13

Good point, will do

source/blender/io/wavefront_obj/exporter/obj_export_file_writer.cc
557

Yes. I tested export with relative paths, using both forward & backward slashes on windows. Both the current and the existing python importers can import the forward-slashes files just fine (almost all Win32 APIs supports forward slashes for filenames).