godot_voxel/voxel_library.h

46 lines
1.1 KiB
C
Raw Normal View History

#ifndef VOXEL_LIBRARY_H
#define VOXEL_LIBRARY_H
#include "voxel.h"
2018-09-19 21:25:04 +02:00
#include <core/resource.h>
class VoxelLibrary : public Resource {
GDCLASS(VoxelLibrary, Resource)
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
2017-01-01 04:40:16 +01:00
VoxelLibrary();
~VoxelLibrary();
2017-01-01 04:40:16 +01:00
int get_atlas_size() const { return _atlas_size; }
void set_atlas_size(int s);
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);
int get_voxel_count() const;
void load_default();
2017-01-01 04:40:16 +01:00
// Internal getters
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]; }
2017-01-01 05:23:22 +01:00
protected:
static void _bind_methods();
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);
private:
2017-01-01 04:40:16 +01:00
Ref<Voxel> _voxel_types[MAX_VOXEL_TYPES];
int _atlas_size;
};
#endif // VOXEL_LIBRARY_H