Work on removing obscure constants.
This commit is contained in:
parent
1b592cd1fd
commit
1fa967fb9b
@ -36,7 +36,7 @@ namespace PolyVox
|
|||||||
|
|
||||||
//Volume interface
|
//Volume interface
|
||||||
public:
|
public:
|
||||||
Volume();
|
Volume(boost::uint8_t uSideLengthPower, boost::uint8_t uBlockSideLengthPower);
|
||||||
~Volume();
|
~Volume();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -51,7 +51,11 @@ namespace PolyVox
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Block<VoxelType>* getBlock(boost::uint16_t index);
|
Block<VoxelType>* getBlock(boost::uint16_t index);
|
||||||
Block<VoxelType>* mBlocks[POLYVOX_NO_OF_BLOCKS_IN_VOLUME];
|
Block<VoxelType>** mBlocks;
|
||||||
|
boost::uint32_t m_uNoOfBlocksInVolume;
|
||||||
|
|
||||||
|
boost::uint16_t m_uSideLengthPower;
|
||||||
|
boost::uint16_t m_uSideLength;
|
||||||
};
|
};
|
||||||
|
|
||||||
//Some handy typedefs
|
//Some handy typedefs
|
||||||
|
@ -28,11 +28,28 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
|
|
||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
Volume<VoxelType>::Volume()
|
Volume<VoxelType>::Volume(boost::uint8_t uSideLengthPower, boost::uint8_t uBlockSideLengthPower)
|
||||||
{
|
{
|
||||||
for(boost::uint16_t i = 0; i < POLYVOX_NO_OF_BLOCKS_IN_VOLUME; ++i)
|
//Check the volume size is sensible. This corresponds to a side length of 65536 voxels
|
||||||
|
assert(uSideLengthPower <= 16);
|
||||||
|
|
||||||
|
//Compute the volume side length
|
||||||
|
m_uSideLengthPower = uSideLengthPower;
|
||||||
|
m_uSideLength = 0x01 << uSideLengthPower;
|
||||||
|
|
||||||
|
//Compute the block side length
|
||||||
|
boost::uint16_t uBlockSideLength = 0x01 << uBlockSideLengthPower;
|
||||||
|
|
||||||
|
//Compute the side length in blocks
|
||||||
|
boost::uint16_t uSideLengthInBlocks = m_uSideLength / uBlockSideLength;
|
||||||
|
|
||||||
|
//Compute number of blocks in the volume
|
||||||
|
m_uNoOfBlocksInVolume = uSideLengthInBlocks * uSideLengthInBlocks * uSideLengthInBlocks;
|
||||||
|
|
||||||
|
mBlocks = new Block<VoxelType>*[m_uNoOfBlocksInVolume];
|
||||||
|
for(boost::uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i)
|
||||||
{
|
{
|
||||||
mBlocks[i] = new Block<VoxelType>(POLYVOX_BLOCK_SIDE_LENGTH_POWER);
|
mBlocks[i] = new Block<VoxelType>(uBlockSideLengthPower);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +63,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
Volume<VoxelType>::~Volume()
|
Volume<VoxelType>::~Volume()
|
||||||
{
|
{
|
||||||
for(boost::uint16_t i = 0; i < POLYVOX_NO_OF_BLOCKS_IN_VOLUME; ++i)
|
for(boost::uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i)
|
||||||
{
|
{
|
||||||
delete mBlocks[i];
|
delete mBlocks[i];
|
||||||
}
|
}
|
||||||
@ -67,7 +84,7 @@ namespace PolyVox
|
|||||||
mBlocks[i] = SharedPtr<Block>(new Block);
|
mBlocks[i] = SharedPtr<Block>(new Block);
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
for(uint16_t i = 0; i < POLYVOX_NO_OF_BLOCKS_IN_VOLUME; ++i)
|
for(uint32_t 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
|
//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.
|
//than 1 as there will be the pointer in the volume and the pointer in the static homogeneous array.
|
||||||
@ -94,9 +111,9 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
bool Volume<VoxelType>::containsPoint(Vector3DFloat pos, float boundary)
|
bool Volume<VoxelType>::containsPoint(Vector3DFloat pos, float boundary)
|
||||||
{
|
{
|
||||||
return (pos.x() < POLYVOX_VOLUME_SIDE_LENGTH - 1 - boundary)
|
return (pos.x() < m_uSideLength - 1 - boundary)
|
||||||
&& (pos.y() < POLYVOX_VOLUME_SIDE_LENGTH - 1 - boundary)
|
&& (pos.y() < m_uSideLength - 1 - boundary)
|
||||||
&& (pos.z() < POLYVOX_VOLUME_SIDE_LENGTH - 1 - boundary)
|
&& (pos.z() < m_uSideLength - 1 - boundary)
|
||||||
&& (pos.x() > boundary)
|
&& (pos.x() > boundary)
|
||||||
&& (pos.y() > boundary)
|
&& (pos.y() > boundary)
|
||||||
&& (pos.z() > boundary);
|
&& (pos.z() > boundary);
|
||||||
@ -105,9 +122,9 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
bool Volume<VoxelType>::containsPoint(Vector3DInt32 pos, boost::uint16_t boundary)
|
bool Volume<VoxelType>::containsPoint(Vector3DInt32 pos, boost::uint16_t boundary)
|
||||||
{
|
{
|
||||||
return (pos.x() < POLYVOX_VOLUME_SIDE_LENGTH - 1 - boundary)
|
return (pos.x() < m_uSideLength - 1 - boundary)
|
||||||
&& (pos.y() < POLYVOX_VOLUME_SIDE_LENGTH - 1 - boundary)
|
&& (pos.y() < m_uSideLength - 1 - boundary)
|
||||||
&& (pos.z() < POLYVOX_VOLUME_SIDE_LENGTH - 1 - boundary)
|
&& (pos.z() < m_uSideLength - 1 - boundary)
|
||||||
&& (pos.x() > boundary)
|
&& (pos.x() > boundary)
|
||||||
&& (pos.y() > boundary)
|
&& (pos.y() > boundary)
|
||||||
&& (pos.z() > boundary);
|
&& (pos.z() > boundary);
|
||||||
|
@ -152,7 +152,7 @@ namespace PolyVox
|
|||||||
void PolyVoxSceneManager::generateLevelVolume(void)
|
void PolyVoxSceneManager::generateLevelVolume(void)
|
||||||
{
|
{
|
||||||
//volumeData = VolumePtr(new Volume);
|
//volumeData = VolumePtr(new Volume);
|
||||||
volumeData = new Volume<boost::uint8_t>();
|
volumeData = new Volume<boost::uint8_t>(POLYVOX_VOLUME_SIDE_LENGTH_POWER, POLYVOX_BLOCK_SIDE_LENGTH_POWER);
|
||||||
VolumeIterator<boost::uint8_t> volIter(*volumeData);
|
VolumeIterator<boost::uint8_t> volIter(*volumeData);
|
||||||
for(uint16_t z = 0; z < POLYVOX_VOLUME_SIDE_LENGTH; ++z)
|
for(uint16_t z = 0; z < POLYVOX_VOLUME_SIDE_LENGTH; ++z)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user