From ee4c184d648796f13e6f9091a756335ca2c538ff Mon Sep 17 00:00:00 2001 From: Relintai Date: Thu, 24 Feb 2022 19:23:25 +0100 Subject: [PATCH] Add properties for rao in the light job. --- world/jobs/terrain_2d_light_job.cpp | 51 +++++++++++++++++++++++++++-- world/jobs/terrain_2d_light_job.h | 17 ++++++++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/world/jobs/terrain_2d_light_job.cpp b/world/jobs/terrain_2d_light_job.cpp index 708ce40..2c516d0 100644 --- a/world/jobs/terrain_2d_light_job.cpp +++ b/world/jobs/terrain_2d_light_job.cpp @@ -24,12 +24,40 @@ SOFTWARE. #include "../../defines.h" -#include "../../library/terrain_2d_surface.h" #include "../../library/terrain_2d_library.h" +#include "../../library/terrain_2d_surface.h" #include "../../meshers/terrain_2d_mesher.h" #include "../default/terrain_2d_chunk_default.h" +int Terrain2DLightJob::get_rao_octaves() { + return _rao_octaves; +} +void Terrain2DLightJob::set_rao_octaves(const int val) { + _rao_octaves = val; +} + +int Terrain2DLightJob::get_rao_period() { + return _rao_period; +} +void Terrain2DLightJob::set_rao_period(const int val) { + _rao_period = val; +} + +float Terrain2DLightJob::get_rao_persistence() { + return _rao_persistence; +} +void Terrain2DLightJob::set_rao_persistence(const float val) { + _rao_persistence = val; +} + +float Terrain2DLightJob::get_rao_scale_factor() { + return _rao_scale_factor; +} +void Terrain2DLightJob::set_rao_scale_factor(const float val) { + _rao_scale_factor = val; +} + void Terrain2DLightJob::phase_light() { Ref chunk = _chunk; @@ -54,7 +82,7 @@ void Terrain2DLightJob::phase_light() { } if (gr && should_do()) { - generate_random_ao(chunk->get_voxel_world()->get_current_seed()); + generate_random_ao(chunk->get_voxel_world()->get_current_seed(), _rao_octaves, _rao_period, _rao_persistence, _rao_scale_factor); if (should_return()) return; @@ -84,10 +112,29 @@ void Terrain2DLightJob::_execute_phase() { } Terrain2DLightJob::Terrain2DLightJob() { + _rao_octaves = 4; + _rao_period = 30; + _rao_persistence = 0.3; + _rao_scale_factor = 0.6; } Terrain2DLightJob::~Terrain2DLightJob() { } void Terrain2DLightJob::_bind_methods() { + ClassDB::bind_method(D_METHOD("get_rao_octaves"), &Terrain2DLightJob::get_rao_octaves); + ClassDB::bind_method(D_METHOD("set_rao_octaves", "value"), &Terrain2DLightJob::set_rao_octaves); + ADD_PROPERTY(PropertyInfo(Variant::INT, "rao_octaves"), "set_rao_octaves", "get_rao_octaves"); + + ClassDB::bind_method(D_METHOD("get_rao_period"), &Terrain2DLightJob::get_rao_period); + ClassDB::bind_method(D_METHOD("set_rao_period", "value"), &Terrain2DLightJob::set_rao_period); + ADD_PROPERTY(PropertyInfo(Variant::INT, "rao_period"), "set_rao_period", "get_rao_period"); + + ClassDB::bind_method(D_METHOD("get_rao_persistence"), &Terrain2DLightJob::get_rao_persistence); + ClassDB::bind_method(D_METHOD("set_rao_persistence", "value"), &Terrain2DLightJob::set_rao_persistence); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "rao_persistence"), "set_rao_persistence", "get_rao_persistence"); + + ClassDB::bind_method(D_METHOD("get_rao_scale_factor"), &Terrain2DLightJob::get_rao_scale_factor); + ClassDB::bind_method(D_METHOD("set_rao_scale_factor", "value"), &Terrain2DLightJob::set_rao_scale_factor); + ADD_PROPERTY(PropertyInfo(Variant::REAL, "rao_scale_factor"), "set_rao_scale_factor", "get_rao_scale_factor"); } diff --git a/world/jobs/terrain_2d_light_job.h b/world/jobs/terrain_2d_light_job.h index 3963292..71bab99 100644 --- a/world/jobs/terrain_2d_light_job.h +++ b/world/jobs/terrain_2d_light_job.h @@ -31,6 +31,18 @@ class Terrain2DLightJob : public Terrain2DJob { GDCLASS(Terrain2DLightJob, Terrain2DJob); public: + int get_rao_octaves(); + void set_rao_octaves(const int val); + + int get_rao_period(); + void set_rao_period(const int val); + + float get_rao_persistence(); + void set_rao_persistence(const float val); + + float get_rao_scale_factor(); + void set_rao_scale_factor(const float val); + void phase_light(); void _execute_phase(); @@ -40,6 +52,11 @@ public: protected: static void _bind_methods(); + + int _rao_octaves; + int _rao_period; + float _rao_persistence; + float _rao_scale_factor; }; #endif