Removed use of template template parameters from CubicSurfaceExtractor.
This commit is contained in:
parent
127d987e07
commit
fec1191a73
@ -31,7 +31,7 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template<typename VolumeType>
|
||||||
class CubicSurfaceExtractor
|
class CubicSurfaceExtractor
|
||||||
{
|
{
|
||||||
struct IndexAndMaterial
|
struct IndexAndMaterial
|
||||||
@ -57,7 +57,7 @@ namespace PolyVox
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CubicSurfaceExtractor(VolumeType<VoxelType>* volData, Region region, SurfaceMesh<PositionMaterial>* result, bool bMergeQuads = true);
|
CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterial>* result, bool bMergeQuads = true);
|
||||||
|
|
||||||
void execute();
|
void execute();
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ namespace PolyVox
|
|||||||
bool mergeQuads(Quad& q1, Quad& q2);
|
bool mergeQuads(Quad& q1, Quad& q2);
|
||||||
|
|
||||||
//The volume data and a sampler to access it.
|
//The volume data and a sampler to access it.
|
||||||
VolumeType<VoxelType>* m_volData;
|
VolumeType* m_volData;
|
||||||
|
|
||||||
//Information about the region we are currently processing
|
//Information about the region we are currently processing
|
||||||
Region m_regSizeInVoxels;
|
Region m_regSizeInVoxels;
|
||||||
|
@ -31,11 +31,11 @@ namespace PolyVox
|
|||||||
// The vertex position at the center of this group is then going to be used by six quads all with different materials.
|
// The vertex position at the center of this group is then going to be used by six quads all with different materials.
|
||||||
// One futher note - we can actually have eight quads sharing a vertex position (imagine two 1x1x10 rows of voxels
|
// One futher note - we can actually have eight quads sharing a vertex position (imagine two 1x1x10 rows of voxels
|
||||||
// sharing a common edge) but in this case all eight quads will not have different materials.
|
// sharing a common edge) but in this case all eight quads will not have different materials.
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template<typename VolumeType>
|
||||||
const uint32_t CubicSurfaceExtractor<VolumeType, VoxelType>::MaxVerticesPerPosition = 6;
|
const uint32_t CubicSurfaceExtractor<VolumeType>::MaxVerticesPerPosition = 6;
|
||||||
|
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template<typename VolumeType>
|
||||||
CubicSurfaceExtractor<VolumeType, VoxelType>::CubicSurfaceExtractor(VolumeType<VoxelType>* volData, Region region, SurfaceMesh<PositionMaterial>* result, bool bMergeQuads)
|
CubicSurfaceExtractor<VolumeType>::CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterial>* result, bool bMergeQuads)
|
||||||
:m_volData(volData)
|
:m_volData(volData)
|
||||||
,m_regSizeInVoxels(region)
|
,m_regSizeInVoxels(region)
|
||||||
,m_meshCurrent(result)
|
,m_meshCurrent(result)
|
||||||
@ -43,8 +43,8 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template<typename VolumeType>
|
||||||
void CubicSurfaceExtractor<VolumeType, VoxelType>::execute()
|
void CubicSurfaceExtractor<VolumeType>::execute()
|
||||||
{
|
{
|
||||||
m_meshCurrent->clear();
|
m_meshCurrent->clear();
|
||||||
|
|
||||||
@ -70,7 +70,7 @@ namespace PolyVox
|
|||||||
m_vecQuads[NegativeZ].resize(m_regSizeInVoxels.getUpperCorner().getZ() - m_regSizeInVoxels.getLowerCorner().getZ() + 2);
|
m_vecQuads[NegativeZ].resize(m_regSizeInVoxels.getUpperCorner().getZ() - m_regSizeInVoxels.getLowerCorner().getZ() + 2);
|
||||||
m_vecQuads[PositiveZ].resize(m_regSizeInVoxels.getUpperCorner().getZ() - m_regSizeInVoxels.getLowerCorner().getZ() + 2);
|
m_vecQuads[PositiveZ].resize(m_regSizeInVoxels.getUpperCorner().getZ() - m_regSizeInVoxels.getLowerCorner().getZ() + 2);
|
||||||
|
|
||||||
typename VolumeType<VoxelType>::Sampler volumeSampler(m_volData);
|
typename VolumeType::Sampler volumeSampler(m_volData);
|
||||||
Quad quad;
|
Quad quad;
|
||||||
|
|
||||||
for(int32_t z = m_regSizeInVoxels.getLowerCorner().getZ(); z <= m_regSizeInVoxels.getUpperCorner().getZ() + 1; z++)
|
for(int32_t z = m_regSizeInVoxels.getLowerCorner().getZ(); z <= m_regSizeInVoxels.getUpperCorner().getZ() + 1; z++)
|
||||||
@ -90,10 +90,10 @@ namespace PolyVox
|
|||||||
|
|
||||||
volumeSampler.setPosition(x,y,z);
|
volumeSampler.setPosition(x,y,z);
|
||||||
|
|
||||||
VoxelType currentVoxel = volumeSampler.getVoxel();
|
VolumeType::VoxelType currentVoxel = volumeSampler.getVoxel();
|
||||||
bool currentVoxelIsSolid = currentVoxel.getMaterial() != 0;
|
bool currentVoxelIsSolid = currentVoxel.getMaterial() != 0;
|
||||||
|
|
||||||
VoxelType negXVoxel = volumeSampler.peekVoxel1nx0py0pz();
|
VolumeType::VoxelType negXVoxel = volumeSampler.peekVoxel1nx0py0pz();
|
||||||
bool negXVoxelIsSolid = negXVoxel.getMaterial() != 0;
|
bool negXVoxelIsSolid = negXVoxel.getMaterial() != 0;
|
||||||
|
|
||||||
if((currentVoxelIsSolid != negXVoxelIsSolid) && (finalY == false) && (finalZ == false))
|
if((currentVoxelIsSolid != negXVoxelIsSolid) && (finalY == false) && (finalZ == false))
|
||||||
@ -130,7 +130,7 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelType negYVoxel = volumeSampler.peekVoxel0px1ny0pz();
|
VolumeType::VoxelType negYVoxel = volumeSampler.peekVoxel0px1ny0pz();
|
||||||
bool negYVoxelIsSolid = negYVoxel.getMaterial() != 0;
|
bool negYVoxelIsSolid = negYVoxel.getMaterial() != 0;
|
||||||
|
|
||||||
if((currentVoxelIsSolid != negYVoxelIsSolid) && (finalX == false) && (finalZ == false))
|
if((currentVoxelIsSolid != negYVoxelIsSolid) && (finalX == false) && (finalZ == false))
|
||||||
@ -167,7 +167,7 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxelType negZVoxel = volumeSampler.peekVoxel0px0py1nz();
|
VolumeType::VoxelType negZVoxel = volumeSampler.peekVoxel0px0py1nz();
|
||||||
bool negZVoxelIsSolid = negZVoxel.getMaterial() != 0;
|
bool negZVoxelIsSolid = negZVoxel.getMaterial() != 0;
|
||||||
|
|
||||||
if((currentVoxelIsSolid != negZVoxelIsSolid) && (finalX == false) && (finalY == false))
|
if((currentVoxelIsSolid != negZVoxelIsSolid) && (finalX == false) && (finalY == false))
|
||||||
@ -243,8 +243,8 @@ namespace PolyVox
|
|||||||
m_meshCurrent->m_vecLodRecords.push_back(lodRecord);
|
m_meshCurrent->m_vecLodRecords.push_back(lodRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template<typename VolumeType>
|
||||||
int32_t CubicSurfaceExtractor<VolumeType, VoxelType>::addVertex(float fX, float fY, float fZ, uint32_t uMaterialIn, Array<3, IndexAndMaterial>& existingVertices)
|
int32_t CubicSurfaceExtractor<VolumeType>::addVertex(float fX, float fY, float fZ, uint32_t uMaterialIn, Array<3, IndexAndMaterial>& existingVertices)
|
||||||
{
|
{
|
||||||
uint32_t uX = static_cast<uint32_t>(fX + 0.75f);
|
uint32_t uX = static_cast<uint32_t>(fX + 0.75f);
|
||||||
uint32_t uY = static_cast<uint32_t>(fY + 0.75f);
|
uint32_t uY = static_cast<uint32_t>(fY + 0.75f);
|
||||||
@ -275,8 +275,8 @@ namespace PolyVox
|
|||||||
return -1; //Should never happen.
|
return -1; //Should never happen.
|
||||||
}
|
}
|
||||||
|
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template<typename VolumeType>
|
||||||
bool CubicSurfaceExtractor<VolumeType, VoxelType>::performQuadMerging(std::list<Quad>& quads)
|
bool CubicSurfaceExtractor<VolumeType>::performQuadMerging(std::list<Quad>& quads)
|
||||||
{
|
{
|
||||||
bool bDidMerge = false;
|
bool bDidMerge = false;
|
||||||
for(typename std::list<Quad>::iterator outerIter = quads.begin(); outerIter != quads.end(); outerIter++)
|
for(typename std::list<Quad>::iterator outerIter = quads.begin(); outerIter != quads.end(); outerIter++)
|
||||||
@ -305,8 +305,8 @@ namespace PolyVox
|
|||||||
return bDidMerge;
|
return bDidMerge;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template<typename VolumeType>
|
||||||
bool CubicSurfaceExtractor<VolumeType, VoxelType>::mergeQuads(Quad& q1, Quad& q2)
|
bool CubicSurfaceExtractor<VolumeType>::mergeQuads(Quad& q1, Quad& q2)
|
||||||
{
|
{
|
||||||
//All four vertices of a given quad have the same material,
|
//All four vertices of a given quad have the same material,
|
||||||
//so just check that the first pair of vertices match.
|
//so just check that the first pair of vertices match.
|
||||||
|
@ -130,7 +130,7 @@ void TestVolumeSubclass::testExtractSurface()
|
|||||||
}
|
}
|
||||||
|
|
||||||
SurfaceMesh<PositionMaterial> result;
|
SurfaceMesh<PositionMaterial> result;
|
||||||
CubicSurfaceExtractor<VolumeSubclass, Material8> cubicSurfaceExtractor(&volumeSubclass, volumeSubclass.getEnclosingRegion(), &result);
|
CubicSurfaceExtractor< VolumeSubclass<Material8> > cubicSurfaceExtractor(&volumeSubclass, volumeSubclass.getEnclosingRegion(), &result);
|
||||||
cubicSurfaceExtractor.execute();
|
cubicSurfaceExtractor.execute();
|
||||||
|
|
||||||
QCOMPARE(result.getNoOfVertices(), static_cast<uint32_t>(8));
|
QCOMPARE(result.getNoOfVertices(), static_cast<uint32_t>(8));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user