Merge branch 'develop' into feature/wrap-modes
Conflicts: library/PolyVoxCore/source/Region.cpp
This commit is contained in:
commit
1f6cbb79a9
@ -2,6 +2,18 @@ Changes for PolyVox version 0.3
|
|||||||
===============================
|
===============================
|
||||||
This release has focused on... (some introduction here).
|
This release has focused on... (some introduction here).
|
||||||
|
|
||||||
|
Region class
|
||||||
|
------------
|
||||||
|
The Region class has been tidied up and enhanced with new functionality. It now contains functions for growing and shrinking regions, as well as 'accumulate()' functions which ensure the Region contains a given point. The concept of an invalid region has also been introduced - this is one whose lower corner is greater than it's upper corner.
|
||||||
|
|
||||||
|
Vector class
|
||||||
|
------------
|
||||||
|
The Vector class has been tidied up. Most notably it now makes use of an 'OperationType' which is used for internal calculations and some results. The documentation has also been updated.
|
||||||
|
|
||||||
|
Deprecated functionality
|
||||||
|
------------------------
|
||||||
|
Vector::operator<() has been deprecated. It was only present to allow Vectors to be used as the key to an std::map, but it makes more sense for this to be specified seperatly as a std::map comparison function. This is now done in the OpenGLExample (search for VectorCompare).
|
||||||
|
|
||||||
Removed functionality
|
Removed functionality
|
||||||
--------------------
|
--------------------
|
||||||
Functionality deprecated for the previous release has now been removed. This includes:
|
Functionality deprecated for the previous release has now been removed. This includes:
|
||||||
@ -13,8 +25,6 @@ Functionality deprecated for the previous release has now been removed. This inc
|
|||||||
- This had a number of problems and was a little too high-level for PolyVox. You should implement change tracking yourself.
|
- This had a number of problems and was a little too high-level for PolyVox. You should implement change tracking yourself.
|
||||||
|
|
||||||
|
|
||||||
The Region class has been tidied up and enhanced with new functionality. It now contains functions for growing and shrinking regions, as well as 'accumulate()' functions which ensure the Region contains a given point. The concept of an invalid region has also been introduced - this is one whose lower corner is greater than it's upper corner.
|
|
||||||
|
|
||||||
Changes for PolyVox version 0.2
|
Changes for PolyVox version 0.2
|
||||||
===============================
|
===============================
|
||||||
This is the first revision for which we have produced a changelog, as we are now trying to streamline our development and release process. Hence this changelog entry is not going to be as structured as we hope they will be in the future. We're writing it from memory, rather than having carefully kept track of all the relevant changes as we made them.
|
This is the first revision for which we have produced a changelog, as we are now trying to streamline our development and release process. Hence this changelog entry is not going to be as structured as we hope they will be in the future. We're writing it from memory, rather than having carefully kept track of all the relevant changes as we made them.
|
||||||
|
@ -39,6 +39,22 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
const int32_t g_uVolumeSideLength = 128;
|
const int32_t g_uVolumeSideLength = 128;
|
||||||
|
|
||||||
|
struct Vector3DUint8Compare
|
||||||
|
{
|
||||||
|
bool operator() (const PolyVox::Vector3DUint8& a, const PolyVox::Vector3DUint8& b)
|
||||||
|
{
|
||||||
|
const uint32_t size = 3;
|
||||||
|
for(uint32_t ct = 0; ct < size; ++ct)
|
||||||
|
{
|
||||||
|
if (a.getElement(ct) < b.getElement(ct))
|
||||||
|
return true;
|
||||||
|
if (b.getElement(ct) < a.getElement(ct))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class OpenGLWidget : public QGLWidget
|
class OpenGLWidget : public QGLWidget
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -71,8 +87,8 @@ class OpenGLWidget : public QGLWidget
|
|||||||
PolyVox::LargeVolume<PolyVox::MaterialDensityPair44>* m_volData;
|
PolyVox::LargeVolume<PolyVox::MaterialDensityPair44>* m_volData;
|
||||||
|
|
||||||
//Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region
|
//Rather than storing one big mesh, the volume is broken into regions and a mesh is stored for each region
|
||||||
std::map<PolyVox::Vector3DUint8, OpenGLSurfaceMesh> m_mapOpenGLSurfaceMeshes;
|
std::map<PolyVox::Vector3DUint8, OpenGLSurfaceMesh, Vector3DUint8Compare> m_mapOpenGLSurfaceMeshes;
|
||||||
std::map<PolyVox::Vector3DUint8, polyvox_shared_ptr<PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> > > m_mapSurfaceMeshes;
|
std::map<PolyVox::Vector3DUint8, polyvox_shared_ptr<PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> >, Vector3DUint8Compare> m_mapSurfaceMeshes;
|
||||||
|
|
||||||
unsigned int m_uRegionSideLength;
|
unsigned int m_uRegionSideLength;
|
||||||
unsigned int m_uVolumeWidthInRegions;
|
unsigned int m_uVolumeWidthInRegions;
|
||||||
|
@ -28,3 +28,4 @@ add_definitions(-DGLEW_STATIC)
|
|||||||
#find_package(OpenGL REQUIRED)
|
#find_package(OpenGL REQUIRED)
|
||||||
#include_directories(${OPENGL_INCLUDE_DIR})
|
#include_directories(${OPENGL_INCLUDE_DIR})
|
||||||
add_library(glew STATIC ${SRC_FILES})
|
add_library(glew STATIC ${SRC_FILES})
|
||||||
|
SET_PROPERTY(TARGET glew PROPERTY FOLDER "Examples/Common")
|
||||||
|
@ -310,6 +310,22 @@ namespace PolyVox
|
|||||||
LargeVolume& operator=(const LargeVolume& rhs);
|
LargeVolume& operator=(const LargeVolume& rhs);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
struct BlockPositionCompare
|
||||||
|
{
|
||||||
|
bool operator() (const PolyVox::Vector3DInt32& a, const PolyVox::Vector3DInt32& b)
|
||||||
|
{
|
||||||
|
const uint32_t size = 3;
|
||||||
|
for(uint32_t ct = 0; ct < size; ++ct)
|
||||||
|
{
|
||||||
|
if (a.getElement(ct) < b.getElement(ct))
|
||||||
|
return true;
|
||||||
|
if (b.getElement(ct) < a.getElement(ct))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
void initialise(const Region& regValidRegion, uint16_t uBlockSideLength);
|
void initialise(const Region& regValidRegion, uint16_t uBlockSideLength);
|
||||||
|
|
||||||
/// gets called when a new region is allocated and needs to be filled
|
/// gets called when a new region is allocated and needs to be filled
|
||||||
@ -323,12 +339,12 @@ namespace PolyVox
|
|||||||
polyvox_function<void(const ConstVolumeProxy<VoxelType>&, const Region&)> m_funcDataOverflowHandler;
|
polyvox_function<void(const ConstVolumeProxy<VoxelType>&, const Region&)> m_funcDataOverflowHandler;
|
||||||
|
|
||||||
Block<VoxelType>* getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const;
|
Block<VoxelType>* getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const;
|
||||||
void eraseBlock(typename std::map<Vector3DInt32, LoadedBlock >::iterator itBlock) const;
|
void eraseBlock(typename std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare>::iterator itBlock) const;
|
||||||
/// this function can be called by m_funcDataRequiredHandler without causing any weird effects
|
/// this function can be called by m_funcDataRequiredHandler without causing any weird effects
|
||||||
bool setVoxelAtConst(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) const;
|
bool setVoxelAtConst(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) const;
|
||||||
|
|
||||||
//The block data
|
//The block data
|
||||||
mutable std::map<Vector3DInt32, LoadedBlock > m_pBlocks;
|
mutable std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare> m_pBlocks;
|
||||||
|
|
||||||
//The cache of uncompressed blocks. The uncompressed block data and the timestamps are stored here rather
|
//The cache of uncompressed blocks. The uncompressed block data and the timestamps are stored here rather
|
||||||
//than in the Block class. This is so that in the future each VolumeIterator might to maintain its own cache
|
//than in the Block class. This is so that in the future each VolumeIterator might to maintain its own cache
|
||||||
|
@ -364,7 +364,7 @@ namespace PolyVox
|
|||||||
for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++)
|
for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++)
|
||||||
{
|
{
|
||||||
Vector3DInt32 pos(x,y,z);
|
Vector3DInt32 pos(x,y,z);
|
||||||
typename std::map<Vector3DInt32, LoadedBlock>::iterator itBlock = m_pBlocks.find(pos);
|
typename std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos);
|
||||||
|
|
||||||
if(itBlock != m_pBlocks.end())
|
if(itBlock != m_pBlocks.end())
|
||||||
{
|
{
|
||||||
@ -395,7 +395,7 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
void LargeVolume<VoxelType>::flushAll()
|
void LargeVolume<VoxelType>::flushAll()
|
||||||
{
|
{
|
||||||
typename std::map<Vector3DInt32, LoadedBlock >::iterator i;
|
typename std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare>::iterator i;
|
||||||
//Replaced the for loop here as the call to
|
//Replaced the for loop here as the call to
|
||||||
//eraseBlock was invalidating the iterator.
|
//eraseBlock was invalidating the iterator.
|
||||||
while(m_pBlocks.size() > 0)
|
while(m_pBlocks.size() > 0)
|
||||||
@ -429,7 +429,7 @@ namespace PolyVox
|
|||||||
for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++)
|
for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); z++)
|
||||||
{
|
{
|
||||||
Vector3DInt32 pos(x,y,z);
|
Vector3DInt32 pos(x,y,z);
|
||||||
typename std::map<Vector3DInt32, LoadedBlock>::iterator itBlock = m_pBlocks.find(pos);
|
typename std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(pos);
|
||||||
if(itBlock == m_pBlocks.end())
|
if(itBlock == m_pBlocks.end())
|
||||||
{
|
{
|
||||||
// not loaded, not unloading
|
// not loaded, not unloading
|
||||||
@ -514,7 +514,7 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
void LargeVolume<VoxelType>::eraseBlock(typename std::map<Vector3DInt32, LoadedBlock >::iterator itBlock) const
|
void LargeVolume<VoxelType>::eraseBlock(typename std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare>::iterator itBlock) const
|
||||||
{
|
{
|
||||||
if(m_funcDataOverflowHandler)
|
if(m_funcDataOverflowHandler)
|
||||||
{
|
{
|
||||||
@ -585,7 +585,7 @@ namespace PolyVox
|
|||||||
return m_pLastAccessedBlock;
|
return m_pLastAccessedBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
typename std::map<Vector3DInt32, LoadedBlock >::iterator itBlock = m_pBlocks.find(v3dBlockPos);
|
typename std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare>::iterator itBlock = m_pBlocks.find(v3dBlockPos);
|
||||||
// check whether the block is already loaded
|
// check whether the block is already loaded
|
||||||
if(itBlock == m_pBlocks.end())
|
if(itBlock == m_pBlocks.end())
|
||||||
{
|
{
|
||||||
@ -598,8 +598,8 @@ namespace PolyVox
|
|||||||
if(m_pBlocks.size() == m_uMaxNumberOfBlocksInMemory)
|
if(m_pBlocks.size() == m_uMaxNumberOfBlocksInMemory)
|
||||||
{
|
{
|
||||||
// find the least recently used block
|
// find the least recently used block
|
||||||
typename std::map<Vector3DInt32, LoadedBlock >::iterator i;
|
typename std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare>::iterator i;
|
||||||
typename std::map<Vector3DInt32, LoadedBlock >::iterator itUnloadBlock = m_pBlocks.begin();
|
typename std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare>::iterator itUnloadBlock = m_pBlocks.begin();
|
||||||
for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++)
|
for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++)
|
||||||
{
|
{
|
||||||
if(i->second.timestamp < itUnloadBlock->second.timestamp)
|
if(i->second.timestamp < itUnloadBlock->second.timestamp)
|
||||||
@ -702,7 +702,7 @@ namespace PolyVox
|
|||||||
uint32_t uSizeInBytes = sizeof(LargeVolume);
|
uint32_t uSizeInBytes = sizeof(LargeVolume);
|
||||||
|
|
||||||
//Memory used by the blocks
|
//Memory used by the blocks
|
||||||
typename std::map<Vector3DInt32, LoadedBlock >::iterator i;
|
typename std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare>::iterator i;
|
||||||
for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++)
|
for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++)
|
||||||
{
|
{
|
||||||
//Inaccurate - account for rest of loaded block.
|
//Inaccurate - account for rest of loaded block.
|
||||||
|
@ -30,25 +30,25 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
/// Represents a part of a Volume.
|
/** Represents a part of a Volume.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*
|
||||||
/// Many operations in PolyVox are constrained to only part of a volume. For example, when running the surface extractors
|
* Many operations in PolyVox are constrained to only part of a volume. For example, when running the surface extractors
|
||||||
/// it is unlikely that you will want to run it on the whole volume at once, as this will give a very large mesh which may
|
* it is unlikely that you will want to run it on the whole volume at once, as this will give a very large mesh which may
|
||||||
/// be too much to render. Instead you will probably want to run a surface extractor a number of times on different parts
|
* be too much to render. Instead you will probably want to run a surface extractor a number of times on different parts
|
||||||
/// of the volume, there by giving a number of meshes which can be culled and rendered seperately.
|
* of the volume, there by giving a number of meshes which can be culled and rendered seperately.
|
||||||
///
|
*
|
||||||
/// The Region class is used to define these parts (regions) of the volume. Essentially it consists of an upper and lower
|
* The Region class is used to define these parts (regions) of the volume. Essentially it consists of an upper and lower
|
||||||
/// bound which specify the range of voxels positions considered to be part of the region. Note that these bounds are
|
* bound which specify the range of voxels positions considered to be part of the region. Note that these bounds are
|
||||||
/// <em>inclusive</em>.
|
* <em>inclusive</em>.
|
||||||
///
|
*
|
||||||
/// As well as the expected set of getters and setters, this class also provide utility functions for increasing and decresing
|
* As well as the expected set of getters and setters, this class also provide utility functions for increasing and decresing
|
||||||
/// the size of the Region, shifting the Region in 3D space, testing whether it contains a given position, enlarging it so that
|
* the size of the Region, shifting the Region in 3D space, testing whether it contains a given position, enlarging it so that
|
||||||
/// it does contain a given position, croppng it to another Region, and various other utility functions.
|
* it does contain a given position, croppng it to another Region, and various other utility functions.
|
||||||
///
|
*
|
||||||
/// \Note The dimensions of a region can be measured either in voxels or in cells. See the manual for more information
|
* \Note The dimensions of a region can be measured either in voxels or in cells. See the manual for more information
|
||||||
/// about these definitions.
|
* about these definitions.
|
||||||
///
|
*
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
#ifdef SWIG
|
#ifdef SWIG
|
||||||
class Region
|
class Region
|
||||||
#else
|
#else
|
||||||
@ -203,193 +203,193 @@ namespace PolyVox
|
|||||||
// 'inline' keyword is used for the definition rather than the declaration.
|
// 'inline' keyword is used for the definition rather than the declaration.
|
||||||
// See also http://www.parashift.com/c++-faq-lite/inline-functions.html
|
// See also http://www.parashift.com/c++-faq-lite/inline-functions.html
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The 'x' position of the lower corner.
|
* \return The 'x' position of the lower corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getLowerX(void) const
|
inline int32_t Region::getLowerX(void) const
|
||||||
{
|
{
|
||||||
return m_iLowerX;
|
return m_iLowerX;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The 'y' position of the lower corner.
|
* \return The 'y' position of the lower corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getLowerY(void) const
|
inline int32_t Region::getLowerY(void) const
|
||||||
{
|
{
|
||||||
return m_iLowerY;
|
return m_iLowerY;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The 'z' position of the lower corner.
|
* \return The 'z' position of the lower corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getLowerZ(void) const
|
inline int32_t Region::getLowerZ(void) const
|
||||||
{
|
{
|
||||||
return m_iLowerZ;
|
return m_iLowerZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The 'x' position of the upper corner.
|
* \return The 'x' position of the upper corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getUpperX(void) const
|
inline int32_t Region::getUpperX(void) const
|
||||||
{
|
{
|
||||||
return m_iUpperX;
|
return m_iUpperX;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The 'y' position of the upper corner.
|
* \return The 'y' position of the upper corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getUpperY(void) const
|
inline int32_t Region::getUpperY(void) const
|
||||||
{
|
{
|
||||||
return m_iUpperY;
|
return m_iUpperY;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The 'z' position of the upper corner.
|
* \return The 'z' position of the upper corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getUpperZ(void) const
|
inline int32_t Region::getUpperZ(void) const
|
||||||
{
|
{
|
||||||
return m_iUpperZ;
|
return m_iUpperZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The position of the lower corner.
|
* \return The position of the lower corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline Vector3DInt32 Region::getLowerCorner(void) const
|
inline Vector3DInt32 Region::getLowerCorner(void) const
|
||||||
{
|
{
|
||||||
return Vector3DInt32(m_iLowerX, m_iLowerY, m_iLowerZ);
|
return Vector3DInt32(m_iLowerX, m_iLowerY, m_iLowerZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The position of the upper corner.
|
* \return The position of the upper corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline Vector3DInt32 Region::getUpperCorner(void) const
|
inline Vector3DInt32 Region::getUpperCorner(void) const
|
||||||
{
|
{
|
||||||
return Vector3DInt32(m_iUpperX, m_iUpperY, m_iUpperZ);
|
return Vector3DInt32(m_iUpperX, m_iUpperY, m_iUpperZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The width of the region measured in voxels.
|
* \return The width of the region measured in voxels.
|
||||||
/// \sa getWidthInCells()
|
* \sa getWidthInCells()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getWidthInVoxels(void) const
|
inline int32_t Region::getWidthInVoxels(void) const
|
||||||
{
|
{
|
||||||
return getWidthInCells() + 1;
|
return getWidthInCells() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The height of the region measured in voxels.
|
* \return The height of the region measured in voxels.
|
||||||
/// \sa getHeightInCells()
|
* \sa getHeightInCells()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getHeightInVoxels(void) const
|
inline int32_t Region::getHeightInVoxels(void) const
|
||||||
{
|
{
|
||||||
return getHeightInCells() + 1;
|
return getHeightInCells() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The depth of the region measured in voxels.
|
* \return The depth of the region measured in voxels.
|
||||||
/// \sa getDepthInCells()
|
* \sa getDepthInCells()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getDepthInVoxels(void) const
|
inline int32_t Region::getDepthInVoxels(void) const
|
||||||
{
|
{
|
||||||
return getDepthInCells() + 1;
|
return getDepthInCells() + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The dimensions of the region measured in voxels.
|
* \return The dimensions of the region measured in voxels.
|
||||||
/// \sa getDimensionsInCells()
|
* \sa getDimensionsInCells()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline Vector3DInt32 Region::getDimensionsInVoxels(void) const
|
inline Vector3DInt32 Region::getDimensionsInVoxels(void) const
|
||||||
{
|
{
|
||||||
return getDimensionsInCells() + Vector3DInt32(1, 1, 1);
|
return getDimensionsInCells() + Vector3DInt32(1, 1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The width of the region measured in cells.
|
* \return The width of the region measured in cells.
|
||||||
/// \sa getWidthInVoxels()
|
* \sa getWidthInVoxels()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getWidthInCells(void) const
|
inline int32_t Region::getWidthInCells(void) const
|
||||||
{
|
{
|
||||||
return m_iUpperX - m_iLowerX;
|
return m_iUpperX - m_iLowerX;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The height of the region measured in cells.
|
* \return The height of the region measured in cells.
|
||||||
/// \sa getHeightInVoxels()
|
* \sa getHeightInVoxels()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getHeightInCells(void) const
|
inline int32_t Region::getHeightInCells(void) const
|
||||||
{
|
{
|
||||||
return m_iUpperY - m_iLowerY;
|
return m_iUpperY - m_iLowerY;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The depth of the region measured in cells.
|
* \return The depth of the region measured in cells.
|
||||||
/// \sa getDepthInVoxels()
|
* \sa getDepthInVoxels()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline int32_t Region::getDepthInCells(void) const
|
inline int32_t Region::getDepthInCells(void) const
|
||||||
{
|
{
|
||||||
return m_iUpperZ - m_iLowerZ;
|
return m_iUpperZ - m_iLowerZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \return The dimensions of the region measured in cells.
|
* \return The dimensions of the region measured in cells.
|
||||||
/// \sa getDimensionsInVoxels()
|
* \sa getDimensionsInVoxels()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline Vector3DInt32 Region::getDimensionsInCells(void) const
|
inline Vector3DInt32 Region::getDimensionsInCells(void) const
|
||||||
{
|
{
|
||||||
return Vector3DInt32(getWidthInCells(), getHeightInCells(), getDepthInCells());
|
return Vector3DInt32(getWidthInCells(), getHeightInCells(), getDepthInCells());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param iX The new 'x' position of the lower corner.
|
* \param iX The new 'x' position of the lower corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline void Region::setLowerX(int32_t iX)
|
inline void Region::setLowerX(int32_t iX)
|
||||||
{
|
{
|
||||||
m_iLowerX = iX;
|
m_iLowerX = iX;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param iY The new 'y' position of the lower corner.
|
* \param iY The new 'y' position of the lower corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline void Region::setLowerY(int32_t iY)
|
inline void Region::setLowerY(int32_t iY)
|
||||||
{
|
{
|
||||||
m_iLowerY = iY;
|
m_iLowerY = iY;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param iZ The new 'z' position of the lower corner.
|
* \param iZ The new 'z' position of the lower corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline void Region::setLowerZ(int32_t iZ)
|
inline void Region::setLowerZ(int32_t iZ)
|
||||||
{
|
{
|
||||||
m_iLowerZ = iZ;
|
m_iLowerZ = iZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param iX The new 'x' position of the upper corner.
|
* \param iX The new 'x' position of the upper corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline void Region::setUpperX(int32_t iX)
|
inline void Region::setUpperX(int32_t iX)
|
||||||
{
|
{
|
||||||
m_iUpperX = iX;
|
m_iUpperX = iX;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param iY The new 'y' position of the upper corner.
|
* \param iY The new 'y' position of the upper corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline void Region::setUpperY(int32_t iY)
|
inline void Region::setUpperY(int32_t iY)
|
||||||
{
|
{
|
||||||
m_iUpperY = iY;
|
m_iUpperY = iY;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param iZ The new 'z' position of the upper corner.
|
* \param iZ The new 'z' position of the upper corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline void Region::setUpperZ(int32_t iZ)
|
inline void Region::setUpperZ(int32_t iZ)
|
||||||
{
|
{
|
||||||
m_iUpperZ = iZ;
|
m_iUpperZ = iZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param v3dLowerCorner The new position of the lower corner.
|
* \param v3dLowerCorner The new position of the lower corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline void Region::setLowerCorner(const Vector3DInt32& v3dLowerCorner)
|
inline void Region::setLowerCorner(const Vector3DInt32& v3dLowerCorner)
|
||||||
{
|
{
|
||||||
m_iLowerX = v3dLowerCorner.getX();
|
m_iLowerX = v3dLowerCorner.getX();
|
||||||
@ -397,9 +397,9 @@ namespace PolyVox
|
|||||||
m_iLowerZ = v3dLowerCorner.getZ();
|
m_iLowerZ = v3dLowerCorner.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param v3dUpperCorner The new position of the upper corner.
|
* \param v3dUpperCorner The new position of the upper corner.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
inline void Region::setUpperCorner(const Vector3DInt32& v3dUpperCorner)
|
inline void Region::setUpperCorner(const Vector3DInt32& v3dUpperCorner)
|
||||||
{
|
{
|
||||||
m_iUpperX = v3dUpperCorner.getX();
|
m_iUpperX = v3dUpperCorner.getX();
|
||||||
|
@ -36,192 +36,193 @@ freely, subject to the following restrictions:
|
|||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
Represents a vector in space.
|
* Represents a vector in space.
|
||||||
|
*
|
||||||
This Vector class is templated on both size and data type. It is designed to be
|
* This is a generl purpose vector class designed to represent both positions and directions. It is templatised
|
||||||
generic but so far had only been tested with vectors of size 2 and 3. Also note
|
* on both size and data type but note that some of the operations do not make sense with integer types. For
|
||||||
that some of the operations do not make sense with integer types, for example it
|
* example it does not make conceptual sense to try and normalise an integer Vector.
|
||||||
does not make conceptual sense to try and normalise an integer Vector.
|
*
|
||||||
|
* Every Vector must have at at least two elements, and the first four elements of any vector are known as the
|
||||||
The elements of the Vector are accessed via the overloaded () operator which takes
|
* X, Y, Z and W elements. Note that W is last even though it comes before X in the alphabet. These elements can
|
||||||
an index indicating the element to fetch. They are set using the set() function which
|
* be accessed through getX(), setX(), getY(), setY(), getZ(), setZ(), getW() and setW(), while other elements
|
||||||
takes an index indicating the element to set and a new value for that element. For
|
* can be accessed through getElemen() and setElement().
|
||||||
convienience, the functions getX(), setX(), getY(), setY(), getZ(), setZ(), getw() and setW()
|
*
|
||||||
do the same thing for the first 4 elements of the Vector.
|
* This class includes a number of common mathematical operations (addition, subtraction, etc) as well as vector
|
||||||
|
* specific operations such as the dot and cross products. Note that this class is also templatised on an
|
||||||
A variety of overloaded operators are also provided for comparison and arithmetic
|
* OperationType which is used for many internal calculations and some results. For example, the square of a
|
||||||
operations. For most of these arithmetic operators only the unary versions are
|
* vector's length will always be an integer if all the elements are integers, but the value might be outside
|
||||||
documented below - however often binary versions are also generated by std::operators.
|
* that which can be represented by the StorageType. You don't need to worry about this as long as you are using
|
||||||
|
* the built in typedefs for common configurations.
|
||||||
Lastly, note that for convienience a set of typedefs are included for 2 and 3 dimensional
|
*
|
||||||
vectors with type float, double, int32_t, and uint32_t. They are used as follows:
|
* Typedefs are provided for 2, 3 and 4 dimensional vector with int8_t, uint8_t, int16_t, uint6_t, int32_t,
|
||||||
|
* uint32_t, float and double types. These typedefs are used as follows:
|
||||||
\code
|
*
|
||||||
Vector2DInt4 test(1,2); //Declares a 2 dimensional Vector of type int4.
|
* \code
|
||||||
\endcode
|
* Vector2DInt32 test(1,2); //Declares a 2 dimensional Vector of type int32_t.
|
||||||
*/
|
* \endcode
|
||||||
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
class Vector
|
class Vector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///Constructor
|
/// Constructor
|
||||||
Vector(void);
|
Vector(void);
|
||||||
///Constructor.
|
/// Constructor.
|
||||||
Vector(StorageType tFillValue);
|
Vector(StorageType tFillValue);
|
||||||
///Constructor.
|
/// Constructor.
|
||||||
Vector(StorageType x, StorageType y);
|
Vector(StorageType x, StorageType y);
|
||||||
///Constructor.
|
/// Constructor.
|
||||||
Vector(StorageType x, StorageType y, StorageType z);
|
Vector(StorageType x, StorageType y, StorageType z);
|
||||||
///Constructor.
|
/// Constructor.
|
||||||
Vector(StorageType x, StorageType y, StorageType z, StorageType w);
|
Vector(StorageType x, StorageType y, StorageType z, StorageType w);
|
||||||
///Copy Constructor.
|
/// Copy Constructor.
|
||||||
Vector(const Vector<Size,StorageType,OperationType>& vector);
|
Vector(const Vector<Size,StorageType,OperationType>& vector);
|
||||||
///Copy Constructor which performs casting.
|
/// Copy Constructor which performs casting.
|
||||||
template <typename CastType> explicit Vector(const Vector<Size,CastType>& vector);
|
template <typename CastType> explicit Vector(const Vector<Size,CastType>& vector);
|
||||||
///Destructor.
|
/// Destructor.
|
||||||
~Vector(void);
|
~Vector(void);
|
||||||
|
|
||||||
///Assignment Operator.
|
/// Assignment Operator.
|
||||||
Vector<Size,StorageType,OperationType>& operator=(const Vector<Size,StorageType,OperationType>& rhs);
|
Vector<Size,StorageType,OperationType>& operator=(const Vector<Size,StorageType,OperationType>& rhs);
|
||||||
///Equality Operator.
|
/// Equality Operator.
|
||||||
bool operator==(const Vector<Size,StorageType,OperationType>& rhs) const;
|
bool operator==(const Vector<Size,StorageType,OperationType>& rhs) const;
|
||||||
///Inequality Operator.
|
/// Inequality Operator.
|
||||||
bool operator!=(const Vector<Size,StorageType,OperationType>& rhs) const;
|
bool operator!=(const Vector<Size,StorageType,OperationType>& rhs) const;
|
||||||
///Comparison Operator.
|
/// Comparison Operator.
|
||||||
bool operator<(const Vector<Size,StorageType,OperationType>& rhs) const;
|
POLYVOX_DEPRECATED bool operator<(const Vector<Size,StorageType,OperationType>& rhs) const;
|
||||||
///Addition and Assignment Operator.
|
/// Addition and Assignment Operator.
|
||||||
Vector<Size,StorageType,OperationType>& operator+=(const Vector<Size,StorageType,OperationType> &rhs);
|
Vector<Size,StorageType,OperationType>& operator+=(const Vector<Size,StorageType,OperationType> &rhs);
|
||||||
///Subtraction and Assignment Operator.
|
/// Subtraction and Assignment Operator.
|
||||||
Vector<Size,StorageType,OperationType>& operator-=(const Vector<Size,StorageType,OperationType> &rhs);
|
Vector<Size,StorageType,OperationType>& operator-=(const Vector<Size,StorageType,OperationType> &rhs);
|
||||||
///Multiplication and Assignment Operator.
|
/// Multiplication and Assignment Operator.
|
||||||
Vector<Size,StorageType,OperationType>& operator*=(const Vector<Size,StorageType,OperationType> &rhs);
|
Vector<Size,StorageType,OperationType>& operator*=(const Vector<Size,StorageType,OperationType> &rhs);
|
||||||
///Division and Assignment Operator.
|
/// Division and Assignment Operator.
|
||||||
Vector<Size,StorageType,OperationType>& operator/=(const Vector<Size,StorageType,OperationType> &rhs);
|
Vector<Size,StorageType,OperationType>& operator/=(const Vector<Size,StorageType,OperationType> &rhs);
|
||||||
///Multiplication and Assignment Operator.
|
/// Multiplication and Assignment Operator.
|
||||||
Vector<Size,StorageType,OperationType>& operator*=(const StorageType& rhs);
|
Vector<Size,StorageType,OperationType>& operator*=(const StorageType& rhs);
|
||||||
///Division and Assignment Operator.
|
/// Division and Assignment Operator.
|
||||||
Vector<Size,StorageType,OperationType>& operator/=(const StorageType& rhs);
|
Vector<Size,StorageType,OperationType>& operator/=(const StorageType& rhs);
|
||||||
|
|
||||||
///Element Access.
|
/// Element Access.
|
||||||
StorageType getElement(uint32_t index) const;
|
StorageType getElement(uint32_t index) const;
|
||||||
///Get the x component of the vector.
|
/// Get the x component of the vector.
|
||||||
StorageType getX(void) const;
|
StorageType getX(void) const;
|
||||||
///Get the y component of the vector.
|
/// Get the y component of the vector.
|
||||||
StorageType getY(void) const;
|
StorageType getY(void) const;
|
||||||
///Get the z component of the vector.
|
/// Get the z component of the vector.
|
||||||
StorageType getZ(void) const;
|
StorageType getZ(void) const;
|
||||||
///Get the w component of the vector.
|
/// Get the w component of the vector.
|
||||||
StorageType getW(void) const;
|
StorageType getW(void) const;
|
||||||
|
|
||||||
///Element Access.
|
/// Element Access.
|
||||||
void setElement(uint32_t index, StorageType tValue);
|
void setElement(uint32_t index, StorageType tValue);
|
||||||
///Element Access.
|
/// Element Access.
|
||||||
void setElements(StorageType x, StorageType y);
|
void setElements(StorageType x, StorageType y);
|
||||||
///Element Access.
|
/// Element Access.
|
||||||
void setElements(StorageType x, StorageType y, StorageType z);
|
void setElements(StorageType x, StorageType y, StorageType z);
|
||||||
///Element Access.
|
/// Element Access.
|
||||||
void setElements(StorageType x, StorageType y, StorageType z, StorageType w);
|
void setElements(StorageType x, StorageType y, StorageType z, StorageType w);
|
||||||
///Set the x component of the vector.
|
/// Set the x component of the vector.
|
||||||
void setX(StorageType tX);
|
void setX(StorageType tX);
|
||||||
///Set the y component of the vector.
|
/// Set the y component of the vector.
|
||||||
void setY(StorageType tY);
|
void setY(StorageType tY);
|
||||||
///Set the z component of the vector.
|
/// Set the z component of the vector.
|
||||||
void setZ(StorageType tZ);
|
void setZ(StorageType tZ);
|
||||||
///Set the w component of the vector.
|
/// Set the w component of the vector.
|
||||||
void setW(StorageType tW);
|
void setW(StorageType tW);
|
||||||
|
|
||||||
///Get the length of the vector.
|
/// Get the length of the vector.
|
||||||
float length(void) const;
|
float length(void) const;
|
||||||
///Get the squared length of the vector.
|
/// Get the squared length of the vector.
|
||||||
OperationType lengthSquared(void) const;
|
OperationType lengthSquared(void) const;
|
||||||
///Find the angle between this vector and that which is passed as a parameter.
|
/// Find the angle between this vector and that which is passed as a parameter.
|
||||||
float angleTo(const Vector<Size,StorageType,OperationType>& vector) const;
|
float angleTo(const Vector<Size,StorageType,OperationType>& vector) const;
|
||||||
///Find the cross product between this vector and the vector passed as a parameter.
|
/// Find the cross product between this vector and the vector passed as a parameter.
|
||||||
Vector<Size,StorageType,OperationType> cross(const Vector<Size,StorageType,OperationType>& vector) const;
|
Vector<Size,StorageType,OperationType> cross(const Vector<Size,StorageType,OperationType>& vector) const;
|
||||||
///Find the dot product between this vector and the vector passed as a parameter.
|
/// Find the dot product between this vector and the vector passed as a parameter.
|
||||||
OperationType dot(const Vector<Size,StorageType,OperationType>& rhs) const;
|
OperationType dot(const Vector<Size,StorageType,OperationType>& rhs) const;
|
||||||
///Normalise the vector.
|
/// Normalise the vector.
|
||||||
void normalise(void);
|
void normalise(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//Values for the vector
|
// Values for the vector
|
||||||
StorageType m_tElements[Size];
|
StorageType m_tElements[Size];
|
||||||
};
|
};
|
||||||
|
|
||||||
//Non-member overloaded operators.
|
// Non-member overloaded operators.
|
||||||
///Addition operator.
|
/// Addition operator.
|
||||||
template <uint32_t Size,typename StorageType,typename OperationType>
|
template <uint32_t Size,typename StorageType,typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator+(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs);
|
Vector<Size,StorageType,OperationType> operator+(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs);
|
||||||
///Subtraction operator.
|
/// Subtraction operator.
|
||||||
template <uint32_t Size,typename StorageType,typename OperationType>
|
template <uint32_t Size,typename StorageType,typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator-(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs);
|
Vector<Size,StorageType,OperationType> operator-(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs);
|
||||||
///Multiplication operator.
|
/// Multiplication operator.
|
||||||
template <uint32_t Size,typename StorageType,typename OperationType>
|
template <uint32_t Size,typename StorageType,typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs);
|
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs);
|
||||||
///Division operator.
|
/// Division operator.
|
||||||
template <uint32_t Size,typename StorageType,typename OperationType>
|
template <uint32_t Size,typename StorageType,typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs);
|
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs);
|
||||||
///Multiplication operator.
|
/// Multiplication operator.
|
||||||
template <uint32_t Size,typename StorageType,typename OperationType>
|
template <uint32_t Size,typename StorageType,typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs);
|
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs);
|
||||||
///Division operator.
|
/// Division operator.
|
||||||
template <uint32_t Size,typename StorageType,typename OperationType>
|
template <uint32_t Size,typename StorageType,typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs);
|
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs);
|
||||||
///Stream insertion operator.
|
/// Stream insertion operator.
|
||||||
template <uint32_t Size, typename StorageType,typename OperationType>
|
template <uint32_t Size, typename StorageType,typename OperationType>
|
||||||
std::ostream& operator<<(std::ostream& os, const Vector<Size,StorageType,OperationType>& vector);
|
std::ostream& operator<<(std::ostream& os, const Vector<Size,StorageType,OperationType>& vector);
|
||||||
|
|
||||||
//Some handy typedefs
|
//Some handy typedefs
|
||||||
|
|
||||||
///A 2D Vector of floats.
|
/// A 2D Vector of floats.
|
||||||
typedef Vector<2,float,float> Vector2DFloat;
|
typedef Vector<2,float,float> Vector2DFloat;
|
||||||
///A 2D Vector of doubles.
|
/// A 2D Vector of doubles.
|
||||||
typedef Vector<2,double,double> Vector2DDouble;
|
typedef Vector<2,double,double> Vector2DDouble;
|
||||||
///A 2D Vector of signed 8-bit values.
|
/// A 2D Vector of signed 8-bit values.
|
||||||
typedef Vector<2,int8_t,int32_t> Vector2DInt8;
|
typedef Vector<2,int8_t,int32_t> Vector2DInt8;
|
||||||
///A 2D Vector of unsigned 8-bit values.
|
/// A 2D Vector of unsigned 8-bit values.
|
||||||
typedef Vector<2,uint8_t,int32_t> Vector2DUint8;
|
typedef Vector<2,uint8_t,int32_t> Vector2DUint8;
|
||||||
///A 2D Vector of signed 16-bit values.
|
/// A 2D Vector of signed 16-bit values.
|
||||||
typedef Vector<2,int16_t,int32_t> Vector2DInt16;
|
typedef Vector<2,int16_t,int32_t> Vector2DInt16;
|
||||||
///A 2D Vector of unsigned 16-bit values.
|
/// A 2D Vector of unsigned 16-bit values.
|
||||||
typedef Vector<2,uint16_t,int32_t> Vector2DUint16;
|
typedef Vector<2,uint16_t,int32_t> Vector2DUint16;
|
||||||
///A 2D Vector of signed 32-bit values.
|
/// A 2D Vector of signed 32-bit values.
|
||||||
typedef Vector<2,int32_t,int32_t> Vector2DInt32;
|
typedef Vector<2,int32_t,int32_t> Vector2DInt32;
|
||||||
///A 2D Vector of unsigned 32-bit values.
|
/// A 2D Vector of unsigned 32-bit values.
|
||||||
typedef Vector<2,uint32_t,int32_t> Vector2DUint32;
|
typedef Vector<2,uint32_t,int32_t> Vector2DUint32;
|
||||||
|
|
||||||
///A 3D Vector of floats.
|
/// A 3D Vector of floats.
|
||||||
typedef Vector<3,float,float> Vector3DFloat;
|
typedef Vector<3,float,float> Vector3DFloat;
|
||||||
///A 3D Vector of doubles.
|
/// A 3D Vector of doubles.
|
||||||
typedef Vector<3,double,double> Vector3DDouble;
|
typedef Vector<3,double,double> Vector3DDouble;
|
||||||
///A 3D Vector of signed 8-bit values.
|
/// A 3D Vector of signed 8-bit values.
|
||||||
typedef Vector<3,int8_t,int32_t> Vector3DInt8;
|
typedef Vector<3,int8_t,int32_t> Vector3DInt8;
|
||||||
///A 3D Vector of unsigned 8-bit values.
|
/// A 3D Vector of unsigned 8-bit values.
|
||||||
typedef Vector<3,uint8_t,int32_t> Vector3DUint8;
|
typedef Vector<3,uint8_t,int32_t> Vector3DUint8;
|
||||||
///A 3D Vector of signed 16-bit values.
|
/// A 3D Vector of signed 16-bit values.
|
||||||
typedef Vector<3,int16_t,int32_t> Vector3DInt16;
|
typedef Vector<3,int16_t,int32_t> Vector3DInt16;
|
||||||
///A 3D Vector of unsigned 16-bit values.
|
/// A 3D Vector of unsigned 16-bit values.
|
||||||
typedef Vector<3,uint16_t,int32_t> Vector3DUint16;
|
typedef Vector<3,uint16_t,int32_t> Vector3DUint16;
|
||||||
///A 3D Vector of signed 32-bit values.
|
/// A 3D Vector of signed 32-bit values.
|
||||||
typedef Vector<3,int32_t,int32_t> Vector3DInt32;
|
typedef Vector<3,int32_t,int32_t> Vector3DInt32;
|
||||||
///A 3D Vector of unsigned 32-bit values.
|
/// A 3D Vector of unsigned 32-bit values.
|
||||||
typedef Vector<3,uint32_t,int32_t> Vector3DUint32;
|
typedef Vector<3,uint32_t,int32_t> Vector3DUint32;
|
||||||
|
|
||||||
///A 4D Vector of floats.
|
/// A 4D Vector of floats.
|
||||||
typedef Vector<4,float,float> Vector4DFloat;
|
typedef Vector<4,float,float> Vector4DFloat;
|
||||||
///A 4D Vector of doubles.
|
/// A 4D Vector of doubles.
|
||||||
typedef Vector<4,double,double> Vector4DDouble;
|
typedef Vector<4,double,double> Vector4DDouble;
|
||||||
///A 4D Vector of signed 8-bit values.
|
/// A 4D Vector of signed 8-bit values.
|
||||||
typedef Vector<4,int8_t,int32_t> Vector4DInt8;
|
typedef Vector<4,int8_t,int32_t> Vector4DInt8;
|
||||||
///A 4D Vector of unsigned 8-bit values.
|
/// A 4D Vector of unsigned 8-bit values.
|
||||||
typedef Vector<4,uint8_t,int32_t> Vector4DUint8;
|
typedef Vector<4,uint8_t,int32_t> Vector4DUint8;
|
||||||
///A 4D Vector of signed 16-bit values.
|
/// A 4D Vector of signed 16-bit values.
|
||||||
typedef Vector<4,int16_t,int32_t> Vector4DInt16;
|
typedef Vector<4,int16_t,int32_t> Vector4DInt16;
|
||||||
///A 4D Vector of unsigned 16-bit values.
|
/// A 4D Vector of unsigned 16-bit values.
|
||||||
typedef Vector<4,uint16_t,int32_t> Vector4DUint16;
|
typedef Vector<4,uint16_t,int32_t> Vector4DUint16;
|
||||||
///A 4D Vector of signed 32-bit values.
|
/// A 4D Vector of signed 32-bit values.
|
||||||
typedef Vector<4,int32_t,int32_t> Vector4DInt32;
|
typedef Vector<4,int32_t,int32_t> Vector4DInt32;
|
||||||
///A 4D Vector of unsigned 32-bit values.
|
/// A 4D Vector of unsigned 32-bit values.
|
||||||
typedef Vector<4,uint32_t,int32_t> Vector4DUint32;
|
typedef Vector<4,uint32_t,int32_t> Vector4DUint32;
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,17 +25,17 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
//-------------------------- Constructors, etc ---------------------------------
|
//-------------------------- Constructors, etc ---------------------------------
|
||||||
/**
|
/**
|
||||||
Creates a Vector object but does not initialise it.
|
* Creates a Vector object but does not initialise it.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
Vector<Size, StorageType, OperationType>::Vector(void)
|
Vector<Size, StorageType, OperationType>::Vector(void)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a Vector object and initialises it with given values.
|
* Creates a Vector object and initialises all components with the given value.
|
||||||
\param x x component to set.
|
* \param tFillValue The value to write to every component.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType>::Vector(StorageType tFillValue)
|
Vector<Size,StorageType,OperationType>::Vector(StorageType tFillValue)
|
||||||
{
|
{
|
||||||
@ -46,10 +46,10 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a Vector object and initialises it with given values.
|
* Creates a Vector object and initialises it with given values.
|
||||||
\param x x component to set.
|
* \param x The X component to set.
|
||||||
\param y y component to set.
|
* \param y The Y component to set.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y)
|
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y)
|
||||||
{
|
{
|
||||||
@ -62,11 +62,11 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a Vector3D object and initialises it with given values.
|
* Creates a Vector3D object and initialises it with given values.
|
||||||
\param x x component to set.
|
* \param x The X component to set.
|
||||||
\param y y component to set.
|
* \param y The Y component to set.
|
||||||
\param z z component to set.
|
* \param z the Z component to set.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z)
|
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z)
|
||||||
{
|
{
|
||||||
@ -81,12 +81,12 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a Vector3D object and initialises it with given values.
|
* Creates a Vector3D object and initialises it with given values.
|
||||||
\param x x component to set.
|
* \param x The X component to set.
|
||||||
\param y y component to set.
|
* \param y The Y component to set.
|
||||||
\param z z component to set.
|
* \param z The Z component to set.
|
||||||
\param w w component to set.
|
* \param w The W component to set.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z, StorageType w)
|
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z, StorageType w)
|
||||||
{
|
{
|
||||||
@ -101,9 +101,9 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Copy constructor builds object based on object passed as parameter.
|
* Copy constructor builds object based on object passed as parameter.
|
||||||
\param vector A reference to the Vector to be copied.
|
* \param vector A reference to the Vector to be copied.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
Vector<Size, StorageType, OperationType>::Vector(const Vector<Size, StorageType, OperationType>& vector)
|
Vector<Size, StorageType, OperationType>::Vector(const Vector<Size, StorageType, OperationType>& vector)
|
||||||
{
|
{
|
||||||
@ -111,14 +111,14 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This copy constructor allows casting between vectors with different data types.
|
* This copy constructor allows casting between vectors with different data types.
|
||||||
It is now possible to use code such as:
|
* It makes it possible to use code such as:
|
||||||
|
*
|
||||||
Vector3DDouble v3dDouble(1.0,2.0,3.0);
|
* Vector3DDouble v3dDouble(1.0,2.0,3.0);
|
||||||
Vector3DFloat v3dFloat = static_cast<Vector3DFloat>(v3dDouble); //Casting
|
* Vector3DFloat v3dFloat = static_cast<Vector3DFloat>(v3dDouble); //Casting
|
||||||
|
*
|
||||||
\param vector A reference to the Vector to be copied.
|
* \param vector A reference to the Vector to be copied.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
template <typename CastType>
|
template <typename CastType>
|
||||||
Vector<Size, StorageType, OperationType>::Vector(const Vector<Size, CastType>& vector)
|
Vector<Size, StorageType, OperationType>::Vector(const Vector<Size, CastType>& vector)
|
||||||
@ -130,8 +130,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Destroys the Vector.
|
* Destroys the Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
Vector<Size, StorageType, OperationType>::~Vector(void)
|
Vector<Size, StorageType, OperationType>::~Vector(void)
|
||||||
{
|
{
|
||||||
@ -146,10 +146,10 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Assignment operator copies each element of first Vector to the second.
|
* Assignment operator copies each element of first Vector to the second.
|
||||||
\param rhs Vector to assign to.
|
* \param rhs Vector to assign to.
|
||||||
\return A reference to the result to allow chaining.
|
* \return A reference to the result to allow chaining.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator=(const Vector<Size, StorageType, OperationType>& rhs)
|
Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator=(const Vector<Size, StorageType, OperationType>& rhs)
|
||||||
{
|
{
|
||||||
@ -162,11 +162,11 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Checks whether two Vectors are equal.
|
* Checks whether two Vectors are equal.
|
||||||
\param rhs The Vector to compare to.
|
* \param rhs The Vector to compare to.
|
||||||
\return true if the Vectors match.
|
* \return true if the Vectors match.
|
||||||
\see operator!=
|
* \see operator!=
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline bool Vector<Size, StorageType, OperationType>::operator==(const Vector<Size, StorageType, OperationType> &rhs) const
|
inline bool Vector<Size, StorageType, OperationType>::operator==(const Vector<Size, StorageType, OperationType> &rhs) const
|
||||||
{
|
{
|
||||||
@ -183,11 +183,11 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Checks whether two Vectors are not equal.
|
* Checks whether two Vectors are not equal.
|
||||||
\param rhs The Vector to compare to.
|
* \param rhs The Vector to compare to.
|
||||||
\return true if the Vectors do not match.
|
* \return true if the Vectors do not match.
|
||||||
\see operator==
|
* \see operator==
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline bool Vector<Size, StorageType, OperationType>::operator!=(const Vector<Size, StorageType, OperationType> &rhs) const
|
inline bool Vector<Size, StorageType, OperationType>::operator!=(const Vector<Size, StorageType, OperationType> &rhs) const
|
||||||
{
|
{
|
||||||
@ -195,12 +195,14 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Checks whether this vector is less than the parameter. The metric is
|
* Checks whether this vector is less than the parameter. The metric is
|
||||||
meaningless but it allows Vectors to me used as key in sdt::map, etc.
|
* meaningless but it allows Vectors to me used as key in sdt::map, etc.
|
||||||
\param rhs The Vector to compare to.
|
* This function is deprecated. You should specify a seperate comparator to the std:map if you need one.
|
||||||
\return true if this is less than the parameter
|
* \param rhs The Vector to compare to.
|
||||||
\see operator!=
|
* \return true if this is less than the parameter
|
||||||
*/
|
* \see operator!=
|
||||||
|
* \deprecated
|
||||||
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline bool Vector<Size, StorageType, OperationType>::operator<(const Vector<Size, StorageType, OperationType> &rhs) const
|
inline bool Vector<Size, StorageType, OperationType>::operator<(const Vector<Size, StorageType, OperationType> &rhs) const
|
||||||
{
|
{
|
||||||
@ -215,10 +217,10 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Addition operator adds corresponding elements of the two Vectors.
|
* Addition operator adds corresponding elements of the two Vectors.
|
||||||
\param rhs Vector to add
|
* \param rhs The Vector to add
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator+=(const Vector<Size, StorageType, OperationType>& rhs)
|
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator+=(const Vector<Size, StorageType, OperationType>& rhs)
|
||||||
{
|
{
|
||||||
@ -230,10 +232,10 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Subtraction operator subtracts corresponding elements of one Vector from the other.
|
* Subtraction operator subtracts corresponding elements of one Vector from the other.
|
||||||
\param rhs Vector to subtract
|
* \param rhs The Vector to subtract
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator-=(const Vector<Size, StorageType, OperationType>& rhs)
|
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator-=(const Vector<Size, StorageType, OperationType>& rhs)
|
||||||
{
|
{
|
||||||
@ -245,10 +247,10 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Multiplication operator multiplies corresponding elements of the two Vectors.
|
* Multiplication operator multiplies corresponding elements of the two Vectors.
|
||||||
\param rhs Vector to multiply by
|
* \param rhs The Vector to multiply by
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator*=(const Vector<Size, StorageType, OperationType>& rhs)
|
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator*=(const Vector<Size, StorageType, OperationType>& rhs)
|
||||||
{
|
{
|
||||||
@ -260,10 +262,10 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Division operator divides corresponding elements of one Vector by the other.
|
* Division operator divides corresponding elements of one Vector by the other.
|
||||||
\param rhs Vector to divide by
|
* \param rhs The Vector to divide by
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator/=(const Vector<Size, StorageType, OperationType>& rhs)
|
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator/=(const Vector<Size, StorageType, OperationType>& rhs)
|
||||||
{
|
{
|
||||||
@ -275,10 +277,10 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Multiplication operator multiplies each element of the Vector by a number.
|
* Multiplication operator multiplies each element of the Vector by a number.
|
||||||
\param rhs the number the Vector is multiplied by.
|
* \param rhs The number the Vector is multiplied by.
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator*=(const StorageType& rhs)
|
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator*=(const StorageType& rhs)
|
||||||
{
|
{
|
||||||
@ -290,10 +292,10 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Division operator divides each element of the Vector by a number.
|
* Division operator divides each element of the Vector by a number.
|
||||||
\param rhs the number the Vector is divided by.
|
* \param rhs The number the Vector is divided by.
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator/=(const StorageType& rhs)
|
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator/=(const StorageType& rhs)
|
||||||
{
|
{
|
||||||
@ -305,11 +307,11 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Addition operator adds corresponding elements of the two Vectors.
|
* Addition operator adds corresponding elements of the two Vectors.
|
||||||
\param lhs Vector to add to.
|
* \param lhs The Vector to add to.
|
||||||
\param rhs Vector to add.
|
* \param rhs The Vector to add.
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator+(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs)
|
Vector<Size,StorageType,OperationType> operator+(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs)
|
||||||
{
|
{
|
||||||
@ -319,11 +321,11 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Subtraction operator subtracts corresponding elements of one Vector from the other.
|
* Subtraction operator subtracts corresponding elements of one Vector from the other.
|
||||||
\param lhs Vector to subtract from.
|
* \param lhs The Vector to subtract from.
|
||||||
\param rhs Vector to subtract.
|
* \param rhs The Vector to subtract.
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator-(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs)
|
Vector<Size,StorageType,OperationType> operator-(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs)
|
||||||
{
|
{
|
||||||
@ -333,11 +335,11 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Multiplication operator mulitplies corresponding elements of the two Vectors.
|
* Multiplication operator mulitplies corresponding elements of the two Vectors.
|
||||||
\param lhs Vector to multiply.
|
* \param lhs The Vector to multiply.
|
||||||
\param rhs Vector to multiply by.
|
* \param rhs The Vector to multiply by.
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs)
|
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs)
|
||||||
{
|
{
|
||||||
@ -347,11 +349,11 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Division operator divides corresponding elements of one Vector by the other.
|
* Division operator divides corresponding elements of one Vector by the other.
|
||||||
\param lhs Vector to divide.
|
* \param lhs The Vector to divide.
|
||||||
\param rhs Vector to divide by.
|
* \param rhs The Vector to divide by.
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs)
|
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const Vector<Size,StorageType,OperationType>& rhs)
|
||||||
{
|
{
|
||||||
@ -361,11 +363,11 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Multiplication operator multiplies each element of the Vector by a number.
|
* Multiplication operator multiplies each element of the Vector by a number.
|
||||||
\param lhs the Vector to multiply.
|
* \param lhs The Vector to multiply.
|
||||||
\param rhs the number the Vector is multiplied by.
|
* \param rhs The number the Vector is multiplied by.
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs)
|
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs)
|
||||||
{
|
{
|
||||||
@ -375,11 +377,11 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Division operator divides each element of the Vector by a number.
|
* Division operator divides each element of the Vector by a number.
|
||||||
\param lhs the Vector to divide.
|
* \param lhs The Vector to divide.
|
||||||
\param rhs the number the Vector is divided by.
|
* \param rhs The number the Vector is divided by.
|
||||||
\return The resulting Vector.
|
* \return The resulting Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs)
|
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs)
|
||||||
{
|
{
|
||||||
@ -389,11 +391,11 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Enables the Vector to be used intuitively with output streams such as cout.
|
* Enables the Vector to be used intuitively with output streams such as cout.
|
||||||
\param os The output stream to write to.
|
* \param os The output stream to write to.
|
||||||
\param vector The Vector to write to the stream.
|
* \param vector The Vector to write to the stream.
|
||||||
\return A reference to the output stream to allow chaining.
|
* \return A reference to the output stream to allow chaining.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
std::ostream& operator<<(std::ostream& os, const Vector<Size, StorageType, OperationType>& vector)
|
std::ostream& operator<<(std::ostream& os, const Vector<Size, StorageType, OperationType>& vector)
|
||||||
{
|
{
|
||||||
@ -411,10 +413,10 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Returns the element at the given position.
|
* Returns the element at the given position.
|
||||||
\param index The index of the element to return.
|
* \param index The index of the element to return.
|
||||||
\return The element.
|
* \return The element.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline StorageType Vector<Size, StorageType, OperationType>::getElement(uint32_t index) const
|
inline StorageType Vector<Size, StorageType, OperationType>::getElement(uint32_t index) const
|
||||||
{
|
{
|
||||||
@ -423,8 +425,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\return A const reference to the X component of a 1, 2, 3, or 4 dimensional Vector.
|
* \return A const reference to the X component of a 1, 2, 3, or 4 dimensional Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline StorageType Vector<Size, StorageType, OperationType>::getX(void) const
|
inline StorageType Vector<Size, StorageType, OperationType>::getX(void) const
|
||||||
{
|
{
|
||||||
@ -432,8 +434,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\return A const reference to the Y component of a 2, 3, or 4 dimensional Vector.
|
* \return A const reference to the Y component of a 2, 3, or 4 dimensional Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline StorageType Vector<Size, StorageType, OperationType>::getY(void) const
|
inline StorageType Vector<Size, StorageType, OperationType>::getY(void) const
|
||||||
{
|
{
|
||||||
@ -441,8 +443,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\return A const reference to the Z component of a 3 or 4 dimensional Vector.
|
* \return A const reference to the Z component of a 3 or 4 dimensional Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline StorageType Vector<Size, StorageType, OperationType>::getZ(void) const
|
inline StorageType Vector<Size, StorageType, OperationType>::getZ(void) const
|
||||||
{
|
{
|
||||||
@ -454,8 +456,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\return A const reference to the W component of a 4 dimensional Vector.
|
* \return A const reference to the W component of a 4 dimensional Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline StorageType Vector<Size, StorageType, OperationType>::getW(void) const
|
inline StorageType Vector<Size, StorageType, OperationType>::getW(void) const
|
||||||
{
|
{
|
||||||
@ -467,9 +469,9 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\param index The index of the element to set.
|
* \param index The index of the element to set.
|
||||||
\param tValue The new value for the element.
|
* \param tValue The new value for the element.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size, StorageType, OperationType>::setElement(uint32_t index, StorageType tValue)
|
inline void Vector<Size, StorageType, OperationType>::setElement(uint32_t index, StorageType tValue)
|
||||||
{
|
{
|
||||||
@ -478,10 +480,10 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets several elements of a vector at once.
|
* Sets several elements of a vector at once.
|
||||||
\param x x component to set.
|
* \param x The X component to set.
|
||||||
\param y y component to set.
|
* \param y The Y component to set.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y)
|
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y)
|
||||||
{
|
{
|
||||||
@ -491,11 +493,11 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets several elements of a vector at once.
|
* Sets several elements of a vector at once.
|
||||||
\param x x component to set.
|
* \param x The X component to set.
|
||||||
\param y y component to set.
|
* \param y The Y component to set.
|
||||||
\param z z component to set.
|
* \param z The Z component to set.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z)
|
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z)
|
||||||
{
|
{
|
||||||
@ -508,12 +510,12 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets several elements of a vector at once.
|
* Sets several elements of a vector at once.
|
||||||
\param x x component to set.
|
* \param x The X component to set.
|
||||||
\param y y component to set.
|
* \param y The Y component to set.
|
||||||
\param z z component to set.
|
* \param z The Z component to set.
|
||||||
\param w w component to set.
|
* \param w The W component to set.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z, StorageType w)
|
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z, StorageType w)
|
||||||
{
|
{
|
||||||
@ -527,8 +529,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\param tX The new value for the X component of a 1, 2, 3, or 4 dimensional Vector.
|
* \param tX The new value for the X component of a 1, 2, 3, or 4 dimensional Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size, StorageType, OperationType>::setX(StorageType tX)
|
inline void Vector<Size, StorageType, OperationType>::setX(StorageType tX)
|
||||||
{
|
{
|
||||||
@ -536,8 +538,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\param tY The new value for the Y component of a 2, 3, or 4 dimensional Vector.
|
* \param tY The new value for the Y component of a 2, 3, or 4 dimensional Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size, StorageType, OperationType>::setY(StorageType tY)
|
inline void Vector<Size, StorageType, OperationType>::setY(StorageType tY)
|
||||||
{
|
{
|
||||||
@ -545,8 +547,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\param tZ The new value for the Z component of a 3 or 4 dimensional Vector.
|
* \param tZ The new value for the Z component of a 3 or 4 dimensional Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size, StorageType, OperationType>::setZ(StorageType tZ)
|
inline void Vector<Size, StorageType, OperationType>::setZ(StorageType tZ)
|
||||||
{
|
{
|
||||||
@ -557,8 +559,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\param tW The new value for the W component of a 4 dimensional Vector.
|
* \param tW The new value for the W component of a 4 dimensional Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size, StorageType, OperationType>::setW(StorageType tW)
|
inline void Vector<Size, StorageType, OperationType>::setW(StorageType tW)
|
||||||
{
|
{
|
||||||
@ -569,9 +571,9 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\note This function does not make much sense on integer Vectors.
|
* \note This function always returns a single precision floating point value, even when the StorageType is a double precision floating point value or an integer.
|
||||||
\return Length of the Vector.
|
* \return The length of the Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline float Vector<Size, StorageType, OperationType>::length(void) const
|
inline float Vector<Size, StorageType, OperationType>::length(void) const
|
||||||
{
|
{
|
||||||
@ -579,8 +581,8 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\return Squared length of the Vector.
|
* \return The squared length of the Vector.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline OperationType Vector<Size, StorageType, OperationType>::lengthSquared(void) const
|
inline OperationType Vector<Size, StorageType, OperationType>::lengthSquared(void) const
|
||||||
{
|
{
|
||||||
@ -593,14 +595,14 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function is commutative, such that a.angleTo(b) == b.angleTo(a). The angle
|
* This function is commutative, such that a.angleTo(b) == b.angleTo(a). The angle
|
||||||
returned is in radians and varies between 0 and 3.14(pi). It is always positive.
|
* returned is in radians and varies between 0 and 3.14(pi). It is always positive.
|
||||||
|
*
|
||||||
\note This function does not make much sense on integer Vectors.
|
* \note This function always returns a single precision floating point value, even when the StorageType is a double precision floating point value or an integer.
|
||||||
|
*
|
||||||
\param vector The Vector to find the angle to.
|
* \param vector The Vector to find the angle to.
|
||||||
\return The angle between them in radians.
|
* \return The angle between them in radians.
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline float Vector<Size, StorageType, OperationType>::angleTo(const Vector<Size, StorageType, OperationType>& vector) const
|
inline float Vector<Size, StorageType, OperationType>::angleTo(const Vector<Size, StorageType, OperationType>& vector) const
|
||||||
{
|
{
|
||||||
@ -608,17 +610,17 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
This function is used to calculate the cross product of two Vectors.
|
* This function is used to calculate the cross product of two Vectors.
|
||||||
The cross product is the Vector which is perpendicular to the two
|
* The cross product is the Vector which is perpendicular to the two
|
||||||
given Vectors. It is worth remembering that, unlike the dot product,
|
* given Vectors. It is worth remembering that, unlike the dot product,
|
||||||
it is not commutative. E.g a.b != b.a. The cross product obeys the
|
* it is not commutative. E.g a.b != b.a. The cross product obeys the
|
||||||
right-hand rule such that if the two vectors are given by the index
|
* right-hand rule such that if the two vectors are given by the index
|
||||||
finger and middle finger respectively then the cross product is given
|
* finger and middle finger respectively then the cross product is given
|
||||||
by the thumb.
|
* by the thumb.
|
||||||
\param vector The vector to cross with this
|
* \param vector The vector to cross with this
|
||||||
\return The value of the cross product.
|
* \return The value of the cross product.
|
||||||
\see dot()
|
* \see dot()
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline Vector<Size, StorageType, OperationType> Vector<Size, StorageType, OperationType>::cross(const Vector<Size, StorageType, OperationType>& vector) const
|
inline Vector<Size, StorageType, OperationType> Vector<Size, StorageType, OperationType>::cross(const Vector<Size, StorageType, OperationType>& vector) const
|
||||||
{
|
{
|
||||||
@ -629,12 +631,12 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Calculates the dot product of the Vector and the parameter.
|
* Calculates the dot product of the Vector and the parameter.
|
||||||
This function is commutative, such that a.dot(b) == b.dot(a).
|
* This function is commutative, such that a.dot(b) == b.dot(a).
|
||||||
\param rhs The Vector to find the dot product with.
|
* \param rhs The Vector to find the dot product with.
|
||||||
\return The value of the dot product.
|
* \return The value of the dot product.
|
||||||
\see cross()
|
* \see cross()
|
||||||
*/
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline OperationType Vector<Size, StorageType, OperationType>::dot(const Vector<Size, StorageType, OperationType>& rhs) const
|
inline OperationType Vector<Size, StorageType, OperationType>::dot(const Vector<Size, StorageType, OperationType>& rhs) const
|
||||||
{
|
{
|
||||||
@ -647,22 +649,21 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Divides the i, j, and k components by the length to give a Vector of length 1.0.
|
* Divides the i, j, and k components by the length to give a Vector of length 1.0. If the vector is
|
||||||
|
* very short (or zero) then a divide by zero may cause elements to take on invalid values. You may
|
||||||
\note This function does not make much sense on integer Vectors.
|
* want to check for this before normalising.
|
||||||
*/
|
*
|
||||||
|
* \note You should not attempt to normalise a vector whose StorageType is an integer.
|
||||||
|
*/
|
||||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||||
inline void Vector<Size, StorageType, OperationType>::normalise(void)
|
inline void Vector<Size, StorageType, OperationType>::normalise(void)
|
||||||
{
|
{
|
||||||
StorageType tLength = static_cast<StorageType>(this->length());
|
float fLength = this->length();
|
||||||
//FIXME - throw div by zero exception?
|
|
||||||
if(tLength < 0.0001f)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for(uint32_t ct = 0; ct < Size; ++ct)
|
for(uint32_t ct = 0; ct < Size; ++ct)
|
||||||
{
|
{
|
||||||
m_tElements[ct] /= tLength;
|
// Standard float rules apply for divide-by-zero
|
||||||
|
m_tElements[ct] /= fLength;
|
||||||
|
assert(m_tElements[ct] == m_tElements[ct]); //Will assert if NAN
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//namespace PolyVox
|
}//namespace PolyVox
|
||||||
|
@ -28,30 +28,30 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
const Region Region::MaxRegion
|
const Region Region::MaxRegion
|
||||||
(
|
(
|
||||||
Vector3DInt32((std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)()),
|
Vector3DInt32((std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)()),
|
||||||
Vector3DInt32((std::numeric_limits<int32_t>::max)(), (std::numeric_limits<int32_t>::max)(), (std::numeric_limits<int32_t>::max)())
|
Vector3DInt32((std::numeric_limits<int32_t>::max)(), (std::numeric_limits<int32_t>::max)(), (std::numeric_limits<int32_t>::max)())
|
||||||
);
|
);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// This Region is not considered valid as defined by isValid(). It's main application
|
* This Region is not considered valid as defined by isValid(). It's main application
|
||||||
/// is to initialise a Region to this value and then() accumulate positions. The result
|
* is to initialise a Region to this value and then() accumulate positions. The result
|
||||||
/// of this will be a Region which encompasses all positions specified.
|
* of this will be a Region which encompasses all positions specified.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
const Region Region::InvertedRegion
|
const Region Region::InvertedRegion
|
||||||
(
|
(
|
||||||
Vector3DInt32((std::numeric_limits<int32_t>::max)(), (std::numeric_limits<int32_t>::max)(), (std::numeric_limits<int32_t>::max)()),
|
Vector3DInt32((std::numeric_limits<int32_t>::max)(), (std::numeric_limits<int32_t>::max)(), (std::numeric_limits<int32_t>::max)()),
|
||||||
Vector3DInt32((std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)())
|
Vector3DInt32((std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)())
|
||||||
);
|
);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param iX The 'x' component of the position to accumulate.
|
* \param iX The 'x' component of the position to accumulate.
|
||||||
/// \param iY The 'y' component of the position to accumulate.
|
* \param iY The 'y' component of the position to accumulate.
|
||||||
/// \param iZ The 'z' component of the position to accumulate.
|
* \param iZ The 'z' component of the position to accumulate.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::accumulate(int32_t iX, int32_t iY, int32_t iZ)
|
void Region::accumulate(int32_t iX, int32_t iY, int32_t iZ)
|
||||||
{
|
{
|
||||||
m_iLowerX = ((std::min)(m_iLowerX, iX));
|
m_iLowerX = ((std::min)(m_iLowerX, iX));
|
||||||
@ -62,21 +62,21 @@ namespace PolyVox
|
|||||||
m_iUpperZ = ((std::max)(m_iUpperZ, iZ));
|
m_iUpperZ = ((std::max)(m_iUpperZ, iZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param v3dPos The position to accumulate.
|
* \param v3dPos The position to accumulate.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::accumulate(const Vector3DInt32& v3dPos)
|
void Region::accumulate(const Vector3DInt32& v3dPos)
|
||||||
{
|
{
|
||||||
accumulate(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
|
accumulate(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// Note that this is not the same as computing the union of two Regions (as the result of
|
* Note that this is not the same as computing the union of two Regions (as the result of
|
||||||
/// such a union may not be a shape which can be exactly represented by a Region). Instead,
|
* such a union may not be a shape which can be exactly represented by a Region). Instead,
|
||||||
/// the result is simply big enough to contain both this Region and the one passed as a parameter.
|
* the result is simply big enough to contain both this Region and the one passed as a parameter.
|
||||||
/// \param reg The Region to accumulate. This must be valid as defined by the isValid() function.
|
* \param reg The Region to accumulate. This must be valid as defined by the isValid() function.
|
||||||
/// \sa isValid()
|
* \sa isValid()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::accumulate(const Region& reg)
|
void Region::accumulate(const Region& reg)
|
||||||
{
|
{
|
||||||
assert(reg.isValid()); //The result of accumulating an invalid region is not defined.
|
assert(reg.isValid()); //The result of accumulating an invalid region is not defined.
|
||||||
@ -89,9 +89,9 @@ namespace PolyVox
|
|||||||
m_iUpperZ = ((std::max)(m_iUpperZ, reg.getUpperZ()));
|
m_iUpperZ = ((std::max)(m_iUpperZ, reg.getUpperZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// Constructs a Region and clears all extents to zero.
|
* Constructs a Region and clears all extents to zero.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
Region::Region()
|
Region::Region()
|
||||||
:m_iLowerX(0)
|
:m_iLowerX(0)
|
||||||
,m_iLowerY(0)
|
,m_iLowerY(0)
|
||||||
@ -102,11 +102,11 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// Constructs a Region and sets the lower and upper corners to the specified values.
|
* Constructs a Region and sets the lower and upper corners to the specified values.
|
||||||
/// \param v3dLowerCorner The desired lower corner of the Region.
|
* \param v3dLowerCorner The desired lower corner of the Region.
|
||||||
/// \param v3dUpperCorner The desired upper corner of the Region.
|
* \param v3dUpperCorner The desired upper corner of the Region.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
Region::Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner)
|
Region::Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner)
|
||||||
:m_iLowerX(v3dLowerCorner.getX())
|
:m_iLowerX(v3dLowerCorner.getX())
|
||||||
,m_iLowerY(v3dLowerCorner.getY())
|
,m_iLowerY(v3dLowerCorner.getY())
|
||||||
@ -117,15 +117,15 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// Constructs a Region and sets the extents to the specified values.
|
* Constructs a Region and sets the extents to the specified values.
|
||||||
/// \param iLowerX The desired lower 'x' extent of the Region.
|
* \param iLowerX The desired lower 'x' extent of the Region.
|
||||||
/// \param iLowerY The desired lower 'y' extent of the Region.
|
* \param iLowerY The desired lower 'y' extent of the Region.
|
||||||
/// \param iLowerZ The desired lower 'z' extent of the Region.
|
* \param iLowerZ The desired lower 'z' extent of the Region.
|
||||||
/// \param iUpperX The desired upper 'x' extent of the Region.
|
* \param iUpperX The desired upper 'x' extent of the Region.
|
||||||
/// \param iUpperY The desired upper 'y' extent of the Region.
|
* \param iUpperY The desired upper 'y' extent of the Region.
|
||||||
/// \param iUpperZ The desired upper 'z' extent of the Region.
|
* \param iUpperZ The desired upper 'z' extent of the Region.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
Region::Region(int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ)
|
Region::Region(int32_t iLowerX, int32_t iLowerY, int32_t iLowerZ, int32_t iUpperX, int32_t iUpperY, int32_t iUpperZ)
|
||||||
:m_iLowerX(iLowerX)
|
:m_iLowerX(iLowerX)
|
||||||
,m_iLowerY(iLowerY)
|
,m_iLowerY(iLowerY)
|
||||||
@ -136,12 +136,12 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// Two regions are considered equal if all their extents match.
|
* Two regions are considered equal if all their extents match.
|
||||||
/// \param rhs The Region to compare to.
|
* \param rhs The Region to compare to.
|
||||||
/// \return true if the Regions match.
|
* \return true if the Regions match.
|
||||||
/// \sa operator!=
|
* \sa operator!=
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::operator==(const Region& rhs) const
|
bool Region::operator==(const Region& rhs) const
|
||||||
{
|
{
|
||||||
return ((m_iLowerX == rhs.m_iLowerX) && (m_iLowerY == rhs.m_iLowerY) && (m_iLowerZ == rhs.m_iLowerZ)
|
return ((m_iLowerX == rhs.m_iLowerX) && (m_iLowerY == rhs.m_iLowerY) && (m_iLowerZ == rhs.m_iLowerZ)
|
||||||
@ -159,15 +159,15 @@ namespace PolyVox
|
|||||||
return !(*this == rhs);
|
return !(*this == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The boundary value can be used to ensure a position is only considered to be inside
|
* The boundary value can be used to ensure a position is only considered to be inside
|
||||||
/// the Region if it is that far in in all directions. Also, the test is inclusive such
|
* the Region if it is that far in in all directions. Also, the test is inclusive such
|
||||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||||
/// \param fX The 'x' position of the point to test.
|
* \param fX The 'x' position of the point to test.
|
||||||
/// \param fY The 'y' position of the point to test.
|
* \param fY The 'y' position of the point to test.
|
||||||
/// \param fZ The 'z' position of the point to test.
|
* \param fZ The 'z' position of the point to test.
|
||||||
/// \param boundary The desired boundary value.
|
* \param boundary The desired boundary value.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::containsPoint(float fX, float fY, float fZ, float boundary) const
|
bool Region::containsPoint(float fX, float fY, float fZ, float boundary) const
|
||||||
{
|
{
|
||||||
return (fX <= m_iUpperX - boundary)
|
return (fX <= m_iUpperX - boundary)
|
||||||
@ -178,27 +178,27 @@ namespace PolyVox
|
|||||||
&& (fZ >= m_iLowerZ + boundary);
|
&& (fZ >= m_iLowerZ + boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The boundary value can be used to ensure a position is only considered to be inside
|
* The boundary value can be used to ensure a position is only considered to be inside
|
||||||
/// the Region if it is that far in in all directions. Also, the test is inclusive such
|
* the Region if it is that far in in all directions. Also, the test is inclusive such
|
||||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||||
/// \param pos The position of the point to test.
|
* \param pos The position to test.
|
||||||
/// \param boundary The desired boundary value.
|
* \param boundary The desired boundary value.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::containsPoint(const Vector3DFloat& pos, float boundary) const
|
bool Region::containsPoint(const Vector3DFloat& pos, float boundary) const
|
||||||
{
|
{
|
||||||
return containsPoint(pos.getX(), pos.getY(), pos.getZ(), boundary);
|
return containsPoint(pos.getX(), pos.getY(), pos.getZ(), boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The boundary value can be used to ensure a position is only considered to be inside
|
* The boundary value can be used to ensure a position is only considered to be inside
|
||||||
/// the Region if it is that far in in all directions. Also, the test is inclusive such
|
* the Region if it is that far in in all directions. Also, the test is inclusive such
|
||||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||||
/// \param iX The 'x' position of the point to test.
|
* \param iX The 'x' position of the point to test.
|
||||||
/// \param iY The 'y' position of the point to test.
|
* \param iY The 'y' position of the point to test.
|
||||||
/// \param iZ The 'z' position of the point to test.
|
* \param iZ The 'z' position of the point to test.
|
||||||
/// \param boundary The desired boundary value.
|
* \param boundary The desired boundary value.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::containsPoint(int32_t iX, int32_t iY, int32_t iZ, uint8_t boundary) const
|
bool Region::containsPoint(int32_t iX, int32_t iY, int32_t iZ, uint8_t boundary) const
|
||||||
{
|
{
|
||||||
return (iX <= m_iUpperX - boundary)
|
return (iX <= m_iUpperX - boundary)
|
||||||
@ -209,101 +209,101 @@ namespace PolyVox
|
|||||||
&& (iZ >= m_iLowerZ + boundary);
|
&& (iZ >= m_iLowerZ + boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The boundary value can be used to ensure a position is only considered to be inside
|
* The boundary value can be used to ensure a position is only considered to be inside
|
||||||
/// the Region if it is that far in in all directions. Also, the test is inclusive such
|
* the Region if it is that far in in all directions. Also, the test is inclusive such
|
||||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||||
/// \param pos The position of the point to test.
|
* \param pos The position to test.
|
||||||
/// \param boundary The desired boundary value.
|
* \param boundary The desired boundary value.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::containsPoint(const Vector3DInt32& pos, uint8_t boundary) const
|
bool Region::containsPoint(const Vector3DInt32& pos, uint8_t boundary) const
|
||||||
{
|
{
|
||||||
return containsPoint(pos.getX(), pos.getY(), pos.getZ(), boundary);
|
return containsPoint(pos.getX(), pos.getY(), pos.getZ(), boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The boundary value can be used to ensure a position is only considered to be inside
|
* The boundary value can be used to ensure a position is only considered to be inside
|
||||||
/// the Region if it is that far in in the 'x' direction. Also, the test is inclusive such
|
* the Region if it is that far in in the 'x' direction. Also, the test is inclusive such
|
||||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||||
/// \param pos The position to test.
|
* \param pos The position to test.
|
||||||
/// \param boundary The desired boundary value.
|
* \param boundary The desired boundary value.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::containsPointInX(float pos, float boundary) const
|
bool Region::containsPointInX(float pos, float boundary) const
|
||||||
{
|
{
|
||||||
return (pos <= m_iUpperX - boundary)
|
return (pos <= m_iUpperX - boundary)
|
||||||
&& (pos >= m_iLowerX + boundary);
|
&& (pos >= m_iLowerX + boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The boundary value can be used to ensure a position is only considered to be inside
|
* The boundary value can be used to ensure a position is only considered to be inside
|
||||||
/// the Region if it is that far in in the 'x' direction. Also, the test is inclusive such
|
* the Region if it is that far in in the 'x' direction. Also, the test is inclusive such
|
||||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||||
/// \param pos The position to test.
|
* \param pos The position to test.
|
||||||
/// \param boundary The desired boundary value.
|
* \param boundary The desired boundary value.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::containsPointInX(int32_t pos, uint8_t boundary) const
|
bool Region::containsPointInX(int32_t pos, uint8_t boundary) const
|
||||||
{
|
{
|
||||||
return (pos <= m_iUpperX - boundary)
|
return (pos <= m_iUpperX - boundary)
|
||||||
&& (pos >= m_iLowerX + boundary);
|
&& (pos >= m_iLowerX + boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The boundary value can be used to ensure a position is only considered to be inside
|
* The boundary value can be used to ensure a position is only considered to be inside
|
||||||
/// the Region if it is that far in in the 'y' direction. Also, the test is inclusive such
|
* the Region if it is that far in in the 'y' direction. Also, the test is inclusive such
|
||||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||||
/// \param pos The position to test.
|
* \param pos The position to test.
|
||||||
/// \param boundary The desired boundary value.
|
* \param boundary The desired boundary value.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::containsPointInY(float pos, float boundary) const
|
bool Region::containsPointInY(float pos, float boundary) const
|
||||||
{
|
{
|
||||||
return (pos <= m_iUpperY - boundary)
|
return (pos <= m_iUpperY - boundary)
|
||||||
&& (pos >= m_iLowerY + boundary);
|
&& (pos >= m_iLowerY + boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The boundary value can be used to ensure a position is only considered to be inside
|
* The boundary value can be used to ensure a position is only considered to be inside
|
||||||
/// the Region if it is that far in in the 'y' direction. Also, the test is inclusive such
|
* the Region if it is that far in in the 'y' direction. Also, the test is inclusive such
|
||||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||||
/// \param pos The position to test.
|
* \param pos The position to test.
|
||||||
/// \param boundary The desired boundary value.
|
* \param boundary The desired boundary value.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::containsPointInY(int32_t pos, uint8_t boundary) const
|
bool Region::containsPointInY(int32_t pos, uint8_t boundary) const
|
||||||
{
|
{
|
||||||
return (pos <= m_iUpperY - boundary)
|
return (pos <= m_iUpperY - boundary)
|
||||||
&& (pos >= m_iLowerY + boundary);
|
&& (pos >= m_iLowerY + boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The boundary value can be used to ensure a position is only considered to be inside
|
* The boundary value can be used to ensure a position is only considered to be inside
|
||||||
/// the Region if it is that far in in the 'z' direction. Also, the test is inclusive such
|
* the Region if it is that far in in the 'z' direction. Also, the test is inclusive such
|
||||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||||
/// \param pos The position to test.
|
* \param pos The position to test.
|
||||||
/// \param boundary The desired boundary value.
|
* \param boundary The desired boundary value.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::containsPointInZ(float pos, float boundary) const
|
bool Region::containsPointInZ(float pos, float boundary) const
|
||||||
{
|
{
|
||||||
return (pos <= m_iUpperZ - boundary)
|
return (pos <= m_iUpperZ - boundary)
|
||||||
&& (pos >= m_iLowerZ + boundary);
|
&& (pos >= m_iLowerZ + boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The boundary value can be used to ensure a position is only considered to be inside
|
* The boundary value can be used to ensure a position is only considered to be inside
|
||||||
/// the Region if it is that far in in the 'z' direction. Also, the test is inclusive such
|
* the Region if it is that far in in the 'z' direction. Also, the test is inclusive such
|
||||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||||
/// \param pos The position to test.
|
* \param pos The position to test.
|
||||||
/// \param boundary The desired boundary value.
|
* \param boundary The desired boundary value.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::containsPointInZ(int32_t pos, uint8_t boundary) const
|
bool Region::containsPointInZ(int32_t pos, uint8_t boundary) const
|
||||||
{
|
{
|
||||||
return (pos <= m_iUpperZ - boundary)
|
return (pos <= m_iUpperZ - boundary)
|
||||||
&& (pos >= m_iLowerZ + boundary);
|
&& (pos >= m_iLowerZ + boundary);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// After calling this functions, the extents of this Region are given by the intersection
|
* After calling this functions, the extents of this Region are given by the intersection
|
||||||
/// of this Region and the one it was cropped to.
|
* of this Region and the one it was cropped to.
|
||||||
/// \param other The Region to crop to.
|
* \param other The Region to crop to.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::cropTo(const Region& other)
|
void Region::cropTo(const Region& other)
|
||||||
{
|
{
|
||||||
m_iLowerX = ((std::max)(m_iLowerX, other.m_iLowerX));
|
m_iLowerX = ((std::max)(m_iLowerX, other.m_iLowerX));
|
||||||
@ -314,11 +314,11 @@ namespace PolyVox
|
|||||||
m_iUpperZ = ((std::min)(m_iUpperZ, other.m_iUpperZ));
|
m_iUpperZ = ((std::min)(m_iUpperZ, other.m_iUpperZ));
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The same amount of growth is applied in all directions. Negative growth
|
* The same amount of growth is applied in all directions. Negative growth
|
||||||
/// is possible but you should prefer the shrink() function for clarity.
|
* is possible but you should prefer the shrink() function for clarity.
|
||||||
/// \param iAmount The amount to grow by.
|
* \param iAmount The amount to grow by.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::grow(int32_t iAmount)
|
void Region::grow(int32_t iAmount)
|
||||||
{
|
{
|
||||||
m_iLowerX -= iAmount;
|
m_iLowerX -= iAmount;
|
||||||
@ -330,13 +330,13 @@ namespace PolyVox
|
|||||||
m_iUpperZ += iAmount;
|
m_iUpperZ += iAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The amount can be specified seperatly for each direction. Negative growth
|
* The amount can be specified seperatly for each direction. Negative growth
|
||||||
/// is possible but you should prefer the shrink() function for clarity.
|
* is possible but you should prefer the shrink() function for clarity.
|
||||||
/// \param iAmountX The amount to grow by in 'x'.
|
* \param iAmountX The amount to grow by in 'x'.
|
||||||
/// \param iAmountY The amount to grow by in 'y'.
|
* \param iAmountY The amount to grow by in 'y'.
|
||||||
/// \param iAmountZ The amount to grow by in 'z'.
|
* \param iAmountZ The amount to grow by in 'z'.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::grow(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
void Region::grow(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
||||||
{
|
{
|
||||||
m_iLowerX -= iAmountX;
|
m_iLowerX -= iAmountX;
|
||||||
@ -348,48 +348,48 @@ namespace PolyVox
|
|||||||
m_iUpperZ += iAmountZ;
|
m_iUpperZ += iAmountZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The amount can be specified seperatly for each direction. Negative growth
|
* The amount can be specified seperatly for each direction. Negative growth
|
||||||
/// is possible but you should prefer the shrink() function for clarity.
|
* is possible but you should prefer the shrink() function for clarity.
|
||||||
/// \param v3dAmount The amount to grow by (one component for each direction).
|
* \param v3dAmount The amount to grow by (one component for each direction).
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::grow(const Vector3DInt32& v3dAmount)
|
void Region::grow(const Vector3DInt32& v3dAmount)
|
||||||
{
|
{
|
||||||
grow(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
grow(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
bool Region::isValid(void) const
|
bool Region::isValid(void) const
|
||||||
{
|
{
|
||||||
return (m_iUpperX >= m_iLowerX) && (m_iUpperY >= m_iLowerY) && (m_iUpperZ >= m_iLowerZ);
|
return (m_iUpperX >= m_iLowerX) && (m_iUpperY >= m_iLowerY) && (m_iUpperZ >= m_iLowerZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param iAmountX The amount to move the Region by in 'x'.
|
* \param iAmountX The amount to move the Region by in 'x'.
|
||||||
/// \param iAmountY The amount to move the Region by in 'y'.
|
* \param iAmountY The amount to move the Region by in 'y'.
|
||||||
/// \param iAmountZ The amount to move the Region by in 'z'.
|
* \param iAmountZ The amount to move the Region by in 'z'.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::shift(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
void Region::shift(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
||||||
{
|
{
|
||||||
shiftLowerCorner(iAmountX, iAmountY, iAmountZ);
|
shiftLowerCorner(iAmountX, iAmountY, iAmountZ);
|
||||||
shiftUpperCorner(iAmountX, iAmountY, iAmountZ);
|
shiftUpperCorner(iAmountX, iAmountY, iAmountZ);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param v3dAmount The amount to move the Region by.
|
* \param v3dAmount The amount to move the Region by.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::shift(const Vector3DInt32& v3dAmount)
|
void Region::shift(const Vector3DInt32& v3dAmount)
|
||||||
{
|
{
|
||||||
shiftLowerCorner(v3dAmount);
|
shiftLowerCorner(v3dAmount);
|
||||||
shiftUpperCorner(v3dAmount);
|
shiftUpperCorner(v3dAmount);
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param iAmountX The amount to move the lower corner by in 'x'.
|
* \param iAmountX The amount to move the lower corner by in 'x'.
|
||||||
/// \param iAmountY The amount to move the lower corner by in 'y'.
|
* \param iAmountY The amount to move the lower corner by in 'y'.
|
||||||
/// \param iAmountZ The amount to move the lower corner by in 'z'.
|
* \param iAmountZ The amount to move the lower corner by in 'z'.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::shiftLowerCorner(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
void Region::shiftLowerCorner(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
||||||
{
|
{
|
||||||
m_iLowerX += iAmountX;
|
m_iLowerX += iAmountX;
|
||||||
@ -397,19 +397,19 @@ namespace PolyVox
|
|||||||
m_iLowerZ += iAmountZ;
|
m_iLowerZ += iAmountZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param v3dAmount The amount to move the lower corner by.
|
* \param v3dAmount The amount to move the lower corner by.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::shiftLowerCorner(const Vector3DInt32& v3dAmount)
|
void Region::shiftLowerCorner(const Vector3DInt32& v3dAmount)
|
||||||
{
|
{
|
||||||
shiftLowerCorner(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
shiftLowerCorner(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param iAmountX The amount to move the upper corner by in 'x'.
|
* \param iAmountX The amount to move the upper corner by in 'x'.
|
||||||
/// \param iAmountY The amount to move the upper corner by in 'y'.
|
* \param iAmountY The amount to move the upper corner by in 'y'.
|
||||||
/// \param iAmountZ The amount to move the upper corner by in 'z'.
|
* \param iAmountZ The amount to move the upper corner by in 'z'.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::shiftUpperCorner(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
void Region::shiftUpperCorner(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
||||||
{
|
{
|
||||||
m_iUpperX += iAmountX;
|
m_iUpperX += iAmountX;
|
||||||
@ -417,19 +417,19 @@ namespace PolyVox
|
|||||||
m_iUpperZ += iAmountZ;
|
m_iUpperZ += iAmountZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// \param v3dAmount The amount to move the upper corner by.
|
* \param v3dAmount The amount to move the upper corner by.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::shiftUpperCorner(const Vector3DInt32& v3dAmount)
|
void Region::shiftUpperCorner(const Vector3DInt32& v3dAmount)
|
||||||
{
|
{
|
||||||
shiftUpperCorner(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
shiftUpperCorner(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The same amount of shrinkage is applied in all directions. Negative shrinkage
|
* The same amount of shrinkage is applied in all directions. Negative shrinkage
|
||||||
/// is possible but you should prefer the grow() function for clarity.
|
* is possible but you should prefer the grow() function for clarity.
|
||||||
/// \param iAmount The amount to shrink by.
|
* \param iAmount The amount to shrink by.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::shrink(int32_t iAmount)
|
void Region::shrink(int32_t iAmount)
|
||||||
{
|
{
|
||||||
m_iLowerX += iAmount;
|
m_iLowerX += iAmount;
|
||||||
@ -441,13 +441,13 @@ namespace PolyVox
|
|||||||
m_iUpperZ -= iAmount;
|
m_iUpperZ -= iAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The amount can be specified seperatly for each direction. Negative shrinkage
|
* The amount can be specified seperatly for each direction. Negative shrinkage
|
||||||
/// is possible but you should prefer the grow() function for clarity.
|
* is possible but you should prefer the grow() function for clarity.
|
||||||
/// \param iAmountX The amount to shrink by in 'x'.
|
* \param iAmountX The amount to shrink by in 'x'.
|
||||||
/// \param iAmountY The amount to shrink by in 'y'.
|
* \param iAmountY The amount to shrink by in 'y'.
|
||||||
/// \param iAmountZ The amount to shrink by in 'z'.
|
* \param iAmountZ The amount to shrink by in 'z'.
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::shrink(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
void Region::shrink(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
||||||
{
|
{
|
||||||
m_iLowerX += iAmountX;
|
m_iLowerX += iAmountX;
|
||||||
@ -459,11 +459,11 @@ namespace PolyVox
|
|||||||
m_iUpperZ -= iAmountZ;
|
m_iUpperZ -= iAmountZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
/**
|
||||||
/// The amount can be specified seperatly for each direction. Negative shrinkage
|
* The amount can be specified seperatly for each direction. Negative shrinkage
|
||||||
/// is possible but you should prefer the grow() function for clarity.
|
* is possible but you should prefer the grow() function for clarity.
|
||||||
/// \param v3dAmount The amount to shrink by (one component for each direction).
|
* \param v3dAmount The amount to shrink by (one component for each direction).
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
*/
|
||||||
void Region::shrink(const Vector3DInt32& v3dAmount)
|
void Region::shrink(const Vector3DInt32& v3dAmount)
|
||||||
{
|
{
|
||||||
shrink(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
shrink(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user