posted January 17, 2000 10:52 AM
I can tell you how my code is arranged, and how I'd modify it if I did it again..I have two classes, the Landscape Class, and the Patch Class.
Landscape is just a means to hold a large square block of the Height Map (from 512->2048 units square have been tested). It keeps a two dimentional array of Patch objects, a pointer to a dynamicly allocated Height Map array and some other junk.
It is not built for infinite tiling like the Tread Marks engine, so if you want this feature, a dynamically allocated Patch array would be more useful here.
For that, you'd allocate patches which are offset from the camera eye to cover everything the player might see that frame. In the case of Tread Marks, I believe this is a 16x16 grid of patches for 1000m visibility.
The Patch class keeps two TriTreeNode structs. These are not dynamically allocated to the patch but rather owned by the object itself. Each Patch object also keeps two variance trees in the form of an array (see a previous post by Seumas about Implicit Binary Trees and how to use them).
The TriTreeNode struct is a basic C structure with five pointers. The Landscape class keeps a static pool of these structures (lots, like 20,000+ of them) as well as a static allocator function for them. This way a Patch can ask the Landscape class to give it a new TriTreeNode off the pool instead of having the system dynamically allocate it (which can fragment memory).
If I were to rewrite this part, I would introduce a BinTriTree class to encapsulate the TriTreeNode stuff and move it out of the Patch class. This would eliminate a useless 'current tree' variable that my code needs to keep track of which tree it's in.
Hope that helped it's early for a Monday... Feel free to ask if you would like more info. My code will be released within a month and is well documented.
--Bryan