Exposed 'VoxelType' in BaseVolume.
This commit is contained in:
parent
86b84339af
commit
309f270e67
@ -84,7 +84,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
//Extract the surface
|
//Extract the surface
|
||||||
SurfaceMesh<PositionMaterialNormal> mesh;
|
SurfaceMesh<PositionMaterialNormal> mesh;
|
||||||
CubicSurfaceExtractorWithNormals<SimpleVolume, uint8_t > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
|
CubicSurfaceExtractorWithNormals< SimpleVolume<uint8_t> > surfaceExtractor(&volData, volData.getEnclosingRegion(), &mesh);
|
||||||
surfaceExtractor.execute();
|
surfaceExtractor.execute();
|
||||||
|
|
||||||
//Pass the surface to the OpenGL window
|
//Pass the surface to the OpenGL window
|
||||||
|
@ -38,10 +38,12 @@ namespace PolyVox
|
|||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
/// More details to come...
|
/// More details to come...
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
template <typename VoxelType>
|
template <typename _VoxelType>
|
||||||
class BaseVolume
|
class BaseVolume
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
typedef _VoxelType VoxelType;
|
||||||
|
|
||||||
#ifndef SWIG
|
#ifndef SWIG
|
||||||
template <typename DerivedVolumeType>
|
template <typename DerivedVolumeType>
|
||||||
class Sampler
|
class Sampler
|
||||||
|
@ -31,6 +31,8 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
|
|
||||||
|
//FIXME - Make this a member of CubicSurfaceExtractorWithNormals?
|
||||||
template<typename VoxelType>
|
template<typename VoxelType>
|
||||||
bool defaultIsQuadNeeded(VoxelType from, VoxelType to, float& materialToUse)
|
bool defaultIsQuadNeeded(VoxelType from, VoxelType to, float& materialToUse)
|
||||||
{
|
{
|
||||||
@ -45,20 +47,20 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template<typename VolumeType>
|
||||||
class CubicSurfaceExtractorWithNormals
|
class CubicSurfaceExtractorWithNormals
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CubicSurfaceExtractorWithNormals(VolumeType<VoxelType>* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, polyvox_function<bool(VoxelType from, VoxelType to, float& materialToUse)> funcIsQuadNeededCallback = defaultIsQuadNeeded<VoxelType>);
|
CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, polyvox_function<bool(typename VolumeType::VoxelType from, typename VolumeType::VoxelType to, float& materialToUse)> funcIsQuadNeededCallback = defaultIsQuadNeeded<VolumeType::VoxelType>);
|
||||||
|
|
||||||
void execute();
|
void execute();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
polyvox_function<bool(VoxelType voxel0, VoxelType voxel1, float& materialToUse)> m_funcIsQuadNeededCallback;
|
polyvox_function<bool(typename VolumeType::VoxelType voxel0, typename VolumeType::VoxelType voxel1, float& materialToUse)> m_funcIsQuadNeededCallback;
|
||||||
|
|
||||||
//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;
|
||||||
typename VolumeType<VoxelType>::Sampler m_sampVolume;
|
typename VolumeType::Sampler m_sampVolume;
|
||||||
|
|
||||||
//The surface patch we are currently filling.
|
//The surface patch we are currently filling.
|
||||||
SurfaceMesh<PositionMaterialNormal>* m_meshCurrent;
|
SurfaceMesh<PositionMaterialNormal>* m_meshCurrent;
|
||||||
|
@ -23,8 +23,8 @@ freely, subject to the following restrictions:
|
|||||||
|
|
||||||
namespace PolyVox
|
namespace PolyVox
|
||||||
{
|
{
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template<typename VolumeType>
|
||||||
CubicSurfaceExtractorWithNormals<VolumeType, VoxelType>::CubicSurfaceExtractorWithNormals(VolumeType<VoxelType>* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, polyvox_function<bool(VoxelType from, VoxelType to, float& materialToUse)> funcIsQuadNeededCallback)
|
CubicSurfaceExtractorWithNormals<VolumeType>::CubicSurfaceExtractorWithNormals(VolumeType* volData, Region region, SurfaceMesh<PositionMaterialNormal>* result, polyvox_function<bool(typename VolumeType::VoxelType from, typename VolumeType::VoxelType to, float& materialToUse)> funcIsQuadNeededCallback)
|
||||||
:m_volData(volData)
|
:m_volData(volData)
|
||||||
,m_sampVolume(volData)
|
,m_sampVolume(volData)
|
||||||
,m_meshCurrent(result)
|
,m_meshCurrent(result)
|
||||||
@ -34,8 +34,8 @@ namespace PolyVox
|
|||||||
assert(m_funcIsQuadNeededCallback);
|
assert(m_funcIsQuadNeededCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
template< template<typename> class VolumeType, typename VoxelType>
|
template<typename VolumeType>
|
||||||
void CubicSurfaceExtractorWithNormals<VolumeType, VoxelType>::execute()
|
void CubicSurfaceExtractorWithNormals<VolumeType>::execute()
|
||||||
{
|
{
|
||||||
m_meshCurrent->clear();
|
m_meshCurrent->clear();
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ namespace PolyVox
|
|||||||
{
|
{
|
||||||
void extractCubicMesh(Volume& volume, const Region& region, Mesh& resultMesh)
|
void extractCubicMesh(Volume& volume, const Region& region, Mesh& resultMesh)
|
||||||
{
|
{
|
||||||
CubicSurfaceExtractorWithNormals<SimpleVolume, MaterialDensityPair88 > surfaceExtractor(&volume, region, &resultMesh, MaterialDensityPair88::isQuadNeeded);
|
CubicSurfaceExtractorWithNormals< SimpleVolume<MaterialDensityPair88> > surfaceExtractor(&volume, region, &resultMesh, MaterialDensityPair88::isQuadNeeded);
|
||||||
surfaceExtractor.execute();
|
surfaceExtractor.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ void testForType(SurfaceMesh<PositionMaterialNormal>& result)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CubicSurfaceExtractorWithNormals<SimpleVolume, VoxelType > extractor(&volData, volData.getEnclosingRegion(), &result, VoxelType::isQuadNeeded);
|
CubicSurfaceExtractorWithNormals< SimpleVolume<VoxelType> > extractor(&volData, volData.getEnclosingRegion(), &result, VoxelType::isQuadNeeded);
|
||||||
extractor.execute();
|
extractor.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user