Tidying up...
This commit is contained in:
parent
e6a7174b53
commit
9a58b83b6d
@ -20,6 +20,7 @@ SET(SRC_FILES
|
|||||||
source/SurfaceVertex.cpp
|
source/SurfaceVertex.cpp
|
||||||
source/Utility.cpp
|
source/Utility.cpp
|
||||||
source/VolumeChangeTracker.cpp
|
source/VolumeChangeTracker.cpp
|
||||||
|
source/VoxelFilters.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
#Projects headers files
|
#Projects headers files
|
||||||
@ -50,6 +51,7 @@ SET(INC_FILES
|
|||||||
include/Vector.h
|
include/Vector.h
|
||||||
include/Vector.inl
|
include/Vector.inl
|
||||||
include/VolumeChangeTracker.h
|
include/VolumeChangeTracker.h
|
||||||
|
include/VoxelFilters.h
|
||||||
)
|
)
|
||||||
|
|
||||||
FIND_PACKAGE(Boost REQUIRED)
|
FIND_PACKAGE(Boost REQUIRED)
|
||||||
|
@ -43,10 +43,10 @@ namespace PolyVox
|
|||||||
bool operator<=(const BlockVolumeIterator& rhs);
|
bool operator<=(const BlockVolumeIterator& rhs);
|
||||||
bool operator>=(const BlockVolumeIterator& rhs);
|
bool operator>=(const BlockVolumeIterator& rhs);
|
||||||
|
|
||||||
VoxelType getMaxedVoxel(boost::uint8_t uLevel) const;
|
|
||||||
boost::uint16_t getPosX(void) const;
|
boost::uint16_t getPosX(void) const;
|
||||||
boost::uint16_t getPosY(void) const;
|
boost::uint16_t getPosY(void) const;
|
||||||
boost::uint16_t getPosZ(void) const;
|
boost::uint16_t getPosZ(void) const;
|
||||||
|
VoxelType getSubSampledVoxel(boost::uint8_t uLevel) const;
|
||||||
const BlockVolume<VoxelType>& getVolume(void) const;
|
const BlockVolume<VoxelType>& getVolume(void) const;
|
||||||
VoxelType getVoxel(void) const;
|
VoxelType getVoxel(void) const;
|
||||||
|
|
||||||
|
@ -105,7 +105,25 @@ namespace PolyVox
|
|||||||
|
|
||||||
#pragma region Getters
|
#pragma region Getters
|
||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
VoxelType BlockVolumeIterator<VoxelType>::getMaxedVoxel(boost::uint8_t uLevel) const
|
boost::uint16_t BlockVolumeIterator<VoxelType>::getPosX(void) const
|
||||||
|
{
|
||||||
|
return mXPosInVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
boost::uint16_t BlockVolumeIterator<VoxelType>::getPosY(void) const
|
||||||
|
{
|
||||||
|
return mYPosInVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
boost::uint16_t BlockVolumeIterator<VoxelType>::getPosZ(void) const
|
||||||
|
{
|
||||||
|
return mZPosInVolume;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename VoxelType>
|
||||||
|
VoxelType BlockVolumeIterator<VoxelType>::getSubSampledVoxel(boost::uint8_t uLevel) const
|
||||||
{
|
{
|
||||||
if(uLevel == 0)
|
if(uLevel == 0)
|
||||||
{
|
{
|
||||||
@ -142,24 +160,6 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename VoxelType>
|
|
||||||
boost::uint16_t BlockVolumeIterator<VoxelType>::getPosX(void) const
|
|
||||||
{
|
|
||||||
return mXPosInVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename VoxelType>
|
|
||||||
boost::uint16_t BlockVolumeIterator<VoxelType>::getPosY(void) const
|
|
||||||
{
|
|
||||||
return mYPosInVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename VoxelType>
|
|
||||||
boost::uint16_t BlockVolumeIterator<VoxelType>::getPosZ(void) const
|
|
||||||
{
|
|
||||||
return mZPosInVolume;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename VoxelType>
|
template <typename VoxelType>
|
||||||
const BlockVolume<VoxelType>& BlockVolumeIterator<VoxelType>::getVolume(void) const
|
const BlockVolume<VoxelType>& BlockVolumeIterator<VoxelType>::getVolume(void) const
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
#include "SurfaceAdjusters.h"
|
#include "VoxelFilters.h"
|
||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
POLYVOX_API void smoothRegionGeometry(BlockVolume<boost::uint8_t>* volumeData, RegionGeometry& regGeom);
|
POLYVOX_API void smoothRegionGeometry(BlockVolume<boost::uint8_t>* volumeData, RegionGeometry& regGeom);
|
||||||
float computeSmoothedVoxel(BlockVolumeIterator<boost::uint8_t>& volIter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
36
PolyVoxCore/include/VoxelFilters.h
Normal file
36
PolyVoxCore/include/VoxelFilters.h
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#pragma region License
|
||||||
|
/******************************************************************************
|
||||||
|
This file is part of the PolyVox library
|
||||||
|
Copyright (C) 2006 David Williams
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU General Public License
|
||||||
|
as published by the Free Software Foundation; either version 2
|
||||||
|
of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
|
******************************************************************************/
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
#ifndef __PolyVox_VoxelFilters_H__
|
||||||
|
#define __PolyVox_VoxelFilters_H__
|
||||||
|
|
||||||
|
#pragma region Headers
|
||||||
|
#include "Constants.h"
|
||||||
|
#include "PolyVoxForwardDeclarations.h"
|
||||||
|
#include "TypeDef.h"
|
||||||
|
#pragma endregion
|
||||||
|
|
||||||
|
namespace PolyVox
|
||||||
|
{
|
||||||
|
float computeSmoothedVoxel(BlockVolumeIterator<boost::uint8_t>& volIter);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -5,6 +5,7 @@
|
|||||||
#include "IndexedSurfacePatch.h"
|
#include "IndexedSurfacePatch.h"
|
||||||
#include "RegionGeometry.h"
|
#include "RegionGeometry.h"
|
||||||
#include "Utility.h"
|
#include "Utility.h"
|
||||||
|
#include "VoxelFilters.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -73,49 +74,4 @@ namespace PolyVox
|
|||||||
++iterSurfaceVertex;
|
++iterSurfaceVertex;
|
||||||
} //while(iterSurfaceVertex != vecVertices.end())
|
} //while(iterSurfaceVertex != vecVertices.end())
|
||||||
}
|
}
|
||||||
|
|
||||||
float computeSmoothedVoxel(BlockVolumeIterator<boost::uint8_t>& volIter)
|
|
||||||
{
|
|
||||||
assert(volIter.getPosX() >= 1);
|
|
||||||
assert(volIter.getPosY() >= 1);
|
|
||||||
assert(volIter.getPosZ() >= 1);
|
|
||||||
assert(volIter.getPosX() < volIter.getVolume().getSideLength() - 2);
|
|
||||||
assert(volIter.getPosY() < volIter.getVolume().getSideLength() - 2);
|
|
||||||
assert(volIter.getPosZ() < volIter.getVolume().getSideLength() - 2);
|
|
||||||
|
|
||||||
float sum = 0.0;
|
|
||||||
|
|
||||||
if(volIter.peekVoxel1nx1ny1nz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1nx1ny0pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1nx1ny1pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1nx0py1nz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1nx0py0pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1nx0py1pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1nx1py1nz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1nx1py0pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1nx1py1pz() != 0) sum += 1.0f;
|
|
||||||
|
|
||||||
if(volIter.peekVoxel0px1ny1nz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel0px1ny0pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel0px1ny1pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel0px0py1nz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.getVoxel() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel0px0py1pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel0px1py1nz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel0px1py0pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel0px1py1pz() != 0) sum += 1.0f;
|
|
||||||
|
|
||||||
if(volIter.peekVoxel1px1ny1nz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1px1ny0pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1px1ny1pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1px0py1nz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1px0py0pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1px0py1pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1px1py1nz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1px1py0pz() != 0) sum += 1.0f;
|
|
||||||
if(volIter.peekVoxel1px1py1pz() != 0) sum += 1.0f;
|
|
||||||
|
|
||||||
sum /= 27.0f;
|
|
||||||
return sum;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -129,22 +129,22 @@ namespace PolyVox
|
|||||||
if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY()))
|
if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY()))
|
||||||
{
|
{
|
||||||
volIter.setPosition(x,y,regSlice.getLowerCorner().getZ());
|
volIter.setPosition(x,y,regSlice.getLowerCorner().getZ());
|
||||||
const uint8_t v000 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v000 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ());
|
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ());
|
||||||
const uint8_t v100 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v100 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ());
|
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||||
const uint8_t v010 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v010 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||||
const uint8_t v110 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v110 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v001 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v001 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v101 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v101 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v011 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v011 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v111 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
if (v000 == 0) iCubeIndex |= 1;
|
if (v000 == 0) iCubeIndex |= 1;
|
||||||
if (v100 == 0) iCubeIndex |= 2;
|
if (v100 == 0) iCubeIndex |= 2;
|
||||||
@ -158,14 +158,14 @@ namespace PolyVox
|
|||||||
else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY())
|
else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY())
|
||||||
{
|
{
|
||||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ());
|
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ());
|
||||||
const uint8_t v100 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v100 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||||
const uint8_t v110 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v110 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v101 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v101 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v111 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
//x
|
//x
|
||||||
uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())];
|
uint8_t iPreviousCubeIndexX = bitmask[getDecimatedIndex(x- offset.getX()-uStepSize,y- offset.getY())];
|
||||||
@ -193,14 +193,14 @@ namespace PolyVox
|
|||||||
else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY()))
|
else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY()))
|
||||||
{
|
{
|
||||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ());
|
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||||
const uint8_t v010 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v010 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||||
const uint8_t v110 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v110 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v011 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v011 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v111 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
//y
|
//y
|
||||||
uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)];
|
uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)];
|
||||||
@ -228,10 +228,10 @@ namespace PolyVox
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ());
|
||||||
const uint8_t v110 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v110 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v111 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
//y
|
//y
|
||||||
uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)];
|
uint8_t iPreviousCubeIndexY = bitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY()-uStepSize)];
|
||||||
@ -298,13 +298,13 @@ namespace PolyVox
|
|||||||
if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY()))
|
if((x==regSlice.getLowerCorner().getX()) && (y==regSlice.getLowerCorner().getY()))
|
||||||
{
|
{
|
||||||
volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v001 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v001 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v101 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v101 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v011 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v011 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v111 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
//z
|
//z
|
||||||
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())];
|
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())];
|
||||||
@ -318,9 +318,9 @@ namespace PolyVox
|
|||||||
else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY())
|
else if((x>regSlice.getLowerCorner().getX()) && y==regSlice.getLowerCorner().getY())
|
||||||
{
|
{
|
||||||
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v101 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v101 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v111 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
//z
|
//z
|
||||||
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())];
|
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())];
|
||||||
@ -342,9 +342,9 @@ namespace PolyVox
|
|||||||
else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY()))
|
else if((x==regSlice.getLowerCorner().getX()) && (y>regSlice.getLowerCorner().getY()))
|
||||||
{
|
{
|
||||||
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v011 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v011 = volIter.getSubSampledVoxel(uLevel);
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v111 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
//z
|
//z
|
||||||
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())];
|
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())];
|
||||||
@ -366,7 +366,7 @@ namespace PolyVox
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
volIter.setPosition(x+uStepSize,y+uStepSize,regSlice.getLowerCorner().getZ()+uStepSize);
|
||||||
const uint8_t v111 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v111 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
//z
|
//z
|
||||||
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())];
|
uint8_t iPreviousCubeIndexZ = previousBitmask[getDecimatedIndex(x- offset.getX(),y- offset.getY())];
|
||||||
@ -418,7 +418,7 @@ namespace PolyVox
|
|||||||
const uint16_t z = regSlice.getLowerCorner().getZ();
|
const uint16_t z = regSlice.getLowerCorner().getZ();
|
||||||
|
|
||||||
volIter.setPosition(x,y,z);
|
volIter.setPosition(x,y,z);
|
||||||
const uint8_t v000 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v000 = volIter.getSubSampledVoxel(uLevel);
|
||||||
|
|
||||||
//Determine the index into the edge table which tells us which vertices are inside of the surface
|
//Determine the index into the edge table which tells us which vertices are inside of the surface
|
||||||
uint8_t iCubeIndex = bitmask[getDecimatedIndex(x - offset.getX(),y - offset.getY())];
|
uint8_t iCubeIndex = bitmask[getDecimatedIndex(x - offset.getX(),y - offset.getY())];
|
||||||
@ -435,7 +435,7 @@ namespace PolyVox
|
|||||||
if(x != regSlice.getUpperCorner().getX())
|
if(x != regSlice.getUpperCorner().getX())
|
||||||
{
|
{
|
||||||
volIter.setPosition(x + uStepSize,y,z);
|
volIter.setPosition(x + uStepSize,y,z);
|
||||||
const uint8_t v100 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v100 = volIter.getSubSampledVoxel(uLevel);
|
||||||
const Vector3DFloat v3dPosition(x - offset.getX() + 0.5f * uStepSize, y - offset.getY(), z - offset.getZ());
|
const Vector3DFloat v3dPosition(x - offset.getX() + 0.5f * uStepSize, y - offset.getY(), z - offset.getZ());
|
||||||
const Vector3DFloat v3dNormal(v000 > v100 ? 1.0f : -1.0f,0.0,0.0);
|
const Vector3DFloat v3dNormal(v000 > v100 ? 1.0f : -1.0f,0.0,0.0);
|
||||||
const uint8_t uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max.
|
const uint8_t uMaterial = v000 | v100; //Because one of these is 0, the or operation takes the max.
|
||||||
@ -449,7 +449,7 @@ namespace PolyVox
|
|||||||
if(y != regSlice.getUpperCorner().getY())
|
if(y != regSlice.getUpperCorner().getY())
|
||||||
{
|
{
|
||||||
volIter.setPosition(x,y + uStepSize,z);
|
volIter.setPosition(x,y + uStepSize,z);
|
||||||
const uint8_t v010 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v010 = volIter.getSubSampledVoxel(uLevel);
|
||||||
const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY() + 0.5f * uStepSize, z - offset.getZ());
|
const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY() + 0.5f * uStepSize, z - offset.getZ());
|
||||||
const Vector3DFloat v3dNormal(0.0,v000 > v010 ? 1.0f : -1.0f,0.0);
|
const Vector3DFloat v3dNormal(0.0,v000 > v010 ? 1.0f : -1.0f,0.0);
|
||||||
const uint8_t uMaterial = v000 | v010; //Because one of these is 0, the or operation takes the max.
|
const uint8_t uMaterial = v000 | v010; //Because one of these is 0, the or operation takes the max.
|
||||||
@ -463,7 +463,7 @@ namespace PolyVox
|
|||||||
//if(z != regSlice.getUpperCorner.getZ())
|
//if(z != regSlice.getUpperCorner.getZ())
|
||||||
{
|
{
|
||||||
volIter.setPosition(x,y,z + uStepSize);
|
volIter.setPosition(x,y,z + uStepSize);
|
||||||
const uint8_t v001 = volIter.getMaxedVoxel(uLevel);
|
const uint8_t v001 = volIter.getSubSampledVoxel(uLevel);
|
||||||
const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY(), z - offset.getZ() + 0.5f * uStepSize);
|
const Vector3DFloat v3dPosition(x - offset.getX(), y - offset.getY(), z - offset.getZ() + 0.5f * uStepSize);
|
||||||
const Vector3DFloat v3dNormal(0.0,0.0,v000 > v001 ? 1.0f : -1.0f);
|
const Vector3DFloat v3dNormal(0.0,0.0,v000 > v001 ? 1.0f : -1.0f);
|
||||||
const uint8_t uMaterial = v000 | v001; //Because one of these is 0, the or operation takes the max.
|
const uint8_t uMaterial = v000 | v001; //Because one of these is 0, the or operation takes the max.
|
||||||
@ -606,21 +606,21 @@ namespace PolyVox
|
|||||||
//while(volIter.moveForwardInRegionXYZ())
|
//while(volIter.moveForwardInRegionXYZ())
|
||||||
//{
|
//{
|
||||||
volIter.setPosition(x,y,z);
|
volIter.setPosition(x,y,z);
|
||||||
const uint8_t v000 = volIter.getMaxedVoxel(1);
|
const uint8_t v000 = volIter.getSubSampledVoxel(1);
|
||||||
volIter.setPosition(x+2,y,z);
|
volIter.setPosition(x+2,y,z);
|
||||||
const uint8_t v100 = volIter.getMaxedVoxel(1);
|
const uint8_t v100 = volIter.getSubSampledVoxel(1);
|
||||||
volIter.setPosition(x,y+2,z);
|
volIter.setPosition(x,y+2,z);
|
||||||
const uint8_t v010 = volIter.getMaxedVoxel(1);
|
const uint8_t v010 = volIter.getSubSampledVoxel(1);
|
||||||
volIter.setPosition(x+2,y+2,z);
|
volIter.setPosition(x+2,y+2,z);
|
||||||
const uint8_t v110 = volIter.getMaxedVoxel(1);
|
const uint8_t v110 = volIter.getSubSampledVoxel(1);
|
||||||
volIter.setPosition(x,y,z+2);
|
volIter.setPosition(x,y,z+2);
|
||||||
const uint8_t v001 = volIter.getMaxedVoxel(1);
|
const uint8_t v001 = volIter.getSubSampledVoxel(1);
|
||||||
volIter.setPosition(x+2,y,z+2);
|
volIter.setPosition(x+2,y,z+2);
|
||||||
const uint8_t v101 = volIter.getMaxedVoxel(1);
|
const uint8_t v101 = volIter.getSubSampledVoxel(1);
|
||||||
volIter.setPosition(x,y+2,z+2);
|
volIter.setPosition(x,y+2,z+2);
|
||||||
const uint8_t v011 = volIter.getMaxedVoxel(1);
|
const uint8_t v011 = volIter.getSubSampledVoxel(1);
|
||||||
volIter.setPosition(x+2,y+2,z+2);
|
volIter.setPosition(x+2,y+2,z+2);
|
||||||
const uint8_t v111 = volIter.getMaxedVoxel(1);
|
const uint8_t v111 = volIter.getSubSampledVoxel(1);
|
||||||
|
|
||||||
//Determine the index into the edge table which tells us which vertices are inside of the surface
|
//Determine the index into the edge table which tells us which vertices are inside of the surface
|
||||||
uint8_t iCubeIndex = 0;
|
uint8_t iCubeIndex = 0;
|
||||||
|
51
PolyVoxCore/source/VoxelFilters.cpp
Normal file
51
PolyVoxCore/source/VoxelFilters.cpp
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#include "VoxelFilters.h"
|
||||||
|
|
||||||
|
#include "BlockVolumeIterator.h"
|
||||||
|
|
||||||
|
namespace PolyVox
|
||||||
|
{
|
||||||
|
float computeSmoothedVoxel(BlockVolumeIterator<boost::uint8_t>& volIter)
|
||||||
|
{
|
||||||
|
assert(volIter.getPosX() >= 1);
|
||||||
|
assert(volIter.getPosY() >= 1);
|
||||||
|
assert(volIter.getPosZ() >= 1);
|
||||||
|
assert(volIter.getPosX() < volIter.getVolume().getSideLength() - 2);
|
||||||
|
assert(volIter.getPosY() < volIter.getVolume().getSideLength() - 2);
|
||||||
|
assert(volIter.getPosZ() < volIter.getVolume().getSideLength() - 2);
|
||||||
|
|
||||||
|
float sum = 0.0;
|
||||||
|
|
||||||
|
if(volIter.peekVoxel1nx1ny1nz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1nx1ny0pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1nx1ny1pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1nx0py1nz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1nx0py0pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1nx0py1pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1nx1py1nz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1nx1py0pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1nx1py1pz() != 0) sum += 1.0f;
|
||||||
|
|
||||||
|
if(volIter.peekVoxel0px1ny1nz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel0px1ny0pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel0px1ny1pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel0px0py1nz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.getVoxel() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel0px0py1pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel0px1py1nz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel0px1py0pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel0px1py1pz() != 0) sum += 1.0f;
|
||||||
|
|
||||||
|
if(volIter.peekVoxel1px1ny1nz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1px1ny0pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1px1ny1pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1px0py1nz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1px0py0pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1px0py1pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1px1py1nz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1px1py0pz() != 0) sum += 1.0f;
|
||||||
|
if(volIter.peekVoxel1px1py1pz() != 0) sum += 1.0f;
|
||||||
|
|
||||||
|
sum /= 27.0f;
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
}
|
8
TODO.txt
8
TODO.txt
@ -1,4 +1,4 @@
|
|||||||
For Version 0.1
|
For Version 1.0
|
||||||
===============
|
===============
|
||||||
Implement Memory Pool
|
Implement Memory Pool
|
||||||
Clean up normal code - make normal generation a seperate pass.
|
Clean up normal code - make normal generation a seperate pass.
|
||||||
@ -16,15 +16,17 @@ Check licensing, #regions, etc.
|
|||||||
Decimated version of marching cubes should use less memory.
|
Decimated version of marching cubes should use less memory.
|
||||||
Unit test - compare output to reference implementation
|
Unit test - compare output to reference implementation
|
||||||
Sort awkward use of 'offset' in decimated marching cubes.
|
Sort awkward use of 'offset' in decimated marching cubes.
|
||||||
|
Use of LinearVolume instead of arrays.
|
||||||
Add API docs
|
Add API docs
|
||||||
Add manual
|
Add manual
|
||||||
Finish OpenGL sample.
|
Finish OpenGL sample.
|
||||||
|
|
||||||
For Version 0.2
|
For Version 2.0
|
||||||
===============
|
===============
|
||||||
Detect detatched regions.
|
Detect detatched regions.
|
||||||
Handle mesh generation for detatched regions.
|
Handle mesh generation for detatched regions.
|
||||||
Generate ambient lighting from volume?
|
Generate ambient lighting from volume?
|
||||||
Utility function for closing outside surfaces?
|
Utility function for closing outside surfaces?
|
||||||
Consider how seperate surface should be generated for a single region.
|
Consider how seperate surface should be generated for a single region.
|
||||||
Consider transparent materials like glass.
|
Consider transparent materials like glass.
|
||||||
|
Allow writing meshes into volumes?
|
Loading…
x
Reference in New Issue
Block a user