Original Post
Hello all. I'm working on a 3D file loader and want to quickly discard duplicated vertices as they are being loaded. For this purpose, every vertex is being placed into an std::map. This requires me to create a 'key' value for every inserted vertex. After a bit of experimenting, I found out that this:
__int64 key = ((__int64&)px ^ 333667 * (__int64&)py ^ 333667 * (__int64&)pz ^ 333667) *
((__int64&)nx ^ 333667 * (__int64&)ny ^ 333667 * (__int64&)nz ^ 333667) ^
((__int64&)tu ^ 333667 * (__int64&)tv ^ 333667);
position (px,py,pz) normal (nx,ny,nz) texturing (tu,tv) seems to work for a limited set of my 3D files, but I have doubts about that method. The magic numbers are just some primes that seem to work. The problem is that the above key works only for position/normal/texture coordinates combo, and needs to be changed significantly for different types of vertices, you cannot just cull away certain attributes for simpler vertices. Can anyone please point me at the right way (fast, simple and robust) to convert a vertex with arbitrary data into integer key value? Or perhaps the above method is the right way?