Moved typedef'd integers into PlyVox namespace instead of std.
This commit is contained in:
parent
1c2a007d23
commit
0758f81b54
@ -36,22 +36,22 @@ namespace PolyVox
|
||||
//Make BlockVolumeIterator a friend
|
||||
friend class BlockVolumeIterator<VoxelType>;
|
||||
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;
|
||||
};
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace PolyVox
|
||||
{
|
||||
#pragma region Constructors/Destructors
|
||||
template <typename VoxelType>
|
||||
Block<VoxelType>::Block(std::uint8_t uSideLengthPower)
|
||||
Block<VoxelType>::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 <typename VoxelType>
|
||||
std::uint16_t Block<VoxelType>::getSideLength(void) const
|
||||
uint16 Block<VoxelType>::getSideLength(void) const
|
||||
{
|
||||
return m_uSideLength;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType Block<VoxelType>::getVoxelAt(std::uint16_t uXPos, std::uint16_t uYPos, std::uint16_t uZPos) const
|
||||
VoxelType Block<VoxelType>::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 <typename VoxelType>
|
||||
void Block<VoxelType>::setVoxelAt(std::uint16_t uXPos, std::uint16_t uYPos, std::uint16_t uZPos, VoxelType tValue)
|
||||
void Block<VoxelType>::setVoxelAt(uint16 uXPos, uint16 uYPos, uint16 uZPos, VoxelType tValue)
|
||||
{
|
||||
assert(uXPos < m_uSideLength);
|
||||
assert(uYPos < m_uSideLength);
|
||||
|
@ -39,21 +39,21 @@ namespace PolyVox
|
||||
friend class BlockVolumeIterator<VoxelType>;
|
||||
|
||||
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<VoxelType> firstVoxel(void);
|
||||
void idle(std::uint32_t uAmount);
|
||||
void idle(uint32 uAmount);
|
||||
BlockVolumeIterator<VoxelType> lastVoxel(void);
|
||||
|
||||
private:
|
||||
@ -65,20 +65,20 @@ namespace PolyVox
|
||||
VoxelType* m_pHomogenousValue;
|
||||
mutable std::map<VoxelType, Block<VoxelType>*> 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<float> FloatBlockVolume;
|
||||
typedef BlockVolume<std::uint8_t> UInt8BlockVolume;
|
||||
typedef BlockVolume<std::uint16_t> UInt16BlockVolume;
|
||||
typedef BlockVolume<uint8> UInt8BlockVolume;
|
||||
typedef BlockVolume<uint16> UInt16BlockVolume;
|
||||
}
|
||||
|
||||
#include "BlockVolume.inl"
|
||||
|
@ -32,7 +32,7 @@ namespace PolyVox
|
||||
{
|
||||
#pragma region Constructors/Destructors
|
||||
template <typename VoxelType>
|
||||
BlockVolume<VoxelType>::BlockVolume(std::uint8_t uSideLengthPower, std::uint8_t uBlockSideLengthPower)
|
||||
BlockVolume<VoxelType>::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<VoxelType>(uBlockSideLengthPower);
|
||||
m_pIsShared[i] = true;
|
||||
@ -78,7 +78,7 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
BlockVolume<VoxelType>::~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<Block>(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 <typename VoxelType>
|
||||
std::uint16_t BlockVolume<VoxelType>::getSideLength(void) const
|
||||
uint16 BlockVolume<VoxelType>::getSideLength(void) const
|
||||
{
|
||||
return m_uSideLength;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType BlockVolume<VoxelType>::getVoxelAt(std::uint16_t uXPos, std::uint16_t uYPos, std::uint16_t uZPos) const
|
||||
VoxelType BlockVolume<VoxelType>::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<VoxelType>* block = m_pBlocks
|
||||
[
|
||||
@ -181,7 +181,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
bool BlockVolume<VoxelType>::containsPoint(const Vector3DInt32& pos, std::uint16_t boundary) const
|
||||
bool BlockVolume<VoxelType>::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 <typename VoxelType>
|
||||
void BlockVolume<VoxelType>::idle(std::uint32_t uAmount)
|
||||
void BlockVolume<VoxelType>::idle(uint32 uAmount)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -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<VoxelType>& 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<VoxelType>& 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;
|
||||
};
|
||||
|
@ -105,25 +105,25 @@ namespace PolyVox
|
||||
|
||||
#pragma region Getters
|
||||
template <typename VoxelType>
|
||||
std::uint16_t BlockVolumeIterator<VoxelType>::getPosX(void) const
|
||||
uint16 BlockVolumeIterator<VoxelType>::getPosX(void) const
|
||||
{
|
||||
return mXPosInVolume;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
std::uint16_t BlockVolumeIterator<VoxelType>::getPosY(void) const
|
||||
uint16 BlockVolumeIterator<VoxelType>::getPosY(void) const
|
||||
{
|
||||
return mYPosInVolume;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
std::uint16_t BlockVolumeIterator<VoxelType>::getPosZ(void) const
|
||||
uint16 BlockVolumeIterator<VoxelType>::getPosZ(void) const
|
||||
{
|
||||
return mZPosInVolume;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType BlockVolumeIterator<VoxelType>::getSubSampledVoxel(std::uint8_t uLevel) const
|
||||
VoxelType BlockVolumeIterator<VoxelType>::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 <typename VoxelType>
|
||||
void BlockVolumeIterator<VoxelType>::setPosition(std::uint16_t xPos, std::uint16_t yPos, std::uint16_t zPos)
|
||||
void BlockVolumeIterator<VoxelType>::setPosition(uint16 xPos, uint16 yPos, uint16 zPos)
|
||||
{
|
||||
mXPosInVolume = xPos;
|
||||
mYPosInVolume = yPos;
|
||||
@ -214,7 +214,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
void BlockVolumeIterator<VoxelType>::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<VoxelType>::setValidRegion(uint16 xFirst, uint16 yFirst, uint16 zFirst, uint16 xLast, uint16 yLast, uint16 zLast)
|
||||
{
|
||||
mXRegionFirst = xFirst;
|
||||
mYRegionFirst = yFirst;
|
||||
@ -236,7 +236,7 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
void BlockVolumeIterator<VoxelType>::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<VoxelType>* 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);
|
||||
|
@ -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
|
||||
|
@ -40,8 +40,8 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeSobelGradient(const BlockVolumeIterator<VoxelType>& volIter);
|
||||
|
||||
POLYVOX_API void computeNormalsForVertices(BlockVolume<std::uint8_t>* volumeData, RegionGeometry& regGeom, NormalGenerationMethod normalGenerationMethod);
|
||||
POLYVOX_API Vector3DFloat computeNormal(BlockVolume<std::uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod);
|
||||
POLYVOX_API void computeNormalsForVertices(BlockVolume<uint8>* volumeData, RegionGeometry& regGeom, NormalGenerationMethod normalGenerationMethod);
|
||||
POLYVOX_API Vector3DFloat computeNormal(BlockVolume<uint8>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod);
|
||||
}
|
||||
|
||||
#include "GradientEstimators.inl"
|
||||
|
@ -47,9 +47,9 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeDecimatedCentralDifferenceGradient(const BlockVolumeIterator<VoxelType>& 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 <typename VoxelType>
|
||||
Vector3DFloat computeSmoothCentralDifferenceGradient(BlockVolumeIterator<VoxelType>& 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);
|
||||
|
@ -40,17 +40,17 @@ namespace PolyVox
|
||||
~IndexedSurfacePatch();
|
||||
|
||||
void addTriangle(const SurfaceVertex& v0,const SurfaceVertex& v1,const SurfaceVertex& v2);
|
||||
void fillVertexAndIndexData(std::vector<SurfaceVertex>& vecVertices, std::vector<std::uint32_t>& vecIndices);
|
||||
void fillVertexAndIndexData(std::vector<SurfaceVertex>& vecVertices, std::vector<uint32>& vecIndices);
|
||||
|
||||
const std::vector<SurfaceVertex>& getVertices(void) const;
|
||||
std::vector<SurfaceVertex>& getVertices(void); //FIXME - non const version should be removed.
|
||||
const std::vector<std::uint32_t>& getIndices(void) const;
|
||||
const std::vector<uint32>& getIndices(void) const;
|
||||
|
||||
unsigned short getNoNonUniformTrianges(void);
|
||||
unsigned short getNoUniformTrianges(void);
|
||||
|
||||
public:
|
||||
std::vector<std::uint32_t> m_vecTriangleIndices;
|
||||
std::vector<uint32> m_vecTriangleIndices;
|
||||
std::vector<SurfaceVertex> m_vecVertices;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace PolyVox
|
||||
{
|
||||
|
||||
template <typename VoxelType>
|
||||
LinearVolume<VoxelType>::LinearVolume(std::uint8_t uSideLengthPower)
|
||||
LinearVolume<VoxelType>::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 <typename VoxelType>
|
||||
VoxelType LinearVolume<VoxelType>::getVoxelAt(const std::uint16_t xPosition, const std::uint16_t yPosition, const std::uint16_t zPosition) const
|
||||
VoxelType LinearVolume<VoxelType>::getVoxelAt(const uint16 xPosition, const uint16 yPosition, const uint16 zPosition) const
|
||||
{
|
||||
return m_tData
|
||||
[
|
||||
@ -78,7 +78,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
void LinearVolume<VoxelType>::setVoxelAt(const std::uint16_t xPosition, const std::uint16_t yPosition, const std::uint16_t zPosition, const VoxelType value)
|
||||
void LinearVolume<VoxelType>::setVoxelAt(const uint16 xPosition, const uint16 yPosition, const uint16 zPosition, const VoxelType value)
|
||||
{
|
||||
m_tData
|
||||
[
|
||||
@ -89,13 +89,13 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
std::uint16_t LinearVolume<VoxelType>::getSideLength(void)
|
||||
uint16 LinearVolume<VoxelType>::getSideLength(void)
|
||||
{
|
||||
return m_uSideLength;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
std::uint32_t LinearVolume<VoxelType>::getNoOfVoxels(void)
|
||||
uint32 LinearVolume<VoxelType>::getNoOfVoxels(void)
|
||||
{
|
||||
return m_uSideLength * m_uSideLength * m_uSideLength;
|
||||
}
|
||||
|
@ -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 <cstdint> 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
|
@ -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 <typename VoxelType> class BlockVolume;
|
||||
typedef BlockVolume<float> FloatBlockVolume;
|
||||
typedef BlockVolume<std::uint8_t> UInt8BlockVolume;
|
||||
typedef BlockVolume<std::uint16_t> UInt16BlockVolume;
|
||||
typedef BlockVolume<uint8> UInt8BlockVolume;
|
||||
typedef BlockVolume<uint16> UInt16BlockVolume;
|
||||
//---------------------------------
|
||||
|
||||
class IndexedSurfacePatch;
|
||||
@ -45,15 +44,15 @@ namespace PolyVox
|
||||
class SurfaceVertex;
|
||||
|
||||
//---------- Vector ----------
|
||||
template <std::uint32_t Size, typename Type> class Vector;
|
||||
template <uint32 Size, typename Type> 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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -32,8 +32,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
POLYVOX_API void smoothRegionGeometry(BlockVolume<std::uint8_t>* volumeData, RegionGeometry& regGeom);
|
||||
POLYVOX_API void adjustDecimatedGeometry(BlockVolume<std::uint8_t>* volumeData, RegionGeometry& regGeom, std::uint8_t val);
|
||||
POLYVOX_API void smoothRegionGeometry(BlockVolume<uint8>* volumeData, RegionGeometry& regGeom);
|
||||
POLYVOX_API void adjustDecimatedGeometry(BlockVolume<uint8>* volumeData, RegionGeometry& regGeom, uint8 val);
|
||||
}
|
||||
|
||||
#endif
|
@ -36,18 +36,18 @@ namespace PolyVox
|
||||
{
|
||||
POLYVOX_API std::list<RegionGeometry> 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<std::uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
POLYVOX_API std::uint32_t computeInitialRoughBitmaskForSlice(BlockVolumeIterator<std::uint8_t>& volIter, const Region& regSlice, const Vector3DFloat& offset, std::uint8_t *bitmask);
|
||||
POLYVOX_API std::uint32_t computeRoughBitmaskForSliceFromPrevious(BlockVolumeIterator<std::uint8_t>& volIter, const Region& regSlice, const Vector3DFloat& offset, std::uint8_t *bitmask, std::uint8_t *previousBitmask);
|
||||
POLYVOX_API void generateRoughIndicesForSlice(BlockVolumeIterator<std::uint8_t>& 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<std::uint8_t>& 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<uint8>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
POLYVOX_API uint32 computeInitialRoughBitmaskForSlice(BlockVolumeIterator<uint8>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask);
|
||||
POLYVOX_API uint32 computeRoughBitmaskForSliceFromPrevious(BlockVolumeIterator<uint8>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask, uint8 *previousBitmask);
|
||||
POLYVOX_API void generateRoughIndicesForSlice(BlockVolumeIterator<uint8>& 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<uint8>& volIter, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]);
|
||||
|
||||
POLYVOX_API void generateReferenceMeshDataForRegion(BlockVolume<std::uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
POLYVOX_API void generateReferenceMeshDataForRegion(BlockVolume<uint8>* 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
|
||||
|
@ -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<std::uint8_t>* volumeData, std::uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
POLYVOX_API std::uint32_t computeInitialDecimatedBitmaskForSlice(BlockVolumeIterator<std::uint8_t>& volIter, std::uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, std::uint8_t *bitmask);
|
||||
POLYVOX_API std::uint32_t computeDecimatedBitmaskForSliceFromPrevious(BlockVolumeIterator<std::uint8_t>& volIter, std::uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, std::uint8_t *bitmask, std::uint8_t *previousBitmask);
|
||||
POLYVOX_API void generateDecimatedIndicesForSlice(BlockVolumeIterator<std::uint8_t>& 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<std::uint8_t>& 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<uint8>* volumeData, uint8 uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
POLYVOX_API uint32 computeInitialDecimatedBitmaskForSlice(BlockVolumeIterator<uint8>& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask);
|
||||
POLYVOX_API uint32 computeDecimatedBitmaskForSliceFromPrevious(BlockVolumeIterator<uint8>& volIter, uint8 uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8 *bitmask, uint8 *previousBitmask);
|
||||
POLYVOX_API void generateDecimatedIndicesForSlice(BlockVolumeIterator<uint8>& 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<uint8>& volIter, uint8 uLevel, Region& regSlice, const Vector3DFloat& offset, uint8* bitmask, IndexedSurfacePatch* singleMaterialPatch,int32 vertexIndicesX[],int32 vertexIndicesY[],int32 vertexIndicesZ[]);
|
||||
|
||||
POLYVOX_API void generateDecimatedMeshDataForRegionSlow(BlockVolume<std::uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
POLYVOX_API void generateDecimatedMeshDataForRegionSlow(BlockVolume<uint8>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch);
|
||||
|
||||
POLYVOX_API Vector3DFloat computeDecimatedNormal(BlockVolume<std::uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod);
|
||||
POLYVOX_API Vector3DFloat computeDecimatedNormal(BlockVolume<uint8>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -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 <typename Type>
|
||||
Type trilinearlyInterpolate(
|
||||
|
@ -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 <iostream>
|
||||
#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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
class Vector
|
||||
{
|
||||
public:
|
||||
@ -66,7 +66,7 @@ namespace PolyVox
|
||||
Vector<Size,Type>& 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 <std::uint32_t Size,typename Type>
|
||||
template <uint32 Size,typename Type>
|
||||
Vector<Size,Type> operator+(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw();
|
||||
///Subtraction operator.
|
||||
template <std::uint32_t Size,typename Type>
|
||||
template <uint32 Size,typename Type>
|
||||
Vector<Size,Type> operator-(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw();
|
||||
///Multiplication operator.
|
||||
template <std::uint32_t Size,typename Type>
|
||||
template <uint32 Size,typename Type>
|
||||
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw();
|
||||
///Division operator.
|
||||
template <std::uint32_t Size,typename Type>
|
||||
template <uint32 Size,typename Type>
|
||||
Vector<Size,Type> operator/(const Vector<Size,Type>& lhs, const Type& rhs) throw();
|
||||
///Stream insertion operator.
|
||||
template <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
std::ostream& operator<<(std::ostream& os, const Vector<Size,Type>& 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;
|
||||
|
||||
|
||||
|
||||
|
@ -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 <std::uint32_t Size,typename Type>
|
||||
template <uint32 Size,typename Type>
|
||||
Vector<Size,Type>::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 <std::uint32_t Size,typename Type>
|
||||
template <uint32 Size,typename Type>
|
||||
Vector<Size,Type>::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 <std::uint32_t Size,typename Type>
|
||||
template <uint32 Size,typename Type>
|
||||
Vector<Size,Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
Vector<Size, Type>::Vector(const Vector<Size, Type>& 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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
template <typename CastType>
|
||||
Vector<Size, Type>::Vector(const Vector<Size, CastType>& vector) throw()
|
||||
{
|
||||
for(std::uint32_t ct = 0; ct < Size; ++ct)
|
||||
for(uint32 ct = 0; ct < Size; ++ct)
|
||||
{
|
||||
m_tElements[ct] = static_cast<CastType>(vector.getElement(ct));
|
||||
}
|
||||
@ -133,7 +133,7 @@ namespace PolyVox
|
||||
/**
|
||||
Destroys the Vector.
|
||||
*/
|
||||
template <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
Vector<Size, Type>::~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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
Vector<Size, Type>& Vector<Size, Type>::operator=(const Vector<Size, Type>& rhs) throw()
|
||||
{
|
||||
if(this == &rhs)
|
||||
@ -162,11 +162,11 @@ namespace PolyVox
|
||||
\return true if the Vectors match.
|
||||
\see operator!=
|
||||
*/
|
||||
template <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline bool Vector<Size, Type>::operator==(const Vector<Size, Type> &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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline bool Vector<Size, Type>::operator<(const Vector<Size, Type> &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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::operator+=(const Vector<Size, Type>& 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 <std::uint32_t Size,typename Type>
|
||||
template <uint32 Size,typename Type>
|
||||
Vector<Size,Type> operator+(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
@ -231,10 +231,10 @@ namespace PolyVox
|
||||
\param rhs Vector to subtract
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::operator-=(const Vector<Size, Type>& 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 <std::uint32_t Size,typename Type>
|
||||
template <uint32 Size,typename Type>
|
||||
Vector<Size,Type> operator-(const Vector<Size,Type>& lhs, const Vector<Size,Type>& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
@ -260,10 +260,10 @@ namespace PolyVox
|
||||
\param rhs the number the Vector is multiplied by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::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 <std::uint32_t Size,typename Type>
|
||||
template <uint32 Size,typename Type>
|
||||
Vector<Size,Type> operator*(const Vector<Size,Type>& lhs, const Type& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> result = lhs;
|
||||
@ -289,10 +289,10 @@ namespace PolyVox
|
||||
\param rhs the number the Vector is divided by.
|
||||
\return The resulting Vector.
|
||||
*/
|
||||
template <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline Vector<Size, Type>& Vector<Size, Type>::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 <std::uint32_t Size,typename Type>
|
||||
template <uint32 Size,typename Type>
|
||||
Vector<Size,Type> operator/(const Vector<Size,Type>& lhs, const Type& rhs) throw()
|
||||
{
|
||||
Vector<Size,Type> 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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
std::ostream& operator<<(std::ostream& os, const Vector<Size, Type>& 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 <std::uint32_t Size, typename Type>
|
||||
inline Type Vector<Size, Type>::getElement(std::uint32_t index) const throw()
|
||||
template <uint32 Size, typename Type>
|
||||
inline Type Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline Type Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline Type Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline Type Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline Type Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
inline void Vector<Size, Type>::setElement(std::uint32_t index, Type tValue) throw()
|
||||
template <uint32 Size, typename Type>
|
||||
inline void Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline void Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline void Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline void Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline void Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline double Vector<Size, Type>::length(void) const throw()
|
||||
{
|
||||
return sqrt(lengthSquared());
|
||||
@ -447,11 +447,11 @@ namespace PolyVox
|
||||
/**
|
||||
\return Squared length of the Vector.
|
||||
*/
|
||||
template <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline double Vector<Size, Type>::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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline double Vector<Size, Type>::angleTo(const Vector<Size, Type>& 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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline Vector<Size, Type> Vector<Size, Type>::cross(const Vector<Size, Type>& 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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline Type Vector<Size, Type>::dot(const Vector<Size, Type>& rhs) const throw()
|
||||
{
|
||||
Type dotProduct = static_cast<Type>(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 <std::uint32_t Size, typename Type>
|
||||
template <uint32 Size, typename Type>
|
||||
inline void Vector<Size, Type>::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<Type>(length);
|
||||
}
|
||||
|
@ -44,26 +44,26 @@ namespace PolyVox
|
||||
//Getters
|
||||
void getChangedRegions(std::list<Region>& listToFill) const;
|
||||
Region getEnclosingRegion(void) const;
|
||||
std::uint16_t getSideLength(void);
|
||||
BlockVolume<std::uint8_t>* 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<uint8>* 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<std::uint8_t>* 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<uint8>* 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<std::uint8_t>* volumeData;
|
||||
BlockVolume<uint8>* volumeData;
|
||||
LinearVolume<bool>* volRegionUpToDate;
|
||||
};
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
float computeSmoothedVoxel(BlockVolumeIterator<std::uint8_t>& volIter);
|
||||
float computeSmoothedVoxel(BlockVolumeIterator<uint8>& volIter);
|
||||
}
|
||||
|
||||
#endif
|
@ -9,7 +9,7 @@ using namespace std;
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
POLYVOX_API void computeNormalsForVertices(BlockVolume<std::uint8_t>* volumeData, RegionGeometry& regGeom, NormalGenerationMethod normalGenerationMethod)
|
||||
POLYVOX_API void computeNormalsForVertices(BlockVolume<uint8>* volumeData, RegionGeometry& regGeom, NormalGenerationMethod normalGenerationMethod)
|
||||
{
|
||||
std::vector<SurfaceVertex>& vecVertices = regGeom.m_patchSingleMaterial->m_vecVertices;
|
||||
std::vector<SurfaceVertex>::iterator iterSurfaceVertex = vecVertices.begin();
|
||||
@ -18,7 +18,7 @@ namespace PolyVox
|
||||
const Vector3DFloat& v3dPos = iterSurfaceVertex->getPosition() + static_cast<Vector3DFloat>(regGeom.m_v3dRegionPosition);
|
||||
const Vector3DInt32 v3dFloor = static_cast<Vector3DInt32>(v3dPos);
|
||||
|
||||
BlockVolumeIterator<std::uint8_t> volIter(*volumeData);
|
||||
BlockVolumeIterator<uint8> 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<uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod)
|
||||
Vector3DFloat computeNormal(BlockVolume<uint8>* 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<uint16_t>(posX);
|
||||
const uint16_t floorY = static_cast<uint16_t>(posY);
|
||||
const uint16_t floorZ = static_cast<uint16_t>(posZ);
|
||||
const uint16 floorX = static_cast<uint16>(posX);
|
||||
const uint16 floorY = static_cast<uint16>(posY);
|
||||
const uint16 floorZ = static_cast<uint16>(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<std::uint8_t> volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create?
|
||||
BlockVolumeIterator<uint8> volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create?
|
||||
|
||||
|
||||
if(normalGenerationMethod == SOBEL)
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ));
|
||||
const Vector3DFloat gradFloor = computeSobelGradient(volIter);
|
||||
if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX+1.0),static_cast<uint16>(posY),static_cast<uint16>(posZ));
|
||||
}
|
||||
if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY+1.0),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY+1.0),static_cast<uint16>(posZ));
|
||||
}
|
||||
if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(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<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ));
|
||||
const Vector3DFloat gradFloor = computeCentralDifferenceGradient(volIter);
|
||||
if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX+1.0),static_cast<uint16>(posY),static_cast<uint16>(posZ));
|
||||
}
|
||||
if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY+1.0),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY+1.0),static_cast<uint16>(posZ));
|
||||
}
|
||||
if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(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<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||
const uint8_t uFloor = volIter.getVoxel() > 0 ? 1 : 0;
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(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<float>(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<float>(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<float>(uFloor - uCeil));
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ namespace PolyVox
|
||||
m_vecTriangleIndices.push_back(m_vecVertices.size()-1);
|
||||
}
|
||||
|
||||
void IndexedSurfacePatch::fillVertexAndIndexData(std::vector<SurfaceVertex>& vecVertices, std::vector<uint32_t>& vecIndices)
|
||||
void IndexedSurfacePatch::fillVertexAndIndexData(std::vector<SurfaceVertex>& vecVertices, std::vector<uint32>& 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<std::uint32_t>& IndexedSurfacePatch::getIndices(void) const
|
||||
const std::vector<uint32>& IndexedSurfacePatch::getIndices(void) const
|
||||
{
|
||||
return m_vecTriangleIndices;
|
||||
}
|
||||
|
@ -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)
|
||||
|
@ -13,12 +13,12 @@ using namespace std;
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
void smoothRegionGeometry(BlockVolume<std::uint8_t>* volumeData, RegionGeometry& regGeom)
|
||||
void smoothRegionGeometry(BlockVolume<uint8>* volumeData, RegionGeometry& regGeom)
|
||||
{
|
||||
const std::uint8_t uSmoothingFactor = 2;
|
||||
const uint8 uSmoothingFactor = 2;
|
||||
const float fThreshold = 0.5f;
|
||||
|
||||
BlockVolumeIterator<std::uint8_t> volIter(*volumeData);
|
||||
BlockVolumeIterator<uint8> volIter(*volumeData);
|
||||
|
||||
std::vector<SurfaceVertex>& vecVertices = regGeom.m_patchSingleMaterial->m_vecVertices;
|
||||
std::vector<SurfaceVertex>::iterator iterSurfaceVertex = vecVertices.begin();
|
||||
@ -77,9 +77,9 @@ namespace PolyVox
|
||||
} //while(iterSurfaceVertex != vecVertices.end())
|
||||
}
|
||||
|
||||
void adjustDecimatedGeometry(BlockVolume<std::uint8_t>* volumeData, RegionGeometry& regGeom, uint8_t val)
|
||||
void adjustDecimatedGeometry(BlockVolume<uint8>* volumeData, RegionGeometry& regGeom, uint8 val)
|
||||
{
|
||||
BlockVolumeIterator<std::uint8_t> volIter(*volumeData);
|
||||
BlockVolumeIterator<uint8> volIter(*volumeData);
|
||||
|
||||
std::vector<SurfaceVertex>& vecVertices = regGeom.m_patchSingleMaterial->m_vecVertices;
|
||||
std::vector<SurfaceVertex>::iterator iterSurfaceVertex = vecVertices.begin();
|
||||
@ -88,7 +88,7 @@ namespace PolyVox
|
||||
Vector3DFloat v3dPos = iterSurfaceVertex->getPosition() + static_cast<Vector3DFloat>(regGeom.m_v3dRegionPosition);
|
||||
Vector3DInt32 v3dFloor = static_cast<Vector3DInt32>(v3dPos);
|
||||
|
||||
BlockVolumeIterator<std::uint8_t> volIter(*volumeData);
|
||||
BlockVolumeIterator<uint8> 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<Vector3DInt16>(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<Vector3DInt16>(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<Vector3DInt32>(v3dPos);
|
||||
|
||||
volIter.setPosition(static_cast<Vector3DInt16>(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<Vector3DInt16>(v3dFloor+Vector3DInt32(1,0,0)));
|
||||
|
@ -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<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
void generateRoughMeshDataForRegion(BlockVolume<uint8>* 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<std::uint8_t> volIter(*volumeData);
|
||||
BlockVolumeIterator<uint8> 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<uint8_t>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask)
|
||||
uint32 computeInitialRoughBitmaskForSlice(BlockVolumeIterator<uint8>& 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<uint8_t>& volIter, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, uint8_t* previousBitmask)
|
||||
uint32 computeRoughBitmaskForSliceFromPrevious(BlockVolumeIterator<uint8>& 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<uint8_t>& 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<uint8>& 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<uint8_t>& 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<uint8>& 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<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
void generateReferenceMeshDataForRegion(BlockVolume<uint8>* 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<std::uint8_t> volIter(*volumeData);
|
||||
uint8 vertMaterials[12];
|
||||
BlockVolumeIterator<uint8> 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<Vector3DFloat>(vertex1) / 2.0f) - offset;
|
||||
//const Vector3DFloat vertex2AsFloat = (static_cast<Vector3DFloat>(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<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)];
|
||||
return vertexIndicesX[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(zIntPart)];
|
||||
}
|
||||
if(yFracPart > 0.000001f)
|
||||
{
|
||||
return vertexIndicesY[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)];
|
||||
return vertexIndicesY[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(zIntPart)];
|
||||
}
|
||||
if(zFracPart > 0.000001f)
|
||||
{
|
||||
return vertexIndicesZ[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)];
|
||||
return vertexIndicesZ[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(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<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)] = newIndex;
|
||||
vertexIndicesX[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(zIntPart)] = newIndex;
|
||||
}
|
||||
if(yFracPart > 0.000001f)
|
||||
{
|
||||
vertexIndicesY[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)] = newIndex;
|
||||
vertexIndicesY[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(zIntPart)] = newIndex;
|
||||
}
|
||||
if(zFracPart > 0.000001f)
|
||||
{
|
||||
vertexIndicesZ[static_cast<uint16_t>(xIntPart)][static_cast<uint16_t>(yIntPart)][static_cast<uint16_t>(zIntPart)] = newIndex;
|
||||
vertexIndicesZ[static_cast<uint16>(xIntPart)][static_cast<uint16>(yIntPart)][static_cast<uint16>(zIntPart)] = newIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<uint8_t>* volumeData, uint8_t uLevel, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
void generateDecimatedMeshDataForRegion(BlockVolume<uint8>* 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<std::uint8_t> volIter(*volumeData);
|
||||
BlockVolumeIterator<uint8> 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<uint8_t>& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask)
|
||||
uint32 computeInitialDecimatedBitmaskForSlice(BlockVolumeIterator<uint8>& 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<uint8_t>& volIter, uint8_t uLevel, const Region& regSlice, const Vector3DFloat& offset, uint8_t* bitmask, uint8_t* previousBitmask)
|
||||
uint32 computeDecimatedBitmaskForSliceFromPrevious(BlockVolumeIterator<uint8>& 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<uint8_t>& 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<uint8>& 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<uint8_t>& 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<uint8>& 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<uint8_t>* volumeData, Region region, IndexedSurfacePatch* singleMaterialPatch)
|
||||
void generateDecimatedMeshDataForRegionSlow(BlockVolume<uint8>* 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<std::uint8_t> volIter(*volumeData);
|
||||
uint8 vertMaterials[12];
|
||||
BlockVolumeIterator<uint8> 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<Vector3DFloat>(vertex1) / 2.0f) - offset;
|
||||
//const Vector3DFloat vertex2AsFloat = (static_cast<Vector3DFloat>(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<uint8_t, IndexedSurfacePatch*>::iterator iterPatch = surfacePatchMapResult.begin(); iterPatch != surfacePatchMapResult.end(); ++iterPatch)
|
||||
//for(std::map<uint8, IndexedSurfacePatch*>::iterator iterPatch = surfacePatchMapResult.begin(); iterPatch != surfacePatchMapResult.end(); ++iterPatch)
|
||||
{
|
||||
|
||||
/*std::vector<SurfaceVertex>::iterator iterSurfaceVertex = singleMaterialPatch->getVertices().begin();
|
||||
@ -797,15 +797,15 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
Vector3DFloat computeDecimatedNormal(BlockVolume<uint8_t>* volumeData, const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod)
|
||||
Vector3DFloat computeDecimatedNormal(BlockVolume<uint8>* 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<uint16_t>(posX);
|
||||
const uint16_t floorY = static_cast<uint16_t>(posY);
|
||||
const uint16_t floorZ = static_cast<uint16_t>(posZ);
|
||||
const uint16 floorX = static_cast<uint16>(posX);
|
||||
const uint16 floorY = static_cast<uint16>(posY);
|
||||
const uint16 floorZ = static_cast<uint16>(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<std::uint8_t> volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create?
|
||||
BlockVolumeIterator<uint8> volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create?
|
||||
|
||||
|
||||
if(normalGenerationMethod == SOBEL)
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ));
|
||||
const Vector3DFloat gradFloor = computeSobelGradient(volIter);
|
||||
if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX+1.0),static_cast<uint16>(posY),static_cast<uint16>(posZ));
|
||||
}
|
||||
if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY+1.0),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY+1.0),static_cast<uint16>(posZ));
|
||||
}
|
||||
if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(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<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(posZ));
|
||||
const Vector3DFloat gradFloor = computeCentralDifferenceGradient(volIter);
|
||||
if((posX - floorX) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX+1.0),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX+1.0),static_cast<uint16>(posY),static_cast<uint16>(posZ));
|
||||
}
|
||||
if((posY - floorY) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY+1.0),static_cast<uint16_t>(posZ));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY+1.0),static_cast<uint16>(posZ));
|
||||
}
|
||||
if((posZ - floorZ) > 0.25) //The result should be 0.0 or 0.5
|
||||
{
|
||||
volIter.setPosition(static_cast<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ+1.0));
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(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<uint16_t>(posX),static_cast<uint16_t>(posY),static_cast<uint16_t>(posZ));
|
||||
const uint8_t uFloor = volIter.getVoxel() > 0 ? 1 : 0;
|
||||
volIter.setPosition(static_cast<uint16>(posX),static_cast<uint16>(posY),static_cast<uint16>(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<float>(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<float>(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<float>(uFloor - uCeil));
|
||||
}
|
||||
}
|
||||
|
@ -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<std::uint8_t>(uResult-1);
|
||||
return static_cast<uint8>(uResult-1);
|
||||
}
|
||||
|
||||
|
||||
bool isPowerOf2(std::uint32_t uInput)
|
||||
bool isPowerOf2(uint32 uInput)
|
||||
{
|
||||
if(uInput == 0)
|
||||
return false;
|
||||
|
@ -50,7 +50,7 @@ namespace PolyVox
|
||||
{
|
||||
}
|
||||
|
||||
void VolumeChangeTracker::setVolumeData(BlockVolume<std::uint8_t>* volumeDataToSet)
|
||||
void VolumeChangeTracker::setVolumeData(BlockVolume<uint8>* volumeDataToSet)
|
||||
{
|
||||
volumeData = volumeDataToSet;
|
||||
volRegionUpToDate = new LinearVolume<bool>(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<std::uint8_t> volIter(*volumeData);
|
||||
BlockVolumeIterator<uint8> volIter(*volumeData);
|
||||
volIter.setPosition(uX,uY,uZ);
|
||||
return volIter.getVoxel();
|
||||
}
|
||||
|
||||
BlockVolume<std::uint8_t>* VolumeChangeTracker::getVolumeData(void) const
|
||||
BlockVolume<uint8>* 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<std::uint8_t> iterVol(*volumeData);
|
||||
BlockVolumeIterator<uint8> 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<std::uint8_t> iterVol(*volumeData);
|
||||
BlockVolumeIterator<uint8> 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);
|
||||
}
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
float computeSmoothedVoxel(BlockVolumeIterator<std::uint8_t>& volIter)
|
||||
float computeSmoothedVoxel(BlockVolumeIterator<uint8>& volIter)
|
||||
{
|
||||
assert(volIter.getPosX() >= 1);
|
||||
assert(volIter.getPosY() >= 1);
|
||||
|
1
TODO.txt
1
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?
|
||||
|
@ -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<uint8_t> g_volData(logBase2(g_uVolumeSideLength));
|
||||
BlockVolume<uint8> 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<uint8_t> volIter(g_volData);
|
||||
BlockVolumeIterator<uint8> 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<uint8_t>(fDistToCenter));
|
||||
volIter.setVoxel(static_cast<uint8>(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<SurfaceVertex>& vecVertices = g_ispRegionSurfaces[uRegionX][uRegionY][uRegionZ]->getVertices();
|
||||
const vector<uint32_t>& vecIndices = g_ispRegionSurfaces[uRegionX][uRegionY][uRegionZ]->getIndices();
|
||||
for(vector<uint32_t>::const_iterator iterIndex = vecIndices.begin(); iterIndex != vecIndices.end(); ++iterIndex)
|
||||
const vector<uint32>& vecIndices = g_ispRegionSurfaces[uRegionX][uRegionY][uRegionZ]->getIndices();
|
||||
for(vector<uint32>::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];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user