Defining region bounds for mesh extraction is entirely arbitrary. In my case I have my world broken up into a series of 32^3 cubes, which I use for both paging and mesh extraction. To manage extraction and paging in different threads, you will need to do a bit more work yourself.
Eg in my code, my paging thread checks the cameras position and determines which chunks should be active based on view distance. If those chunks are not allocated, it flags them as needing to be allocated/loaded. The list of chunks needing allocation is checked by another allocation/loading management thread, which interacts with polyvox to allocate the necessary blocks, then uses setVoxel so set voxel data, and finally marks the chunks as active for extraction. I use listeners to alert the mesh manager that updates are required whenever a chunk is set active, or voxel data changed. Finally a mesh management thread checks the update list, extracts the meshes required, and attaches them to the scene using the ogre scene manager.
All of those classes address chunks with 3d int vector, and since chunk size is constant, the region to extract, coordinates of node to attach the mesh etc are easy to calculate and consistent. Eg for chunk 0,0,0 I extract region 0,0,0 to 31,31,31. Or for chunk 10,10,10 I extract region 320,320,320 to 351,351,351 for example. Keep in mind vertex coordinates are relative to the lower bounds of the region, so the scene node the mesh attaches to also needs to have same coordinates as minimum bounds of the extraction region. Your coordinat system will have to change a bit if you are using 2D paging (which most people seem to be?), whereas I page in 3 dimensions.
This might not make much sense, it is a simplifcation of what I really use. My pager tracks multiple positions simultaneously, and I actually have a VolumeManger, ChunkManager, MeshManager, Pager, VoxelDataLoader, VoxelGenerator, GarbageManager, and I run 6 threads, not 3. Also I use dedicated threads, not task based threading. So I might have screwed up my explanation a bit.
|