Removed use of template template parameters from CubicSurfaceExtractor.

This commit is contained in:
unknown 2012-05-18 15:12:30 +02:00
parent 127d987e07
commit fec1191a73
3 changed files with 21 additions and 21 deletions

View File

@ -31,7 +31,7 @@ freely, subject to the following restrictions:
namespace PolyVox
{
template< template<typename> class VolumeType, typename VoxelType>
template<typename VolumeType>
class CubicSurfaceExtractor
{
struct IndexAndMaterial
@ -57,7 +57,7 @@ namespace PolyVox
};
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();
@ -67,7 +67,7 @@ namespace PolyVox
bool mergeQuads(Quad& q1, Quad& q2);
//The volume data and a sampler to access it.
VolumeType<VoxelType>* m_volData;
VolumeType* m_volData;
//Information about the region we are currently processing
Region m_regSizeInVoxels;

View File

@ -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.
// 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.
template< template<typename> class VolumeType, typename VoxelType>
const uint32_t CubicSurfaceExtractor<VolumeType, VoxelType>::MaxVerticesPerPosition = 6;
template<typename VolumeType>
const uint32_t CubicSurfaceExtractor<VolumeType>::MaxVerticesPerPosition = 6;
template< template<typename> class VolumeType, typename VoxelType>
CubicSurfaceExtractor<VolumeType, VoxelType>::CubicSurfaceExtractor(VolumeType<VoxelType>* volData, Region region, SurfaceMesh<PositionMaterial>* result, bool bMergeQuads)
template<typename VolumeType>
CubicSurfaceExtractor<VolumeType>::CubicSurfaceExtractor(VolumeType* volData, Region region, SurfaceMesh<PositionMaterial>* result, bool bMergeQuads)
:m_volData(volData)
,m_regSizeInVoxels(region)
,m_meshCurrent(result)
@ -43,8 +43,8 @@ namespace PolyVox
{
}
template< template<typename> class VolumeType, typename VoxelType>
void CubicSurfaceExtractor<VolumeType, VoxelType>::execute()
template<typename VolumeType>
void CubicSurfaceExtractor<VolumeType>::execute()
{
m_meshCurrent->clear();
@ -70,7 +70,7 @@ namespace PolyVox
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);
typename VolumeType<VoxelType>::Sampler volumeSampler(m_volData);
typename VolumeType::Sampler volumeSampler(m_volData);
Quad quad;
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);
VoxelType currentVoxel = volumeSampler.getVoxel();
VolumeType::VoxelType currentVoxel = volumeSampler.getVoxel();
bool currentVoxelIsSolid = currentVoxel.getMaterial() != 0;
VoxelType negXVoxel = volumeSampler.peekVoxel1nx0py0pz();
VolumeType::VoxelType negXVoxel = volumeSampler.peekVoxel1nx0py0pz();
bool negXVoxelIsSolid = negXVoxel.getMaterial() != 0;
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;
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;
if((currentVoxelIsSolid != negZVoxelIsSolid) && (finalX == false) && (finalY == false))
@ -243,8 +243,8 @@ namespace PolyVox
m_meshCurrent->m_vecLodRecords.push_back(lodRecord);
}
template< template<typename> class VolumeType, typename VoxelType>
int32_t CubicSurfaceExtractor<VolumeType, VoxelType>::addVertex(float fX, float fY, float fZ, uint32_t uMaterialIn, Array<3, IndexAndMaterial>& existingVertices)
template<typename VolumeType>
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 uY = static_cast<uint32_t>(fY + 0.75f);
@ -275,8 +275,8 @@ namespace PolyVox
return -1; //Should never happen.
}
template< template<typename> class VolumeType, typename VoxelType>
bool CubicSurfaceExtractor<VolumeType, VoxelType>::performQuadMerging(std::list<Quad>& quads)
template<typename VolumeType>
bool CubicSurfaceExtractor<VolumeType>::performQuadMerging(std::list<Quad>& quads)
{
bool bDidMerge = false;
for(typename std::list<Quad>::iterator outerIter = quads.begin(); outerIter != quads.end(); outerIter++)
@ -305,8 +305,8 @@ namespace PolyVox
return bDidMerge;
}
template< template<typename> class VolumeType, typename VoxelType>
bool CubicSurfaceExtractor<VolumeType, VoxelType>::mergeQuads(Quad& q1, Quad& q2)
template<typename VolumeType>
bool CubicSurfaceExtractor<VolumeType>::mergeQuads(Quad& q1, Quad& q2)
{
//All four vertices of a given quad have the same material,
//so just check that the first pair of vertices match.

View File

@ -130,7 +130,7 @@ void TestVolumeSubclass::testExtractSurface()
}
SurfaceMesh<PositionMaterial> result;
CubicSurfaceExtractor<VolumeSubclass, Material8> cubicSurfaceExtractor(&volumeSubclass, volumeSubclass.getEnclosingRegion(), &result);
CubicSurfaceExtractor< VolumeSubclass<Material8> > cubicSurfaceExtractor(&volumeSubclass, volumeSubclass.getEnclosingRegion(), &result);
cubicSurfaceExtractor.execute();
QCOMPARE(result.getNoOfVertices(), static_cast<uint32_t>(8));