I extracted the relevant parts of my POLY2KVX code and cleaned it up for you. This should give you an idea of how my hash code works:
#define MAXDIM 1024
#define MAYDIM 1024
#define MAZDIM 512
#define LHASHHEAD 20
long hashhead[1<<LHASHHEAD];
typedef struct { long prev, ind, val; } hash_t;
hash_t *hash;
long getval (long ind)
{
long i = ((ind>>8) & ((1<<LHASHHEAD)-1));
for(i=hashhead[i];i>=0;i=hash[i].prev)
if (hash[i].ind == ind) return(hash[i].val);
return(-1);
}
//Example call: (setval function not shown)
long value_at_xyz = getval((x*MAYDIM + y)*MAZDIM + z);
I chose a very large hash head size (1048576 indices) so it would be fast enough for large objects.
Why the (x,y,z) coordinate is a 28-bit size?
You need exactly 28 bits to specify an index into a Voxlap-sized array. Voxlap boards are always: 1024x1024x256. (log2(1024)+log2(1024)+log2(256) = 28).
Does POLY2KVX converts meshes that arent "closed"?
Yes, they work, but their interior of the object will be hollow. My normal estimation code isn't designed for hollow objects with thin surfaces, so that's why the colors look terrible when you load it in SLAB6. If you press 'R' to disable lighting, it will look a little better.