godot_voxel/terrain/voxel_data_block_enter_info.cpp
Marc Gilleron 86ba74ce3a Some changes and fixes related modifiers
- VoxelLodTerrain no longer caches generated voxels by default, so
  generating on the fly is no longer exclusive to full load mode.
  Might add an option later, but not for now (VoxelTerrain is still
  unaffected and keeps caching them)
- The "Cached" state is represented with blocks having no voxel data,
  so it needs extra checks in some areas to avoid null access
- Fix generate task was not including modifiers after the base generator
- The "save_generator_output" option on streams now means such blocks are
  considered edited
- Modifying modifiers now clears cached generated blocks
  intersecting with them.
- Fix "re-generate" was erasing the internal stack of modifiers
- Added docs
2022-06-18 23:14:18 +01:00

42 lines
1.5 KiB
C++

#include "voxel_data_block_enter_info.h"
#include "../storage/voxel_buffer_gd.h"
#include "../storage/voxel_data_block.h"
namespace zylann::voxel {
int VoxelDataBlockEnterInfo::_b_get_network_peer_id() const {
return network_peer_id;
}
Ref<gd::VoxelBuffer> VoxelDataBlockEnterInfo::_b_get_voxels() const {
ERR_FAIL_COND_V(voxel_block == nullptr, Ref<gd::VoxelBuffer>());
ERR_FAIL_COND_V(!voxel_block->has_voxels(), Ref<gd::VoxelBuffer>());
std::shared_ptr<VoxelBufferInternal> vbi = voxel_block->get_voxels_shared();
Ref<gd::VoxelBuffer> vb = gd::VoxelBuffer::create_shared(vbi);
return vb;
}
Vector3i VoxelDataBlockEnterInfo::_b_get_position() const {
return block_position;
}
int VoxelDataBlockEnterInfo::_b_get_lod_index() const {
ERR_FAIL_COND_V(voxel_block == nullptr, 0);
return voxel_block->get_lod_index();
}
bool VoxelDataBlockEnterInfo::_b_are_voxels_edited() const {
ERR_FAIL_COND_V(voxel_block == nullptr, false);
return voxel_block->is_edited();
}
void VoxelDataBlockEnterInfo::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_network_peer_id"), &VoxelDataBlockEnterInfo::_b_get_network_peer_id);
ClassDB::bind_method(D_METHOD("get_voxels"), &VoxelDataBlockEnterInfo::_b_get_voxels);
ClassDB::bind_method(D_METHOD("get_position"), &VoxelDataBlockEnterInfo::_b_get_position);
ClassDB::bind_method(D_METHOD("get_lod_index"), &VoxelDataBlockEnterInfo::_b_get_lod_index);
ClassDB::bind_method(D_METHOD("are_voxels_edited"), &VoxelDataBlockEnterInfo::_b_are_voxels_edited);
}
} // namespace zylann::voxel