-
Notifications
You must be signed in to change notification settings - Fork 2
/
tile_generator.h
42 lines (34 loc) · 1.17 KB
/
tile_generator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#ifndef TILE_GENERATOR_H
#define TILE_GENERATOR_H
#include "modules/voxel/generators/voxel_generator.h"
#include "modules/voxel/streams/voxel_block_request.h"
#include "core/ustring.h"
#include <unordered_map>
#include <functional>
#include <array>
#include <optional>
#include "tile_generator_types.h"
namespace TGI = TileGeneratorInternal;
class TileGenerator : public VoxelGenerator {
GDCLASS(TileGenerator, VoxelGenerator)
private:
struct HeightMapAccess;
int _floor_elevation;
int _ceiling_elevation;
std::array<std::optional<TGI::cache_entry_t>,4> _image_cache;
int _next_cache_entry = 0;
std::unordered_map<TGI::key_t,String,std::function<size_t(TGI::key_t)>> _tile_map;
const inline std::optional<Ref<Image>> _get_tile_from_tile_key(const TGI::key_t tile_key);
protected:
static void _bind_methods();
public:
TileGenerator();
virtual void generate_block(VoxelBlockRequest &input);
void set_floor_elevation(int floor_elevation);
int get_floor_elevation();
void set_ceiling_elevation(int ceiling_elevation);
void set_cell(int x, int z, String resource);
int get_ceiling_elevation();
real_t get_elevation(const real_t x, const real_t z);
};
#endif // TILE_GENERATOR_H