Added setVoxel() functions to replace setVoxelAt() functions in the same way that getVoxel() replaces getVoxelAt().
This commit is contained in:
parent
fa8e7c390f
commit
ea4d6d3168
@ -172,6 +172,10 @@ namespace PolyVox
|
|||||||
/// Sets the value used for voxels which are outside the volume
|
/// Sets the value used for voxels which are outside the volume
|
||||||
void setBorderValue(const VoxelType& tBorder);
|
void setBorderValue(const VoxelType& tBorder);
|
||||||
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||||
|
void setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, BoundsCheck eBoundsCheck = BoundsChecks::Full);
|
||||||
|
/// Sets the voxel at the position given by a 3D vector
|
||||||
|
void setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, BoundsCheck eBoundsCheck = BoundsChecks::Full);
|
||||||
|
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||||
bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue);
|
bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue);
|
||||||
/// Sets the voxel at the position given by a 3D vector
|
/// Sets the voxel at the position given by a 3D vector
|
||||||
bool setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue);
|
bool setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue);
|
||||||
|
@ -234,6 +234,32 @@ namespace PolyVox
|
|||||||
m_tBorderValue = tBorder;
|
m_tBorderValue = tBorder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \param uXPos the \c x position of the voxel
|
||||||
|
/// \param uYPos the \c y position of the voxel
|
||||||
|
/// \param uZPos the \c z position of the voxel
|
||||||
|
/// \param tValue the value to which the voxel will be set
|
||||||
|
/// \return whether the requested position is inside the volume
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
void BaseVolume<VoxelType>::setVoxel(int32_t /*uXPos*/, int32_t /*uYPos*/, int32_t /*uZPos*/, VoxelType /*tValue*/, BoundsCheck /*eBoundsCheck*/)
|
||||||
|
{
|
||||||
|
POLYVOX_THROW(not_implemented, "You should never call the base class version of this function.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \param v3dPos the 3D position of the voxel
|
||||||
|
/// \param tValue the value to which the voxel will be set
|
||||||
|
/// \return whether the requested position is inside the volume
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
void BaseVolume<VoxelType>::setVoxel(const Vector3DInt32& /*v3dPos*/, VoxelType /*tValue*/, BoundsCheck /*eBoundsCheck*/)
|
||||||
|
{
|
||||||
|
POLYVOX_THROW(not_implemented, "You should never call the base class version of this function.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \param uXPos the \c x position of the voxel
|
/// \param uXPos the \c x position of the voxel
|
||||||
/// \param uYPos the \c y position of the voxel
|
/// \param uYPos the \c y position of the voxel
|
||||||
|
@ -283,6 +283,10 @@ namespace PolyVox
|
|||||||
/// Sets the number of blocks which can be in memory before the paging system starts unloading them
|
/// Sets the number of blocks which can be in memory before the paging system starts unloading them
|
||||||
void setMaxNumberOfBlocksInMemory(uint32_t uMaxNumberOfBlocksInMemory);
|
void setMaxNumberOfBlocksInMemory(uint32_t uMaxNumberOfBlocksInMemory);
|
||||||
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||||
|
void setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, BoundsCheck eBoundsCheck = BoundsChecks::Full);
|
||||||
|
/// Sets the voxel at the position given by a 3D vector
|
||||||
|
void setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, BoundsCheck eBoundsCheck = BoundsChecks::Full);
|
||||||
|
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||||
bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue);
|
bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue);
|
||||||
/// Sets the voxel at the position given by a 3D vector
|
/// Sets the voxel at the position given by a 3D vector
|
||||||
bool setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue);
|
bool setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue);
|
||||||
|
@ -280,6 +280,50 @@ namespace PolyVox
|
|||||||
m_uMaxNumberOfBlocksInMemory = uMaxNumberOfBlocksInMemory;
|
m_uMaxNumberOfBlocksInMemory = uMaxNumberOfBlocksInMemory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \param uXPos the \c x position of the voxel
|
||||||
|
/// \param uYPos the \c y position of the voxel
|
||||||
|
/// \param uZPos the \c z position of the voxel
|
||||||
|
/// \param tValue the value to which the voxel will be set
|
||||||
|
/// \return whether the requested position is inside the volume
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
void LargeVolume<VoxelType>::setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, BoundsCheck eBoundsCheck)
|
||||||
|
{
|
||||||
|
// If bounds checking is enabled then we validate the
|
||||||
|
// bounds, and throw an exception if they are violated.
|
||||||
|
if(eBoundsCheck == BoundsChecks::Full)
|
||||||
|
{
|
||||||
|
if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)) == false)
|
||||||
|
{
|
||||||
|
POLYVOX_THROW(std::out_of_range, "Position is outside valid region");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int32_t blockX = uXPos >> m_uBlockSideLengthPower;
|
||||||
|
const int32_t blockY = uYPos >> m_uBlockSideLengthPower;
|
||||||
|
const int32_t blockZ = uZPos >> m_uBlockSideLengthPower;
|
||||||
|
|
||||||
|
const uint16_t xOffset = static_cast<uint16_t>(uXPos - (blockX << m_uBlockSideLengthPower));
|
||||||
|
const uint16_t yOffset = static_cast<uint16_t>(uYPos - (blockY << m_uBlockSideLengthPower));
|
||||||
|
const uint16_t zOffset = static_cast<uint16_t>(uZPos - (blockZ << m_uBlockSideLengthPower));
|
||||||
|
|
||||||
|
Block<VoxelType>* pUncompressedBlock = getUncompressedBlock(blockX, blockY, blockZ);
|
||||||
|
|
||||||
|
pUncompressedBlock->setVoxelAt(xOffset,yOffset,zOffset, tValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \param v3dPos the 3D position of the voxel
|
||||||
|
/// \param tValue the value to which the voxel will be set
|
||||||
|
/// \return whether the requested position is inside the volume
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
void LargeVolume<VoxelType>::setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, BoundsCheck eBoundsCheck)
|
||||||
|
{
|
||||||
|
setVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue, eBoundsCheck);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \param uXPos the \c x position of the voxel
|
/// \param uXPos the \c x position of the voxel
|
||||||
/// \param uYPos the \c y position of the voxel
|
/// \param uYPos the \c y position of the voxel
|
||||||
|
@ -128,6 +128,10 @@ namespace PolyVox
|
|||||||
/// Gets a voxel at the position given by a 3D vector
|
/// Gets a voxel at the position given by a 3D vector
|
||||||
VoxelType getVoxel(const Vector3DInt32& v3dPos, WrapMode eWrapMode, VoxelType tBorder = VoxelType()) const;
|
VoxelType getVoxel(const Vector3DInt32& v3dPos, WrapMode eWrapMode, VoxelType tBorder = VoxelType()) const;
|
||||||
|
|
||||||
|
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||||
|
void setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, BoundsCheck eBoundsCheck = BoundsChecks::Full);
|
||||||
|
/// Sets the voxel at the position given by a 3D vector
|
||||||
|
void setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, BoundsCheck eBoundsCheck = BoundsChecks::Full);
|
||||||
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||||
bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue);
|
bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue);
|
||||||
/// Sets the voxel at the position given by a 3D vector
|
/// Sets the voxel at the position given by a 3D vector
|
||||||
|
@ -210,6 +210,50 @@ namespace PolyVox
|
|||||||
return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, tBorder);
|
return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, tBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \param uXPos the \c x position of the voxel
|
||||||
|
/// \param uYPos the \c y position of the voxel
|
||||||
|
/// \param uZPos the \c z position of the voxel
|
||||||
|
/// \param tValue the value to which the voxel will be set
|
||||||
|
/// \return whether the requested position is inside the volume
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, BoundsCheck eBoundsCheck)
|
||||||
|
{
|
||||||
|
// If bounds checking is enabled then we validate the
|
||||||
|
// bounds, and throw an exception if they are violated.
|
||||||
|
if(eBoundsCheck == BoundsChecks::Full)
|
||||||
|
{
|
||||||
|
if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)) == false)
|
||||||
|
{
|
||||||
|
POLYVOX_THROW(std::out_of_range, "Position is outside valid region");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const Vector3DInt32& v3dLowerCorner = this->m_regValidRegion.getLowerCorner();
|
||||||
|
int32_t iLocalXPos = uXPos - v3dLowerCorner.getX();
|
||||||
|
int32_t iLocalYPos = uYPos - v3dLowerCorner.getY();
|
||||||
|
int32_t iLocalZPos = uZPos - v3dLowerCorner.getZ();
|
||||||
|
|
||||||
|
m_pData
|
||||||
|
[
|
||||||
|
iLocalXPos +
|
||||||
|
iLocalYPos * this->getWidth() +
|
||||||
|
iLocalZPos * this->getWidth() * this->getHeight()
|
||||||
|
] = tValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \param v3dPos the 3D position of the voxel
|
||||||
|
/// \param tValue the value to which the voxel will be set
|
||||||
|
/// \return whether the requested position is inside the volume
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, BoundsCheck eBoundsCheck)
|
||||||
|
{
|
||||||
|
setVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue, eBoundsCheck);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \param uXPos the \c x position of the voxel
|
/// \param uXPos the \c x position of the voxel
|
||||||
/// \param uYPos the \c y position of the voxel
|
/// \param uYPos the \c y position of the voxel
|
||||||
|
@ -167,6 +167,10 @@ namespace PolyVox
|
|||||||
/// Gets a voxel at the position given by a 3D vector
|
/// Gets a voxel at the position given by a 3D vector
|
||||||
VoxelType getVoxel(const Vector3DInt32& v3dPos, WrapMode eWrapMode, VoxelType tBorder = VoxelType()) const;
|
VoxelType getVoxel(const Vector3DInt32& v3dPos, WrapMode eWrapMode, VoxelType tBorder = VoxelType()) const;
|
||||||
|
|
||||||
|
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||||
|
void setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, BoundsCheck eBoundsCheck = BoundsChecks::Full);
|
||||||
|
/// Sets the voxel at the position given by a 3D vector
|
||||||
|
void setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, BoundsCheck eBoundsCheck = BoundsChecks::Full);
|
||||||
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
/// Sets the voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||||
bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue);
|
bool setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue);
|
||||||
/// Sets the voxel at the position given by a 3D vector
|
/// Sets the voxel at the position given by a 3D vector
|
||||||
|
@ -210,6 +210,50 @@ namespace PolyVox
|
|||||||
return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, tBorder);
|
return getVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), eWrapMode, tBorder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \param uXPos the \c x position of the voxel
|
||||||
|
/// \param uYPos the \c y position of the voxel
|
||||||
|
/// \param uZPos the \c z position of the voxel
|
||||||
|
/// \param tValue the value to which the voxel will be set
|
||||||
|
/// \return whether the requested position is inside the volume
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
void SimpleVolume<VoxelType>::setVoxel(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue, BoundsCheck eBoundsCheck)
|
||||||
|
{
|
||||||
|
// If bounds checking is enabled then we validate the
|
||||||
|
// bounds, and throw an exception if they are violated.
|
||||||
|
if(eBoundsCheck == BoundsChecks::Full)
|
||||||
|
{
|
||||||
|
if(this->m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)) == false)
|
||||||
|
{
|
||||||
|
POLYVOX_THROW(std::out_of_range, "Position is outside valid region");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int32_t blockX = uXPos >> m_uBlockSideLengthPower;
|
||||||
|
const int32_t blockY = uYPos >> m_uBlockSideLengthPower;
|
||||||
|
const int32_t blockZ = uZPos >> m_uBlockSideLengthPower;
|
||||||
|
|
||||||
|
const uint16_t xOffset = uXPos - (blockX << m_uBlockSideLengthPower);
|
||||||
|
const uint16_t yOffset = uYPos - (blockY << m_uBlockSideLengthPower);
|
||||||
|
const uint16_t zOffset = uZPos - (blockZ << m_uBlockSideLengthPower);
|
||||||
|
|
||||||
|
typename SimpleVolume<VoxelType>::Block* pUncompressedBlock = getUncompressedBlock(blockX, blockY, blockZ);
|
||||||
|
|
||||||
|
pUncompressedBlock->setVoxelAt(xOffset,yOffset,zOffset, tValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \param v3dPos the 3D position of the voxel
|
||||||
|
/// \param tValue the value to which the voxel will be set
|
||||||
|
/// \return whether the requested position is inside the volume
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
void SimpleVolume<VoxelType>::setVoxel(const Vector3DInt32& v3dPos, VoxelType tValue, BoundsCheck eBoundsCheck)
|
||||||
|
{
|
||||||
|
setVoxel(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue, eBoundsCheck);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// \param uXPos the \c x position of the voxel
|
/// \param uXPos the \c x position of the voxel
|
||||||
/// \param uYPos the \c y position of the voxel
|
/// \param uYPos the \c y position of the voxel
|
||||||
|
Loading…
x
Reference in New Issue
Block a user