Merge branch 'patch-1' of github.com:mrakh/reactphysics3d into mrakh-patch-1
This commit is contained in:
commit
d0ab634f4e
|
@ -91,30 +91,26 @@ class Deque {
|
||||||
/// Return a reference to an item at the given virtual index in range [0; mSize-1]
|
/// Return a reference to an item at the given virtual index in range [0; mSize-1]
|
||||||
T& getItem(uint64 virtualIndex) const {
|
T& getItem(uint64 virtualIndex) const {
|
||||||
|
|
||||||
// If the virtual index is valid
|
// Ensure the virtual index is valid
|
||||||
if (virtualIndex < mSize) {
|
assert(virtualIndex < mSize);
|
||||||
|
|
||||||
uint64 chunkIndex = mFirstChunkIndex;
|
uint64 chunkIndex = mFirstChunkIndex;
|
||||||
uint64 itemIndex = mFirstItemIndex;
|
uint64 itemIndex = mFirstItemIndex;
|
||||||
|
|
||||||
const uint64 nbItemsFirstChunk = CHUNK_NB_ITEMS - mFirstItemIndex;
|
const uint64 nbItemsFirstChunk = CHUNK_NB_ITEMS - mFirstItemIndex;
|
||||||
if (virtualIndex < nbItemsFirstChunk) {
|
if (virtualIndex < nbItemsFirstChunk) {
|
||||||
itemIndex += virtualIndex;
|
itemIndex += virtualIndex;
|
||||||
}
|
|
||||||
else {
|
|
||||||
|
|
||||||
virtualIndex -= nbItemsFirstChunk;
|
|
||||||
chunkIndex++;
|
|
||||||
|
|
||||||
chunkIndex += virtualIndex / CHUNK_NB_ITEMS;
|
|
||||||
itemIndex = virtualIndex % CHUNK_NB_ITEMS;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mChunks[chunkIndex][itemIndex];
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(false);
|
|
||||||
|
virtualIndex -= nbItemsFirstChunk;
|
||||||
|
chunkIndex++;
|
||||||
|
|
||||||
|
chunkIndex += virtualIndex / CHUNK_NB_ITEMS;
|
||||||
|
itemIndex = virtualIndex % CHUNK_NB_ITEMS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return mChunks[chunkIndex][itemIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add more chunks
|
/// Add more chunks
|
||||||
|
|
Loading…
Reference in New Issue
Block a user