Sign in to follow this  

DirectXCollision BoundingFrustum usage?

This topic is 1445 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 got my DirectXMath-using camera to compute view and projection matrices properly, however when using DirectXCollision structures I ran into some problems.When I frustum cull, everything is always culled away.Here is what I do:

-Build a projection matrix
-Build a frustum from that projection matrix with BoundingFrustum::CreateFromMatrix
-Transform the frustum by the view matrix that is generated each frame

-Each screen object has a BoundingSphere that is transformed by it's world matrix each frame

-Each frame I test if entities intersect frustum and if they don't, they aren't rendered.

Is this the proper usage?

Share this post


Link to post
Share on other sites

Would be faster and more reliable to extract from the view-projection matrix directly rather than transforming the frustum by the view matrix.

 

Otherwise if your objects are not being drawn then you need to use a debugger and verify the bounding spheres etc.  You should create a test case in which it is clear when an object is inside, colliding with, or outside the frustum.  If the return values are always exactly opposite then the normals on your frustum are reversed (but I don’t know how that could happen if you only use their math functions).

 

 

L. Spiro

Share this post


Link to post
Share on other sites

If you define the view matrix as the inverse of the camera’s world matrix, then passing the projection matrix to BoundingFrustum::CreateFromMatrix() and transforming that by the view matrix is the same as just calling BoundingFrustum::CreateFromMatrix() with the view-projection matrix except a million times slower.  I would call BoundingFrustum::CreateFromMatrix() on the view-projection matrix just for stability more than anything, since that is what is generally used to create a frustum from a matrix.

 

 

If you want to eliminate that as a factor, why don’t you keep the camera on identity and move the objects around?

 

 

L. Spiro

Share this post


Link to post
Share on other sites

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