Restructuring computeBitmask code.
This commit is contained in:
parent
5974a1de9b
commit
54f235e09a
@ -160,7 +160,7 @@ namespace PolyVox
|
|||||||
private:
|
private:
|
||||||
//Compute the cell bitmask for a particular slice in z.
|
//Compute the cell bitmask for a particular slice in z.
|
||||||
template<bool isPrevZAvail>
|
template<bool isPrevZAvail>
|
||||||
void computeBitmaskForSlice(Array3DUint8& pBitmask, uint32_t uSlice);
|
void computeBitmaskForSlice(Array3DUint8& pBitmask);
|
||||||
|
|
||||||
//Use the cell bitmasks to generate all the vertices needed for that slice
|
//Use the cell bitmasks to generate all the vertices needed for that slice
|
||||||
void generateVerticesForSlice(const Array3DUint8& pBitmask,
|
void generateVerticesForSlice(const Array3DUint8& pBitmask,
|
||||||
|
@ -68,12 +68,7 @@ namespace PolyVox
|
|||||||
m_regSlicePrevious.setUpperCorner(v3dUpperCorner);
|
m_regSlicePrevious.setUpperCorner(v3dUpperCorner);
|
||||||
m_regSliceCurrent = m_regSlicePrevious;
|
m_regSliceCurrent = m_regSlicePrevious;
|
||||||
|
|
||||||
//Process the first slice (previous slice not available)
|
computeBitmaskForSlice<true>(pBitmask);
|
||||||
computeBitmaskForSlice<false>(pBitmask, 0);
|
|
||||||
for (int32_t uSlice = 1; uSlice <= m_regSizeInVoxels.getUpperZ() - m_regSizeInVoxels.getLowerZ(); uSlice++)
|
|
||||||
{
|
|
||||||
computeBitmaskForSlice<true>(pBitmask, uSlice);
|
|
||||||
}
|
|
||||||
|
|
||||||
generateVerticesForSlice(pBitmask, pIndicesX, pIndicesY, pIndicesZ);
|
generateVerticesForSlice(pBitmask, pIndicesX, pIndicesY, pIndicesZ);
|
||||||
|
|
||||||
@ -100,28 +95,24 @@ namespace PolyVox
|
|||||||
|
|
||||||
template<typename VolumeType, typename MeshType, typename ControllerType>
|
template<typename VolumeType, typename MeshType, typename ControllerType>
|
||||||
template<bool isPrevZAvail>
|
template<bool isPrevZAvail>
|
||||||
void MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::computeBitmaskForSlice(Array3DUint8& pBitmask, uint32_t uSlice)
|
void MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::computeBitmaskForSlice(Array3DUint8& pBitmask)
|
||||||
{
|
{
|
||||||
const int32_t iMaxXVolSpace = m_regSizeInVoxels.getUpperX();
|
const int32_t iMaxXVolSpace = m_regSizeInVoxels.getUpperX();
|
||||||
const int32_t iMaxYVolSpace = m_regSizeInVoxels.getUpperY();
|
const int32_t iMaxYVolSpace = m_regSizeInVoxels.getUpperY();
|
||||||
|
const int32_t iMaxZVolSpace = m_regSizeInVoxels.getUpperZ();
|
||||||
|
|
||||||
//Process the lower left corner
|
for (int32_t iZVolSpace = m_regSliceCurrent.getLowerZ(); iZVolSpace <= iMaxZVolSpace; iZVolSpace++)
|
||||||
int32_t iYVolSpace = m_regSizeInVoxels.getLowerY();
|
{
|
||||||
int32_t iXVolSpace = m_regSizeInVoxels.getLowerX();
|
uint32_t uZRegSpace = iZVolSpace - m_regSizeInVoxels.getLowerZ();
|
||||||
int32_t iZVolSpace = m_regSizeInVoxels.getLowerZ() + uSlice;
|
|
||||||
|
|
||||||
uint32_t uXRegSpace = iXVolSpace - m_regSizeInVoxels.getLowerX();
|
|
||||||
uint32_t uYRegSpace = iYVolSpace - m_regSizeInVoxels.getLowerY();
|
|
||||||
uint32_t uZRegSpace = uSlice;
|
|
||||||
|
|
||||||
//Process all remaining elemnents of the slice. In this case, previous x and y values are always available
|
//Process all remaining elemnents of the slice. In this case, previous x and y values are always available
|
||||||
for(iYVolSpace = m_regSliceCurrent.getLowerY(); iYVolSpace <= iMaxYVolSpace; iYVolSpace++)
|
for (int32_t iYVolSpace = m_regSliceCurrent.getLowerY(); iYVolSpace <= iMaxYVolSpace; iYVolSpace++)
|
||||||
{
|
{
|
||||||
m_sampVolume.setPosition(m_regSliceCurrent.getLowerX(), iYVolSpace, iZVolSpace);
|
m_sampVolume.setPosition(m_regSliceCurrent.getLowerX(), iYVolSpace, iZVolSpace);
|
||||||
for(iXVolSpace = m_regSliceCurrent.getLowerX(); iXVolSpace <= iMaxXVolSpace; iXVolSpace++)
|
for (int32_t iXVolSpace = m_regSliceCurrent.getLowerX(); iXVolSpace <= iMaxXVolSpace; iXVolSpace++)
|
||||||
{
|
{
|
||||||
uXRegSpace = iXVolSpace - m_regSizeInVoxels.getLowerX();
|
uint32_t uXRegSpace = iXVolSpace - m_regSizeInVoxels.getLowerX();
|
||||||
uYRegSpace = iYVolSpace - m_regSizeInVoxels.getLowerY();
|
uint32_t uYRegSpace = iYVolSpace - m_regSizeInVoxels.getLowerY();
|
||||||
|
|
||||||
m_sampVolume.movePositiveX();
|
m_sampVolume.movePositiveX();
|
||||||
|
|
||||||
@ -163,6 +154,7 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
template<typename VolumeType, typename MeshType, typename ControllerType>
|
template<typename VolumeType, typename MeshType, typename ControllerType>
|
||||||
void MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::generateVerticesForSlice(const Array3DUint8& pBitmask,
|
void MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::generateVerticesForSlice(const Array3DUint8& pBitmask,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user