Initial version of RawVolume as copy of SimpleVolume.
This commit is contained in:
@ -42,6 +42,10 @@ SET(CORE_INC_FILES
|
|||||||
include/PolyVoxCore/MeshDecimator.h
|
include/PolyVoxCore/MeshDecimator.h
|
||||||
include/PolyVoxCore/MeshDecimator.inl
|
include/PolyVoxCore/MeshDecimator.inl
|
||||||
include/PolyVoxCore/PolyVoxForwardDeclarations.h
|
include/PolyVoxCore/PolyVoxForwardDeclarations.h
|
||||||
|
include/PolyVoxCore/RawVolume.h
|
||||||
|
include/PolyVoxCore/RawVolume.inl
|
||||||
|
include/PolyVoxCore/RawVolumeBlock.inl
|
||||||
|
include/PolyVoxCore/RawVolumeSampler.inl
|
||||||
include/PolyVoxCore/Raycast.h
|
include/PolyVoxCore/Raycast.h
|
||||||
include/PolyVoxCore/Raycast.inl
|
include/PolyVoxCore/Raycast.inl
|
||||||
include/PolyVoxCore/RaycastWithCallback.h
|
include/PolyVoxCore/RaycastWithCallback.h
|
||||||
@ -49,6 +53,7 @@ SET(CORE_INC_FILES
|
|||||||
include/PolyVoxCore/Region.h
|
include/PolyVoxCore/Region.h
|
||||||
include/PolyVoxCore/SimpleVolume.h
|
include/PolyVoxCore/SimpleVolume.h
|
||||||
include/PolyVoxCore/SimpleVolume.inl
|
include/PolyVoxCore/SimpleVolume.inl
|
||||||
|
include/PolyVoxCore/SimpleVolumeBlock.inl
|
||||||
include/PolyVoxCore/SimpleVolumeSampler.inl
|
include/PolyVoxCore/SimpleVolumeSampler.inl
|
||||||
include/PolyVoxCore/SurfaceExtractor.h
|
include/PolyVoxCore/SurfaceExtractor.h
|
||||||
include/PolyVoxCore/SurfaceExtractor.inl
|
include/PolyVoxCore/SurfaceExtractor.inl
|
||||||
|
221
library/PolyVoxCore/include/PolyVoxCore/RawVolume.h
Normal file
221
library/PolyVoxCore/include/PolyVoxCore/RawVolume.h
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
Copyright (c) 2005-2009 David Williams
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __PolyVox_RawVolume_H__
|
||||||
|
#define __PolyVox_RawVolume_H__
|
||||||
|
|
||||||
|
#include "PolyVoxCore/Region.h"
|
||||||
|
#include "PolyVoxCore/PolyVoxForwardDeclarations.h"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
|
namespace PolyVox
|
||||||
|
{
|
||||||
|
template <typename VoxelType>
|
||||||
|
class RawVolume
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
#ifndef SWIG
|
||||||
|
class Block
|
||||||
|
{
|
||||||
|
//Make Sampler a friend
|
||||||
|
friend class RawVolume<VoxelType>::Sampler;
|
||||||
|
public:
|
||||||
|
Block(uint16_t uSideLength = 0);
|
||||||
|
|
||||||
|
uint16_t getSideLength(void) const;
|
||||||
|
VoxelType getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const;
|
||||||
|
VoxelType getVoxelAt(const Vector3DUint16& v3dPos) const;
|
||||||
|
|
||||||
|
void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue);
|
||||||
|
void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue);
|
||||||
|
|
||||||
|
void fill(VoxelType tValue);
|
||||||
|
void initialise(uint16_t uSideLength);
|
||||||
|
uint32_t calculateSizeInBytes(void);
|
||||||
|
|
||||||
|
public:
|
||||||
|
VoxelType* m_tUncompressedData;
|
||||||
|
uint16_t m_uSideLength;
|
||||||
|
uint8_t m_uSideLengthPower;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Sampler
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Sampler(RawVolume<VoxelType>* volume);
|
||||||
|
~Sampler();
|
||||||
|
|
||||||
|
Sampler& operator=(const Sampler& rhs) throw();
|
||||||
|
|
||||||
|
int32_t getPosX(void) const;
|
||||||
|
int32_t getPosY(void) const;
|
||||||
|
int32_t getPosZ(void) const;
|
||||||
|
VoxelType getSubSampledVoxel(uint8_t uLevel) const;
|
||||||
|
const RawVolume<VoxelType>* getVolume(void) const;
|
||||||
|
inline VoxelType getVoxel(void) const;
|
||||||
|
|
||||||
|
void setPosition(const Vector3DInt32& v3dNewPos);
|
||||||
|
void setPosition(int32_t xPos, int32_t yPos, int32_t zPos);
|
||||||
|
|
||||||
|
void movePositiveX(void);
|
||||||
|
void movePositiveY(void);
|
||||||
|
void movePositiveZ(void);
|
||||||
|
|
||||||
|
void moveNegativeX(void);
|
||||||
|
void moveNegativeY(void);
|
||||||
|
void moveNegativeZ(void);
|
||||||
|
|
||||||
|
inline VoxelType peekVoxel1nx1ny1nz(void) const;
|
||||||
|
inline VoxelType peekVoxel1nx1ny0pz(void) const;
|
||||||
|
inline VoxelType peekVoxel1nx1ny1pz(void) const;
|
||||||
|
inline VoxelType peekVoxel1nx0py1nz(void) const;
|
||||||
|
inline VoxelType peekVoxel1nx0py0pz(void) const;
|
||||||
|
inline VoxelType peekVoxel1nx0py1pz(void) const;
|
||||||
|
inline VoxelType peekVoxel1nx1py1nz(void) const;
|
||||||
|
inline VoxelType peekVoxel1nx1py0pz(void) const;
|
||||||
|
inline VoxelType peekVoxel1nx1py1pz(void) const;
|
||||||
|
|
||||||
|
inline VoxelType peekVoxel0px1ny1nz(void) const;
|
||||||
|
inline VoxelType peekVoxel0px1ny0pz(void) const;
|
||||||
|
inline VoxelType peekVoxel0px1ny1pz(void) const;
|
||||||
|
inline VoxelType peekVoxel0px0py1nz(void) const;
|
||||||
|
inline VoxelType peekVoxel0px0py0pz(void) const;
|
||||||
|
inline VoxelType peekVoxel0px0py1pz(void) const;
|
||||||
|
inline VoxelType peekVoxel0px1py1nz(void) const;
|
||||||
|
inline VoxelType peekVoxel0px1py0pz(void) const;
|
||||||
|
inline VoxelType peekVoxel0px1py1pz(void) const;
|
||||||
|
|
||||||
|
inline VoxelType peekVoxel1px1ny1nz(void) const;
|
||||||
|
inline VoxelType peekVoxel1px1ny0pz(void) const;
|
||||||
|
inline VoxelType peekVoxel1px1ny1pz(void) const;
|
||||||
|
inline VoxelType peekVoxel1px0py1nz(void) const;
|
||||||
|
inline VoxelType peekVoxel1px0py0pz(void) const;
|
||||||
|
inline VoxelType peekVoxel1px0py1pz(void) const;
|
||||||
|
inline VoxelType peekVoxel1px1py1nz(void) const;
|
||||||
|
inline VoxelType peekVoxel1px1py0pz(void) const;
|
||||||
|
inline VoxelType peekVoxel1px1py1pz(void) const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//The current volume
|
||||||
|
RawVolume<VoxelType>* mVolume;
|
||||||
|
|
||||||
|
//The current position in the volume
|
||||||
|
int32_t mXPosInVolume;
|
||||||
|
int32_t mYPosInVolume;
|
||||||
|
int32_t mZPosInVolume;
|
||||||
|
|
||||||
|
//Other current position information
|
||||||
|
VoxelType* mCurrentVoxel;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public:
|
||||||
|
/// Constructor for creating a fixed size volume.
|
||||||
|
RawVolume
|
||||||
|
(
|
||||||
|
const Region& regValid,
|
||||||
|
uint16_t uBlockSideLength = 32
|
||||||
|
);
|
||||||
|
/// Deprecated constructor - do not use.
|
||||||
|
RawVolume
|
||||||
|
(
|
||||||
|
int32_t dont_use_this_constructor_1, int32_t dont_use_this_constructor_2, int32_t dont_use_this_constructor_3
|
||||||
|
);
|
||||||
|
/// Destructor
|
||||||
|
~RawVolume();
|
||||||
|
|
||||||
|
/// Gets the value used for voxels which are outside the volume
|
||||||
|
VoxelType getBorderValue(void) const;
|
||||||
|
/// Gets a Region representing the extents of the RawVolume.
|
||||||
|
Region getEnclosingRegion(void) const;
|
||||||
|
/// Gets the width of the volume in voxels.
|
||||||
|
int32_t getWidth(void) const;
|
||||||
|
/// Gets the height of the volume in voxels.
|
||||||
|
int32_t getHeight(void) const;
|
||||||
|
/// Gets the depth of the volume in voxels.
|
||||||
|
int32_t getDepth(void) const;
|
||||||
|
/// Gets the length of the longest side in voxels
|
||||||
|
int32_t getLongestSideLength(void) const;
|
||||||
|
/// Gets the length of the shortest side in voxels
|
||||||
|
int32_t getShortestSideLength(void) const;
|
||||||
|
/// Gets the length of the diagonal in voxels
|
||||||
|
float getDiagonalLength(void) const;
|
||||||
|
/// Gets a voxel at the position given by <tt>x,y,z</tt> coordinates
|
||||||
|
VoxelType getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const;
|
||||||
|
/// Gets a voxel at the position given by a 3D vector
|
||||||
|
VoxelType getVoxelAt(const Vector3DInt32& v3dPos) const;
|
||||||
|
|
||||||
|
/// Sets the value used for voxels which are outside the volume
|
||||||
|
void setBorderValue(const VoxelType& tBorder);
|
||||||
|
/// 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);
|
||||||
|
/// Sets the voxel at the position given by a 3D vector
|
||||||
|
bool setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue);
|
||||||
|
|
||||||
|
/// Calculates approximatly how many bytes of memory the volume is currently using.
|
||||||
|
uint32_t calculateSizeInBytes(void);
|
||||||
|
|
||||||
|
/// Deprecated - I don't think we should expose this function? Let us know if you disagree...
|
||||||
|
void resize(const Region& regValidRegion, uint16_t uBlockSideLength);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Block* getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const;
|
||||||
|
|
||||||
|
//The block data
|
||||||
|
Block* m_pBlocks;
|
||||||
|
|
||||||
|
//We don't store an actual Block for the border, just the uncompressed data. This is partly because the border
|
||||||
|
//block does not have a position (so can't be passed to getUncompressedBlock()) and partly because there's a
|
||||||
|
//good chance we'll often hit it anyway. It's a chunk of homogenous data (rather than a single value) so that
|
||||||
|
//the VolumeIterator can do it's usual pointer arithmetic without needing to know it's gone outside the volume.
|
||||||
|
VoxelType* m_pUncompressedBorderData;
|
||||||
|
|
||||||
|
//The size of the volume
|
||||||
|
Region m_regValidRegion;
|
||||||
|
Region m_regValidRegionInBlocks;
|
||||||
|
|
||||||
|
//Volume size measured in blocks.
|
||||||
|
uint32_t m_uNoOfBlocksInVolume;
|
||||||
|
uint16_t m_uWidthInBlocks;
|
||||||
|
uint16_t m_uHeightInBlocks;
|
||||||
|
uint16_t m_uDepthInBlocks;
|
||||||
|
|
||||||
|
//The size of the blocks
|
||||||
|
uint16_t m_uBlockSideLength;
|
||||||
|
uint8_t m_uBlockSideLengthPower;
|
||||||
|
|
||||||
|
//Some useful sizes
|
||||||
|
int32_t m_uLongestSideLength;
|
||||||
|
int32_t m_uShortestSideLength;
|
||||||
|
float m_fDiagonalLength;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "PolyVoxCore/RawVolumeBlock.inl"
|
||||||
|
#include "PolyVoxCore/RawVolume.inl"
|
||||||
|
#include "PolyVoxCore/RawVolumeSampler.inl"
|
||||||
|
|
||||||
|
#endif //__PolyVox_RawVolume_H__
|
350
library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl
Normal file
350
library/PolyVoxCore/include/PolyVoxCore/RawVolume.inl
Normal file
@ -0,0 +1,350 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
Copyright (c) 2005-2009 David Williams
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "PolyVoxCore/ConstVolumeProxy.h"
|
||||||
|
#include "PolyVoxImpl/Block.h"
|
||||||
|
#include "PolyVoxCore/Log.h"
|
||||||
|
#include "PolyVoxCore/Region.h"
|
||||||
|
#include "PolyVoxCore/Vector.h"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstdlib> //For abort()
|
||||||
|
#include <stdexcept> //For invalid_argument
|
||||||
|
|
||||||
|
namespace PolyVox
|
||||||
|
{
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Deprecated - do not use this constructor.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
RawVolume<VoxelType>::RawVolume
|
||||||
|
(
|
||||||
|
int32_t dont_use_this_constructor_1, int32_t dont_use_this_constructor_2, int32_t dont_use_this_constructor_3
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//In earlier verions of PolyVox the constructor took three values indicating width, height, and depth. However, this
|
||||||
|
//causes confusion because these three parameters can be interpreted as two function pointers and a block size instead,
|
||||||
|
//hence calling a different constructor. And simply removing this constructor will cause confusion because existing
|
||||||
|
//code with three parameters will then always resolve to the constructor with two function pointers and a block size.
|
||||||
|
//
|
||||||
|
//Eventually this constructor will be removed, it's just here to make people change their code to the new version.
|
||||||
|
//
|
||||||
|
//IF YOU HIT THIS ASSERT/ABORT, CHANGE YOUR CODE TO USE THE CONSTRUCTOR TAKING A 'Region' INSTEAD.
|
||||||
|
assert(false);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// This constructor creates a volume with a fixed size which is specified as a parameter. By default this constructor will not enable paging but you can override this if desired. If you do wish to enable paging then you are required to provide the call back function (see the other RawVolume constructor).
|
||||||
|
/// \param regValid Specifies the minimum and maximum valid voxel positions.
|
||||||
|
/// \param dataRequiredHandler The callback function which will be called when PolyVox tries to use data which is not currently in momory.
|
||||||
|
/// \param dataOverflowHandler The callback function which will be called when PolyVox has too much data and needs to remove some from memory.
|
||||||
|
/// \param bPagingEnabled Controls whether or not paging is enabled for this RawVolume.
|
||||||
|
/// \param uBlockSideLength The size of the blocks making up the volume. Small blocks will compress/decompress faster, but there will also be more of them meaning voxel access could be slower.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
RawVolume<VoxelType>::RawVolume
|
||||||
|
(
|
||||||
|
const Region& regValid,
|
||||||
|
uint16_t uBlockSideLength
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//Create a volume of the right size.
|
||||||
|
resize(regValid,uBlockSideLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Destroys the volume
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
RawVolume<VoxelType>::~RawVolume()
|
||||||
|
{
|
||||||
|
delete[] m_pBlocks;
|
||||||
|
m_pBlocks = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// The border value is returned whenever an atempt is made to read a voxel which
|
||||||
|
/// is outside the extents of the volume.
|
||||||
|
/// \return The value used for voxels outside of the volume
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::getBorderValue(void) const
|
||||||
|
{
|
||||||
|
return *m_pUncompressedBorderData;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \return A Region representing the extent of the volume.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
Region RawVolume<VoxelType>::getEnclosingRegion(void) const
|
||||||
|
{
|
||||||
|
return m_regValidRegion;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \return The width of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the width is 64.
|
||||||
|
/// \sa getHeight(), getDepth()
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
int32_t RawVolume<VoxelType>::getWidth(void) const
|
||||||
|
{
|
||||||
|
return m_regValidRegion.getUpperCorner().getX() - m_regValidRegion.getLowerCorner().getX() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \return The height of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the height is 64.
|
||||||
|
/// \sa getWidth(), getDepth()
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
int32_t RawVolume<VoxelType>::getHeight(void) const
|
||||||
|
{
|
||||||
|
return m_regValidRegion.getUpperCorner().getY() - m_regValidRegion.getLowerCorner().getY() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \return The depth of the volume in voxels. Note that this value is inclusive, so that if the valid range is e.g. 0 to 63 then the depth is 64.
|
||||||
|
/// \sa getWidth(), getHeight()
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
int32_t RawVolume<VoxelType>::getDepth(void) const
|
||||||
|
{
|
||||||
|
return m_regValidRegion.getUpperCorner().getZ() - m_regValidRegion.getLowerCorner().getZ() + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \return The length of the shortest side in voxels. For example, if a volume has
|
||||||
|
/// dimensions 256x512x1024 this function will return 256.
|
||||||
|
/// \sa getLongestSideLength(), getDiagonalLength()
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
int32_t RawVolume<VoxelType>::getShortestSideLength(void) const
|
||||||
|
{
|
||||||
|
return m_uShortestSideLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \return The length of the longest side in voxels. For example, if a volume has
|
||||||
|
/// dimensions 256x512x1024 this function will return 1024.
|
||||||
|
/// \sa getShortestSideLength(), getDiagonalLength()
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
int32_t RawVolume<VoxelType>::getLongestSideLength(void) const
|
||||||
|
{
|
||||||
|
return m_uLongestSideLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \return The length of the diagonal in voxels. For example, if a volume has
|
||||||
|
/// dimensions 256x512x1024 this function will return sqrt(256*256+512*512+1024*1024)
|
||||||
|
/// = 1173.139. This value is computed on volume creation so retrieving it is fast.
|
||||||
|
/// \sa getShortestSideLength(), getLongestSideLength()
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
float RawVolume<VoxelType>::getDiagonalLength(void) const
|
||||||
|
{
|
||||||
|
return m_fDiagonalLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \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
|
||||||
|
/// \return The voxel value
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::getVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos) const
|
||||||
|
{
|
||||||
|
if(m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)))
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
RawVolume<VoxelType>::Block* pUncompressedBlock = getUncompressedBlock(blockX, blockY, blockZ);
|
||||||
|
|
||||||
|
return pUncompressedBlock->getVoxelAt(xOffset,yOffset,zOffset);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return getBorderValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \param v3dPos The 3D position of the voxel
|
||||||
|
/// \return The voxel value
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::getVoxelAt(const Vector3DInt32& v3dPos) const
|
||||||
|
{
|
||||||
|
return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \param tBorder The value to use for voxels outside the volume.
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::setBorderValue(const VoxelType& tBorder)
|
||||||
|
{
|
||||||
|
/*Block<VoxelType>* pUncompressedBorderBlock = getUncompressedBlock(&m_pBorderBlock);
|
||||||
|
return pUncompressedBorderBlock->fill(tBorder);*/
|
||||||
|
std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength, 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>
|
||||||
|
bool RawVolume<VoxelType>::setVoxelAt(int32_t uXPos, int32_t uYPos, int32_t uZPos, VoxelType tValue)
|
||||||
|
{
|
||||||
|
assert(m_regValidRegion.containsPoint(Vector3DInt32(uXPos, uYPos, uZPos)));
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
RawVolume<VoxelType>::Block* pUncompressedBlock = getUncompressedBlock(blockX, blockY, blockZ);
|
||||||
|
|
||||||
|
pUncompressedBlock->setVoxelAt(xOffset,yOffset,zOffset, tValue);
|
||||||
|
|
||||||
|
//Return true to indicate that we modified a voxel.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// \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>
|
||||||
|
bool RawVolume<VoxelType>::setVoxelAt(const Vector3DInt32& v3dPos, VoxelType tValue)
|
||||||
|
{
|
||||||
|
return setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// This function should probably be made internal...
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::resize(const Region& regValidRegion, uint16_t uBlockSideLength)
|
||||||
|
{
|
||||||
|
//Debug mode validation
|
||||||
|
assert(uBlockSideLength > 0);
|
||||||
|
|
||||||
|
//Release mode validation
|
||||||
|
if(uBlockSideLength == 0)
|
||||||
|
{
|
||||||
|
throw std::invalid_argument("Block side length cannot be zero.");
|
||||||
|
}
|
||||||
|
if(!isPowerOf2(uBlockSideLength))
|
||||||
|
{
|
||||||
|
throw std::invalid_argument("Block side length must be a power of two.");
|
||||||
|
}
|
||||||
|
|
||||||
|
m_uBlockSideLength = uBlockSideLength;
|
||||||
|
m_pUncompressedBorderData = 0;
|
||||||
|
|
||||||
|
m_regValidRegion = regValidRegion;
|
||||||
|
|
||||||
|
m_regValidRegionInBlocks.setLowerCorner(m_regValidRegion.getLowerCorner() / static_cast<int32_t>(uBlockSideLength));
|
||||||
|
m_regValidRegionInBlocks.setUpperCorner(m_regValidRegion.getUpperCorner() / static_cast<int32_t>(uBlockSideLength));
|
||||||
|
|
||||||
|
//Compute the block side length
|
||||||
|
m_uBlockSideLength = uBlockSideLength;
|
||||||
|
m_uBlockSideLengthPower = logBase2(m_uBlockSideLength);
|
||||||
|
|
||||||
|
//Compute the size of the volume in blocks (and note +1 at the end)
|
||||||
|
m_uWidthInBlocks = m_regValidRegionInBlocks.getUpperCorner().getX() - m_regValidRegionInBlocks.getLowerCorner().getX() + 1;
|
||||||
|
m_uHeightInBlocks = m_regValidRegionInBlocks.getUpperCorner().getY() - m_regValidRegionInBlocks.getLowerCorner().getY() + 1;
|
||||||
|
m_uDepthInBlocks = m_regValidRegionInBlocks.getUpperCorner().getZ() - m_regValidRegionInBlocks.getLowerCorner().getZ() + 1;
|
||||||
|
m_uNoOfBlocksInVolume = m_uWidthInBlocks * m_uHeightInBlocks * m_uDepthInBlocks;
|
||||||
|
|
||||||
|
//Allocate the data
|
||||||
|
m_pBlocks = new Block[m_uNoOfBlocksInVolume];
|
||||||
|
for(uint32_t i = 0; i < m_uNoOfBlocksInVolume; ++i)
|
||||||
|
{
|
||||||
|
m_pBlocks[i].initialise(m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create the border block
|
||||||
|
m_pUncompressedBorderData = new VoxelType[m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength];
|
||||||
|
std::fill(m_pUncompressedBorderData, m_pUncompressedBorderData + m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength, VoxelType());
|
||||||
|
|
||||||
|
//Other properties we might find useful later
|
||||||
|
m_uLongestSideLength = (std::max)((std::max)(getWidth(),getHeight()),getDepth());
|
||||||
|
m_uShortestSideLength = (std::min)((std::min)(getWidth(),getHeight()),getDepth());
|
||||||
|
m_fDiagonalLength = sqrtf(static_cast<float>(getWidth() * getWidth() + getHeight() * getHeight() + getDepth() * getDepth()));
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
typename RawVolume<VoxelType>::Block* RawVolume<VoxelType>::getUncompressedBlock(int32_t uBlockX, int32_t uBlockY, int32_t uBlockZ) const
|
||||||
|
{
|
||||||
|
//The lower left corner of the volume could be
|
||||||
|
//anywhere, but array indices need to start at zero.
|
||||||
|
uBlockX -= m_regValidRegionInBlocks.getLowerCorner().getX();
|
||||||
|
uBlockY -= m_regValidRegionInBlocks.getLowerCorner().getY();
|
||||||
|
uBlockZ -= m_regValidRegionInBlocks.getLowerCorner().getZ();
|
||||||
|
|
||||||
|
//Compute the block index
|
||||||
|
uint32_t uBlockIndex =
|
||||||
|
uBlockX +
|
||||||
|
uBlockY * m_uWidthInBlocks +
|
||||||
|
uBlockZ * m_uWidthInBlocks * m_uHeightInBlocks;
|
||||||
|
|
||||||
|
//Return the block
|
||||||
|
return &(m_pBlocks[uBlockIndex]);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// Note: This function needs reviewing for accuracy...
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
template <typename VoxelType>
|
||||||
|
uint32_t RawVolume<VoxelType>::calculateSizeInBytes(void)
|
||||||
|
{
|
||||||
|
uint32_t uSizeInBytes = sizeof(RawVolume);
|
||||||
|
|
||||||
|
uint32_t uSizeOfBlockInBytes = m_uBlockSideLength * m_uBlockSideLength * m_uBlockSideLength * sizeof(VoxelType);
|
||||||
|
|
||||||
|
//Memory used by the blocks ( + 1 is for border)
|
||||||
|
uSizeInBytes += uSizeOfBlockInBytes * (m_uNoOfBlocksInVolume + 1);
|
||||||
|
|
||||||
|
return uSizeInBytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
133
library/PolyVoxCore/include/PolyVoxCore/RawVolumeBlock.inl
Normal file
133
library/PolyVoxCore/include/PolyVoxCore/RawVolumeBlock.inl
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
Copyright (c) 2005-2009 David Williams
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "PolyVoxImpl/Utility.h"
|
||||||
|
#include "Vector.h"
|
||||||
|
|
||||||
|
#include <cassert>
|
||||||
|
#include <cstring> //For memcpy
|
||||||
|
#include <limits>
|
||||||
|
#include <stdexcept> //for std::invalid_argument
|
||||||
|
|
||||||
|
namespace PolyVox
|
||||||
|
{
|
||||||
|
template <typename VoxelType>
|
||||||
|
RawVolume<VoxelType>::Block::Block(uint16_t uSideLength)
|
||||||
|
:m_uSideLength(0)
|
||||||
|
,m_uSideLengthPower(0)
|
||||||
|
,m_tUncompressedData(0)
|
||||||
|
{
|
||||||
|
if(uSideLength != 0)
|
||||||
|
{
|
||||||
|
initialise(uSideLength);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
uint16_t RawVolume<VoxelType>::Block::getSideLength(void) const
|
||||||
|
{
|
||||||
|
return m_uSideLength;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Block::getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const
|
||||||
|
{
|
||||||
|
assert(uXPos < m_uSideLength);
|
||||||
|
assert(uYPos < m_uSideLength);
|
||||||
|
assert(uZPos < m_uSideLength);
|
||||||
|
|
||||||
|
assert(m_tUncompressedData);
|
||||||
|
|
||||||
|
return m_tUncompressedData
|
||||||
|
[
|
||||||
|
uXPos +
|
||||||
|
uYPos * m_uSideLength +
|
||||||
|
uZPos * m_uSideLength * m_uSideLength
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Block::getVoxelAt(const Vector3DUint16& v3dPos) const
|
||||||
|
{
|
||||||
|
return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Block::setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue)
|
||||||
|
{
|
||||||
|
assert(uXPos < m_uSideLength);
|
||||||
|
assert(uYPos < m_uSideLength);
|
||||||
|
assert(uZPos < m_uSideLength);
|
||||||
|
|
||||||
|
assert(m_tUncompressedData);
|
||||||
|
|
||||||
|
m_tUncompressedData
|
||||||
|
[
|
||||||
|
uXPos +
|
||||||
|
uYPos * m_uSideLength +
|
||||||
|
uZPos * m_uSideLength * m_uSideLength
|
||||||
|
] = tValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Block::setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue)
|
||||||
|
{
|
||||||
|
setVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ(), tValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Block::fill(VoxelType tValue)
|
||||||
|
{
|
||||||
|
const uint32_t uNoOfVoxels = m_uSideLength * m_uSideLength * m_uSideLength;
|
||||||
|
std::fill(m_tUncompressedData, m_tUncompressedData + uNoOfVoxels, tValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Block::initialise(uint16_t uSideLength)
|
||||||
|
{
|
||||||
|
//Debug mode validation
|
||||||
|
assert(isPowerOf2(uSideLength));
|
||||||
|
|
||||||
|
//Release mode validation
|
||||||
|
if(!isPowerOf2(uSideLength))
|
||||||
|
{
|
||||||
|
throw std::invalid_argument("Block side length must be a power of two.");
|
||||||
|
}
|
||||||
|
|
||||||
|
//Compute the side length
|
||||||
|
m_uSideLength = uSideLength;
|
||||||
|
m_uSideLengthPower = logBase2(uSideLength);
|
||||||
|
|
||||||
|
m_tUncompressedData = new VoxelType[m_uSideLength * m_uSideLength * m_uSideLength];
|
||||||
|
|
||||||
|
RawVolume<VoxelType>::Block::fill(VoxelType());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
uint32_t RawVolume<VoxelType>::Block::calculateSizeInBytes(void)
|
||||||
|
{
|
||||||
|
uint32_t uSizeInBytes = sizeof(Block);
|
||||||
|
uSizeInBytes += sizeof(VoxelType) * m_uSideLength * m_uSideLength * m_uSideLength;
|
||||||
|
return uSizeInBytes;
|
||||||
|
}
|
||||||
|
}
|
533
library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl
Normal file
533
library/PolyVoxCore/include/PolyVoxCore/RawVolumeSampler.inl
Normal file
@ -0,0 +1,533 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
Copyright (c) 2005-2009 David Williams
|
||||||
|
|
||||||
|
This software is provided 'as-is', without any express or implied
|
||||||
|
warranty. In no event will the authors be held liable for any damages
|
||||||
|
arising from the use of this software.
|
||||||
|
|
||||||
|
Permission is granted to anyone to use this software for any purpose,
|
||||||
|
including commercial applications, and to alter it and redistribute it
|
||||||
|
freely, subject to the following restrictions:
|
||||||
|
|
||||||
|
1. The origin of this software must not be misrepresented; you must not
|
||||||
|
claim that you wrote the original software. If you use this software
|
||||||
|
in a product, an acknowledgment in the product documentation would be
|
||||||
|
appreciated but is not required.
|
||||||
|
|
||||||
|
2. Altered source versions must be plainly marked as such, and must not be
|
||||||
|
misrepresented as being the original software.
|
||||||
|
|
||||||
|
3. This notice may not be removed or altered from any source
|
||||||
|
distribution.
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include "PolyVoxImpl/Block.h"
|
||||||
|
#include "PolyVoxCore/RawVolume.h"
|
||||||
|
#include "PolyVoxCore/Vector.h"
|
||||||
|
#include "PolyVoxCore/Region.h"
|
||||||
|
|
||||||
|
#define BORDER_LOW(x) ((( x >> mVolume->m_uBlockSideLengthPower) << mVolume->m_uBlockSideLengthPower) != x)
|
||||||
|
#define BORDER_HIGH(x) ((( (x+1) >> mVolume->m_uBlockSideLengthPower) << mVolume->m_uBlockSideLengthPower) != (x+1))
|
||||||
|
//#define BORDER_LOW(x) (( x % mVolume->m_uBlockSideLength) != 0)
|
||||||
|
//#define BORDER_HIGH(x) (( x % mVolume->m_uBlockSideLength) != mVolume->m_uBlockSideLength - 1)
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
namespace PolyVox
|
||||||
|
{
|
||||||
|
template <typename VoxelType>
|
||||||
|
RawVolume<VoxelType>::Sampler::Sampler(RawVolume<VoxelType>* volume)
|
||||||
|
:mVolume(volume)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
RawVolume<VoxelType>::Sampler::~Sampler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
typename RawVolume<VoxelType>::Sampler& RawVolume<VoxelType>::Sampler::operator=(const typename RawVolume<VoxelType>::Sampler& rhs) throw()
|
||||||
|
{
|
||||||
|
if(this == &rhs)
|
||||||
|
{
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
mVolume = rhs.mVolume;
|
||||||
|
mXPosInVolume = rhs.mXPosInVolume;
|
||||||
|
mYPosInVolume = rhs.mYPosInVolume;
|
||||||
|
mZPosInVolume = rhs.mZPosInVolume;
|
||||||
|
mCurrentVoxel = rhs.mCurrentVoxel;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
int32_t RawVolume<VoxelType>::Sampler::getPosX(void) const
|
||||||
|
{
|
||||||
|
return mXPosInVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
int32_t RawVolume<VoxelType>::Sampler::getPosY(void) const
|
||||||
|
{
|
||||||
|
return mYPosInVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
int32_t RawVolume<VoxelType>::Sampler::getPosZ(void) const
|
||||||
|
{
|
||||||
|
return mZPosInVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::getSubSampledVoxel(uint8_t uLevel) const
|
||||||
|
{
|
||||||
|
if(uLevel == 0)
|
||||||
|
{
|
||||||
|
return getVoxel();
|
||||||
|
}
|
||||||
|
else if(uLevel == 1)
|
||||||
|
{
|
||||||
|
VoxelType tValue = getVoxel();
|
||||||
|
tValue = (std::min)(tValue, peekVoxel1px0py0pz());
|
||||||
|
tValue = (std::min)(tValue, peekVoxel0px1py0pz());
|
||||||
|
tValue = (std::min)(tValue, peekVoxel1px1py0pz());
|
||||||
|
tValue = (std::min)(tValue, peekVoxel0px0py1pz());
|
||||||
|
tValue = (std::min)(tValue, peekVoxel1px0py1pz());
|
||||||
|
tValue = (std::min)(tValue, peekVoxel0px1py1pz());
|
||||||
|
tValue = (std::min)(tValue, peekVoxel1px1py1pz());
|
||||||
|
return tValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
const uint8_t uSize = 1 << uLevel;
|
||||||
|
|
||||||
|
VoxelType tValue = (std::numeric_limits<VoxelType>::max)();
|
||||||
|
for(uint8_t z = 0; z < uSize; ++z)
|
||||||
|
{
|
||||||
|
for(uint8_t y = 0; y < uSize; ++y)
|
||||||
|
{
|
||||||
|
for(uint8_t x = 0; x < uSize; ++x)
|
||||||
|
{
|
||||||
|
tValue = (std::min)(tValue, mVolume->getVoxelAt(mXPosInVolume + x, mYPosInVolume + y, mZPosInVolume + z));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return tValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
const RawVolume<VoxelType>* RawVolume<VoxelType>::Sampler::getVolume(void) const
|
||||||
|
{
|
||||||
|
return mVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::getVoxel(void) const
|
||||||
|
{
|
||||||
|
return *mCurrentVoxel;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Sampler::setPosition(const Vector3DInt32& v3dNewPos)
|
||||||
|
{
|
||||||
|
setPosition(v3dNewPos.getX(), v3dNewPos.getY(), v3dNewPos.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Sampler::setPosition(int32_t xPos, int32_t yPos, int32_t zPos)
|
||||||
|
{
|
||||||
|
mXPosInVolume = xPos;
|
||||||
|
mYPosInVolume = yPos;
|
||||||
|
mZPosInVolume = zPos;
|
||||||
|
|
||||||
|
const int32_t uXBlock = mXPosInVolume >> mVolume->m_uBlockSideLengthPower;
|
||||||
|
const int32_t uYBlock = mYPosInVolume >> mVolume->m_uBlockSideLengthPower;
|
||||||
|
const int32_t uZBlock = mZPosInVolume >> mVolume->m_uBlockSideLengthPower;
|
||||||
|
|
||||||
|
const uint16_t uXPosInBlock = mXPosInVolume - (uXBlock << mVolume->m_uBlockSideLengthPower);
|
||||||
|
const uint16_t uYPosInBlock = mYPosInVolume - (uYBlock << mVolume->m_uBlockSideLengthPower);
|
||||||
|
const uint16_t uZPosInBlock = mZPosInVolume - (uZBlock << mVolume->m_uBlockSideLengthPower);
|
||||||
|
|
||||||
|
const uint32_t uVoxelIndexInBlock = uXPosInBlock +
|
||||||
|
uYPosInBlock * mVolume->m_uBlockSideLength +
|
||||||
|
uZPosInBlock * mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength;
|
||||||
|
|
||||||
|
if(mVolume->m_regValidRegionInBlocks.containsPoint(Vector3DInt32(uXBlock, uYBlock, uZBlock)))
|
||||||
|
{
|
||||||
|
Block* pUncompressedCurrentBlock = mVolume->getUncompressedBlock(uXBlock, uYBlock, uZBlock);
|
||||||
|
|
||||||
|
mCurrentVoxel = pUncompressedCurrentBlock->m_tUncompressedData + uVoxelIndexInBlock;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mCurrentVoxel = mVolume->m_pUncompressedBorderData + uVoxelIndexInBlock;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Sampler::movePositiveX(void)
|
||||||
|
{
|
||||||
|
//Note the *pre* increament here
|
||||||
|
if((++mXPosInVolume) % mVolume->m_uBlockSideLength != 0)
|
||||||
|
{
|
||||||
|
//No need to compute new block.
|
||||||
|
++mCurrentVoxel;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
|
||||||
|
setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Sampler::movePositiveY(void)
|
||||||
|
{
|
||||||
|
//Note the *pre* increament here
|
||||||
|
if((++mYPosInVolume) % mVolume->m_uBlockSideLength != 0)
|
||||||
|
{
|
||||||
|
//No need to compute new block.
|
||||||
|
mCurrentVoxel += mVolume->m_uBlockSideLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
|
||||||
|
setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Sampler::movePositiveZ(void)
|
||||||
|
{
|
||||||
|
//Note the *pre* increament here
|
||||||
|
if((++mZPosInVolume) % mVolume->m_uBlockSideLength != 0)
|
||||||
|
{
|
||||||
|
//No need to compute new block.
|
||||||
|
mCurrentVoxel += mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
|
||||||
|
setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Sampler::moveNegativeX(void)
|
||||||
|
{
|
||||||
|
//Note the *post* decreament here
|
||||||
|
if((mXPosInVolume--) % mVolume->m_uBlockSideLength != 0)
|
||||||
|
{
|
||||||
|
//No need to compute new block.
|
||||||
|
--mCurrentVoxel;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
|
||||||
|
setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Sampler::moveNegativeY(void)
|
||||||
|
{
|
||||||
|
//Note the *post* decreament here
|
||||||
|
if((mYPosInVolume--) % mVolume->m_uBlockSideLength != 0)
|
||||||
|
{
|
||||||
|
//No need to compute new block.
|
||||||
|
mCurrentVoxel -= mVolume->m_uBlockSideLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
|
||||||
|
setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
void RawVolume<VoxelType>::Sampler::moveNegativeZ(void)
|
||||||
|
{
|
||||||
|
//Note the *post* decreament here
|
||||||
|
if((mZPosInVolume--) % mVolume->m_uBlockSideLength != 0)
|
||||||
|
{
|
||||||
|
//No need to compute new block.
|
||||||
|
mCurrentVoxel -= mVolume->m_uBlockSideLength * mVolume->m_uBlockSideLength;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//We've hit the block boundary. Just calling setPosition() is the easiest way to resolve this.
|
||||||
|
setPosition(mXPosInVolume, mYPosInVolume, mZPosInVolume);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny1nz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny0pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1ny1pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume-1,mZPosInVolume+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py1nz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mXPosInVolume) && BORDER_LOW(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - 1 - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py0pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mXPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - 1);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx0py1pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume,mZPosInVolume+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py1nz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mYPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py0pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1nx1py1pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - 1 + mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume-1,mYPosInVolume+1,mZPosInVolume+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny1nz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny0pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mYPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1ny1pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume-1,mZPosInVolume+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px0py1nz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_LOW(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px0py0pz(void) const
|
||||||
|
{
|
||||||
|
return *mCurrentVoxel;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px0py1pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume,mZPosInVolume+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py1nz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py0pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mYPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel0px1py1pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume,mYPosInVolume+1,mZPosInVolume+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny1nz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_LOW(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny0pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1ny1pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume-1,mZPosInVolume+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py1nz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mXPosInVolume) && BORDER_LOW(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + 1 - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py0pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mXPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + 1);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px0py1pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume,mZPosInVolume+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py1nz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_LOW(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength - mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py0pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType RawVolume<VoxelType>::Sampler::peekVoxel1px1py1pz(void) const
|
||||||
|
{
|
||||||
|
if( BORDER_HIGH(mXPosInVolume) && BORDER_HIGH(mYPosInVolume) && BORDER_HIGH(mZPosInVolume) )
|
||||||
|
{
|
||||||
|
return *(mCurrentVoxel + 1 + mVolume->m_uBlockSideLength + mVolume->m_uBlockSideLength*mVolume->m_uBlockSideLength);
|
||||||
|
}
|
||||||
|
return mVolume->getVoxelAt(mXPosInVolume+1,mYPosInVolume+1,mZPosInVolume+1);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user