mitsuba-blender
mitsuba-blender copied to clipboard
Importer: Improve OBJ file loading performance
Blender's built-in operators for OBJ file loading directly creates Blender objects, meshes and materials in the given scene. In the context of the add-on, the importer needs a function that returns a single mesh instance (multiple object from a single OBJ file is not currently supported).
The current implementation is based on Blender's own Python OBJ parser and makes the necessary adjustments to return a mesh instance. However, the newer Blender 3.2.2 version comes with a C++ implementation that promises more than 10x performance improvements and the current solution would not be able to leverage it.
Solution
One can record the state of the scene (objects, meshes, materials, etc...) before and after calling the built-in Blender operator and extract the required information from the difference.
This solution means that the add-on always uses Blender's own implementation which can benefit from performance improvements in future versions.