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"
#include <resource.h>
class VoxelLibrary : public Resource {
GDCLASS(VoxelLibrary, Resource)
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-12-31 19:40:16 -08:00
VoxelLibrary();
~VoxelLibrary();
2016-12-31 19:40:16 -08:00
int get_atlas_size() const { return _atlas_size; }
void set_atlas_size(int s);
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);
int get_voxel_count() const;
void load_default();
2016-12-31 19:40:16 -08:00
// Internal getters
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-12-31 20:23:22 -08: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;
2016-12-31 20:23:22 -08:00
Ref<Voxel> _get_voxel_bind(int id);
private:
2016-12-31 19:40:16 -08:00
Ref<Voxel> _voxel_types[MAX_VOXEL_TYPES];
int _atlas_size;
};
#endif // VOXEL_LIBRARY_H