Dylancyclone / VMF2OBJ

Convert source-engine VMF files into OBJ files with materials (including brushes, displacements, entities, and models)
MIT License
113 stars 6 forks source link

Sort faces by texture #4

Open Dylancyclone opened 4 years ago

Dylancyclone commented 4 years ago

If a brush used multiple materials, it is possible for the .obj file to switch back and forth between the materials multiple times. For optimization, it would be nice to sort the faces so that only one usemtl needs to be used per material per object.

For example:

usemtl tools/toolsnodraw
f 1/1 2/2 3/3 4/4 
usemtl tools/toolstrigger
f 5/5 6/6 7/7 8/8 
usemtl tools/toolsnodraw
f 9/9 10/10 11/11 12/12

could be optimized to:

usemtl tools/toolsnodraw
f 1/1 2/2 3/3 4/4 
f 9/9 10/10 11/11 12/12
usemtl tools/toolstrigger
f 5/5 6/6 7/7 8/8