Jump to content
  • Advertisement
Sign in to follow this  
pressgreen

Most efficient Picking Method

This topic is 2076 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Edited by greenzone

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites


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...

Share this post


Link to post
Share on other sites

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.

Edited by Paradigm Shifter

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!