2016-05-01 22:20:27 +02:00
|
|
|
#ifndef VOXEL_LIBRARY_H
|
|
|
|
#define VOXEL_LIBRARY_H
|
|
|
|
|
|
|
|
#include "voxel.h"
|
2017-08-15 02:24:52 +02:00
|
|
|
#include <resource.h>
|
2016-05-01 22:20:27 +02:00
|
|
|
|
2017-08-15 02:24:52 +02:00
|
|
|
class VoxelLibrary : public Resource {
|
|
|
|
GDCLASS(VoxelLibrary, Resource)
|
2016-05-01 22:20:27 +02:00
|
|
|
|
|
|
|
public:
|
2017-01-01 04:40:16 +01:00
|
|
|
static const unsigned int MAX_VOXEL_TYPES = 256; // Required limit because voxel types are stored in 8 bits
|
2016-05-01 22:20:27 +02:00
|
|
|
|
2017-01-01 04:40:16 +01:00
|
|
|
VoxelLibrary();
|
|
|
|
~VoxelLibrary();
|
2016-05-01 22:20:27 +02:00
|
|
|
|
2017-01-01 04:40:16 +01:00
|
|
|
int get_atlas_size() const { return _atlas_size; }
|
|
|
|
void set_atlas_size(int s);
|
2016-05-01 22:20:27 +02:00
|
|
|
|
2017-01-01 04:40:16 +01:00
|
|
|
// Use this factory rather than creating voxels from scratch
|
|
|
|
Ref<Voxel> create_voxel(int id, String name);
|
2016-05-01 22:20:27 +02:00
|
|
|
|
2017-08-15 02:24:52 +02:00
|
|
|
int get_voxel_count() const;
|
|
|
|
|
|
|
|
void load_default();
|
|
|
|
|
2017-01-01 04:40:16 +01:00
|
|
|
// Internal getters
|
2016-05-01 22:20:27 +02:00
|
|
|
|
2017-01-01 04:40:16 +01:00
|
|
|
_FORCE_INLINE_ bool has_voxel(int id) const { return _voxel_types[id].is_valid(); }
|
2017-08-13 01:19:39 +02:00
|
|
|
_FORCE_INLINE_ const Voxel &get_voxel_const(int id) const { return **_voxel_types[id]; }
|
2016-05-01 22:20:27 +02:00
|
|
|
|
2017-01-01 05:23:22 +01:00
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
|
|
|
|
2017-08-15 02:24:52 +02: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;
|
|
|
|
|
2017-01-01 05:23:22 +01:00
|
|
|
Ref<Voxel> _get_voxel_bind(int id);
|
|
|
|
|
2016-05-01 22:20:27 +02:00
|
|
|
private:
|
2017-01-01 04:40:16 +01:00
|
|
|
Ref<Voxel> _voxel_types[MAX_VOXEL_TYPES];
|
|
|
|
int _atlas_size;
|
2016-05-01 22:20:27 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // VOXEL_LIBRARY_H
|