UVAtlas. D3DXCreateTextureGutterHelper fails with some Meshes

I finally found the solution to a problem that was driving me nuts.

D3DXCreateTextureGutterHelper (or the constructor of TextureGutterHelper, if on MDX) throws an "Invalid Call" exception with certain meshes.

I came to a situation where the method worked for a Mesh generated by D3DXCreateUVAtlas, but failed for the (aparently) SAME mesh created by me:

* Same number of vertices/faces
* Same attribute table
* Same vertex format
* Same Mesh Options
* Same declarations
* Same indices at IndexBuffer
* SAME EVERYTHING

Then, what was the cause?

My meshes have 2 or more different sets of TexCoords. One of them to address the UVAtlas, and others for other kind of textures. Aparently, D3DXCreateTextureGutterHelper will fail if the coordinates addressing the UVAtlas are not in the 1st set of TexCoords.

In my case, UVAtlas TexCoords are always in the 2nd set of TexCoords. That´s why it was failing.

Workaround: create a temp Mesh and copy the UVAtlas coordinates to the first set. Then, the method will succeed.

PS To the Microsoft DirectX Team:

The work done with all the UVAtlas functions is priceless. They are really useful, but please, document things like this a little bit.

This kind of problems are very easy to work around when known, but finding the cause by brute-force investigation can take hours and hours.