Got mesh smoothing working.
Cleaning up code. Various changes made without internet access.
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -23,9 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#define __PolyVox_Block_H__
|
||||
|
||||
#pragma region Headers
|
||||
#include "Constants.h"
|
||||
#include "PolyVoxForwardDeclarations.h"
|
||||
#include "TypeDef.h"
|
||||
|
||||
#include "boost/cstdint.hpp"
|
||||
#pragma endregion
|
||||
@ -37,8 +35,6 @@ namespace PolyVox
|
||||
{
|
||||
//Make VolumeIterator a friend
|
||||
friend class VolumeIterator<VoxelType>;
|
||||
|
||||
//Block interface
|
||||
public:
|
||||
Block(boost::uint8_t uSideLengthPower);
|
||||
Block(const Block& rhs);
|
||||
@ -46,17 +42,12 @@ namespace PolyVox
|
||||
|
||||
Block& operator=(const Block& rhs);
|
||||
|
||||
//bool isHomogeneous(void);
|
||||
boost::uint16_t getSideLength(void) const;
|
||||
VoxelType getVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos) const;
|
||||
|
||||
boost::uint16_t getSideLength(void);
|
||||
|
||||
VoxelType getVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition) const;
|
||||
void setVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition, const VoxelType value);
|
||||
|
||||
//void fillWithValue(const VoxelType value);
|
||||
void setVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos, VoxelType tValue);
|
||||
|
||||
private:
|
||||
boost::uint32_t getNoOfVoxels(void);
|
||||
boost::uint8_t m_uSideLengthPower;
|
||||
boost::uint16_t m_uSideLength;
|
||||
VoxelType* m_tData;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -16,18 +17,25 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <cstring>
|
||||
#pragma region Headers
|
||||
#include <cassert>
|
||||
#include <cstring> //For memcpy
|
||||
#pragma endregion
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
|
||||
#pragma region Constructors/Destructors
|
||||
template <typename VoxelType>
|
||||
Block<VoxelType>::Block(boost::uint8_t uSideLengthPower)
|
||||
:m_tData(0)
|
||||
{
|
||||
//Check the block size is sensible. This corresponds to a side length of 256 voxels
|
||||
assert(uSideLengthPower <= 8);
|
||||
if(uSideLengthPower > 8)
|
||||
{
|
||||
throw std::invalid_argument("Block side length must be less than or equal to eight");
|
||||
}
|
||||
|
||||
//Compute the side length
|
||||
m_uSideLengthPower = uSideLengthPower;
|
||||
@ -35,7 +43,7 @@ namespace PolyVox
|
||||
|
||||
//If this fails an exception will be thrown. Memory is not
|
||||
//allocated and there is nothing else in this class to clean up
|
||||
m_tData = new VoxelType[getNoOfVoxels()];
|
||||
m_tData = new VoxelType[m_uSideLength * m_uSideLength * m_uSideLength];
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -50,7 +58,9 @@ namespace PolyVox
|
||||
delete[] m_tData;
|
||||
m_tData = 0;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Operators
|
||||
template <typename VoxelType>
|
||||
Block<VoxelType>& Block<VoxelType>::operator=(const Block<VoxelType>& rhs)
|
||||
{
|
||||
@ -58,43 +68,48 @@ namespace PolyVox
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
memcpy(m_tData,rhs.m_tData,getNoOfVoxels());
|
||||
|
||||
memcpy(m_tData, rhs.m_tData, m_uSideLength * m_uSideLength * m_uSideLength);
|
||||
return *this;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Getters
|
||||
template <typename VoxelType>
|
||||
VoxelType Block<VoxelType>::getVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition) const
|
||||
{
|
||||
return m_tData
|
||||
[
|
||||
xPosition +
|
||||
yPosition * m_uSideLength +
|
||||
zPosition * m_uSideLength * m_uSideLength
|
||||
];
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
void Block<VoxelType>::setVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition, const VoxelType value)
|
||||
{
|
||||
m_tData
|
||||
[
|
||||
xPosition +
|
||||
yPosition * m_uSideLength +
|
||||
zPosition * m_uSideLength * m_uSideLength
|
||||
] = value;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
boost::uint16_t Block<VoxelType>::getSideLength(void)
|
||||
boost::uint16_t Block<VoxelType>::getSideLength(void) const
|
||||
{
|
||||
return m_uSideLength;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
boost::uint32_t Block<VoxelType>::getNoOfVoxels(void)
|
||||
VoxelType Block<VoxelType>::getVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos) const
|
||||
{
|
||||
return m_uSideLength * m_uSideLength * m_uSideLength;
|
||||
assert(uXPos < m_uSideLength);
|
||||
assert(uYPos < m_uSideLength);
|
||||
assert(uZPos < m_uSideLength);
|
||||
|
||||
return m_tData
|
||||
[
|
||||
uXPos +
|
||||
uYPos * m_uSideLength +
|
||||
uZPos * m_uSideLength * m_uSideLength
|
||||
];
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Setters
|
||||
template <typename VoxelType>
|
||||
void Block<VoxelType>::setVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos, VoxelType tValue)
|
||||
{
|
||||
assert(uXPos < m_uSideLength);
|
||||
assert(uYPos < m_uSideLength);
|
||||
assert(uZPos < m_uSideLength);
|
||||
|
||||
m_tData
|
||||
[
|
||||
uXPos +
|
||||
uYPos * m_uSideLength +
|
||||
uZPos * m_uSideLength * m_uSideLength
|
||||
] = tValue;
|
||||
}
|
||||
#pragma endregion
|
||||
}
|
||||
|
@ -1,3 +1,24 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __PolyVox_Constants_H__
|
||||
#define __PolyVox_Constants_H__
|
||||
|
||||
@ -10,15 +31,15 @@ namespace PolyVox
|
||||
//const boost::uint32_t POLYVOX_BLOCK_SIDE_LENGTH = (0x0001 << POLYVOX_BLOCK_SIDE_LENGTH_POWER);
|
||||
//const boost::uint32_t POLYVOX_NO_OF_VOXELS_IN_BLOCK = (POLYVOX_BLOCK_SIDE_LENGTH * POLYVOX_BLOCK_SIDE_LENGTH * POLYVOX_BLOCK_SIDE_LENGTH);
|
||||
|
||||
const boost::uint32_t POLYVOX_VOLUME_SIDE_LENGTH_POWER = 8;
|
||||
const boost::uint32_t POLYVOX_VOLUME_SIDE_LENGTH = (0x0001 << POLYVOX_VOLUME_SIDE_LENGTH_POWER);
|
||||
const boost::uint16_t POLYVOX_VOLUME_SIDE_LENGTH_POWER = 8;
|
||||
const boost::uint16_t POLYVOX_VOLUME_SIDE_LENGTH = (0x0001 << POLYVOX_VOLUME_SIDE_LENGTH_POWER);
|
||||
//const boost::uint32_t POLYVOX_VOLUME_SIDE_LENGTH_IN_BLOCKS = (POLYVOX_VOLUME_SIDE_LENGTH >> POLYVOX_BLOCK_SIDE_LENGTH_POWER);
|
||||
//const boost::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 boost::uint32_t POLYVOX_NO_OF_VOXELS_IN_VOLUME = (POLYVOX_VOLUME_SIDE_LENGTH * POLYVOX_VOLUME_SIDE_LENGTH * POLYVOX_VOLUME_SIDE_LENGTH);
|
||||
|
||||
const boost::uint32_t POLYVOX_REGION_SIDE_LENGTH_POWER = 4;
|
||||
const boost::uint32_t POLYVOX_REGION_SIDE_LENGTH = (0x0001 << POLYVOX_REGION_SIDE_LENGTH_POWER);
|
||||
const boost::uint32_t POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS = (POLYVOX_VOLUME_SIDE_LENGTH >> POLYVOX_REGION_SIDE_LENGTH_POWER);
|
||||
const boost::uint16_t POLYVOX_REGION_SIDE_LENGTH_POWER = 4;
|
||||
const boost::uint16_t POLYVOX_REGION_SIDE_LENGTH = (0x0001 << POLYVOX_REGION_SIDE_LENGTH_POWER);
|
||||
const boost::uint16_t POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS = (POLYVOX_VOLUME_SIDE_LENGTH >> POLYVOX_REGION_SIDE_LENGTH_POWER);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,3 +1,24 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __PolyVox_GradientEstimators_H__
|
||||
#define __PolyVox_GradientEstimators_H__
|
||||
|
||||
@ -9,6 +30,9 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeCentralDifferenceGradient(const VolumeIterator<VoxelType>& volIter);
|
||||
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeSmoothCentralDifferenceGradient(VolumeIterator<VoxelType>& volIter);
|
||||
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeSobelGradient(const VolumeIterator<VoxelType>& volIter);
|
||||
}
|
||||
|
@ -1,3 +1,24 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
@ -21,6 +42,37 @@ namespace PolyVox
|
||||
);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeSmoothCentralDifferenceGradient(VolumeIterator<VoxelType>& volIter)
|
||||
{
|
||||
boost::uint16_t initialX = volIter.getPosX();
|
||||
boost::uint16_t initialY = volIter.getPosY();
|
||||
boost::uint16_t initialZ = volIter.getPosZ();
|
||||
|
||||
//FIXME - bitwise way of doing this?
|
||||
volIter.setPosition(initialX-1, initialY, initialZ);
|
||||
float voxel1nx = volIter.getAveragedVoxel(1);
|
||||
volIter.setPosition(initialX+1, initialY, initialZ);
|
||||
float voxel1px = volIter.getAveragedVoxel(1);
|
||||
|
||||
volIter.setPosition(initialX, initialY-1, initialZ);
|
||||
float voxel1ny = volIter.getAveragedVoxel(1);
|
||||
volIter.setPosition(initialX, initialY+1, initialZ);
|
||||
float voxel1py = volIter.getAveragedVoxel(1);
|
||||
|
||||
volIter.setPosition(initialX, initialY, initialZ-1);
|
||||
float voxel1nz = volIter.getAveragedVoxel(1);
|
||||
volIter.setPosition(initialX, initialY, initialZ+1);
|
||||
float voxel1pz = volIter.getAveragedVoxel(1);
|
||||
|
||||
return Vector3DFloat
|
||||
(
|
||||
voxel1px - voxel1nx,
|
||||
voxel1py - voxel1ny,
|
||||
voxel1pz - voxel1nz
|
||||
);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
Vector3DFloat computeSobelGradient(const VolumeIterator<VoxelType>& volIter)
|
||||
{
|
||||
|
@ -1,3 +1,24 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __PolyVox_IndexedSurfacePatch_H__
|
||||
#define __PolyVox_IndexedSurfacePatch_H__
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -16,6 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <cstring>
|
||||
|
||||
|
@ -1,3 +1,24 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __PolyVox_MarchingCubeTables_H__
|
||||
#define __PolyVox_MarchingCubeTables_H__
|
||||
|
||||
|
@ -1,3 +1,24 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __PolyVox_ForwardDeclarations_H__
|
||||
#define __PolyVox_ForwardDeclarations_H__
|
||||
|
||||
@ -13,12 +34,12 @@ namespace PolyVox
|
||||
class RegionGeometry;
|
||||
class SurfaceVertex;
|
||||
template <boost::uint32_t Size, typename Type> class Vector;
|
||||
typedef Vector<2,float> Vector2DFloat;
|
||||
typedef Vector<2,double> Vector2DDouble;
|
||||
typedef Vector<2,boost::int32_t> Vector2DInt32;
|
||||
typedef Vector<2,boost::uint32_t> Vector2DUint32;
|
||||
typedef Vector<3,float> Vector3DFloat;
|
||||
typedef Vector<3,double> Vector3DDouble;
|
||||
typedef Vector<3,boost::int8_t> Vector3DInt8;
|
||||
typedef Vector<3,boost::uint8_t> Vector3DUint8;
|
||||
typedef Vector<3,boost::int16_t> Vector3DInt16;
|
||||
typedef Vector<3,boost::uint16_t> Vector3DUint16;
|
||||
typedef Vector<3,boost::int32_t> Vector3DInt32;
|
||||
typedef Vector<3,boost::uint32_t> Vector3DUint32;
|
||||
template <typename VoxelType> class Volume;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -16,6 +17,8 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __PolyVox_PolyVoxSceneManager_H__
|
||||
#define __PolyVox_PolyVoxSceneManager_H__
|
||||
|
||||
@ -49,6 +52,8 @@ namespace PolyVox
|
||||
const std::string& getTypeName(void) const;
|
||||
boost::uint16_t getSideLength(void);
|
||||
|
||||
const Volume<boost::uint8_t>* getVolumeData(void) const;
|
||||
|
||||
|
||||
//Setters
|
||||
void setVolumeData(Volume<boost::uint8_t>* volumeDataToSet);
|
||||
@ -62,15 +67,17 @@ namespace PolyVox
|
||||
|
||||
//void generateLevelVolume(void);
|
||||
|
||||
void generateMeshDataForRegion(boost::uint16_t regionX, boost::uint16_t regionY, boost::uint16_t regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch) const;
|
||||
void generateRoughMeshDataForRegion(boost::uint16_t regionX, boost::uint16_t regionY, boost::uint16_t regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch) const;
|
||||
void generateSmoothMeshDataForRegion(boost::uint16_t regionX, boost::uint16_t regionY, boost::uint16_t regionZ, IndexedSurfacePatch* singleMaterialPatch, IndexedSurfacePatch* multiMaterialPatch) const;
|
||||
|
||||
bool containsPoint(Vector3DFloat pos, float boundary);
|
||||
bool containsPoint(Vector3DInt32 pos, boost::uint16_t boundary);
|
||||
//bool containsPoint(Vector3DFloat pos, float boundary);
|
||||
//bool containsPoint(Vector3DInt32 pos, boost::uint16_t boundary);
|
||||
|
||||
|
||||
LinearVolume<bool>* volSurfaceUpToDate;
|
||||
|
||||
Vector3DFloat computeNormal(const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) const;
|
||||
Vector3DFloat computeSmoothNormal(const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) const;
|
||||
|
||||
public:
|
||||
void markVoxelChanged(boost::uint16_t x, boost::uint16_t y, boost::uint16_t z);
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -16,6 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __PolyVox_RegionGeometry_H__
|
||||
#define __PolyVox_RegionGeometry_H__
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -16,6 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __PolyVox_SurfaceVertex_H__
|
||||
#define __PolyVox_SurfaceVertex_H__
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -16,6 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
//Dave, maybe make use of OgrePlatform.h instead?
|
||||
// I think use _OgreExport instead of POLYVOX_API and define OGRE_NONCLIENT_BUILD instead of POLYVOX_EXPORT?
|
||||
|
@ -1,3 +1,24 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __PolyVox_Utility_H__
|
||||
#define __PolyVox_Utility_H__
|
||||
|
||||
|
@ -1,3 +1,24 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __PolyVox_Vector_H__
|
||||
#define __PolyVox_Vector_H__
|
||||
|
||||
@ -103,12 +124,12 @@ namespace PolyVox
|
||||
std::ostream& operator<<(std::ostream& os, const Vector<Size,Type>& vector) throw();
|
||||
|
||||
//Some handy typedefs
|
||||
typedef Vector<2,float> Vector2DFloat;
|
||||
typedef Vector<2,double> Vector2DDouble;
|
||||
typedef Vector<2,boost::int32_t> Vector2DInt32;
|
||||
typedef Vector<2,boost::uint32_t> Vector2DUint32;
|
||||
typedef Vector<3,float> Vector3DFloat;
|
||||
typedef Vector<3,double> Vector3DDouble;
|
||||
typedef Vector<3,boost::int8_t> Vector3DInt8;
|
||||
typedef Vector<3,boost::uint8_t> Vector3DUint8;
|
||||
typedef Vector<3,boost::int16_t> Vector3DInt16;
|
||||
typedef Vector<3,boost::uint16_t> Vector3DUint16;
|
||||
typedef Vector<3,boost::int32_t> Vector3DInt32;
|
||||
typedef Vector<3,boost::uint32_t> Vector3DUint32;
|
||||
|
||||
|
@ -1,3 +1,24 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -16,15 +17,16 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __PolyVox_Volume_H__
|
||||
#define __PolyVox_Volume_H__
|
||||
|
||||
#include "boost/cstdint.hpp"
|
||||
|
||||
#include "Constants.h"
|
||||
#pragma region Headers
|
||||
#include "PolyVoxForwardDeclarations.h"
|
||||
#include "TypeDef.h"
|
||||
#include "Vector.h"
|
||||
|
||||
#include "boost/cstdint.hpp"
|
||||
#pragma endregion
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
@ -34,30 +36,24 @@ namespace PolyVox
|
||||
//Make VolumeIterator a friend
|
||||
friend class VolumeIterator<VoxelType>;
|
||||
|
||||
//Volume interface
|
||||
public:
|
||||
Volume(boost::uint8_t uSideLengthPower, boost::uint8_t uBlockSideLengthPower = 5);
|
||||
~Volume();
|
||||
|
||||
private:
|
||||
Volume(const Volume& rhs);
|
||||
~Volume();
|
||||
|
||||
Volume& operator=(const Volume& rhs);
|
||||
|
||||
public:
|
||||
bool containsPoint(Vector3DFloat pos, float boundary);
|
||||
bool containsPoint(Vector3DInt32 pos, boost::uint16_t boundary);
|
||||
|
||||
boost::uint16_t getSideLength(void);
|
||||
boost::uint8_t getSideLengthPower(void);
|
||||
boost::uint16_t getSideLengthInBlocks(void);
|
||||
VoxelType getVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos) const;
|
||||
VoxelType getVoxelAt(const Vector3DUint16& v3dPos) const;
|
||||
|
||||
boost::uint16_t getBlockSideLength(void);
|
||||
boost::uint16_t getBlockSideLengthPower(void);
|
||||
void setVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos, VoxelType tValue);
|
||||
void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue);
|
||||
|
||||
void tidy(void);
|
||||
bool containsPoint(Vector3DFloat pos, float boundary) const;
|
||||
bool containsPoint(Vector3DInt32 pos, boost::uint16_t boundary) const;
|
||||
|
||||
private:
|
||||
Block<VoxelType>* getBlock(boost::uint16_t index);
|
||||
Block<VoxelType>** mBlocks;
|
||||
boost::uint32_t m_uNoOfBlocksInVolume;
|
||||
boost::uint16_t m_uSideLengthInBlocks;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -16,23 +17,27 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream> //FIXME - remove this...
|
||||
#include <queue>
|
||||
|
||||
#pragma region Headers
|
||||
#include "Block.h"
|
||||
#include "VolumeIterator.h" //Maybe this shouldn't be here?
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring> //For memcpy
|
||||
#pragma endregion
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
|
||||
#pragma region Constructors/Destructors
|
||||
template <typename VoxelType>
|
||||
Volume<VoxelType>::Volume(boost::uint8_t uSideLengthPower, boost::uint8_t uBlockSideLengthPower)
|
||||
:mBlocks(0)
|
||||
{
|
||||
//Check the volume size is sensible. This corresponds to a side length of 65536 voxels
|
||||
assert(uSideLengthPower <= 16);
|
||||
if(uSideLengthPower > 16)
|
||||
{
|
||||
throw std::invalid_argument("Block side length must be less than or equal to 65536");
|
||||
}
|
||||
|
||||
//Compute the volume side length
|
||||
m_uSideLengthPower = uSideLengthPower;
|
||||
@ -63,7 +68,6 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
Volume<VoxelType>::Volume(const Volume<VoxelType>& rhs)
|
||||
{
|
||||
std::cout << "Warning - Copying Volume" << std::endl;
|
||||
*this = rhs;
|
||||
}
|
||||
|
||||
@ -75,11 +79,12 @@ namespace PolyVox
|
||||
delete mBlocks[i];
|
||||
}
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Operators
|
||||
template <typename VoxelType>
|
||||
Volume<VoxelType>& Volume<VoxelType>::operator=(const Volume& rhs)
|
||||
{
|
||||
std::cout << "Warning - Assigning Volume" << std::endl;
|
||||
if (this == &rhs)
|
||||
{
|
||||
return *this;
|
||||
@ -108,57 +113,9 @@ namespace PolyVox
|
||||
|
||||
return *this;
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
template <typename VoxelType>
|
||||
Block<VoxelType>* Volume<VoxelType>::getBlock(boost::uint16_t index)
|
||||
{
|
||||
return mBlocks[index];
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
bool Volume<VoxelType>::containsPoint(Vector3DFloat pos, float boundary)
|
||||
{
|
||||
return (pos.x() < m_uSideLength - 1 - boundary)
|
||||
&& (pos.y() < m_uSideLength - 1 - boundary)
|
||||
&& (pos.z() < m_uSideLength - 1 - boundary)
|
||||
&& (pos.x() > boundary)
|
||||
&& (pos.y() > boundary)
|
||||
&& (pos.z() > boundary);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
bool Volume<VoxelType>::containsPoint(Vector3DInt32 pos, boost::uint16_t boundary)
|
||||
{
|
||||
return (pos.x() < m_uSideLength - 1 - boundary)
|
||||
&& (pos.y() < m_uSideLength - 1 - boundary)
|
||||
&& (pos.z() < m_uSideLength - 1 - boundary)
|
||||
&& (pos.x() > boundary)
|
||||
&& (pos.y() > boundary)
|
||||
&& (pos.z() > boundary);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
void Volume<VoxelType>::tidy(void)
|
||||
{
|
||||
//Check for homogeneous blocks
|
||||
/*for(uint32_t ct = 0; ct < POLYVOX_NO_OF_BLOCKS_IN_VOLUME; ++ct)
|
||||
{
|
||||
if(mBlocks[ct]->isHomogeneous())
|
||||
{
|
||||
//LogManager::getSingleton().logMessage("Got homogeneous block with value " + stringConverter::tostring(mBlocks[ct]->getVoxelAt(0,0,0)));
|
||||
|
||||
const VoxelType homogeneousValue = mBlocks[ct]->getVoxelAt(0,0,0);
|
||||
SharedPtr<Block>& homogeneousBlock = mHomogeneousBlocks[homogeneousValue];
|
||||
if(homogeneousBlock.isNull())
|
||||
{
|
||||
homogeneousBlock = SharedPtr<Block>(new Block);
|
||||
homogeneousBlock->fillWithValue(homogeneousValue);
|
||||
}
|
||||
mBlocks[ct] = homogeneousBlock;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
#pragma region Getters
|
||||
template <typename VoxelType>
|
||||
boost::uint16_t Volume<VoxelType>::getSideLength(void)
|
||||
{
|
||||
@ -166,26 +123,99 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
boost::uint8_t Volume<VoxelType>::getSideLengthPower(void)
|
||||
VoxelType Volume<VoxelType>::getVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos) const
|
||||
{
|
||||
return m_uSideLengthPower;
|
||||
assert(uXPos < mVolume.getSideLength());
|
||||
assert(uYPos < mVolume.getSideLength());
|
||||
assert(uZPos < mVolume.getSideLength());
|
||||
|
||||
const uint16_t blockX = uXPos >> m_uBlockSideLengthPower;
|
||||
const uint16_t blockY = uYPos >> m_uBlockSideLengthPower;
|
||||
const uint16_t blockZ = uZPos >> m_uBlockSideLengthPower;
|
||||
|
||||
const uint16_t xOffset = uXPos - (blockX << m_uBlockSideLengthPower);
|
||||
const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower);
|
||||
const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower);
|
||||
|
||||
const Block<VoxelType>* block = mBlocks
|
||||
[
|
||||
blockX +
|
||||
blockY * m_uSideLengthInBlocks +
|
||||
blockZ * m_uSideLengthInBlocks * m_uSideLengthInBlocks
|
||||
];
|
||||
|
||||
return block->getVoxelAt(xOffset,yOffset,zOffset);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
boost::uint16_t Volume<VoxelType>::getSideLengthInBlocks(void)
|
||||
VoxelType Volume<VoxelType>::getVoxelAt(const Vector3DUint16& v3dPos) const
|
||||
{
|
||||
return m_uSideLengthInBlocks;
|
||||
assert(v3dPos.x() < m_uSideLength);
|
||||
assert(v3dPos.y() < m_uSideLength);
|
||||
assert(v3dPos.z() < m_uSideLength);
|
||||
|
||||
return getVoxelAt(v3dPos.x(), v3dPos.y(), v3dPos.z());
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Setters
|
||||
template <typename VoxelType>
|
||||
void Volume<VoxelType>::setVoxelAt(boost::uint16_t uXPos, boost::uint16_t uYPos, boost::uint16_t uZPos, VoxelType tValue)
|
||||
{
|
||||
assert(uXPos < mVolume.getSideLength());
|
||||
assert(uYPos < mVolume.getSideLength());
|
||||
assert(uZPos < mVolume.getSideLength());
|
||||
|
||||
const uint16_t blockX = uXPos >> m_uBlockSideLengthPower;
|
||||
const uint16_t blockY = uYPos >> m_uBlockSideLengthPower;
|
||||
const uint16_t blockZ = uZPos >> m_uBlockSideLengthPower;
|
||||
|
||||
const uint16_t xOffset = uXPos - (blockX << m_uBlockSideLengthPower);
|
||||
const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower);
|
||||
const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower);
|
||||
|
||||
const Block<VoxelType>* block = mBlocks
|
||||
[
|
||||
blockX +
|
||||
blockY * m_uSideLengthInBlocks +
|
||||
blockZ * m_uSideLengthInBlocks * m_uSideLengthInBlocks
|
||||
];
|
||||
|
||||
return block->setVoxelAt(xOffset,yOffset,zOffset, tValue);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
boost::uint16_t Volume<VoxelType>::getBlockSideLength(void)
|
||||
void Volume<VoxelType>::setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue)
|
||||
{
|
||||
return m_uBlockSideLength;
|
||||
assert(v3dPos.x() < m_uSideLength);
|
||||
assert(v3dPos.y() < m_uSideLength);
|
||||
assert(v3dPos.z() < m_uSideLength);
|
||||
|
||||
setVoxelAt(v3dPos.x(), v3dPos.y(), v3dPos.z(), tValue);
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Other
|
||||
template <typename VoxelType>
|
||||
bool Volume<VoxelType>::containsPoint(Vector3DFloat pos, float boundary) const
|
||||
{
|
||||
return (pos.x() <= m_uSideLength - 1 - boundary)
|
||||
&& (pos.y() <= m_uSideLength - 1 - boundary)
|
||||
&& (pos.z() <= m_uSideLength - 1 - boundary)
|
||||
&& (pos.x() >= boundary)
|
||||
&& (pos.y() >= boundary)
|
||||
&& (pos.z() >= boundary);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
boost::uint16_t Volume<VoxelType>::getBlockSideLengthPower(void)
|
||||
bool Volume<VoxelType>::containsPoint(Vector3DInt32 pos, boost::uint16_t boundary) const
|
||||
{
|
||||
return m_uBlockSideLengthPower;
|
||||
return (pos.x() <= m_uSideLength - 1 - boundary)
|
||||
&& (pos.y() <= m_uSideLength - 1 - boundary)
|
||||
&& (pos.z() <= m_uSideLength - 1 - boundary)
|
||||
&& (pos.x() >= boundary)
|
||||
&& (pos.y() >= boundary)
|
||||
&& (pos.z() >= boundary);
|
||||
}
|
||||
#pragma endregion
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -16,6 +17,8 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#ifndef __VolumeIterator_H__
|
||||
#define __VolumeIterator_H__
|
||||
|
||||
@ -37,7 +40,7 @@ namespace PolyVox
|
||||
void setVoxel(VoxelType value);
|
||||
VoxelType getVoxel(void);
|
||||
|
||||
float getAveragedVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition, boost::uint16_t size) const;
|
||||
float getAveragedVoxel(boost::uint16_t size) const;
|
||||
|
||||
|
||||
|
||||
@ -83,7 +86,7 @@ namespace PolyVox
|
||||
|
||||
private:
|
||||
|
||||
VoxelType getVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition) const;
|
||||
//VoxelType getVoxelAt(const boost::uint16_t xPosition, const boost::uint16_t yPosition, const boost::uint16_t zPosition) const;
|
||||
|
||||
//The current volume
|
||||
Volume<VoxelType>& mVolume;
|
||||
|
@ -1,5 +1,6 @@
|
||||
#pragma region License
|
||||
/******************************************************************************
|
||||
This file is part of a voxel plugin for OGRE
|
||||
This file is part of the PolyVox library
|
||||
Copyright (C) 2006 David Williams
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
@ -16,6 +17,7 @@ You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
******************************************************************************/
|
||||
#pragma endregion
|
||||
|
||||
#include "block.h"
|
||||
#include "Volume.h"
|
||||
@ -36,9 +38,9 @@ namespace PolyVox
|
||||
,mXRegionFirstBlock(0)
|
||||
,mYRegionFirstBlock(0)
|
||||
,mZRegionFirstBlock(0)
|
||||
,mXRegionLastBlock(volume.getSideLengthInBlocks()-1)
|
||||
,mYRegionLastBlock(volume.getSideLengthInBlocks()-1)
|
||||
,mZRegionLastBlock(volume.getSideLengthInBlocks()-1)
|
||||
,mXRegionLastBlock(volume.m_uSideLengthInBlocks-1)
|
||||
,mYRegionLastBlock(volume.m_uSideLengthInBlocks-1)
|
||||
,mZRegionLastBlock(volume.m_uSideLengthInBlocks-1)
|
||||
,mXPosInVolume(0)
|
||||
,mYPosInVolume(0)
|
||||
,mZPosInVolume(0)
|
||||
@ -84,38 +86,49 @@ namespace PolyVox
|
||||
return *mCurrentVoxel;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
/*template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::getVoxelAt(const uint16_t xPosition, const uint16_t yPosition, const uint16_t zPosition) const
|
||||
{
|
||||
const uint16_t blockX = xPosition >> mVolume.getBlockSideLengthPower();
|
||||
const uint16_t blockY = yPosition >> mVolume.getBlockSideLengthPower();
|
||||
const uint16_t blockZ = zPosition >> mVolume.getBlockSideLengthPower();
|
||||
assert(xPosition < mVolume.getSideLength());
|
||||
assert(yPosition < mVolume.getSideLength());
|
||||
assert(zPosition < mVolume.getSideLength());
|
||||
|
||||
const uint16_t xOffset = xPosition - (blockX << mVolume.getBlockSideLengthPower());
|
||||
const uint16_t yOffset = yPosition - (blockY << mVolume.getBlockSideLengthPower());
|
||||
const uint16_t zOffset = zPosition - (blockZ << mVolume.getBlockSideLengthPower());
|
||||
const uint16_t blockX = xPosition >> mVolume.m_uBlockSideLengthPower;
|
||||
const uint16_t blockY = yPosition >> mVolume.m_uBlockSideLengthPower;
|
||||
const uint16_t blockZ = zPosition >> mVolume.m_uBlockSideLengthPower;
|
||||
|
||||
const uint16_t xOffset = xPosition - (blockX << mVolume.m_uBlockSideLengthPower);
|
||||
const uint16_t yOffset = yPosition - (blockY << mVolume.m_uBlockSideLengthPower);
|
||||
const uint16_t zOffset = zPosition - (blockZ << mVolume.m_uBlockSideLengthPower);
|
||||
|
||||
const Block<VoxelType>* block = mVolume.mBlocks
|
||||
[
|
||||
blockX +
|
||||
blockY * mVolume.getSideLengthInBlocks() +
|
||||
blockZ * mVolume.getSideLengthInBlocks() * mVolume.getSideLengthInBlocks()
|
||||
blockY * mVolume.m_uSideLengthInBlocks +
|
||||
blockZ * mVolume.m_uSideLengthInBlocks * mVolume.m_uSideLengthInBlocks
|
||||
];
|
||||
|
||||
return block->getVoxelAt(xOffset,yOffset,zOffset);
|
||||
}
|
||||
}*/
|
||||
|
||||
template <typename VoxelType>
|
||||
float VolumeIterator<VoxelType>::getAveragedVoxelAt(const uint16_t xPosition, const uint16_t yPosition, const uint16_t zPosition, uint16_t size) const
|
||||
float VolumeIterator<VoxelType>::getAveragedVoxel(uint16_t size) const
|
||||
{
|
||||
assert(mXPosInVolume >= size);
|
||||
assert(mYPosInVolume >= size);
|
||||
assert(mZPosInVolume >= size);
|
||||
assert(mXPosInVolume < mVolume.getSideLength() - (size + 1));
|
||||
assert(mYPosInVolume < mVolume.getSideLength() - (size + 1));
|
||||
assert(mZPosInVolume < mVolume.getSideLength() - (size + 1));
|
||||
|
||||
float sum = 0.0;
|
||||
for(uint16_t z = zPosition-size; z <= zPosition+size; ++z)
|
||||
for(uint16_t z = mZPosInVolume-size; z <= mZPosInVolume+size; ++z)
|
||||
{
|
||||
for(uint16_t y = yPosition-size; y <= yPosition+size; ++y)
|
||||
for(uint16_t y = mYPosInVolume-size; y <= mYPosInVolume+size; ++y)
|
||||
{
|
||||
for(uint16_t x = xPosition-size; x <= xPosition+size; ++x)
|
||||
for(uint16_t x = mXPosInVolume-size; x <= mXPosInVolume+size; ++x)
|
||||
{
|
||||
if(getVoxelAt(x,y,z) != 0)
|
||||
if(mVolume.getVoxelAt(x,y,z) != 0)
|
||||
{
|
||||
sum += 1.0;
|
||||
}
|
||||
@ -155,22 +168,22 @@ namespace PolyVox
|
||||
mYPosInVolume = yPos;
|
||||
mZPosInVolume = zPos;
|
||||
|
||||
mXBlock = mXPosInVolume >> mVolume.getBlockSideLengthPower();
|
||||
mYBlock = mYPosInVolume >> mVolume.getBlockSideLengthPower();
|
||||
mZBlock = mZPosInVolume >> mVolume.getBlockSideLengthPower();
|
||||
mXBlock = mXPosInVolume >> mVolume.m_uBlockSideLengthPower;
|
||||
mYBlock = mYPosInVolume >> mVolume.m_uBlockSideLengthPower;
|
||||
mZBlock = mZPosInVolume >> mVolume.m_uBlockSideLengthPower;
|
||||
|
||||
mXPosInBlock = mXPosInVolume - (mXBlock << mVolume.getBlockSideLengthPower());
|
||||
mYPosInBlock = mYPosInVolume - (mYBlock << mVolume.getBlockSideLengthPower());
|
||||
mZPosInBlock = mZPosInVolume - (mZBlock << mVolume.getBlockSideLengthPower());
|
||||
mXPosInBlock = mXPosInVolume - (mXBlock << mVolume.m_uBlockSideLengthPower);
|
||||
mYPosInBlock = mYPosInVolume - (mYBlock << mVolume.m_uBlockSideLengthPower);
|
||||
mZPosInBlock = mZPosInVolume - (mZBlock << mVolume.m_uBlockSideLengthPower);
|
||||
|
||||
mBlockIndexInVolume = mXBlock +
|
||||
mYBlock * mVolume.getSideLengthInBlocks() +
|
||||
mZBlock * mVolume.getSideLengthInBlocks() * mVolume.getSideLengthInBlocks();
|
||||
mYBlock * mVolume.m_uSideLengthInBlocks +
|
||||
mZBlock * mVolume.m_uSideLengthInBlocks * mVolume.m_uSideLengthInBlocks;
|
||||
Block<VoxelType>* currentBlock = mVolume.mBlocks[mBlockIndexInVolume];
|
||||
|
||||
mVoxelIndexInBlock = mXPosInBlock +
|
||||
mYPosInBlock * mVolume.getBlockSideLength() +
|
||||
mZPosInBlock * mVolume.getBlockSideLength() * mVolume.getBlockSideLength();
|
||||
mYPosInBlock * mVolume.m_uBlockSideLength +
|
||||
mZPosInBlock * mVolume.m_uBlockSideLength * mVolume.m_uBlockSideLength;
|
||||
|
||||
mCurrentVoxel = currentBlock->m_tData + mVoxelIndexInBlock;
|
||||
}
|
||||
@ -186,13 +199,13 @@ namespace PolyVox
|
||||
mYRegionLast = yLast;
|
||||
mZRegionLast = zLast;
|
||||
|
||||
mXRegionFirstBlock = mXRegionFirst >> mVolume.getBlockSideLengthPower();
|
||||
mYRegionFirstBlock = mYRegionFirst >> mVolume.getBlockSideLengthPower();
|
||||
mZRegionFirstBlock = mZRegionFirst >> mVolume.getBlockSideLengthPower();
|
||||
mXRegionFirstBlock = mXRegionFirst >> mVolume.m_uBlockSideLengthPower;
|
||||
mYRegionFirstBlock = mYRegionFirst >> mVolume.m_uBlockSideLengthPower;
|
||||
mZRegionFirstBlock = mZRegionFirst >> mVolume.m_uBlockSideLengthPower;
|
||||
|
||||
mXRegionLastBlock = mXRegionLast >> mVolume.getBlockSideLengthPower();
|
||||
mYRegionLastBlock = mYRegionLast >> mVolume.getBlockSideLengthPower();
|
||||
mZRegionLastBlock = mZRegionLast >> mVolume.getBlockSideLengthPower();
|
||||
mXRegionLastBlock = mXRegionLast >> mVolume.m_uBlockSideLengthPower;
|
||||
mYRegionLastBlock = mYRegionLast >> mVolume.m_uBlockSideLengthPower;
|
||||
mZRegionLastBlock = mZRegionLast >> mVolume.m_uBlockSideLengthPower;
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -201,34 +214,34 @@ namespace PolyVox
|
||||
mXPosInBlock++;
|
||||
mCurrentVoxel++;
|
||||
mXPosInVolume++;
|
||||
if((mXPosInBlock == mVolume.getBlockSideLength()) || (mXPosInVolume > mXRegionLast))
|
||||
if((mXPosInBlock == mVolume.m_uBlockSideLength) || (mXPosInVolume > mXRegionLast))
|
||||
{
|
||||
mXPosInVolume = (std::max)(mXRegionFirst,uint16_t(mXBlock * mVolume.getBlockSideLength()));
|
||||
mXPosInBlock = mXPosInVolume - (mXBlock << mVolume.getBlockSideLengthPower());
|
||||
mXPosInVolume = (std::max)(mXRegionFirst,uint16_t(mXBlock * mVolume.m_uBlockSideLength));
|
||||
mXPosInBlock = mXPosInVolume - (mXBlock << mVolume.m_uBlockSideLengthPower);
|
||||
mVoxelIndexInBlock = mXPosInBlock +
|
||||
mYPosInBlock * mVolume.getBlockSideLength() +
|
||||
mZPosInBlock * mVolume.getBlockSideLength() * mVolume.getBlockSideLength();
|
||||
mYPosInBlock * mVolume.m_uBlockSideLength +
|
||||
mZPosInBlock * mVolume.m_uBlockSideLength * mVolume.m_uBlockSideLength;
|
||||
Block<VoxelType>* currentBlock = mVolume.mBlocks[mBlockIndexInVolume];
|
||||
mCurrentVoxel = currentBlock->m_tData + mVoxelIndexInBlock;
|
||||
|
||||
mYPosInBlock++;
|
||||
mYPosInVolume++;
|
||||
mCurrentVoxel += mVolume.getBlockSideLength();
|
||||
if((mYPosInBlock == mVolume.getBlockSideLength()) || (mYPosInVolume > mYRegionLast))
|
||||
mCurrentVoxel += mVolume.m_uBlockSideLength;
|
||||
if((mYPosInBlock == mVolume.m_uBlockSideLength) || (mYPosInVolume > mYRegionLast))
|
||||
{
|
||||
mYPosInVolume = (std::max)(mYRegionFirst,uint16_t(mYBlock * mVolume.getBlockSideLength()));
|
||||
mYPosInBlock = mYPosInVolume - (mYBlock << mVolume.getBlockSideLengthPower());
|
||||
mYPosInVolume = (std::max)(mYRegionFirst,uint16_t(mYBlock * mVolume.m_uBlockSideLength));
|
||||
mYPosInBlock = mYPosInVolume - (mYBlock << mVolume.m_uBlockSideLengthPower);
|
||||
mVoxelIndexInBlock = mXPosInBlock +
|
||||
mYPosInBlock * mVolume.getBlockSideLength() +
|
||||
mZPosInBlock * mVolume.getBlockSideLength() * mVolume.getBlockSideLength();
|
||||
mYPosInBlock * mVolume.m_uBlockSideLength +
|
||||
mZPosInBlock * mVolume.m_uBlockSideLength * mVolume.m_uBlockSideLength;
|
||||
Block<VoxelType>* currentBlock = mVolume.mBlocks[mBlockIndexInVolume];
|
||||
mCurrentVoxel = currentBlock->m_tData + mVoxelIndexInBlock;
|
||||
|
||||
mZPosInBlock++;
|
||||
mZPosInVolume++;
|
||||
mCurrentVoxel += mVolume.getBlockSideLength() * mVolume.getBlockSideLength();
|
||||
mCurrentVoxel += mVolume.m_uBlockSideLength * mVolume.m_uBlockSideLength;
|
||||
|
||||
if((mZPosInBlock == mVolume.getBlockSideLength()) || (mZPosInVolume > mZRegionLast))
|
||||
if((mZPosInBlock == mVolume.m_uBlockSideLength) || (mZPosInVolume > mZRegionLast))
|
||||
{
|
||||
//At this point we've left the current block. Find a new one...
|
||||
|
||||
@ -238,20 +251,20 @@ namespace PolyVox
|
||||
{
|
||||
mXBlock = mXRegionFirstBlock;
|
||||
mBlockIndexInVolume = mXBlock +
|
||||
mYBlock * mVolume.getSideLengthInBlocks() +
|
||||
mZBlock * mVolume.getSideLengthInBlocks() * mVolume.getSideLengthInBlocks();
|
||||
mYBlock * mVolume.m_uSideLengthInBlocks +
|
||||
mZBlock * mVolume.m_uSideLengthInBlocks * mVolume.m_uSideLengthInBlocks;
|
||||
|
||||
++mYBlock;
|
||||
mBlockIndexInVolume += mVolume.getSideLengthInBlocks();
|
||||
mBlockIndexInVolume += mVolume.m_uSideLengthInBlocks;
|
||||
if(mYBlock > mYRegionLastBlock)
|
||||
{
|
||||
mYBlock = mYRegionFirstBlock;
|
||||
mBlockIndexInVolume = mXBlock +
|
||||
mYBlock * mVolume.getSideLengthInBlocks() +
|
||||
mZBlock * mVolume.getSideLengthInBlocks() * mVolume.getSideLengthInBlocks();
|
||||
mYBlock * mVolume.m_uSideLengthInBlocks +
|
||||
mZBlock * mVolume.m_uSideLengthInBlocks * mVolume.m_uSideLengthInBlocks;
|
||||
|
||||
++mZBlock;
|
||||
mBlockIndexInVolume += mVolume.getSideLengthInBlocks() * mVolume.getSideLengthInBlocks();
|
||||
mBlockIndexInVolume += mVolume.m_uSideLengthInBlocks * mVolume.m_uSideLengthInBlocks;
|
||||
if(mZBlock > mZRegionLastBlock)
|
||||
{
|
||||
mIsValidForRegion = false;
|
||||
@ -263,17 +276,17 @@ namespace PolyVox
|
||||
Block<VoxelType>* currentBlock = mVolume.mBlocks[mBlockIndexInVolume];
|
||||
//mCurrentBlock = mVolume->mBlocks[mBlockIndexInVolume];
|
||||
|
||||
mXPosInVolume = (std::max)(mXRegionFirst,uint16_t(mXBlock * mVolume.getBlockSideLength()));
|
||||
mYPosInVolume = (std::max)(mYRegionFirst,uint16_t(mYBlock * mVolume.getBlockSideLength()));
|
||||
mZPosInVolume = (std::max)(mZRegionFirst,uint16_t(mZBlock * mVolume.getBlockSideLength()));
|
||||
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));
|
||||
|
||||
mXPosInBlock = mXPosInVolume - (mXBlock << mVolume.getBlockSideLengthPower());
|
||||
mYPosInBlock = mYPosInVolume - (mYBlock << mVolume.getBlockSideLengthPower());
|
||||
mZPosInBlock = mZPosInVolume - (mZBlock << mVolume.getBlockSideLengthPower());
|
||||
mXPosInBlock = mXPosInVolume - (mXBlock << mVolume.m_uBlockSideLengthPower);
|
||||
mYPosInBlock = mYPosInVolume - (mYBlock << mVolume.m_uBlockSideLengthPower);
|
||||
mZPosInBlock = mZPosInVolume - (mZBlock << mVolume.m_uBlockSideLengthPower);
|
||||
|
||||
mVoxelIndexInBlock = mXPosInBlock +
|
||||
mYPosInBlock * mVolume.getBlockSideLength() +
|
||||
mZPosInBlock * mVolume.getBlockSideLength() * mVolume.getBlockSideLength();
|
||||
mYPosInBlock * mVolume.m_uBlockSideLength +
|
||||
mZPosInBlock * mVolume.m_uBlockSideLength * mVolume.m_uBlockSideLength;
|
||||
|
||||
mCurrentVoxel = currentBlock->m_tData + mVoxelIndexInBlock;
|
||||
}
|
||||
@ -290,91 +303,91 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1nx1ny1nz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != 0) && (mYPosInVolume%mVolume.getBlockSideLength() != 0) && (mZPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != 0) && (mYPosInVolume%mVolume.m_uBlockSideLength != 0) && (mZPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel - 1 - mVolume.getBlockSideLength() - mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - 1 - mVolume.m_uBlockSideLength - mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1nx1ny0pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != 0) && (mYPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != 0) && (mYPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel - 1 - mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - 1 - mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume);
|
||||
return mVolume.getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1nx1ny1pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != 0) && (mYPosInVolume%mVolume.getBlockSideLength() != 0) && (mZPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != 0) && (mYPosInVolume%mVolume.m_uBlockSideLength != 0) && (mZPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel - 1 - mVolume.getBlockSideLength() + mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - 1 - mVolume.m_uBlockSideLength + mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1nx0py1nz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != 0) && (mZPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != 0) && (mZPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel - 1 - mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - 1 - mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1nx0py0pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel - 1);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume);
|
||||
return mVolume.getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1nx0py1pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != 0) && (mZPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != 0) && (mZPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel - 1 + mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - 1 + mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1nx1py1nz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != 0) && (mYPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mZPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != 0) && (mYPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mZPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel - 1 + mVolume.getBlockSideLength() - mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - 1 + mVolume.m_uBlockSideLength - mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1nx1py0pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != 0) && (mYPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != 0) && (mYPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel - 1 + mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - 1 + mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume);
|
||||
return mVolume.getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1nx1py1pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != 0) && (mYPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mZPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != 0) && (mYPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mZPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel - 1 + mVolume.getBlockSideLength() + mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - 1 + mVolume.m_uBlockSideLength + mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -382,41 +395,41 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel0px1ny1nz(void) const
|
||||
{
|
||||
if((mYPosInVolume%mVolume.getBlockSideLength() != 0) && (mZPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mYPosInVolume%mVolume.m_uBlockSideLength != 0) && (mZPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel - mVolume.getBlockSideLength() - mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - mVolume.m_uBlockSideLength - mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel0px1ny0pz(void) const
|
||||
{
|
||||
if((mYPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mYPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel - mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume);
|
||||
return mVolume.getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel0px1ny1pz(void) const
|
||||
{
|
||||
if((mYPosInVolume%mVolume.getBlockSideLength() != 0) && (mZPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mYPosInVolume%mVolume.m_uBlockSideLength != 0) && (mZPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel - mVolume.getBlockSideLength() + mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - mVolume.m_uBlockSideLength + mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel0px0py1nz(void) const
|
||||
{
|
||||
if((mZPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mZPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel - mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel - mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
@ -428,41 +441,41 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel0px0py1pz(void) const
|
||||
{
|
||||
if((mZPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mZPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel + mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel0px1py1nz(void) const
|
||||
{
|
||||
if((mYPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mZPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mYPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mZPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel + mVolume.getBlockSideLength() - mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + mVolume.m_uBlockSideLength - mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel0px1py0pz(void) const
|
||||
{
|
||||
if((mYPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mYPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel + mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume);
|
||||
return mVolume.getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel0px1py1pz(void) const
|
||||
{
|
||||
if((mYPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mZPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mYPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mZPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel + mVolume.getBlockSideLength() + mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + mVolume.m_uBlockSideLength + mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@ -470,90 +483,90 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1px1ny1nz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mYPosInVolume%mVolume.getBlockSideLength() != 0) && (mZPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mYPosInVolume%mVolume.m_uBlockSideLength != 0) && (mZPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel + 1 - mVolume.getBlockSideLength() - mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + 1 - mVolume.m_uBlockSideLength - mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1px1ny0pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mYPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mYPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel + 1 - mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + 1 - mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume);
|
||||
return mVolume.getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1px1ny1pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mYPosInVolume%mVolume.getBlockSideLength() != 0) && (mZPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mYPosInVolume%mVolume.m_uBlockSideLength != 0) && (mZPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel + 1 - mVolume.getBlockSideLength() + mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + 1 - mVolume.m_uBlockSideLength + mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1px0py1nz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mZPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mZPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel + 1 - mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + 1 - mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1px0py0pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel + 1);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume);
|
||||
return mVolume.getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1px0py1pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mZPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mZPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel + 1 + mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + 1 + mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1px1py1nz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mYPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mZPosInVolume%mVolume.getBlockSideLength() != 0))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mYPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mZPosInVolume%mVolume.m_uBlockSideLength != 0))
|
||||
{
|
||||
return *(mCurrentVoxel + 1 + mVolume.getBlockSideLength() - mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + 1 + mVolume.m_uBlockSideLength - mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1px1py0pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mYPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mYPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel + 1 + mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + 1 + mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume);
|
||||
return mVolume.getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume);
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeIterator<VoxelType>::peekVoxel1px1py1pz(void) const
|
||||
{
|
||||
if((mXPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mYPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1) && (mZPosInVolume%mVolume.getBlockSideLength() != mVolume.getBlockSideLength()-1))
|
||||
if((mXPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mYPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1) && (mZPosInVolume%mVolume.m_uBlockSideLength != mVolume.m_uBlockSideLength-1))
|
||||
{
|
||||
return *(mCurrentVoxel + 1 + mVolume.getBlockSideLength() + mVolume.getBlockSideLength()*mVolume.getBlockSideLength());
|
||||
return *(mCurrentVoxel + 1 + mVolume.m_uBlockSideLength + mVolume.m_uBlockSideLength*mVolume.m_uBlockSideLength);
|
||||
}
|
||||
return getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1);
|
||||
return mVolume.getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user