From a91ff9a10fbfa8f833ffc6adb4664ca34889111a Mon Sep 17 00:00:00 2001 From: David Williams Date: Fri, 19 Jun 2009 21:02:44 +0000 Subject: [PATCH] Made sure all Thermite stuff is in the Thermite namespace. --- library/PolyVoxUtil/source/Serialization.cpp | 42 +++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/library/PolyVoxUtil/source/Serialization.cpp b/library/PolyVoxUtil/source/Serialization.cpp index 65df4c75..1a36c017 100644 --- a/library/PolyVoxUtil/source/Serialization.cpp +++ b/library/PolyVoxUtil/source/Serialization.cpp @@ -30,18 +30,31 @@ namespace PolyVox //Read data for(uint16_t z = 0; z < volumeDepth; ++z) { + //Update progress once per slice. + if(pCallback) + { + float fProgress = static_cast(z) / static_cast(volumeDepth); + pCallback(fProgress); + } + for(uint16_t y = 0; y < volumeHeight; ++y) { for(uint16_t x = 0; x < volumeWidth; ++x) { uint8_t value = 0; stream.read(reinterpret_cast(&value), sizeof(value)); - + volume->setVoxelAt(x,y,z,value); } } } + //Finished + if(pCallback) + { + pCallback(1.0f); + } + return volume; } @@ -64,6 +77,13 @@ namespace PolyVox VolumeSampler volIter(&volume); for(uint16_t z = 0; z < volumeDepth; ++z) { + //Update progress once per slice. + if(pCallback) + { + float fProgress = static_cast(z) / static_cast(volumeDepth); + pCallback(fProgress); + } + for(uint16_t y = 0; y < volumeHeight; ++y) { for(uint16_t x = 0; x < volumeWidth; ++x) @@ -74,6 +94,12 @@ namespace PolyVox } } } + + //Finished + if(pCallback) + { + pCallback(1.0f); + } } //Note: we don't do much error handling in here - exceptions will simply be propergated up to the caller. @@ -136,6 +162,7 @@ namespace PolyVox { pCallback(1.0f); } + return volume; } @@ -161,6 +188,13 @@ namespace PolyVox bool firstTime = true; for(uint16_t z = 0; z < volumeDepth; ++z) { + //Update progress once per slice. + if(pCallback) + { + float fProgress = static_cast(z) / static_cast(volumeDepth); + pCallback(fProgress); + } + for(uint16_t y = 0; y < volumeHeight; ++y) { for(uint16_t x = 0; x < volumeWidth; ++x) @@ -192,5 +226,11 @@ namespace PolyVox } stream.write(reinterpret_cast(¤t), sizeof(current)); stream.write(reinterpret_cast(&runLength), sizeof(runLength)); + + //Finished + if(pCallback) + { + pCallback(1.0f); + } } } \ No newline at end of file