Optimising SurfaceExtractor.
This commit is contained in:
parent
64318fb546
commit
5a99101341
@ -38,7 +38,7 @@ void OpenGLWidget::setVolume(PolyVox::Volume<PolyVox::uint8_t>* volData)
|
||||
m_uVolumeDepthInRegions = volData->getDepth() / m_uRegionSideLength;
|
||||
|
||||
SurfaceExtractor surfaceExtractor(*volData);
|
||||
surfaceExtractor.setLodLevel(0);
|
||||
surfaceExtractor.setLodLevel(1);
|
||||
|
||||
//Our volume is broken down into cuboid regions, and we create one mesh for each region.
|
||||
//This three-level for loop iterates over each region.
|
||||
|
@ -131,8 +131,6 @@ namespace PolyVox
|
||||
float getDiagonalLength(void) const;
|
||||
VoxelType getVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos) const;
|
||||
VoxelType getVoxelAt(const Vector3DUint16& v3dPos) const;
|
||||
VoxelType getVoxelAtWithBoundCheck(int16_t uXPos, int16_t uYPos, int16_t uZPos) const;
|
||||
VoxelType getVoxelAtWithBoundCheck(const Vector3DInt16& v3dPos) const;
|
||||
|
||||
void setVoxelAt(uint16_t uXPos, uint16_t uYPos, uint16_t uZPos, VoxelType tValue);
|
||||
void setVoxelAt(const Vector3DUint16& v3dPos, VoxelType tValue);
|
||||
|
@ -249,25 +249,6 @@ namespace PolyVox
|
||||
{
|
||||
return getVoxelAt(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType Volume<VoxelType>::getVoxelAtWithBoundCheck(int16_t uXPos, int16_t uYPos, int16_t uZPos) const
|
||||
{
|
||||
if((uXPos >=0) && (uXPos < m_uWidth) && (uYPos >= 0) && (uYPos < m_uHeight) && (uZPos >= 0) && (uZPos < m_uDepth))
|
||||
{
|
||||
return getVoxelAt(uXPos, uYPos, uZPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType Volume<VoxelType>::getVoxelAtWithBoundCheck(const Vector3DInt16& v3dPos) const
|
||||
{
|
||||
return getVoxelAtWithBoundCheck(v3dPos.getX(), v3dPos.getY(), v3dPos.getZ());
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
#pragma region Setters
|
||||
|
@ -47,44 +47,43 @@ namespace PolyVox
|
||||
uint16_t getPosY(void) const;
|
||||
uint16_t getPosZ(void) const;
|
||||
VoxelType getSubSampledVoxel(uint8_t uLevel) const;
|
||||
VoxelType getSubSampledVoxelWithBoundsCheck(uint8_t uLevel) const;
|
||||
const Volume<VoxelType>& getVolume(void) const;
|
||||
VoxelType getVoxel(void) const;
|
||||
inline VoxelType getVoxel(void) const;
|
||||
|
||||
void setPosition(const Vector3DInt16& v3dNewPos);
|
||||
void setPosition(uint16_t xPos, uint16_t yPos, uint16_t zPos);
|
||||
|
||||
void movePositiveX(void);
|
||||
|
||||
VoxelType peekVoxel1nx1ny1nz(void) const;
|
||||
VoxelType peekVoxel1nx1ny0pz(void) const;
|
||||
VoxelType peekVoxel1nx1ny1pz(void) const;
|
||||
VoxelType peekVoxel1nx0py1nz(void) const;
|
||||
VoxelType peekVoxel1nx0py0pz(void) const;
|
||||
VoxelType peekVoxel1nx0py1pz(void) const;
|
||||
VoxelType peekVoxel1nx1py1nz(void) const;
|
||||
VoxelType peekVoxel1nx1py0pz(void) const;
|
||||
VoxelType peekVoxel1nx1py1pz(void) const;
|
||||
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;
|
||||
|
||||
VoxelType peekVoxel0px1ny1nz(void) const;
|
||||
VoxelType peekVoxel0px1ny0pz(void) const;
|
||||
VoxelType peekVoxel0px1ny1pz(void) const;
|
||||
VoxelType peekVoxel0px0py1nz(void) const;
|
||||
VoxelType peekVoxel0px0py0pz(void) const;
|
||||
VoxelType peekVoxel0px0py1pz(void) const;
|
||||
VoxelType peekVoxel0px1py1nz(void) const;
|
||||
VoxelType peekVoxel0px1py0pz(void) const;
|
||||
VoxelType peekVoxel0px1py1pz(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;
|
||||
|
||||
VoxelType peekVoxel1px1ny1nz(void) const;
|
||||
VoxelType peekVoxel1px1ny0pz(void) const;
|
||||
VoxelType peekVoxel1px1ny1pz(void) const;
|
||||
VoxelType peekVoxel1px0py1nz(void) const;
|
||||
VoxelType peekVoxel1px0py0pz(void) const;
|
||||
VoxelType peekVoxel1px0py1pz(void) const;
|
||||
VoxelType peekVoxel1px1py1nz(void) const;
|
||||
VoxelType peekVoxel1px1py0pz(void) const;
|
||||
VoxelType peekVoxel1px1py1pz(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:
|
||||
|
||||
|
@ -163,25 +163,6 @@ namespace PolyVox
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
VoxelType VolumeSampler<VoxelType>::getSubSampledVoxelWithBoundsCheck(uint8_t uLevel) const
|
||||
{
|
||||
const uint8_t uSize = 1 << uLevel;
|
||||
|
||||
if((mXPosInVolume >= 0) && (mXPosInVolume <= mVolume.getWidth() - uSize) &&
|
||||
(mYPosInVolume >= 0) && (mYPosInVolume <= mVolume.getHeight() - uSize) &&
|
||||
(mZPosInVolume >= 0) && (mZPosInVolume <= mVolume.getDepth() - uSize))
|
||||
{
|
||||
return getSubSampledVoxel(uLevel);
|
||||
}
|
||||
else
|
||||
{
|
||||
//If any voxel is outside then it's value will be zero, and so the minimum will be zero.
|
||||
//No need to even look at the rest of the voxels.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
const Volume<VoxelType>& VolumeSampler<VoxelType>::getVolume(void) const
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user