From 9947425169b610914a84043dbbea24adb0172cfb Mon Sep 17 00:00:00 2001 From: David Williams Date: Wed, 15 Apr 2015 16:58:24 +0200 Subject: [PATCH] Fix for code which determines which old chunk to delete. --- include/PolyVox/PagedVolume.inl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/include/PolyVox/PagedVolume.inl b/include/PolyVox/PagedVolume.inl index 7c650e43..92ad0fa4 100644 --- a/include/PolyVox/PagedVolume.inl +++ b/include/PolyVox/PagedVolume.inl @@ -343,13 +343,18 @@ namespace PolyVox // just check e.g. 10 and delete the oldest of those) but we'll see if this is a bottleneck first. Paging // the data in is probably more expensive. uint32_t uChunkCount = 0; - uint32_t uOldestChunkIndex = std::numeric_limits::max(); + uint32_t uOldestChunkIndex = 0; + uint32_t uOldestChunkTimestamp = std::numeric_limits::max(); for (uint32_t uIndex = 0; uIndex < uChunkArraySize; uIndex++) { if (m_arrayChunks[uIndex]) { uChunkCount++; - uOldestChunkIndex = std::min(uOldestChunkIndex, m_arrayChunks[uIndex]->m_uChunkLastAccessed); + if (m_arrayChunks[uIndex]->m_uChunkLastAccessed < uOldestChunkIndex) + { + uOldestChunkIndex = m_arrayChunks[uIndex]->m_uChunkLastAccessed; + uOldestChunkIndex = uIndex; + } } }