diff --git a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h index 1943a771..0f9e5405 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h +++ b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.h @@ -48,7 +48,7 @@ namespace PolyVox //Compute the cell bitmask for a given cell. template - void computeBitmaskForCell(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask); + void computeBitmaskForCell(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask, uint32_t uXRegSpace, uint32_t uYRegSpace); //Use the cell bitmasks to generate all the vertices needed for that slice void generateVerticesForSlice(const Array2DUint8& pCurrentBitmask, @@ -182,16 +182,6 @@ namespace PolyVox VolumeType* m_volData; typename VolumeType::Sampler m_sampVolume; - //Holds a position in volume space. - int32_t iXVolSpace; - int32_t iYVolSpace; - int32_t iZVolSpace; - - //Holds a position in region space. - uint32_t uXRegSpace; - uint32_t uYRegSpace; - uint32_t uZRegSpace; - //Used to return the number of cells in a slice which contain triangles. uint32_t m_uNoOfOccupiedCells; diff --git a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl index 52741703..b5df8f03 100644 --- a/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl +++ b/library/PolyVoxCore/include/PolyVoxCore/MarchingCubesSurfaceExtractor.inl @@ -136,18 +136,18 @@ namespace PolyVox const int32_t iMaxXVolSpace = m_regSliceCurrent.getUpperCorner().getX(); const int32_t iMaxYVolSpace = m_regSliceCurrent.getUpperCorner().getY(); - iZVolSpace = m_regSliceCurrent.getLowerCorner().getZ(); - uZRegSpace = iZVolSpace - m_regSizeInVoxels.getLowerCorner().getZ(); + int32_t iZVolSpace = m_regSliceCurrent.getLowerCorner().getZ(); + uint32_t uZRegSpace = iZVolSpace - m_regSizeInVoxels.getLowerCorner().getZ(); //Process the lower left corner - iYVolSpace = m_regSliceCurrent.getLowerCorner().getY(); - iXVolSpace = m_regSliceCurrent.getLowerCorner().getX(); + int32_t iYVolSpace = m_regSliceCurrent.getLowerCorner().getY(); + int32_t iXVolSpace = m_regSliceCurrent.getLowerCorner().getX(); - uXRegSpace = iXVolSpace - m_regSizeInVoxels.getLowerCorner().getX(); - uYRegSpace = iYVolSpace - m_regSizeInVoxels.getLowerCorner().getY(); + uint32_t uXRegSpace = iXVolSpace - m_regSizeInVoxels.getLowerCorner().getX(); + uint32_t uYRegSpace = iYVolSpace - m_regSizeInVoxels.getLowerCorner().getY(); m_sampVolume.setPosition(iXVolSpace,iYVolSpace,iZVolSpace); - computeBitmaskForCell(pPreviousBitmask, pCurrentBitmask); + computeBitmaskForCell(pPreviousBitmask, pCurrentBitmask, uXRegSpace, uYRegSpace); //Process the edge where x is minimal. iXVolSpace = m_regSliceCurrent.getLowerCorner().getX(); @@ -159,7 +159,7 @@ namespace PolyVox m_sampVolume.movePositiveY(); - computeBitmaskForCell(pPreviousBitmask, pCurrentBitmask); + computeBitmaskForCell(pPreviousBitmask, pCurrentBitmask, uXRegSpace, uYRegSpace); } //Process the edge where y is minimal. @@ -172,7 +172,7 @@ namespace PolyVox m_sampVolume.movePositiveX(); - computeBitmaskForCell(pPreviousBitmask, pCurrentBitmask); + computeBitmaskForCell(pPreviousBitmask, pCurrentBitmask, uXRegSpace, uYRegSpace); } //Process all remaining elemnents of the slice. In this case, previous x and y values are always available @@ -186,7 +186,7 @@ namespace PolyVox m_sampVolume.movePositiveX(); - computeBitmaskForCell(pPreviousBitmask, pCurrentBitmask); + computeBitmaskForCell(pPreviousBitmask, pCurrentBitmask, uXRegSpace, uYRegSpace); } } @@ -195,7 +195,7 @@ namespace PolyVox template template - void MarchingCubesSurfaceExtractor::computeBitmaskForCell(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask) + void MarchingCubesSurfaceExtractor::computeBitmaskForCell(const Array2DUint8& pPreviousBitmask, Array2DUint8& pCurrentBitmask, uint32_t uXRegSpace, uint32_t uYRegSpace) { uint8_t iCubeIndex = 0; @@ -385,7 +385,7 @@ namespace PolyVox } //Save the bitmask - pCurrentBitmask[uXRegSpace][iYVolSpace- m_regSizeInVoxels.getLowerCorner().getY()] = iCubeIndex; + pCurrentBitmask[uXRegSpace][uYRegSpace] = iCubeIndex; if(edgeTable[iCubeIndex] != 0) {