Renames Type to OpType in VisualShaderNodeMultiplyAdd

To prevent possible conflicts with C# and other languages.
This commit is contained in:
Yuri Roubinsky 2020-09-15 11:06:18 +03:00
parent 8818a93a3c
commit f137f14e1c
4 changed files with 32 additions and 32 deletions

View file

@ -11,19 +11,19 @@
<methods> <methods>
</methods> </methods>
<members> <members>
<member name="type" type="int" setter="set_type" getter="get_type" enum="VisualShaderNodeMultiplyAdd.Type" default="0"> <member name="op_type" type="int" setter="set_op_type" getter="get_op_type" enum="VisualShaderNodeMultiplyAdd.OpType" default="0">
A type of operands and returned value. A type of operands and returned value.
</member> </member>
</members> </members>
<constants> <constants>
<constant name="TYPE_SCALAR" value="0" enum="Type"> <constant name="OP_TYPE_SCALAR" value="0" enum="OpType">
A scalar type. A scalar type.
</constant> </constant>
<constant name="TYPE_VECTOR" value="1" enum="Type"> <constant name="OP_TYPE_VECTOR" value="1" enum="OpType">
A vector type. A vector type.
</constant> </constant>
<constant name="TYPE_MAX" value="2" enum="Type"> <constant name="OP_TYPE_MAX" value="2" enum="OpType">
Represents the size of the [enum Type] enum. Represents the size of the [enum OpType] enum.
</constant> </constant>
</constants> </constants>
</class> </class>

View file

@ -1639,7 +1639,7 @@ VisualShaderNode *VisualShaderEditor::_add_node(int p_idx, int p_op_idx) {
VisualShaderNodeMultiplyAdd *fmaFunc = Object::cast_to<VisualShaderNodeMultiplyAdd>(vsn); VisualShaderNodeMultiplyAdd *fmaFunc = Object::cast_to<VisualShaderNodeMultiplyAdd>(vsn);
if (fmaFunc) { if (fmaFunc) {
fmaFunc->set_type((VisualShaderNodeMultiplyAdd::Type)p_op_idx); fmaFunc->set_op_type((VisualShaderNodeMultiplyAdd::OpType)p_op_idx);
} }
} }
@ -3084,7 +3084,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("Max", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the greater of two values."), VisualShaderNodeFloatOp::OP_MAX, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("Max", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the greater of two values."), VisualShaderNodeFloatOp::OP_MAX, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Min", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the lesser of two values."), VisualShaderNodeFloatOp::OP_MIN, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("Min", "Scalar", "Functions", "VisualShaderNodeFloatOp", TTR("Returns the lesser of two values."), VisualShaderNodeFloatOp::OP_MIN, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Mix", "Scalar", "Functions", "VisualShaderNodeScalarInterp", TTR("Linear interpolation between two scalars."), -1, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("Mix", "Scalar", "Functions", "VisualShaderNodeScalarInterp", TTR("Linear interpolation between two scalars."), -1, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("MultiplyAdd", "Scalar", "Functions", "VisualShaderNodeMultiplyAdd", TTR("Performs a fused multiply-add operation (a * b + c) on scalars."), VisualShaderNodeMultiplyAdd::TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("MultiplyAdd", "Scalar", "Functions", "VisualShaderNodeMultiplyAdd", TTR("Performs a fused multiply-add operation (a * b + c) on scalars."), VisualShaderNodeMultiplyAdd::OP_TYPE_SCALAR, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Negate", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeFloatFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("Negate", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeFloatFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_SCALAR));
add_options.push_back(AddOption("Negate", "Scalar", "Functions", "VisualShaderNodeIntFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeIntFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_SCALAR_INT)); add_options.push_back(AddOption("Negate", "Scalar", "Functions", "VisualShaderNodeIntFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeIntFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_SCALAR_INT));
add_options.push_back(AddOption("OneMinus", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("1.0 - scalar"), VisualShaderNodeFloatFunc::FUNC_ONEMINUS, VisualShaderNode::PORT_TYPE_SCALAR)); add_options.push_back(AddOption("OneMinus", "Scalar", "Functions", "VisualShaderNodeFloatFunc", TTR("1.0 - scalar"), VisualShaderNodeFloatFunc::FUNC_ONEMINUS, VisualShaderNode::PORT_TYPE_SCALAR));
@ -3190,7 +3190,7 @@ VisualShaderEditor::VisualShaderEditor() {
add_options.push_back(AddOption("Min", "Vector", "Functions", "VisualShaderNodeVectorOp", TTR("Returns the lesser of two values."), VisualShaderNodeVectorOp::OP_MIN, VisualShaderNode::PORT_TYPE_VECTOR)); add_options.push_back(AddOption("Min", "Vector", "Functions", "VisualShaderNodeVectorOp", TTR("Returns the lesser of two values."), VisualShaderNodeVectorOp::OP_MIN, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Mix", "Vector", "Functions", "VisualShaderNodeVectorInterp", TTR("Linear interpolation between two vectors."), -1, VisualShaderNode::PORT_TYPE_VECTOR)); add_options.push_back(AddOption("Mix", "Vector", "Functions", "VisualShaderNodeVectorInterp", TTR("Linear interpolation between two vectors."), -1, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("MixS", "Vector", "Functions", "VisualShaderNodeVectorScalarMix", TTR("Linear interpolation between two vectors using scalar."), -1, VisualShaderNode::PORT_TYPE_VECTOR)); add_options.push_back(AddOption("MixS", "Vector", "Functions", "VisualShaderNodeVectorScalarMix", TTR("Linear interpolation between two vectors using scalar."), -1, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("MultiplyAdd", "Vector", "Functions", "VisualShaderNodeMultiplyAdd", TTR("Performs a fused multiply-add operation (a * b + c) on vectors."), VisualShaderNodeMultiplyAdd::TYPE_VECTOR, VisualShaderNode::PORT_TYPE_VECTOR)); add_options.push_back(AddOption("MultiplyAdd", "Vector", "Functions", "VisualShaderNodeMultiplyAdd", TTR("Performs a fused multiply-add operation (a * b + c) on vectors."), VisualShaderNodeMultiplyAdd::OP_TYPE_VECTOR, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Negate", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeVectorFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_VECTOR)); add_options.push_back(AddOption("Negate", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Returns the opposite value of the parameter."), VisualShaderNodeVectorFunc::FUNC_NEGATE, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("Normalize", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Calculates the normalize product of vector."), VisualShaderNodeVectorFunc::FUNC_NORMALIZE, VisualShaderNode::PORT_TYPE_VECTOR)); add_options.push_back(AddOption("Normalize", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("Calculates the normalize product of vector."), VisualShaderNodeVectorFunc::FUNC_NORMALIZE, VisualShaderNode::PORT_TYPE_VECTOR));
add_options.push_back(AddOption("OneMinus", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("1.0 - vector"), VisualShaderNodeVectorFunc::FUNC_ONEMINUS, VisualShaderNode::PORT_TYPE_VECTOR)); add_options.push_back(AddOption("OneMinus", "Vector", "Functions", "VisualShaderNodeVectorFunc", TTR("1.0 - vector"), VisualShaderNodeVectorFunc::FUNC_ONEMINUS, VisualShaderNode::PORT_TYPE_VECTOR));

View file

@ -5169,7 +5169,7 @@ int VisualShaderNodeMultiplyAdd::get_input_port_count() const {
} }
VisualShaderNodeMultiplyAdd::PortType VisualShaderNodeMultiplyAdd::get_input_port_type(int p_port) const { VisualShaderNodeMultiplyAdd::PortType VisualShaderNodeMultiplyAdd::get_input_port_type(int p_port) const {
if (type == TYPE_SCALAR) { if (op_type == OP_TYPE_SCALAR) {
return PORT_TYPE_SCALAR; return PORT_TYPE_SCALAR;
} }
return PORT_TYPE_VECTOR; return PORT_TYPE_VECTOR;
@ -5191,7 +5191,7 @@ int VisualShaderNodeMultiplyAdd::get_output_port_count() const {
} }
VisualShaderNodeMultiplyAdd::PortType VisualShaderNodeMultiplyAdd::get_output_port_type(int p_port) const { VisualShaderNodeMultiplyAdd::PortType VisualShaderNodeMultiplyAdd::get_output_port_type(int p_port) const {
if (type == TYPE_SCALAR) { if (op_type == OP_TYPE_SCALAR) {
return PORT_TYPE_SCALAR; return PORT_TYPE_SCALAR;
} else { } else {
return PORT_TYPE_VECTOR; return PORT_TYPE_VECTOR;
@ -5206,10 +5206,10 @@ String VisualShaderNodeMultiplyAdd::generate_code(Shader::Mode p_mode, VisualSha
return "\t" + p_output_vars[0] + " = fma(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n"; return "\t" + p_output_vars[0] + " = fma(" + p_input_vars[0] + ", " + p_input_vars[1] + ", " + p_input_vars[2] + ");\n";
} }
void VisualShaderNodeMultiplyAdd::set_type(Type p_type) { void VisualShaderNodeMultiplyAdd::set_op_type(OpType p_op_type) {
ERR_FAIL_INDEX((int)p_type, TYPE_MAX); ERR_FAIL_INDEX((int)p_op_type, OP_TYPE_MAX);
if (p_type != type) { if (p_op_type != op_type) {
if (p_type == TYPE_SCALAR) { if (p_op_type == OP_TYPE_SCALAR) {
set_input_port_default_value(0, 0.0); set_input_port_default_value(0, 0.0);
set_input_port_default_value(1, 0.0); set_input_port_default_value(1, 0.0);
set_input_port_default_value(2, 0.0); set_input_port_default_value(2, 0.0);
@ -5219,29 +5219,29 @@ void VisualShaderNodeMultiplyAdd::set_type(Type p_type) {
set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0)); set_input_port_default_value(2, Vector3(0.0, 0.0, 0.0));
} }
} }
type = p_type; op_type = p_op_type;
emit_changed(); emit_changed();
} }
VisualShaderNodeMultiplyAdd::Type VisualShaderNodeMultiplyAdd::get_type() const { VisualShaderNodeMultiplyAdd::OpType VisualShaderNodeMultiplyAdd::get_op_type() const {
return type; return op_type;
} }
Vector<StringName> VisualShaderNodeMultiplyAdd::get_editable_properties() const { Vector<StringName> VisualShaderNodeMultiplyAdd::get_editable_properties() const {
Vector<StringName> props; Vector<StringName> props;
props.push_back("type"); props.push_back("op_type");
return props; return props;
} }
void VisualShaderNodeMultiplyAdd::_bind_methods() { void VisualShaderNodeMultiplyAdd::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_type", "type"), &VisualShaderNodeMultiplyAdd::set_type); ClassDB::bind_method(D_METHOD("set_op_type", "type"), &VisualShaderNodeMultiplyAdd::set_op_type);
ClassDB::bind_method(D_METHOD("get_type"), &VisualShaderNodeMultiplyAdd::get_type); ClassDB::bind_method(D_METHOD("get_op_type"), &VisualShaderNodeMultiplyAdd::get_op_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "type", PROPERTY_HINT_ENUM, "Scalar,Vector"), "set_type", "get_type"); ADD_PROPERTY(PropertyInfo(Variant::INT, "op_type", PROPERTY_HINT_ENUM, "Scalar,Vector"), "set_op_type", "get_op_type");
BIND_ENUM_CONSTANT(TYPE_SCALAR); BIND_ENUM_CONSTANT(OP_TYPE_SCALAR);
BIND_ENUM_CONSTANT(TYPE_VECTOR); BIND_ENUM_CONSTANT(OP_TYPE_VECTOR);
BIND_ENUM_CONSTANT(TYPE_MAX); BIND_ENUM_CONSTANT(OP_TYPE_MAX);
} }
VisualShaderNodeMultiplyAdd::VisualShaderNodeMultiplyAdd() { VisualShaderNodeMultiplyAdd::VisualShaderNodeMultiplyAdd() {

View file

@ -2121,14 +2121,14 @@ class VisualShaderNodeMultiplyAdd : public VisualShaderNode {
GDCLASS(VisualShaderNodeMultiplyAdd, VisualShaderNode); GDCLASS(VisualShaderNodeMultiplyAdd, VisualShaderNode);
public: public:
enum Type { enum OpType {
TYPE_SCALAR, OP_TYPE_SCALAR,
TYPE_VECTOR, OP_TYPE_VECTOR,
TYPE_MAX, OP_TYPE_MAX,
}; };
protected: protected:
Type type = TYPE_SCALAR; OpType op_type = OP_TYPE_SCALAR;
protected: protected:
static void _bind_methods(); static void _bind_methods();
@ -2146,14 +2146,14 @@ public:
virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
void set_type(Type p_type); void set_op_type(OpType p_type);
Type get_type() const; OpType get_op_type() const;
virtual Vector<StringName> get_editable_properties() const override; virtual Vector<StringName> get_editable_properties() const override;
VisualShaderNodeMultiplyAdd(); VisualShaderNodeMultiplyAdd();
}; };
VARIANT_ENUM_CAST(VisualShaderNodeMultiplyAdd::Type) VARIANT_ENUM_CAST(VisualShaderNodeMultiplyAdd::OpType)
#endif // VISUAL_SHADER_NODES_H #endif // VISUAL_SHADER_NODES_H