Multiple Linepicks?

Blitz3D Forums/Blitz3D Programming/Multiple Linepicks?

Cubed Inc.(Posted 2014) [#1]
This may be either a very reasonable question or a very stupid one: is it possible to have more than one linepick?


Kryzon(Posted 2014) [#2]
You can call any of the pick commands, LinePick included, any number of times.
But too many calls to these can slow your program down, especially if you have a scene with lots of objects and if these objects have complex geometry.

EDIT: Also be aware that each LinePick will overwrite the contact data of the last call to it.


RemiD(Posted 2014) [#3]
There are some tricks to do many linepicks without producing too much slowdown :

Each pickable must be a low tris mesh. (has the minimum number of tris possible)

For each mesh that you want to be able to pick, calculate a max radius (depending on if the width or the depth of the mesh is the maximum, calculate the diagonal/2)
Then instead of doing a linepick against all meshes of the world
Set all meshes to not pickable entitypickmode(mesh,0)
Then calculate which meshes are near enough the start point of the linepick, depending on the length of the linepick, and the radius of the mesh you want to be able to pick.
if the mesh is near enough
consider this mesh
set this mesh as pickable entitypickmode(mesh,2)
if the mesh is too far
don't consider this mesh
then do the linepicks one at a time
if the linepicks have not a great length, the calculation will be very fast because there will be only a few low tris pickables to consider each time.
I have done as much as 90x10 = 900 linepicks per frame in less than 20ms with this approach.

Another tip is to specify a bigger radius. This decreases the number of linepicks you have to do.


dynaman(Posted 2014) [#4]
I've done it. I wanted to know EVERYTHING a line would point to, so I did a linepick and excluded whatever is picked and then do another linkepick, etc...

I turned it into a function call linepickall, lost track of it many years ago but the basics are simple enough to write it in half an hour or so.


Yue(Posted 2014) [#5]
Is it possible to hook a camera linepick ?, ie where the line pointing at the camera.


Stevie G(Posted 2014) [#6]
See command 'CameraPick'.


Yue(Posted 2014) [#7]
Stevie G, distance on cameraPick?


Guy Fawkes(Posted 2014) [#8]
Yue, it doesn't use a distance, you can basically pick anything close OR far away from you as long as it is in view.

Like so:

picked = CameraPick(camera, MouseX(), MouseY())



Yue(Posted 2014) [#9]
Therefore I would hitch a linepick to the camera, but it seems impossible, because with a line have a chance to set the distance of the line.


Stevie G(Posted 2014) [#10]
If you want the line to have a specific distance use ...

Tformvector 0,0,LengthOfLine, CameraEntity, 0

LinePick EntityX( CameraEntity , 1 ), EntityY( CameraEntity, 1 ), EntityZ( CameraEntity, 1 ), Tformedx(), Tformedy(), Tformedz()



Yue(Posted 2014) [#11]
Stevie G, Thanks You =)


Blitzplotter(Posted 2014) [#12]
This is good stuff, might be playing with a bit of linepicking maself tomorrow!