mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-08 04:21:50 +00:00
move block set logic to the blocks_agent
This commit is contained in:
parent
6157f8193d
commit
87c19d69dc
7 changed files with 210 additions and 133 deletions
|
|
@ -14,6 +14,16 @@ class Level;
|
|||
class ContentIndices;
|
||||
|
||||
class GlobalChunks {
|
||||
static inline uint64_t keyfrom(int32_t x, int32_t z) {
|
||||
union {
|
||||
int32_t pos[2];
|
||||
uint64_t key;
|
||||
} ekey;
|
||||
ekey.pos[0] = x;
|
||||
ekey.pos[1] = z;
|
||||
return ekey.key;
|
||||
}
|
||||
|
||||
Level* level;
|
||||
const ContentIndices* indices;
|
||||
std::unordered_map<uint64_t, std::shared_ptr<Chunk>> chunksMap;
|
||||
|
|
@ -41,7 +51,13 @@ public:
|
|||
|
||||
void putChunk(std::shared_ptr<Chunk> chunk);
|
||||
|
||||
Chunk* getChunk(int cx, int cz) const;
|
||||
inline Chunk* getChunk(int cx, int cz) const {
|
||||
const auto& found = chunksMap.find(keyfrom(cx, cz));
|
||||
if (found == chunksMap.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return found->second.get();
|
||||
}
|
||||
|
||||
const ContentIndices& getContentIndices() const {
|
||||
return *indices;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue