-Treat scalar conversions when calling functions as error, closes #24261
-Make shader editor display errors if exist when just opening it -Make ShaderMaterial not lose parameters if opened in error.
This commit is contained in:
parent
07fbc34195
commit
fd68bb2596
3 changed files with 16 additions and 6 deletions
|
@ -53,6 +53,7 @@ void ShaderTextEditor::set_edited_shader(const Ref<Shader> &p_shader) {
|
|||
|
||||
get_text_edit()->set_text(p_shader->get_code());
|
||||
|
||||
_validate_script();
|
||||
_line_col_changed();
|
||||
}
|
||||
|
||||
|
|
|
@ -113,6 +113,9 @@ bool ShaderMaterial::_set(const StringName &p_name, const Variant &p_value) {
|
|||
if (n.find("param/") == 0) { //backwards compatibility
|
||||
pr = n.substr(6, n.length());
|
||||
}
|
||||
if (n.find("shader_param/") == 0) { //backwards compatibility
|
||||
pr = n.replace_first("shader_param/", "");
|
||||
}
|
||||
}
|
||||
if (pr) {
|
||||
VisualServer::get_singleton()->material_set_param(_get_material(), pr, p_value);
|
||||
|
@ -128,6 +131,16 @@ bool ShaderMaterial::_get(const StringName &p_name, Variant &r_ret) const {
|
|||
if (shader.is_valid()) {
|
||||
|
||||
StringName pr = shader->remap_param(p_name);
|
||||
if (!pr) {
|
||||
String n = p_name;
|
||||
if (n.find("param/") == 0) { //backwards compatibility
|
||||
pr = n.substr(6, n.length());
|
||||
}
|
||||
if (n.find("shader_param/") == 0) { //backwards compatibility
|
||||
pr = n.replace_first("shader_param/", "");
|
||||
}
|
||||
}
|
||||
|
||||
if (pr) {
|
||||
r_ret = VisualServer::get_singleton()->material_get_param(_get_material(), pr);
|
||||
return true;
|
||||
|
|
|
@ -2074,9 +2074,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, OperatorNode *p
|
|||
bool fail = false;
|
||||
for (int i = 0; i < argcount; i++) {
|
||||
|
||||
if (get_scalar_type(args[i]) == args[i] && p_func->arguments[i + 1]->type == Node::TYPE_CONSTANT && convert_constant(static_cast<ConstantNode *>(p_func->arguments[i + 1]), builtin_func_defs[idx].args[i])) {
|
||||
//all good
|
||||
} else if (args[i] != builtin_func_defs[idx].args[i]) {
|
||||
if (args[i] != builtin_func_defs[idx].args[i]) {
|
||||
fail = true;
|
||||
break;
|
||||
}
|
||||
|
@ -2186,9 +2184,7 @@ bool ShaderLanguage::_validate_function_call(BlockNode *p_block, OperatorNode *p
|
|||
|
||||
for (int j = 0; j < args.size(); j++) {
|
||||
|
||||
if (get_scalar_type(args[j]) == args[j] && p_func->arguments[j + 1]->type == Node::TYPE_CONSTANT && convert_constant(static_cast<ConstantNode *>(p_func->arguments[j + 1]), pfunc->arguments[j].type)) {
|
||||
//all good
|
||||
} else if (args[j] != pfunc->arguments[j].type) {
|
||||
if (args[j] != pfunc->arguments[j].type) {
|
||||
fail = true;
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue