Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

.x file: How to use loops to traverse the tree structure

This topic is 1127 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 probably cannot get the number of children within that structure.

I mean the hierarchy because it isn't a member variable in the D3DXFRAME structure.

I sometimes would want to iterate a lot of frames, Is it an absolute thing to do it by recursion,

because I am getting stack overflows. I got about 50000 custom frames, so the C++ program cannot hold

that many frames on the stack by recursion, which is quite unsatisfactory.

Any ideas I can work around this?

Thanks

Jack

Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement
Don't know XNA nor directX, but the general strategy to avoid recursion is to have a 'notdone' list, a list of nodes you still have to visit.

while (!notdone.is_empty()) {
    node = notdone.pop(); // Get one of the nodes.
    // Do something with 'node'
    for (Node child : node.childs) { // Add childs to the 'notdone' list.
        notdone.append(child);
    }
}

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!