Sign in to follow this  
Mikeske

Quadtree Culling

Recommended Posts

I'm trying to setup a quadtree like terrain-loader like on codeplex's site (http://www.codeplex.com/quadtreeload) The main thing is that I would like to use the XNA-BoundingFrustum What i do is: See if the root node is visible, if so, check each of its children which in case, check thier childs. With this I'm reducing the workload, If parent isn't visible then childs aren't either: if the main update sequennce of the terrain:
           
 m_Frustum = new BoundingFrustum(viewproj);
 //try culling away stuff of the terrain here...
 if (m_root != null)
       m_root.TryCull(m_Frustum);

Trycull in case is a recursive function which does nothing more then:
  
           switch (_frustum.Contains(new BoundingBox(new Vector3(this.m_startX, m_startY, m_minHeight), new Vector3(m_endX, m_endY, m_maxHeight))))
            {
                case ContainmentType.Disjoint:
                    //box is outside frustum
                    {
                        m_visible = false;
                    }
                    break;
                case ContainmentType.Intersects:
                    //the box intersects the frustum
                case ContainmentType.Contains:
                    //the box is inside the frustum
                    {
                        m_visible = true;
                    }
                    break;
            }

            //now if needed checks childs
            if (m_visible == true)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (m_child[i] != null)
                        m_child[i].TryCull(_frustum);
                }
            }

In some parts of the terrain, terrain objects dissapear, totally disappear and re-appear... What does the BoundingFrustum.contains(...) returns if the frustum is totally inside the boundingbox of the terrain-section? hopefully some ppl can shed some light on my problem and help me out. Thx Mike

Share this post


Link to post
Share on other sites
I have absolutely the same problem as you and just wanted to open almost the same thread. I also use the BoundingFrustum and BoundingBox classes from XNA.

I can verify my BoundingBoxes are correct. Here's a screenshot which shows the BoundingBoxes that are detected as not visible (ContainmentType.Disjoint):

As you can see they are clearly inside the frustum.
The BoundingFrustum is just the normal new BoundingFrustum(matrixView * matrixProjection)

[Edited by - FoxHunter2 on August 7, 2007 6:00:59 AM]

Share this post


Link to post
Share on other sites
Hey foxhunter,

Thx for the reply, I hardly can't believe that we are the only one having this problem...
So ppl please some reaction on this problem, where are the whizz-programmers on gamedev who can shed some light on the problem or give a possible solution which I/we could try.

Foxhunter, maybe something can clear things out for you, they mention the thing I said about the box being totally bigger then the frustum at:

solution thread???
If you see an answer plss get back to me about the matter ok?!

Greetz
Mike

Share this post


Link to post
Share on other sites
I already saw this thread, but I don't think this is the problem here (at least not in my case). You can see that only partially some patches get culled, which makes no sense.

You could reopen this thread over at http://forums.xna.com/, this is the official and most active XNA forum with some XNA officials being active.
I don't have an account there yet, but I will reply to this thread when I create an account.

regards

Share this post


Link to post
Share on other sites

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