diff options
Diffstat (limited to 'modules/opensimplex/noise_texture.cpp')
-rw-r--r-- | modules/opensimplex/noise_texture.cpp | 35 |
1 files changed, 16 insertions, 19 deletions
diff --git a/modules/opensimplex/noise_texture.cpp b/modules/opensimplex/noise_texture.cpp index 16cd04b044..1181e69cd3 100644 --- a/modules/opensimplex/noise_texture.cpp +++ b/modules/opensimplex/noise_texture.cpp @@ -59,7 +59,6 @@ NoiseTexture::~NoiseTexture() { } void NoiseTexture::_bind_methods() { - ClassDB::bind_method(D_METHOD("set_width", "width"), &NoiseTexture::set_width); ClassDB::bind_method(D_METHOD("set_height", "height"), &NoiseTexture::set_height); @@ -88,7 +87,6 @@ void NoiseTexture::_bind_methods() { } void NoiseTexture::_validate_property(PropertyInfo &property) const { - if (property.name == "bump_strength") { if (!as_normalmap) { property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL; @@ -110,7 +108,6 @@ void NoiseTexture::_set_texture_data(const Ref<Image> &p_image) { } void NoiseTexture::_thread_done(const Ref<Image> &p_image) { - _set_texture_data(p_image); Thread::wait_to_finish(noise_thread); memdelete(noise_thread); @@ -127,16 +124,15 @@ void NoiseTexture::_thread_function(void *p_ud) { } void NoiseTexture::_queue_update() { - - if (update_queued) + if (update_queued) { return; + } update_queued = true; call_deferred("_update_texture"); } Ref<Image> NoiseTexture::_generate_texture() { - // Prevent memdelete due to unref() on other thread. Ref<OpenSimplexNoise> ref_noise = noise; @@ -169,7 +165,6 @@ void NoiseTexture::_update_texture() { use_thread = false; #endif if (use_thread) { - if (!noise_thread) { noise_thread = Thread::create(_thread_function, this); regen_queued = false; @@ -185,8 +180,9 @@ void NoiseTexture::_update_texture() { } void NoiseTexture::set_noise(Ref<OpenSimplexNoise> p_noise) { - if (p_noise == noise) + if (p_noise == noise) { return; + } if (noise.is_valid()) { noise->disconnect(CoreStringNames::get_singleton()->changed, callable_mp(this, &NoiseTexture::_queue_update)); } @@ -202,22 +198,25 @@ Ref<OpenSimplexNoise> NoiseTexture::get_noise() { } void NoiseTexture::set_width(int p_width) { - if (p_width == size.x) + if (p_width == size.x) { return; + } size.x = p_width; _queue_update(); } void NoiseTexture::set_height(int p_height) { - if (p_height == size.y) + if (p_height == size.y) { return; + } size.y = p_height; _queue_update(); } void NoiseTexture::set_seamless(bool p_seamless) { - if (p_seamless == seamless) + if (p_seamless == seamless) { return; + } seamless = p_seamless; _queue_update(); } @@ -227,8 +226,9 @@ bool NoiseTexture::get_seamless() { } void NoiseTexture::set_as_normalmap(bool p_as_normalmap) { - if (p_as_normalmap == as_normalmap) + if (p_as_normalmap == as_normalmap) { return; + } as_normalmap = p_as_normalmap; _queue_update(); _change_notify(); @@ -239,26 +239,24 @@ bool NoiseTexture::is_normalmap() { } void NoiseTexture::set_bump_strength(float p_bump_strength) { - - if (p_bump_strength == bump_strength) + if (p_bump_strength == bump_strength) { return; + } bump_strength = p_bump_strength; - if (as_normalmap) + if (as_normalmap) { _queue_update(); + } } float NoiseTexture::get_bump_strength() { - return bump_strength; } int NoiseTexture::get_width() const { - return size.x; } int NoiseTexture::get_height() const { - return size.y; } @@ -271,6 +269,5 @@ RID NoiseTexture::get_rid() const { } Ref<Image> NoiseTexture::get_data() const { - return data; } |