2020-01-26 22:43:47 +00:00
|
|
|
#ifndef VOXEL_GENERATOR_NOISE_H
|
|
|
|
#define VOXEL_GENERATOR_NOISE_H
|
2019-05-05 18:27:33 +01:00
|
|
|
|
2022-02-15 21:49:20 +00:00
|
|
|
#include "../../storage/voxel_buffer_gd.h"
|
2020-12-18 21:19:02 +00:00
|
|
|
#include "../voxel_generator.h"
|
2022-04-03 20:07:17 +01:00
|
|
|
#include <modules/noise/noise.h>
|
2019-05-05 18:27:33 +01:00
|
|
|
|
2022-01-09 22:13:10 +00:00
|
|
|
namespace zylann::voxel {
|
|
|
|
|
2020-01-26 22:34:26 +00:00
|
|
|
class VoxelGeneratorNoise : public VoxelGenerator {
|
|
|
|
GDCLASS(VoxelGeneratorNoise, VoxelGenerator)
|
2020-01-10 22:46:59 +08:00
|
|
|
|
2019-05-05 18:27:33 +01:00
|
|
|
public:
|
2020-08-30 21:40:03 +01:00
|
|
|
VoxelGeneratorNoise();
|
2021-01-16 13:41:46 +00:00
|
|
|
~VoxelGeneratorNoise();
|
2020-08-30 21:40:03 +01:00
|
|
|
|
2022-02-03 00:02:10 +00:00
|
|
|
void set_channel(VoxelBufferInternal::ChannelId p_channel);
|
|
|
|
VoxelBufferInternal::ChannelId get_channel() const;
|
|
|
|
|
2020-02-15 03:12:13 +08:00
|
|
|
int get_used_channels_mask() const override;
|
|
|
|
|
2022-04-03 20:07:17 +01:00
|
|
|
void set_noise(Ref<Noise> noise);
|
|
|
|
Ref<Noise> get_noise() const;
|
2019-05-05 18:27:33 +01:00
|
|
|
|
|
|
|
void set_height_start(real_t y);
|
|
|
|
real_t get_height_start() const;
|
|
|
|
|
|
|
|
void set_height_range(real_t hrange);
|
|
|
|
real_t get_height_range() const;
|
|
|
|
|
2022-02-12 23:37:02 +00:00
|
|
|
Result generate_block(VoxelGenerator::VoxelQueryData &input) override;
|
2019-05-05 18:27:33 +01:00
|
|
|
|
2022-02-03 00:02:10 +00:00
|
|
|
private:
|
2021-03-27 00:57:08 +00:00
|
|
|
void _on_noise_changed();
|
|
|
|
|
2022-02-15 21:49:20 +00:00
|
|
|
void _b_set_channel(gd::VoxelBuffer::ChannelId p_channel);
|
|
|
|
gd::VoxelBuffer::ChannelId _b_get_channel() const;
|
2022-02-03 00:02:10 +00:00
|
|
|
|
2019-05-05 18:27:33 +01:00
|
|
|
static void _bind_methods();
|
|
|
|
|
2022-04-03 20:07:17 +01:00
|
|
|
Ref<Noise> _noise;
|
2021-01-16 13:41:46 +00:00
|
|
|
|
|
|
|
struct Parameters {
|
2022-01-09 22:13:10 +00:00
|
|
|
VoxelBufferInternal::ChannelId channel = VoxelBufferInternal::CHANNEL_SDF;
|
2022-04-03 20:07:17 +01:00
|
|
|
Ref<Noise> noise;
|
2021-01-16 13:41:46 +00:00
|
|
|
float height_start = 0;
|
|
|
|
float height_range = 300;
|
|
|
|
};
|
|
|
|
|
|
|
|
Parameters _parameters;
|
2021-02-19 01:30:22 +00:00
|
|
|
RWLock _parameters_lock;
|
2019-05-05 18:27:33 +01:00
|
|
|
};
|
|
|
|
|
2022-01-09 22:13:10 +00:00
|
|
|
} // namespace zylann::voxel
|
|
|
|
|
2020-01-26 22:43:47 +00:00
|
|
|
#endif // VOXEL_GENERATOR_NOISE_H
|