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).
|
||||
|
||||
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
|
||||
--------------------
|
||||
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.
|
||||
|
||||
|
||||
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
|
||||
===============================
|
||||
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;
|
||||
|
||||
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
|
||||
{
|
||||
|
||||
@ -71,8 +87,8 @@ class OpenGLWidget : public QGLWidget
|
||||
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
|
||||
std::map<PolyVox::Vector3DUint8, OpenGLSurfaceMesh> m_mapOpenGLSurfaceMeshes;
|
||||
std::map<PolyVox::Vector3DUint8, polyvox_shared_ptr<PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> > > m_mapSurfaceMeshes;
|
||||
std::map<PolyVox::Vector3DUint8, OpenGLSurfaceMesh, Vector3DUint8Compare> m_mapOpenGLSurfaceMeshes;
|
||||
std::map<PolyVox::Vector3DUint8, polyvox_shared_ptr<PolyVox::SurfaceMesh<PolyVox::PositionMaterialNormal> >, Vector3DUint8Compare> m_mapSurfaceMeshes;
|
||||
|
||||
unsigned int m_uRegionSideLength;
|
||||
unsigned int m_uVolumeWidthInRegions;
|
||||
|
@ -28,3 +28,4 @@ add_definitions(-DGLEW_STATIC)
|
||||
#find_package(OpenGL REQUIRED)
|
||||
#include_directories(${OPENGL_INCLUDE_DIR})
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
/// 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;
|
||||
|
||||
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
|
||||
bool setVoxelAtConst(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue) const;
|
||||
|
||||
//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
|
||||
//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++)
|
||||
{
|
||||
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())
|
||||
{
|
||||
@ -395,7 +395,7 @@ namespace PolyVox
|
||||
template <typename VoxelType>
|
||||
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
|
||||
//eraseBlock was invalidating the iterator.
|
||||
while(m_pBlocks.size() > 0)
|
||||
@ -429,7 +429,7 @@ namespace PolyVox
|
||||
for(int32_t z = v3dStart.getZ(); z <= v3dEnd.getZ(); 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())
|
||||
{
|
||||
// not loaded, not unloading
|
||||
@ -514,7 +514,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -585,7 +585,7 @@ namespace PolyVox
|
||||
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
|
||||
if(itBlock == m_pBlocks.end())
|
||||
{
|
||||
@ -598,8 +598,8 @@ namespace PolyVox
|
||||
if(m_pBlocks.size() == m_uMaxNumberOfBlocksInMemory)
|
||||
{
|
||||
// find the least recently used block
|
||||
typename std::map<Vector3DInt32, LoadedBlock >::iterator i;
|
||||
typename std::map<Vector3DInt32, LoadedBlock >::iterator itUnloadBlock = m_pBlocks.begin();
|
||||
typename std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare>::iterator i;
|
||||
typename std::map<Vector3DInt32, LoadedBlock, BlockPositionCompare>::iterator itUnloadBlock = m_pBlocks.begin();
|
||||
for(i = m_pBlocks.begin(); i != m_pBlocks.end(); i++)
|
||||
{
|
||||
if(i->second.timestamp < itUnloadBlock->second.timestamp)
|
||||
@ -702,7 +702,7 @@ namespace PolyVox
|
||||
uint32_t uSizeInBytes = sizeof(LargeVolume);
|
||||
|
||||
//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++)
|
||||
{
|
||||
//Inaccurate - account for rest of loaded block.
|
||||
|
@ -30,25 +30,25 @@ freely, subject to the following restrictions:
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
/// 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
|
||||
/// 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
|
||||
/// 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
|
||||
/// bound which specify the range of voxels positions considered to be part of the region. Note that these bounds are
|
||||
/// <em>inclusive</em>.
|
||||
///
|
||||
/// 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
|
||||
/// 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
|
||||
/// about these definitions.
|
||||
///
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/** 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
|
||||
* 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
|
||||
* 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
|
||||
* bound which specify the range of voxels positions considered to be part of the region. Note that these bounds are
|
||||
* <em>inclusive</em>.
|
||||
*
|
||||
* 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
|
||||
* 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
|
||||
* about these definitions.
|
||||
*
|
||||
*/
|
||||
#ifdef SWIG
|
||||
class Region
|
||||
#else
|
||||
@ -203,193 +203,193 @@ namespace PolyVox
|
||||
// 'inline' keyword is used for the definition rather than the declaration.
|
||||
// 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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
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
|
||||
{
|
||||
return m_iUpperZ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The position of the lower corner.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \return The position of the lower corner.
|
||||
*/
|
||||
inline Vector3DInt32 Region::getLowerCorner(void) const
|
||||
{
|
||||
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
|
||||
{
|
||||
return Vector3DInt32(m_iUpperX, m_iUpperY, m_iUpperZ);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The width of the region measured in voxels.
|
||||
/// \sa getWidthInCells()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \return The width of the region measured in voxels.
|
||||
* \sa getWidthInCells()
|
||||
*/
|
||||
inline int32_t Region::getWidthInVoxels(void) const
|
||||
{
|
||||
return getWidthInCells() + 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The height of the region measured in voxels.
|
||||
/// \sa getHeightInCells()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \return The height of the region measured in voxels.
|
||||
* \sa getHeightInCells()
|
||||
*/
|
||||
inline int32_t Region::getHeightInVoxels(void) const
|
||||
{
|
||||
return getHeightInCells() + 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The depth of the region measured in voxels.
|
||||
/// \sa getDepthInCells()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \return The depth of the region measured in voxels.
|
||||
* \sa getDepthInCells()
|
||||
*/
|
||||
inline int32_t Region::getDepthInVoxels(void) const
|
||||
{
|
||||
return getDepthInCells() + 1;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The dimensions of the region measured in voxels.
|
||||
/// \sa getDimensionsInCells()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \return The dimensions of the region measured in voxels.
|
||||
* \sa getDimensionsInCells()
|
||||
*/
|
||||
inline Vector3DInt32 Region::getDimensionsInVoxels(void) const
|
||||
{
|
||||
return getDimensionsInCells() + Vector3DInt32(1, 1, 1);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The width of the region measured in cells.
|
||||
/// \sa getWidthInVoxels()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \return The width of the region measured in cells.
|
||||
* \sa getWidthInVoxels()
|
||||
*/
|
||||
inline int32_t Region::getWidthInCells(void) const
|
||||
{
|
||||
return m_iUpperX - m_iLowerX;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The height of the region measured in cells.
|
||||
/// \sa getHeightInVoxels()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \return The height of the region measured in cells.
|
||||
* \sa getHeightInVoxels()
|
||||
*/
|
||||
inline int32_t Region::getHeightInCells(void) const
|
||||
{
|
||||
return m_iUpperY - m_iLowerY;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The depth of the region measured in cells.
|
||||
/// \sa getDepthInVoxels()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \return The depth of the region measured in cells.
|
||||
* \sa getDepthInVoxels()
|
||||
*/
|
||||
inline int32_t Region::getDepthInCells(void) const
|
||||
{
|
||||
return m_iUpperZ - m_iLowerZ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \return The dimensions of the region measured in cells.
|
||||
/// \sa getDimensionsInVoxels()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \return The dimensions of the region measured in cells.
|
||||
* \sa getDimensionsInVoxels()
|
||||
*/
|
||||
inline Vector3DInt32 Region::getDimensionsInCells(void) const
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
m_iLowerX = v3dLowerCorner.getX();
|
||||
@ -397,9 +397,9 @@ namespace PolyVox
|
||||
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)
|
||||
{
|
||||
m_iUpperX = v3dUpperCorner.getX();
|
||||
|
@ -36,29 +36,30 @@ freely, subject to the following restrictions:
|
||||
namespace PolyVox
|
||||
{
|
||||
/**
|
||||
Represents a vector in space.
|
||||
|
||||
This Vector class is templated on both size and data type. It is designed to be
|
||||
generic but so far had only been tested with vectors of size 2 and 3. Also note
|
||||
that some of the operations do not make sense with integer types, for example it
|
||||
does not make conceptual sense to try and normalise an integer Vector.
|
||||
|
||||
The elements of the Vector are accessed via the overloaded () operator which takes
|
||||
an index indicating the element to fetch. They are set using the set() function which
|
||||
takes an index indicating the element to set and a new value for that element. For
|
||||
convienience, the functions getX(), setX(), getY(), setY(), getZ(), setZ(), getw() and setW()
|
||||
do the same thing for the first 4 elements of the Vector.
|
||||
|
||||
A variety of overloaded operators are also provided for comparison and arithmetic
|
||||
operations. For most of these arithmetic operators only the unary versions are
|
||||
documented below - however often binary versions are also generated by std::operators.
|
||||
|
||||
Lastly, note that for convienience a set of typedefs are included for 2 and 3 dimensional
|
||||
vectors with type float, double, int32_t, and uint32_t. They are used as follows:
|
||||
|
||||
\code
|
||||
Vector2DInt4 test(1,2); //Declares a 2 dimensional Vector of type int4.
|
||||
\endcode
|
||||
* Represents a vector in space.
|
||||
*
|
||||
* This is a generl purpose vector class designed to represent both positions and directions. It is templatised
|
||||
* on both size and data type but note that some of the operations do not make sense with integer types. For
|
||||
* example it 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
|
||||
* X, Y, Z and W elements. Note that W is last even though it comes before X in the alphabet. These elements can
|
||||
* be accessed through getX(), setX(), getY(), setY(), getZ(), setZ(), getW() and setW(), while other elements
|
||||
* can be accessed through getElemen() and setElement().
|
||||
*
|
||||
* 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
|
||||
* OperationType which is used for many internal calculations and some results. For example, the square of a
|
||||
* vector's length will always be an integer if all the elements are integers, but the value might be outside
|
||||
* 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.
|
||||
*
|
||||
* 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
|
||||
* Vector2DInt32 test(1,2); //Declares a 2 dimensional Vector of type int32_t.
|
||||
* \endcode
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
class Vector
|
||||
@ -88,7 +89,7 @@ namespace PolyVox
|
||||
/// Inequality Operator.
|
||||
bool operator!=(const Vector<Size,StorageType,OperationType>& rhs) const;
|
||||
/// 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.
|
||||
Vector<Size,StorageType,OperationType>& operator+=(const Vector<Size,StorageType,OperationType> &rhs);
|
||||
/// Subtraction and Assignment Operator.
|
||||
|
@ -25,7 +25,7 @@ namespace PolyVox
|
||||
{
|
||||
//-------------------------- 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>
|
||||
Vector<Size, StorageType, OperationType>::Vector(void)
|
||||
@ -33,8 +33,8 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Creates a Vector object and initialises it with given values.
|
||||
\param x x component to set.
|
||||
* Creates a Vector object and initialises all components with the given value.
|
||||
* \param tFillValue The value to write to every component.
|
||||
*/
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
Vector<Size,StorageType,OperationType>::Vector(StorageType tFillValue)
|
||||
@ -46,9 +46,9 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Creates a Vector object and initialises it with given values.
|
||||
\param x x component to set.
|
||||
\param y y component to set.
|
||||
* Creates a Vector object and initialises it with given values.
|
||||
* \param x The X component to set.
|
||||
* \param y The Y component to set.
|
||||
*/
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y)
|
||||
@ -62,10 +62,10 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Creates a Vector3D object and initialises it with given values.
|
||||
\param x x component to set.
|
||||
\param y y component to set.
|
||||
\param z z component to set.
|
||||
* Creates a Vector3D object and initialises it with given values.
|
||||
* \param x The X component to set.
|
||||
* \param y The Y component to set.
|
||||
* \param z the Z component to set.
|
||||
*/
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z)
|
||||
@ -81,11 +81,11 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Creates a Vector3D object and initialises it with given values.
|
||||
\param x x component to set.
|
||||
\param y y component to set.
|
||||
\param z z component to set.
|
||||
\param w w component to set.
|
||||
* Creates a Vector3D object and initialises it with given values.
|
||||
* \param x The X component to set.
|
||||
* \param y The Y component to set.
|
||||
* \param z The Z component to set.
|
||||
* \param w The W component to set.
|
||||
*/
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
Vector<Size,StorageType,OperationType>::Vector(StorageType x, StorageType y, StorageType z, StorageType w)
|
||||
@ -101,8 +101,8 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Copy constructor builds object based on object passed as parameter.
|
||||
\param vector A reference to the Vector to be copied.
|
||||
* Copy constructor builds object based on object passed as parameter.
|
||||
* \param vector A reference to the Vector to be copied.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
Vector<Size, StorageType, OperationType>::Vector(const Vector<Size, StorageType, OperationType>& vector)
|
||||
@ -111,13 +111,13 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
This copy constructor allows casting between vectors with different data types.
|
||||
It is now possible to use code such as:
|
||||
|
||||
Vector3DDouble v3dDouble(1.0,2.0,3.0);
|
||||
Vector3DFloat v3dFloat = static_cast<Vector3DFloat>(v3dDouble); //Casting
|
||||
|
||||
\param vector A reference to the Vector to be copied.
|
||||
* This copy constructor allows casting between vectors with different data types.
|
||||
* It makes it possible to use code such as:
|
||||
*
|
||||
* Vector3DDouble v3dDouble(1.0,2.0,3.0);
|
||||
* Vector3DFloat v3dFloat = static_cast<Vector3DFloat>(v3dDouble); //Casting
|
||||
*
|
||||
* \param vector A reference to the Vector to be copied.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
template <typename CastType>
|
||||
@ -130,7 +130,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Destroys the Vector.
|
||||
* Destroys the Vector.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
Vector<Size, StorageType, OperationType>::~Vector(void)
|
||||
@ -146,9 +146,9 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Assignment operator copies each element of first Vector to the second.
|
||||
\param rhs Vector to assign to.
|
||||
\return A reference to the result to allow chaining.
|
||||
* Assignment operator copies each element of first Vector to the second.
|
||||
* \param rhs Vector to assign to.
|
||||
* \return A reference to the result to allow chaining.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator=(const Vector<Size, StorageType, OperationType>& rhs)
|
||||
@ -162,10 +162,10 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Checks whether two Vectors are equal.
|
||||
\param rhs The Vector to compare to.
|
||||
\return true if the Vectors match.
|
||||
\see operator!=
|
||||
* Checks whether two Vectors are equal.
|
||||
* \param rhs The Vector to compare to.
|
||||
* \return true if the Vectors match.
|
||||
* \see operator!=
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline bool Vector<Size, StorageType, OperationType>::operator==(const Vector<Size, StorageType, OperationType> &rhs) const
|
||||
@ -183,10 +183,10 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Checks whether two Vectors are not equal.
|
||||
\param rhs The Vector to compare to.
|
||||
\return true if the Vectors do not match.
|
||||
\see operator==
|
||||
* Checks whether two Vectors are not equal.
|
||||
* \param rhs The Vector to compare to.
|
||||
* \return true if the Vectors do not match.
|
||||
* \see operator==
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline bool Vector<Size, StorageType, OperationType>::operator!=(const Vector<Size, StorageType, OperationType> &rhs) const
|
||||
@ -195,11 +195,13 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
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.
|
||||
\param rhs The Vector to compare to.
|
||||
\return true if this is less than the parameter
|
||||
\see operator!=
|
||||
* 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.
|
||||
* This function is deprecated. You should specify a seperate comparator to the std:map if you need one.
|
||||
* \param rhs The Vector to compare to.
|
||||
* \return true if this is less than the parameter
|
||||
* \see operator!=
|
||||
* \deprecated
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline bool Vector<Size, StorageType, OperationType>::operator<(const Vector<Size, StorageType, OperationType> &rhs) const
|
||||
@ -215,9 +217,9 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Addition operator adds corresponding elements of the two Vectors.
|
||||
\param rhs Vector to add
|
||||
\return The resulting Vector.
|
||||
* Addition operator adds corresponding elements of the two Vectors.
|
||||
* \param rhs The Vector to add
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator+=(const Vector<Size, StorageType, OperationType>& rhs)
|
||||
@ -230,9 +232,9 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Subtraction operator subtracts corresponding elements of one Vector from the other.
|
||||
\param rhs Vector to subtract
|
||||
\return The resulting Vector.
|
||||
* Subtraction operator subtracts corresponding elements of one Vector from the other.
|
||||
* \param rhs The Vector to subtract
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator-=(const Vector<Size, StorageType, OperationType>& rhs)
|
||||
@ -245,9 +247,9 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Multiplication operator multiplies corresponding elements of the two Vectors.
|
||||
\param rhs Vector to multiply by
|
||||
\return The resulting Vector.
|
||||
* Multiplication operator multiplies corresponding elements of the two Vectors.
|
||||
* \param rhs The Vector to multiply by
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator*=(const Vector<Size, StorageType, OperationType>& rhs)
|
||||
@ -260,9 +262,9 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Division operator divides corresponding elements of one Vector by the other.
|
||||
\param rhs Vector to divide by
|
||||
\return The resulting Vector.
|
||||
* Division operator divides corresponding elements of one Vector by the other.
|
||||
* \param rhs The Vector to divide by
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator/=(const Vector<Size, StorageType, OperationType>& rhs)
|
||||
@ -275,9 +277,9 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Multiplication operator multiplies each element of the Vector by a number.
|
||||
\param rhs the number the Vector is multiplied by.
|
||||
\return The resulting Vector.
|
||||
* Multiplication operator multiplies each element of the Vector by a number.
|
||||
* \param rhs The number the Vector is multiplied by.
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator*=(const StorageType& rhs)
|
||||
@ -290,9 +292,9 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Division operator divides each element of the Vector by a number.
|
||||
\param rhs the number the Vector is divided by.
|
||||
\return The resulting Vector.
|
||||
* Division operator divides each element of the Vector by a number.
|
||||
* \param rhs The number the Vector is divided by.
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline Vector<Size, StorageType, OperationType>& Vector<Size, StorageType, OperationType>::operator/=(const StorageType& rhs)
|
||||
@ -305,10 +307,10 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Addition operator adds corresponding elements of the two Vectors.
|
||||
\param lhs Vector to add to.
|
||||
\param rhs Vector to add.
|
||||
\return The resulting Vector.
|
||||
* Addition operator adds corresponding elements of the two Vectors.
|
||||
* \param lhs The Vector to add to.
|
||||
* \param rhs The Vector to add.
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
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)
|
||||
@ -319,10 +321,10 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Subtraction operator subtracts corresponding elements of one Vector from the other.
|
||||
\param lhs Vector to subtract from.
|
||||
\param rhs Vector to subtract.
|
||||
\return The resulting Vector.
|
||||
* Subtraction operator subtracts corresponding elements of one Vector from the other.
|
||||
* \param lhs The Vector to subtract from.
|
||||
* \param rhs The Vector to subtract.
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
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)
|
||||
@ -333,10 +335,10 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Multiplication operator mulitplies corresponding elements of the two Vectors.
|
||||
\param lhs Vector to multiply.
|
||||
\param rhs Vector to multiply by.
|
||||
\return The resulting Vector.
|
||||
* Multiplication operator mulitplies corresponding elements of the two Vectors.
|
||||
* \param lhs The Vector to multiply.
|
||||
* \param rhs The Vector to multiply by.
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
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)
|
||||
@ -347,10 +349,10 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Division operator divides corresponding elements of one Vector by the other.
|
||||
\param lhs Vector to divide.
|
||||
\param rhs Vector to divide by.
|
||||
\return The resulting Vector.
|
||||
* Division operator divides corresponding elements of one Vector by the other.
|
||||
* \param lhs The Vector to divide.
|
||||
* \param rhs The Vector to divide by.
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
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)
|
||||
@ -361,10 +363,10 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Multiplication operator multiplies each element of the Vector by a number.
|
||||
\param lhs the Vector to multiply.
|
||||
\param rhs the number the Vector is multiplied by.
|
||||
\return The resulting Vector.
|
||||
* Multiplication operator multiplies each element of the Vector by a number.
|
||||
* \param lhs The Vector to multiply.
|
||||
* \param rhs The number the Vector is multiplied by.
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
Vector<Size,StorageType,OperationType> operator*(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs)
|
||||
@ -375,10 +377,10 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Division operator divides each element of the Vector by a number.
|
||||
\param lhs the Vector to divide.
|
||||
\param rhs the number the Vector is divided by.
|
||||
\return The resulting Vector.
|
||||
* Division operator divides each element of the Vector by a number.
|
||||
* \param lhs The Vector to divide.
|
||||
* \param rhs The number the Vector is divided by.
|
||||
* \return The resulting Vector.
|
||||
*/
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
Vector<Size,StorageType,OperationType> operator/(const Vector<Size,StorageType,OperationType>& lhs, const StorageType& rhs)
|
||||
@ -389,10 +391,10 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Enables the Vector to be used intuitively with output streams such as cout.
|
||||
\param os The output stream to write to.
|
||||
\param vector The Vector to write to the stream.
|
||||
\return A reference to the output stream to allow chaining.
|
||||
* Enables the Vector to be used intuitively with output streams such as cout.
|
||||
* \param os The output stream to write to.
|
||||
* \param vector The Vector to write to the stream.
|
||||
* \return A reference to the output stream to allow chaining.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
std::ostream& operator<<(std::ostream& os, const Vector<Size, StorageType, OperationType>& vector)
|
||||
@ -411,9 +413,9 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Returns the element at the given position.
|
||||
\param index The index of the element to return.
|
||||
\return The element.
|
||||
* Returns the element at the given position.
|
||||
* \param index The index of the element to return.
|
||||
* \return The element.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline StorageType Vector<Size, StorageType, OperationType>::getElement(uint32_t index) const
|
||||
@ -423,7 +425,7 @@ 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>
|
||||
inline StorageType Vector<Size, StorageType, OperationType>::getX(void) const
|
||||
@ -432,7 +434,7 @@ 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>
|
||||
inline StorageType Vector<Size, StorageType, OperationType>::getY(void) const
|
||||
@ -441,7 +443,7 @@ 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>
|
||||
inline StorageType Vector<Size, StorageType, OperationType>::getZ(void) const
|
||||
@ -454,7 +456,7 @@ 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>
|
||||
inline StorageType Vector<Size, StorageType, OperationType>::getW(void) const
|
||||
@ -467,8 +469,8 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
\param index The index of the element to set.
|
||||
\param tValue The new value for the element.
|
||||
* \param index The index of the element to set.
|
||||
* \param tValue The new value for the element.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline void Vector<Size, StorageType, OperationType>::setElement(uint32_t index, StorageType tValue)
|
||||
@ -478,9 +480,9 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Sets several elements of a vector at once.
|
||||
\param x x component to set.
|
||||
\param y y component to set.
|
||||
* Sets several elements of a vector at once.
|
||||
* \param x The X component to set.
|
||||
* \param y The Y component to set.
|
||||
*/
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y)
|
||||
@ -491,10 +493,10 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Sets several elements of a vector at once.
|
||||
\param x x component to set.
|
||||
\param y y component to set.
|
||||
\param z z component to set.
|
||||
* Sets several elements of a vector at once.
|
||||
* \param x The X component to set.
|
||||
* \param y The Y component to set.
|
||||
* \param z The Z component to set.
|
||||
*/
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z)
|
||||
@ -508,11 +510,11 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Sets several elements of a vector at once.
|
||||
\param x x component to set.
|
||||
\param y y component to set.
|
||||
\param z z component to set.
|
||||
\param w w component to set.
|
||||
* Sets several elements of a vector at once.
|
||||
* \param x The X component to set.
|
||||
* \param y The Y component to set.
|
||||
* \param z The Z component to set.
|
||||
* \param w The W component to set.
|
||||
*/
|
||||
template <uint32_t Size,typename StorageType, typename OperationType>
|
||||
inline void Vector<Size,StorageType,OperationType>::setElements(StorageType x, StorageType y, StorageType z, StorageType w)
|
||||
@ -527,7 +529,7 @@ 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>
|
||||
inline void Vector<Size, StorageType, OperationType>::setX(StorageType tX)
|
||||
@ -536,7 +538,7 @@ 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>
|
||||
inline void Vector<Size, StorageType, OperationType>::setY(StorageType tY)
|
||||
@ -545,7 +547,7 @@ 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>
|
||||
inline void Vector<Size, StorageType, OperationType>::setZ(StorageType tZ)
|
||||
@ -557,7 +559,7 @@ 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>
|
||||
inline void Vector<Size, StorageType, OperationType>::setW(StorageType tW)
|
||||
@ -569,8 +571,8 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
\note This function does not make much sense on integer Vectors.
|
||||
\return Length of the Vector.
|
||||
* \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 The length of the Vector.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline float Vector<Size, StorageType, OperationType>::length(void) const
|
||||
@ -579,7 +581,7 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
\return Squared length of the Vector.
|
||||
* \return The squared length of the Vector.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline OperationType Vector<Size, StorageType, OperationType>::lengthSquared(void) const
|
||||
@ -593,13 +595,13 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
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.
|
||||
|
||||
\note This function does not make much sense on integer Vectors.
|
||||
|
||||
\param vector The Vector to find the angle to.
|
||||
\return The angle between them in radians.
|
||||
* 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.
|
||||
*
|
||||
* \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.
|
||||
* \return The angle between them in radians.
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
inline float Vector<Size, StorageType, OperationType>::angleTo(const Vector<Size, StorageType, OperationType>& vector) const
|
||||
@ -608,16 +610,16 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
This function is used to calculate the cross product of two Vectors.
|
||||
The cross product is the Vector which is perpendicular to the two
|
||||
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
|
||||
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
|
||||
by the thumb.
|
||||
\param vector The vector to cross with this
|
||||
\return The value of the cross product.
|
||||
\see dot()
|
||||
* This function is used to calculate the cross product of two Vectors.
|
||||
* The cross product is the Vector which is perpendicular to the two
|
||||
* 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
|
||||
* 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
|
||||
* by the thumb.
|
||||
* \param vector The vector to cross with this
|
||||
* \return The value of the cross product.
|
||||
* \see dot()
|
||||
*/
|
||||
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
|
||||
@ -629,11 +631,11 @@ namespace PolyVox
|
||||
}
|
||||
|
||||
/**
|
||||
Calculates the dot product of the Vector and the parameter.
|
||||
This function is commutative, such that a.dot(b) == b.dot(a).
|
||||
\param rhs The Vector to find the dot product with.
|
||||
\return The value of the dot product.
|
||||
\see cross()
|
||||
* Calculates the dot product of the Vector and the parameter.
|
||||
* This function is commutative, such that a.dot(b) == b.dot(a).
|
||||
* \param rhs The Vector to find the dot product with.
|
||||
* \return The value of the dot product.
|
||||
* \see cross()
|
||||
*/
|
||||
template <uint32_t Size, typename StorageType, typename OperationType>
|
||||
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.
|
||||
|
||||
\note This function does not make much sense on integer Vectors.
|
||||
* 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
|
||||
* 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>
|
||||
inline void Vector<Size, StorageType, OperationType>::normalise(void)
|
||||
{
|
||||
StorageType tLength = static_cast<StorageType>(this->length());
|
||||
//FIXME - throw div by zero exception?
|
||||
if(tLength < 0.0001f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
float fLength = this->length();
|
||||
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
|
||||
|
@ -28,30 +28,30 @@ freely, subject to the following restrictions:
|
||||
|
||||
namespace PolyVox
|
||||
{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
*/
|
||||
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>::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
|
||||
/// 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.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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
|
||||
* of this will be a Region which encompasses all positions specified.
|
||||
*/
|
||||
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>::min)(), (std::numeric_limits<int32_t>::min)(), (std::numeric_limits<int32_t>::min)())
|
||||
);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \param iX The 'x' 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 iX The 'x' 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.
|
||||
*/
|
||||
void Region::accumulate(int32_t iX, int32_t iY, int32_t iZ)
|
||||
{
|
||||
m_iLowerX = ((std::min)(m_iLowerX, iX));
|
||||
@ -62,21 +62,21 @@ namespace PolyVox
|
||||
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)
|
||||
{
|
||||
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
|
||||
/// 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.
|
||||
/// \param reg The Region to accumulate. This must be valid as defined by the isValid() function.
|
||||
/// \sa isValid()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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,
|
||||
* 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.
|
||||
* \sa isValid()
|
||||
*/
|
||||
void Region::accumulate(const Region& reg)
|
||||
{
|
||||
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()));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constructs a Region and clears all extents to zero.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Constructs a Region and clears all extents to zero.
|
||||
*/
|
||||
Region::Region()
|
||||
:m_iLowerX(0)
|
||||
,m_iLowerY(0)
|
||||
@ -102,11 +102,11 @@ namespace PolyVox
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constructs a Region and sets the lower and upper corners to the specified values.
|
||||
/// \param v3dLowerCorner The desired lower corner of the Region.
|
||||
/// \param v3dUpperCorner The desired upper corner of the Region.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Constructs a Region and sets the lower and upper corners to the specified values.
|
||||
* \param v3dLowerCorner The desired lower corner of the Region.
|
||||
* \param v3dUpperCorner The desired upper corner of the Region.
|
||||
*/
|
||||
Region::Region(const Vector3DInt32& v3dLowerCorner, const Vector3DInt32& v3dUpperCorner)
|
||||
:m_iLowerX(v3dLowerCorner.getX())
|
||||
,m_iLowerY(v3dLowerCorner.getY())
|
||||
@ -117,15 +117,15 @@ namespace PolyVox
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Constructs a Region and sets the extents to the specified values.
|
||||
/// \param iLowerX The desired lower 'x' 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 iUpperX The desired upper 'x' extent of the Region.
|
||||
/// \param iUpperY The desired upper 'y' extent of the Region.
|
||||
/// \param iUpperZ The desired upper 'z' extent of the Region.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Constructs a Region and sets the extents to the specified values.
|
||||
* \param iLowerX The desired lower 'x' 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 iUpperX The desired upper 'x' extent of the Region.
|
||||
* \param iUpperY The desired upper 'y' 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)
|
||||
:m_iLowerX(iLowerX)
|
||||
,m_iLowerY(iLowerY)
|
||||
@ -136,12 +136,12 @@ namespace PolyVox
|
||||
{
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// Two regions are considered equal if all their extents match.
|
||||
/// \param rhs The Region to compare to.
|
||||
/// \return true if the Regions match.
|
||||
/// \sa operator!=
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Two regions are considered equal if all their extents match.
|
||||
* \param rhs The Region to compare to.
|
||||
* \return true if the Regions match.
|
||||
* \sa operator!=
|
||||
*/
|
||||
bool Region::operator==(const Region& rhs) const
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// 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 fY The 'y' position of the point to test.
|
||||
/// \param fZ The 'z' position of the point to test.
|
||||
/// \param boundary The desired boundary value.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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
|
||||
* 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 fY The 'y' position of the point to test.
|
||||
* \param fZ The 'z' position of the point to test.
|
||||
* \param boundary The desired boundary value.
|
||||
*/
|
||||
bool Region::containsPoint(float fX, float fY, float fZ, float boundary) const
|
||||
{
|
||||
return (fX <= m_iUpperX - boundary)
|
||||
@ -178,27 +178,27 @@ namespace PolyVox
|
||||
&& (fZ >= m_iLowerZ + boundary);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// 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 boundary The desired boundary value.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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
|
||||
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
* \param pos The position to test.
|
||||
* \param boundary The desired boundary value.
|
||||
*/
|
||||
bool Region::containsPoint(const Vector3DFloat& pos, float boundary) const
|
||||
{
|
||||
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 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.
|
||||
/// \param iX The 'x' 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 boundary The desired boundary value.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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
|
||||
* 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 iY The 'y' position of the point to test.
|
||||
* \param iZ The 'z' position of the point to test.
|
||||
* \param boundary The desired boundary value.
|
||||
*/
|
||||
bool Region::containsPoint(int32_t iX, int32_t iY, int32_t iZ, uint8_t boundary) const
|
||||
{
|
||||
return (iX <= m_iUpperX - boundary)
|
||||
@ -209,101 +209,101 @@ namespace PolyVox
|
||||
&& (iZ >= m_iLowerZ + boundary);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// 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 boundary The desired boundary value.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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
|
||||
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
* \param pos The position to test.
|
||||
* \param boundary The desired boundary value.
|
||||
*/
|
||||
bool Region::containsPoint(const Vector3DInt32& pos, uint8_t boundary) const
|
||||
{
|
||||
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 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.
|
||||
/// \param pos The position to test.
|
||||
/// \param boundary The desired boundary value.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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
|
||||
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
* \param pos The position to test.
|
||||
* \param boundary The desired boundary value.
|
||||
*/
|
||||
bool Region::containsPointInX(float pos, float boundary) const
|
||||
{
|
||||
return (pos <= m_iUpperX - boundary)
|
||||
&& (pos >= m_iLowerX + boundary);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
/// \param pos The position to test.
|
||||
/// \param boundary The desired boundary value.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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
|
||||
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
* \param pos The position to test.
|
||||
* \param boundary The desired boundary value.
|
||||
*/
|
||||
bool Region::containsPointInX(int32_t pos, uint8_t boundary) const
|
||||
{
|
||||
return (pos <= m_iUpperX - boundary)
|
||||
&& (pos >= m_iLowerX + boundary);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
/// \param pos The position to test.
|
||||
/// \param boundary The desired boundary value.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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
|
||||
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
* \param pos The position to test.
|
||||
* \param boundary The desired boundary value.
|
||||
*/
|
||||
bool Region::containsPointInY(float pos, float boundary) const
|
||||
{
|
||||
return (pos <= m_iUpperY - boundary)
|
||||
&& (pos >= m_iLowerY + boundary);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
/// \param pos The position to test.
|
||||
/// \param boundary The desired boundary value.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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
|
||||
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
* \param pos The position to test.
|
||||
* \param boundary The desired boundary value.
|
||||
*/
|
||||
bool Region::containsPointInY(int32_t pos, uint8_t boundary) const
|
||||
{
|
||||
return (pos <= m_iUpperY - boundary)
|
||||
&& (pos >= m_iLowerY + boundary);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
/// \param pos The position to test.
|
||||
/// \param boundary The desired boundary value.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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
|
||||
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
* \param pos The position to test.
|
||||
* \param boundary The desired boundary value.
|
||||
*/
|
||||
bool Region::containsPointInZ(float pos, float boundary) const
|
||||
{
|
||||
return (pos <= m_iUpperZ - boundary)
|
||||
&& (pos >= m_iLowerZ + boundary);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// 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
|
||||
/// that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
/// \param pos The position to test.
|
||||
/// \param boundary The desired boundary value.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* 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
|
||||
* that positions lying exactly on the edge of the Region are considered to be inside it.
|
||||
* \param pos The position to test.
|
||||
* \param boundary The desired boundary value.
|
||||
*/
|
||||
bool Region::containsPointInZ(int32_t pos, uint8_t boundary) const
|
||||
{
|
||||
return (pos <= m_iUpperZ - boundary)
|
||||
&& (pos >= m_iLowerZ + boundary);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// After calling this functions, the extents of this Region are given by the intersection
|
||||
/// of this Region and the one it was cropped to.
|
||||
/// \param other The Region to crop to.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* After calling this functions, the extents of this Region are given by the intersection
|
||||
* of this Region and the one it was cropped to.
|
||||
* \param other The Region to crop to.
|
||||
*/
|
||||
void Region::cropTo(const Region& other)
|
||||
{
|
||||
m_iLowerX = ((std::max)(m_iLowerX, other.m_iLowerX));
|
||||
@ -314,11 +314,11 @@ namespace PolyVox
|
||||
m_iUpperZ = ((std::min)(m_iUpperZ, other.m_iUpperZ));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// The same amount of growth is applied in all directions. Negative growth
|
||||
/// is possible but you should prefer the shrink() function for clarity.
|
||||
/// \param iAmount The amount to grow by.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* The same amount of growth is applied in all directions. Negative growth
|
||||
* is possible but you should prefer the shrink() function for clarity.
|
||||
* \param iAmount The amount to grow by.
|
||||
*/
|
||||
void Region::grow(int32_t iAmount)
|
||||
{
|
||||
m_iLowerX -= iAmount;
|
||||
@ -330,13 +330,13 @@ namespace PolyVox
|
||||
m_iUpperZ += iAmount;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// The amount can be specified seperatly for each direction. Negative growth
|
||||
/// is possible but you should prefer the shrink() function for clarity.
|
||||
/// \param iAmountX The amount to grow by in 'x'.
|
||||
/// \param iAmountY The amount to grow by in 'y'.
|
||||
/// \param iAmountZ The amount to grow by in 'z'.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* The amount can be specified seperatly for each direction. Negative growth
|
||||
* is possible but you should prefer the shrink() function for clarity.
|
||||
* \param iAmountX The amount to grow by in 'x'.
|
||||
* \param iAmountY The amount to grow by in 'y'.
|
||||
* \param iAmountZ The amount to grow by in 'z'.
|
||||
*/
|
||||
void Region::grow(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
||||
{
|
||||
m_iLowerX -= iAmountX;
|
||||
@ -348,48 +348,48 @@ namespace PolyVox
|
||||
m_iUpperZ += iAmountZ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// The amount can be specified seperatly for each direction. Negative growth
|
||||
/// is possible but you should prefer the shrink() function for clarity.
|
||||
/// \param v3dAmount The amount to grow by (one component for each direction).
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* The amount can be specified seperatly for each direction. Negative growth
|
||||
* is possible but you should prefer the shrink() function for clarity.
|
||||
* \param v3dAmount The amount to grow by (one component for each direction).
|
||||
*/
|
||||
void Region::grow(const Vector3DInt32& v3dAmount)
|
||||
{
|
||||
grow(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
*/
|
||||
bool Region::isValid(void) const
|
||||
{
|
||||
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 iAmountY The amount to move the Region by in 'y'.
|
||||
/// \param iAmountZ The amount to move the Region by in 'z'.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \param iAmountX The amount to move the Region by in 'x'.
|
||||
* \param iAmountY The amount to move the Region by in 'y'.
|
||||
* \param iAmountZ The amount to move the Region by in 'z'.
|
||||
*/
|
||||
void Region::shift(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
||||
{
|
||||
shiftLowerCorner(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)
|
||||
{
|
||||
shiftLowerCorner(v3dAmount);
|
||||
shiftUpperCorner(v3dAmount);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \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 iAmountZ The amount to move the lower corner by in 'z'.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \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 iAmountZ The amount to move the lower corner by in 'z'.
|
||||
*/
|
||||
void Region::shiftLowerCorner(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
||||
{
|
||||
m_iLowerX += iAmountX;
|
||||
@ -397,19 +397,19 @@ namespace PolyVox
|
||||
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)
|
||||
{
|
||||
shiftLowerCorner(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// \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 iAmountZ The amount to move the upper corner by in 'z'.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* \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 iAmountZ The amount to move the upper corner by in 'z'.
|
||||
*/
|
||||
void Region::shiftUpperCorner(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
||||
{
|
||||
m_iUpperX += iAmountX;
|
||||
@ -417,19 +417,19 @@ namespace PolyVox
|
||||
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)
|
||||
{
|
||||
shiftUpperCorner(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// The same amount of shrinkage is applied in all directions. Negative shrinkage
|
||||
/// is possible but you should prefer the grow() function for clarity.
|
||||
/// \param iAmount The amount to shrink by.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* The same amount of shrinkage is applied in all directions. Negative shrinkage
|
||||
* is possible but you should prefer the grow() function for clarity.
|
||||
* \param iAmount The amount to shrink by.
|
||||
*/
|
||||
void Region::shrink(int32_t iAmount)
|
||||
{
|
||||
m_iLowerX += iAmount;
|
||||
@ -441,13 +441,13 @@ namespace PolyVox
|
||||
m_iUpperZ -= iAmount;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// The amount can be specified seperatly for each direction. Negative shrinkage
|
||||
/// is possible but you should prefer the grow() function for clarity.
|
||||
/// \param iAmountX The amount to shrink by in 'x'.
|
||||
/// \param iAmountY The amount to shrink by in 'y'.
|
||||
/// \param iAmountZ The amount to shrink by in 'z'.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* The amount can be specified seperatly for each direction. Negative shrinkage
|
||||
* is possible but you should prefer the grow() function for clarity.
|
||||
* \param iAmountX The amount to shrink by in 'x'.
|
||||
* \param iAmountY The amount to shrink by in 'y'.
|
||||
* \param iAmountZ The amount to shrink by in 'z'.
|
||||
*/
|
||||
void Region::shrink(int32_t iAmountX, int32_t iAmountY, int32_t iAmountZ)
|
||||
{
|
||||
m_iLowerX += iAmountX;
|
||||
@ -459,11 +459,11 @@ namespace PolyVox
|
||||
m_iUpperZ -= iAmountZ;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// The amount can be specified seperatly for each direction. Negative shrinkage
|
||||
/// is possible but you should prefer the grow() function for clarity.
|
||||
/// \param v3dAmount The amount to shrink by (one component for each direction).
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* The amount can be specified seperatly for each direction. Negative shrinkage
|
||||
* is possible but you should prefer the grow() function for clarity.
|
||||
* \param v3dAmount The amount to shrink by (one component for each direction).
|
||||
*/
|
||||
void Region::shrink(const Vector3DInt32& v3dAmount)
|
||||
{
|
||||
shrink(v3dAmount.getX(), v3dAmount.getY(), v3dAmount.getZ());
|
||||
|
Loading…
x
Reference in New Issue
Block a user