#include "voxsrc.h" #include #include namespace godot { GeoWorldVoxelGeneratorSource::GeoWorldVoxelGeneratorSource() : fileSource(NULL) {} GeoWorldVoxelGeneratorSource::~GeoWorldVoxelGeneratorSource() { delete this->fileSource; } void GeoWorldVoxelGeneratorSource::setInputFile(String inputFile) { delete this->fileSource; this->inputFile = inputFile; Godot::print("Set input file = " + inputFile); if (inputFile.empty()) this->fileSource = NULL; else this->fileSource = geoworld::FileSource::open(inputFile.utf8().get_data()); } String GeoWorldVoxelGeneratorSource::getInputFile() { return inputFile; } void GeoWorldVoxelGeneratorSource::_register_methods() { register_property("InputFile", &GeoWorldVoxelGeneratorSource::setInputFile, &GeoWorldVoxelGeneratorSource::getInputFile, "default.pgw"); register_method("_generate_block", &GeoWorldVoxelGeneratorSource::_generate_block); } void GeoWorldVoxelGeneratorSource::_init() {} void GeoWorldVoxelGeneratorSource::_generate_block(Ref out_buffer, const Vector3 origin_in_voxels, const int64_t lod) { // TODO: Synchronize Godot::print("(BEGIN) origin = <" + origin_in_voxels + ">, LOD = " + lod); const int64_t width = out_buffer->get_size_x(), depth = out_buffer->get_size_z(), height = out_buffer->get_size_y(); for (int64_t k = 0; k < depth; ++k) for (int64_t j = 0; j < height; ++j) for (int64_t i = 0; i < width; ++i) out_buffer->set_voxel( 0, origin_in_voxels.x + i, origin_in_voxels.y + j, origin_in_voxels.z + k ); Godot::print("(END) origin = <" + origin_in_voxels + ">, LOD = " + lod); } int64_t GeoWorldVoxelGeneratorSource::_get_used_channels_mask() { Godot::print("Retrieve used channels mask"); return 1 << VoxelBuffer::CHANNEL_SDF; } }