36 lines
823 B
C++
36 lines
823 B
C++
#pragma once
|
|
|
|
#include <sstream>
|
|
#include "forward.h"
|
|
#include "Voxel.hpp"
|
|
|
|
namespace world {
|
|
constexpr auto RLE = true; //NOTE: only ~2.5% gain after zstd
|
|
|
|
/// World part as linear 3d voxel array
|
|
class Chunk {
|
|
public:
|
|
Chunk(std::istream& str, bool rle = RLE);
|
|
virtual ~Chunk();
|
|
|
|
struct EditBody {
|
|
Voxel value;
|
|
float delay;
|
|
};
|
|
struct Edit: EditBody {
|
|
chunk_voxel_idx idx;
|
|
};
|
|
|
|
/// Get voxel from index
|
|
inline const Voxel& get(chunk_voxel_idx idx) const {
|
|
return voxels[idx];
|
|
}
|
|
/// Get voxel from position
|
|
const Voxel &getAt(const chunk_voxel_pos &pos) const;
|
|
|
|
protected:
|
|
Chunk() { }
|
|
/// Chunk data
|
|
std::array<Voxel, CHUNK_SIZE> voxels;
|
|
};
|
|
} |