okidoki, I see why my idea was somewhat unlogical.
if I use pointer swapping, it gets very messy for the user.
copying is much nicer.
for anyone willing to work with block (note: block != voxel) coordinates, try out my fork of polyvox.
https://gitorious.org/~ker/polyvox/kers-polyvoxIt's as simple as manually looping over all the voxels in a block and writing them to the other block. I'm sure a memcopy would work, but maybe not for all voxel types.
my setup is the following:
a mutex to protect the volume.
a second volume inside the thread.
whenever I want to render some part, I copy all the blocks touching that part and that have been modified since the last rendering to the second volume (and locking the first volume the entire copying time).
the copying takes less than one ms for 32^3 blocks in debug mode.
There is an untested function for people who want to use regions instead of block coordinates. But it only works for regions that are aligned to block borders.
I attached a not yet cleaned up or commented version of my ThreadedVolume class to this post. it has no dependencies except for boost, PolyVox (obviously
), and some PolyVox Helpers of mine (also attached)
I hope the interface is self explanatory, otherwise, just ask