diff --git a/scene/resources/gradient_texture.cpp b/scene/resources/gradient_texture.cpp index 2b0e455efb2..6ec9422d2de 100644 --- a/scene/resources/gradient_texture.cpp +++ b/scene/resources/gradient_texture.cpp @@ -85,7 +85,7 @@ void GradientTexture1D::_queue_update() { callable_mp(this, &GradientTexture1D::update_now).call_deferred(); } -void GradientTexture1D::_update() const { +void GradientTexture1D::_update() { update_pending = false; if (gradient.is_null()) { @@ -172,14 +172,14 @@ RID GradientTexture1D::get_rid() const { } Ref GradientTexture1D::get_image() const { - update_now(); + const_cast(this)->update_now(); if (!texture.is_valid()) { return Ref(); } return RenderingServer::get_singleton()->texture_2d_get(texture); } -void GradientTexture1D::update_now() const { +void GradientTexture1D::update_now() { if (update_pending) { _update(); } @@ -225,7 +225,7 @@ void GradientTexture2D::_queue_update() { callable_mp(this, &GradientTexture2D::update_now).call_deferred(); } -void GradientTexture2D::_update() const { +void GradientTexture2D::_update() { update_pending = false; if (gradient.is_null()) { @@ -405,14 +405,14 @@ RID GradientTexture2D::get_rid() const { } Ref GradientTexture2D::get_image() const { - update_now(); + const_cast(this)->update_now(); if (!texture.is_valid()) { return Ref(); } return RenderingServer::get_singleton()->texture_2d_get(texture); } -void GradientTexture2D::update_now() const { +void GradientTexture2D::update_now() { if (update_pending) { _update(); } diff --git a/scene/resources/gradient_texture.h b/scene/resources/gradient_texture.h index 764e5e66453..761e8d995b6 100644 --- a/scene/resources/gradient_texture.h +++ b/scene/resources/gradient_texture.h @@ -38,13 +38,13 @@ class GradientTexture1D : public Texture2D { private: Ref gradient; - mutable bool update_pending = false; + bool update_pending = false; mutable RID texture; int width = 256; bool use_hdr = false; void _queue_update(); - void _update() const; + void _update(); protected: static void _bind_methods(); @@ -64,7 +64,7 @@ class GradientTexture1D : public Texture2D { virtual bool has_alpha() const override { return true; } virtual Ref get_image() const override; - void update_now() const; + void update_now(); GradientTexture1D(); virtual ~GradientTexture1D(); @@ -102,9 +102,9 @@ class GradientTexture2D : public Texture2D { float _get_gradient_offset_at(int x, int y) const; - mutable bool update_pending = false; + bool update_pending = false; void _queue_update(); - void _update() const; + void _update(); protected: static void _bind_methods(); @@ -134,7 +134,7 @@ class GradientTexture2D : public Texture2D { virtual RID get_rid() const override; virtual bool has_alpha() const override { return true; } virtual Ref get_image() const override; - void update_now() const; + void update_now(); GradientTexture2D(); virtual ~GradientTexture2D();