A PagedVolume must now always be provided with a Pager when it is constructed.

This commit is contained in:
David Williams
2015-03-07 17:01:07 +01:00
parent 5a5b2b3875
commit aaa6b1dc15
4 changed files with 20 additions and 29 deletions

View File

@ -35,6 +35,8 @@ namespace PolyVox
,m_pPager(pPager)
,m_v3dChunkSpacePosition(v3dPosition)
{
POLYVOX_ASSERT(m_pPager, "No valid pager supplied to chunk constructor.");
// Compute the side length
m_uSideLength = uSideLength;
m_uSideLengthPower = logBase2(uSideLength);
@ -44,21 +46,13 @@ namespace PolyVox
m_tData = new VoxelType[uNoOfVoxels];
// Pass the chunk to the Pager to give it a chance to initialise it with any data
if (m_pPager)
{
// From the coordinates of the chunk we deduce the coordinates of the contained voxels.
Vector3DInt32 v3dLower = m_v3dChunkSpacePosition * static_cast<int32_t>(m_uSideLength);
Vector3DInt32 v3dUpper = v3dLower + Vector3DInt32(m_uSideLength - 1, m_uSideLength - 1, m_uSideLength - 1);
Region reg(v3dLower, v3dUpper);
// From the coordinates of the chunk we deduce the coordinates of the contained voxels.
Vector3DInt32 v3dLower = m_v3dChunkSpacePosition * static_cast<int32_t>(m_uSideLength);
Vector3DInt32 v3dUpper = v3dLower + Vector3DInt32(m_uSideLength - 1, m_uSideLength - 1, m_uSideLength - 1);
Region reg(v3dLower, v3dUpper);
// Page the data in
m_pPager->pageIn(reg, this);
}
else
{
// Just fill with zeros
std::fill(m_tData, m_tData + uNoOfVoxels, VoxelType());
}
// Page the data in
m_pPager->pageIn(reg, this);
// We'll use this later to decide if data needs to be paged out again.
m_bDataModified = false;
@ -67,7 +61,7 @@ namespace PolyVox
template <typename VoxelType>
PagedVolume<VoxelType>::Chunk::~Chunk()
{
if (m_pPager && m_bDataModified)
if (m_bDataModified)
{
// From the coordinates of the chunk we deduce the coordinates of the contained voxels.
Vector3DInt32 v3dLower = m_v3dChunkSpacePosition * static_cast<int32_t>(m_uSideLength);