forked from blender/blender
Implement type conversion for NodeItem #9
@ -12,38 +12,38 @@ namespace blender::nodes::materialx {
|
||||
|
||||
NodeItem::NodeItem(MaterialX::GraphElement *graph) : graph_(graph) {}
|
||||
|
||||
NodeItem::Type NodeItem::type(const std::string &mx_type)
|
||||
NodeItem::Type NodeItem::type(const std::string &type_str)
|
||||
{
|
||||
if (mx_type == "string") {
|
||||
if (type_str == "string") {
|
||||
return Type::String;
|
||||
}
|
||||
if (mx_type == "integer") {
|
||||
if (type_str == "integer") {
|
||||
return Type::Integer;
|
||||
}
|
||||
if (mx_type == "float") {
|
||||
if (type_str == "float") {
|
||||
return Type::Float;
|
||||
}
|
||||
if (mx_type == "vector2") {
|
||||
if (type_str == "vector2") {
|
||||
return Type::Vector2;
|
||||
}
|
||||
if (mx_type == "vector3") {
|
||||
if (type_str == "vector3") {
|
||||
return Type::Vector3;
|
||||
}
|
||||
if (mx_type == "vector4") {
|
||||
if (type_str == "vector4") {
|
||||
return Type::Vector4;
|
||||
}
|
||||
if (mx_type == "color3") {
|
||||
if (type_str == "color3") {
|
||||
return Type::Color3;
|
||||
}
|
||||
if (mx_type == "color4") {
|
||||
if (type_str == "color4") {
|
||||
return Type::Color4;
|
||||
}
|
||||
return Type::Other;
|
||||
}
|
||||
|
||||
std::string NodeItem::type(Type mx_type)
|
||||
std::string NodeItem::type(Type tp)
|
||||
{
|
||||
switch (mx_type) {
|
||||
switch (tp) {
|
||||
case Type::String:
|
||||
return "string";
|
||||
case Type::Integer:
|
||||
@ -61,8 +61,9 @@ std::string NodeItem::type(Type mx_type)
|
||||
case Type::Color4:
|
||||
return "color4";
|
||||
default:
|
||||
return "";
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
NodeItem NodeItem::empty() const
|
||||
@ -119,15 +120,15 @@ void NodeItem::set_input(const std::string &name,
|
||||
|
||||
void NodeItem::set_input(const std::string &name,
|
||||
const NodeItem &item,
|
||||
Type to_type,
|
||||
Type in_type,
|
||||
const std::string &output_name)
|
||||
{
|
||||
set_input(name, item.convert(to_type), output_name);
|
||||
set_input(name, item.convert(in_type), output_name);
|
||||
}
|
||||
|
||||
void NodeItem::add_output(const std::string &name, const std::string &mx_type)
|
||||
void NodeItem::add_output(const std::string &name, Type out_type)
|
||||
{
|
||||
node->addOutput(name, mx_type);
|
||||
node->addOutput(name, type(out_type));
|
||||
}
|
||||
|
||||
NodeItem::operator bool() const
|
||||
|
@ -24,22 +24,22 @@ class NodeItem {
|
||||
NodeItem(MaterialX::GraphElement *graph);
|
||||
~NodeItem() = default;
|
||||
BogdanNagirniak marked this conversation as resolved
Outdated
|
||||
|
||||
static Type type(const std::string &mx_type);
|
||||
static std::string type(Type mx_type);
|
||||
static Type type(const std::string &type_str);
|
||||
static std::string type(Type tp);
|
||||
|
||||
NodeItem empty() const;
|
||||
template<class T> NodeItem val(const T &data) const;
|
||||
|
||||
template<class T>
|
||||
void set_input(const std::string &name, const T &value, const std::string &mx_type);
|
||||
void set_input(const std::string &name,
|
||||
void set_input(const std::string &in_name, const T &value, const std::string &in_type);
|
||||
void set_input(const std::string &in_name,
|
||||
const NodeItem &item,
|
||||
const std::string &output_name = "");
|
||||
void set_input(const std::string &name,
|
||||
const std::string &out_name = "");
|
||||
void set_input(const std::string &in_name,
|
||||
BogdanNagirniak marked this conversation as resolved
Georgiy Markelov
commented
Suggest add Suggest add `#pragma region` for such places
Bogdan Nagirniak
commented
It is not commonly used in Blender code It is not commonly used in Blender code
|
||||
const NodeItem &item,
|
||||
Type to_type,
|
||||
const std::string &output_name = "");
|
||||
void add_output(const std::string &name, const std::string &mx_type);
|
||||
Type in_type,
|
||||
const std::string &out_name = "");
|
||||
void add_output(const std::string &in_name, Type out_type);
|
||||
|
||||
operator bool() const;
|
||||
NodeItem operator+(const NodeItem &other) const;
|
||||
@ -106,9 +106,9 @@ template<class T> NodeItem NodeItem::val(const T &data) const
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void NodeItem::set_input(const std::string &name, const T &value, const std::string &mx_type)
|
||||
void NodeItem::set_input(const std::string &in_name, const T &value, const std::string &in_type)
|
||||
{
|
||||
node->setInputValue(name, value, mx_type);
|
||||
node->setInputValue(in_name, value, in_type);
|
||||
}
|
||||
|
||||
} // namespace blender::nodes::materialx
|
||||
|
@ -20,8 +20,8 @@ NodeItem TexCheckerNodeParser::compute()
|
||||
|
||||
NodeItem separate = create_node("separate2", "multioutput");
|
||||
separate.set_input("in", vector);
|
||||
separate.add_output("outx", "float");
|
||||
separate.add_output("outy", "float");
|
||||
separate.add_output("outx", NodeItem::Type::Float);
|
||||
separate.add_output("outy", NodeItem::Type::Float);
|
||||
|
||||
NodeItem modulo_x = create_node("modulo", "float");
|
||||
modulo_x.set_input("in1", separate, "outx");
|
||||
|
Loading…
Reference in New Issue
Block a user
IfType -> ComparisonType