2016-05-01 13:20:27 -07:00
|
|
|
#ifndef VOXEL_LIBRARY_H
|
|
|
|
#define VOXEL_LIBRARY_H
|
|
|
|
|
|
|
|
#include "voxel.h"
|
2018-09-19 12:25:04 -07:00
|
|
|
#include <core/resource.h>
|
2016-05-01 13:20:27 -07:00
|
|
|
|
2017-08-14 17:24:52 -07:00
|
|
|
class VoxelLibrary : public Resource {
|
|
|
|
GDCLASS(VoxelLibrary, Resource)
|
2016-05-01 13:20:27 -07:00
|
|
|
|
|
|
|
public:
|
2016-12-31 19:40:16 -08:00
|
|
|
static const unsigned int MAX_VOXEL_TYPES = 256; // Required limit because voxel types are stored in 8 bits
|
2016-05-01 13:20:27 -07:00
|
|
|
|
2016-12-31 19:40:16 -08:00
|
|
|
VoxelLibrary();
|
|
|
|
~VoxelLibrary();
|
2016-05-01 13:20:27 -07:00
|
|
|
|
2016-12-31 19:40:16 -08:00
|
|
|
int get_atlas_size() const { return _atlas_size; }
|
|
|
|
void set_atlas_size(int s);
|
2016-05-01 13:20:27 -07:00
|
|
|
|
2016-12-31 19:40:16 -08:00
|
|
|
// Use this factory rather than creating voxels from scratch
|
|
|
|
Ref<Voxel> create_voxel(int id, String name);
|
2016-05-01 13:20:27 -07:00
|
|
|
|
2017-08-14 17:24:52 -07:00
|
|
|
int get_voxel_count() const;
|
|
|
|
|
|
|
|
void load_default();
|
|
|
|
|
2016-12-31 19:40:16 -08:00
|
|
|
// Internal getters
|
2016-05-01 13:20:27 -07:00
|
|
|
|
2016-12-31 19:40:16 -08:00
|
|
|
_FORCE_INLINE_ bool has_voxel(int id) const { return _voxel_types[id].is_valid(); }
|
2017-08-12 16:19:39 -07:00
|
|
|
_FORCE_INLINE_ const Voxel &get_voxel_const(int id) const { return **_voxel_types[id]; }
|
2016-05-01 13:20:27 -07:00
|
|
|
|
2016-12-31 20:23:22 -08:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-08-14 17:24:52 -07:00
|
|
|
bool _set(const StringName &p_name, const Variant &p_value);
|
|
|
|
bool _get(const StringName &p_name, Variant &r_ret) const;
|
|
|
|
void _get_property_list(List<PropertyInfo> *p_list) const;
|
|
|
|
|
2016-12-31 20:23:22 -08:00
|
|
|
Ref<Voxel> _get_voxel_bind(int id);
|
|
|
|
|
2016-05-01 13:20:27 -07:00
|
|
|
private:
|
2016-12-31 19:40:16 -08:00
|
|
|
Ref<Voxel> _voxel_types[MAX_VOXEL_TYPES];
|
|
|
|
int _atlas_size;
|
2016-05-01 13:20:27 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VOXEL_LIBRARY_H
|