# cube frustrum test

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

## 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 on other sites
Maybe this can give you some inspiration flipcode - octrees for visibility (frustum culling with octrees).

##### Share on other sites
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 on other sites
Got it... fixing code now...

##### 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 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 on other sites
I will optimize it to reduce traversal time, but later, im still only wanting to keep it simple. thanks.

1. 1
2. 2
Rutin
20
3. 3
khawk
16
4. 4
A4L
14
5. 5

• 11
• 16
• 26
• 10
• 11
• ### Forum Statistics

• Total Topics
633756
• Total Posts
3013707
×