42 lines
1.5 KiB
C++
42 lines
1.5 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>
|
|
|
|
using namespace data;
|
|
namespace contouring {
|
|
/// Stupid cubes 1:1 contouring
|
|
class FlatSurroundingBox: public AbstractFlat {
|
|
public:
|
|
FlatSurroundingBox(const std::string&);
|
|
virtual ~FlatSurroundingBox();
|
|
|
|
void update(const voxel_pos&, const world::area_map&) override;
|
|
|
|
/// Chunk data change
|
|
void onUpdate(const area_<chunk_pos> &, const chunk_pos &, const world::ChunkContainer &, geometry::Faces) override;
|
|
/// Chunk existante ping
|
|
/// @note notify for chunks entering view while moving
|
|
void onNotify(const area_<chunk_pos> &, const chunk_pos &, const world::ChunkContainer &) override;
|
|
|
|
protected:
|
|
safe_priority_queue_map<area_<chunk_pos>, surrounding::faces, int, area_hash> loadQueue;
|
|
safe_queue<std::pair<area_<chunk_pos>, buffer::ShortIndexed::Data>> loadedQueue;
|
|
|
|
bool running = true;
|
|
std::vector<std::thread> workers;
|
|
|
|
void enqueue(const area_<chunk_pos> &, const chunk_pos& offset, const world::ChunkContainer &);
|
|
|
|
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
|