30 template <
typename VoxelType>
47 template <
typename VoxelType>
56 template <
typename VoxelType>
70 template <
typename VoxelType>
82 template <
typename VoxelType>
87 const Vector3DInt32& v3dLowerCorner = this->m_regValidRegion.getLowerCorner();
88 int32_t iLocalXPos = uXPos - v3dLowerCorner.getX();
89 int32_t iLocalYPos = uYPos - v3dLowerCorner.getY();
90 int32_t iLocalZPos = uZPos - v3dLowerCorner.getZ();
95 iLocalYPos * this->getWidth() +
96 iLocalZPos * this->getWidth() * this->getHeight()
104 template <
typename VoxelType>
107 return getVoxel(v3dPos.
getX(), v3dPos.
getY(), v3dPos.
getZ());
116 template <
typename VoxelType>
119 if(this->m_regValidRegion.containsPoint(
Vector3DInt32(uXPos, uYPos, uZPos)))
121 const Vector3DInt32& v3dLowerCorner = this->m_regValidRegion.getLowerCorner();
122 int32_t iLocalXPos = uXPos - v3dLowerCorner.
getX();
123 int32_t iLocalYPos = uYPos - v3dLowerCorner.
getY();
124 int32_t iLocalZPos = uZPos - v3dLowerCorner.
getZ();
129 iLocalYPos * this->getWidth() +
130 iLocalZPos * this->getWidth() * this->getHeight()
135 return this->getBorderValue();
143 template <
typename VoxelType>
146 return getVoxelAt(v3dPos.
getX(), v3dPos.
getY(), v3dPos.
getZ());
155 template <
typename VoxelType>
163 uXPos = (std::max)(uXPos, this->m_regValidRegion.getLowerX());
164 uYPos = (std::max)(uYPos, this->m_regValidRegion.getLowerY());
165 uZPos = (std::max)(uZPos, this->m_regValidRegion.getLowerZ());
166 uXPos = (std::min)(uXPos, this->m_regValidRegion.getUpperX());
167 uYPos = (std::min)(uYPos, this->m_regValidRegion.getUpperY());
168 uZPos = (std::min)(uZPos, this->m_regValidRegion.getUpperZ());
171 return getVoxel(uXPos, uYPos, uZPos);
176 if(this->m_regValidRegion.containsPoint(uXPos, uYPos, uZPos))
178 return getVoxel(uXPos, uYPos, uZPos);
199 template <
typename VoxelType>
202 return getVoxelWithWrapping(v3dPos.
getX(), v3dPos.
getY(), v3dPos.
getZ(), eWrapMode, tBorder);
212 template <
typename VoxelType>
215 if(this->m_regValidRegion.containsPoint(
Vector3DInt32(uXPos, uYPos, uZPos)))
217 const Vector3DInt32& v3dLowerCorner = this->m_regValidRegion.getLowerCorner();
218 int32_t iLocalXPos = uXPos - v3dLowerCorner.
getX();
219 int32_t iLocalYPos = uYPos - v3dLowerCorner.
getY();
220 int32_t iLocalZPos = uZPos - v3dLowerCorner.
getZ();
225 iLocalYPos * this->getWidth() +
226 iLocalZPos * this->getWidth() * this->getHeight()
243 template <
typename VoxelType>
246 return setVoxelAt(v3dPos.
getX(), v3dPos.
getY(), v3dPos.
getZ(), tValue);
252 template <
typename VoxelType>
255 this->m_regValidRegion = regValidRegion;
258 POLYVOX_ASSERT(this->getWidth() > 0,
"Volume width must be greater than zero.");
259 POLYVOX_ASSERT(this->getHeight() > 0,
"Volume width must be greater than zero.");
260 POLYVOX_ASSERT(this->getDepth() > 0,
"Volume width must be greater than zero.");
263 m_pData =
new VoxelType[this->getWidth() * this->getHeight()* this->getDepth()];
266 this->m_uLongestSideLength = (std::max)((std::max)(this->getWidth(),this->getHeight()),this->getDepth());
267 this->m_uShortestSideLength = (std::min)((std::min)(this->getWidth(),this->getHeight()),this->getDepth());
268 this->m_fDiagonalLength = sqrtf(static_cast<float>(this->getWidth() * this->getWidth() + this->getHeight() * this->getHeight() + this->getDepth() * this->getDepth()));
274 template <
typename VoxelType>
277 return this->getWidth() * this->getHeight() * this->getDepth() *
sizeof(
VoxelType);