[8125274] | 1 | #include "voxsrc.h"
|
---|
| 2 |
|
---|
[c61312b] | 3 | #include <mars_log.h>
|
---|
| 4 |
|
---|
| 5 | #include <VoxelBuffer.hpp>
|
---|
| 6 |
|
---|
[8125274] | 7 | namespace godot {
|
---|
[c61312b] | 8 | GeoWorldVoxelGeneratorSource::GeoWorldVoxelGeneratorSource() : fileSource(NULL) {}
|
---|
| 9 | GeoWorldVoxelGeneratorSource::~GeoWorldVoxelGeneratorSource() {
|
---|
| 10 | delete this->fileSource;
|
---|
| 11 | }
|
---|
| 12 |
|
---|
| 13 | void GeoWorldVoxelGeneratorSource::setInputFile(String inputFile) {
|
---|
| 14 | delete this->fileSource;
|
---|
| 15 | this->inputFile = inputFile;
|
---|
| 16 |
|
---|
| 17 | Godot::print("Set input file = " + inputFile);
|
---|
| 18 | if (inputFile.empty())
|
---|
| 19 | this->fileSource = NULL;
|
---|
| 20 | else
|
---|
| 21 | this->fileSource = geoworld::FileSource::open(inputFile.utf8().get_data());
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | String GeoWorldVoxelGeneratorSource::getInputFile() { return inputFile; }
|
---|
| 25 |
|
---|
| 26 | void GeoWorldVoxelGeneratorSource::_register_methods() {
|
---|
| 27 | register_property<GeoWorldVoxelGeneratorSource, String>("InputFile", &GeoWorldVoxelGeneratorSource::setInputFile, &GeoWorldVoxelGeneratorSource::getInputFile, "default.pgw");
|
---|
[8125274] | 28 |
|
---|
[c61312b] | 29 | register_method("_generate_block", &GeoWorldVoxelGeneratorSource::_generate_block);
|
---|
[8125274] | 30 | }
|
---|
| 31 |
|
---|
[c61312b] | 32 | void GeoWorldVoxelGeneratorSource::_init() {}
|
---|
| 33 |
|
---|
| 34 | void GeoWorldVoxelGeneratorSource::_generate_block(Ref<VoxelBuffer> out_buffer, const Vector3 origin_in_voxels, const int64_t lod) {
|
---|
| 35 | // TODO: Synchronize
|
---|
| 36 | Godot::print("(BEGIN) origin = <" + origin_in_voxels + ">, LOD = " + lod);
|
---|
| 37 |
|
---|
| 38 | const int64_t
|
---|
| 39 | width = out_buffer->get_size_x(),
|
---|
| 40 | depth = out_buffer->get_size_z(),
|
---|
| 41 | height = out_buffer->get_size_y();
|
---|
| 42 |
|
---|
| 43 | for (int64_t k = 0; k < depth; ++k)
|
---|
| 44 | for (int64_t j = 0; j < height; ++j)
|
---|
| 45 | for (int64_t i = 0; i < width; ++i)
|
---|
| 46 | out_buffer->set_voxel(
|
---|
| 47 | 0,
|
---|
| 48 | origin_in_voxels.x + i,
|
---|
| 49 | origin_in_voxels.y + j,
|
---|
| 50 | origin_in_voxels.z + k
|
---|
| 51 | );
|
---|
| 52 |
|
---|
| 53 | Godot::print("(END) origin = <" + origin_in_voxels + ">, LOD = " + lod);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | int64_t GeoWorldVoxelGeneratorSource::_get_used_channels_mask() {
|
---|
| 57 | Godot::print("Retrieve used channels mask");
|
---|
| 58 | return 1 << VoxelBuffer::CHANNEL_SDF;
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | }
|
---|