X-Plane / XPlane2Blender

Scenery & Aircraft export addon for Blender and X-Plane
GNU General Public License v3.0
190 stars 67 forks source link

Vertex Optimization on Export #709

Open ian-m-carr opened 1 year ago

ian-m-carr commented 1 year ago

I have been doing some investigation into round tripping models using the import/export flow and the code from the feat_import branch. But I beleive this applies in general across branches.

When exporting with optimization switched on vertices which duplicate location,normal and uv within each object are aggregated and output only once. But this optimisation is reset per object exported. In my case (C90B_cockpit_2) this results in the vertex table increasing in size by a factor of 3 on round trip. The cockpit object contains many duplicate instances of the same switch mesh.

Moving the dictionary initialization out of the object loop returns the vertex table size to approximately the original number ~30000-> ~10000 VT entries.

vertices_dct = {}

The resulting obj file appears to render correctly in XP-12 animations and textures appear as expected.

Unfortunately I am unable to get the unit tests to run on Windows, so cannot indicate if this impacts the behaviour in any other way.

This commit from my fork indicates the changes I made https://github.com/X-Plane/XPlane2Blender/commit/93195c9b0a5028def28cfd96da3cc8a6c69198e1