From 308a6f4f99a5204682a2612d097e5c066f88196f Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Tue, 5 Sep 2017 20:40:50 -0300 Subject: hide next pass for material types that make it pointless, closes #10686 --- scene/resources/material.cpp | 11 +++++++++++ scene/resources/material.h | 6 ++++++ 2 files changed, 17 insertions(+) (limited to 'scene/resources') diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 3d6a10ffc7..a187692bcb 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -65,6 +65,12 @@ RID Material::get_rid() const { return material; } +void Material::_validate_property(PropertyInfo &property) const { + + if (!_can_do_next_pass() && property.name=="next_pass") { + property.usage=0; + } +} void Material::_bind_methods() { @@ -204,6 +210,11 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id Resource::get_argument_options(p_function, p_idx, r_options); } +bool ShaderMaterial::_can_do_next_pass() const { + + return shader.is_valid() && shader->get_mode()==Shader::MODE_SPATIAL; +} + ShaderMaterial::ShaderMaterial() { } diff --git a/scene/resources/material.h b/scene/resources/material.h index 4e77ab1ed6..fdb11982a8 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -53,6 +53,9 @@ class Material : public Resource { protected: _FORCE_INLINE_ RID _get_material() const { return material; } static void _bind_methods(); + virtual bool _can_do_next_pass() const { return false; } + + void _validate_property(PropertyInfo &property) const; public: enum { @@ -84,6 +87,8 @@ protected: void get_argument_options(const StringName &p_function, int p_idx, List *r_options) const; + virtual bool _can_do_next_pass() const; + public: void set_shader(const Ref &p_shader); Ref get_shader() const; @@ -394,6 +399,7 @@ private: protected: static void _bind_methods(); void _validate_property(PropertyInfo &property) const; + virtual bool _can_do_next_pass() const { return true; } public: void set_albedo(const Color &p_albedo); -- cgit v1.2.3