Most efficient Picking Method

Started by
6 comments, last by Paradigm Shifter 10 years, 5 months ago

I am curious as to what is the most efficient picking method. Currently I render all the objects of the screen assigning each a different color and then what ever color is under the mouse during picking is the object that is then selected. I have also heard if i change the size of the screen during picking to be just a little larger then the mouse and then drawing the screen right under the mouse during the picking pass helps with the efficiency as well. Also is casting a ray more efficient then doing a render pass for handling picking? Any thoughts on this would be pure awesomeness thanks biggrin.png

J-GREEN

Greenpanoply
Advertisement

Chances are casting a ray is way more efficient than rendering everything in the scene, because you can think of casting a ray as the equivalent of rendering a 1x1 pixel window. But the answer probably depends on the type of scene you have, if you have a reasonable space-partitioning structure available...

So the answer is "only testing can tell", which is the answer to every "most efficient" question.

I guess my question would be then which scenarios is one better then the other?

J-GREEN

Greenpanoply

Ray-casting combined with some sort of spatial subdivision structure (like a quad-tree) is typically going to be the most performant method of picking, albeit significantly more complex to implement than your current solution.

There are a couple of cases that rendering-based methods do very well at, and are simultaneously very hard to handle with ray-casting:

- Picking partially transparent (alpha-blended) objects.

- Picking non-manfold objects, or objects with holes in them (i.e. clicking on the centre of a donut).

But as with most efficiency questions, the real question is "efficient enough for what?". Is your current approach causing you performance problems?

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Why would picking an object with an hole in it be easier with rendering? Surely the raytrace method is going to boil down to ray vs. tri anyway eventually, you'll just get a false positive with a bounding box first.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley


Why would picking an object with an hole in it be easier with rendering? Surely the raytrace method is going to boil down to ray vs. tri anyway eventually, you'll just get a false positive with a bounding box first.

You really don't want to go all the way to ray-triangle intersections.

As soon as you do that, you've lost any efficiency benefit you might have had over the rendering method, plus you have to keep copies of all your geometry in main memory...

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

My current method is working just fine. I was just curious to know what other thought of the matter.

J-GREEN

Greenpanoply

Mmkay. I wouldn't call it "very hard" though ;)

The rendering method has the advantage that not much code has to be written and you can usually do it with a hardware query anyway. You can only pick one pixel at a time with a mouse, so it doesn't have to be super fast.

But it is worth thinking about how to do efficient raycasts since you want to do those for AI or collision. But if you use a Physics library do raycasts with that instead.

"Most people think, great God will come from the sky, take away everything, and make everybody feel high" - Bob Marley

This topic is closed to new replies.

Advertisement