Sign in to follow this  

Who is responsible for scene picking?

This topic is 2657 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

Working in opengl, I am currently working on color picking with glReadPixels. And i have problems deciding who is responsible for calling the pick() function and who should decide what unique values to use for each entity in the scene.

What is the case usually?

-- MORE INFO --
I have a IGraphics interface which essentially is a wrapper for the underlying API i.e. opengl. IGraphics wraps stuff like glDrawElements, SwapBuffers, ReadPixels etc.

currently I have a Renderer::Render() which gets called in the idle loop:


Renderer::Render()
{
// bunch of IGraphic calls.
for (each entity in Scene)
{
...
_mIGraphics->DrawBuffers();
}
...
_mIGraphics->SwapBuffers();
}



Should I also let Renderer do the picking? Other candidates include the Scene object, but then I will have to share the IGraphics object which is currently contained in an inner-class inside Renderer... that is bad.

Share this post


Link to post
Share on other sites
I think the question should be, what is the purpose of the picking, and which class cares most about that purpose? Are you doing it for some process the renderer manages? Or one the scene manages? All things being equal, any functionality should be located closest to the other functionality it's most closely related to. Simple naive test: which class accesses the data generated by picking the most.

Share this post


Link to post
Share on other sites
It really depends on your overall architecture and how things would most naturally fit. From what you've described it sounds like Renderer makes the most sense for containing the picking logic, at least at a low level; you might consider wrapping that in a higher level interface as well for clean separation in case you want to rework your picking methodology later (e.g. if you decide to do picking via a physics library and a raycast, such as Bullet).

Share this post


Link to post
Share on other sites
I guess if you are doing color picking it would be somewhere in the renderer. You will also need access to GUI elements, since you need pick those as well. Also, if you pick a GUI element during a frame, then you should not also simultaneously pick a world object that happens to be behind that GUI element.

Share this post


Link to post
Share on other sites

This topic is 2657 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this