summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/font.cpp1
-rw-r--r--scene/resources/material.cpp27
-rw-r--r--scene/resources/material.h2
-rw-r--r--scene/resources/shader.cpp11
-rw-r--r--scene/resources/shader.h2
-rw-r--r--scene/resources/texture.cpp11
-rw-r--r--scene/resources/texture.h3
-rw-r--r--scene/resources/visual_shader.cpp4
-rw-r--r--scene/resources/visual_shader.h2
9 files changed, 55 insertions, 8 deletions
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 50bf8f38f7..b78b3a6ffb 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -178,6 +178,7 @@ PoolVector<int> BitmapFont::_get_kernings() const {
void BitmapFont::_set_textures(const Vector<Variant> &p_textures) {
+ textures.clear();
for (int i = 0; i < p_textures.size(); i++) {
Ref<Texture> tex = p_textures[i];
ERR_CONTINUE(!tex.is_valid());
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/shader.cpp b/scene/resources/shader.cpp
index 1bfc41bd92..66bf3b4991 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -126,6 +126,11 @@ void Shader::get_default_texture_param_list(List<StringName> *r_textures) const
r_textures->push_back(E->key());
}
}
+
+bool Shader::is_text_shader() const {
+ return true;
+}
+
bool Shader::has_param(const StringName &p_param) const {
return params_cache.has(p_param);
@@ -235,8 +240,10 @@ Error ResourceFormatSaverShader::save(const String &p_path, const RES &p_resourc
void ResourceFormatSaverShader::get_recognized_extensions(const RES &p_resource, List<String> *p_extensions) const {
- if (Object::cast_to<Shader>(*p_resource)) {
- p_extensions->push_back("shader");
+ if (const Shader *shader = Object::cast_to<Shader>(*p_resource)) {
+ if (shader->is_text_shader()) {
+ p_extensions->push_back("shader");
+ }
}
}
bool ResourceFormatSaverShader::recognize(const RES &p_resource) const {
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 6c91205c0c..c2c205237f 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -79,6 +79,8 @@ public:
Ref<Texture> get_default_texture_param(const StringName &p_param) const;
void get_default_texture_param_list(List<StringName> *r_textures) const;
+ virtual bool is_text_shader() const;
+
_FORCE_INLINE_ StringName remap_param(const StringName &p_param) const {
if (params_cache_dirty)
get_param_list(NULL);
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>
*/
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 6bfb6ec5bf..f12ea8f2bb 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -414,6 +414,10 @@ Shader::Mode VisualShader::get_mode() const {
return shader_mode;
}
+bool VisualShader::is_text_shader() const {
+ return false;
+}
+
String VisualShader::generate_preview_shader(Type p_type, int p_node, int p_port, Vector<DefaultTextureParam> &default_tex_params) const {
Ref<VisualShaderNode> node = get_node(p_type, p_node);
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index 70d2425304..2867daac3a 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -141,6 +141,8 @@ public:
void set_mode(Mode p_mode);
virtual Mode get_mode() const;
+ virtual bool is_text_shader() const;
+
void set_graph_offset(const Vector2 &p_offset);
Vector2 get_graph_offset() const;