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 commit is contained in:
parent
e0ce93acb1
commit
13be35aac9
@ -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 computeBitmaskForSlice();
|
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);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// 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.
|
||||||
|
@ -42,18 +42,6 @@ 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;
|
||||||
@ -130,7 +118,26 @@ 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();
|
||||||
@ -314,12 +321,5 @@ namespace PolyVox
|
|||||||
} // For each triangle
|
} // For each triangle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} // For each cell
|
|
||||||
sampler.movePositiveX();
|
|
||||||
} // For X
|
|
||||||
startOfRow.movePositiveY();
|
|
||||||
} // For Y
|
|
||||||
startOfSlice.movePositiveZ();
|
|
||||||
} // For Z
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user