1
0
Fork 0
Univerxel/src/contouring/FlatSurroundingBox.hpp

42 lines
1.5 KiB
C++
Raw Normal View History

2020-07-18 15:42:45 +00:00
#pragma once
#include "AbstractFlat.hpp"
#include "surrounding.hpp"
2020-07-22 20:55:13 +00:00
#include "../data/safe_queue.hpp"
#include "../data/safe_priority_queue.hpp"
#include "../data/circular_buffer.hpp"
2020-07-25 16:45:03 +00:00
#include "../render/buffer/ShortIndexed.hpp"
2020-07-22 20:55:13 +00:00
#include <thread>
2020-07-25 16:45:03 +00:00
using namespace data;
2020-07-18 15:42:45 +00:00
namespace contouring {
2020-07-25 16:45:03 +00:00
/// Stupid cubes 1:1 contouring
2020-07-18 15:42:45 +00:00
class FlatSurroundingBox: public AbstractFlat {
public:
2020-07-22 20:55:13 +00:00
FlatSurroundingBox(const std::string&);
virtual ~FlatSurroundingBox();
2020-08-02 20:15:53 +00:00
void update(const voxel_pos&, const world::area_map&) override;
2020-07-22 20:55:13 +00:00
2020-07-18 15:42:45 +00:00
/// Chunk data change
2020-08-03 16:15:02 +00:00
void onUpdate(const area_<chunk_pos> &, const chunk_pos &, const world::ChunkContainer &, geometry::Faces) override;
2020-07-18 15:42:45 +00:00
/// Chunk existante ping
/// @note notify for chunks entering view while moving
2020-08-03 16:15:02 +00:00
void onNotify(const area_<chunk_pos> &, const chunk_pos &, const world::ChunkContainer &) override;
2020-07-18 15:42:45 +00:00
2020-07-22 20:55:13 +00:00
protected:
2020-08-02 20:15:53 +00:00
safe_priority_queue_map<area_<chunk_pos>, surrounding::faces, int, area_hash> loadQueue;
safe_queue<std::pair<area_<chunk_pos>, buffer::ShortIndexed::Data>> loadedQueue;
2020-07-22 20:55:13 +00:00
bool running = true;
std::vector<std::thread> workers;
2020-08-03 16:15:02 +00:00
void enqueue(const area_<chunk_pos> &, const chunk_pos& offset, const world::ChunkContainer &);
2020-07-22 20:55:13 +00:00
2020-07-18 15:42:45 +00:00
private:
2020-07-24 19:42:47 +00:00
static inline bool isTransparent(const surrounding::faces &surrounding, const std::pair<ushort, ushort> &idx);
2020-07-25 16:45:03 +00:00
static void render(const surrounding::faces &surrounding, std::vector<buffer::VertexData> &vertices);
2020-07-18 15:42:45 +00:00
};
2020-07-25 16:45:03 +00:00
} // namespace contouring