Just a short question this time. I want to hash a number of integer tuples (x, y, z) into a linear array to quickly find matching tuples. The tuples don't have any special spatial properties (i.e. are distributed quite randomly).
What would be a good mapping function from a tuple to an array index ?
hashindex = (x * MediumPrime + y * SmallPrime + z) % LargePrimeAndArraySize;
came to my mind, but I'm missing the experience to decide here.
Are there any alternatives ? For example, might using some tree-based sorting (octree, etc) be any faster than simple hashing ?
The point behind this question is that I recently implemented wavefront .obj loading, and it stores 3d geometry data in a very strange way. It has seperate vertex, texture, and normal vertices, and each face seperately indexes into each of these. Consequently, I want to merge vertices that share the same (vertex index, texture index, normal index) tuple. Linear searching results in an O(vertex*face) runtime, and thus takes forever on large meshes.
Any further input ? :)
Thank you,
Cheers,
- Wernaeh












