diff --git a/PolyVoxCore/include/Block.h b/PolyVoxCore/include/Block.h index e588249b..2c55fe5c 100644 --- a/PolyVoxCore/include/Block.h +++ b/PolyVoxCore/include/Block.h @@ -36,22 +36,22 @@ namespace PolyVox //Make BlockVolumeIterator a friend friend class BlockVolumeIterator; public: - Block(std::uint8_t uSideLengthPower); + Block(uint8 uSideLengthPower); Block(const Block& rhs); ~Block(); Block& operator=(const Block& rhs); - std::uint16_t getSideLength(void) const; - VoxelType getVoxelAt(std::uint16_t uXPos, std::uint16_t uYPos, std::uint16_t uZPos) const; + uint16 getSideLength(void) const; + VoxelType getVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos) const; - void setVoxelAt(std::uint16_t uXPos, std::uint16_t uYPos, std::uint16_t uZPos, VoxelType tValue); + void setVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos, VoxelType tValue); void fill(VoxelType tValue); private: - std::uint8_t m_uSideLengthPower; - std::uint16_t m_uSideLength; + uint8 m_uSideLengthPower; + uint16 m_uSideLength; VoxelType* m_tData; }; } diff --git a/PolyVoxCore/include/Block.inl b/PolyVoxCore/include/Block.inl index 497d7c59..2b0f81d7 100644 --- a/PolyVoxCore/include/Block.inl +++ b/PolyVoxCore/include/Block.inl @@ -29,7 +29,7 @@ namespace PolyVox { #pragma region Constructors/Destructors template - Block::Block(std::uint8_t uSideLengthPower) + Block::Block(uint8 uSideLengthPower) :m_tData(0) { //Check the block size is sensible. This corresponds to a side length of 256 voxels @@ -76,13 +76,13 @@ namespace PolyVox #pragma region Getters template - std::uint16_t Block::getSideLength(void) const + uint16 Block::getSideLength(void) const { return m_uSideLength; } template - VoxelType Block::getVoxelAt(std::uint16_t uXPos, std::uint16_t uYPos, std::uint16_t uZPos) const + VoxelType Block::getVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos) const { assert(uXPos < m_uSideLength); assert(uYPos < m_uSideLength); @@ -99,7 +99,7 @@ namespace PolyVox #pragma region Setters template - void Block::setVoxelAt(std::uint16_t uXPos, std::uint16_t uYPos, std::uint16_t uZPos, VoxelType tValue) + void Block::setVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos, VoxelType tValue) { assert(uXPos < m_uSideLength); assert(uYPos < m_uSideLength); diff --git a/PolyVoxCore/include/BlockVolume.h b/PolyVoxCore/include/BlockVolume.h index a9cba7cf..2229a20d 100644 --- a/PolyVoxCore/include/BlockVolume.h +++ b/PolyVoxCore/include/BlockVolume.h @@ -39,21 +39,21 @@ namespace PolyVox friend class BlockVolumeIterator; public: - BlockVolume(std::uint8_t uSideLengthPower, std::uint8_t uBlockSideLengthPower = 5); + BlockVolume(uint8 uSideLengthPower, uint8 uBlockSideLengthPower = 5); BlockVolume(const BlockVolume& rhs); ~BlockVolume(); BlockVolume& operator=(const BlockVolume& rhs); Region getEnclosingRegion(void) const; - std::uint16_t getSideLength(void) const; - VoxelType getVoxelAt(std::uint16_t uXPos, std::uint16_t uYPos, std::uint16_t uZPos) const; + uint16 getSideLength(void) const; + VoxelType getVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos) const; VoxelType getVoxelAt(const Vector3DUint16& v3dPos) const; bool containsPoint(const Vector3DFloat& pos, float boundary) const; - bool containsPoint(const Vector3DInt32& pos, std::uint16_t boundary) const; + bool containsPoint(const Vector3DInt32& pos, uint16 boundary) const; BlockVolumeIterator firstVoxel(void); - void idle(std::uint32_t uAmount); + void idle(uint32 uAmount); BlockVolumeIterator lastVoxel(void); private: @@ -65,20 +65,20 @@ namespace PolyVox VoxelType* m_pHomogenousValue; mutable std::map*> m_pHomogenousBlocks; - std::uint32_t m_uNoOfBlocksInVolume; - std::uint16_t m_uSideLengthInBlocks; + uint32 m_uNoOfBlocksInVolume; + uint16 m_uSideLengthInBlocks; - std::uint8_t m_uSideLengthPower; - std::uint16_t m_uSideLength; + uint8 m_uSideLengthPower; + uint16 m_uSideLength; - std::uint8_t m_uBlockSideLengthPower; - std::uint16_t m_uBlockSideLength; + uint8 m_uBlockSideLengthPower; + uint16 m_uBlockSideLength; }; //Some handy typedefs typedef BlockVolume FloatBlockVolume; - typedef BlockVolume UInt8BlockVolume; - typedef BlockVolume UInt16BlockVolume; + typedef BlockVolume UInt8BlockVolume; + typedef BlockVolume UInt16BlockVolume; } #include "BlockVolume.inl" diff --git a/PolyVoxCore/include/BlockVolume.inl b/PolyVoxCore/include/BlockVolume.inl index 8a6ed0c0..edc389aa 100644 --- a/PolyVoxCore/include/BlockVolume.inl +++ b/PolyVoxCore/include/BlockVolume.inl @@ -32,7 +32,7 @@ namespace PolyVox { #pragma region Constructors/Destructors template - BlockVolume::BlockVolume(std::uint8_t uSideLengthPower, std::uint8_t uBlockSideLengthPower) + BlockVolume::BlockVolume(uint8 uSideLengthPower, uint8 uBlockSideLengthPower) :m_pBlocks(0) { //Check the volume size is sensible. This corresponds to a side length of 65536 voxels @@ -60,7 +60,7 @@ namespace PolyVox m_pIsShared = new bool[m_uNoOfBlocksInVolume]; m_pIsPotentiallySharable = new bool[m_uNoOfBlocksInVolume]; m_pHomogenousValue = new VoxelType[m_uNoOfBlocksInVolume]; - for(std::uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i) + for(uint32 i = 0; i < m_uNoOfBlocksInVolume; ++i) { m_pBlocks[i] = getHomogenousBlock(0); //new Block(uBlockSideLengthPower); m_pIsShared[i] = true; @@ -78,7 +78,7 @@ namespace PolyVox template BlockVolume::~BlockVolume() { - for(std::uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i) + for(uint32 i = 0; i < m_uNoOfBlocksInVolume; ++i) { delete m_pBlocks[i]; } @@ -94,13 +94,13 @@ namespace PolyVox return *this; } - /*for(uint16_t i = 0; i < POLYVOX_NO_OF_BLOCKS_IN_VOLUME; ++i) + /*for(uint16 i = 0; i < POLYVOX_NO_OF_BLOCKS_IN_VOLUME; ++i) { //FIXME - Add checking... m_pBlocks[i] = SharedPtr(new Block); }*/ - for(uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i) + for(uint32 i = 0; i < m_uNoOfBlocksInVolume; ++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. @@ -127,25 +127,25 @@ namespace PolyVox } template - std::uint16_t BlockVolume::getSideLength(void) const + uint16 BlockVolume::getSideLength(void) const { return m_uSideLength; } template - VoxelType BlockVolume::getVoxelAt(std::uint16_t uXPos, std::uint16_t uYPos, std::uint16_t uZPos) const + VoxelType BlockVolume::getVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos) const { assert(uXPos < getSideLength()); assert(uYPos < getSideLength()); assert(uZPos < getSideLength()); - const std::uint16_t blockX = uXPos >> m_uBlockSideLengthPower; - const std::uint16_t blockY = uYPos >> m_uBlockSideLengthPower; - const std::uint16_t blockZ = uZPos >> m_uBlockSideLengthPower; + const uint16 blockX = uXPos >> m_uBlockSideLengthPower; + const uint16 blockY = uYPos >> m_uBlockSideLengthPower; + const uint16 blockZ = uZPos >> m_uBlockSideLengthPower; - const std::uint16_t xOffset = uXPos - (blockX << m_uBlockSideLengthPower); - const std::uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower); - const std::uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); + const uint16 xOffset = uXPos - (blockX << m_uBlockSideLengthPower); + const uint16 yOffset = uYPos - (blockY << m_uBlockSideLengthPower); + const uint16 zOffset = uZPos - (blockZ << m_uBlockSideLengthPower); const Block* block = m_pBlocks [ @@ -181,7 +181,7 @@ namespace PolyVox } template - bool BlockVolume::containsPoint(const Vector3DInt32& pos, std::uint16_t boundary) const + bool BlockVolume::containsPoint(const Vector3DInt32& pos, uint16 boundary) const { return (pos.getX() <= m_uSideLength - 1 - boundary) && (pos.getY() <= m_uSideLength - 1 - boundary) @@ -200,7 +200,7 @@ namespace PolyVox } template - void BlockVolume::idle(std::uint32_t uAmount) + void BlockVolume::idle(uint32 uAmount) { } diff --git a/PolyVoxCore/include/BlockVolumeIterator.h b/PolyVoxCore/include/BlockVolumeIterator.h index ef96a7e8..939ded5e 100644 --- a/PolyVoxCore/include/BlockVolumeIterator.h +++ b/PolyVoxCore/include/BlockVolumeIterator.h @@ -43,17 +43,17 @@ namespace PolyVox bool operator<=(const BlockVolumeIterator& rhs); bool operator>=(const BlockVolumeIterator& rhs); - std::uint16_t getPosX(void) const; - std::uint16_t getPosY(void) const; - std::uint16_t getPosZ(void) const; - VoxelType getSubSampledVoxel(std::uint8_t uLevel) const; + uint16 getPosX(void) const; + uint16 getPosY(void) const; + uint16 getPosZ(void) const; + VoxelType getSubSampledVoxel(uint8 uLevel) const; const BlockVolume& getVolume(void) const; VoxelType getVoxel(void) const; void setPosition(const Vector3DInt16& v3dNewPos); - void setPosition(std::uint16_t xPos, std::uint16_t yPos, std::uint16_t zPos); + void setPosition(uint16 xPos, uint16 yPos, uint16 zPos); void setValidRegion(const Region& region); - void setValidRegion(std::uint16_t xFirst, std::uint16_t yFirst, std::uint16_t zFirst, std::uint16_t xLast, std::uint16_t yLast, std::uint16_t zLast); + void setValidRegion(uint16 xFirst, uint16 yFirst, uint16 zFirst, uint16 xLast, uint16 yLast, uint16 zLast); void setVoxel(VoxelType tValue); bool isValidForRegion(void) const; @@ -96,38 +96,38 @@ namespace PolyVox BlockVolume& mVolume; //The current position in the volume - std::uint16_t mXPosInVolume; - std::uint16_t mYPosInVolume; - std::uint16_t mZPosInVolume; + uint16 mXPosInVolume; + uint16 mYPosInVolume; + uint16 mZPosInVolume; //The position of the current block - std::uint16_t mXBlock; - std::uint16_t mYBlock; - std::uint16_t mZBlock; + uint16 mXBlock; + uint16 mYBlock; + uint16 mZBlock; //The offset into the current block - std::uint16_t mXPosInBlock; - std::uint16_t mYPosInBlock; - std::uint16_t mZPosInBlock; + uint16 mXPosInBlock; + uint16 mYPosInBlock; + uint16 mZPosInBlock; //Other current position information VoxelType* mCurrentVoxel; - std::uint32_t mBlockIndexInVolume; - std::uint32_t mVoxelIndexInBlock; + uint32 mBlockIndexInVolume; + uint32 mVoxelIndexInBlock; - std::uint16_t mXRegionFirst; - std::uint16_t mYRegionFirst; - std::uint16_t mZRegionFirst; - std::uint16_t mXRegionLast; - std::uint16_t mYRegionLast; - std::uint16_t mZRegionLast; + uint16 mXRegionFirst; + uint16 mYRegionFirst; + uint16 mZRegionFirst; + uint16 mXRegionLast; + uint16 mYRegionLast; + uint16 mZRegionLast; - std::uint16_t mXRegionFirstBlock; - std::uint16_t mYRegionFirstBlock; - std::uint16_t mZRegionFirstBlock; - std::uint16_t mXRegionLastBlock; - std::uint16_t mYRegionLastBlock; - std::uint16_t mZRegionLastBlock; + uint16 mXRegionFirstBlock; + uint16 mYRegionFirstBlock; + uint16 mZRegionFirstBlock; + uint16 mXRegionLastBlock; + uint16 mYRegionLastBlock; + uint16 mZRegionLastBlock; bool mIsValidForRegion; }; diff --git a/PolyVoxCore/include/BlockVolumeIterator.inl b/PolyVoxCore/include/BlockVolumeIterator.inl index 1d8fd9bf..bc117e15 100644 --- a/PolyVoxCore/include/BlockVolumeIterator.inl +++ b/PolyVoxCore/include/BlockVolumeIterator.inl @@ -105,25 +105,25 @@ namespace PolyVox #pragma region Getters template - std::uint16_t BlockVolumeIterator::getPosX(void) const + uint16 BlockVolumeIterator::getPosX(void) const { return mXPosInVolume; } template - std::uint16_t BlockVolumeIterator::getPosY(void) const + uint16 BlockVolumeIterator::getPosY(void) const { return mYPosInVolume; } template - std::uint16_t BlockVolumeIterator::getPosZ(void) const + uint16 BlockVolumeIterator::getPosZ(void) const { return mZPosInVolume; } template - VoxelType BlockVolumeIterator::getSubSampledVoxel(std::uint8_t uLevel) const + VoxelType BlockVolumeIterator::getSubSampledVoxel(uint8 uLevel) const { if(uLevel == 0) { @@ -143,14 +143,14 @@ namespace PolyVox } else { - const std::uint8_t uSize = 1 << uLevel; + const uint8 uSize = 1 << uLevel; VoxelType tValue = 0; - for(std::uint8_t z = 0; z < uSize; ++z) + for(uint8 z = 0; z < uSize; ++z) { - for(std::uint8_t y = 0; y < uSize; ++y) + for(uint8 y = 0; y < uSize; ++y) { - for(std::uint8_t x = 0; x < uSize; ++x) + for(uint8 x = 0; x < uSize; ++x) { tValue = (std::max)(tValue, mVolume.getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z)); } @@ -181,7 +181,7 @@ namespace PolyVox } template - void BlockVolumeIterator::setPosition(std::uint16_t xPos, std::uint16_t yPos, std::uint16_t zPos) + void BlockVolumeIterator::setPosition(uint16 xPos, uint16 yPos, uint16 zPos) { mXPosInVolume = xPos; mYPosInVolume = yPos; @@ -214,7 +214,7 @@ namespace PolyVox } template - void BlockVolumeIterator::setValidRegion(std::uint16_t xFirst, std::uint16_t yFirst, std::uint16_t zFirst, std::uint16_t xLast, std::uint16_t yLast, std::uint16_t zLast) + void BlockVolumeIterator::setValidRegion(uint16 xFirst, uint16 yFirst, uint16 zFirst, uint16 xLast, uint16 yLast, uint16 zLast) { mXRegionFirst = xFirst; mYRegionFirst = yFirst; @@ -236,7 +236,7 @@ namespace PolyVox template void BlockVolumeIterator::setVoxel(VoxelType tValue) { - const std::uint32_t uBlockIndex = + const uint32 uBlockIndex = mXBlock + mYBlock * mVolume.m_uSideLengthInBlocks + mZBlock * mVolume.m_uSideLengthInBlocks * mVolume.m_uSideLengthInBlocks; @@ -278,7 +278,7 @@ namespace PolyVox mXPosInVolume++; if((mXPosInBlock == mVolume.m_uBlockSideLength) || (mXPosInVolume > mXRegionLast)) { - mXPosInVolume = (std::max)(mXRegionFirst,uint16_t(mXBlock * mVolume.m_uBlockSideLength)); + mXPosInVolume = (std::max)(mXRegionFirst,uint16(mXBlock * mVolume.m_uBlockSideLength)); mXPosInBlock = mXPosInVolume - (mXBlock << mVolume.m_uBlockSideLengthPower); mVoxelIndexInBlock = mXPosInBlock + mYPosInBlock * mVolume.m_uBlockSideLength + @@ -291,7 +291,7 @@ namespace PolyVox mCurrentVoxel += mVolume.m_uBlockSideLength; if((mYPosInBlock == mVolume.m_uBlockSideLength) || (mYPosInVolume > mYRegionLast)) { - mYPosInVolume = (std::max)(mYRegionFirst,uint16_t(mYBlock * mVolume.m_uBlockSideLength)); + mYPosInVolume = (std::max)(mYRegionFirst,uint16(mYBlock * mVolume.m_uBlockSideLength)); mYPosInBlock = mYPosInVolume - (mYBlock << mVolume.m_uBlockSideLengthPower); mVoxelIndexInBlock = mXPosInBlock + mYPosInBlock * mVolume.m_uBlockSideLength + @@ -338,9 +338,9 @@ namespace PolyVox Block* currentBlock = mVolume.m_pBlocks[mBlockIndexInVolume]; //mCurrentBlock = mVolume->m_pBlocks[mBlockIndexInVolume]; - mXPosInVolume = (std::max)(mXRegionFirst,uint16_t(mXBlock * mVolume.m_uBlockSideLength)); - mYPosInVolume = (std::max)(mYRegionFirst,uint16_t(mYBlock * mVolume.m_uBlockSideLength)); - mZPosInVolume = (std::max)(mZRegionFirst,uint16_t(mZBlock * mVolume.m_uBlockSideLength)); + mXPosInVolume = (std::max)(mXRegionFirst,uint16(mXBlock * mVolume.m_uBlockSideLength)); + mYPosInVolume = (std::max)(mYRegionFirst,uint16(mYBlock * mVolume.m_uBlockSideLength)); + mZPosInVolume = (std::max)(mZRegionFirst,uint16(mZBlock * mVolume.m_uBlockSideLength)); mXPosInBlock = mXPosInVolume - (mXBlock << mVolume.m_uBlockSideLengthPower); mYPosInBlock = mYPosInVolume - (mYBlock << mVolume.m_uBlockSideLengthPower); diff --git a/PolyVoxCore/include/Constants.h b/PolyVoxCore/include/Constants.h index a4c9fa6a..6bfe2e23 100644 --- a/PolyVoxCore/include/Constants.h +++ b/PolyVoxCore/include/Constants.h @@ -22,24 +22,24 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef __PolyVox_Constants_H__ #define __PolyVox_Constants_H__ -#include "PolyVoxCStdInt.h" +#include "PolyVoxForwardDeclarations.h" namespace PolyVox { //FIXME - i think we can define mod using a bitmask which flattens the upper bits. Should define that here. - //const std::uint32_t POLYVOX_BLOCK_SIDE_LENGTH_POWER = 5; - //const std::uint32_t POLYVOX_BLOCK_SIDE_LENGTH = (0x0001 << POLYVOX_BLOCK_SIDE_LENGTH_POWER); - //const std::uint32_t POLYVOX_NO_OF_VOXELS_IN_BLOCK = (POLYVOX_BLOCK_SIDE_LENGTH * POLYVOX_BLOCK_SIDE_LENGTH * POLYVOX_BLOCK_SIDE_LENGTH); + //const uint32 POLYVOX_BLOCK_SIDE_LENGTH_POWER = 5; + //const uint32 POLYVOX_BLOCK_SIDE_LENGTH = (0x0001 << POLYVOX_BLOCK_SIDE_LENGTH_POWER); + //const uint32 POLYVOX_NO_OF_VOXELS_IN_BLOCK = (POLYVOX_BLOCK_SIDE_LENGTH * POLYVOX_BLOCK_SIDE_LENGTH * POLYVOX_BLOCK_SIDE_LENGTH); - const std::uint16_t POLYVOX_VOLUME_SIDE_LENGTH_POWER = 8; - const std::uint16_t POLYVOX_VOLUME_SIDE_LENGTH = (0x0001 << POLYVOX_VOLUME_SIDE_LENGTH_POWER); - //const std::uint32_t POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS = (POLYVOX_VOLUME_SIDE_LENGTH >> POLYVOX_BLOCK_SIDE_LENGTH_POWER); - //const std::uint32_t POLYVOX_NO_OF_BLOCKS_IN_VOLUME = (POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS * POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS * POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS); - //const std::uint32_t POLYVOX_NO_OF_VOXELS_IN_VOLUME = (POLYVOX_VOLUME_SIDE_LENGTH * POLYVOX_VOLUME_SIDE_LENGTH * POLYVOX_VOLUME_SIDE_LENGTH); + const uint16 POLYVOX_VOLUME_SIDE_LENGTH_POWER = 8; + const uint16 POLYVOX_VOLUME_SIDE_LENGTH = (0x0001 << POLYVOX_VOLUME_SIDE_LENGTH_POWER); + //const uint32 POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS = (POLYVOX_VOLUME_SIDE_LENGTH >> POLYVOX_BLOCK_SIDE_LENGTH_POWER); + //const uint32 POLYVOX_NO_OF_BLOCKS_IN_VOLUME = (POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS * POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS * POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS); + //const uint32 POLYVOX_NO_OF_VOXELS_IN_VOLUME = (POLYVOX_VOLUME_SIDE_LENGTH * POLYVOX_VOLUME_SIDE_LENGTH * POLYVOX_VOLUME_SIDE_LENGTH); - const std::uint16_t POLYVOX_REGION_SIDE_LENGTH_POWER = 4; - const std::uint16_t POLYVOX_REGION_SIDE_LENGTH = (0x0001 << POLYVOX_REGION_SIDE_LENGTH_POWER); - const std::uint16_t POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS = (POLYVOX_VOLUME_SIDE_LENGTH >> POLYVOX_REGION_SIDE_LENGTH_POWER); + const uint16 POLYVOX_REGION_SIDE_LENGTH_POWER = 4; + const uint16 POLYVOX_REGION_SIDE_LENGTH = (0x0001 << POLYVOX_REGION_SIDE_LENGTH_POWER); + const uint16 POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS = (POLYVOX_VOLUME_SIDE_LENGTH >> POLYVOX_REGION_SIDE_LENGTH_POWER); } #endif diff --git a/PolyVoxCore/include/GradientEstimators.h b/PolyVoxCore/include/GradientEstimators.h index bbd23502..8289bbf4 100644 --- a/PolyVoxCore/include/GradientEstimators.h +++ b/PolyVoxCore/include/GradientEstimators.h @@ -40,8 +40,8 @@ namespace PolyVox template Vector3DFloat computeSobelGradient(const BlockVolumeIterator& volIter); - POLYVOX_API void computeNormalsForVertices(BlockVolume* volumeData, RegionGeometry& regGeom, NormalGenerationMethod normalGenerationMethod); - POLYVOX_API Vector3DFloat computeNormal(BlockVolume* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod); + POLYVOX_API void computeNormalsForVertices(BlockVolume* volumeData, RegionGeometry& regGeom, NormalGenerationMethod normalGenerationMethod); + POLYVOX_API Vector3DFloat computeNormal(BlockVolume* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod); } #include "GradientEstimators.inl" diff --git a/PolyVoxCore/include/GradientEstimators.inl b/PolyVoxCore/include/GradientEstimators.inl index a568c491..333f79b0 100644 --- a/PolyVoxCore/include/GradientEstimators.inl +++ b/PolyVoxCore/include/GradientEstimators.inl @@ -47,9 +47,9 @@ namespace PolyVox template Vector3DFloat computeDecimatedCentralDifferenceGradient(const BlockVolumeIterator& volIter) { - const uint16_t x = volIter.getPosX(); - const uint16_t y = volIter.getPosY(); - const uint16_t z = volIter.getPosZ(); + const uint16 x = volIter.getPosX(); + const uint16 y = volIter.getPosY(); + const uint16 z = volIter.getPosZ(); //FIXME - bitwise way of doing this? VoxelType voxel1nx = volIter.getVoxelAt(x-2, y ,z ) > 0 ? 1: 0; @@ -72,9 +72,9 @@ namespace PolyVox template Vector3DFloat computeSmoothCentralDifferenceGradient(BlockVolumeIterator& volIter) { - std::uint16_t initialX = volIter.getPosX(); - std::uint16_t initialY = volIter.getPosY(); - std::uint16_t initialZ = volIter.getPosZ(); + uint16 initialX = volIter.getPosX(); + uint16 initialY = volIter.getPosY(); + uint16 initialZ = volIter.getPosZ(); //FIXME - bitwise way of doing this? volIter.setPosition(initialX-1, initialY, initialZ); diff --git a/PolyVoxCore/include/IndexedSurfacePatch.h b/PolyVoxCore/include/IndexedSurfacePatch.h index 65b4c26d..8058df72 100644 --- a/PolyVoxCore/include/IndexedSurfacePatch.h +++ b/PolyVoxCore/include/IndexedSurfacePatch.h @@ -40,17 +40,17 @@ namespace PolyVox ~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); const std::vector& getVertices(void) const; std::vector& getVertices(void); //FIXME - non const version should be removed. - const std::vector& getIndices(void) const; + const std::vector& getIndices(void) const; unsigned short getNoNonUniformTrianges(void); unsigned short getNoUniformTrianges(void); public: - std::vector m_vecTriangleIndices; + std::vector m_vecTriangleIndices; std::vector m_vecVertices; }; diff --git a/PolyVoxCore/include/LinearVolume.h b/PolyVoxCore/include/LinearVolume.h index aed86502..a4c9975b 100644 --- a/PolyVoxCore/include/LinearVolume.h +++ b/PolyVoxCore/include/LinearVolume.h @@ -36,7 +36,7 @@ namespace PolyVox class LinearVolume { public: - LinearVolume(std::uint8_t uSideLengthPower); + LinearVolume(uint8 uSideLengthPower); LinearVolume(const LinearVolume& rhs); ~LinearVolume(); @@ -44,17 +44,17 @@ namespace PolyVox //bool isHomogeneous(void); - std::uint16_t getSideLength(void); + uint16 getSideLength(void); - VoxelType getVoxelAt(const std::uint16_t xPosition, const std::uint16_t yPosition, const std::uint16_t zPosition) const; - void setVoxelAt(const std::uint16_t xPosition, const std::uint16_t yPosition, const std::uint16_t zPosition, const VoxelType value); + VoxelType getVoxelAt(const uint16 xPosition, const uint16 yPosition, const uint16 zPosition) const; + void setVoxelAt(const uint16 xPosition, const uint16 yPosition, const uint16 zPosition, const VoxelType value); //void fillWithValue(const VoxelType value); private: - std::uint32_t getNoOfVoxels(void); - std::uint8_t m_uSideLengthPower; - std::uint16_t m_uSideLength; + uint32 getNoOfVoxels(void); + uint8 m_uSideLengthPower; + uint16 m_uSideLength; VoxelType* m_tData; }; } diff --git a/PolyVoxCore/include/LinearVolume.inl b/PolyVoxCore/include/LinearVolume.inl index 5a0706c9..3e3a9b54 100644 --- a/PolyVoxCore/include/LinearVolume.inl +++ b/PolyVoxCore/include/LinearVolume.inl @@ -25,7 +25,7 @@ namespace PolyVox { template - LinearVolume::LinearVolume(std::uint8_t uSideLengthPower) + LinearVolume::LinearVolume(uint8 uSideLengthPower) :m_tData(0) { //Check the block size is sensible. This corresponds to a side length of 256 voxels @@ -67,7 +67,7 @@ namespace PolyVox } template - VoxelType LinearVolume::getVoxelAt(const std::uint16_t xPosition, const std::uint16_t yPosition, const std::uint16_t zPosition) const + VoxelType LinearVolume::getVoxelAt(const uint16 xPosition, const uint16 yPosition, const uint16 zPosition) const { return m_tData [ @@ -78,7 +78,7 @@ namespace PolyVox } template - void LinearVolume::setVoxelAt(const std::uint16_t xPosition, const std::uint16_t yPosition, const std::uint16_t zPosition, const VoxelType value) + void LinearVolume::setVoxelAt(const uint16 xPosition, const uint16 yPosition, const uint16 zPosition, const VoxelType value) { m_tData [ @@ -89,13 +89,13 @@ namespace PolyVox } template - std::uint16_t LinearVolume::getSideLength(void) + uint16 LinearVolume::getSideLength(void) { return m_uSideLength; } template - std::uint32_t LinearVolume::getNoOfVoxels(void) + uint32 LinearVolume::getNoOfVoxels(void) { return m_uSideLength * m_uSideLength * m_uSideLength; } diff --git a/PolyVoxCore/include/PolyVoxCStdInt.h b/PolyVoxCore/include/PolyVoxCStdInt.h index f3b79d4a..1714c7e9 100644 --- a/PolyVoxCore/include/PolyVoxCStdInt.h +++ b/PolyVoxCore/include/PolyVoxCStdInt.h @@ -24,14 +24,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. //Adding things to the std namespace in not actually allowed, but Microsoft //have still not added to thier standard library. -namespace std +namespace PolyVox { - typedef char int8_t; - typedef short int16_t; - typedef long int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned long uint32_t; + typedef char int8; + typedef short int16; + typedef long int32; + typedef unsigned char uint8; + typedef unsigned short uint16; + typedef unsigned long uint32; } + #endif \ No newline at end of file diff --git a/PolyVoxCore/include/PolyVoxForwardDeclarations.h b/PolyVoxCore/include/PolyVoxForwardDeclarations.h index 2f2b06dc..4bb7667d 100644 --- a/PolyVoxCore/include/PolyVoxForwardDeclarations.h +++ b/PolyVoxCore/include/PolyVoxForwardDeclarations.h @@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define __PolyVox_ForwardDeclarations_H__ #include "Enums.h" - #include "PolyVoxCStdInt.h" namespace PolyVox @@ -33,8 +32,8 @@ namespace PolyVox //---------- BlockVolume ---------- template class BlockVolume; typedef BlockVolume FloatBlockVolume; - typedef BlockVolume UInt8BlockVolume; - typedef BlockVolume UInt16BlockVolume; + typedef BlockVolume UInt8BlockVolume; + typedef BlockVolume UInt16BlockVolume; //--------------------------------- class IndexedSurfacePatch; @@ -45,15 +44,15 @@ namespace PolyVox class SurfaceVertex; //---------- Vector ---------- - template class Vector; + template class Vector; typedef Vector<3,float> Vector3DFloat; typedef Vector<3,double> Vector3DDouble; - typedef Vector<3,std::int8_t> Vector3DInt8; - typedef Vector<3,std::uint8_t> Vector3DUint8; - typedef Vector<3,std::int16_t> Vector3DInt16; - typedef Vector<3,std::uint16_t> Vector3DUint16; - typedef Vector<3,std::int32_t> Vector3DInt32; - typedef Vector<3,std::uint32_t> Vector3DUint32; + typedef Vector<3,int8> Vector3DInt8; + typedef Vector<3,uint8> Vector3DUint8; + typedef Vector<3,int16> Vector3DInt16; + typedef Vector<3,uint16> Vector3DUint16; + typedef Vector<3,int32> Vector3DInt32; + typedef Vector<3,uint32> Vector3DUint32; //---------------------------- class VolumeChangeTracker; diff --git a/PolyVoxCore/include/Region.h b/PolyVoxCore/include/Region.h index 225d8a2c..91150166 100644 --- a/PolyVoxCore/include/Region.h +++ b/PolyVoxCore/include/Region.h @@ -42,7 +42,7 @@ namespace PolyVox void setUpperCorner(const Vector3DInt32& v3dUpperCorner); bool containsPoint(const Vector3DFloat& pos, float boundary) const; - bool containsPoint(const Vector3DInt32& pos, std::uint8_t boundary) const; + bool containsPoint(const Vector3DInt32& pos, uint8 boundary) const; void cropTo(const Region& other); void shift(const Vector3DInt32& amount); diff --git a/PolyVoxCore/include/SurfaceAdjusters.h b/PolyVoxCore/include/SurfaceAdjusters.h index 771b7c51..39561947 100644 --- a/PolyVoxCore/include/SurfaceAdjusters.h +++ b/PolyVoxCore/include/SurfaceAdjusters.h @@ -32,8 +32,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - POLYVOX_API void smoothRegionGeometry(BlockVolume* volumeData, RegionGeometry& regGeom); - POLYVOX_API void adjustDecimatedGeometry(BlockVolume* volumeData, RegionGeometry& regGeom, std::uint8_t val); + POLYVOX_API void smoothRegionGeometry(BlockVolume* volumeData, RegionGeometry& regGeom); + POLYVOX_API void adjustDecimatedGeometry(BlockVolume* volumeData, RegionGeometry& regGeom, uint8 val); } #endif \ No newline at end of file diff --git a/PolyVoxCore/include/SurfaceExtractors.h b/PolyVoxCore/include/SurfaceExtractors.h index ad36f35d..8b0a95a8 100644 --- a/PolyVoxCore/include/SurfaceExtractors.h +++ b/PolyVoxCore/include/SurfaceExtractors.h @@ -36,18 +36,18 @@ namespace PolyVox { POLYVOX_API std::list getChangedRegionGeometry(VolumeChangeTracker& volume); - std::uint32_t getIndex(std::uint32_t x, std::uint32_t y); + uint32 getIndex(uint32 x, uint32 y); - POLYVOX_API void generateRoughMeshDataForRegion(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); - POLYVOX_API std::uint32_t computeInitialRoughBitmaskForSlice(BlockVolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, std::uint8_t *bitmask); - POLYVOX_API std::uint32_t computeRoughBitmaskForSliceFromPrevious(BlockVolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, std::uint8_t *bitmask, std::uint8_t *previousBitmask); - POLYVOX_API void generateRoughIndicesForSlice(BlockVolumeIterator& volIter, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, std::uint8_t* bitmask0, std::uint8_t* bitmask1, std::int32_t vertexIndicesX0[],std::int32_t vertexIndicesY0[],std::int32_t vertexIndicesZ0[], std::int32_t vertexIndicesX1[],std::int32_t vertexIndicesY1[],std::int32_t vertexIndicesZ1[]); - POLYVOX_API void generateRoughVerticesForSlice(BlockVolumeIterator& volIter, Region& regSlice, const Vector3DFloat& offset, std::uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,std::int32_t vertexIndicesX[],std::int32_t vertexIndicesY[],std::int32_t vertexIndicesZ[]); + POLYVOX_API void generateRoughMeshDataForRegion(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); + POLYVOX_API uint32 computeInitialRoughBitmaskForSlice(BlockVolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask); + POLYVOX_API uint32 computeRoughBitmaskForSliceFromPrevious(BlockVolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask, uint8 *previousBitmask); + POLYVOX_API void generateRoughIndicesForSlice(BlockVolumeIterator& volIter, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8* bitmask0, uint8* bitmask1, int32 vertexIndicesX0[],int32 vertexIndicesY0[],int32 vertexIndicesZ0[], int32 vertexIndicesX1[],int32 vertexIndicesY1[],int32 vertexIndicesZ1[]); + POLYVOX_API void generateRoughVerticesForSlice(BlockVolumeIterator& volIter, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]); - POLYVOX_API void generateReferenceMeshDataForRegion(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); + POLYVOX_API void generateReferenceMeshDataForRegion(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); - std::int32_t getIndexFor(const Vector3DFloat& pos, std::int32_t vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]); - void setIndexFor(const Vector3DFloat& pos, std::int32_t newIndex, std::int32_t vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]); + int32 getIndexFor(const Vector3DFloat& pos, int32 vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]); + void setIndexFor(const Vector3DFloat& pos, int32 newIndex, int32 vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]); } #endif diff --git a/PolyVoxCore/include/SurfaceExtractorsDecimated.h b/PolyVoxCore/include/SurfaceExtractorsDecimated.h index 36bd8634..95c5e43a 100644 --- a/PolyVoxCore/include/SurfaceExtractorsDecimated.h +++ b/PolyVoxCore/include/SurfaceExtractorsDecimated.h @@ -34,17 +34,17 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - std::uint32_t getDecimatedIndex(std::uint32_t x, std::uint32_t y); + uint32 getDecimatedIndex(uint32 x, uint32 y); - POLYVOX_API void generateDecimatedMeshDataForRegion(BlockVolume* volumeData, std::uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch); - POLYVOX_API std::uint32_t computeInitialDecimatedBitmaskForSlice(BlockVolumeIterator& volIter, std::uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, std::uint8_t *bitmask); - POLYVOX_API std::uint32_t computeDecimatedBitmaskForSliceFromPrevious(BlockVolumeIterator& volIter, std::uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, std::uint8_t *bitmask, std::uint8_t *previousBitmask); - POLYVOX_API void generateDecimatedIndicesForSlice(BlockVolumeIterator& volIter, std::uint8_t uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, std::uint8_t* bitmask0, std::uint8_t* bitmask1, std::int32_t vertexIndicesX0[],std::int32_t vertexIndicesY0[],std::int32_t vertexIndicesZ0[], std::int32_t vertexIndicesX1[],std::int32_t vertexIndicesY1[],std::int32_t vertexIndicesZ1[]); - POLYVOX_API void generateDecimatedVerticesForSlice(BlockVolumeIterator& volIter, std::uint8_t uLevel, Region& regSlice, const Vector3DFloat& offset, std::uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,std::int32_t vertexIndicesX[],std::int32_t vertexIndicesY[],std::int32_t vertexIndicesZ[]); + POLYVOX_API void generateDecimatedMeshDataForRegion(BlockVolume* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch); + POLYVOX_API uint32 computeInitialDecimatedBitmaskForSlice(BlockVolumeIterator& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask); + POLYVOX_API uint32 computeDecimatedBitmaskForSliceFromPrevious(BlockVolumeIterator& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask, uint8 *previousBitmask); + POLYVOX_API void generateDecimatedIndicesForSlice(BlockVolumeIterator& volIter, uint8 uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8* bitmask0, uint8* bitmask1, int32 vertexIndicesX0[],int32 vertexIndicesY0[],int32 vertexIndicesZ0[], int32 vertexIndicesX1[],int32 vertexIndicesY1[],int32 vertexIndicesZ1[]); + POLYVOX_API void generateDecimatedVerticesForSlice(BlockVolumeIterator& volIter, uint8 uLevel, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]); - POLYVOX_API void generateDecimatedMeshDataForRegionSlow(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); + POLYVOX_API void generateDecimatedMeshDataForRegionSlow(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch); - POLYVOX_API Vector3DFloat computeDecimatedNormal(BlockVolume* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod); + POLYVOX_API Vector3DFloat computeDecimatedNormal(BlockVolume* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod); } #endif diff --git a/PolyVoxCore/include/Utility.h b/PolyVoxCore/include/Utility.h index 7971d575..a2c5b655 100644 --- a/PolyVoxCore/include/Utility.h +++ b/PolyVoxCore/include/Utility.h @@ -24,12 +24,12 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "TypeDef.h" -#include "PolyVoxCStdInt.h" +#include "PolyVoxForwardDeclarations.h" namespace PolyVox { - POLYVOX_API std::uint8_t logBase2(std::uint32_t uInput); - POLYVOX_API bool isPowerOf2(std::uint32_t uInput); + POLYVOX_API uint8 logBase2(uint32 uInput); + POLYVOX_API bool isPowerOf2(uint32 uInput); template Type trilinearlyInterpolate( diff --git a/PolyVoxCore/include/Vector.h b/PolyVoxCore/include/Vector.h index 9d9fdfe5..c5a16cba 100644 --- a/PolyVoxCore/include/Vector.h +++ b/PolyVoxCore/include/Vector.h @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define __PolyVox_Vector_H__ #pragma region Headers -#include "PolyVoxCStdInt.h" +#include "PolyVoxForwardDeclarations.h" #include #pragma endregion @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { ///Represents a vector in space. - template + template class Vector { public: @@ -66,7 +66,7 @@ namespace PolyVox Vector& operator/=(const Type& rhs) throw(); ///Element Access - Type getElement(std::uint32_t index) const throw(); + Type getElement(uint32 index) const throw(); ///Get the x component of the vector. Type getX(void) const throw(); ///Get the y component of the vector. @@ -77,7 +77,7 @@ namespace PolyVox Type getW(void) const throw(); ///Element Access - void setElement(std::uint32_t index, Type tValue) throw(); + void setElement(uint32 index, Type tValue) throw(); ///Set the x component of the vector. void setX(Type tX) throw(); ///Set the y component of the vector. @@ -107,19 +107,19 @@ namespace PolyVox //Non-member overloaded operators. ///Addition operator. - template + template Vector operator+(const Vector& lhs, const Vector& rhs) throw(); ///Subtraction operator. - template + template Vector operator-(const Vector& lhs, const Vector& rhs) throw(); ///Multiplication operator. - template + template Vector operator*(const Vector& lhs, const Type& rhs) throw(); ///Division operator. - template + template Vector operator/(const Vector& lhs, const Type& rhs) throw(); ///Stream insertion operator. - template + template std::ostream& operator<<(std::ostream& os, const Vector& vector) throw(); //Some handy typedefs @@ -128,17 +128,17 @@ namespace PolyVox ///A 3D Vector of doubles. typedef Vector<3,double> Vector3DDouble; ///A 3D Vector of signed 8-bit values. - typedef Vector<3,std::int8_t> Vector3DInt8; + typedef Vector<3,int8> Vector3DInt8; ///A 3D Vector of unsigned 8-bit values. - typedef Vector<3,std::uint8_t> Vector3DUint8; + typedef Vector<3,uint8> Vector3DUint8; ///A 3D Vector of signed 16-bit values. - typedef Vector<3,std::int16_t> Vector3DInt16; + typedef Vector<3,int16> Vector3DInt16; ///A 3D Vector of unsigned 16-bit values. - typedef Vector<3,std::uint16_t> Vector3DUint16; + typedef Vector<3,uint16> Vector3DUint16; ///A 3D Vector of signed 32-bit values. - typedef Vector<3,std::int32_t> Vector3DInt32; + typedef Vector<3,int32> Vector3DInt32; ///A 3D Vector of unsigned 32-bit values. - typedef Vector<3,std::uint32_t> Vector3DUint32; + typedef Vector<3,uint32> Vector3DUint32; diff --git a/PolyVoxCore/include/Vector.inl b/PolyVoxCore/include/Vector.inl index f3ee7dff..e21dfd2e 100644 --- a/PolyVoxCore/include/Vector.inl +++ b/PolyVoxCore/include/Vector.inl @@ -42,7 +42,7 @@ namespace PolyVox documented below - however often binary versions are also generated by std::operators. Lastly, note that for convienience a set of typedefs are included for 2 and 3 dimentionsal - vectors with type float, double, std::int32_t, and std::uint32_t. They are used as follows: + vectors with type float, double, int32, and uint32. They are used as follows: Vector2DInt4 test(1,2); //Declares a 2 dimensional Vector of type int4. */ @@ -54,7 +54,7 @@ namespace PolyVox \param x x component to set. \param y y component to set. */ - template + template Vector::Vector(Type x, Type y) throw() { m_tElements[0] = x; @@ -68,7 +68,7 @@ namespace PolyVox \param y y component to set. \param z z component to set. */ - template + template Vector::Vector(Type x, Type y, Type z) throw() { m_tElements[0] = x; @@ -84,7 +84,7 @@ namespace PolyVox \param z z component to set. \param w w component to set. */ - template + template Vector::Vector(Type x, Type y, Type z, Type w) throw() { m_tElements[0] = x; @@ -96,7 +96,7 @@ namespace PolyVox /** Creates a Vector object but does not initialise it. */ - template + template Vector::Vector(void) throw() { } @@ -105,7 +105,7 @@ namespace PolyVox Copy constructor builds object based on object passed as parameter. \param vector A reference to the Vector to be copied. */ - template + template Vector::Vector(const Vector& vector) throw() { std::memcpy(m_tElements, vector.m_tElements, sizeof(Type) * Size); @@ -120,11 +120,11 @@ namespace PolyVox \param vector A reference to the Vector to be copied. */ - template + template template Vector::Vector(const Vector& vector) throw() { - for(std::uint32_t ct = 0; ct < Size; ++ct) + for(uint32 ct = 0; ct < Size; ++ct) { m_tElements[ct] = static_cast(vector.getElement(ct)); } @@ -133,7 +133,7 @@ namespace PolyVox /** Destroys the Vector. */ - template + template Vector::~Vector(void) throw() { } @@ -145,7 +145,7 @@ namespace PolyVox \param rhs Vector to assign to. \return A reference to the result to allow chaining. */ - template + template Vector& Vector::operator=(const Vector& rhs) throw() { if(this == &rhs) @@ -162,11 +162,11 @@ namespace PolyVox \return true if the Vectors match. \see operator!= */ - template + template inline bool Vector::operator==(const Vector &rhs) const throw() { bool equal = true; - for(std::uint32_t ct = 0; ct < Size; ++ct) + for(uint32 ct = 0; ct < Size; ++ct) { if(m_tElements[ct] != rhs(ct)) { @@ -184,7 +184,7 @@ namespace PolyVox \return true if this is less than the parameter \see operator!= */ - template + template inline bool Vector::operator<(const Vector &rhs) const throw() { for(int ct = 0; ct < Size; ++ct) @@ -202,10 +202,10 @@ namespace PolyVox \param rhs Vector to add \return The resulting Vector. */ - template + template inline Vector& Vector::operator+=(const Vector& rhs) throw() { - for(std::uint32_t ct = 0; ct < Size; ++ct) + for(uint32 ct = 0; ct < Size; ++ct) { m_tElements[ct] += rhs.m_tElements[ct]; } @@ -218,7 +218,7 @@ namespace PolyVox \param rhs Vector to add. \return The resulting Vector. */ - template + template Vector operator+(const Vector& lhs, const Vector& rhs) throw() { Vector result = lhs; @@ -231,10 +231,10 @@ namespace PolyVox \param rhs Vector to subtract \return The resulting Vector. */ - template + template inline Vector& Vector::operator-=(const Vector& rhs) throw() { - for(std::uint32_t ct = 0; ct < Size; ++ct) + for(uint32 ct = 0; ct < Size; ++ct) { m_tElements[ct] -= rhs.m_tElements[ct]; } @@ -247,7 +247,7 @@ namespace PolyVox \param rhs Vector to subtract. \return The resulting Vector. */ - template + template Vector operator-(const Vector& lhs, const Vector& rhs) throw() { Vector result = lhs; @@ -260,10 +260,10 @@ namespace PolyVox \param rhs the number the Vector is multiplied by. \return The resulting Vector. */ - template + template inline Vector& Vector::operator*=(const Type& rhs) throw() { - for(std::uint32_t ct = 0; ct < Size; ++ct) + for(uint32 ct = 0; ct < Size; ++ct) { m_tElements[ct] *= rhs; } @@ -276,7 +276,7 @@ namespace PolyVox \param rhs the number the Vector is multiplied by. \return The resulting Vector. */ - template + template Vector operator*(const Vector& lhs, const Type& rhs) throw() { Vector result = lhs; @@ -289,10 +289,10 @@ namespace PolyVox \param rhs the number the Vector is divided by. \return The resulting Vector. */ - template + template inline Vector& Vector::operator/=(const Type& rhs) throw() { - for(std::uint32_t ct = 0; ct < Size; ++ct) + for(uint32 ct = 0; ct < Size; ++ct) { m_tElements[ct] /= rhs; } @@ -305,7 +305,7 @@ namespace PolyVox \param rhs the number the Vector is divided by. \return The resulting Vector. */ - template + template Vector operator/(const Vector& lhs, const Type& rhs) throw() { Vector result = lhs; @@ -319,11 +319,11 @@ namespace PolyVox \param vector The Vector to write to the stream. \return A reference to the output stream to allow chaining. */ - template + template std::ostream& operator<<(std::ostream& os, const Vector& vector) throw() { os << "("; - for(std::uint32_t ct = 0; ct < Size; ++ct) + for(uint32 ct = 0; ct < Size; ++ct) { os << vector.getElement(ct); if(ct < (Size-1)) @@ -342,8 +342,8 @@ namespace PolyVox \param index The index of the element to return. \return The element. */ - template - inline Type Vector::getElement(std::uint32_t index) const throw() + template + inline Type Vector::getElement(uint32 index) const throw() { return m_tElements[index]; } @@ -351,7 +351,7 @@ namespace PolyVox /** \return A const reference to the X component of a 1, 2, 3, or 4 dimensional Vector. */ - template + template inline Type Vector::getX(void) const throw() { return m_tElements[0]; @@ -360,7 +360,7 @@ namespace PolyVox /** \return A const reference to the Y component of a 2, 3, or 4 dimensional Vector. */ - template + template inline Type Vector::getY(void) const throw() { return m_tElements[1]; @@ -369,7 +369,7 @@ namespace PolyVox /** \return A const reference to the Z component of a 3 or 4 dimensional Vector. */ - template + template inline Type Vector::getZ(void) const throw() { return m_tElements[2]; @@ -378,7 +378,7 @@ namespace PolyVox /** \return A const reference to the W component of a 4 dimensional Vector. */ - template + template inline Type Vector::getW(void) const throw() { return m_tElements[3]; @@ -390,8 +390,8 @@ namespace PolyVox \param index The index of the element to set. \param tValue The new value for the element. */ - template - inline void Vector::setElement(std::uint32_t index, Type tValue) throw() + template + inline void Vector::setElement(uint32 index, Type tValue) throw() { m_tElements[index] = tValue; } @@ -399,7 +399,7 @@ namespace PolyVox /** \param tX The new value for the X component of a 1, 2, 3, or 4 dimensional Vector. */ - template + template inline void Vector::setX(Type tX) throw() { m_tElements[0] = tX; @@ -408,7 +408,7 @@ namespace PolyVox /** \param tX The new value for the Y component of a 2, 3, or 4 dimensional Vector. */ - template + template inline void Vector::setY(Type tY) throw() { m_tElements[1] = tY; @@ -417,7 +417,7 @@ namespace PolyVox /** \param tX The new value for the Z component of a 3 or 4 dimensional Vector. */ - template + template inline void Vector::setZ(Type tZ) throw() { m_tElements[2] = tZ; @@ -426,7 +426,7 @@ namespace PolyVox /** \param tX The new value for the W component of a 4 dimensional Vector. */ - template + template inline void Vector::setW(Type tW) throw() { m_tElements[3] = tW; @@ -438,7 +438,7 @@ namespace PolyVox NOTE: This function does not make much sense on integer Vectors. \return Length of the Vector. */ - template + template inline double Vector::length(void) const throw() { return sqrt(lengthSquared()); @@ -447,11 +447,11 @@ namespace PolyVox /** \return Squared length of the Vector. */ - template + template inline double Vector::lengthSquared(void) const throw() { double result = 0.0f; - for(std::uint32_t ct = 0; ct < Size; ++ct) + for(uint32 ct = 0; ct < Size; ++ct) { result += m_tElements[ct] * m_tElements[ct]; } @@ -467,7 +467,7 @@ namespace PolyVox \param Vector3D The Vector to find the angle to. \return The angle between them in radians. */ - template + template inline double Vector::angleTo(const Vector& vector) const throw() { return acos(dot(vector) / (vector.length() * this->length())); @@ -486,7 +486,7 @@ namespace PolyVox \return The value of the cross product. \see dot() */ - template + template inline Vector Vector::cross(const Vector& vector) const throw() { Type i = vector.getZ() * this->getY() - vector.getY() * this->getZ(); @@ -502,11 +502,11 @@ namespace PolyVox \return The value of the dot product. \see cross() */ - template + template inline Type Vector::dot(const Vector& rhs) const throw() { Type dotProduct = static_cast(0); - for(std::uint32_t ct = 0; ct < Size; ++ct) + for(uint32 ct = 0; ct < Size; ++ct) { dotProduct += m_tElements[ct] * rhs.m_tElements[ct]; } @@ -518,7 +518,7 @@ namespace PolyVox NOTE: This function does not make much sense on integer Vectors. */ - template + template inline void Vector::normalise(void) throw() { double length = this->length(); @@ -527,7 +527,7 @@ namespace PolyVox { return; } - for(std::uint32_t ct = 0; ct < Size; ++ct) + for(uint32 ct = 0; ct < Size; ++ct) { m_tElements[ct] /= static_cast(length); } diff --git a/PolyVoxCore/include/VolumeChangeTracker.h b/PolyVoxCore/include/VolumeChangeTracker.h index 9ab7ad32..307a5c0c 100644 --- a/PolyVoxCore/include/VolumeChangeTracker.h +++ b/PolyVoxCore/include/VolumeChangeTracker.h @@ -44,26 +44,26 @@ namespace PolyVox //Getters void getChangedRegions(std::list& listToFill) const; Region getEnclosingRegion(void) const; - std::uint16_t getSideLength(void); - BlockVolume* getVolumeData(void) const; - std::uint8_t getVoxelAt(const Vector3DUint16& pos); - std::uint8_t getVoxelAt(std::uint16_t uX, std::uint16_t uY, std::uint16_t uZ); + uint16 getSideLength(void); + BlockVolume* getVolumeData(void) const; + uint8 getVoxelAt(const Vector3DUint16& pos); + uint8 getVoxelAt(uint16 uX, uint16 uY, uint16 uZ); //Setters void setAllRegionsUpToDate(bool newUpToDateValue); - void setLockedVoxelAt(std::uint16_t x, std::uint16_t y, std::uint16_t z, std::uint8_t value); - void setVolumeData(BlockVolume* volumeDataToSet); - void setVoxelAt(std::uint16_t x, std::uint16_t y, std::uint16_t z, std::uint8_t value); + void setLockedVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value); + void setVolumeData(BlockVolume* volumeDataToSet); + void setVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value); //Others void lockRegion(const Region& regToLock); void unlockRegion(void); - //void markRegionChanged(std::uint16_t firstX, std::uint16_t firstY, std::uint16_t firstZ, std::uint16_t lastX, std::uint16_t lastY, std::uint16_t lastZ); + //void markRegionChanged(uint16 firstX, uint16 firstY, uint16 firstZ, uint16 lastX, uint16 lastY, uint16 lastZ); private: bool m_bIsLocked; Region m_regLastLocked; - BlockVolume* volumeData; + BlockVolume* volumeData; LinearVolume* volRegionUpToDate; }; } diff --git a/PolyVoxCore/include/VoxelFilters.h b/PolyVoxCore/include/VoxelFilters.h index fe731ae7..5d52c823 100644 --- a/PolyVoxCore/include/VoxelFilters.h +++ b/PolyVoxCore/include/VoxelFilters.h @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. namespace PolyVox { - float computeSmoothedVoxel(BlockVolumeIterator& volIter); + float computeSmoothedVoxel(BlockVolumeIterator& volIter); } #endif \ No newline at end of file diff --git a/PolyVoxCore/source/GradientEstimators.cpp b/PolyVoxCore/source/GradientEstimators.cpp index b54372ba..3099f696 100644 --- a/PolyVoxCore/source/GradientEstimators.cpp +++ b/PolyVoxCore/source/GradientEstimators.cpp @@ -9,7 +9,7 @@ using namespace std; namespace PolyVox { - POLYVOX_API void computeNormalsForVertices(BlockVolume* volumeData, RegionGeometry& regGeom, NormalGenerationMethod normalGenerationMethod) + POLYVOX_API void computeNormalsForVertices(BlockVolume* volumeData, RegionGeometry& regGeom, NormalGenerationMethod normalGenerationMethod) { std::vector& vecVertices = regGeom.m_patchSingleMaterial->m_vecVertices; std::vector::iterator iterSurfaceVertex = vecVertices.begin(); @@ -18,7 +18,7 @@ namespace PolyVox const Vector3DFloat& v3dPos = iterSurfaceVertex->getPosition() + static_cast(regGeom.m_v3dRegionPosition); const Vector3DInt32 v3dFloor = static_cast(v3dPos); - BlockVolumeIterator volIter(*volumeData); + BlockVolumeIterator volIter(*volumeData); //Check all corners are within the volume, allowing a boundary for gradient estimation bool lowerCornerInside = volumeData->containsPoint(v3dFloor,1); @@ -78,15 +78,15 @@ namespace PolyVox } } - Vector3DFloat computeNormal(BlockVolume* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) + Vector3DFloat computeNormal(BlockVolume* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) { const float posX = position.getX(); const float posY = position.getY(); const float posZ = position.getZ(); - const uint16_t floorX = static_cast(posX); - const uint16_t floorY = static_cast(posY); - const uint16_t floorZ = static_cast(posZ); + const uint16 floorX = static_cast(posX); + const uint16 floorY = static_cast(posY); + const uint16 floorZ = static_cast(posZ); //Check all corners are within the volume, allowing a boundary for gradient estimation bool lowerCornerInside = volumeData->containsPoint(Vector3DInt32(floorX, floorY, floorZ),1); @@ -98,24 +98,24 @@ namespace PolyVox Vector3DFloat result; - BlockVolumeIterator volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create? + BlockVolumeIterator volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create? 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 Vector3DFloat gradFloor = computeSobelGradient(volIter); 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 Vector3DFloat gradCeil = computeSobelGradient(volIter); result = ((gradFloor + gradCeil) * -1.0f); @@ -127,19 +127,19 @@ namespace PolyVox } 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 Vector3DFloat gradFloor = computeCentralDifferenceGradient(volIter); 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 Vector3DFloat gradCeil = computeCentralDifferenceGradient(volIter); result = ((gradFloor + gradCeil) * -1.0f); @@ -151,21 +151,21 @@ namespace PolyVox } if(normalGenerationMethod == SIMPLE) { - volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); - const uint8_t uFloor = volIter.getVoxel() > 0 ? 1 : 0; + volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); + const uint8 uFloor = volIter.getVoxel() > 0 ? 1 : 0; if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 { - uint8_t uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; + uint8 uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; result = Vector3DFloat(static_cast(uFloor - uCeil),0.0,0.0); } else if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5 { - uint8_t uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; + uint8 uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; result = Vector3DFloat(0.0,static_cast(uFloor - uCeil),0.0); } else if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5 { - uint8_t uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; + uint8 uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; result = Vector3DFloat(0.0, 0.0,static_cast(uFloor - uCeil)); } } diff --git a/PolyVoxCore/source/IndexedSurfacePatch.cpp b/PolyVoxCore/source/IndexedSurfacePatch.cpp index 00a863ce..8e6e4e14 100644 --- a/PolyVoxCore/source/IndexedSurfacePatch.cpp +++ b/PolyVoxCore/source/IndexedSurfacePatch.cpp @@ -43,7 +43,7 @@ namespace PolyVox m_vecTriangleIndices.push_back(m_vecVertices.size()-1); } - 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()); @@ -68,7 +68,7 @@ namespace PolyVox return m_vecVertices; } - const std::vector& IndexedSurfacePatch::getIndices(void) const + const std::vector& IndexedSurfacePatch::getIndices(void) const { return m_vecTriangleIndices; } diff --git a/PolyVoxCore/source/Region.cpp b/PolyVoxCore/source/Region.cpp index b3621dc6..54078e80 100644 --- a/PolyVoxCore/source/Region.cpp +++ b/PolyVoxCore/source/Region.cpp @@ -44,7 +44,7 @@ namespace PolyVox && (pos.getZ() >= m_v3dLowerCorner.getZ() + boundary); } - bool Region::containsPoint(const Vector3DInt32& pos, std::uint8_t boundary) const + bool Region::containsPoint(const Vector3DInt32& pos, uint8 boundary) const { return (pos.getX() <= m_v3dUpperCorner.getX() - boundary) && (pos.getY() <= m_v3dUpperCorner.getY() - boundary) diff --git a/PolyVoxCore/source/SurfaceAdjusters.cpp b/PolyVoxCore/source/SurfaceAdjusters.cpp index 2982f64a..98e15a4e 100644 --- a/PolyVoxCore/source/SurfaceAdjusters.cpp +++ b/PolyVoxCore/source/SurfaceAdjusters.cpp @@ -13,12 +13,12 @@ using namespace std; namespace PolyVox { - void smoothRegionGeometry(BlockVolume* volumeData, RegionGeometry& regGeom) + void smoothRegionGeometry(BlockVolume* volumeData, RegionGeometry& regGeom) { - const std::uint8_t uSmoothingFactor = 2; + const uint8 uSmoothingFactor = 2; const float fThreshold = 0.5f; - BlockVolumeIterator volIter(*volumeData); + BlockVolumeIterator volIter(*volumeData); std::vector& vecVertices = regGeom.m_patchSingleMaterial->m_vecVertices; std::vector::iterator iterSurfaceVertex = vecVertices.begin(); @@ -77,9 +77,9 @@ namespace PolyVox } //while(iterSurfaceVertex != vecVertices.end()) } - void adjustDecimatedGeometry(BlockVolume* volumeData, RegionGeometry& regGeom, uint8_t val) + void adjustDecimatedGeometry(BlockVolume* volumeData, RegionGeometry& regGeom, uint8 val) { - BlockVolumeIterator volIter(*volumeData); + BlockVolumeIterator volIter(*volumeData); std::vector& vecVertices = regGeom.m_patchSingleMaterial->m_vecVertices; std::vector::iterator iterSurfaceVertex = vecVertices.begin(); @@ -88,7 +88,7 @@ namespace PolyVox Vector3DFloat v3dPos = iterSurfaceVertex->getPosition() + static_cast(regGeom.m_v3dRegionPosition); Vector3DInt32 v3dFloor = static_cast(v3dPos); - BlockVolumeIterator volIter(*volumeData); + BlockVolumeIterator volIter(*volumeData); //Check all corners are within the volume, allowing a boundary for gradient estimation bool lowerCornerInside = volumeData->containsPoint(v3dFloor,1); @@ -97,7 +97,7 @@ namespace PolyVox if(lowerCornerInside && upperCornerInside) //If this test fails the vertex will be left as it was { //volIter.setPosition(static_cast(v3dFloor)); - //const uint8_t uFloor = volIter.getVoxel(); + //const uint8 uFloor = volIter.getVoxel(); if(((v3dPos.getX() - v3dFloor.getX()) < 0.001) && ((v3dPos.getY() - v3dFloor.getY()) < 0.001) && ((v3dPos.getZ() - v3dFloor.getZ()) < 0.001)) //int x = v3dPos.getX(); //if(x % 2 != 0) @@ -105,7 +105,7 @@ namespace PolyVox { //exit(0); //volIter.setPosition(static_cast(v3dFloor+Vector3DInt32(1,0,0))); - //const uint8_t uCeil = volIter.getVoxel(); + //const uint8 uCeil = volIter.getVoxel(); //if(uFloor == uCeil) //In this case they must both be zero { //if(iterSurfaceVertex->getNormal().getX() > 0) @@ -115,9 +115,9 @@ namespace PolyVox v3dFloor = static_cast(v3dPos); volIter.setPosition(static_cast(v3dFloor)); - const uint8_t uFloor = volIter.getVoxel(); + const uint8 uFloor = volIter.getVoxel(); - uint8_t uCeil; + uint8 uCeil; if((iterSurfaceVertex->getNormal().getX() > 0.5f) || (iterSurfaceVertex->getNormal().getX() < -0.5f)) { volIter.setPosition(static_cast(v3dFloor+Vector3DInt32(1,0,0))); diff --git a/PolyVoxCore/source/SurfaceExtractors.cpp b/PolyVoxCore/source/SurfaceExtractors.cpp index dbb82fba..cf0d15ee 100644 --- a/PolyVoxCore/source/SurfaceExtractors.cpp +++ b/PolyVoxCore/source/SurfaceExtractors.cpp @@ -30,9 +30,9 @@ namespace PolyVox regionGeometry.m_patchSingleMaterial = new IndexedSurfacePatch(); regionGeometry.m_v3dRegionPosition = iterChangedRegions->getLowerCorner(); - generateDecimatedMeshDataForRegion(volume.getVolumeData(), 1, *iterChangedRegions, regionGeometry.m_patchSingleMaterial); + //generateDecimatedMeshDataForRegion(volume.getVolumeData(), 1, *iterChangedRegions, regionGeometry.m_patchSingleMaterial); - //generateReferenceMeshDataForRegion(volume.getVolumeData(), *iterChangedRegions, regionGeometry.m_patchSingleMaterial); + generateReferenceMeshDataForRegion(volume.getVolumeData(), *iterChangedRegions, regionGeometry.m_patchSingleMaterial); //for(int ct = 0; ct < 2; ct++) Vector3DInt32 temp = regionGeometry.m_v3dRegionPosition; @@ -61,27 +61,27 @@ namespace PolyVox return listChangedRegionGeometry; } - std::uint32_t getIndex(std::uint32_t x, std::uint32_t y) + uint32 getIndex(uint32 x, uint32 y) { return x + (y * (POLYVOX_REGION_SIDE_LENGTH+1)); } - void generateRoughMeshDataForRegion(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) + void generateRoughMeshDataForRegion(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) { singleMaterialPatch->m_vecVertices.clear(); singleMaterialPatch->m_vecTriangleIndices.clear(); //For edge indices - std::int32_t* vertexIndicesX0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::int32_t* vertexIndicesY0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::int32_t* vertexIndicesZ0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::int32_t* vertexIndicesX1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::int32_t* vertexIndicesY1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::int32_t* vertexIndicesZ1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesX0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesY0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesZ0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesX1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesY1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesZ1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; //Cell bitmasks - std::uint8_t* bitmask0 = new std::uint8_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::uint8_t* bitmask1 = new std::uint8_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + uint8* bitmask0 = new uint8[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + uint8* bitmask1 = new uint8[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; //When generating the mesh for a region we actually look one voxel outside it in the // back, bottom, right direction. Protect against access violations by cropping region here @@ -97,22 +97,22 @@ namespace PolyVox regSlice0.setUpperCorner(Vector3DInt32(regSlice0.getUpperCorner().getX(),regSlice0.getUpperCorner().getY(),regSlice0.getLowerCorner().getZ())); //Iterator to access the volume data - BlockVolumeIterator volIter(*volumeData); + BlockVolumeIterator volIter(*volumeData); //Compute bitmask for initial slice - std::uint32_t uNoOfNonEmptyCellsForSlice0 = computeInitialRoughBitmaskForSlice(volIter, regSlice0, offset, bitmask0); + uint32 uNoOfNonEmptyCellsForSlice0 = computeInitialRoughBitmaskForSlice(volIter, regSlice0, offset, bitmask0); if(uNoOfNonEmptyCellsForSlice0 != 0) { //If there were some non-empty cells then generate initial slice vertices for them generateRoughVerticesForSlice(volIter,regSlice0, offset, bitmask0, singleMaterialPatch, vertexIndicesX0, vertexIndicesY0, vertexIndicesZ0); } - for(std::uint32_t uSlice = 0; ((uSlice <= POLYVOX_REGION_SIDE_LENGTH-1) && (uSlice + offset.getZ() < region.getUpperCorner().getZ())); ++uSlice) + for(uint32 uSlice = 0; ((uSlice <= POLYVOX_REGION_SIDE_LENGTH-1) && (uSlice + offset.getZ() < region.getUpperCorner().getZ())); ++uSlice) { Region regSlice1(regSlice0); regSlice1.shift(Vector3DInt32(0,0,1)); - std::uint32_t uNoOfNonEmptyCellsForSlice1 = computeRoughBitmaskForSliceFromPrevious(volIter, regSlice1, offset, bitmask1, bitmask0); + uint32 uNoOfNonEmptyCellsForSlice1 = computeRoughBitmaskForSliceFromPrevious(volIter, regSlice1, offset, bitmask1, bitmask0); if(uNoOfNonEmptyCellsForSlice1 != 0) { @@ -143,9 +143,9 @@ namespace PolyVox delete[] vertexIndicesZ1; } - std::uint32_t computeInitialRoughBitmaskForSlice(BlockVolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask) + uint32 computeInitialRoughBitmaskForSlice(BlockVolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask) { - std::uint32_t uNoOfNonEmptyCells = 0; + uint32 uNoOfNonEmptyCells = 0; //Iterate over each cell in the region volIter.setPosition(regSlice.getLowerCorner().getX(),regSlice.getLowerCorner().getY(), regSlice.getLowerCorner().getZ()); @@ -153,23 +153,23 @@ namespace PolyVox do { //Current position - const uint16_t x = volIter.getPosX() - offset.getX(); - const uint16_t y = volIter.getPosY() - offset.getY(); + const uint16 x = volIter.getPosX() - offset.getX(); + const uint16 y = volIter.getPosY() - offset.getY(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8_t iCubeIndex = 0; + uint8 iCubeIndex = 0; if((x==0) && (y==0)) { - 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 v000 = volIter.getVoxel(); + const uint8 v100 = volIter.peekVoxel1px0py0pz(); + const uint8 v010 = volIter.peekVoxel0px1py0pz(); + const uint8 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(); + const uint8 v001 = volIter.peekVoxel0px0py1pz(); + const uint8 v101 = volIter.peekVoxel1px0py1pz(); + const uint8 v011 = volIter.peekVoxel0px1py1pz(); + const uint8 v111 = volIter.peekVoxel1px1py1pz(); if (v000 == 0) iCubeIndex |= 1; if (v100 == 0) iCubeIndex |= 2; @@ -182,25 +182,25 @@ namespace PolyVox } else if((x>0) && y==0) { - const uint8_t v100 = volIter.peekVoxel1px0py0pz(); - const uint8_t v110 = volIter.peekVoxel1px1py0pz(); + const uint8 v100 = volIter.peekVoxel1px0py0pz(); + const uint8 v110 = volIter.peekVoxel1px1py0pz(); - const uint8_t v101 = volIter.peekVoxel1px0py1pz(); - const uint8_t v111 = volIter.peekVoxel1px1py1pz(); + const uint8 v101 = volIter.peekVoxel1px0py1pz(); + const uint8 v111 = volIter.peekVoxel1px1py1pz(); //x - uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; - uint8_t srcBit6 = iPreviousCubeIndexX & 64; - uint8_t destBit7 = srcBit6 << 1; + uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; + uint8 srcBit6 = iPreviousCubeIndexX & 64; + uint8 destBit7 = srcBit6 << 1; - uint8_t srcBit5 = iPreviousCubeIndexX & 32; - uint8_t destBit4 = srcBit5 >> 1; + uint8 srcBit5 = iPreviousCubeIndexX & 32; + uint8 destBit4 = srcBit5 >> 1; - uint8_t srcBit2 = iPreviousCubeIndexX & 4; - uint8_t destBit3 = srcBit2 << 1; + uint8 srcBit2 = iPreviousCubeIndexX & 4; + uint8 destBit3 = srcBit2 << 1; - uint8_t srcBit1 = iPreviousCubeIndexX & 2; - uint8_t destBit0 = srcBit1 >> 1; + uint8 srcBit1 = iPreviousCubeIndexX & 2; + uint8 destBit0 = srcBit1 >> 1; iCubeIndex |= destBit0; if (v100 == 0) iCubeIndex |= 2; @@ -213,25 +213,25 @@ namespace PolyVox } else if((x==0) && (y>0)) { - const uint8_t v010 = volIter.peekVoxel0px1py0pz(); - const uint8_t v110 = volIter.peekVoxel1px1py0pz(); + const uint8 v010 = volIter.peekVoxel0px1py0pz(); + const uint8 v110 = volIter.peekVoxel1px1py0pz(); - const uint8_t v011 = volIter.peekVoxel0px1py1pz(); - const uint8_t v111 = volIter.peekVoxel1px1py1pz(); + const uint8 v011 = volIter.peekVoxel0px1py1pz(); + const uint8 v111 = volIter.peekVoxel1px1py1pz(); //y - uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; - uint8_t srcBit7 = iPreviousCubeIndexY & 128; - uint8_t destBit4 = srcBit7 >> 3; + uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; + uint8 srcBit7 = iPreviousCubeIndexY & 128; + uint8 destBit4 = srcBit7 >> 3; - uint8_t srcBit6 = iPreviousCubeIndexY & 64; - uint8_t destBit5 = srcBit6 >> 1; + uint8 srcBit6 = iPreviousCubeIndexY & 64; + uint8 destBit5 = srcBit6 >> 1; - uint8_t srcBit3 = iPreviousCubeIndexY & 8; - uint8_t destBit0 = srcBit3 >> 3; + uint8 srcBit3 = iPreviousCubeIndexY & 8; + uint8 destBit0 = srcBit3 >> 3; - uint8_t srcBit2 = iPreviousCubeIndexY & 4; - uint8_t destBit1 = srcBit2 >> 1; + uint8 srcBit2 = iPreviousCubeIndexY & 4; + uint8 destBit1 = srcBit2 >> 1; iCubeIndex |= destBit0; iCubeIndex |= destBit1; @@ -244,31 +244,31 @@ namespace PolyVox } else { - const uint8_t v110 = volIter.peekVoxel1px1py0pz(); + const uint8 v110 = volIter.peekVoxel1px1py0pz(); - const uint8_t v111 = volIter.peekVoxel1px1py1pz(); + const uint8 v111 = volIter.peekVoxel1px1py1pz(); //y - uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; - uint8_t srcBit7 = iPreviousCubeIndexY & 128; - uint8_t destBit4 = srcBit7 >> 3; + uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; + uint8 srcBit7 = iPreviousCubeIndexY & 128; + uint8 destBit4 = srcBit7 >> 3; - uint8_t srcBit6 = iPreviousCubeIndexY & 64; - uint8_t destBit5 = srcBit6 >> 1; + uint8 srcBit6 = iPreviousCubeIndexY & 64; + uint8 destBit5 = srcBit6 >> 1; - uint8_t srcBit3 = iPreviousCubeIndexY & 8; - uint8_t destBit0 = srcBit3 >> 3; + uint8 srcBit3 = iPreviousCubeIndexY & 8; + uint8 destBit0 = srcBit3 >> 3; - uint8_t srcBit2 = iPreviousCubeIndexY & 4; - uint8_t destBit1 = srcBit2 >> 1; + uint8 srcBit2 = iPreviousCubeIndexY & 4; + uint8 destBit1 = srcBit2 >> 1; //x - uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; + uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; srcBit6 = iPreviousCubeIndexX & 64; - uint8_t destBit7 = srcBit6 << 1; + uint8 destBit7 = srcBit6 << 1; srcBit2 = iPreviousCubeIndexX & 4; - uint8_t destBit3 = srcBit2 << 1; + uint8 destBit3 = srcBit2 << 1; iCubeIndex |= destBit0; iCubeIndex |= destBit1; @@ -293,9 +293,9 @@ namespace PolyVox return uNoOfNonEmptyCells; } - std::uint32_t computeRoughBitmaskForSliceFromPrevious(BlockVolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, uint8_t* previousBitmask) + uint32 computeRoughBitmaskForSliceFromPrevious(BlockVolumeIterator& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, uint8* previousBitmask) { - std::uint32_t uNoOfNonEmptyCells = 0; + uint32 uNoOfNonEmptyCells = 0; //Iterate over each cell in the region volIter.setPosition(regSlice.getLowerCorner().getX(),regSlice.getLowerCorner().getY(), regSlice.getLowerCorner().getZ()); @@ -303,21 +303,21 @@ namespace PolyVox do { //Current position - const uint16_t x = volIter.getPosX() - offset.getX(); - const uint16_t y = volIter.getPosY() - offset.getY(); + const uint16 x = volIter.getPosX() - offset.getX(); + const uint16 y = volIter.getPosY() - offset.getY(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8_t iCubeIndex = 0; + uint8 iCubeIndex = 0; if((x==0) && (y==0)) { - const uint8_t v001 = volIter.peekVoxel0px0py1pz(); - const uint8_t v101 = volIter.peekVoxel1px0py1pz(); - const uint8_t v011 = volIter.peekVoxel0px1py1pz(); - const uint8_t v111 = volIter.peekVoxel1px1py1pz(); + const uint8 v001 = volIter.peekVoxel0px0py1pz(); + const uint8 v101 = volIter.peekVoxel1px0py1pz(); + const uint8 v011 = volIter.peekVoxel0px1py1pz(); + const uint8 v111 = volIter.peekVoxel1px1py1pz(); //z - uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; + uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; iCubeIndex = iPreviousCubeIndexZ >> 4; if (v001 == 0) iCubeIndex |= 16; @@ -327,20 +327,20 @@ namespace PolyVox } else if((x>0) && y==0) { - const uint8_t v101 = volIter.peekVoxel1px0py1pz(); - const uint8_t v111 = volIter.peekVoxel1px1py1pz(); + const uint8 v101 = volIter.peekVoxel1px0py1pz(); + const uint8 v111 = volIter.peekVoxel1px1py1pz(); //z - uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; + uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; iCubeIndex = iPreviousCubeIndexZ >> 4; //x - uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; - uint8_t srcBit6 = iPreviousCubeIndexX & 64; - uint8_t destBit7 = srcBit6 << 1; + uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; + uint8 srcBit6 = iPreviousCubeIndexX & 64; + uint8 destBit7 = srcBit6 << 1; - uint8_t srcBit5 = iPreviousCubeIndexX & 32; - uint8_t destBit4 = srcBit5 >> 1; + uint8 srcBit5 = iPreviousCubeIndexX & 32; + uint8 destBit4 = srcBit5 >> 1; iCubeIndex |= destBit4; if (v101 == 0) iCubeIndex |= 32; @@ -349,20 +349,20 @@ namespace PolyVox } else if((x==0) && (y>0)) { - const uint8_t v011 = volIter.peekVoxel0px1py1pz(); - const uint8_t v111 = volIter.peekVoxel1px1py1pz(); + const uint8 v011 = volIter.peekVoxel0px1py1pz(); + const uint8 v111 = volIter.peekVoxel1px1py1pz(); //z - uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; + uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; iCubeIndex = iPreviousCubeIndexZ >> 4; //y - uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; - uint8_t srcBit7 = iPreviousCubeIndexY & 128; - uint8_t destBit4 = srcBit7 >> 3; + uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; + uint8 srcBit7 = iPreviousCubeIndexY & 128; + uint8 destBit4 = srcBit7 >> 3; - uint8_t srcBit6 = iPreviousCubeIndexY & 64; - uint8_t destBit5 = srcBit6 >> 1; + uint8 srcBit6 = iPreviousCubeIndexY & 64; + uint8 destBit5 = srcBit6 >> 1; iCubeIndex |= destBit4; iCubeIndex |= destBit5; @@ -371,24 +371,24 @@ namespace PolyVox } else { - const uint8_t v111 = volIter.peekVoxel1px1py1pz(); + const uint8 v111 = volIter.peekVoxel1px1py1pz(); //z - uint8_t iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; + uint8 iPreviousCubeIndexZ = previousBitmask[getIndex(x,y)]; iCubeIndex = iPreviousCubeIndexZ >> 4; //y - uint8_t iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; - uint8_t srcBit7 = iPreviousCubeIndexY & 128; - uint8_t destBit4 = srcBit7 >> 3; + uint8 iPreviousCubeIndexY = bitmask[getIndex(x,y-1)]; + uint8 srcBit7 = iPreviousCubeIndexY & 128; + uint8 destBit4 = srcBit7 >> 3; - uint8_t srcBit6 = iPreviousCubeIndexY & 64; - uint8_t destBit5 = srcBit6 >> 1; + uint8 srcBit6 = iPreviousCubeIndexY & 64; + uint8 destBit5 = srcBit6 >> 1; //x - uint8_t iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; + uint8 iPreviousCubeIndexX = bitmask[getIndex(x-1,y)]; srcBit6 = iPreviousCubeIndexX & 64; - uint8_t destBit7 = srcBit6 << 1; + uint8 destBit7 = srcBit6 << 1; iCubeIndex |= destBit4; iCubeIndex |= destBit5; @@ -409,7 +409,7 @@ namespace PolyVox return uNoOfNonEmptyCells; } - void generateRoughVerticesForSlice(BlockVolumeIterator& volIter, Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,std::int32_t vertexIndicesX[],std::int32_t vertexIndicesY[],std::int32_t vertexIndicesZ[]) + void generateRoughVerticesForSlice(BlockVolumeIterator& volIter, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]) { //Iterate over each cell in the region volIter.setPosition(regSlice.getLowerCorner().getX(),regSlice.getLowerCorner().getY(), regSlice.getLowerCorner().getZ()); @@ -418,14 +418,14 @@ namespace PolyVox do { //Current position - const uint16_t x = volIter.getPosX() - offset.getX(); - const uint16_t y = volIter.getPosY() - offset.getY(); - const uint16_t z = volIter.getPosZ() - offset.getZ(); + const uint16 x = volIter.getPosX() - offset.getX(); + const uint16 y = volIter.getPosY() - offset.getY(); + const uint16 z = volIter.getPosZ() - offset.getZ(); - const uint8_t v000 = volIter.getVoxel(); + const uint8 v000 = volIter.getVoxel(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8_t iCubeIndex = bitmask[getIndex(x,y)]; + uint8 iCubeIndex = bitmask[getIndex(x,y)]; /* Cube is entirely in/out of the surface */ if (edgeTable[iCubeIndex] == 0) @@ -438,10 +438,10 @@ namespace PolyVox { if((x + offset.getX()) != regSlice.getUpperCorner().getX()) { - const uint8_t v100 = volIter.peekVoxel1px0py0pz(); + const uint8 v100 = volIter.peekVoxel1px0py0pz(); const Vector3DFloat v3dPosition(x + 0.5f, y, z); const Vector3DFloat v3dNormal(v000 > v100 ? 1.0f : -1.0f, 0.0f, 0.0f); - const uint8_t uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. + const uint8 uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. const SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); vertexIndicesX[getIndex(x,y)] = singleMaterialPatch->m_vecVertices.size()-1; @@ -451,10 +451,10 @@ namespace PolyVox { if((y + offset.getY()) != regSlice.getUpperCorner().getY()) { - const uint8_t v010 = volIter.peekVoxel0px1py0pz(); + const uint8 v010 = volIter.peekVoxel0px1py0pz(); const Vector3DFloat v3dPosition(x, y + 0.5f, z); const Vector3DFloat v3dNormal(0.0f, v000 > v010 ? 1.0f : -1.0f, 0.0f); - const uint8_t uMaterial = v000 | v010; + const uint8 uMaterial = v000 | v010; SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); vertexIndicesY[getIndex(x,y)] = singleMaterialPatch->m_vecVertices.size()-1; @@ -464,10 +464,10 @@ namespace PolyVox { //if((z + offset.getZ()) != upperCorner.getZ()) { - const uint8_t v001 = volIter.peekVoxel0px0py1pz(); + const uint8 v001 = volIter.peekVoxel0px0py1pz(); const Vector3DFloat v3dPosition(x, y, z + 0.5f); const Vector3DFloat v3dNormal(0.0f, 0.0f, v000 > v001 ? 1.0f : -1.0f); - const uint8_t uMaterial = v000 | v001; + const uint8 uMaterial = v000 | v001; SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); vertexIndicesZ[getIndex(x,y)] = singleMaterialPatch->m_vecVertices.size()-1; @@ -476,9 +476,9 @@ namespace PolyVox }while(volIter.moveForwardInRegionXYZ());//For each cell } - void generateRoughIndicesForSlice(BlockVolumeIterator& volIter, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8_t* bitmask0, uint8_t* bitmask1, std::int32_t vertexIndicesX0[],std::int32_t vertexIndicesY0[],std::int32_t vertexIndicesZ0[], std::int32_t vertexIndicesX1[],std::int32_t vertexIndicesY1[],std::int32_t vertexIndicesZ1[]) + void generateRoughIndicesForSlice(BlockVolumeIterator& volIter, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8* bitmask0, uint8* bitmask1, int32 vertexIndicesX0[],int32 vertexIndicesY0[],int32 vertexIndicesZ0[], int32 vertexIndicesX1[],int32 vertexIndicesY1[],int32 vertexIndicesZ1[]) { - std::uint32_t indlist[12]; + uint32 indlist[12]; Region regCroppedSlice(regSlice); regCroppedSlice.setUpperCorner(regCroppedSlice.getUpperCorner() - Vector3DInt32(1,1,0)); @@ -488,12 +488,12 @@ namespace PolyVox do { //Current position - const uint16_t x = volIter.getPosX() - offset.getX(); - const uint16_t y = volIter.getPosY() - offset.getY(); - const uint16_t z = volIter.getPosZ() - offset.getZ(); + const uint16 x = volIter.getPosX() - offset.getX(); + const uint16 y = volIter.getPosY() - offset.getY(); + const uint16 z = volIter.getPosZ() - offset.getZ(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8_t iCubeIndex = bitmask0[getIndex(x,y)]; + uint8 iCubeIndex = bitmask0[getIndex(x,y)]; /* Cube is entirely in/out of the surface */ if (edgeTable[iCubeIndex] == 0) @@ -565,9 +565,9 @@ namespace PolyVox for (int i=0;triTable[iCubeIndex][i]!=-1;i+=3) { - std::uint32_t ind0 = indlist[triTable[iCubeIndex][i ]]; - std::uint32_t ind1 = indlist[triTable[iCubeIndex][i+1]]; - std::uint32_t ind2 = indlist[triTable[iCubeIndex][i+2]]; + uint32 ind0 = indlist[triTable[iCubeIndex][i ]]; + uint32 ind1 = indlist[triTable[iCubeIndex][i+1]]; + uint32 ind2 = indlist[triTable[iCubeIndex][i+2]]; singleMaterialPatch->m_vecTriangleIndices.push_back(ind0); singleMaterialPatch->m_vecTriangleIndices.push_back(ind1); @@ -576,11 +576,11 @@ namespace PolyVox }while(volIter.moveForwardInRegionXYZ());//For each cell } - void generateReferenceMeshDataForRegion(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) + void generateReferenceMeshDataForRegion(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) { - static std::int32_t vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; - static std::int32_t vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; - static std::int32_t vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; + static int32 vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; + static int32 vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; + static int32 vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]; memset(vertexIndicesX,0xFF,sizeof(vertexIndicesX)); //0xFF is -1 as two's complement - this may not be portable... memset(vertexIndicesY,0xFF,sizeof(vertexIndicesY)); @@ -598,8 +598,8 @@ namespace PolyVox Vector3DFloat vertlist[12]; Vector3DFloat normlist[12]; - uint8_t vertMaterials[12]; - BlockVolumeIterator volIter(*volumeData); + uint8 vertMaterials[12]; + BlockVolumeIterator volIter(*volumeData); volIter.setValidRegion(region); ////////////////////////////////////////////////////////////////////////// @@ -611,22 +611,22 @@ namespace PolyVox while(volIter.moveForwardInRegionXYZ()) { //Current position - const uint16_t x = volIter.getPosX(); - const uint16_t y = volIter.getPosY(); - const uint16_t z = volIter.getPosZ(); + const uint16 x = volIter.getPosX(); + const uint16 y = volIter.getPosY(); + const uint16 z = volIter.getPosZ(); //Voxels values - 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(); + const uint8 v000 = volIter.getVoxel(); + const uint8 v100 = volIter.peekVoxel1px0py0pz(); + const uint8 v010 = volIter.peekVoxel0px1py0pz(); + const uint8 v110 = volIter.peekVoxel1px1py0pz(); + const uint8 v001 = volIter.peekVoxel0px0py1pz(); + const uint8 v101 = volIter.peekVoxel1px0py1pz(); + const uint8 v011 = volIter.peekVoxel0px1py1pz(); + const uint8 v111 = volIter.peekVoxel1px1py1pz(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8_t iCubeIndex = 0; + uint8 iCubeIndex = 0; if (v000 == 0) iCubeIndex |= 1; if (v100 == 0) iCubeIndex |= 2; @@ -781,9 +781,9 @@ namespace PolyVox //const Vector3DFloat vertex1AsFloat = (static_cast(vertex1) / 2.0f) - offset; //const Vector3DFloat vertex2AsFloat = (static_cast(vertex2) / 2.0f) - offset; - 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]]; + const uint8 material0 = vertMaterials[triTable[iCubeIndex][i ]]; + const uint8 material1 = vertMaterials[triTable[iCubeIndex][i+1]]; + const uint8 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. SurfaceVertex v0(vertex0, normal0, material0 + 0.1f); @@ -792,7 +792,7 @@ namespace PolyVox //singleMaterialPatch->addTriangle(surfaceVertex0Alpha1, surfaceVertex1Alpha1, surfaceVertex2Alpha1); - int32_t index = getIndexFor(v0.getPosition(), vertexIndicesX, vertexIndicesY, vertexIndicesZ); + int32 index = getIndexFor(v0.getPosition(), vertexIndicesX, vertexIndicesY, vertexIndicesZ); if(index == -1) { singleMaterialPatch->m_vecVertices.push_back(v0); @@ -831,7 +831,7 @@ namespace PolyVox }//For each cell } - std::int32_t getIndexFor(const Vector3DFloat& pos, std::int32_t vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]) + int32 getIndexFor(const Vector3DFloat& pos, int32 vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]) { assert(pos.getX() >= 0.0f); assert(pos.getY() >= 0.0f); @@ -850,20 +850,20 @@ namespace PolyVox //Of all the fractional parts, two should be zero and one should have a value. if(xFracPart > 0.000001f) { - return vertexIndicesX[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)]; + return vertexIndicesX[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)]; } if(yFracPart > 0.000001f) { - return vertexIndicesY[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)]; + return vertexIndicesY[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)]; } if(zFracPart > 0.000001f) { - return vertexIndicesZ[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)]; + return vertexIndicesZ[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)]; } while(true); } - void setIndexFor(const Vector3DFloat& pos, std::int32_t newIndex, std::int32_t vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], std::int32_t vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]) + void setIndexFor(const Vector3DFloat& pos, int32 newIndex, int32 vertexIndicesX[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesY[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1], int32 vertexIndicesZ[POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1][POLYVOX_REGION_SIDE_LENGTH+1]) { assert(pos.getX() >= 0.0f); assert(pos.getY() >= 0.0f); @@ -884,15 +884,15 @@ namespace PolyVox //Of all the fractional parts, two should be zero and one should have a value. if(xFracPart > 0.000001f) { - vertexIndicesX[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)] = newIndex; + vertexIndicesX[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)] = newIndex; } if(yFracPart > 0.000001f) { - vertexIndicesY[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)] = newIndex; + vertexIndicesY[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)] = newIndex; } if(zFracPart > 0.000001f) { - vertexIndicesZ[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)] = newIndex; + vertexIndicesZ[static_cast(xIntPart)][static_cast(yIntPart)][static_cast(zIntPart)] = newIndex; } } } diff --git a/PolyVoxCore/source/SurfaceExtractorsDecimated.cpp b/PolyVoxCore/source/SurfaceExtractorsDecimated.cpp index 79d724ec..d83d25d2 100644 --- a/PolyVoxCore/source/SurfaceExtractorsDecimated.cpp +++ b/PolyVoxCore/source/SurfaceExtractorsDecimated.cpp @@ -15,29 +15,29 @@ using namespace std; namespace PolyVox { - std::uint32_t getDecimatedIndex(std::uint32_t x, std::uint32_t y) + uint32 getDecimatedIndex(uint32 x, uint32 y) { return x + (y * (POLYVOX_REGION_SIDE_LENGTH+1)); } - void generateDecimatedMeshDataForRegion(BlockVolume* volumeData, uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch) + void generateDecimatedMeshDataForRegion(BlockVolume* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch) { singleMaterialPatch->m_vecVertices.clear(); singleMaterialPatch->m_vecTriangleIndices.clear(); //For edge indices - std::int32_t* vertexIndicesX0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::int32_t* vertexIndicesY0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::int32_t* vertexIndicesZ0 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::int32_t* vertexIndicesX1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::int32_t* vertexIndicesY1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::int32_t* vertexIndicesZ1 = new std::int32_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesX0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesY0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesZ0 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesX1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesY1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + int32* vertexIndicesZ1 = new int32[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; //Cell bitmasks - std::uint8_t* bitmask0 = new std::uint8_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - std::uint8_t* bitmask1 = new std::uint8_t[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + uint8* bitmask0 = new uint8[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; + uint8* bitmask1 = new uint8[(POLYVOX_REGION_SIDE_LENGTH+1) * (POLYVOX_REGION_SIDE_LENGTH+1)]; - const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; + const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; //When generating the mesh for a region we actually look outside it in the // back, bottom, right direction. Protect against access violations by cropping region here @@ -55,22 +55,22 @@ namespace PolyVox regSlice0.setUpperCorner(v3dUpperCorner); //Iterator to access the volume data - BlockVolumeIterator volIter(*volumeData); + BlockVolumeIterator volIter(*volumeData); //Compute bitmask for initial slice - std::uint32_t uNoOfNonEmptyCellsForSlice0 = computeInitialDecimatedBitmaskForSlice(volIter, uLevel, regSlice0, offset, bitmask0); + uint32 uNoOfNonEmptyCellsForSlice0 = computeInitialDecimatedBitmaskForSlice(volIter, uLevel, regSlice0, offset, bitmask0); if(uNoOfNonEmptyCellsForSlice0 != 0) { //If there were some non-empty cells then generate initial slice vertices for them generateDecimatedVerticesForSlice(volIter, uLevel, regSlice0, offset, bitmask0, singleMaterialPatch, vertexIndicesX0, vertexIndicesY0, vertexIndicesZ0); } - for(std::uint32_t uSlice = 1; ((uSlice <= POLYVOX_REGION_SIDE_LENGTH) && (uSlice + offset.getZ() <= regVolume.getUpperCorner().getZ())); uSlice += uStepSize) + for(uint32 uSlice = 1; ((uSlice <= POLYVOX_REGION_SIDE_LENGTH) && (uSlice + offset.getZ() <= regVolume.getUpperCorner().getZ())); uSlice += uStepSize) { Region regSlice1(regSlice0); regSlice1.shift(Vector3DInt32(0,0,uStepSize)); - std::uint32_t uNoOfNonEmptyCellsForSlice1 = computeDecimatedBitmaskForSliceFromPrevious(volIter, uLevel, regSlice1, offset, bitmask1, bitmask0); + uint32 uNoOfNonEmptyCellsForSlice1 = computeDecimatedBitmaskForSliceFromPrevious(volIter, uLevel, regSlice1, offset, bitmask1, bitmask0); if(uNoOfNonEmptyCellsForSlice1 != 0) { @@ -110,41 +110,41 @@ namespace PolyVox }*/ } - std::uint32_t computeInitialDecimatedBitmaskForSlice(BlockVolumeIterator& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask) + uint32 computeInitialDecimatedBitmaskForSlice(BlockVolumeIterator& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask) { - const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; - std::uint32_t uNoOfNonEmptyCells = 0; + const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; + uint32 uNoOfNonEmptyCells = 0; //Iterate over each cell in the region - for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) + for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) { - for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) + for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) { //Current position volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8_t iCubeIndex = 0; + uint8 iCubeIndex = 0; if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY())) { volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()); - const uint8_t v000 = volIter.getSubSampledVoxel(uLevel); + const uint8 v000 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()); - const uint8_t v100 = volIter.getSubSampledVoxel(uLevel); + const uint8 v100 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8_t v010 = volIter.getSubSampledVoxel(uLevel); + const uint8 v010 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); + const uint8 v110 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v001 = volIter.getSubSampledVoxel(uLevel); + const uint8 v001 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); + const uint8 v101 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); + const uint8 v011 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); + const uint8 v111 = volIter.getSubSampledVoxel(uLevel); if (v000 == 0) iCubeIndex |= 1; if (v100 == 0) iCubeIndex |= 2; @@ -158,28 +158,28 @@ namespace PolyVox else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY()) { volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()); - const uint8_t v100 = volIter.getSubSampledVoxel(uLevel); + const uint8 v100 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); + const uint8 v110 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); + const uint8 v101 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); + const uint8 v111 = volIter.getSubSampledVoxel(uLevel); //x - uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; - uint8_t srcBit6 = iPreviousCubeIndexX & 64; - uint8_t destBit7 = srcBit6 << 1; + uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; + uint8 srcBit6 = iPreviousCubeIndexX & 64; + uint8 destBit7 = srcBit6 << 1; - uint8_t srcBit5 = iPreviousCubeIndexX & 32; - uint8_t destBit4 = srcBit5 >> 1; + uint8 srcBit5 = iPreviousCubeIndexX & 32; + uint8 destBit4 = srcBit5 >> 1; - uint8_t srcBit2 = iPreviousCubeIndexX & 4; - uint8_t destBit3 = srcBit2 << 1; + uint8 srcBit2 = iPreviousCubeIndexX & 4; + uint8 destBit3 = srcBit2 << 1; - uint8_t srcBit1 = iPreviousCubeIndexX & 2; - uint8_t destBit0 = srcBit1 >> 1; + uint8 srcBit1 = iPreviousCubeIndexX & 2; + uint8 destBit0 = srcBit1 >> 1; iCubeIndex |= destBit0; if (v100 == 0) iCubeIndex |= 2; @@ -193,28 +193,28 @@ namespace PolyVox else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY())) { volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8_t v010 = volIter.getSubSampledVoxel(uLevel); + const uint8 v010 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); + const uint8 v110 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); + const uint8 v011 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); + const uint8 v111 = volIter.getSubSampledVoxel(uLevel); //y - uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; - uint8_t srcBit7 = iPreviousCubeIndexY & 128; - uint8_t destBit4 = srcBit7 >> 3; + uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; + uint8 srcBit7 = iPreviousCubeIndexY & 128; + uint8 destBit4 = srcBit7 >> 3; - uint8_t srcBit6 = iPreviousCubeIndexY & 64; - uint8_t destBit5 = srcBit6 >> 1; + uint8 srcBit6 = iPreviousCubeIndexY & 64; + uint8 destBit5 = srcBit6 >> 1; - uint8_t srcBit3 = iPreviousCubeIndexY & 8; - uint8_t destBit0 = srcBit3 >> 3; + uint8 srcBit3 = iPreviousCubeIndexY & 8; + uint8 destBit0 = srcBit3 >> 3; - uint8_t srcBit2 = iPreviousCubeIndexY & 4; - uint8_t destBit1 = srcBit2 >> 1; + uint8 srcBit2 = iPreviousCubeIndexY & 4; + uint8 destBit1 = srcBit2 >> 1; iCubeIndex |= destBit0; iCubeIndex |= destBit1; @@ -228,32 +228,32 @@ namespace PolyVox else { volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()); - const uint8_t v110 = volIter.getSubSampledVoxel(uLevel); + const uint8 v110 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); + const uint8 v111 = volIter.getSubSampledVoxel(uLevel); //y - uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; - uint8_t srcBit7 = iPreviousCubeIndexY & 128; - uint8_t destBit4 = srcBit7 >> 3; + uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; + uint8 srcBit7 = iPreviousCubeIndexY & 128; + uint8 destBit4 = srcBit7 >> 3; - uint8_t srcBit6 = iPreviousCubeIndexY & 64; - uint8_t destBit5 = srcBit6 >> 1; + uint8 srcBit6 = iPreviousCubeIndexY & 64; + uint8 destBit5 = srcBit6 >> 1; - uint8_t srcBit3 = iPreviousCubeIndexY & 8; - uint8_t destBit0 = srcBit3 >> 3; + uint8 srcBit3 = iPreviousCubeIndexY & 8; + uint8 destBit0 = srcBit3 >> 3; - uint8_t srcBit2 = iPreviousCubeIndexY & 4; - uint8_t destBit1 = srcBit2 >> 1; + uint8 srcBit2 = iPreviousCubeIndexY & 4; + uint8 destBit1 = srcBit2 >> 1; //x - uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; + uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; srcBit6 = iPreviousCubeIndexX & 64; - uint8_t destBit7 = srcBit6 << 1; + uint8 destBit7 = srcBit6 << 1; srcBit2 = iPreviousCubeIndexX & 4; - uint8_t destBit3 = srcBit2 << 1; + uint8 destBit3 = srcBit2 << 1; iCubeIndex |= destBit0; iCubeIndex |= destBit1; @@ -279,35 +279,35 @@ namespace PolyVox return uNoOfNonEmptyCells; } - std::uint32_t computeDecimatedBitmaskForSliceFromPrevious(BlockVolumeIterator& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, uint8_t* previousBitmask) + uint32 computeDecimatedBitmaskForSliceFromPrevious(BlockVolumeIterator& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, uint8* previousBitmask) { - const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; - std::uint32_t uNoOfNonEmptyCells = 0; + const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; + uint32 uNoOfNonEmptyCells = 0; //Iterate over each cell in the region - for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) + for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) { - for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) + for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) { //Current position volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8_t iCubeIndex = 0; + uint8 iCubeIndex = 0; if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY())) { volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v001 = volIter.getSubSampledVoxel(uLevel); + const uint8 v001 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); + const uint8 v101 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); + const uint8 v011 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); + const uint8 v111 = volIter.getSubSampledVoxel(uLevel); //z - uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; + uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; iCubeIndex = iPreviousCubeIndexZ >> 4; if (v001 == 0) iCubeIndex |= 16; @@ -318,21 +318,21 @@ namespace PolyVox else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY()) { volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v101 = volIter.getSubSampledVoxel(uLevel); + const uint8 v101 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); + const uint8 v111 = volIter.getSubSampledVoxel(uLevel); //z - uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; + uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; iCubeIndex = iPreviousCubeIndexZ >> 4; //x - uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; - uint8_t srcBit6 = iPreviousCubeIndexX & 64; - uint8_t destBit7 = srcBit6 << 1; + uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; + uint8 srcBit6 = iPreviousCubeIndexX & 64; + uint8 destBit7 = srcBit6 << 1; - uint8_t srcBit5 = iPreviousCubeIndexX & 32; - uint8_t destBit4 = srcBit5 >> 1; + uint8 srcBit5 = iPreviousCubeIndexX & 32; + uint8 destBit4 = srcBit5 >> 1; iCubeIndex |= destBit4; if (v101 == 0) iCubeIndex |= 32; @@ -342,21 +342,21 @@ namespace PolyVox else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY())) { volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v011 = volIter.getSubSampledVoxel(uLevel); + const uint8 v011 = volIter.getSubSampledVoxel(uLevel); volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); + const uint8 v111 = volIter.getSubSampledVoxel(uLevel); //z - uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; + uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; iCubeIndex = iPreviousCubeIndexZ >> 4; //y - uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; - uint8_t srcBit7 = iPreviousCubeIndexY & 128; - uint8_t destBit4 = srcBit7 >> 3; + uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; + uint8 srcBit7 = iPreviousCubeIndexY & 128; + uint8 destBit4 = srcBit7 >> 3; - uint8_t srcBit6 = iPreviousCubeIndexY & 64; - uint8_t destBit5 = srcBit6 >> 1; + uint8 srcBit6 = iPreviousCubeIndexY & 64; + uint8 destBit5 = srcBit6 >> 1; iCubeIndex |= destBit4; iCubeIndex |= destBit5; @@ -366,24 +366,24 @@ namespace PolyVox else { volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize); - const uint8_t v111 = volIter.getSubSampledVoxel(uLevel); + const uint8 v111 = volIter.getSubSampledVoxel(uLevel); //z - uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; + uint8 iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())]; iCubeIndex = iPreviousCubeIndexZ >> 4; //y - uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; - uint8_t srcBit7 = iPreviousCubeIndexY & 128; - uint8_t destBit4 = srcBit7 >> 3; + uint8 iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)]; + uint8 srcBit7 = iPreviousCubeIndexY & 128; + uint8 destBit4 = srcBit7 >> 3; - uint8_t srcBit6 = iPreviousCubeIndexY & 64; - uint8_t destBit5 = srcBit6 >> 1; + uint8 srcBit6 = iPreviousCubeIndexY & 64; + uint8 destBit5 = srcBit6 >> 1; //x - uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; + uint8 iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())]; srcBit6 = iPreviousCubeIndexX & 64; - uint8_t destBit7 = srcBit6 << 1; + uint8 destBit7 = srcBit6 << 1; iCubeIndex |= destBit4; iCubeIndex |= destBit5; @@ -405,23 +405,23 @@ namespace PolyVox return uNoOfNonEmptyCells; } - void generateDecimatedVerticesForSlice(BlockVolumeIterator& volIter, uint8_t uLevel, Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, IndexedSurfacePatch* singleMaterialPatch,std::int32_t vertexIndicesX[],std::int32_t vertexIndicesY[],std::int32_t vertexIndicesZ[]) + void generateDecimatedVerticesForSlice(BlockVolumeIterator& volIter, uint8 uLevel, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]) { - const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; + const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; //Iterate over each cell in the region - for(uint16_t y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) + for(uint16 y = regSlice.getLowerCorner().getY(); y <= regSlice.getUpperCorner().getY(); y += uStepSize) { - for(uint16_t x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) + for(uint16 x = regSlice.getLowerCorner().getX(); x <= regSlice.getUpperCorner().getX(); x += uStepSize) { //Current position - const uint16_t z = regSlice.getLowerCorner().getZ(); + const uint16 z = regSlice.getLowerCorner().getZ(); volIter.setPosition(x,y,z); - const uint8_t v000 = volIter.getSubSampledVoxel(uLevel); + const uint8 v000 = volIter.getSubSampledVoxel(uLevel); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8_t iCubeIndex = bitmask[getDecimatedIndex(x - offset.getX(),y - offset.getY())]; + uint8 iCubeIndex = bitmask[getDecimatedIndex(x - offset.getX(),y - offset.getY())]; /* Cube is entirely in/out of the surface */ if (edgeTable[iCubeIndex] == 0) @@ -435,10 +435,10 @@ namespace PolyVox if(x != regSlice.getUpperCorner().getX()) { volIter.setPosition(x + uStepSize,y,z); - const uint8_t v100 = volIter.getSubSampledVoxel(uLevel); + const uint8 v100 = volIter.getSubSampledVoxel(uLevel); const Vector3DFloat v3dPosition(x - offset.getX() + 0.5f * uStepSize, y - offset.getY(), z - offset.getZ()); const Vector3DFloat v3dNormal(v000 > v100 ? 1.0f : -1.0f,0.0,0.0); - const uint8_t uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. + const uint8 uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max. SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); vertexIndicesX[getDecimatedIndex(x - offset.getX(),y - offset.getY())] = singleMaterialPatch->m_vecVertices.size()-1; @@ -449,10 +449,10 @@ namespace PolyVox if(y != regSlice.getUpperCorner().getY()) { volIter.setPosition(x,y + uStepSize,z); - const uint8_t v010 = volIter.getSubSampledVoxel(uLevel); + const uint8 v010 = volIter.getSubSampledVoxel(uLevel); const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY() + 0.5f * uStepSize, z - offset.getZ()); const Vector3DFloat v3dNormal(0.0,v000 > v010 ? 1.0f : -1.0f,0.0); - const uint8_t uMaterial = v000 | v010; //Because one of these is 0, the or operation takes the max. + const uint8 uMaterial = v000 | v010; //Because one of these is 0, the or operation takes the max. SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); vertexIndicesY[getDecimatedIndex(x - offset.getX(),y - offset.getY())] = singleMaterialPatch->m_vecVertices.size()-1; @@ -463,10 +463,10 @@ namespace PolyVox //if(z != regSlice.getUpperCorner.getZ()) { volIter.setPosition(x,y,z + uStepSize); - const uint8_t v001 = volIter.getSubSampledVoxel(uLevel); + const uint8 v001 = volIter.getSubSampledVoxel(uLevel); const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY(), z - offset.getZ() + 0.5f * uStepSize); const Vector3DFloat v3dNormal(0.0,0.0,v000 > v001 ? 1.0f : -1.0f); - const uint8_t uMaterial = v000 | v001; //Because one of these is 0, the or operation takes the max. + const uint8 uMaterial = v000 | v001; //Because one of these is 0, the or operation takes the max. const SurfaceVertex surfaceVertex(v3dPosition, v3dNormal, uMaterial); singleMaterialPatch->m_vecVertices.push_back(surfaceVertex); vertexIndicesZ[getDecimatedIndex(x - offset.getX(),y - offset.getY())] = singleMaterialPatch->m_vecVertices.size()-1; @@ -476,20 +476,20 @@ namespace PolyVox } } - void generateDecimatedIndicesForSlice(BlockVolumeIterator& volIter, uint8_t uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8_t* bitmask0, uint8_t* bitmask1, std::int32_t vertexIndicesX0[],std::int32_t vertexIndicesY0[],std::int32_t vertexIndicesZ0[], std::int32_t vertexIndicesX1[],std::int32_t vertexIndicesY1[],std::int32_t vertexIndicesZ1[]) + void generateDecimatedIndicesForSlice(BlockVolumeIterator& volIter, uint8 uLevel, const Region& regSlice, IndexedSurfacePatch* singleMaterialPatch, const Vector3DFloat& offset, uint8* bitmask0, uint8* bitmask1, int32 vertexIndicesX0[],int32 vertexIndicesY0[],int32 vertexIndicesZ0[], int32 vertexIndicesX1[],int32 vertexIndicesY1[],int32 vertexIndicesZ1[]) { - const uint8_t uStepSize = uLevel == 0 ? 1 : 1 << uLevel; - std::uint32_t indlist[12]; + const uint8 uStepSize = uLevel == 0 ? 1 : 1 << uLevel; + uint32 indlist[12]; - for(uint16_t y = regSlice.getLowerCorner().getY() - offset.getY(); y < regSlice.getUpperCorner().getY() - offset.getY(); y += uStepSize) + for(uint16 y = regSlice.getLowerCorner().getY() - offset.getY(); y < regSlice.getUpperCorner().getY() - offset.getY(); y += uStepSize) { - for(uint16_t x = regSlice.getLowerCorner().getX() - offset.getX(); x < regSlice.getUpperCorner().getX() - offset.getX(); x += uStepSize) + for(uint16 x = regSlice.getLowerCorner().getX() - offset.getX(); x < regSlice.getUpperCorner().getX() - offset.getX(); x += uStepSize) { //Current position - const uint16_t z = regSlice.getLowerCorner().getZ() - offset.getZ(); + const uint16 z = regSlice.getLowerCorner().getZ() - offset.getZ(); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8_t iCubeIndex = bitmask0[getDecimatedIndex(x,y)]; + uint8 iCubeIndex = bitmask0[getDecimatedIndex(x,y)]; /* Cube is entirely in/out of the surface */ if (edgeTable[iCubeIndex] == 0) @@ -561,9 +561,9 @@ namespace PolyVox for (int i=0;triTable[iCubeIndex][i]!=-1;i+=3) { - std::uint32_t ind0 = indlist[triTable[iCubeIndex][i ]]; - std::uint32_t ind1 = indlist[triTable[iCubeIndex][i+1]]; - std::uint32_t ind2 = indlist[triTable[iCubeIndex][i+2]]; + uint32 ind0 = indlist[triTable[iCubeIndex][i ]]; + uint32 ind1 = indlist[triTable[iCubeIndex][i+1]]; + uint32 ind2 = indlist[triTable[iCubeIndex][i+2]]; singleMaterialPatch->m_vecTriangleIndices.push_back(ind0); singleMaterialPatch->m_vecTriangleIndices.push_back(ind1); @@ -573,7 +573,7 @@ namespace PolyVox } } - void generateDecimatedMeshDataForRegionSlow(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) + void generateDecimatedMeshDataForRegionSlow(BlockVolume* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch) { //When generating the mesh for a region we actually look one voxel outside it in the // back, bottom, right direction. Protect against access violations by cropping region here @@ -587,8 +587,8 @@ namespace PolyVox Vector3DFloat vertlist[12]; Vector3DFloat normlist[12]; - uint8_t vertMaterials[12]; - BlockVolumeIterator volIter(*volumeData); + uint8 vertMaterials[12]; + BlockVolumeIterator volIter(*volumeData); volIter.setValidRegion(region); ////////////////////////////////////////////////////////////////////////// @@ -597,33 +597,33 @@ namespace PolyVox //Iterate over each cell in the region //volIter.setPosition(region.getLowerCorner().getX(),region.getLowerCorner().getY(), region.getLowerCorner().getZ()); - for(uint16_t z = region.getLowerCorner().getZ(); z <= region.getUpperCorner().getZ(); z += 2) + for(uint16 z = region.getLowerCorner().getZ(); z <= region.getUpperCorner().getZ(); z += 2) { - for(uint16_t y = region.getLowerCorner().getY(); y <= region.getUpperCorner().getY(); y += 2) + for(uint16 y = region.getLowerCorner().getY(); y <= region.getUpperCorner().getY(); y += 2) { - for(uint16_t x = region.getLowerCorner().getX(); x <= region.getUpperCorner().getX(); x += 2) + for(uint16 x = region.getLowerCorner().getX(); x <= region.getUpperCorner().getX(); x += 2) { //while(volIter.moveForwardInRegionXYZ()) //{ volIter.setPosition(x,y,z); - const uint8_t v000 = volIter.getSubSampledVoxel(1); + const uint8 v000 = volIter.getSubSampledVoxel(1); volIter.setPosition(x+2,y,z); - const uint8_t v100 = volIter.getSubSampledVoxel(1); + const uint8 v100 = volIter.getSubSampledVoxel(1); volIter.setPosition(x,y+2,z); - const uint8_t v010 = volIter.getSubSampledVoxel(1); + const uint8 v010 = volIter.getSubSampledVoxel(1); volIter.setPosition(x+2,y+2,z); - const uint8_t v110 = volIter.getSubSampledVoxel(1); + const uint8 v110 = volIter.getSubSampledVoxel(1); volIter.setPosition(x,y,z+2); - const uint8_t v001 = volIter.getSubSampledVoxel(1); + const uint8 v001 = volIter.getSubSampledVoxel(1); volIter.setPosition(x+2,y,z+2); - const uint8_t v101 = volIter.getSubSampledVoxel(1); + const uint8 v101 = volIter.getSubSampledVoxel(1); volIter.setPosition(x,y+2,z+2); - const uint8_t v011 = volIter.getSubSampledVoxel(1); + const uint8 v011 = volIter.getSubSampledVoxel(1); volIter.setPosition(x+2,y+2,z+2); - const uint8_t v111 = volIter.getSubSampledVoxel(1); + const uint8 v111 = volIter.getSubSampledVoxel(1); //Determine the index into the edge table which tells us which vertices are inside of the surface - uint8_t iCubeIndex = 0; + uint8 iCubeIndex = 0; if (v000 == 0) iCubeIndex |= 1; if (v100 == 0) iCubeIndex |= 2; @@ -762,9 +762,9 @@ namespace PolyVox //const Vector3DFloat vertex1AsFloat = (static_cast(vertex1) / 2.0f) - offset; //const Vector3DFloat vertex2AsFloat = (static_cast(vertex2) / 2.0f) - offset; - 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]]; + const uint8 material0 = vertMaterials[triTable[iCubeIndex][i ]]; + const uint8 material1 = vertMaterials[triTable[iCubeIndex][i+1]]; + const uint8 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. @@ -784,7 +784,7 @@ namespace PolyVox //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->getVertices().begin(); @@ -797,15 +797,15 @@ namespace PolyVox } } - Vector3DFloat computeDecimatedNormal(BlockVolume* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) + Vector3DFloat computeDecimatedNormal(BlockVolume* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) { const float posX = position.getX(); const float posY = position.getY(); const float posZ = position.getZ(); - const uint16_t floorX = static_cast(posX); - const uint16_t floorY = static_cast(posY); - const uint16_t floorZ = static_cast(posZ); + const uint16 floorX = static_cast(posX); + const uint16 floorY = static_cast(posY); + const uint16 floorZ = static_cast(posZ); //Check all corners are within the volume, allowing a boundary for gradient estimation bool lowerCornerInside = volumeData->containsPoint(Vector3DInt32(floorX, floorY, floorZ),1); @@ -817,24 +817,24 @@ namespace PolyVox Vector3DFloat result; - BlockVolumeIterator volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create? + BlockVolumeIterator volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create? 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 Vector3DFloat gradFloor = computeSobelGradient(volIter); 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 Vector3DFloat gradCeil = computeSobelGradient(volIter); result = ((gradFloor + gradCeil) * -1.0f); @@ -846,19 +846,19 @@ namespace PolyVox } 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 Vector3DFloat gradFloor = computeCentralDifferenceGradient(volIter); 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 Vector3DFloat gradCeil = computeCentralDifferenceGradient(volIter); result = ((gradFloor + gradCeil) * -1.0f); @@ -870,21 +870,21 @@ namespace PolyVox } if(normalGenerationMethod == SIMPLE) { - volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); - const uint8_t uFloor = volIter.getVoxel() > 0 ? 1 : 0; + volIter.setPosition(static_cast(posX),static_cast(posY),static_cast(posZ)); + const uint8 uFloor = volIter.getVoxel() > 0 ? 1 : 0; if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5 { - uint8_t uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; + uint8 uCeil = volIter.peekVoxel1px0py0pz() > 0 ? 1 : 0; result = Vector3DFloat(static_cast(uFloor - uCeil),0.0,0.0); } else if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5 { - uint8_t uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; + uint8 uCeil = volIter.peekVoxel0px1py0pz() > 0 ? 1 : 0; result = Vector3DFloat(0.0,static_cast(uFloor - uCeil),0.0); } else if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5 { - uint8_t uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; + uint8 uCeil = volIter.peekVoxel0px0py1pz() > 0 ? 1 : 0; result = Vector3DFloat(0.0, 0.0,static_cast(uFloor - uCeil)); } } diff --git a/PolyVoxCore/source/Utility.cpp b/PolyVoxCore/source/Utility.cpp index 27f09de8..3ebf1876 100644 --- a/PolyVoxCore/source/Utility.cpp +++ b/PolyVoxCore/source/Utility.cpp @@ -27,21 +27,21 @@ namespace PolyVox { //Note: this function only works for inputs which are a power of two and not zero //If this is not the case then the output is undefined. - std::uint8_t logBase2(std::uint32_t uInput) + uint8 logBase2(uint32 uInput) { assert(uInput != 0); assert(isPowerOf2(uInput)); - std::uint32_t uResult = 0; + uint32 uResult = 0; while( (uInput >> uResult) != 0) { ++uResult; } - return static_cast(uResult-1); + return static_cast(uResult-1); } - bool isPowerOf2(std::uint32_t uInput) + bool isPowerOf2(uint32 uInput) { if(uInput == 0) return false; diff --git a/PolyVoxCore/source/VolumeChangeTracker.cpp b/PolyVoxCore/source/VolumeChangeTracker.cpp index 6d86bc30..79431099 100644 --- a/PolyVoxCore/source/VolumeChangeTracker.cpp +++ b/PolyVoxCore/source/VolumeChangeTracker.cpp @@ -50,7 +50,7 @@ namespace PolyVox { } - void VolumeChangeTracker::setVolumeData(BlockVolume* volumeDataToSet) + void VolumeChangeTracker::setVolumeData(BlockVolume* volumeDataToSet) { volumeData = volumeDataToSet; volRegionUpToDate = new LinearVolume(PolyVox::logBase2(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS)); @@ -64,23 +64,23 @@ namespace PolyVox listToFill.clear(); //Regenerate meshes. - for(uint16_t regionZ = 0; regionZ < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionZ) - //for(uint16_t regionZ = 0; regionZ < 1; ++regionZ) + for(uint16 regionZ = 0; regionZ < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionZ) + //for(uint16 regionZ = 0; regionZ < 1; ++regionZ) { - for(uint16_t regionY = 0; regionY < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionY) - //for(uint16_t regionY = 0; regionY < 2; ++regionY) + for(uint16 regionY = 0; regionY < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionY) + //for(uint16 regionY = 0; regionY < 2; ++regionY) { - for(uint16_t regionX = 0; regionX < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionX) - //for(uint16_t regionX = 0; regionX < 2; ++regionX) + for(uint16 regionX = 0; regionX < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++regionX) + //for(uint16 regionX = 0; regionX < 2; ++regionX) { if(volRegionUpToDate->getVoxelAt(regionX, regionY, regionZ) == false) { - const uint16_t firstX = regionX * POLYVOX_REGION_SIDE_LENGTH; - const uint16_t firstY = regionY * POLYVOX_REGION_SIDE_LENGTH; - const uint16_t firstZ = regionZ * POLYVOX_REGION_SIDE_LENGTH; - const uint16_t lastX = firstX + POLYVOX_REGION_SIDE_LENGTH; - const uint16_t lastY = firstY + POLYVOX_REGION_SIDE_LENGTH; - const uint16_t lastZ = firstZ + POLYVOX_REGION_SIDE_LENGTH; + const uint16 firstX = regionX * POLYVOX_REGION_SIDE_LENGTH; + const uint16 firstY = regionY * POLYVOX_REGION_SIDE_LENGTH; + const uint16 firstZ = regionZ * POLYVOX_REGION_SIDE_LENGTH; + const uint16 lastX = firstX + POLYVOX_REGION_SIDE_LENGTH; + const uint16 lastY = firstY + POLYVOX_REGION_SIDE_LENGTH; + const uint16 lastZ = firstZ + POLYVOX_REGION_SIDE_LENGTH; listToFill.push_back(Region(Vector3DInt32(firstX, firstY, firstZ), Vector3DInt32(lastX, lastY, lastZ))); } @@ -91,11 +91,11 @@ namespace PolyVox void VolumeChangeTracker::setAllRegionsUpToDate(bool newUpToDateValue) { - for(uint16_t blockZ = 0; blockZ < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockZ) + for(uint16 blockZ = 0; blockZ < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockZ) { - for(uint16_t blockY = 0; blockY < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockY) + for(uint16 blockY = 0; blockY < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockY) { - for(uint16_t blockX = 0; blockX < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockX) + for(uint16 blockX = 0; blockX < POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS; ++blockX) { volRegionUpToDate->setVoxelAt(blockX, blockY, blockZ, newUpToDateValue); } @@ -103,7 +103,7 @@ namespace PolyVox } } - uint16_t VolumeChangeTracker::getSideLength(void) + uint16 VolumeChangeTracker::getSideLength(void) { return volumeData->getSideLength(); } @@ -113,31 +113,31 @@ namespace PolyVox return volumeData->getEnclosingRegion(); } - uint8_t VolumeChangeTracker::getVoxelAt(const Vector3DUint16& pos) + uint8 VolumeChangeTracker::getVoxelAt(const Vector3DUint16& pos) { return getVoxelAt(pos.getX(), pos.getY(), pos.getZ()); } - uint8_t VolumeChangeTracker::getVoxelAt(uint16_t uX, uint16_t uY, uint16_t uZ) + uint8 VolumeChangeTracker::getVoxelAt(uint16 uX, uint16 uY, uint16 uZ) { assert(uX < volumeData->getSideLength()); assert(uY < volumeData->getSideLength()); assert(uZ < volumeData->getSideLength()); - BlockVolumeIterator volIter(*volumeData); + BlockVolumeIterator volIter(*volumeData); volIter.setPosition(uX,uY,uZ); return volIter.getVoxel(); } - BlockVolume* VolumeChangeTracker::getVolumeData(void) const + BlockVolume* VolumeChangeTracker::getVolumeData(void) const { return volumeData; } - void VolumeChangeTracker::setVoxelAt(std::uint16_t x, std::uint16_t y, std::uint16_t z, std::uint8_t value) + void VolumeChangeTracker::setVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value) { //FIXME - rather than creating a iterator each time we should have one stored - BlockVolumeIterator iterVol(*volumeData); + BlockVolumeIterator iterVol(*volumeData); iterVol.setPosition(x,y,z); iterVol.setVoxel(value); @@ -153,23 +153,23 @@ namespace PolyVox } else //Mark surrounding regions as well { - const uint16_t regionX = x >> POLYVOX_REGION_SIDE_LENGTH_POWER; - const uint16_t regionY = y >> POLYVOX_REGION_SIDE_LENGTH_POWER; - const uint16_t regionZ = z >> POLYVOX_REGION_SIDE_LENGTH_POWER; + const uint16 regionX = x >> POLYVOX_REGION_SIDE_LENGTH_POWER; + const uint16 regionY = y >> POLYVOX_REGION_SIDE_LENGTH_POWER; + const uint16 regionZ = z >> POLYVOX_REGION_SIDE_LENGTH_POWER; - 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 uint16 minRegionX = (std::max)(uint16(0),uint16(regionX-1)); + const uint16 minRegionY = (std::max)(uint16(0),uint16(regionY-1)); + const uint16 minRegionZ = (std::max)(uint16(0),uint16(regionZ-1)); - const uint16_t maxRegionX = (std::min)(uint16_t(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16_t(regionX+1)); - const uint16_t maxRegionY = (std::min)(uint16_t(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16_t(regionY+1)); - const uint16_t maxRegionZ = (std::min)(uint16_t(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16_t(regionZ+1)); + const uint16 maxRegionX = (std::min)(uint16(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16(regionX+1)); + const uint16 maxRegionY = (std::min)(uint16(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16(regionY+1)); + const uint16 maxRegionZ = (std::min)(uint16(POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS-1),uint16(regionZ+1)); - for(uint16_t zCt = minRegionZ; zCt <= maxRegionZ; zCt++) + for(uint16 zCt = minRegionZ; zCt <= maxRegionZ; zCt++) { - for(uint16_t yCt = minRegionY; yCt <= maxRegionY; yCt++) + for(uint16 yCt = minRegionY; yCt <= maxRegionY; yCt++) { - for(uint16_t xCt = minRegionX; xCt <= maxRegionX; xCt++) + for(uint16 xCt = minRegionX; xCt <= maxRegionX; xCt++) { volRegionUpToDate->setVoxelAt(xCt,yCt,zCt,false); } @@ -178,12 +178,12 @@ namespace PolyVox } } - void VolumeChangeTracker::setLockedVoxelAt(std::uint16_t x, std::uint16_t y, std::uint16_t z, std::uint8_t value) + void VolumeChangeTracker::setLockedVoxelAt(uint16 x, uint16 y, uint16 z, uint8 value) { assert(m_bIsLocked); //FIXME - rather than creating a iterator each time we should have one stored - BlockVolumeIterator iterVol(*volumeData); + BlockVolumeIterator iterVol(*volumeData); iterVol.setPosition(x,y,z); iterVol.setVoxel(value); } @@ -206,19 +206,19 @@ namespace PolyVox throw std::logic_error("No region is locked. You must lock a region before you can unlock it."); } - const uint16_t firstRegionX = m_regLastLocked.getLowerCorner().getX() >> POLYVOX_REGION_SIDE_LENGTH_POWER; - const uint16_t firstRegionY = m_regLastLocked.getLowerCorner().getY() >> POLYVOX_REGION_SIDE_LENGTH_POWER; - const uint16_t firstRegionZ = m_regLastLocked.getLowerCorner().getZ() >> POLYVOX_REGION_SIDE_LENGTH_POWER; + const uint16 firstRegionX = m_regLastLocked.getLowerCorner().getX() >> POLYVOX_REGION_SIDE_LENGTH_POWER; + const uint16 firstRegionY = m_regLastLocked.getLowerCorner().getY() >> POLYVOX_REGION_SIDE_LENGTH_POWER; + const uint16 firstRegionZ = m_regLastLocked.getLowerCorner().getZ() >> POLYVOX_REGION_SIDE_LENGTH_POWER; - const uint16_t lastRegionX = m_regLastLocked.getUpperCorner().getX() >> POLYVOX_REGION_SIDE_LENGTH_POWER; - const uint16_t lastRegionY = m_regLastLocked.getUpperCorner().getY() >> POLYVOX_REGION_SIDE_LENGTH_POWER; - const uint16_t lastRegionZ = m_regLastLocked.getUpperCorner().getZ() >> POLYVOX_REGION_SIDE_LENGTH_POWER; + const uint16 lastRegionX = m_regLastLocked.getUpperCorner().getX() >> POLYVOX_REGION_SIDE_LENGTH_POWER; + const uint16 lastRegionY = m_regLastLocked.getUpperCorner().getY() >> POLYVOX_REGION_SIDE_LENGTH_POWER; + const uint16 lastRegionZ = m_regLastLocked.getUpperCorner().getZ() >> POLYVOX_REGION_SIDE_LENGTH_POWER; - for(uint16_t zCt = firstRegionZ; zCt <= lastRegionZ; zCt++) + for(uint16 zCt = firstRegionZ; zCt <= lastRegionZ; zCt++) { - for(uint16_t yCt = firstRegionY; yCt <= lastRegionY; yCt++) + for(uint16 yCt = firstRegionY; yCt <= lastRegionY; yCt++) { - for(uint16_t xCt = firstRegionX; xCt <= lastRegionX; xCt++) + for(uint16 xCt = firstRegionX; xCt <= lastRegionX; xCt++) { volRegionUpToDate->setVoxelAt(xCt,yCt,zCt,false); } diff --git a/PolyVoxCore/source/VoxelFilters.cpp b/PolyVoxCore/source/VoxelFilters.cpp index cd954dc6..6e91f2a5 100644 --- a/PolyVoxCore/source/VoxelFilters.cpp +++ b/PolyVoxCore/source/VoxelFilters.cpp @@ -4,7 +4,7 @@ namespace PolyVox { - float computeSmoothedVoxel(BlockVolumeIterator& volIter) + float computeSmoothedVoxel(BlockVolumeIterator& volIter) { assert(volIter.getPosX() >= 1); assert(volIter.getPosY() >= 1); diff --git a/TODO.txt b/TODO.txt index 13f24005..65efdcec 100644 --- a/TODO.txt +++ b/TODO.txt @@ -7,7 +7,6 @@ Refine interface to mesh generateion - flags structure? Refine interface to volumes and iterators. Implement block volume tidy() funtion. Remove hard-coded region size. -Remove boost dependancy? Seperate namespaces - PolyVoxCore, PolyVoxUtil, PolyVoxImpl Move getChangedRegionGeometry() out of PolyVon and into Thermite? Remove/refactor IndexedSurfacePatch? Incorporate into RegionGeometry? diff --git a/examples/OpenGL/main.cpp b/examples/OpenGL/main.cpp index 41d1b882..64308b71 100644 --- a/examples/OpenGL/main.cpp +++ b/examples/OpenGL/main.cpp @@ -15,12 +15,12 @@ using namespace std; //Global variables are easier for demonstration purposes, especially //as I'm not sure how/if I can pass variables to the GLUT functions. -const uint16_t g_uVolumeSideLength = 128; -const uint16_t g_uRegionSideLength = 16; -const uint16_t g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength; +const uint16 g_uVolumeSideLength = 128; +const uint16 g_uRegionSideLength = 16; +const uint16 g_uVolumeSideLengthInRegions = g_uVolumeSideLength / g_uRegionSideLength; //Creates a volume 128x128x128 -BlockVolume g_volData(logBase2(g_uVolumeSideLength)); +BlockVolume g_volData(logBase2(g_uVolumeSideLength)); //Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region IndexedSurfacePatch* g_ispRegionSurfaces[g_uVolumeSideLengthInRegions][g_uVolumeSideLengthInRegions][g_uVolumeSideLengthInRegions]; @@ -28,7 +28,7 @@ IndexedSurfacePatch* g_ispRegionSurfaces[g_uVolumeSideLengthInRegions][g_uVolume void createSphereInVolume(void) { //Create an iterator to access data in the volume - BlockVolumeIterator volIter(g_volData); + BlockVolumeIterator volIter(g_volData); //A region corresponding to the whole volume const Region& regWholeVolume = g_volData.getEnclosingRegion(); @@ -47,7 +47,7 @@ void createSphereInVolume(void) if(fDistToCenter <= 50.0f) { - volIter.setVoxel(static_cast(fDistToCenter)); + volIter.setVoxel(static_cast(fDistToCenter)); } else { @@ -76,15 +76,15 @@ void display ( void ) // Create The Display Function glTranslatef(-g_uVolumeSideLength/2,-g_uVolumeSideLength/2,-200.0f); glBegin(GL_TRIANGLES); - for(uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) + for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) { - for(uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) + for(uint16 uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) { - for(uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) + for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) { const vector& vecVertices = g_ispRegionSurfaces[uRegionX][uRegionY][uRegionZ]->getVertices(); - const vector& vecIndices = g_ispRegionSurfaces[uRegionX][uRegionY][uRegionZ]->getIndices(); - for(vector::const_iterator iterIndex = vecIndices.begin(); iterIndex != vecIndices.end(); ++iterIndex) + const vector& vecIndices = g_ispRegionSurfaces[uRegionX][uRegionY][uRegionZ]->getIndices(); + for(vector::const_iterator iterIndex = vecIndices.begin(); iterIndex != vecIndices.end(); ++iterIndex) { const SurfaceVertex& vertex = vecVertices[*iterIndex]; const Vector3DFloat& v3dVertexPos = vertex.getPosition(); @@ -144,11 +144,11 @@ void main ( int argc, char** argv ) // Create Main Function For Bringing It Al { createSphereInVolume(); - for(uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) + for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) { - for(uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) + for(uint16 uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) { - for(uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) + for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) { g_ispRegionSurfaces[uRegionX][uRegionY][uRegionZ] = new IndexedSurfacePatch(); IndexedSurfacePatch* ispCurrent = g_ispRegionSurfaces[uRegionX][uRegionY][uRegionZ]; @@ -171,11 +171,11 @@ void main ( int argc, char** argv ) // Create Main Function For Bringing It Al glutSpecialFunc ( arrow_keys ); glutMainLoop ( ); // Initialize The Main Loop - for(uint16_t uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) + for(uint16 uRegionZ = 0; uRegionZ < g_uVolumeSideLengthInRegions; ++uRegionZ) { - for(uint16_t uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) + for(uint16 uRegionY = 0; uRegionY < g_uVolumeSideLengthInRegions; ++uRegionY) { - for(uint16_t uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) + for(uint16 uRegionX = 0; uRegionX < g_uVolumeSideLengthInRegions; ++uRegionX) { delete g_ispRegionSurfaces[uRegionX][uRegionY][uRegionZ]; }