godot_voxel/voxel_terrain.h

57 lines
1.4 KiB
C
Raw Normal View History

#ifndef VOXEL_TERRAIN_H
#define VOXEL_TERRAIN_H
#include <scene/main/node.h>
#include "voxel_map.h"
#include "voxel_mesher.h"
#include "voxel_provider.h"
// Infinite static terrain made of voxels.
// It is loaded around VoxelTerrainStreamers.
class VoxelTerrain : public Node /*, public IVoxelMapObserver*/ {
2017-01-01 04:40:16 +01:00
OBJ_TYPE(VoxelTerrain, Node)
public:
2017-01-01 04:40:16 +01:00
VoxelTerrain();
void set_provider(Ref<VoxelProvider> provider);
Ref<VoxelProvider> get_provider();
void force_load_blocks(Vector3i center, Vector3i extents);
2017-01-01 04:40:16 +01:00
int get_block_update_count();
2017-01-01 04:40:16 +01:00
Ref<VoxelMesher> get_mesher() { return _mesher; }
protected:
2017-01-01 04:40:16 +01:00
void _notification(int p_what);
void _process();
2017-01-01 04:40:16 +01:00
void update_blocks();
void update_block_mesh(Vector3i block_pos);
2017-01-01 04:40:16 +01:00
// Observer events
//void block_removed(VoxelBlock & block);
2017-01-01 04:40:16 +01:00
static void _bind_methods();
2017-01-01 04:40:16 +01:00
// Convenience
Vector3 _voxel_to_block_binding(Vector3 pos) { return Vector3i(VoxelMap::voxel_to_block(pos)).to_vec3(); }
Vector3 _block_to_voxel_binding(Vector3 pos) { return Vector3i(VoxelMap::block_to_voxel(pos)).to_vec3(); }
void _force_load_blocks_binding(Vector3 center, Vector3 extents) { force_load_blocks(center, extents); }
2017-01-02 02:19:02 +01:00
private:
// Parameters
int _min_y; // In blocks, not voxels
int _max_y;
// Voxel storage
Ref<VoxelMap> _map;
Vector<Vector3i> _block_update_queue;
Ref<VoxelMesher> _mesher;
Ref<VoxelProvider> _provider;
};
#endif // VOXEL_TERRAIN_H