Changed interface to SurfaceExtractor.
This commit is contained in:
@ -39,9 +39,9 @@ namespace PolyVox
|
||||
class SurfaceExtractor
|
||||
{
|
||||
public:
|
||||
SurfaceExtractor(Volume<VoxelType>& volData);
|
||||
SurfaceExtractor(Volume<VoxelType>* volData, Region region, SurfaceMesh* result);
|
||||
|
||||
std::shared_ptr<SurfaceMesh> extractSurfaceForRegion(Region region);
|
||||
void execute();
|
||||
|
||||
private:
|
||||
//Compute the cell bitmask for a particular slice in z.
|
||||
@ -71,7 +71,7 @@ namespace PolyVox
|
||||
const Array2DInt32& m_pCurrentVertexIndicesZ);
|
||||
|
||||
//The volume data and a sampler to access it.
|
||||
Volume<VoxelType> m_volData;
|
||||
Volume<VoxelType>* m_volData;
|
||||
VolumeSampler<VoxelType> m_sampVolume;
|
||||
|
||||
//Holds a position in volume space.
|
||||
@ -91,6 +91,7 @@ namespace PolyVox
|
||||
SurfaceMesh* m_meshCurrent;
|
||||
|
||||
//Information about the region we are currently processing
|
||||
Region m_regInput;
|
||||
Region m_regInputCropped;
|
||||
Region m_regInputUncropped;
|
||||
Region m_regVolumeCropped;
|
||||
|
@ -32,27 +32,29 @@ using namespace std;
|
||||
namespace PolyVox
|
||||
{
|
||||
template <typename VoxelType>
|
||||
SurfaceExtractor<VoxelType>::SurfaceExtractor(Volume<VoxelType>& volData)
|
||||
SurfaceExtractor<VoxelType>::SurfaceExtractor(Volume<VoxelType>* volData, Region region, SurfaceMesh* result)
|
||||
:m_volData(volData)
|
||||
,m_sampVolume(&volData)
|
||||
,m_sampVolume(volData)
|
||||
,m_regInput(region)
|
||||
,m_meshCurrent(result)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename VoxelType>
|
||||
shared_ptr<SurfaceMesh> SurfaceExtractor<VoxelType>::extractSurfaceForRegion(Region region)
|
||||
void SurfaceExtractor<VoxelType>::execute()
|
||||
{
|
||||
m_regInputUncropped = region;
|
||||
m_regInputUncropped = m_regInput;
|
||||
|
||||
//When generating the mesh for a region we actually look outside it in the
|
||||
// back, bottom, right direction. Protect against access violations by cropping region here
|
||||
m_regVolumeCropped = m_volData.getEnclosingRegion();
|
||||
m_regVolumeCropped = m_volData->getEnclosingRegion();
|
||||
m_regInputUncropped.cropTo(m_regVolumeCropped);
|
||||
m_regVolumeCropped.setUpperCorner(m_regVolumeCropped.getUpperCorner() - Vector3DInt16(1,1,1));
|
||||
|
||||
m_regInputCropped = region;
|
||||
m_regInputCropped = m_regInput;
|
||||
m_regInputCropped.cropTo(m_regVolumeCropped);
|
||||
|
||||
m_meshCurrent = new SurfaceMesh();
|
||||
//m_meshCurrent = new SurfaceMesh();
|
||||
|
||||
m_uRegionWidth = m_regInputCropped.width();
|
||||
m_uRegionHeight = m_regInputCropped.height();
|
||||
@ -147,8 +149,6 @@ namespace PolyVox
|
||||
lodRecord.beginIndex = 0;
|
||||
lodRecord.endIndex = m_meshCurrent->getNoOfIndices();
|
||||
m_meshCurrent->m_vecLodRecords.push_back(lodRecord);
|
||||
|
||||
return shared_ptr<SurfaceMesh>(m_meshCurrent);
|
||||
}
|
||||
|
||||
template<typename VoxelType>
|
||||
|
Reference in New Issue
Block a user