eeeeh, yes
I'd be happy to supply my streamed volume, but FIRST I gotta clean up that code, I am just starting to use somewhat proper variable naming (again)... + I forgot many probably useful comments
Shanee wrote:
So wait, did you make it that a hash map of coordinates each has a block of voxel data which can be loaded and unloadted from stream? does it update just one volume for it all? *confused*
the following three lines are my changes to the interface of Volume. (and lots of stuff removed that was just useful for boundaries, sorry no getEnclosingRegion anymore)
Code:
boost::function<void(Vector3DInt64, Block<VoxelType>&) > loadBlock;
boost::function<void(Vector3DInt64, const Block<VoxelType>&) > unloadBlock;
mutable std::unordered_map<PolyVox::Vector3DInt64, Block<VoxelType> > m_pBlocks;
now... m_pBlocks is empty at creation of the Volume.
there's seriously nothing in there, not even empty blocks.
you are allowed to register your own loadBlock and unloadBlock functions (using boost::bind, if this is an issue due to dependencies on boost, I can modify this to some messy pointer arithmetic)
also unordered_map is only in c++0x
anyway, loadBlock is called, when you try to access (set/getVoxel) a nonexisting/not_yet_loaded block.
it gives you a block reference which you can fill with your own data if you wish and a Vector3DInt64 which is the position of the Block in Block-coordinates (shift this by your Block-sidelength to get Volume coordinates)
if you don't set a loadBlock function, the default is used, which is filling the block with VoxelType().
unloadBlock works almost the same... you get block coordinates so you know where this block belongs and you get the Block to somehow extract the data from and save however you want. doing nothing in the unloadBlock function causes the data to be lost.
unloadBlock is called whenever the size of the unordered_map reaches some threshhold. least recently used then decides which block to drop.
and behind all that there's still all the compression working without any problems
(un)loadBlock always gets an uncompressed block, so no worries there...