Replaced number with constant.
This commit is contained in:
parent
c4cccf9043
commit
99390580dd
@ -307,10 +307,15 @@ namespace PolyVox
|
|||||||
|
|
||||||
uint32_t m_uChunkCountLimit = 0;
|
uint32_t m_uChunkCountLimit = 0;
|
||||||
|
|
||||||
// The size of the volume
|
// Chunks are stored in the following array which is used as a hash-table. Conventional wisdom is that such a hash-table
|
||||||
//Region m_regValidRegionInChunks;
|
// should not be more than half full to avoid conflicts, and a practical chunk size seems to be 64^3. With this configuration
|
||||||
|
// there can be up to 32768*64^3 = 8 gigavoxels (with each voxel perhaps being many bytes). This should effectively make use
|
||||||
mutable std::unique_ptr< Chunk > m_arrayChunks[16384];
|
// of even high end machines. Of course, the user can choose to limit the memory usage in which case much less of the chunk
|
||||||
|
// array will actually be used. None-the-less, we have chosen to use a fixed size array (rather than a vector) as it appear to
|
||||||
|
// be slightly faster (probably due to the extra pointer indirection in a vector?) and the actual size of this array should
|
||||||
|
// just be 1Mb or so.
|
||||||
|
static const uint32_t uChunkArraySize = 65536;
|
||||||
|
mutable std::unique_ptr< Chunk > m_arrayChunks[uChunkArraySize];
|
||||||
|
|
||||||
// The size of the chunks
|
// The size of the chunks
|
||||||
uint16_t m_uChunkSideLength;
|
uint16_t m_uChunkSideLength;
|
||||||
|
@ -58,7 +58,7 @@ namespace PolyVox
|
|||||||
|
|
||||||
// Enforce sensible limits on the number of chunks.
|
// Enforce sensible limits on the number of chunks.
|
||||||
const uint32_t uMinPracticalNoOfChunks = 32; // Enough to make sure a chunks and it's neighbours can be loaded, with a few to spare.
|
const uint32_t uMinPracticalNoOfChunks = 32; // Enough to make sure a chunks and it's neighbours can be loaded, with a few to spare.
|
||||||
const uint32_t uMaxPracticalNoOfChunks = 32768; // Should prevent multi-gigabyte volumes when chunk sizes are reasonable.
|
const uint32_t uMaxPracticalNoOfChunks = uChunkArraySize / 2; // A hash table should only become half-full to avoid too many clashes.
|
||||||
POLYVOX_LOG_WARNING_IF(m_uChunkCountLimit < uMinPracticalNoOfChunks, "Requested memory usage limit of "
|
POLYVOX_LOG_WARNING_IF(m_uChunkCountLimit < uMinPracticalNoOfChunks, "Requested memory usage limit of "
|
||||||
<< uTargetMemoryUsageInBytes / (1024 * 1024) << "Mb is too low and cannot be adhered to.");
|
<< uTargetMemoryUsageInBytes / (1024 * 1024) << "Mb is too low and cannot be adhered to.");
|
||||||
m_uChunkCountLimit = (std::max)(m_uChunkCountLimit, uMinPracticalNoOfChunks);
|
m_uChunkCountLimit = (std::max)(m_uChunkCountLimit, uMinPracticalNoOfChunks);
|
||||||
@ -287,7 +287,7 @@ namespace PolyVox
|
|||||||
}
|
}
|
||||||
|
|
||||||
iIndex++;
|
iIndex++;
|
||||||
iIndex %= 16384;
|
iIndex %= uChunkArraySize;
|
||||||
} while (iIndex != iStartIndex);
|
} while (iIndex != iStartIndex);
|
||||||
|
|
||||||
// Check whether the chunk was found.
|
// Check whether the chunk was found.
|
||||||
@ -307,7 +307,7 @@ namespace PolyVox
|
|||||||
pChunk->m_uChunkLastAccessed = ++m_uTimestamper; // Important, as we may soon delete the oldest chunk
|
pChunk->m_uChunkLastAccessed = ++m_uTimestamper; // Important, as we may soon delete the oldest chunk
|
||||||
//m_mapChunks.insert(std::make_pair(v3dChunkPos, std::unique_ptr<Chunk>(pChunk)));
|
//m_mapChunks.insert(std::make_pair(v3dChunkPos, std::unique_ptr<Chunk>(pChunk)));
|
||||||
|
|
||||||
for (uint32_t ct = iStartIndex; ct < 16384; ct++)
|
for (uint32_t ct = iStartIndex; ct < uChunkArraySize; ct++)
|
||||||
{
|
{
|
||||||
if (m_arrayChunks[ct] == nullptr)
|
if (m_arrayChunks[ct] == nullptr)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user