diff --git a/include/Block.h b/include/Block.h index 6ee8147b..29e3e66b 100644 --- a/include/Block.h +++ b/include/Block.h @@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef __Block_H__ #define __Block_H__ -#include "OgrePrerequisites.h" +#include "boost/cstdint.hpp" #include "Constants.h" @@ -43,13 +43,13 @@ namespace Ogre //bool isHomogeneous(void); - uchar getVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition) const; - void setVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition, const uchar value); + boost::uint8_t getVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition) const; + void setVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition, const boost::uint8_t value); - //void fillWithValue(const uchar value); + //void fillWithValue(const uint8_t value); private: - uchar mData[OGRE_NO_OF_VOXELS_IN_BLOCK]; + boost::uint8_t mData[OGRE_NO_OF_VOXELS_IN_BLOCK]; }; } diff --git a/include/Constants.h b/include/Constants.h index de0b5ad2..c2cdf890 100644 --- a/include/Constants.h +++ b/include/Constants.h @@ -1,25 +1,27 @@ #ifndef __Constants_H__ #define __Constants_H__ +#include "boost/cstdint.hpp" + namespace Ogre { //FIXME - i think we can define mod using a bitmask which flattens the upper bits. Should define that here. - const unsigned int OGRE_BLOCK_SIDE_LENGTH_POWER = 5; - const unsigned int OGRE_BLOCK_SIDE_LENGTH = (0x0001 << OGRE_BLOCK_SIDE_LENGTH_POWER); - const unsigned int OGRE_NO_OF_VOXELS_IN_BLOCK = (OGRE_BLOCK_SIDE_LENGTH * OGRE_BLOCK_SIDE_LENGTH * OGRE_BLOCK_SIDE_LENGTH); + const boost::uint32_t OGRE_BLOCK_SIDE_LENGTH_POWER = 5; + const boost::uint32_t OGRE_BLOCK_SIDE_LENGTH = (0x0001 << OGRE_BLOCK_SIDE_LENGTH_POWER); + const boost::uint32_t OGRE_NO_OF_VOXELS_IN_BLOCK = (OGRE_BLOCK_SIDE_LENGTH * OGRE_BLOCK_SIDE_LENGTH * OGRE_BLOCK_SIDE_LENGTH); - const unsigned int OGRE_VOLUME_SIDE_LENGTH_POWER = 8; - const unsigned int OGRE_VOLUME_SIDE_LENGTH = (0x0001 << OGRE_VOLUME_SIDE_LENGTH_POWER); - const unsigned int OGRE_VOLUME_SIDE_LENGTH_IN_BLOCKS = (OGRE_VOLUME_SIDE_LENGTH >> OGRE_BLOCK_SIDE_LENGTH_POWER); - const unsigned int OGRE_NO_OF_BLOCKS_IN_VOLUME = (OGRE_VOLUME_SIDE_LENGTH_IN_BLOCKS * OGRE_VOLUME_SIDE_LENGTH_IN_BLOCKS * OGRE_VOLUME_SIDE_LENGTH_IN_BLOCKS); - const unsigned int OGRE_NO_OF_VOXELS_IN_VOLUME = (OGRE_VOLUME_SIDE_LENGTH * OGRE_VOLUME_SIDE_LENGTH * OGRE_VOLUME_SIDE_LENGTH); + const boost::uint32_t OGRE_VOLUME_SIDE_LENGTH_POWER = 8; + const boost::uint32_t OGRE_VOLUME_SIDE_LENGTH = (0x0001 << OGRE_VOLUME_SIDE_LENGTH_POWER); + const boost::uint32_t OGRE_VOLUME_SIDE_LENGTH_IN_BLOCKS = (OGRE_VOLUME_SIDE_LENGTH >> OGRE_BLOCK_SIDE_LENGTH_POWER); + const boost::uint32_t OGRE_NO_OF_BLOCKS_IN_VOLUME = (OGRE_VOLUME_SIDE_LENGTH_IN_BLOCKS * OGRE_VOLUME_SIDE_LENGTH_IN_BLOCKS * OGRE_VOLUME_SIDE_LENGTH_IN_BLOCKS); + const boost::uint32_t OGRE_NO_OF_VOXELS_IN_VOLUME = (OGRE_VOLUME_SIDE_LENGTH * OGRE_VOLUME_SIDE_LENGTH * OGRE_VOLUME_SIDE_LENGTH); - const unsigned int OGRE_REGION_SIDE_LENGTH_POWER = 4; - const unsigned int OGRE_REGION_SIDE_LENGTH = (0x0001 << OGRE_REGION_SIDE_LENGTH_POWER); - const unsigned int OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS = (OGRE_VOLUME_SIDE_LENGTH >> OGRE_REGION_SIDE_LENGTH_POWER); - const unsigned int OGRE_NO_OF_REGIONS_IN_VOLUME = (OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS * OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS * OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS); + const boost::uint32_t OGRE_REGION_SIDE_LENGTH_POWER = 4; + const boost::uint32_t OGRE_REGION_SIDE_LENGTH = (0x0001 << OGRE_REGION_SIDE_LENGTH_POWER); + const boost::uint32_t OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS = (OGRE_VOLUME_SIDE_LENGTH >> OGRE_REGION_SIDE_LENGTH_POWER); + const boost::uint32_t OGRE_NO_OF_REGIONS_IN_VOLUME = (OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS * OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS * OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS); - const unsigned long OGRE_MAX_VOXELS_TO_BURN_PER_FRAME = 1000; + const boost::uint32_t OGRE_MAX_VOXELS_TO_BURN_PER_FRAME = 1000; } #endif diff --git a/include/IndexedSurfacePatch.h b/include/IndexedSurfacePatch.h index 56c75f50..7a420ba5 100644 --- a/include/IndexedSurfacePatch.h +++ b/include/IndexedSurfacePatch.h @@ -1,6 +1,8 @@ #ifndef __IndexedSurfacePatch_H__ #define __IndexedSurfacePatch_H__ +#include "boost/cstdint.hpp" + //#include //#include @@ -21,10 +23,10 @@ namespace Ogre ~IndexedSurfacePatch(); void addTriangle(const SurfaceVertex& v0,const SurfaceVertex& v1,const SurfaceVertex& v2); - void fillVertexAndIndexData(std::vector& vecVertices, std::vector& vecIndices); + void fillVertexAndIndexData(std::vector& vecVertices, std::vector& vecIndices); //private: - std::vector m_vecTriangleIndices; + std::vector m_vecTriangleIndices; std::vector m_vecVertices; long int vertexIndices[OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1][OGRE_REGION_SIDE_LENGTH*2+1]; diff --git a/include/IntegralVector3.h b/include/IntegralVector3.h index 90bad209..5460ed0a 100644 --- a/include/IntegralVector3.h +++ b/include/IntegralVector3.h @@ -19,7 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef __IntegralVector3_H__ #define __IntegralVector3_H__ -#include +#include "boost/cstdint.hpp" + #include namespace Ogre @@ -104,10 +105,10 @@ namespace Ogre typedef IntegralVector3 IntVector3; typedef IntegralVector3 LongVector3; - typedef IntegralVector3 UCharVector3; - typedef IntegralVector3 UShortVector3; - typedef IntegralVector3 UIntVector3; - typedef IntegralVector3 ULongVector3; + typedef IntegralVector3 UCharVector3; + typedef IntegralVector3 UShortVector3; + typedef IntegralVector3 UIntVector3; + typedef IntegralVector3 ULongVector3; } #endif diff --git a/include/PolyVoxSceneManager.h b/include/PolyVoxSceneManager.h index d7a9b606..3178d698 100644 --- a/include/PolyVoxSceneManager.h +++ b/include/PolyVoxSceneManager.h @@ -19,7 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef __PolyVoxSceneManager_H__ #define __PolyVoxSceneManager_H__ -#include "OgrePrerequisites.h" +#include "boost/cstdint.hpp" + #include "OgreSceneManager.h" #include "Constants.h" @@ -51,9 +52,9 @@ namespace Ogre ~PolyVoxSceneManager(); //Getters - uchar getMaterialIndexAt(uint uX, uint uY, uint uZ); + boost::uint8_t getMaterialIndexAt(boost::uint16_t uX, boost::uint16_t uY, boost::uint16_t uZ); const String& getTypeName(void) const; - uint getSideLength(void); + boost::uint16_t getSideLength(void); //Setters @@ -63,14 +64,14 @@ namespace Ogre std::list getChangedRegionGeometry(void); void setAllUpToDateFlagsTo(bool newUpToDateValue); - void createSphereAt(Vector3 centre, Real radius, uchar value, bool painting); + void createSphereAt(Vector3 centre, Real radius, boost::uint8_t value, bool painting); void generateLevelVolume(void); - void generateMeshDataForRegion(uint regionX, uint regionY, uint regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch) const; + void generateMeshDataForRegion(boost::uint16_t regionX,boost:: uint16_t regionY, boost::uint16_t regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch) const; bool containsPoint(Vector3 pos, float boundary); - bool containsPoint(IntVector3 pos, uint boundary); + bool containsPoint(IntVector3 pos, boost::uint16_t boundary); @@ -83,14 +84,14 @@ namespace Ogre Vector3 computeNormal(const Vector3& position, NormalGenerationMethod normalGenerationMethod) const; public: - void markVoxelChanged(uint x, uint y, uint z); - void markRegionChanged(uint firstX, uint firstY, uint firstZ, uint lastX, uint lastY, uint lastZ); + void markVoxelChanged(boost::uint16_t x, boost::uint16_t y, boost::uint16_t z); + void markRegionChanged(boost::uint16_t firstX, boost::uint16_t firstY, boost::uint16_t firstZ, boost::uint16_t lastX, boost::uint16_t lastY, boost::uint16_t lastZ); - static uint fileNo; + static boost::uint16_t fileNo; bool useNormalSmoothing; - uint normalSmoothingFilterSize; + boost::uint16_t normalSmoothingFilterSize; NormalGenerationMethod m_normalGenerationMethod; diff --git a/include/SurfaceEdge.h b/include/SurfaceEdge.h index 51448292..df43d2f7 100644 --- a/include/SurfaceEdge.h +++ b/include/SurfaceEdge.h @@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef __SurfaceEdge_H__ #define __SurfaceEdge_H__ -#include "OgrePrerequisites.h" #include "SurfaceTypes.h" namespace Ogre diff --git a/include/SurfaceTriangle.h b/include/SurfaceTriangle.h index dffe89a1..b0d5324a 100644 --- a/include/SurfaceTriangle.h +++ b/include/SurfaceTriangle.h @@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef __SurfaceTriangle_H__ #define __SurfaceTriangle_H__ -#include "OgrePrerequisites.h" #include "SurfaceTypes.h" namespace Ogre diff --git a/include/SurfaceVertex.h b/include/SurfaceVertex.h index 23a53301..bb0f2a65 100644 --- a/include/SurfaceVertex.h +++ b/include/SurfaceVertex.h @@ -22,7 +22,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "TypeDef.h" -#include "OgrePrerequisites.h" #include "OgreVector3.h" #include "IntegralVector3.h" diff --git a/include/Volume.h b/include/Volume.h index aed0f199..0d4a6672 100644 --- a/include/Volume.h +++ b/include/Volume.h @@ -19,7 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef __Volume_H__ #define __Volume_H__ -#include "OgrePrerequisites.h" +#include "boost/cstdint.hpp" + #include "Block.h" #include "Constants.h" @@ -41,15 +42,15 @@ namespace Ogre Volume& operator=(const Volume& rhs); - Block* getBlock(uint index); + Block* getBlock(boost::uint16_t index); bool containsPoint(Vector3 pos, float boundary); - bool containsPoint(IntVector3 pos, uint boundary); + bool containsPoint(IntVector3 pos, boost::uint16_t boundary); bool loadFromFile(const std::string& sFilename); bool saveToFile(const std::string& sFilename); - void regionGrow(uint xStart, uint yStart, uint zStart, uchar value); + void regionGrow(boost::uint16_t xStart, boost::uint16_t yStart, boost::uint16_t zStart, boost::uint8_t value); void tidy(void); private: diff --git a/include/VolumeIterator.h b/include/VolumeIterator.h index 32e84e97..12d89b8b 100644 --- a/include/VolumeIterator.h +++ b/include/VolumeIterator.h @@ -19,7 +19,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef __VolumeIterator_H__ #define __VolumeIterator_H__ -#include "OgrePrerequisites.h" +#include "boost/cstdint.hpp" + #include "TypeDef.h" @@ -33,96 +34,96 @@ namespace Ogre VolumeIterator(Volume& volume); ~VolumeIterator(); - void setVoxel(uchar value); - uchar getVoxel(void); + void setVoxel(boost::uint8_t value); + boost::uint8_t getVoxel(void); - uchar getVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition) const; - void setVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition, const uchar value); + boost::uint8_t getVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition) const; + void setVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition, const boost::uint8_t value); - float getAveragedVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition, uint size) const; + float getAveragedVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition, boost::uint16_t size) const; //FIXME - this shouldn't return float vector Vector3 getCentralDifferenceGradient(void) const; Vector3 getAveragedCentralDifferenceGradient(void) const; Vector3 getSobelGradient(void) const; - uint getPosX(void); - uint getPosY(void); - uint getPosZ(void); + boost::uint16_t getPosX(void); + boost::uint16_t getPosY(void); + boost::uint16_t getPosZ(void); - void setPosition(uint xPos, uint yPos, uint zPos); - void setValidRegion(uint xFirst, uint yFirst, uint zFirst, uint xLast, uint yLast, uint zLast); + void setPosition(boost::uint16_t xPos, boost::uint16_t yPos, boost::uint16_t zPos); + void setValidRegion(boost::uint16_t xFirst, boost::uint16_t yFirst, boost::uint16_t zFirst, boost::uint16_t xLast, boost::uint16_t yLast, boost::uint16_t zLast); void moveForwardInRegion(void); bool isValidForRegion(void); - uchar peekVoxel1nx1ny1nz(void) const; - uchar peekVoxel1nx1ny0pz(void) const; - uchar peekVoxel1nx1ny1pz(void) const; - uchar peekVoxel1nx0py1nz(void) const; - uchar peekVoxel1nx0py0pz(void) const; - uchar peekVoxel1nx0py1pz(void) const; - uchar peekVoxel1nx1py1nz(void) const; - uchar peekVoxel1nx1py0pz(void) const; - uchar peekVoxel1nx1py1pz(void) const; + boost::uint8_t peekVoxel1nx1ny1nz(void) const; + boost::uint8_t peekVoxel1nx1ny0pz(void) const; + boost::uint8_t peekVoxel1nx1ny1pz(void) const; + boost::uint8_t peekVoxel1nx0py1nz(void) const; + boost::uint8_t peekVoxel1nx0py0pz(void) const; + boost::uint8_t peekVoxel1nx0py1pz(void) const; + boost::uint8_t peekVoxel1nx1py1nz(void) const; + boost::uint8_t peekVoxel1nx1py0pz(void) const; + boost::uint8_t peekVoxel1nx1py1pz(void) const; - uchar peekVoxel0px1ny1nz(void) const; - uchar peekVoxel0px1ny0pz(void) const; - uchar peekVoxel0px1ny1pz(void) const; - uchar peekVoxel0px0py1nz(void) const; - uchar peekVoxel0px0py0pz(void) const; - uchar peekVoxel0px0py1pz(void) const; - uchar peekVoxel0px1py1nz(void) const; - uchar peekVoxel0px1py0pz(void) const; - uchar peekVoxel0px1py1pz(void) const; + boost::uint8_t peekVoxel0px1ny1nz(void) const; + boost::uint8_t peekVoxel0px1ny0pz(void) const; + boost::uint8_t peekVoxel0px1ny1pz(void) const; + boost::uint8_t peekVoxel0px0py1nz(void) const; + boost::uint8_t peekVoxel0px0py0pz(void) const; + boost::uint8_t peekVoxel0px0py1pz(void) const; + boost::uint8_t peekVoxel0px1py1nz(void) const; + boost::uint8_t peekVoxel0px1py0pz(void) const; + boost::uint8_t peekVoxel0px1py1pz(void) const; - uchar peekVoxel1px1ny1nz(void) const; - uchar peekVoxel1px1ny0pz(void) const; - uchar peekVoxel1px1ny1pz(void) const; - uchar peekVoxel1px0py1nz(void) const; - uchar peekVoxel1px0py0pz(void) const; - uchar peekVoxel1px0py1pz(void) const; - uchar peekVoxel1px1py1nz(void) const; - uchar peekVoxel1px1py0pz(void) const; - uchar peekVoxel1px1py1pz(void) const; + boost::uint8_t peekVoxel1px1ny1nz(void) const; + boost::uint8_t peekVoxel1px1ny0pz(void) const; + boost::uint8_t peekVoxel1px1ny1pz(void) const; + boost::uint8_t peekVoxel1px0py1nz(void) const; + boost::uint8_t peekVoxel1px0py0pz(void) const; + boost::uint8_t peekVoxel1px0py1pz(void) const; + boost::uint8_t peekVoxel1px1py1nz(void) const; + boost::uint8_t peekVoxel1px1py0pz(void) const; + boost::uint8_t peekVoxel1px1py1pz(void) const; private: //The current volume Volume& mVolume; //The current position in the volume - uint mXPosInVolume; - uint mYPosInVolume; - uint mZPosInVolume; + boost::uint16_t mXPosInVolume; + boost::uint16_t mYPosInVolume; + boost::uint16_t mZPosInVolume; //The position of the current block - uint mXBlock; - uint mYBlock; - uint mZBlock; + boost::uint16_t mXBlock; + boost::uint16_t mYBlock; + boost::uint16_t mZBlock; //The offset into the current block - uint mXPosInBlock; - uint mYPosInBlock; - uint mZPosInBlock; + boost::uint16_t mXPosInBlock; + boost::uint16_t mYPosInBlock; + boost::uint16_t mZPosInBlock; //Other current position information - uchar* mCurrentVoxel; - ulong mBlockIndexInVolume; - ulong mVoxelIndexInBlock; + boost::uint8_t* mCurrentVoxel; + boost::uint32_t mBlockIndexInVolume; + boost::uint32_t mVoxelIndexInBlock; - uint mXRegionFirst; - uint mYRegionFirst; - uint mZRegionFirst; - uint mXRegionLast; - uint mYRegionLast; - uint mZRegionLast; + boost::uint16_t mXRegionFirst; + boost::uint16_t mYRegionFirst; + boost::uint16_t mZRegionFirst; + boost::uint16_t mXRegionLast; + boost::uint16_t mYRegionLast; + boost::uint16_t mZRegionLast; - uint mXRegionFirstBlock; - uint mYRegionFirstBlock; - uint mZRegionFirstBlock; - uint mXRegionLastBlock; - uint mYRegionLastBlock; - uint mZRegionLastBlock; + boost::uint16_t mXRegionFirstBlock; + boost::uint16_t mYRegionFirstBlock; + boost::uint16_t mZRegionFirstBlock; + boost::uint16_t mXRegionLastBlock; + boost::uint16_t mYRegionLastBlock; + boost::uint16_t mZRegionLastBlock; bool mIsValidForRegion; }; diff --git a/source/Block.cpp b/source/Block.cpp index 04b6d510..a9364843 100644 --- a/source/Block.cpp +++ b/source/Block.cpp @@ -23,6 +23,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "Block.h" +using namespace boost; + namespace Ogre { Block::Block() @@ -50,7 +52,7 @@ namespace Ogre { return *this; } - uchar Block::getVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition) const + uint8_t Block::getVoxelAt(const uint16_t xPosition, const uint16_t yPosition, const uint16_t zPosition) const { return mData [ @@ -60,7 +62,7 @@ namespace Ogre { ]; } - void Block::setVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition, const uchar value) + void Block::setVoxelAt(const uint16_t xPosition, const uint16_t yPosition, const uint16_t zPosition, const uint8_t value) { mData [ @@ -70,15 +72,15 @@ namespace Ogre { ] = value; } - /*void Block::fillWithValue(const uchar value) + /*void Block::fillWithValue(const uint8_t value) { memset(mData,value,OGRE_NO_OF_VOXELS_IN_BLOCK); }*/ /*bool Block::isHomogeneous(void) { - uchar uFirstVoxel = mData[0]; - for(ulong ct = 1; ct < OGRE_NO_OF_VOXELS_IN_BLOCK; ++ct) + uint8_t uFirstVoxel = mData[0]; + for(uint32_t ct = 1; ct < OGRE_NO_OF_VOXELS_IN_BLOCK; ++ct) { if(mData[ct] != uFirstVoxel) { diff --git a/source/IndexedSurfacePatch.cpp b/source/IndexedSurfacePatch.cpp index 7ea4bdf2..8ed04580 100644 --- a/source/IndexedSurfacePatch.cpp +++ b/source/IndexedSurfacePatch.cpp @@ -1,5 +1,7 @@ #include "IndexedSurfacePatch.h" +using namespace boost; + namespace Ogre { long int IndexedSurfacePatch::noOfVerticesSubmitted = 0; @@ -77,7 +79,7 @@ namespace Ogre } } - void IndexedSurfacePatch::fillVertexAndIndexData(std::vector& vecVertices, std::vector& vecIndices) + void IndexedSurfacePatch::fillVertexAndIndexData(std::vector& vecVertices, std::vector& vecIndices) { vecVertices.resize(m_vecVertices.size()); std::copy(m_vecVertices.begin(), m_vecVertices.end(), vecVertices.begin()); diff --git a/source/PolyVoxSceneManager.cpp b/source/PolyVoxSceneManager.cpp index 1cd81e0d..6a9ab8fb 100644 --- a/source/PolyVoxSceneManager.cpp +++ b/source/PolyVoxSceneManager.cpp @@ -29,6 +29,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include +using namespace boost; + namespace Ogre { @@ -54,13 +56,13 @@ namespace Ogre std::list listChangedRegionGeometry; //Regenerate meshes. - for(uint regionZ = 0; regionZ < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionZ) + for(uint16_t regionZ = 0; regionZ < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionZ) { //LogManager::getSingleton().logMessage("regionZ = " + StringConverter::toString(regionZ)); - for(uint regionY = 0; regionY < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionY) + for(uint16_t regionY = 0; regionY < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionY) { //LogManager::getSingleton().logMessage("regionY = " + StringConverter::toString(regionY)); - for(uint regionX = 0; regionX < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionX) + for(uint16_t regionX = 0; regionX < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionX) { //LogManager::getSingleton().logMessage("regionX = " + StringConverter::toString(regionX)); if(surfaceUpToDate[regionX][regionY][regionZ] == false) @@ -88,11 +90,11 @@ namespace Ogre void PolyVoxSceneManager::setAllUpToDateFlagsTo(bool newUpToDateValue) { - for(uint blockZ = 0; blockZ < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockZ) + for(uint16_t blockZ = 0; blockZ < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockZ) { - for(uint blockY = 0; blockY < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockY) + for(uint16_t blockY = 0; blockY < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockY) { - for(uint blockX = 0; blockX < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockX) + for(uint16_t blockX = 0; blockX < OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockX) { surfaceUpToDate[blockX][blockY][blockZ] = newUpToDateValue; } @@ -100,7 +102,7 @@ namespace Ogre } } - void PolyVoxSceneManager::createSphereAt(Vector3 centre, Real radius, uchar value, bool painting) + void PolyVoxSceneManager::createSphereAt(Vector3 centre, Real radius, uint8_t value, bool painting) { int firstX = static_cast(std::floor(centre.x - radius)); int firstY = static_cast(std::floor(centre.y - radius)); @@ -154,11 +156,11 @@ namespace Ogre //volumeData = VolumePtr(new Volume); volumeData = new Volume(); VolumeIterator volIter(*volumeData); - for(uint z = 0; z < OGRE_VOLUME_SIDE_LENGTH; ++z) + for(uint16_t z = 0; z < OGRE_VOLUME_SIDE_LENGTH; ++z) { - for(uint y = 0; y < OGRE_VOLUME_SIDE_LENGTH; ++y) + for(uint16_t y = 0; y < OGRE_VOLUME_SIDE_LENGTH; ++y) { - for(uint x = 0; x < OGRE_VOLUME_SIDE_LENGTH; ++x) + for(uint16_t x = 0; x < OGRE_VOLUME_SIDE_LENGTH; ++x) { if((x/16+y/16+z/16)%2 == 0) volIter.setVoxelAt(x,y,z,4); @@ -168,11 +170,11 @@ namespace Ogre } } - for(uint z = 0; z < OGRE_VOLUME_SIDE_LENGTH; ++z) + for(uint16_t z = 0; z < OGRE_VOLUME_SIDE_LENGTH; ++z) { - for(uint y = 0; y < OGRE_VOLUME_SIDE_LENGTH; ++y) + for(uint16_t y = 0; y < OGRE_VOLUME_SIDE_LENGTH; ++y) { - for(uint x = 0; x < OGRE_VOLUME_SIDE_LENGTH; ++x) + for(uint16_t x = 0; x < OGRE_VOLUME_SIDE_LENGTH; ++x) { if( (z<62)|| @@ -193,26 +195,26 @@ namespace Ogre Vector3 centre(128,128,128); Vector3 v3dSize(192,96,128); - uint uHalfX = static_cast(v3dSize.x / 2); - uint uHalfY = static_cast(v3dSize.y / 2); - uint uHalfZ = static_cast(v3dSize.z / 2); + uint16_t uHalfX = static_cast(v3dSize.x / 2); + uint16_t uHalfY = static_cast(v3dSize.y / 2); + uint16_t uHalfZ = static_cast(v3dSize.z / 2); - for(uint z = static_cast(centre.z) - uHalfZ; z < static_cast(centre.z) + uHalfZ; z++) + for(uint16_t z = static_cast(centre.z) - uHalfZ; z < static_cast(centre.z) + uHalfZ; z++) { - for(uint y = static_cast(centre.y) - uHalfY; y < static_cast(centre.y) + uHalfY; y++) + for(uint16_t y = static_cast(centre.y) - uHalfY; y < static_cast(centre.y) + uHalfY; y++) { - for(uint x = static_cast(centre.x) - uHalfX; x < static_cast(centre.x) + uHalfX; x++) + for(uint16_t x = static_cast(centre.x) - uHalfX; x < static_cast(centre.x) + uHalfX; x++) { volIter.setVoxelAt(x,y,z,0); } } } - for(uint z = 0; z < OGRE_VOLUME_SIDE_LENGTH; ++z) + for(uint16_t z = 0; z < OGRE_VOLUME_SIDE_LENGTH; ++z) { - for(uint y = 0; y < OGRE_VOLUME_SIDE_LENGTH; ++y) + for(uint16_t y = 0; y < OGRE_VOLUME_SIDE_LENGTH; ++y) { - for(uint x = 0; x < OGRE_VOLUME_SIDE_LENGTH; ++x) + for(uint16_t x = 0; x < OGRE_VOLUME_SIDE_LENGTH; ++x) { if( (x%64 < 8) && @@ -232,24 +234,24 @@ namespace Ogre } } - void PolyVoxSceneManager::generateMeshDataForRegion(const uint regionX, const uint regionY, const uint regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch) const + void PolyVoxSceneManager::generateMeshDataForRegion(const uint16_t regionX, const uint16_t regionY, const uint16_t regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch) const { //IndexedSurfacePatch* surfacePatchResult = new IndexedSurfacePatch; //LogManager::getSingleton().logMessage("Generating Mesh Data"); //First and last voxels in the region - const uint firstX = regionX * OGRE_REGION_SIDE_LENGTH; - const uint firstY = regionY * OGRE_REGION_SIDE_LENGTH; - const uint firstZ = regionZ * OGRE_REGION_SIDE_LENGTH; - const uint lastX = (std::min)(firstX + OGRE_REGION_SIDE_LENGTH-1,static_cast(OGRE_VOLUME_SIDE_LENGTH-2)); - const uint lastY = (std::min)(firstY + OGRE_REGION_SIDE_LENGTH-1,static_cast(OGRE_VOLUME_SIDE_LENGTH-2)); - const uint lastZ = (std::min)(firstZ + OGRE_REGION_SIDE_LENGTH-1,static_cast(OGRE_VOLUME_SIDE_LENGTH-2)); + const uint16_t firstX = regionX * OGRE_REGION_SIDE_LENGTH; + const uint16_t firstY = regionY * OGRE_REGION_SIDE_LENGTH; + const uint16_t firstZ = regionZ * OGRE_REGION_SIDE_LENGTH; + const uint16_t lastX = (std::min)(firstX + OGRE_REGION_SIDE_LENGTH-1,static_cast(OGRE_VOLUME_SIDE_LENGTH-2)); + const uint16_t lastY = (std::min)(firstY + OGRE_REGION_SIDE_LENGTH-1,static_cast(OGRE_VOLUME_SIDE_LENGTH-2)); + const uint16_t lastZ = (std::min)(firstZ + OGRE_REGION_SIDE_LENGTH-1,static_cast(OGRE_VOLUME_SIDE_LENGTH-2)); //Offset from lower block corner const UIntVector3 offset(firstX*2,firstY*2,firstZ*2); UIntVector3 vertlist[12]; - uchar vertMaterials[12]; + uint8_t vertMaterials[12]; VolumeIterator volIter(*volumeData); volIter.setValidRegion(firstX,firstY,firstZ,lastX,lastY,lastZ); @@ -261,24 +263,24 @@ namespace Ogre for(volIter.setPosition(firstX,firstY,firstZ);volIter.isValidForRegion();volIter.moveForwardInRegion()) { //Current position - const uint x = volIter.getPosX(); - const uint y = volIter.getPosY(); - const uint z = volIter.getPosZ(); + const uint16_t x = volIter.getPosX(); + const uint16_t y = volIter.getPosY(); + const uint16_t z = volIter.getPosZ(); //LogManager::getSingleton().logMessage("x = " + StringConverter::toString(int(x)) + " y = " + StringConverter::toString(int(y)) + " z = " + StringConverter::toString(int(z))); //Voxels values - const uchar v000 = volIter.getVoxel(); - const uchar v100 = volIter.peekVoxel1px0py0pz(); - const uchar v010 = volIter.peekVoxel0px1py0pz(); - const uchar v110 = volIter.peekVoxel1px1py0pz(); - const uchar v001 = volIter.peekVoxel0px0py1pz(); - const uchar v101 = volIter.peekVoxel1px0py1pz(); - const uchar v011 = volIter.peekVoxel0px1py1pz(); - const uchar v111 = volIter.peekVoxel1px1py1pz(); + const uint8_t v000 = volIter.getVoxel(); + const uint8_t v100 = volIter.peekVoxel1px0py0pz(); + const uint8_t v010 = volIter.peekVoxel0px1py0pz(); + const uint8_t v110 = volIter.peekVoxel1px1py0pz(); + const uint8_t v001 = volIter.peekVoxel0px0py1pz(); + const uint8_t v101 = volIter.peekVoxel1px0py1pz(); + const uint8_t v011 = volIter.peekVoxel0px1py1pz(); + const uint8_t v111 = volIter.peekVoxel1px1py1pz(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uchar iCubeIndex = 0; + uint8_t iCubeIndex = 0; if (v000 == 0) iCubeIndex |= 1; if (v100 == 0) iCubeIndex |= 2; @@ -388,9 +390,9 @@ namespace Ogre const UIntVector3 vertex1 = vertlist[triTable[iCubeIndex][i+1]] - offset; const UIntVector3 vertex2 = vertlist[triTable[iCubeIndex][i+2]] - offset; - const uchar material0 = vertMaterials[triTable[iCubeIndex][i ]]; - const uchar material1 = vertMaterials[triTable[iCubeIndex][i+1]]; - const uchar material2 = vertMaterials[triTable[iCubeIndex][i+2]]; + const uint8_t material0 = vertMaterials[triTable[iCubeIndex][i ]]; + const uint8_t material1 = vertMaterials[triTable[iCubeIndex][i+1]]; + const uint8_t material2 = vertMaterials[triTable[iCubeIndex][i+2]]; //If all the materials are the same, we just need one triangle for that material with all the alphas set high. @@ -508,7 +510,7 @@ namespace Ogre //FIXME - can it happen that we have no vertices or triangles? Should exit early? - //for(std::map::iterator iterPatch = surfacePatchMapResult.begin(); iterPatch != surfacePatchMapResult.end(); ++iterPatch) + //for(std::map::iterator iterPatch = surfacePatchMapResult.begin(); iterPatch != surfacePatchMapResult.end(); ++iterPatch) { std::vector::iterator iterSurfaceVertex = singleMaterialPatch->m_vecVertices.begin(); @@ -527,7 +529,7 @@ namespace Ogre ++iterSurfaceVertex; } - uint noOfRemovedVertices = 0; + uint16_t noOfRemovedVertices = 0; //do { //noOfRemovedVertices = iterPatch->second.decimate(); @@ -549,28 +551,28 @@ namespace Ogre const float posY = position.y; const float posZ = position.z; - const uint floorX = static_cast(posX); - const uint floorY = static_cast(posY); - const uint floorZ = static_cast(posZ); + const uint16_t floorX = static_cast(posX); + const uint16_t floorY = static_cast(posY); + const uint16_t floorZ = static_cast(posZ); Vector3 result; if(normalGenerationMethod == SOBEL) { - volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); + volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); const Vector3 gradFloor = volIter.getSobelGradient(); if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 { - volIter.setPosition(static_cast(posX+1.0),static_cast(posY),static_cast(posZ)); + volIter.setPosition(static_cast(posX+1.0),static_cast(posY),static_cast(posZ)); } if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5 { - volIter.setPosition(static_cast(posX),static_cast(posY+1.0),static_cast(posZ)); + volIter.setPosition(static_cast(posX),static_cast(posY+1.0),static_cast(posZ)); } if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5 { - volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ+1.0)); + volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ+1.0)); } const Vector3 gradCeil = volIter.getSobelGradient(); result = ((gradFloor + gradCeil) * -1.0); @@ -582,19 +584,19 @@ namespace Ogre } if(normalGenerationMethod == CENTRAL_DIFFERENCE) { - volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); + volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); const Vector3 gradFloor = volIter.getCentralDifferenceGradient(); if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 { - volIter.setPosition(static_cast(posX+1.0),static_cast(posY),static_cast(posZ)); + volIter.setPosition(static_cast(posX+1.0),static_cast(posY),static_cast(posZ)); } if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5 { - volIter.setPosition(static_cast(posX),static_cast(posY+1.0),static_cast(posZ)); + volIter.setPosition(static_cast(posX),static_cast(posY+1.0),static_cast(posZ)); } if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5 { - volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ+1.0)); + volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ+1.0)); } const Vector3 gradCeil = volIter.getCentralDifferenceGradient(); result = ((gradFloor + gradCeil) * -1.0); @@ -606,28 +608,28 @@ namespace Ogre } if(normalGenerationMethod == SIMPLE) { - volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); - const uchar uFloor = volIter.getVoxel() > 0 ? 1 : 0; + volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); + const uint8_t uFloor = volIter.getVoxel() > 0 ? 1 : 0; if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 { - uchar uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; + uint8_t uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; result = Vector3(uFloor - uCeil,0.0,0.0); } else if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5 { - uchar uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; + uint8_t uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; result = Vector3(0.0,uFloor - uCeil,0.0); } else if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5 { - uchar uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; + uint8_t uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; result = Vector3(0.0, 0.0,uFloor - uCeil); } } return result; } - void PolyVoxSceneManager::markVoxelChanged(uint x, uint y, uint z) + void PolyVoxSceneManager::markVoxelChanged(uint16_t x, uint16_t y, uint16_t z) { //If we are not on a boundary, just mark one region. if((x % OGRE_REGION_SIDE_LENGTH != 0) && @@ -641,23 +643,23 @@ namespace Ogre } else //Mark surrounding block as well { - const uint regionX = x >> OGRE_REGION_SIDE_LENGTH_POWER; - const uint regionY = y >> OGRE_REGION_SIDE_LENGTH_POWER; - const uint regionZ = z >> OGRE_REGION_SIDE_LENGTH_POWER; + const uint16_t regionX = x >> OGRE_REGION_SIDE_LENGTH_POWER; + const uint16_t regionY = y >> OGRE_REGION_SIDE_LENGTH_POWER; + const uint16_t regionZ = z >> OGRE_REGION_SIDE_LENGTH_POWER; - const uint minRegionX = (std::max)(uint(0),regionX-1); - const uint minRegionY = (std::max)(uint(0),regionY-1); - const uint minRegionZ = (std::max)(uint(0),regionZ-1); + const uint16_t minRegionX = (std::max)(uint16_t(0),uint16_t(regionX-1)); + const uint16_t minRegionY = (std::max)(uint16_t(0),uint16_t(regionY-1)); + const uint16_t minRegionZ = (std::max)(uint16_t(0),uint16_t(regionZ-1)); - const uint maxRegionX = (std::min)(uint(OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS-1),regionX+1); - const uint maxRegionY = (std::min)(uint(OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS-1),regionY+1); - const uint maxRegionZ = (std::min)(uint(OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS-1),regionZ+1); + const uint16_t maxRegionX = (std::min)(uint16_t(OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16_t(regionX+1)); + const uint16_t maxRegionY = (std::min)(uint16_t(OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16_t(regionY+1)); + const uint16_t maxRegionZ = (std::min)(uint16_t(OGRE_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16_t(regionZ+1)); - for(uint zCt = minRegionZ; zCt <= maxRegionZ; zCt++) + for(uint16_t zCt = minRegionZ; zCt <= maxRegionZ; zCt++) { - for(uint yCt = minRegionY; yCt <= maxRegionY; yCt++) + for(uint16_t yCt = minRegionY; yCt <= maxRegionY; yCt++) { - for(uint xCt = minRegionX; xCt <= maxRegionX; xCt++) + for(uint16_t xCt = minRegionX; xCt <= maxRegionX; xCt++) { surfaceUpToDate[xCt][yCt][zCt] = false; } @@ -666,21 +668,21 @@ namespace Ogre } } - void PolyVoxSceneManager::markRegionChanged(uint firstX, uint firstY, uint firstZ, uint lastX, uint lastY, uint lastZ) + void PolyVoxSceneManager::markRegionChanged(uint16_t firstX, uint16_t firstY, uint16_t firstZ, uint16_t lastX, uint16_t lastY, uint16_t lastZ) { - const uint firstRegionX = firstX >> OGRE_REGION_SIDE_LENGTH_POWER; - const uint firstRegionY = firstY >> OGRE_REGION_SIDE_LENGTH_POWER; - const uint firstRegionZ = firstZ >> OGRE_REGION_SIDE_LENGTH_POWER; + const uint16_t firstRegionX = firstX >> OGRE_REGION_SIDE_LENGTH_POWER; + const uint16_t firstRegionY = firstY >> OGRE_REGION_SIDE_LENGTH_POWER; + const uint16_t firstRegionZ = firstZ >> OGRE_REGION_SIDE_LENGTH_POWER; - const uint lastRegionX = lastX >> OGRE_REGION_SIDE_LENGTH_POWER; - const uint lastRegionY = lastY >> OGRE_REGION_SIDE_LENGTH_POWER; - const uint lastRegionZ = lastZ >> OGRE_REGION_SIDE_LENGTH_POWER; + const uint16_t lastRegionX = lastX >> OGRE_REGION_SIDE_LENGTH_POWER; + const uint16_t lastRegionY = lastY >> OGRE_REGION_SIDE_LENGTH_POWER; + const uint16_t lastRegionZ = lastZ >> OGRE_REGION_SIDE_LENGTH_POWER; - for(uint zCt = firstRegionZ; zCt <= lastRegionZ; zCt++) + for(uint16_t zCt = firstRegionZ; zCt <= lastRegionZ; zCt++) { - for(uint yCt = firstRegionY; yCt <= lastRegionY; yCt++) + for(uint16_t yCt = firstRegionY; yCt <= lastRegionY; yCt++) { - for(uint xCt = firstRegionX; xCt <= lastRegionX; xCt++) + for(uint16_t xCt = firstRegionX; xCt <= lastRegionX; xCt++) { surfaceUpToDate[xCt][yCt][zCt] = false; } @@ -688,12 +690,12 @@ namespace Ogre } } - uint PolyVoxSceneManager::getSideLength(void) + uint16_t PolyVoxSceneManager::getSideLength(void) { return OGRE_VOLUME_SIDE_LENGTH; } - uchar PolyVoxSceneManager::getMaterialIndexAt(uint uX, uint uY, uint uZ) + uint8_t PolyVoxSceneManager::getMaterialIndexAt(uint16_t uX, uint16_t uY, uint16_t uZ) { if(volumeData->containsPoint(IntVector3(uX,uY,uZ),0)) { @@ -716,7 +718,7 @@ namespace Ogre return volumeData->containsPoint(pos, boundary); } - bool PolyVoxSceneManager::containsPoint(IntVector3 pos, uint boundary) + bool PolyVoxSceneManager::containsPoint(IntVector3 pos, uint16_t boundary) { return volumeData->containsPoint(pos, boundary); } diff --git a/source/SurfaceTriangle.cpp b/source/SurfaceTriangle.cpp index 4eb13f09..12f17b8a 100644 --- a/source/SurfaceTriangle.cpp +++ b/source/SurfaceTriangle.cpp @@ -22,7 +22,7 @@ namespace Ogre { std::stringstream ss; - uint ct = 0; + uint16_t ct = 0; SurfaceEdgeIterator edgeIter = edge; ss << "SurfaceTriangle:"; do diff --git a/source/Volume.cpp b/source/Volume.cpp index 188801ae..fa9ddf81 100644 --- a/source/Volume.cpp +++ b/source/Volume.cpp @@ -27,6 +27,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include //FIXME - remove this... +using namespace boost; + namespace Ogre { @@ -40,12 +42,12 @@ namespace Ogre homogeneousBlock->fillWithValue(0); }*/ - /*for(uint i = 0; i < OGRE_NO_OF_BLOCKS_IN_VOLUME; ++i) + /*for(uint16_t i = 0; i < OGRE_NO_OF_BLOCKS_IN_VOLUME; ++i) { mBlocks[i] = mHomogeneousBlocks[0]; }*/ - for(uint i = 0; i < OGRE_NO_OF_BLOCKS_IN_VOLUME; ++i) + for(uint16_t i = 0; i < OGRE_NO_OF_BLOCKS_IN_VOLUME; ++i) { mBlocks[i] = new Block; } @@ -69,13 +71,13 @@ namespace Ogre return *this; } - /*for(uint i = 0; i < OGRE_NO_OF_BLOCKS_IN_VOLUME; ++i) + /*for(uint16_t i = 0; i < OGRE_NO_OF_BLOCKS_IN_VOLUME; ++i) { //FIXME - Add checking... mBlocks[i] = SharedPtr(new Block); }*/ - for(uint i = 0; i < OGRE_NO_OF_BLOCKS_IN_VOLUME; ++i) + for(uint16_t i = 0; i < OGRE_NO_OF_BLOCKS_IN_VOLUME; ++i) { //I think this is OK... If a block is in the homogeneous array it's ref count will be greater //than 1 as there will be the pointer in the volume and the pointer in the static homogeneous array. @@ -93,15 +95,15 @@ namespace Ogre return *this; } - /*uchar Volume::getVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition) const + /*uint8_t Volume::getVoxelAt(const uint16_t xPosition, const uint16_t yPosition, const uint16_t zPosition) const { - const uint blockX = xPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint blockY = yPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint blockZ = zPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockX = xPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockY = yPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockZ = zPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint xOffset = xPosition - (blockX << OGRE_BLOCK_SIDE_LENGTH_POWER); - const uint yOffset = yPosition - (blockY << OGRE_BLOCK_SIDE_LENGTH_POWER); - const uint zOffset = zPosition - (blockZ << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t xOffset = xPosition - (blockX << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t yOffset = yPosition - (blockY << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t zOffset = zPosition - (blockZ << OGRE_BLOCK_SIDE_LENGTH_POWER); Block* block = mBlocks [ @@ -113,15 +115,15 @@ namespace Ogre return block->getVoxelAt(xOffset,yOffset,zOffset); }*/ - /*void Volume::setVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition, const uchar value) + /*void Volume::setVoxelAt(const uint16_t xPosition, const uint16_t yPosition, const uint16_t zPosition, const uint8_t value) { - const uint blockX = xPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint blockY = yPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint blockZ = zPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockX = xPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockY = yPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockZ = zPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint xOffset = xPosition - (blockX << OGRE_BLOCK_SIDE_LENGTH_POWER); - const uint yOffset = yPosition - (blockY << OGRE_BLOCK_SIDE_LENGTH_POWER); - const uint zOffset = zPosition - (blockZ << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t xOffset = xPosition - (blockX << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t yOffset = yPosition - (blockY << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t zOffset = zPosition - (blockZ << OGRE_BLOCK_SIDE_LENGTH_POWER); Block* block = mBlocks [ @@ -133,7 +135,7 @@ namespace Ogre block->setVoxelAt(xOffset,yOffset,zOffset, value); }*/ - Block* Volume::getBlock(uint index) + Block* Volume::getBlock(uint16_t index) { return mBlocks[index]; } @@ -148,7 +150,7 @@ namespace Ogre && (pos.z > boundary); } - bool Volume::containsPoint(IntVector3 pos, uint boundary) + bool Volume::containsPoint(IntVector3 pos, uint16_t boundary) { return (pos.x < OGRE_VOLUME_SIDE_LENGTH - 1 - boundary) && (pos.y < OGRE_VOLUME_SIDE_LENGTH - 1 - boundary) @@ -170,9 +172,9 @@ namespace Ogre } //Read volume dimensions - uchar volumeWidth = 0; - uchar volumeHeight = 0; - uchar volumeDepth = 0; + uint8_t volumeWidth = 0; + uint8_t volumeHeight = 0; + uint8_t volumeDepth = 0; file.read(reinterpret_cast(&volumeWidth), sizeof(volumeWidth)); file.read(reinterpret_cast(&volumeHeight), sizeof(volumeHeight)); file.read(reinterpret_cast(&volumeDepth), sizeof(volumeDepth)); @@ -184,13 +186,13 @@ namespace Ogre //Read data VolumeIterator volIter(*this); - for(uint z = 0; z < OGRE_VOLUME_SIDE_LENGTH; ++z) + for(uint16_t z = 0; z < OGRE_VOLUME_SIDE_LENGTH; ++z) { - for(uint y = 0; y < OGRE_VOLUME_SIDE_LENGTH; ++y) + for(uint16_t y = 0; y < OGRE_VOLUME_SIDE_LENGTH; ++y) { - for(uint x = 0; x < OGRE_VOLUME_SIDE_LENGTH; ++x) + for(uint16_t x = 0; x < OGRE_VOLUME_SIDE_LENGTH; ++x) { - uchar value; + uint8_t value; file.read(reinterpret_cast(&value), sizeof(value)); //FIXME - check for error here volIter.setVoxelAt(x,y,z,value); } @@ -218,9 +220,9 @@ namespace Ogre } //Read volume dimensions - uchar volumeWidth = 0; - uchar volumeHeight = 0; - uchar volumeDepth = 0; + uint8_t volumeWidth = 0; + uint8_t volumeHeight = 0; + uint8_t volumeDepth = 0; file.write(reinterpret_cast(&volumeWidth), sizeof(volumeWidth)); file.write(reinterpret_cast(&volumeHeight), sizeof(volumeHeight)); file.write(reinterpret_cast(&volumeDepth), sizeof(volumeDepth)); @@ -232,13 +234,13 @@ namespace Ogre //Write data VolumeIterator volIter(*this); - for(uint z = 0; z < OGRE_VOLUME_SIDE_LENGTH; ++z) + for(uint16_t z = 0; z < OGRE_VOLUME_SIDE_LENGTH; ++z) { - for(uint y = 0; y < OGRE_VOLUME_SIDE_LENGTH; ++y) + for(uint16_t y = 0; y < OGRE_VOLUME_SIDE_LENGTH; ++y) { - for(uint x = 0; x < OGRE_VOLUME_SIDE_LENGTH; ++x) + for(uint16_t x = 0; x < OGRE_VOLUME_SIDE_LENGTH; ++x) { - uchar value = volIter.getVoxelAt(x,y,z); + uint8_t value = volIter.getVoxelAt(x,y,z); file.write(reinterpret_cast(&value), sizeof(value)); //FIXME - check for error here } } @@ -246,7 +248,7 @@ namespace Ogre return true; } - void Volume::regionGrow(uint xStart, uint yStart, uint zStart, uchar value) + void Volume::regionGrow(uint16_t xStart, uint16_t yStart, uint16_t zStart, uint8_t value) { //FIXME - introduce integrer 'isInVolume' function if((xStart > OGRE_VOLUME_SIDE_LENGTH-1) || (yStart > OGRE_VOLUME_SIDE_LENGTH-1) || (zStart > OGRE_VOLUME_SIDE_LENGTH-1) @@ -257,7 +259,7 @@ namespace Ogre } VolumeIterator volIter(*this); - const uchar uSeedValue = volIter.getVoxelAt(xStart,yStart,zStart); + const uint8_t uSeedValue = volIter.getVoxelAt(xStart,yStart,zStart); if(value == uSeedValue) { @@ -322,13 +324,13 @@ namespace Ogre void Volume::tidy(void) { //Check for homogeneous blocks - /*for(ulong ct = 0; ct < OGRE_NO_OF_BLOCKS_IN_VOLUME; ++ct) + /*for(uint32_t ct = 0; ct < OGRE_NO_OF_BLOCKS_IN_VOLUME; ++ct) { if(mBlocks[ct]->isHomogeneous()) { //LogManager::getSingleton().logMessage("Got homogeneous block with value " + StringConverter::toString(mBlocks[ct]->getVoxelAt(0,0,0))); - const uchar homogeneousValue = mBlocks[ct]->getVoxelAt(0,0,0); + const uint8_t homogeneousValue = mBlocks[ct]->getVoxelAt(0,0,0); SharedPtr& homogeneousBlock = mHomogeneousBlocks[homogeneousValue]; if(homogeneousBlock.isNull()) { diff --git a/source/VolumeIterator.cpp b/source/VolumeIterator.cpp index c477f33b..805ff1b3 100644 --- a/source/VolumeIterator.cpp +++ b/source/VolumeIterator.cpp @@ -24,6 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "OgreStringConverter.h" #include "OgreVector3.h" +using namespace boost; + namespace Ogre { VolumeIterator::VolumeIterator(Volume& volume) @@ -61,7 +63,7 @@ namespace Ogre { } - void VolumeIterator::setVoxel(uchar value) + void VolumeIterator::setVoxel(uint8_t value) { Block* currentBlock = mVolume.mBlocks[mBlockIndexInVolume]; @@ -77,21 +79,21 @@ namespace Ogre *mCurrentVoxel = value; } - uchar VolumeIterator::getVoxel(void) + uint8_t VolumeIterator::getVoxel(void) { //return getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume); return *mCurrentVoxel; } - uchar VolumeIterator::getVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition) const + uint8_t VolumeIterator::getVoxelAt(const uint16_t xPosition, const uint16_t yPosition, const uint16_t zPosition) const { - const uint blockX = xPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint blockY = yPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint blockZ = zPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockX = xPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockY = yPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockZ = zPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint xOffset = xPosition - (blockX << OGRE_BLOCK_SIDE_LENGTH_POWER); - const uint yOffset = yPosition - (blockY << OGRE_BLOCK_SIDE_LENGTH_POWER); - const uint zOffset = zPosition - (blockZ << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t xOffset = xPosition - (blockX << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t yOffset = yPosition - (blockY << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t zOffset = zPosition - (blockZ << OGRE_BLOCK_SIDE_LENGTH_POWER); const Block* block = mVolume.mBlocks [ @@ -103,14 +105,14 @@ namespace Ogre return block->getVoxelAt(xOffset,yOffset,zOffset); } - float VolumeIterator::getAveragedVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition, uint size) const + float VolumeIterator::getAveragedVoxelAt(const uint16_t xPosition, const uint16_t yPosition, const uint16_t zPosition, uint16_t size) const { float sum = 0.0; - for(uint z = zPosition-size; z <= zPosition+size; ++z) + for(uint16_t z = zPosition-size; z <= zPosition+size; ++z) { - for(uint y = yPosition-size; y <= yPosition+size; ++y) + for(uint16_t y = yPosition-size; y <= yPosition+size; ++y) { - for(uint x = xPosition-size; x <= xPosition+size; ++x) + for(uint16_t x = xPosition-size; x <= xPosition+size; ++x) { if(getVoxelAt(x,y,z) != 0) { @@ -120,22 +122,22 @@ namespace Ogre } } - uint kernelSideLength = size * 2 + 1; - uint kernelVolume = kernelSideLength * kernelSideLength * kernelSideLength; + uint16_t kernelSideLength = size * 2 + 1; + uint16_t kernelVolume = kernelSideLength * kernelSideLength * kernelSideLength; sum /= static_cast(kernelVolume); return sum; } - void VolumeIterator::setVoxelAt(const uint xPosition, const uint yPosition, const uint zPosition, const uchar value) + void VolumeIterator::setVoxelAt(const uint16_t xPosition, const uint16_t yPosition, const uint16_t zPosition, const uint8_t value) { - const uint blockX = xPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint blockY = yPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint blockZ = zPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockX = xPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockY = yPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; + const uint16_t blockZ = zPosition >> OGRE_BLOCK_SIDE_LENGTH_POWER; - const uint xOffset = xPosition - (blockX << OGRE_BLOCK_SIDE_LENGTH_POWER); - const uint yOffset = yPosition - (blockY << OGRE_BLOCK_SIDE_LENGTH_POWER); - const uint zOffset = zPosition - (blockZ << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t xOffset = xPosition - (blockX << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t yOffset = yPosition - (blockY << OGRE_BLOCK_SIDE_LENGTH_POWER); + const uint16_t zOffset = zPosition - (blockZ << OGRE_BLOCK_SIDE_LENGTH_POWER); Block* block = mVolume.mBlocks [ @@ -168,14 +170,14 @@ namespace Ogre } //FIXME - bitwise way of doing this? - uchar voxel1nx = peekVoxel1nx0py0pz() > 0 ? 1: 0; - uchar voxel1px = peekVoxel1px0py0pz() > 0 ? 1: 0; + uint8_t voxel1nx = peekVoxel1nx0py0pz() > 0 ? 1: 0; + uint8_t voxel1px = peekVoxel1px0py0pz() > 0 ? 1: 0; - uchar voxel1ny = peekVoxel0px1ny0pz() > 0 ? 1: 0; - uchar voxel1py = peekVoxel0px1py0pz() > 0 ? 1: 0; + uint8_t voxel1ny = peekVoxel0px1ny0pz() > 0 ? 1: 0; + uint8_t voxel1py = peekVoxel0px1py0pz() > 0 ? 1: 0; - uchar voxel1nz = peekVoxel0px0py1nz() > 0 ? 1: 0; - uchar voxel1pz = peekVoxel0px0py1pz() > 0 ? 1: 0; + uint8_t voxel1nz = peekVoxel0px0py1nz() > 0 ? 1: 0; + uint8_t voxel1pz = peekVoxel0px0py1pz() > 0 ? 1: 0; return Vector3(int(voxel1px) - int(voxel1nx),int(voxel1py) - int(voxel1ny),int(voxel1pz) - int(voxel1nz)); } @@ -218,35 +220,35 @@ namespace Ogre static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, { {3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } }; - const uchar pVoxel1nx1ny1nz = peekVoxel1nx1ny1nz() > 0 ? 1: 0; - const uchar pVoxel1nx1ny0pz = peekVoxel1nx1ny0pz() > 0 ? 1: 0; - const uchar pVoxel1nx1ny1pz = peekVoxel1nx1ny1pz() > 0 ? 1: 0; - const uchar pVoxel1nx0py1nz = peekVoxel1nx0py1nz() > 0 ? 1: 0; - const uchar pVoxel1nx0py0pz = peekVoxel1nx0py0pz() > 0 ? 1: 0; - const uchar pVoxel1nx0py1pz = peekVoxel1nx0py1pz() > 0 ? 1: 0; - const uchar pVoxel1nx1py1nz = peekVoxel1nx1py1nz() > 0 ? 1: 0; - const uchar pVoxel1nx1py0pz = peekVoxel1nx1py0pz() > 0 ? 1: 0; - const uchar pVoxel1nx1py1pz = peekVoxel1nx1py1pz() > 0 ? 1: 0; + const uint8_t pVoxel1nx1ny1nz = peekVoxel1nx1ny1nz() > 0 ? 1: 0; + const uint8_t pVoxel1nx1ny0pz = peekVoxel1nx1ny0pz() > 0 ? 1: 0; + const uint8_t pVoxel1nx1ny1pz = peekVoxel1nx1ny1pz() > 0 ? 1: 0; + const uint8_t pVoxel1nx0py1nz = peekVoxel1nx0py1nz() > 0 ? 1: 0; + const uint8_t pVoxel1nx0py0pz = peekVoxel1nx0py0pz() > 0 ? 1: 0; + const uint8_t pVoxel1nx0py1pz = peekVoxel1nx0py1pz() > 0 ? 1: 0; + const uint8_t pVoxel1nx1py1nz = peekVoxel1nx1py1nz() > 0 ? 1: 0; + const uint8_t pVoxel1nx1py0pz = peekVoxel1nx1py0pz() > 0 ? 1: 0; + const uint8_t pVoxel1nx1py1pz = peekVoxel1nx1py1pz() > 0 ? 1: 0; - const uchar pVoxel0px1ny1nz = peekVoxel0px1ny1nz() > 0 ? 1: 0; - const uchar pVoxel0px1ny0pz = peekVoxel0px1ny0pz() > 0 ? 1: 0; - const uchar pVoxel0px1ny1pz = peekVoxel0px1ny1pz() > 0 ? 1: 0; - const uchar pVoxel0px0py1nz = peekVoxel0px0py1nz() > 0 ? 1: 0; - //const uchar pVoxel0px0py0pz = peekVoxel0px0py0pz() > 0 ? 1: 0; - const uchar pVoxel0px0py1pz = peekVoxel0px0py1pz() > 0 ? 1: 0; - const uchar pVoxel0px1py1nz = peekVoxel0px1py1nz() > 0 ? 1: 0; - const uchar pVoxel0px1py0pz = peekVoxel0px1py0pz() > 0 ? 1: 0; - const uchar pVoxel0px1py1pz = peekVoxel0px1py1pz() > 0 ? 1: 0; + const uint8_t pVoxel0px1ny1nz = peekVoxel0px1ny1nz() > 0 ? 1: 0; + const uint8_t pVoxel0px1ny0pz = peekVoxel0px1ny0pz() > 0 ? 1: 0; + const uint8_t pVoxel0px1ny1pz = peekVoxel0px1ny1pz() > 0 ? 1: 0; + const uint8_t pVoxel0px0py1nz = peekVoxel0px0py1nz() > 0 ? 1: 0; + //const uint8_t pVoxel0px0py0pz = peekVoxel0px0py0pz() > 0 ? 1: 0; + const uint8_t pVoxel0px0py1pz = peekVoxel0px0py1pz() > 0 ? 1: 0; + const uint8_t pVoxel0px1py1nz = peekVoxel0px1py1nz() > 0 ? 1: 0; + const uint8_t pVoxel0px1py0pz = peekVoxel0px1py0pz() > 0 ? 1: 0; + const uint8_t pVoxel0px1py1pz = peekVoxel0px1py1pz() > 0 ? 1: 0; - const uchar pVoxel1px1ny1nz = peekVoxel1px1ny1nz() > 0 ? 1: 0; - const uchar pVoxel1px1ny0pz = peekVoxel1px1ny0pz() > 0 ? 1: 0; - const uchar pVoxel1px1ny1pz = peekVoxel1px1ny1pz() > 0 ? 1: 0; - const uchar pVoxel1px0py1nz = peekVoxel1px0py1nz() > 0 ? 1: 0; - const uchar pVoxel1px0py0pz = peekVoxel1px0py0pz() > 0 ? 1: 0; - const uchar pVoxel1px0py1pz = peekVoxel1px0py1pz() > 0 ? 1: 0; - const uchar pVoxel1px1py1nz = peekVoxel1px1py1nz() > 0 ? 1: 0; - const uchar pVoxel1px1py0pz = peekVoxel1px1py0pz() > 0 ? 1: 0; - const uchar pVoxel1px1py1pz = peekVoxel1px1py1pz() > 0 ? 1: 0; + const uint8_t pVoxel1px1ny1nz = peekVoxel1px1ny1nz() > 0 ? 1: 0; + const uint8_t pVoxel1px1ny0pz = peekVoxel1px1ny0pz() > 0 ? 1: 0; + const uint8_t pVoxel1px1ny1pz = peekVoxel1px1ny1pz() > 0 ? 1: 0; + const uint8_t pVoxel1px0py1nz = peekVoxel1px0py1nz() > 0 ? 1: 0; + const uint8_t pVoxel1px0py0pz = peekVoxel1px0py0pz() > 0 ? 1: 0; + const uint8_t pVoxel1px0py1pz = peekVoxel1px0py1pz() > 0 ? 1: 0; + const uint8_t pVoxel1px1py1nz = peekVoxel1px1py1nz() > 0 ? 1: 0; + const uint8_t pVoxel1px1py0pz = peekVoxel1px1py0pz() > 0 ? 1: 0; + const uint8_t pVoxel1px1py1pz = peekVoxel1px1py1pz() > 0 ? 1: 0; @@ -295,22 +297,22 @@ namespace Ogre return Vector3(xGrad,yGrad,zGrad); } - uint VolumeIterator::getPosX(void) + uint16_t VolumeIterator::getPosX(void) { return mXPosInVolume; } - uint VolumeIterator::getPosY(void) + uint16_t VolumeIterator::getPosY(void) { return mYPosInVolume; } - uint VolumeIterator::getPosZ(void) + uint16_t VolumeIterator::getPosZ(void) { return mZPosInVolume; } - void VolumeIterator::setPosition(uint xPos, uint yPos, uint zPos) + void VolumeIterator::setPosition(uint16_t xPos, uint16_t yPos, uint16_t zPos) { mXPosInVolume = xPos; mYPosInVolume = yPos; @@ -336,7 +338,7 @@ namespace Ogre mCurrentVoxel = currentBlock->mData + mVoxelIndexInBlock; } - void VolumeIterator::setValidRegion(uint xFirst, uint yFirst, uint zFirst, uint xLast, uint yLast, uint zLast) + void VolumeIterator::setValidRegion(uint16_t xFirst, uint16_t yFirst, uint16_t zFirst, uint16_t xLast, uint16_t yLast, uint16_t zLast) { mXRegionFirst = xFirst; mYRegionFirst = yFirst; @@ -370,7 +372,7 @@ namespace Ogre mXPosInVolume++; if((mXPosInBlock == OGRE_BLOCK_SIDE_LENGTH) || (mXPosInVolume > mXRegionLast)) { - mXPosInVolume = (std::max)(mXRegionFirst,mXBlock * OGRE_BLOCK_SIDE_LENGTH); + mXPosInVolume = (std::max)(mXRegionFirst,uint16_t(mXBlock * OGRE_BLOCK_SIDE_LENGTH)); mXPosInBlock = mXPosInVolume - (mXBlock << OGRE_BLOCK_SIDE_LENGTH_POWER); mVoxelIndexInBlock = mXPosInBlock + mYPosInBlock * OGRE_BLOCK_SIDE_LENGTH + @@ -383,7 +385,7 @@ namespace Ogre mCurrentVoxel += OGRE_BLOCK_SIDE_LENGTH; if((mYPosInBlock == OGRE_BLOCK_SIDE_LENGTH) || (mYPosInVolume > mYRegionLast)) { - mYPosInVolume = (std::max)(mYRegionFirst,mYBlock * OGRE_BLOCK_SIDE_LENGTH); + mYPosInVolume = (std::max)(mYRegionFirst,uint16_t(mYBlock * OGRE_BLOCK_SIDE_LENGTH)); mYPosInBlock = mYPosInVolume - (mYBlock << OGRE_BLOCK_SIDE_LENGTH_POWER); mVoxelIndexInBlock = mXPosInBlock + mYPosInBlock * OGRE_BLOCK_SIDE_LENGTH + @@ -430,9 +432,9 @@ namespace Ogre Block* currentBlock = mVolume.mBlocks[mBlockIndexInVolume]; //mCurrentBlock = mVolume->mBlocks[mBlockIndexInVolume]; - mXPosInVolume = (std::max)(mXRegionFirst,mXBlock * OGRE_BLOCK_SIDE_LENGTH); - mYPosInVolume = (std::max)(mYRegionFirst,mYBlock * OGRE_BLOCK_SIDE_LENGTH); - mZPosInVolume = (std::max)(mZRegionFirst,mZBlock * OGRE_BLOCK_SIDE_LENGTH); + mXPosInVolume = (std::max)(mXRegionFirst,uint16_t(mXBlock * OGRE_BLOCK_SIDE_LENGTH)); + mYPosInVolume = (std::max)(mYRegionFirst,uint16_t(mYBlock * OGRE_BLOCK_SIDE_LENGTH)); + mZPosInVolume = (std::max)(mZRegionFirst,uint16_t(mZBlock * OGRE_BLOCK_SIDE_LENGTH)); mXPosInBlock = mXPosInVolume - (mXBlock << OGRE_BLOCK_SIDE_LENGTH_POWER); mYPosInBlock = mYPosInVolume - (mYBlock << OGRE_BLOCK_SIDE_LENGTH_POWER); @@ -453,7 +455,7 @@ namespace Ogre return mIsValidForRegion; } - uchar VolumeIterator::peekVoxel1nx1ny1nz(void) const + uint8_t VolumeIterator::peekVoxel1nx1ny1nz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -462,7 +464,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1); } - uchar VolumeIterator::peekVoxel1nx1ny0pz(void) const + uint8_t VolumeIterator::peekVoxel1nx1ny0pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -471,7 +473,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume); } - uchar VolumeIterator::peekVoxel1nx1ny1pz(void) const + uint8_t VolumeIterator::peekVoxel1nx1ny1pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -480,7 +482,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1); } - uchar VolumeIterator::peekVoxel1nx0py1nz(void) const + uint8_t VolumeIterator::peekVoxel1nx0py1nz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -489,7 +491,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1); } - uchar VolumeIterator::peekVoxel1nx0py0pz(void) const + uint8_t VolumeIterator::peekVoxel1nx0py0pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -498,7 +500,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume); } - uchar VolumeIterator::peekVoxel1nx0py1pz(void) const + uint8_t VolumeIterator::peekVoxel1nx0py1pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -507,7 +509,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1); } - uchar VolumeIterator::peekVoxel1nx1py1nz(void) const + uint8_t VolumeIterator::peekVoxel1nx1py1nz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -516,7 +518,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1); } - uchar VolumeIterator::peekVoxel1nx1py0pz(void) const + uint8_t VolumeIterator::peekVoxel1nx1py0pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -525,7 +527,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume); } - uchar VolumeIterator::peekVoxel1nx1py1pz(void) const + uint8_t VolumeIterator::peekVoxel1nx1py1pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -536,7 +538,7 @@ namespace Ogre ////////////////////////////////////////////////////////////////////////// - uchar VolumeIterator::peekVoxel0px1ny1nz(void) const + uint8_t VolumeIterator::peekVoxel0px1ny1nz(void) const { if((mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -545,7 +547,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1); } - uchar VolumeIterator::peekVoxel0px1ny0pz(void) const + uint8_t VolumeIterator::peekVoxel0px1ny0pz(void) const { if((mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -554,7 +556,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume); } - uchar VolumeIterator::peekVoxel0px1ny1pz(void) const + uint8_t VolumeIterator::peekVoxel0px1ny1pz(void) const { if((mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -563,7 +565,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1); } - uchar VolumeIterator::peekVoxel0px0py1nz(void) const + uint8_t VolumeIterator::peekVoxel0px0py1nz(void) const { if((mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -572,12 +574,12 @@ namespace Ogre return getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1); } - uchar VolumeIterator::peekVoxel0px0py0pz(void) const + uint8_t VolumeIterator::peekVoxel0px0py0pz(void) const { return *mCurrentVoxel; } - uchar VolumeIterator::peekVoxel0px0py1pz(void) const + uint8_t VolumeIterator::peekVoxel0px0py1pz(void) const { if((mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -586,7 +588,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1); } - uchar VolumeIterator::peekVoxel0px1py1nz(void) const + uint8_t VolumeIterator::peekVoxel0px1py1nz(void) const { if((mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -595,7 +597,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1); } - uchar VolumeIterator::peekVoxel0px1py0pz(void) const + uint8_t VolumeIterator::peekVoxel0px1py0pz(void) const { if((mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -604,7 +606,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume); } - uchar VolumeIterator::peekVoxel0px1py1pz(void) const + uint8_t VolumeIterator::peekVoxel0px1py1pz(void) const { if((mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -615,7 +617,7 @@ namespace Ogre ////////////////////////////////////////////////////////////////////////// - uchar VolumeIterator::peekVoxel1px1ny1nz(void) const + uint8_t VolumeIterator::peekVoxel1px1ny1nz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -624,7 +626,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1); } - uchar VolumeIterator::peekVoxel1px1ny0pz(void) const + uint8_t VolumeIterator::peekVoxel1px1ny0pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -633,7 +635,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume); } - uchar VolumeIterator::peekVoxel1px1ny1pz(void) const + uint8_t VolumeIterator::peekVoxel1px1ny1pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -642,7 +644,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1); } - uchar VolumeIterator::peekVoxel1px0py1nz(void) const + uint8_t VolumeIterator::peekVoxel1px0py1nz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -651,7 +653,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1); } - uchar VolumeIterator::peekVoxel1px0py0pz(void) const + uint8_t VolumeIterator::peekVoxel1px0py0pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -660,7 +662,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume); } - uchar VolumeIterator::peekVoxel1px0py1pz(void) const + uint8_t VolumeIterator::peekVoxel1px0py1pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -669,7 +671,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1); } - uchar VolumeIterator::peekVoxel1px1py1nz(void) const + uint8_t VolumeIterator::peekVoxel1px1py1nz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != 0)) { @@ -678,7 +680,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1); } - uchar VolumeIterator::peekVoxel1px1py0pz(void) const + uint8_t VolumeIterator::peekVoxel1px1py0pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) { @@ -687,7 +689,7 @@ namespace Ogre return getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume); } - uchar VolumeIterator::peekVoxel1px1py1pz(void) const + uint8_t VolumeIterator::peekVoxel1px1py1pz(void) const { if((mXPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mYPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1) && (mZPosInVolume%OGRE_BLOCK_SIDE_LENGTH != OGRE_BLOCK_SIDE_LENGTH-1)) {