Sign in to follow this  
m4gnus

Problem with my Scenegraph tree

Recommended Posts

Hi, First sorry for the very general subject, but i didn't how how to describe my problem in that short subjetc line. I have a design problem(i haven't been programming for abou 2 months just because of design probs) with my scenegraph(a simple tree): I want to store the traversed form of the tree(a std::list of nodes) somewhere(atm it's stored with the root of the tree) and i thought it would be faster to update that list when adding a node to the tree and not building the list every frame from scratch. Now i have some problems with that approach. I thought i simply store an iterator for the list in every node, and when adding a children to a node it can just add itself at the right position in the list,as it has the iterator of its parent(and the iterator for its siblings). But that would mean i would be restricted to building the tree from the top(root) down(leaves) and i have to pay special attention in what order i add children to nodes. This introduces potential bug sources and is not good design(is it?). So should i just build the list from scratch each frame? or update it everytime something changes. If later: how can i accomplish that? i hope i made clear what i want. thanks in advance. regards, m4gnus

Share this post


Link to post
Share on other sites
Sounds like you've fallen victim to premature optimization.

Neverminding any hackish issues with updating a traversal list, why bother with the traversal list instead of just traversing your tree? Are you dealing with tens of thousands of tree nodes?

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