I have a C++ raycaster, which inserts millions of points into a range of (-1,-1,-1) to (1,1,1). To avoid inserting duplicate points into the vertex buffer i want to check if a certain range already holding a point.
Thats how i setup my grid:
const int size = 500 * 500 * 500;
bool *grid = new bool[size];
for(int i = 0; i < size; i++)
grid[i] = false;
unsigned double divide = 2.0 / size;
Now i want to check intersection points to add:
// In my code i handle negative and positive cases
int x = intersection.X / divide;
int y = intersection.Y / divide;
int z = intersection.Z / divide;
if(!grid[x * y *z])
//insert
else
//discard
The problem iam facing is that divide is always 0, because size is too high. But i can't get how i can solve that. Iam already using unsigned double for.