2019-09-03 14:54:40 -07:00
|
|
|
#include "voxel_tool_lod_terrain.h"
|
|
|
|
#include "terrain/voxel_lod_terrain.h"
|
2019-09-05 11:43:25 -07:00
|
|
|
#include "terrain/voxel_map.h"
|
2019-09-03 14:54:40 -07:00
|
|
|
|
|
|
|
VoxelToolLodTerrain::VoxelToolLodTerrain(VoxelLodTerrain *terrain, Ref<VoxelMap> map) {
|
|
|
|
ERR_FAIL_COND(terrain == nullptr);
|
|
|
|
_terrain = terrain;
|
|
|
|
_map = map; // At the moment, only LOD0 is supported
|
|
|
|
// Don't destroy the terrain while a voxel tool still references it
|
|
|
|
}
|
|
|
|
|
|
|
|
bool VoxelToolLodTerrain::is_area_editable(const Rect3i &box) const {
|
|
|
|
ERR_FAIL_COND_V(_terrain == nullptr, false);
|
2019-09-06 15:24:56 -07:00
|
|
|
return _map->is_area_fully_loaded(box.padded(1));
|
2019-09-03 14:54:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
int VoxelToolLodTerrain::_get_voxel(Vector3i pos) {
|
|
|
|
ERR_FAIL_COND_V(_terrain == nullptr, 0);
|
|
|
|
return _map->get_voxel(pos, _channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
float VoxelToolLodTerrain::_get_voxel_f(Vector3i pos) {
|
|
|
|
ERR_FAIL_COND_V(_terrain == nullptr, 0);
|
|
|
|
return _map->get_voxel_f(pos, _channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VoxelToolLodTerrain::_set_voxel(Vector3i pos, int v) {
|
|
|
|
ERR_FAIL_COND(_terrain == nullptr);
|
|
|
|
_map->set_voxel(v, pos, _channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VoxelToolLodTerrain::_set_voxel_f(Vector3i pos, float v) {
|
|
|
|
ERR_FAIL_COND(_terrain == nullptr);
|
|
|
|
_map->set_voxel_f(v, pos, _channel);
|
|
|
|
}
|
|
|
|
|
|
|
|
void VoxelToolLodTerrain::_post_edit(const Rect3i &box) {
|
|
|
|
ERR_FAIL_COND(_terrain == nullptr);
|
|
|
|
_terrain->post_edit_area(box);
|
|
|
|
}
|