Merge pull request #33341 from Chaosus/vs_fix_samplers
Fix invalid casting on visual shader sampler
This commit is contained in:
commit
213ecd65cd
1 changed files with 7 additions and 9 deletions
|
@ -1064,17 +1064,14 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
|
||||||
String src_var = "n_out" + itos(from_node) + "p" + itos(from_port);
|
String src_var = "n_out" + itos(from_node) + "p" + itos(from_port);
|
||||||
|
|
||||||
if (in_type == VisualShaderNode::PORT_TYPE_SAMPLER && out_type == VisualShaderNode::PORT_TYPE_SAMPLER) {
|
if (in_type == VisualShaderNode::PORT_TYPE_SAMPLER && out_type == VisualShaderNode::PORT_TYPE_SAMPLER) {
|
||||||
VisualShaderNodeInput *input = (VisualShaderNodeInput *)graph[type].nodes[from_node].node.ptr();
|
VisualShaderNode *ptr = const_cast<VisualShaderNode *>(graph[type].nodes[from_node].node.ptr());
|
||||||
if (input) {
|
if (ptr->has_method("get_input_real_name")) {
|
||||||
inputs[i] = input->get_input_real_name();
|
inputs[i] = ptr->call("get_input_real_name");
|
||||||
} else {
|
} else if (ptr->has_method("get_uniform_name")) {
|
||||||
VisualShaderNodeUniform *uniform = (VisualShaderNodeUniform *)graph[type].nodes[from_node].node.ptr();
|
inputs[i] = ptr->call("get_uniform_name");
|
||||||
if (uniform) {
|
|
||||||
inputs[i] = uniform->get_uniform_name();
|
|
||||||
} else {
|
} else {
|
||||||
inputs[i] = "";
|
inputs[i] = "";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else if (in_type == out_type) {
|
} else if (in_type == out_type) {
|
||||||
inputs[i] = src_var;
|
inputs[i] = src_var;
|
||||||
} else if (in_type == VisualShaderNode::PORT_TYPE_SCALAR && out_type == VisualShaderNode::PORT_TYPE_VECTOR) {
|
} else if (in_type == VisualShaderNode::PORT_TYPE_SCALAR && out_type == VisualShaderNode::PORT_TYPE_VECTOR) {
|
||||||
|
@ -1796,6 +1793,7 @@ void VisualShaderNodeInput::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("set_input_name", "name"), &VisualShaderNodeInput::set_input_name);
|
ClassDB::bind_method(D_METHOD("set_input_name", "name"), &VisualShaderNodeInput::set_input_name);
|
||||||
ClassDB::bind_method(D_METHOD("get_input_name"), &VisualShaderNodeInput::get_input_name);
|
ClassDB::bind_method(D_METHOD("get_input_name"), &VisualShaderNodeInput::get_input_name);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_input_real_name"), &VisualShaderNodeInput::get_input_real_name);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::STRING, "input_name", PROPERTY_HINT_ENUM, ""), "set_input_name", "get_input_name");
|
ADD_PROPERTY(PropertyInfo(Variant::STRING, "input_name", PROPERTY_HINT_ENUM, ""), "set_input_name", "get_input_name");
|
||||||
ADD_SIGNAL(MethodInfo("input_type_changed"));
|
ADD_SIGNAL(MethodInfo("input_type_changed"));
|
||||||
|
|
Loading…
Reference in a new issue