de49d18af5
In a previous step of the mesh writing process, the loop `totlayer` was replaced and a temporary vector is used for layer data instead. Use this temporary vector to find the UV sub-layers, since the vector and the CustomData struct in the mesh don't necessarily match. Also use a local variable for mesh loop count to make it clearer that the mesh isn't used except at the end. Thanks to Campbell for finding the source of this error.