Jump to content
  • Advertisement
Sign in to follow this  
rouncED

cube frustrum test

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

Whats the general way someone with an octree and a view frustrum (consisting of planes) tests if an axis aligned cube is inside the frustrum. At the moment ive quickly written a corner testing algorythm, which tests the 8 corners with what side of the planes they are on, but if the octree node is large enough the frustrum could be contained within it, but the corners would all be tested as outside - and im kinda stuck. Whats the solution? thanks...

Share this post


Link to post
Share on other sites
Advertisement
If there exists a frustum plane for which each bbox vertex is outside, you now that the whole bbox is outside of the frustum.

From there you can carry on knowing that at least a portion of the bbox is inside or you can check if your bbox is on the inside of EVERY frustum plane (completely contained)

Share this post


Link to post
Share on other sites
Quote:
If there exists a frustum plane for which each bbox vertex is outside, you now that the whole bbox is outside of the frustum.
There's actually a much more efficient method than the above. Instead of testing each of the box corners individually, you compare the distance from the box center to the plane to the projected box radius (with respect to the plane normal).

It sounds a little complicated, but it basically reduces to two dot products and one conditional (whereas the per-corner method requires 8 dot products and 8 conditionals). Another solution is the 'n-vertex and p-vertex' method, although my guess is that the simple projection method is probably more efficient.

If you can't find any references on this method, I can post some pseudocode.

[Edit: It looks like the article linked to earlier uses the 'n-vertex and p-vertex' method.]

Share this post


Link to post
Share on other sites
Frustum culling is awesome.

@rouncED: If it's actually a cube, you could probably get away with approximating it as a sphere, couldn't you? I read somewhere that the sphere test is much easier than the AABB test.

Also, listen to jyk. He probably knows what he's talking about.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!