add blocks_agent templates & remove block.get_slow

This commit is contained in:
MihailRis 2024-12-16 11:26:57 +03:00
parent 5bf56d1f64
commit 6157f8193d
9 changed files with 158 additions and 104 deletions

View file

@ -11,10 +11,12 @@
class Chunk;
class Level;
class ContentIndices;
class GlobalChunks {
Level* level;
std::unordered_map<long long, std::shared_ptr<Chunk>> chunksMap;
const ContentIndices* indices;
std::unordered_map<uint64_t, std::shared_ptr<Chunk>> chunksMap;
std::unordered_map<glm::ivec2, std::shared_ptr<Chunk>> pinnedChunks;
std::unordered_map<ptrdiff_t, int> refCounters;
public:
@ -27,8 +29,6 @@ public:
void pinChunk(std::shared_ptr<Chunk> chunk);
void unpinChunk(int x, int z);
voxel* get(int x, int y, int z) const;
size_t size() const;
void incref(Chunk* chunk);
@ -38,4 +38,12 @@ public:
void save(Chunk* chunk);
void saveAll();
void putChunk(std::shared_ptr<Chunk> chunk);
Chunk* getChunk(int cx, int cz) const;
const ContentIndices& getContentIndices() const {
return *indices;
}
};