A PagedVolume must now always be provided with a Pager when it is constructed.
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user