1
0
Fork 0
Univerxel/src/client/contouring/FlatDualMC.hpp

68 lines
2.6 KiB
C++
Raw Normal View History

2020-07-24 19:42:47 +00:00
#pragma once
2020-09-20 16:41:54 +00:00
#include "Abstract.hpp"
2020-07-24 19:42:47 +00:00
#include "surrounding.hpp"
2020-09-20 16:41:54 +00:00
#include "../../core/data/safe_queue.hpp"
#include "../../core/data/safe_priority_queue.hpp"
2020-10-04 13:32:28 +00:00
#include "../render/api/Models.hpp"
2020-09-20 16:41:54 +00:00
#include "../../core/data/math.hpp"
2020-07-24 19:42:47 +00:00
#include <thread>
2020-07-25 16:45:03 +00:00
using namespace data;
2020-07-24 19:42:47 +00:00
namespace contouring {
2020-07-25 16:45:03 +00:00
/// Dual Marching Cube 1:1 contouring
2020-10-04 13:32:28 +00:00
class FlatDualMC final: public Abstract {
2020-07-24 19:42:47 +00:00
public:
FlatDualMC(const std::string&);
virtual ~FlatDualMC();
2020-09-20 16:41:54 +00:00
void update(const voxel_pos&, const world::client::area_map&) override;
2020-07-24 19:42:47 +00:00
void onGui() override;
2020-08-05 13:14:57 +00:00
std::string getOptions() const override;
2020-09-20 16:41:54 +00:00
std::pair<float, float> getFarRange() const override;
size_t getQueueSize() override;
2020-07-24 19:42:47 +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-24 19:42:47 +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-24 19:42:47 +00:00
2020-09-20 16:41:54 +00:00
/// Get buffers in frustum with model matrices
/// @note buffers invalidated after update
void getModels(draw_call draw, const std::optional<geometry::Frustum> &frustum, const glm::llvec3 &offset, int density) override;
/// Get buffers hitting occlusion rays with model matrices
/// @note buffers invalidated after update
void getModels(draw_call draw, const glm::ifvec3 &from, float far, const std::vector<glm::vec3> &occlusion, const glm::llvec3 &offset, int density) override;
2020-07-24 19:42:47 +00:00
protected:
2020-10-04 13:32:28 +00:00
//FIXME: use unique_ptr
robin_hood::unordered_map<area_id, robin_hood::pair<area_info, robin_hood::unordered_map<chunk_pos, render::LodModel*>>> buffers;
2020-09-20 16:41:54 +00:00
2020-08-02 20:15:53 +00:00
safe_priority_queue_map<area_<chunk_pos>, surrounding::corners, int, area_hash> loadQueue;
2020-10-04 13:32:28 +00:00
safe_queue<std::pair<area_<chunk_pos>, render::LodModel::LodData>> loadedQueue;
2020-07-24 19:42:47 +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-24 19:42:47 +00:00
2020-09-27 20:25:35 +00:00
ushort loadDistance = 3;
ushort keepDistance = 4;
2020-08-29 14:35:08 +00:00
bool transparency = false;
2020-07-24 19:42:47 +00:00
float iso = .1f;
bool manifold = true;
2020-08-07 17:08:02 +00:00
bool reordering = true;
2020-08-08 21:35:46 +00:00
float lod_strength = .15;
float lod_quality = 0;
std::deque<bool> lod_levels;
std::vector<std::pair<float, float>> loadedLevels;
2020-07-24 19:42:47 +00:00
2020-10-04 13:32:28 +00:00
void render(const surrounding::corners &surrounding, render::LodModel::LodData& out, std::vector<render::VertexData>& tmp) const;
2020-07-24 19:42:47 +00:00
};
}