Make TPick.Pick() respect entity order

BlitzMax Forums/MiniB3D Module/Make TPick.Pick() respect entity order

ima747(Posted 2009) [#1]
I'm using a bunch of camera picks in my project for the user to interact with various objects. Some are at different EntityOrders since they are HUD's etc. and tracking their scaling and motion would just be a nightmare so I just make the order under 0 and move them away a bit. This looks right (more or less) however picking doesn't respect orders, it just cycles the list of entity's and finds the closest thing that hits, but since closest and on top are two different things it often grabs the wrong thing.

Can someone give me a point in the right direction for how I might go about this? it looks like I either needs to find a way to break each order set into it's own list and cycle lowest to highest (really bad idea), keep picking through everything then sort that list by entity order lowest to highest, or do some poking in C_Pick... and I can only see that ending in tears...

Thoughts?


Sledge(Posted 2009) [#2]
Telling you the first thing hit by a ray is exactly what a pick is! For a layered system I would set up a second camera specifically for rendering and picking (child) HUD elements -- squirrel 'em away at some desolate coordinate, set the camera's cls mode appropriately (so rendering the HUD does not obliterate the main scene render) and off you go.


*(Posted 2009) [#3]
simply make the hud unpickable when you want to pick the rest.


ima747(Posted 2009) [#4]
the problem I'm facing is that "the rest" are getting picked ahead of the hub. Perhaps I'm not explaining myself well, and perhaps re:sledge's response it's a bug...

I have a HUD element 10 ahead of the camera on the z axis, it's entity order is -1 so it is drawn on top of normal things no matter it's depth. It's depth is used for size because scaling it would be troublesome for other reasons. This element picks fine normally, or if things are behind it (depth > 10).
I have a normal entity passing 2 ahead of the camera with an entity order of 0. since the hud is -1 the hud is drawn on top, however if I try to click the hud element with the normal entity in position I get the entity (depth 2 despite the entity order) and not the hud element.

This is either a bug in the ray cast for the pick (it doesn't respect entity order, only distance) or it's working as intended which doesn't make sense to me so I need a work around.


Sledge(Posted 2009) [#5]
Picks tell you which object they hit first, which will be the closest, which has nothing to do with the order you've opted to render them. A pick has no concept of the full stack of objects in front of it -- if it did, picking would be very costly rather than just costly! If it's not already clear, I'm saying this isn't a bug. Seriously, a dedicated HUD camera is the most elegant way to achieve what you want.


ima747(Posted 2009) [#6]
I follow now, I was misunderstanding your previous post.

Off to camera #2 land for me.


Sledge(Posted 2009) [#7]
Thought you might've got the wrong end of the stick. Here's some decidedly inelegant code I whipped up as an example... it includes a few different ways of doing things hence the chaos. :D




ima747(Posted 2009) [#8]
Thanks sledge, I think I can dig through that. I used 2 cams once a long long time ago but having an example on hand is going to save a lot of time :0)