Revert "Rather ugly split of some code into a separate function, to keep the main loop as small and simple as possible. To be tidied up shortly."

This reverts commit 13be35aac906ee34448c3160372db4dcb031022f.
This commit is contained in:
David Williams 2015-05-25 20:35:55 +02:00
parent c384fbfea8
commit 1d51ee8d0a
2 changed files with 197 additions and 197 deletions

View File

@ -159,7 +159,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.
void generateMeshForCell(uint32_t uXRegSpace, uint32_t uYRegSpace, uint32_t uZRegSpace, typename VolumeType::Sampler& sampler, typename VolumeType::VoxelType v111, uint8_t iCubeIndex, Array3DInt32& pIndicesX, Array3DInt32& pIndicesY, Array3DInt32& pIndicesZ, int32_t iXVolSpace, int32_t iYVolSpace, int32_t iZVolSpace); void computeBitmaskForSlice();
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// NOTE: These two functions are in the .h file rather than the .inl due to an apparent bug in VC2010. // NOTE: These two functions are in the .h file rather than the .inl due to an apparent bug in VC2010.

View File

@ -42,6 +42,18 @@ namespace PolyVox
Timer timer; Timer timer;
m_meshCurrent->clear(); m_meshCurrent->clear();
computeBitmaskForSlice();
m_meshCurrent->setOffset(m_regSizeInVoxels.getLowerCorner());
POLYVOX_LOG_TRACE("Marching cubes surface extraction took ", timer.elapsedTimeInMilliSeconds(),
"ms (Region size = ", m_regSizeInVoxels.getWidthInVoxels(), "x", m_regSizeInVoxels.getHeightInVoxels(),
"x", m_regSizeInVoxels.getDepthInVoxels(), ")");
}
template<typename VolumeType, typename MeshType, typename ControllerType>
void MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::computeBitmaskForSlice()
{
const uint32_t uArrayWidth = m_regSizeInVoxels.getUpperX() - m_regSizeInVoxels.getLowerX() + 2; const uint32_t uArrayWidth = m_regSizeInVoxels.getUpperX() - m_regSizeInVoxels.getLowerX() + 2;
const uint32_t uArrayHeight = m_regSizeInVoxels.getUpperY() - m_regSizeInVoxels.getLowerY() + 2; const uint32_t uArrayHeight = m_regSizeInVoxels.getUpperY() - m_regSizeInVoxels.getLowerY() + 2;
const uint32_t uArrayDepth = m_regSizeInVoxels.getUpperZ() - m_regSizeInVoxels.getLowerZ() + 2; const uint32_t uArrayDepth = m_regSizeInVoxels.getUpperZ() - m_regSizeInVoxels.getLowerZ() + 2;
@ -118,26 +130,7 @@ namespace PolyVox
/* Cube is entirely in/out of the surface */ /* Cube is entirely in/out of the surface */
if (edgeTable[iCubeIndex] != 0) if (edgeTable[iCubeIndex] != 0)
{ {
generateMeshForCell(uXRegSpace, uYRegSpace, uZRegSpace, sampler, v111, iCubeIndex, pIndicesX, pIndicesY, pIndicesZ, iXVolSpace, iYVolSpace, iZVolSpace);
}
sampler.movePositiveX();
} // For X
startOfRow.movePositiveY();
} // For Y
startOfSlice.movePositiveZ();
} // For Z
m_meshCurrent->setOffset(m_regSizeInVoxels.getLowerCorner());
POLYVOX_LOG_TRACE("Marching cubes surface extraction took ", timer.elapsedTimeInMilliSeconds(),
"ms (Region size = ", m_regSizeInVoxels.getWidthInVoxels(), "x", m_regSizeInVoxels.getHeightInVoxels(),
"x", m_regSizeInVoxels.getDepthInVoxels(), ")");
}
template<typename VolumeType, typename MeshType, typename ControllerType>
void MarchingCubesSurfaceExtractor<VolumeType, MeshType, ControllerType>::generateMeshForCell(uint32_t uXRegSpace, uint32_t uYRegSpace, uint32_t uZRegSpace, typename VolumeType::Sampler& sampler, typename VolumeType::VoxelType v111, uint8_t iCubeIndex, Array3DInt32& pIndicesX, Array3DInt32& pIndicesY, Array3DInt32& pIndicesZ, int32_t iXVolSpace, int32_t iYVolSpace, int32_t iZVolSpace)
{
// These three might not have been sampled, as v111 is the only one we sample every iteration. // These three might not have been sampled, as v111 is the only one we sample every iteration.
typename VolumeType::VoxelType v110 = sampler.peekVoxel0px0py1nz(); typename VolumeType::VoxelType v110 = sampler.peekVoxel0px0py1nz();
typename VolumeType::VoxelType v101 = sampler.peekVoxel0px1ny0pz(); typename VolumeType::VoxelType v101 = sampler.peekVoxel0px1ny0pz();
@ -321,5 +314,12 @@ namespace PolyVox
} // For each triangle } // For each triangle
} }
} }
} // For each cell
sampler.movePositiveX();
} // For X
startOfRow.movePositiveY();
} // For Y
startOfSlice.movePositiveZ();
} // For Z
} }
} }