diff options
Diffstat (limited to 'scene/resources')
-rw-r--r-- | scene/resources/material.cpp | 27 | ||||
-rw-r--r-- | scene/resources/material.h | 2 | ||||
-rw-r--r-- | scene/resources/texture.cpp | 11 | ||||
-rw-r--r-- | scene/resources/texture.h | 3 |
4 files changed, 37 insertions, 6 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 4727526b68..2cf802a2da 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -145,6 +145,31 @@ void ShaderMaterial::_get_property_list(List<PropertyInfo> *p_list) const { } } +bool ShaderMaterial::property_can_revert(const String &p_name) { + if (shader.is_valid()) { + + StringName pr = shader->remap_param(p_name); + if (pr) { + Variant default_value = VisualServer::get_singleton()->material_get_param_default(_get_material(), pr); + Variant current_value; + _get(p_name, current_value); + return default_value.get_type() != Variant::NIL && default_value != current_value; + } + } + return false; +} + +Variant ShaderMaterial::property_get_revert(const String &p_name) { + Variant r_ret; + if (shader.is_valid()) { + StringName pr = shader->remap_param(p_name); + if (pr) { + r_ret = VisualServer::get_singleton()->material_get_param_default(_get_material(), pr); + } + } + return r_ret; +} + void ShaderMaterial::set_shader(const Ref<Shader> &p_shader) { if (shader.is_valid()) { @@ -190,6 +215,8 @@ void ShaderMaterial::_bind_methods() { ClassDB::bind_method(D_METHOD("set_shader_param", "param", "value"), &ShaderMaterial::set_shader_param); ClassDB::bind_method(D_METHOD("get_shader_param", "param"), &ShaderMaterial::get_shader_param); ClassDB::bind_method(D_METHOD("_shader_changed"), &ShaderMaterial::_shader_changed); + ClassDB::bind_method(D_METHOD("property_can_revert", "name"), &ShaderMaterial::property_can_revert); + ClassDB::bind_method(D_METHOD("property_get_revert", "name"), &ShaderMaterial::property_get_revert); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "shader", PROPERTY_HINT_RESOURCE_TYPE, "Shader"), "set_shader", "get_shader"); } diff --git a/scene/resources/material.h b/scene/resources/material.h index 078649e7b0..4a2a813341 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -85,6 +85,8 @@ protected: bool _set(const StringName &p_name, const Variant &p_value); bool _get(const StringName &p_name, Variant &r_ret) const; void _get_property_list(List<PropertyInfo> *p_list) const; + bool property_can_revert(const String &p_name); + Variant property_get_revert(const String &p_name); static void _bind_methods(); diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 9875c7b130..16b4ed31df 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -30,11 +30,11 @@ #include "texture.h" -#include "bit_mask.h" #include "core/core_string_names.h" #include "core/io/image_loader.h" #include "core/method_bind_ext.gen.inc" #include "core/os/os.h" +#include "scene/resources/bit_mask.h" Size2 Texture::get_size() const { @@ -1633,16 +1633,17 @@ void GradientTexture::_queue_update() { if (update_pending) return; + update_pending = true; call_deferred("_update"); } void GradientTexture::_update() { + update_pending = false; + if (gradient.is_null()) return; - update_pending = false; - PoolVector<uint8_t> data; data.resize(width * 4); { @@ -1945,8 +1946,8 @@ void AnimatedTexture::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::REAL, "fps", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_fps", "get_fps"); for (int i = 0; i < MAX_FRAMES; i++) { - ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "frame_" + itos(i) + "/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_frame_texture", "get_frame_texture", i); - ADD_PROPERTYI(PropertyInfo(Variant::REAL, "frame_" + itos(i) + "/delay_sec", PROPERTY_HINT_RANGE, "0.0,16.0,0.01"), "set_frame_delay", "get_frame_delay", i); + ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "frame_" + itos(i) + "/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_frame_texture", "get_frame_texture", i); + ADD_PROPERTYI(PropertyInfo(Variant::REAL, "frame_" + itos(i) + "/delay_sec", PROPERTY_HINT_RANGE, "0.0,16.0,0.01", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "set_frame_delay", "get_frame_delay", i); } } diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 4865f7b507..cb759c63da 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -37,9 +37,10 @@ #include "core/os/rw_lock.h" #include "core/os/thread_safe.h" #include "core/resource.h" -#include "curve.h" #include "scene/resources/color_ramp.h" +#include "scene/resources/curve.h" #include "servers/visual_server.h" + /** @author Juan Linietsky <reduzio@gmail.com> */ |