52 lines
1.9 KiB
C++
52 lines
1.9 KiB
C++
#pragma once
|
|
|
|
#include "AbstractFlat.hpp"
|
|
#include "surrounding.hpp"
|
|
|
|
#include "../data/safe_queue.hpp"
|
|
#include "../data/safe_priority_queue.hpp"
|
|
#include "../data/circular_buffer.hpp"
|
|
#include "../render/buffer/ShortIndexed.hpp"
|
|
#include <thread>
|
|
|
|
#define REPORT_BUFFER_SIZE 128
|
|
|
|
using namespace data;
|
|
namespace contouring {
|
|
/// Stupid cubes 1:1 contouring
|
|
class FlatSurroundingBox: public AbstractFlat {
|
|
public:
|
|
FlatSurroundingBox(const std::string&);
|
|
virtual ~FlatSurroundingBox();
|
|
|
|
void update(const camera_pos&) override;
|
|
|
|
void onGui() override;
|
|
|
|
/// Chunk data change
|
|
void onUpdate(const chunk_pos &, const robin_hood::unordered_map<chunk_pos, std::shared_ptr<world::Chunk>> &, geometry::Faces) override;
|
|
/// Chunk existante ping
|
|
/// @note notify for chunks entering view while moving
|
|
void onNotify(const chunk_pos &, const robin_hood::unordered_map<chunk_pos, std::shared_ptr<world::Chunk>> &) override;
|
|
|
|
protected:
|
|
safe_priority_queue_map<chunk_pos, surrounding::faces, int> loadQueue;
|
|
safe_queue<std::pair<chunk_pos, buffer::ShortIndexed::Data>> loadedQueue;
|
|
|
|
struct report {
|
|
circular_buffer<float> count = circular_buffer<float>(REPORT_BUFFER_SIZE, 0); // MAYBE: store int
|
|
circular_buffer<float> load = circular_buffer<float>(REPORT_BUFFER_SIZE, 0);
|
|
circular_buffer<float> loaded = circular_buffer<float>(REPORT_BUFFER_SIZE, 0);
|
|
} reports;
|
|
|
|
bool running = true;
|
|
std::vector<std::thread> workers;
|
|
|
|
void enqueue(const chunk_pos &, const robin_hood::unordered_map<chunk_pos, std::shared_ptr<world::Chunk>> &);
|
|
|
|
private:
|
|
static inline bool isTransparent(const surrounding::faces &surrounding, const std::pair<ushort, ushort> &idx);
|
|
static void render(const surrounding::faces &surrounding, std::vector<buffer::VertexData> &vertices);
|
|
};
|
|
} // namespace contouring
|