Fastest way to do point search?

Blitz3D Forums/Blitz3D Programming/Fastest way to do point search?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I would make a an array and for each element in the array, create an empty bank:

pointres = 100
Dim PointMap(pointres,pointres,pointres)
For x=0 to pointres
for y=0 to pointres
for z=0 to pointres
PointMap(x,y,z)=CreateBank()
next
next
next

Then I would be able to place the camera coordinates into this position with relative ease:

x=Entityx(camera)/pointres
y=Entityy(camera)/pointres
z=Entityz(camera)/pointres

Then this returns a bank handle... the bank is a linear list of points in that zone. These could be entityhandles if you are using pivots, or just coordinates.

then what we do is search -1 to 1 from the camera.
For x-1 to x+1
for y-1 to y+1
for z-1 to z+1
compare points
next
next
next

This would probably mean you only ever need to compare 3 or 4 points at a time. It's stupidy fast no matter how many points you have in your clouds. The only thing that will slow it down is the density. You speed it up easily by using only a little more ram by increasing your pointres value.

I did this back when I was doing occlusion. Not highly mathematical because I seriously doubt maths is needed here as they don't move: an elegent lookup table is the answer.