2022-11-10 19:47:39 +01:00
|
|
|
#ifndef CHUNKMANAGER_H
|
|
|
|
#define CHUNKMANAGER_H
|
|
|
|
|
2023-07-29 23:32:45 +02:00
|
|
|
#include <oneapi/tbb/concurrent_hash_map.h>
|
2023-05-20 21:19:44 +02:00
|
|
|
#include <oneapi/tbb/concurrent_queue.h>
|
2023-07-29 23:32:45 +02:00
|
|
|
#include <oneapi/tbb/concurrent_priority_queue.h>
|
|
|
|
#include <thread>
|
2023-05-20 21:19:44 +02:00
|
|
|
|
2023-10-03 18:43:29 +02:00
|
|
|
#include "chunk.hpp"
|
2023-04-09 21:44:17 +02:00
|
|
|
#include "globals.hpp"
|
2023-10-03 18:43:29 +02:00
|
|
|
#include "worldupdatemessage.h"
|
2023-03-03 21:33:11 +01:00
|
|
|
|
2023-07-29 23:32:45 +02:00
|
|
|
// Seconds to be passed outside of render distance for a chunk to be destroyed
|
|
|
|
#define UNLOAD_TIMEOUT 10
|
|
|
|
|
|
|
|
#define MESHING_PRIORITY_NORMAL 0
|
|
|
|
#define MESHING_PRIORITY_PLAYER_EDIT 10
|
|
|
|
#define GENERATION_PRIORITY_NORMAL 0
|
|
|
|
|
2022-11-10 19:47:39 +01:00
|
|
|
namespace chunkmanager
|
|
|
|
{
|
2023-10-03 22:25:46 +02:00
|
|
|
typedef oneapi::tbb::concurrent_hash_map<chunk_index_t, Chunk::Chunk*> ChunkTable;
|
2023-07-29 23:32:45 +02:00
|
|
|
typedef std::pair<Chunk::Chunk*, uint8_t> ChunkPQEntry;
|
|
|
|
// The comparing function to use
|
|
|
|
struct compare_f {
|
|
|
|
bool operator()(const ChunkPQEntry& u, const ChunkPQEntry& v) const {
|
|
|
|
return u.second > v.second;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
typedef oneapi::tbb::concurrent_priority_queue<ChunkPQEntry, compare_f> ChunkPriorityQueue;
|
|
|
|
|
|
|
|
void init();
|
2023-10-03 18:43:29 +02:00
|
|
|
void update();
|
2023-04-29 14:54:43 +02:00
|
|
|
void stop();
|
2023-03-23 21:17:06 +01:00
|
|
|
void destroy();
|
2023-10-03 18:43:29 +02:00
|
|
|
WorldUpdateMsgQueue& getWorldUpdateQueue();
|
2023-10-03 22:25:46 +02:00
|
|
|
std::array<std::array<chunk_intcoord_t, 3>, chunks_volume>& getChunksIndices();
|
2023-06-01 21:22:52 +02:00
|
|
|
Block getBlockAtPos(int x, int y, int z);
|
2022-11-10 19:47:39 +01:00
|
|
|
}
|
|
|
|
|
2023-03-07 21:37:28 +01:00
|
|
|
#endif
|