Only the region size constants remain.
This commit is contained in:
parent
f07b617f02
commit
2107128f7c
@ -3,15 +3,6 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
Vector3DFloat computeCentralDifferenceGradient(const VolumeIterator<VoxelType>& volIter)
|
Vector3DFloat computeCentralDifferenceGradient(const VolumeIterator<VoxelType>& volIter)
|
||||||
{
|
{
|
||||||
//FIXME - should this test be here?
|
|
||||||
if((volIter.getPosX() < 1) || (volIter.getPosX() > POLYVOX_VOLUME_SIDE_LENGTH-2) ||
|
|
||||||
(volIter.getPosY() < 1) || (volIter.getPosY() > POLYVOX_VOLUME_SIDE_LENGTH-2) ||
|
|
||||||
(volIter.getPosZ() < 1) || (volIter.getPosZ() > POLYVOX_VOLUME_SIDE_LENGTH-2))
|
|
||||||
{
|
|
||||||
//LogManager::getSingleton().logMessage("Out of range");
|
|
||||||
return Vector3DFloat(0.0,0.0,0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
//FIXME - bitwise way of doing this?
|
//FIXME - bitwise way of doing this?
|
||||||
VoxelType voxel1nx = volIter.peekVoxel1nx0py0pz() > 0 ? 1: 0;
|
VoxelType voxel1nx = volIter.peekVoxel1nx0py0pz() > 0 ? 1: 0;
|
||||||
VoxelType voxel1px = volIter.peekVoxel1px0py0pz() > 0 ? 1: 0;
|
VoxelType voxel1px = volIter.peekVoxel1px0py0pz() > 0 ? 1: 0;
|
||||||
@ -33,15 +24,6 @@ namespace PolyVox
|
|||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
Vector3DFloat computeSobelGradient(const VolumeIterator<VoxelType>& volIter)
|
Vector3DFloat computeSobelGradient(const VolumeIterator<VoxelType>& volIter)
|
||||||
{
|
{
|
||||||
//FIXME - should this test be here?
|
|
||||||
if((volIter.getPosX() < 1) || (volIter.getPosX() > POLYVOX_VOLUME_SIDE_LENGTH-2) ||
|
|
||||||
(volIter.getPosY() < 1) || (volIter.getPosY() > POLYVOX_VOLUME_SIDE_LENGTH-2) ||
|
|
||||||
(volIter.getPosZ() < 1) || (volIter.getPosZ() > POLYVOX_VOLUME_SIDE_LENGTH-2))
|
|
||||||
{
|
|
||||||
//LogManager::getSingleton().logMessage("Out of range");
|
|
||||||
return Vector3DFloat(0.0,0.0,0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, {
|
static const int weights[3][3][3] = { { {2,3,2}, {3,6,3}, {2,3,2} }, {
|
||||||
{3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } };
|
{3,6,3}, {6,0,6}, {3,6,3} }, { {2,3,2}, {3,6,3}, {2,3,2} } };
|
||||||
|
|
||||||
|
@ -71,9 +71,6 @@ namespace PolyVox
|
|||||||
bool surfaceUpToDate[POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
bool surfaceUpToDate[POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
||||||
bool regionIsHomogenous[POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
bool regionIsHomogenous[POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
||||||
|
|
||||||
//SurfacePatchRenderable* m_singleMaterialSurfaces[POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
|
||||||
//SurfacePatchRenderable* m_multiMaterialSurfaces[POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS][POLYVOX_VOLUME_SIDE_LENGTH_IN_REGIONS];
|
|
||||||
|
|
||||||
Vector3DFloat computeNormal(const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) const;
|
Vector3DFloat computeNormal(const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -48,6 +48,7 @@ namespace PolyVox
|
|||||||
bool containsPoint(Vector3DInt32 pos, boost::uint16_t boundary);
|
bool containsPoint(Vector3DInt32 pos, boost::uint16_t boundary);
|
||||||
|
|
||||||
boost::uint16_t getSideLength(void);
|
boost::uint16_t getSideLength(void);
|
||||||
|
boost::uint8_t getSideLengthPower(void);
|
||||||
boost::uint16_t getSideLengthInBlocks(void);
|
boost::uint16_t getSideLengthInBlocks(void);
|
||||||
|
|
||||||
boost::uint16_t getBlockSideLength(void);
|
boost::uint16_t getBlockSideLength(void);
|
||||||
@ -61,7 +62,7 @@ namespace PolyVox
|
|||||||
boost::uint32_t m_uNoOfBlocksInVolume;
|
boost::uint32_t m_uNoOfBlocksInVolume;
|
||||||
boost::uint16_t m_uSideLengthInBlocks;
|
boost::uint16_t m_uSideLengthInBlocks;
|
||||||
|
|
||||||
boost::uint16_t m_uSideLengthPower;
|
boost::uint8_t m_uSideLengthPower;
|
||||||
boost::uint16_t m_uSideLength;
|
boost::uint16_t m_uSideLength;
|
||||||
|
|
||||||
boost::uint16_t m_uBlockSideLengthPower;
|
boost::uint16_t m_uBlockSideLengthPower;
|
||||||
|
@ -165,6 +165,12 @@ namespace PolyVox
|
|||||||
return m_uSideLength;
|
return m_uSideLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
boost::uint8_t Volume<VoxelType>::getSideLengthPower(void)
|
||||||
|
{
|
||||||
|
return m_uSideLengthPower;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
boost::uint16_t Volume<VoxelType>::getSideLengthInBlocks(void)
|
boost::uint16_t Volume<VoxelType>::getSideLengthInBlocks(void)
|
||||||
{
|
{
|
||||||
|
@ -117,9 +117,9 @@ namespace PolyVox
|
|||||||
firstY = std::max(firstY,0);
|
firstY = std::max(firstY,0);
|
||||||
firstZ = std::max(firstZ,0);
|
firstZ = std::max(firstZ,0);
|
||||||
|
|
||||||
lastX = std::min(lastX,int(POLYVOX_VOLUME_SIDE_LENGTH-1));
|
lastX = std::min(lastX,int(volumeData->getSideLength()-1));
|
||||||
lastY = std::min(lastY,int(POLYVOX_VOLUME_SIDE_LENGTH-1));
|
lastY = std::min(lastY,int(volumeData->getSideLength()-1));
|
||||||
lastZ = std::min(lastZ,int(POLYVOX_VOLUME_SIDE_LENGTH-1));
|
lastZ = std::min(lastZ,int(volumeData->getSideLength()-1));
|
||||||
|
|
||||||
VolumeIterator<boost::uint8_t> volIter(*volumeData);
|
VolumeIterator<boost::uint8_t> volIter(*volumeData);
|
||||||
volIter.setValidRegion(firstX,firstY,firstZ,lastX,lastY,lastZ);
|
volIter.setValidRegion(firstX,firstY,firstZ,lastX,lastY,lastZ);
|
||||||
@ -242,9 +242,9 @@ namespace PolyVox
|
|||||||
const uint16_t firstX = regionX * POLYVOX_REGION_SIDE_LENGTH;
|
const uint16_t firstX = regionX * POLYVOX_REGION_SIDE_LENGTH;
|
||||||
const uint16_t firstY = regionY * POLYVOX_REGION_SIDE_LENGTH;
|
const uint16_t firstY = regionY * POLYVOX_REGION_SIDE_LENGTH;
|
||||||
const uint16_t firstZ = regionZ * POLYVOX_REGION_SIDE_LENGTH;
|
const uint16_t firstZ = regionZ * POLYVOX_REGION_SIDE_LENGTH;
|
||||||
const uint16_t lastX = (std::min)(firstX + POLYVOX_REGION_SIDE_LENGTH-1,static_cast<uint32_t>(POLYVOX_VOLUME_SIDE_LENGTH-2));
|
const uint16_t lastX = (std::min)(firstX + POLYVOX_REGION_SIDE_LENGTH-1,static_cast<uint32_t>(volumeData->getSideLength()-2));
|
||||||
const uint16_t lastY = (std::min)(firstY + POLYVOX_REGION_SIDE_LENGTH-1,static_cast<uint32_t>(POLYVOX_VOLUME_SIDE_LENGTH-2));
|
const uint16_t lastY = (std::min)(firstY + POLYVOX_REGION_SIDE_LENGTH-1,static_cast<uint32_t>(volumeData->getSideLength()-2));
|
||||||
const uint16_t lastZ = (std::min)(firstZ + POLYVOX_REGION_SIDE_LENGTH-1,static_cast<uint32_t>(POLYVOX_VOLUME_SIDE_LENGTH-2));
|
const uint16_t lastZ = (std::min)(firstZ + POLYVOX_REGION_SIDE_LENGTH-1,static_cast<uint32_t>(volumeData->getSideLength()-2));
|
||||||
|
|
||||||
//Offset from lower block corner
|
//Offset from lower block corner
|
||||||
const Vector3DFloat offset(firstX,firstY,firstZ);
|
const Vector3DFloat offset(firstX,firstY,firstZ);
|
||||||
@ -544,7 +544,7 @@ namespace PolyVox
|
|||||||
|
|
||||||
Vector3DFloat PolyVoxSceneManager::computeNormal(const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) const
|
Vector3DFloat PolyVoxSceneManager::computeNormal(const Vector3DFloat& position, NormalGenerationMethod normalGenerationMethod) const
|
||||||
{
|
{
|
||||||
VolumeIterator<boost::uint8_t> volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create?
|
|
||||||
|
|
||||||
const float posX = position.x();
|
const float posX = position.x();
|
||||||
const float posY = position.y();
|
const float posY = position.y();
|
||||||
@ -554,8 +554,18 @@ namespace PolyVox
|
|||||||
const uint16_t floorY = static_cast<uint16_t>(posY);
|
const uint16_t floorY = static_cast<uint16_t>(posY);
|
||||||
const uint16_t floorZ = static_cast<uint16_t>(posZ);
|
const uint16_t floorZ = static_cast<uint16_t>(posZ);
|
||||||
|
|
||||||
|
//Check all corners are within the volume, allowing a boundary for gradient estimation
|
||||||
|
bool lowerCornerInside = volumeData->containsPoint(Vector3DInt32(floorX, floorY, floorZ),1);
|
||||||
|
bool upperCornerInside = volumeData->containsPoint(Vector3DInt32(floorX+1, floorY+1, floorZ+1),1);
|
||||||
|
if((!lowerCornerInside) || (!upperCornerInside))
|
||||||
|
{
|
||||||
|
normalGenerationMethod = SIMPLE;
|
||||||
|
}
|
||||||
|
|
||||||
Vector3DFloat result;
|
Vector3DFloat result;
|
||||||
|
|
||||||
|
VolumeIterator<boost::uint8_t> volIter(*volumeData); //FIXME - save this somewhere - could be expensive to create?
|
||||||
|
|
||||||
|
|
||||||
if(normalGenerationMethod == SOBEL)
|
if(normalGenerationMethod == SOBEL)
|
||||||
{
|
{
|
||||||
@ -691,7 +701,7 @@ namespace PolyVox
|
|||||||
|
|
||||||
uint16_t PolyVoxSceneManager::getSideLength(void)
|
uint16_t PolyVoxSceneManager::getSideLength(void)
|
||||||
{
|
{
|
||||||
return POLYVOX_VOLUME_SIDE_LENGTH;
|
return volumeData->getSideLength();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t PolyVoxSceneManager::getMaterialIndexAt(uint16_t uX, uint16_t uY, uint16_t uZ)
|
uint8_t PolyVoxSceneManager::getMaterialIndexAt(uint16_t uX, uint16_t uY, uint16_t uZ)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user