mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-03-06 04:18:36 -06:00
Rename HashKey to ChunkHashKey and define it as uint64_t
This commit is contained in:
@@ -95,8 +95,21 @@ namespace openspace {
|
||||
return std::abs(x - other.x) + std::abs(y - other.y);
|
||||
}
|
||||
|
||||
HashKey ChunkIndex::hashKey() const {
|
||||
return x ^ (y << 16) ^ (level << 24);
|
||||
|
||||
/**
|
||||
Creates a hash which can be used as key in hash maps
|
||||
BITS | USAGE
|
||||
0-6 | level
|
||||
6-26 | x
|
||||
26-46 | y
|
||||
46-64 | reserved for future use, e.g. time key
|
||||
*/
|
||||
ChunkHashKey ChunkIndex::hashKey() const {
|
||||
ChunkHashKey key = 0LL;
|
||||
key |= level;
|
||||
key |= x << 6;
|
||||
key |= ((ChunkHashKey)y) << 26;
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <glm/glm.hpp>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
|
||||
@@ -51,7 +52,7 @@ enum CardinalDirection {
|
||||
|
||||
|
||||
|
||||
using HashKey = unsigned long;
|
||||
using ChunkHashKey = uint64_t;
|
||||
|
||||
|
||||
struct ChunkIndex {
|
||||
@@ -107,7 +108,7 @@ struct ChunkIndex {
|
||||
|
||||
int manhattan(const ChunkIndex& other) const;
|
||||
|
||||
HashKey hashKey() const;
|
||||
ChunkHashKey hashKey() const;
|
||||
|
||||
bool operator==(const ChunkIndex& other) const;
|
||||
};
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace openspace {
|
||||
|
||||
std::shared_ptr<TileIOResult> AsyncTileDataProvider::nextTileIOResult() {
|
||||
auto tileIOResult = _concurrentJobManager.popFinishedJob()->product();
|
||||
HashKey key = tileIOResult->chunkIndex.hashKey();
|
||||
ChunkHashKey key = tileIOResult->chunkIndex.hashKey();
|
||||
if (_enqueuedTileRequests.find(key) != _enqueuedTileRequests.end()) {
|
||||
_enqueuedTileRequests.erase(key);
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ namespace openspace {
|
||||
|
||||
std::shared_ptr<TileDataset> _tileDataset;
|
||||
ConcurrentJobManager<TileIOResult> _concurrentJobManager;
|
||||
std::unordered_map<HashKey, ChunkIndex> _enqueuedTileRequests;
|
||||
std::unordered_map<ChunkHashKey, ChunkIndex> _enqueuedTileRequests;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace openspace {
|
||||
return tile;
|
||||
}
|
||||
|
||||
HashKey key = chunkIndex.hashKey();
|
||||
ChunkHashKey key = chunkIndex.hashKey();
|
||||
|
||||
if (_tileCache->exist(key)) {
|
||||
return _tileCache->get(key);
|
||||
@@ -118,7 +118,7 @@ namespace openspace {
|
||||
return Tile::Status::OutOfRange;
|
||||
}
|
||||
|
||||
HashKey key = chunkIndex.hashKey();
|
||||
ChunkHashKey key = chunkIndex.hashKey();
|
||||
|
||||
if (_tileCache->exist(key)) {
|
||||
return _tileCache->get(key).status;
|
||||
@@ -129,7 +129,7 @@ namespace openspace {
|
||||
|
||||
|
||||
Tile CachingTileProvider::getOrStartFetchingTile(ChunkIndex chunkIndex) {
|
||||
HashKey hashkey = chunkIndex.hashKey();
|
||||
ChunkHashKey hashkey = chunkIndex.hashKey();
|
||||
if (_tileCache->exist(hashkey)) {
|
||||
return _tileCache->get(hashkey);
|
||||
}
|
||||
@@ -145,7 +145,7 @@ namespace openspace {
|
||||
|
||||
|
||||
void CachingTileProvider::initializeAndAddToCache(std::shared_ptr<TileIOResult> tileIOResult) {
|
||||
HashKey key = tileIOResult->chunkIndex.hashKey();
|
||||
ChunkHashKey key = tileIOResult->chunkIndex.hashKey();
|
||||
TileDataset::DataLayout dataLayout = _asyncTextureDataProvider->getTextureDataProvider()->getDataLayout();
|
||||
Texture* texturePtr = new Texture(
|
||||
tileIOResult->imageData,
|
||||
|
||||
@@ -75,7 +75,7 @@ namespace openspace {
|
||||
};
|
||||
|
||||
|
||||
typedef LRUCache<HashKey, Tile> TileCache;
|
||||
typedef LRUCache<ChunkHashKey, Tile> TileCache;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user