Advertisement Jump to content
Sign in to follow this  
RobMaddison

Bounding box transforms

This topic is 1902 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 was just wondering about bounding boxes and the best way to keep track of them in terms of the transformation of the object they are bounding.

When I add a mesh to my world, I currently just create a bounding box from the local extents of the mesh (at some point this will obviously be pre-computed). When I come to frustum cull this bounding box, should I transform it by the same transform that the object has? Only that's 8 extra transforms. I can't move the box to fit around the world positions of the object as that would obviously be too slow.

Share this post


Link to post
Share on other sites
Advertisement

Why would it be slow? Transforming a mesh of 8 coordinate-only vertexes is negligible, and it would 'move the box to fit'. More importantly, why are you doing frustum culling manually?

Edited by Khatharr

Share this post


Link to post
Share on other sites

Eh? My mistake, the platform I learned on had hardware culling, but poking around it looks like that's not present in DX or OGL. That actually surprises me, since the GPU could easily optimize it so well, though it does mean that you have to run everything across the bus.

 

Anyway, just running a cube through a transform is really very lightweight. Possibly you could do a point/radius test by applying your scale to your radius and then just translating the center point, but if you do any uneven scaling or shearing then that wouldn't work.

Share this post


Link to post
Share on other sites

You'd have to get the data back from the GPU as well, unless you sent all the vertices to be transformed across the bus, which frustum culling is trying to avoid. GPUs work best by being given a lot of data to operate on with no branching. The most extreme example of that was on the PS2 where the GPU didn't like back face culling, it was usually quicker to draw everything double sided than check for back faces ;)

Share this post


Link to post
Share on other sites
I think I've kind of answered my own question, but thanks for the replies. I've never heard of frustum culling on the GPU either - you're not confusing it with clipping are you? That happens on the GPU

Share this post


Link to post
Share on other sites

Talking to seg in the chat, realized that I was thinking about clipping rather than culling. My bad.

 

Edit: ninja'd again. lol

Edited by Khatharr

Share this post


Link to post
Share on other sites

In a normal setup you have a source object/model which is then shared by all the instances of that model in the game world.

The shared model will have the base bounding box and bounding sphere and each instance will have its own copy, updated when that object’s transform changes, to reflect its real world bounding box.  As few objects in a game scene actually move this is not very expensive.

 

Frustum culling is then done on the transformed bounding boxes as they are.

 

 

L. Spiro

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!